Merge branch 'ethereum:master' into portal

This commit is contained in:
Chen Kai 2024-07-24 22:22:46 +08:00 committed by GitHub
commit 5bf4c2b2a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 76 additions and 14 deletions

View file

@ -42,6 +42,7 @@ import (
"github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/txpool/blobpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
@ -1625,6 +1626,18 @@ func setTxPool(ctx *cli.Context, cfg *legacypool.Config) {
} }
} }
func setBlobPool(ctx *cli.Context, cfg *blobpool.Config) {
if ctx.IsSet(BlobPoolDataDirFlag.Name) {
cfg.Datadir = ctx.String(BlobPoolDataDirFlag.Name)
}
if ctx.IsSet(BlobPoolDataCapFlag.Name) {
cfg.Datacap = ctx.Uint64(BlobPoolDataCapFlag.Name)
}
if ctx.IsSet(BlobPoolPriceBumpFlag.Name) {
cfg.PriceBump = ctx.Uint64(BlobPoolPriceBumpFlag.Name)
}
}
func setMiner(ctx *cli.Context, cfg *miner.Config) { func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.Bool(MiningEnabledFlag.Name) { if ctx.Bool(MiningEnabledFlag.Name) {
log.Warn("The flag --mine is deprecated and will be removed") log.Warn("The flag --mine is deprecated and will be removed")
@ -1726,6 +1739,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
setEtherbase(ctx, cfg) setEtherbase(ctx, cfg)
setGPO(ctx, &cfg.GPO) setGPO(ctx, &cfg.GPO)
setTxPool(ctx, &cfg.TxPool) setTxPool(ctx, &cfg.TxPool)
setBlobPool(ctx, &cfg.BlobPool)
setMiner(ctx, &cfg.Miner) setMiner(ctx, &cfg.Miner)
setRequiredBlocks(ctx, cfg) setRequiredBlocks(ctx, cfg)
setLes(ctx, cfg) setLes(ctx, cfg)

View file

@ -471,20 +471,28 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) {
// storage. This function should only be used for debugging and the mutations // storage. This function should only be used for debugging and the mutations
// must be discarded afterwards. // must be discarded afterwards.
func (s *StateDB) SetStorage(addr common.Address, storage map[common.Hash]common.Hash) { func (s *StateDB) SetStorage(addr common.Address, storage map[common.Hash]common.Hash) {
// SetStorage needs to wipe existing storage. We achieve this by pretending // SetStorage needs to wipe the existing storage. We achieve this by marking
// that the account self-destructed earlier in this block, by flagging // the account as self-destructed in this block. The effect is that storage
// it in stateObjectsDestruct. The effect of doing so is that storage lookups // lookups will not hit the disk, as it is assumed that the disk data belongs
// will not hit disk, since it is assumed that the disk-data is belonging
// to a previous incarnation of the object. // to a previous incarnation of the object.
// //
// TODO(rjl493456442) this function should only be supported by 'unwritable' // TODO (rjl493456442): This function should only be supported by 'unwritable'
// state and all mutations made should all be discarded afterwards. // state, and all mutations made should be discarded afterward.
if _, ok := s.stateObjectsDestruct[addr]; !ok { obj := s.getStateObject(addr)
s.stateObjectsDestruct[addr] = nil if obj != nil {
if _, ok := s.stateObjectsDestruct[addr]; !ok {
s.stateObjectsDestruct[addr] = obj
}
} }
stateObject := s.getOrNewStateObject(addr) newObj := s.createObject(addr)
for k, v := range storage { for k, v := range storage {
stateObject.SetState(k, v) newObj.SetState(k, v)
}
// Inherit the metadata of original object if it was existent
if obj != nil {
newObj.SetCode(common.BytesToHash(obj.CodeHash()), obj.code)
newObj.SetNonce(obj.Nonce())
newObj.SetBalance(obj.Balance(), tracing.BalanceChangeUnspecified)
} }
} }
@ -1158,6 +1166,10 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
// Finalize any pending changes and merge everything into the tries // Finalize any pending changes and merge everything into the tries
s.IntermediateRoot(deleteEmptyObjects) s.IntermediateRoot(deleteEmptyObjects)
// Short circuit if any error occurs within the IntermediateRoot.
if s.dbErr != nil {
return nil, fmt.Errorf("commit aborted due to database error: %v", s.dbErr)
}
// Commit objects to the trie, measuring the elapsed time // Commit objects to the trie, measuring the elapsed time
var ( var (
accountTrieNodesUpdated int accountTrieNodesUpdated int

View file

@ -2,7 +2,7 @@
All notable changes to the tracing interface will be documented in this file. All notable changes to the tracing interface will be documented in this file.
## [Unreleased] ## [v1.14.3]
There have been minor backwards-compatible changes to the tracing interface to explicitly mark the execution of **system** contracts. As of now the only system call updates the parent beacon block root as per [EIP-4788](https://eips.ethereum.org/EIPS/eip-4788). Other system calls are being considered for the future hardfork. There have been minor backwards-compatible changes to the tracing interface to explicitly mark the execution of **system** contracts. As of now the only system call updates the parent beacon block root as per [EIP-4788](https://eips.ethereum.org/EIPS/eip-4788). Other system calls are being considered for the future hardfork.
@ -77,3 +77,4 @@ The hooks `CaptureStart` and `CaptureEnd` have been removed. These hooks signale
[unreleased]: https://github.com/ethereum/go-ethereum/compare/v1.14.0...master [unreleased]: https://github.com/ethereum/go-ethereum/compare/v1.14.0...master
[v1.14.0]: https://github.com/ethereum/go-ethereum/releases/tag/v1.14.0 [v1.14.0]: https://github.com/ethereum/go-ethereum/releases/tag/v1.14.0
[v1.14.3]: https://github.com/ethereum/go-ethereum/releases/tag/v1.14.3

View file

@ -201,7 +201,7 @@ type ValidationOptionsWithState struct {
// rules without duplicating code and running the risk of missed updates. // rules without duplicating code and running the risk of missed updates.
func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, opts *ValidationOptionsWithState) error { func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, opts *ValidationOptionsWithState) error {
// Ensure the transaction adheres to nonce ordering // Ensure the transaction adheres to nonce ordering
from, err := signer.Sender(tx) // already validated (and cached), but cleaner to check from, err := types.Sender(signer, tx) // already validated (and cached), but cleaner to check
if err != nil { if err != nil {
log.Error("Transaction sender recovery failed", "err", err) log.Error("Transaction sender recovery failed", "err", err)
return err return err

View file

@ -781,15 +781,24 @@ func TestEstimateGas(t *testing.T) {
func TestCall(t *testing.T) { func TestCall(t *testing.T) {
t.Parallel() t.Parallel()
// Initialize test accounts // Initialize test accounts
var ( var (
accounts = newAccounts(3) accounts = newAccounts(3)
dad = common.HexToAddress("0x0000000000000000000000000000000000000dad")
genesis = &core.Genesis{ genesis = &core.Genesis{
Config: params.MergedTestChainConfig, Config: params.MergedTestChainConfig,
Alloc: types.GenesisAlloc{ Alloc: types.GenesisAlloc{
accounts[0].addr: {Balance: big.NewInt(params.Ether)}, accounts[0].addr: {Balance: big.NewInt(params.Ether)},
accounts[1].addr: {Balance: big.NewInt(params.Ether)}, accounts[1].addr: {Balance: big.NewInt(params.Ether)},
accounts[2].addr: {Balance: big.NewInt(params.Ether)}, accounts[2].addr: {Balance: big.NewInt(params.Ether)},
dad: {
Balance: big.NewInt(params.Ether),
Nonce: 1,
Storage: map[common.Hash]common.Hash{
common.Hash{}: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"),
},
},
}, },
} }
genBlocks = 10 genBlocks = 10
@ -949,6 +958,32 @@ func TestCall(t *testing.T) {
}, },
want: "0x0122000000000000000000000000000000000000000000000000000000000000", want: "0x0122000000000000000000000000000000000000000000000000000000000000",
}, },
// Clear the entire storage set
{
blockNumber: rpc.LatestBlockNumber,
call: TransactionArgs{
From: &accounts[1].addr,
// Yul:
// object "Test" {
// code {
// let dad := 0x0000000000000000000000000000000000000dad
// if eq(balance(dad), 0) {
// revert(0, 0)
// }
// let slot := sload(0)
// mstore(0, slot)
// return(0, 32)
// }
// }
Input: hex2Bytes("610dad6000813103600f57600080fd5b6000548060005260206000f3"),
},
overrides: StateOverride{
dad: OverrideAccount{
State: &map[common.Hash]common.Hash{},
},
},
want: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
} }
for i, tc := range testSuite { for i, tc := range testSuite {
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides) result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)

View file

@ -78,7 +78,7 @@ func (r *reader) Node(owner common.Hash, path []byte, hash common.Hash) ([]byte,
if len(blob) > 0 { if len(blob) > 0 {
blobHex = hexutil.Encode(blob) blobHex = hexutil.Encode(blob)
} }
log.Error("Unexpected trie node", "location", loc.loc, "owner", owner, "path", path, "expect", hash, "got", got, "blob", blobHex) log.Error("Unexpected trie node", "location", loc.loc, "owner", owner.Hex(), "path", path, "expect", hash.Hex(), "got", got.Hex(), "blob", blobHex)
return nil, fmt.Errorf("unexpected node: (%x %v), %x!=%x, %s, blob: %s", owner, path, hash, got, loc.string(), blobHex) return nil, fmt.Errorf("unexpected node: (%x %v), %x!=%x, %s, blob: %s", owner, path, hash, got, loc.string(), blobHex)
} }
return blob, nil return blob, nil