diff --git a/core/blockchain.go b/core/blockchain.go index 9292296384..6c453b095d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -46,6 +46,7 @@ import ( "github.com/ava-labs/libevm/core/vm" "github.com/ava-labs/libevm/ethdb" "github.com/ava-labs/libevm/event" + "github.com/ava-labs/libevm/libevm/stateconf" "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/metrics" "github.com/ava-labs/libevm/trie" @@ -1760,8 +1761,8 @@ func (bc *BlockChain) commitWithSnap( ) (common.Hash, error) { // blockHashes must be passed through [state.StateDB]'s Commit since snapshots // are based on the block hash. - blockHashes := snapshot.WithBlockHashes(current.Hash(), current.ParentHash()) - root, err := statedb.Commit(current.NumberU64(), bc.chainConfig.IsEIP158(current.Number()), blockHashes) + snapshotOpt := snapshot.WithBlockHashes(current.Hash(), current.ParentHash()) + root, err := statedb.Commit(current.NumberU64(), bc.chainConfig.IsEIP158(current.Number()), stateconf.WithSnapshotUpdateOpts(snapshotOpt)) if err != nil { return common.Hash{}, err } @@ -1769,7 +1770,7 @@ func (bc *BlockChain) commitWithSnap( // parent root, however here the snapshots are based on the block hash, so // this update is necessary. Note blockHashes are passed here as well. if bc.snaps != nil && root == parentRoot { - if err := bc.snaps.Update(root, parentRoot, nil, nil, nil, blockHashes); err != nil { + if err := bc.snaps.Update(root, parentRoot, nil, nil, nil, snapshotOpt); err != nil { return common.Hash{}, err } } diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index 4a6ccba927..53ac02fb70 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -320,7 +320,7 @@ type blockHashes struct { } func WithBlockHashes(blockHash, parentBlockHash common.Hash) stateconf.SnapshotUpdateOption { - return stateconf.WithUpdatePayload(blockHashes{blockHash, parentBlockHash}) + return stateconf.WithSnapshotUpdatePayload(blockHashes{blockHash, parentBlockHash}) } // Update adds a new snapshot into the tree, if that can be linked to an existing @@ -337,7 +337,7 @@ func (t *Tree) Update( return fmt.Errorf("missing block hashes") } - payload := stateconf.ExtractUpdatePayload(opts[0]) + payload := stateconf.ExtractSnapshotUpdatePayload(opts[0]) p, ok := payload.(blockHashes) if !ok { return fmt.Errorf("invalid block hashes payload type: %T", payload) diff --git a/core/state/trie_prefetcher_extra_test.go b/core/state/trie_prefetcher_extra_test.go index d899cce093..e1a1232cb2 100644 --- a/core/state/trie_prefetcher_extra_test.go +++ b/core/state/trie_prefetcher_extra_test.go @@ -17,6 +17,7 @@ import ( "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/ethdb" + "github.com/ava-labs/libevm/libevm/stateconf" "github.com/ava-labs/libevm/metrics" "github.com/ava-labs/libevm/triedb" "github.com/ava-labs/subnet-evm/core/state/snapshot" @@ -183,8 +184,8 @@ func addKVs( statedb.SetState(address, common.BytesToHash(key), common.BytesToHash(value)) } } - blockHashes := snapshot.WithBlockHashes(fakeHash(block+1), fakeHash(block)) - root, err = statedb.Commit(block+1, true, blockHashes) + snapshotOpt := snapshot.WithBlockHashes(fakeHash(block+1), fakeHash(block)) + root, err = statedb.Commit(block+1, true, stateconf.WithSnapshotUpdateOpts(snapshotOpt)) if err != nil { return nil, common.Hash{}, fmt.Errorf("committing with snap: %w", err) } diff --git a/go.mod b/go.mod index 921b61c3bf..e4c47bb939 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/VictoriaMetrics/fastcache v1.12.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 github.com/ava-labs/avalanchego v1.13.2-rc.0 - github.com/ava-labs/libevm v1.13.14-0.2.0.release + github.com/ava-labs/libevm v1.13.14-0.3.0.rc.1 github.com/davecgh/go-spew v1.1.1 github.com/deckarep/golang-set/v2 v2.1.0 github.com/fjl/gencodec v0.1.1 diff --git a/go.sum b/go.sum index 625fbe42d8..02d07e69b5 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,8 @@ github.com/ava-labs/avalanchego v1.13.2-rc.0 h1:BWV5z/u6oJwRPx/zuACBbge4puhoDV38 github.com/ava-labs/avalanchego v1.13.2-rc.0/go.mod h1:BCxJWx2E1zeCDoQuH12I+B7BsrAbBpF19af4O0V7b/8= github.com/ava-labs/coreth v0.15.2-rc.0.0.20250610170140-2fcf45f828a2 h1:/E1w2S6xvEhkO2+C9sGCV8W80qaeSN5WBFqdKLl12HM= github.com/ava-labs/coreth v0.15.2-rc.0.0.20250610170140-2fcf45f828a2/go.mod h1:cqwBag+zzqifDutdPVzZKovfC2d0L8Zxq4YgTGaMCwg= -github.com/ava-labs/libevm v1.13.14-0.2.0.release h1:uKGCc5/ceeBbfAPRVtBUxbQt50WzB2pEDb8Uy93ePgQ= -github.com/ava-labs/libevm v1.13.14-0.2.0.release/go.mod h1:+Iol+sVQ1KyoBsHf3veyrBmHCXr3xXRWq6ZXkgVfNLU= +github.com/ava-labs/libevm v1.13.14-0.3.0.rc.1 h1:vBMYo+Iazw0rGTr+cwjkBdh5eadLPlv4ywI4lKye3CA= +github.com/ava-labs/libevm v1.13.14-0.3.0.rc.1/go.mod h1:+Iol+sVQ1KyoBsHf3veyrBmHCXr3xXRWq6ZXkgVfNLU= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/params/hooks_libevm.go b/params/hooks_libevm.go index 3702514eba..edbe790c93 100644 --- a/params/hooks_libevm.go +++ b/params/hooks_libevm.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/libevm/core/vm" "github.com/ava-labs/libevm/libevm" "github.com/ava-labs/libevm/libevm/legacy" + ethparams "github.com/ava-labs/libevm/params" "github.com/ava-labs/subnet-evm/params/extras" customheader "github.com/ava-labs/subnet-evm/plugin/evm/header" "github.com/ava-labs/subnet-evm/precompile/contract" @@ -52,6 +53,11 @@ func (r RulesExtra) ActivePrecompiles(existing []common.Address) []common.Addres return existing } +// MinimumGasConsumption is a no-op. +func (r RulesExtra) MinimumGasConsumption(x uint64) uint64 { + return (ethparams.NOOPHooks{}).MinimumGasConsumption(x) +} + // precompileOverrideBuiltin specifies precompiles that were activated prior to the // dynamic precompile activation registry. // These were only active historically and are not active in the current network. diff --git a/triedb/hashdb/database.go b/triedb/hashdb/database.go index 2a3bd11a16..5375d94bbf 100644 --- a/triedb/hashdb/database.go +++ b/triedb/hashdb/database.go @@ -37,6 +37,7 @@ import ( "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/ethdb" + "github.com/ava-labs/libevm/libevm/stateconf" "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/metrics" "github.com/ava-labs/libevm/rlp" @@ -649,7 +650,7 @@ func (db *Database) Initialized(genesisRoot common.Hash) bool { // account trie with multiple storage tries if necessary. // If ReferenceRootAtomicallyOnUpdate was enabled in the config, it will also add a reference from // the root to the metaroot while holding the db's lock. -func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set) error { +func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set, _ ...stateconf.TrieDBUpdateOption) error { // Ensure the parent state is present and signal a warning if not. if parent != types.EmptyRootHash { if blob, _ := db.node(parent); len(blob) == 0 { diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index f4fcdede6a..21580bfafd 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -36,6 +36,7 @@ import ( "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/ethdb" + "github.com/ava-labs/libevm/libevm/stateconf" "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/trie/trienode" "github.com/ava-labs/libevm/trie/triestate" @@ -241,7 +242,7 @@ func (db *Database) Reader(root common.Hash) (database.Reader, error) { // // The passed in maps(nodes, states) will be retained to avoid copying everything. // Therefore, these maps must not be changed afterwards. -func (db *Database) Update(root common.Hash, parentRoot common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set) error { +func (db *Database) Update(root common.Hash, parentRoot common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set, _ ...stateconf.TrieDBUpdateOption) error { // Hold the lock to prevent concurrent mutations. db.lock.Lock() defer db.lock.Unlock()