diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d40d8e0b4..895cb4884c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: path: avalanchego token: ${{ secrets.AVALANCHE_PAT }} - name: Run e2e tests - uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@84e9aebcfbc04602865f4c0a3e8b46a27409a3f5 + uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@fff1df9564d3fa86899780d73e887d9ee5b9b54e with: run: ./scripts/run_task.sh test-e2e-ci prometheus_url: ${{ secrets.PROMETHEUS_URL || '' }} @@ -132,7 +132,7 @@ jobs: ref: ${{ github.event.inputs.avalanchegoBranch }} path: avalanchego - name: Run Warp E2E Tests - uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@84e9aebcfbc04602865f4c0a3e8b46a27409a3f5 + uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@fff1df9564d3fa86899780d73e887d9ee5b9b54e with: run: ./scripts/run_task.sh test-e2e-warp-ci artifact_prefix: warp diff --git a/core/blockchain.go b/core/blockchain.go index ba97bd8df7..c72841fccc 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -42,13 +42,13 @@ import ( "time" "github.com/ava-labs/avalanchego/vms/evm/acp176" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus" "github.com/ava-labs/coreth/core/extstate" "github.com/ava-labs/coreth/core/state/snapshot" "github.com/ava-labs/coreth/internal/version" "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/plugin/evm/customlogs" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/triedb/firewood" "github.com/ava-labs/coreth/triedb/hashdb" diff --git a/core/blockchain_repair_test.go b/core/blockchain_repair_test.go index c493e367d7..0b26cce751 100644 --- a/core/blockchain_repair_test.go +++ b/core/blockchain_repair_test.go @@ -35,9 +35,9 @@ import ( "math/big" "testing" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/core/blockchain_test.go b/core/blockchain_test.go index d19c02b884..eb6195b356 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -34,10 +34,10 @@ import ( "testing" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/core/state/pruner" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/core/genesis_test.go b/core/genesis_test.go index 63a1c50b18..233a515fa4 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -36,10 +36,10 @@ import ( "reflect" "testing" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/params/extras" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/coreth/precompile/contracts/warp" "github.com/ava-labs/coreth/triedb/firewood" diff --git a/core/state/pruner/pruner.go b/core/state/pruner/pruner.go index 43fc954a4f..0c3f30f21b 100644 --- a/core/state/pruner/pruner.go +++ b/core/state/pruner/pruner.go @@ -38,8 +38,8 @@ import ( "strings" "time" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/core/state/snapshot" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/core/state/snapshot/disklayer_test.go b/core/state/snapshot/disklayer_test.go index bc501ed600..73545d9c1b 100644 --- a/core/state/snapshot/disklayer_test.go +++ b/core/state/snapshot/disklayer_test.go @@ -31,7 +31,7 @@ import ( "bytes" "testing" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb/memorydb" diff --git a/core/state/snapshot/generate.go b/core/state/snapshot/generate.go index 49b02f46d2..a6264ccfa8 100644 --- a/core/state/snapshot/generate.go +++ b/core/state/snapshot/generate.go @@ -32,7 +32,7 @@ import ( "fmt" "time" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/core/state/snapshot/journal.go b/core/state/snapshot/journal.go index 23c1b2aba0..f2c3e57a3b 100644 --- a/core/state/snapshot/journal.go +++ b/core/state/snapshot/journal.go @@ -33,7 +33,7 @@ import ( "fmt" "time" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb" diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index 62e3d7b681..dc66972d5a 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -35,7 +35,7 @@ import ( "sync" "time" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" ethsnapshot "github.com/ava-labs/libevm/core/state/snapshot" diff --git a/core/state/snapshot/wipe.go b/core/state/snapshot/wipe.go index af03b8ab43..d427231079 100644 --- a/core/state/snapshot/wipe.go +++ b/core/state/snapshot/wipe.go @@ -31,7 +31,7 @@ import ( "bytes" "time" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb" diff --git a/core/state/snapshot/wipe_test.go b/core/state/snapshot/wipe_test.go index ca0b5ca6d2..b925303d91 100644 --- a/core/state/snapshot/wipe_test.go +++ b/core/state/snapshot/wipe_test.go @@ -31,7 +31,7 @@ import ( "math/rand" "testing" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb/memorydb" diff --git a/core/state_manager.go b/core/state_manager.go index 0f1b5844d0..d83302ffbc 100644 --- a/core/state_manager.go +++ b/core/state_manager.go @@ -30,7 +30,7 @@ package core import ( "fmt" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/ethdb" diff --git a/eth/api_debug.go b/eth/api_debug.go index 19b88ce16b..8fcf865223 100644 --- a/eth/api_debug.go +++ b/eth/api_debug.go @@ -33,8 +33,8 @@ import ( "fmt" "time" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/internal/ethapi" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/hexutil" diff --git a/eth/backend.go b/eth/backend.go index 7c3c3af424..309429afaf 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -36,6 +36,7 @@ import ( "time" "github.com/ava-labs/avalanchego/utils/timer/mockable" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/bloombits" @@ -51,7 +52,6 @@ import ( "github.com/ava-labs/coreth/miner" "github.com/ava-labs/coreth/node" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/libevm/accounts" "github.com/ava-labs/libevm/common" diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 97802296dd..27bf436045 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -39,12 +39,12 @@ import ( "testing" "time" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/bloombits" "github.com/ava-labs/coreth/internal/ethapi" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/rpc" ethereum "github.com/ava-labs/libevm" diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go index b0fbd5a86f..507d9dc049 100644 --- a/eth/filters/filter_test.go +++ b/eth/filters/filter_test.go @@ -35,11 +35,11 @@ import ( "testing" "time" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/accounts/abi" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/eth/state_accessor.go b/eth/state_accessor.go index 8542ff14b2..a14cb6396c 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -33,10 +33,10 @@ import ( "fmt" "time" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/extstate" "github.com/ava-labs/coreth/eth/tracers" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/state" diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index c81f897dd8..82efb862c7 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -38,12 +38,12 @@ import ( "sync/atomic" "testing" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/consensus" "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/internal/ethapi" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/hexutil" diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index 5bc7a203f9..85f7a0f9f5 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -32,9 +32,9 @@ import ( "os" "testing" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/tests" "github.com/ava-labs/libevm/common" diff --git a/go.mod b/go.mod index 2760703e4d..c362e6c734 100644 --- a/go.mod +++ b/go.mod @@ -11,11 +11,11 @@ module github.com/ava-labs/coreth // // - If updating between minor versions (e.g. 1.24.x -> 1.25.x): // - Consider updating the version of golangci-lint (see tools/go.mod) -go 1.24.7 +go 1.24.8 require ( github.com/VictoriaMetrics/fastcache v1.12.1 - github.com/ava-labs/avalanchego v1.13.6-0.20251003124629-84e9aebcfbc0 + github.com/ava-labs/avalanchego v1.13.6-0.20251008120019-fff1df9564d3 github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12 github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc diff --git a/go.sum b/go.sum index 8880cb2ebf..91c9fc0ddd 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/ava-labs/avalanchego v1.13.6-0.20251003124629-84e9aebcfbc0 h1:B3ti+6P0r7V6BZw5PG7nP7hZ4AJj/1tSsmOOAwnonhs= -github.com/ava-labs/avalanchego v1.13.6-0.20251003124629-84e9aebcfbc0/go.mod h1:yplWYV/FzAZeYAhy0yOj8wjJA1PCdTPxQf8Wzpwg6DY= +github.com/ava-labs/avalanchego v1.13.6-0.20251008120019-fff1df9564d3 h1:PExdlCEpGaAg75iIlWYBYFtUeqiyBityzAjRiZ5nm4M= +github.com/ava-labs/avalanchego v1.13.6-0.20251008120019-fff1df9564d3/go.mod h1:EL0MGbL2liE9jp4QtCHR2thkNl8hCkD26DJ+7cmcaqs= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12 h1:aMcrLbpJ/dyu2kZDf/Di/4JIWsUcYPyTDKymiHpejt0= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12/go.mod h1:cq89ua3iiZ5wPBALTEQS5eG8DIZcs7ov6OiL4YR1BVY= github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661 h1:lt4yQE1HMvxWrdD5RFj+h9kWUsZK2rmNohvkeQsbG9M= diff --git a/plugin/evm/customrawdb/accessors_metadata_ext.go b/plugin/evm/customrawdb/accessors_metadata_ext.go deleted file mode 100644 index 709ea157ff..0000000000 --- a/plugin/evm/customrawdb/accessors_metadata_ext.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "fmt" - "time" - - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/ethdb" - "github.com/ava-labs/libevm/rlp" -) - -// writeCurrentTimeMarker writes a marker of the current time in the db at `key`. -func writeCurrentTimeMarker(db ethdb.KeyValueStore, key []byte) error { - data, err := rlp.EncodeToBytes(uint64(time.Now().Unix())) - if err != nil { - return err - } - return db.Put(key, data) -} - -// readTimeMarker reads the timestamp stored at `key` -func readTimeMarker(db ethdb.KeyValueStore, key []byte) (time.Time, error) { - data, err := db.Get(key) - if err != nil { - return time.Time{}, err - } - - var unix uint64 - if err := rlp.DecodeBytes(data, &unix); err != nil { - return time.Time{}, err - } - - return time.Unix(int64(unix), 0), nil -} - -// WriteOfflinePruning writes a time marker of the last attempt to run offline pruning. -// The marker is written when offline pruning completes and is deleted when the node -// is started successfully with offline pruning disabled. This ensures users must -// disable offline pruning and start their node successfully between runs of offline -// pruning. -func WriteOfflinePruning(db ethdb.KeyValueStore) error { - return writeCurrentTimeMarker(db, offlinePruningKey) -} - -// ReadOfflinePruning reads the most recent timestamp of an attempt to run offline -// pruning if present. -func ReadOfflinePruning(db ethdb.KeyValueStore) (time.Time, error) { - return readTimeMarker(db, offlinePruningKey) -} - -// DeleteOfflinePruning deletes any marker of the last attempt to run offline pruning. -func DeleteOfflinePruning(db ethdb.KeyValueStore) error { - return db.Delete(offlinePruningKey) -} - -// WritePopulateMissingTries writes a marker for the current attempt to populate -// missing tries. -func WritePopulateMissingTries(db ethdb.KeyValueStore) error { - return writeCurrentTimeMarker(db, populateMissingTriesKey) -} - -// ReadPopulateMissingTries reads the most recent timestamp of an attempt to -// re-populate missing trie nodes. -func ReadPopulateMissingTries(db ethdb.KeyValueStore) (time.Time, error) { - return readTimeMarker(db, populateMissingTriesKey) -} - -// DeletePopulateMissingTries deletes any marker of the last attempt to -// re-populate missing trie nodes. -func DeletePopulateMissingTries(db ethdb.KeyValueStore) error { - return db.Delete(populateMissingTriesKey) -} - -// WritePruningDisabled writes a marker to track whether the node has ever run -// with pruning disabled. -func WritePruningDisabled(db ethdb.KeyValueStore) error { - return db.Put(pruningDisabledKey, nil) -} - -// HasPruningDisabled returns true if there is a marker present indicating that -// the node has run with pruning disabled at some pooint. -func HasPruningDisabled(db ethdb.KeyValueStore) (bool, error) { - return db.Has(pruningDisabledKey) -} - -// WriteAcceptorTip writes `hash` as the last accepted block that has been fully processed. -func WriteAcceptorTip(db ethdb.KeyValueWriter, hash common.Hash) error { - return db.Put(acceptorTipKey, hash[:]) -} - -// ReadAcceptorTip reads the hash of the last accepted block that was fully processed. -// If there is no value present (the index is being initialized for the first time), then the -// empty hash is returned. -func ReadAcceptorTip(db ethdb.KeyValueReader) (common.Hash, error) { - has, err := db.Has(acceptorTipKey) - if err != nil { - return common.Hash{}, err - } - if !has { - // If the index is not present on disk, the [acceptorTipKey] index has not been initialized yet. - return common.Hash{}, nil - } - h, err := db.Get(acceptorTipKey) - if err != nil { - return common.Hash{}, err - } - if len(h) != common.HashLength { - return common.Hash{}, fmt.Errorf("value has incorrect length %d", len(h)) - } - return common.BytesToHash(h), nil -} diff --git a/plugin/evm/customrawdb/accessors_snapshot_ext.go b/plugin/evm/customrawdb/accessors_snapshot_ext.go deleted file mode 100644 index cd1ab1a926..0000000000 --- a/plugin/evm/customrawdb/accessors_snapshot_ext.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/rawdb" - "github.com/ava-labs/libevm/ethdb" - "github.com/ava-labs/libevm/log" -) - -// ReadSnapshotBlockHash retrieves the hash of the block whose state is contained in -// the persisted snapshot. -func ReadSnapshotBlockHash(db ethdb.KeyValueReader) common.Hash { - data, _ := db.Get(snapshotBlockHashKey) - if len(data) != common.HashLength { - return common.Hash{} - } - return common.BytesToHash(data) -} - -// WriteSnapshotBlockHash stores the root of the block whose state is contained in -// the persisted snapshot. -func WriteSnapshotBlockHash(db ethdb.KeyValueWriter, blockHash common.Hash) { - if err := db.Put(snapshotBlockHashKey, blockHash[:]); err != nil { - log.Crit("Failed to store snapshot block hash", "err", err) - } -} - -// DeleteSnapshotBlockHash deletes the hash of the block whose state is contained in -// the persisted snapshot. Since snapshots are not immutable, this method can -// be used during updates, so a crash or failure will mark the entire snapshot -// invalid. -func DeleteSnapshotBlockHash(db ethdb.KeyValueWriter) { - if err := db.Delete(snapshotBlockHashKey); err != nil { - log.Crit("Failed to remove snapshot block hash", "err", err) - } -} - -// IterateAccountSnapshots returns an iterator for walking all of the accounts in the snapshot -func IterateAccountSnapshots(db ethdb.Iteratee) ethdb.Iterator { - it := db.NewIterator(rawdb.SnapshotAccountPrefix, nil) - keyLen := len(rawdb.SnapshotAccountPrefix) + common.HashLength - return rawdb.NewKeyLengthIterator(it, keyLen) -} diff --git a/plugin/evm/customrawdb/accessors_state_sync.go b/plugin/evm/customrawdb/accessors_state_sync.go deleted file mode 100644 index ad9c88f093..0000000000 --- a/plugin/evm/customrawdb/accessors_state_sync.go +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "encoding/binary" - - "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/rawdb" - "github.com/ava-labs/libevm/ethdb" - "github.com/ava-labs/libevm/log" -) - -// ReadSyncRoot reads the root corresponding to the main trie of an in-progress -// sync and returns common.Hash{} if no in-progress sync was found. -func ReadSyncRoot(db ethdb.KeyValueReader) (common.Hash, error) { - has, err := db.Has(syncRootKey) - if err != nil || !has { - return common.Hash{}, err - } - root, err := db.Get(syncRootKey) - if err != nil { - return common.Hash{}, err - } - return common.BytesToHash(root), nil -} - -// WriteSyncRoot writes root as the root of the main trie of the in-progress sync. -func WriteSyncRoot(db ethdb.KeyValueWriter, root common.Hash) error { - return db.Put(syncRootKey, root[:]) -} - -// AddCodeToFetch adds a marker that we need to fetch the code for `hash`. -func AddCodeToFetch(db ethdb.KeyValueWriter, hash common.Hash) { - if err := db.Put(codeToFetchKey(hash), nil); err != nil { - log.Crit("Failed to put code to fetch", "codeHash", hash, "err", err) - } -} - -// DeleteCodeToFetch removes the marker that the code corresponding to `hash` needs to be fetched. -func DeleteCodeToFetch(db ethdb.KeyValueWriter, hash common.Hash) { - if err := db.Delete(codeToFetchKey(hash)); err != nil { - log.Crit("Failed to delete code to fetch", "codeHash", hash, "err", err) - } -} - -// NewCodeToFetchIterator returns a KeyLength iterator over all code -// hashes that are pending syncing. It is the caller's responsibility to -// unpack the key and call Release on the returned iterator. -func NewCodeToFetchIterator(db ethdb.Iteratee) ethdb.Iterator { - return rawdb.NewKeyLengthIterator( - db.NewIterator(CodeToFetchPrefix, nil), - codeToFetchKeyLength, - ) -} - -func codeToFetchKey(hash common.Hash) []byte { - codeToFetchKey := make([]byte, codeToFetchKeyLength) - copy(codeToFetchKey, CodeToFetchPrefix) - copy(codeToFetchKey[len(CodeToFetchPrefix):], hash[:]) - return codeToFetchKey -} - -// NewSyncSegmentsIterator returns a KeyLength iterator over all trie segments -// added for root. It is the caller's responsibility to unpack the key and call -// Release on the returned iterator. -func NewSyncSegmentsIterator(db ethdb.Iteratee, root common.Hash) ethdb.Iterator { - segmentsPrefix := make([]byte, len(syncSegmentsPrefix)+common.HashLength) - copy(segmentsPrefix, syncSegmentsPrefix) - copy(segmentsPrefix[len(syncSegmentsPrefix):], root[:]) - - return rawdb.NewKeyLengthIterator( - db.NewIterator(segmentsPrefix, nil), - syncSegmentsKeyLength, - ) -} - -// WriteSyncSegment adds a trie segment for root at the given start position. -func WriteSyncSegment(db ethdb.KeyValueWriter, root common.Hash, start common.Hash) error { - return db.Put(packSyncSegmentKey(root, start), []byte{0x01}) -} - -// ClearSyncSegments removes segment markers for root from db -func ClearSyncSegments(db ethdb.KeyValueStore, root common.Hash) error { - segmentsPrefix := make([]byte, len(syncSegmentsPrefix)+common.HashLength) - copy(segmentsPrefix, syncSegmentsPrefix) - copy(segmentsPrefix[len(syncSegmentsPrefix):], root[:]) - return clearPrefix(db, segmentsPrefix, syncSegmentsKeyLength) -} - -// ClearAllSyncSegments removes all segment markers from db -func ClearAllSyncSegments(db ethdb.KeyValueStore) error { - return clearPrefix(db, syncSegmentsPrefix, syncSegmentsKeyLength) -} - -// UnpackSyncSegmentKey returns the root and start position for a trie segment -// key returned from NewSyncSegmentsIterator. -func UnpackSyncSegmentKey(keyBytes []byte) (common.Hash, []byte) { - keyBytes = keyBytes[len(syncSegmentsPrefix):] // skip prefix - root := common.BytesToHash(keyBytes[:common.HashLength]) - start := keyBytes[common.HashLength:] - return root, start -} - -// packSyncSegmentKey packs root and account into a key for storage in db. -func packSyncSegmentKey(root common.Hash, start common.Hash) []byte { - bytes := make([]byte, syncSegmentsKeyLength) - copy(bytes, syncSegmentsPrefix) - copy(bytes[len(syncSegmentsPrefix):], root[:]) - copy(bytes[len(syncSegmentsPrefix)+common.HashLength:], start.Bytes()) - return bytes -} - -// NewSyncStorageTriesIterator returns a KeyLength iterator over all storage tries -// added for syncing (beginning at seek). It is the caller's responsibility to unpack -// the key and call Release on the returned iterator. -func NewSyncStorageTriesIterator(db ethdb.Iteratee, seek []byte) ethdb.Iterator { - return rawdb.NewKeyLengthIterator(db.NewIterator(syncStorageTriesPrefix, seek), syncStorageTriesKeyLength) -} - -// WriteSyncStorageTrie adds a storage trie for account (with the given root) to be synced. -func WriteSyncStorageTrie(db ethdb.KeyValueWriter, root common.Hash, account common.Hash) error { - return db.Put(packSyncStorageTrieKey(root, account), []byte{0x01}) -} - -// ClearSyncStorageTrie removes all storage trie accounts (with the given root) from db. -// Intended for use when the trie with root has completed syncing. -func ClearSyncStorageTrie(db ethdb.KeyValueStore, root common.Hash) error { - accountsPrefix := make([]byte, len(syncStorageTriesPrefix)+common.HashLength) - copy(accountsPrefix, syncStorageTriesPrefix) - copy(accountsPrefix[len(syncStorageTriesPrefix):], root[:]) - return clearPrefix(db, accountsPrefix, syncStorageTriesKeyLength) -} - -// ClearAllSyncStorageTries removes all storage tries added for syncing from db -func ClearAllSyncStorageTries(db ethdb.KeyValueStore) error { - return clearPrefix(db, syncStorageTriesPrefix, syncStorageTriesKeyLength) -} - -// UnpackSyncStorageTrieKey returns the root and account for a storage trie -// key returned from NewSyncStorageTriesIterator. -func UnpackSyncStorageTrieKey(keyBytes []byte) (common.Hash, common.Hash) { - keyBytes = keyBytes[len(syncStorageTriesPrefix):] // skip prefix - root := common.BytesToHash(keyBytes[:common.HashLength]) - account := common.BytesToHash(keyBytes[common.HashLength:]) - return root, account -} - -// packSyncStorageTrieKey packs root and account into a key for storage in db. -func packSyncStorageTrieKey(root common.Hash, account common.Hash) []byte { - bytes := make([]byte, 0, syncStorageTriesKeyLength) - bytes = append(bytes, syncStorageTriesPrefix...) - bytes = append(bytes, root[:]...) - bytes = append(bytes, account[:]...) - return bytes -} - -// WriteSyncPerformed logs an entry in `db` indicating the VM state synced to `blockNumber`. -func WriteSyncPerformed(db ethdb.KeyValueWriter, blockNumber uint64) error { - syncPerformedPrefixLen := len(syncPerformedPrefix) - bytes := make([]byte, syncPerformedPrefixLen+wrappers.LongLen) - copy(bytes[:syncPerformedPrefixLen], syncPerformedPrefix) - binary.BigEndian.PutUint64(bytes[syncPerformedPrefixLen:], blockNumber) - return db.Put(bytes, []byte{0x01}) -} - -// NewSyncPerformedIterator returns an iterator over all block numbers the VM -// has state synced to. -func NewSyncPerformedIterator(db ethdb.Iteratee) ethdb.Iterator { - return rawdb.NewKeyLengthIterator(db.NewIterator(syncPerformedPrefix, nil), syncPerformedKeyLength) -} - -// UnpackSyncPerformedKey returns the block number from keys the iterator returned -// from NewSyncPerformedIterator. -func UnpackSyncPerformedKey(key []byte) uint64 { - return binary.BigEndian.Uint64(key[len(syncPerformedPrefix):]) -} - -// GetLatestSyncPerformed returns the latest block number state synced performed to. -func GetLatestSyncPerformed(db ethdb.Iteratee) uint64 { - it := NewSyncPerformedIterator(db) - defer it.Release() - - var latestSyncPerformed uint64 - for it.Next() { - syncPerformed := UnpackSyncPerformedKey(it.Key()) - if syncPerformed > latestSyncPerformed { - latestSyncPerformed = syncPerformed - } - } - return latestSyncPerformed -} - -// clearPrefix removes all keys in db that begin with prefix and match an -// expected key length. `keyLen` must include the length of the prefix. -func clearPrefix(db ethdb.KeyValueStore, prefix []byte, keyLen int) error { - it := db.NewIterator(prefix, nil) - defer it.Release() - - batch := db.NewBatch() - for it.Next() { - key := common.CopyBytes(it.Key()) - if len(key) != keyLen { - continue - } - if err := batch.Delete(key); err != nil { - return err - } - if batch.ValueSize() > ethdb.IdealBatchSize { - if err := batch.Write(); err != nil { - return err - } - batch.Reset() - } - } - if err := it.Error(); err != nil { - return err - } - return batch.Write() -} diff --git a/plugin/evm/customrawdb/accessors_state_sync_test.go b/plugin/evm/customrawdb/accessors_state_sync_test.go deleted file mode 100644 index 6a57572e4f..0000000000 --- a/plugin/evm/customrawdb/accessors_state_sync_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "slices" - "testing" - - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/rawdb" - "github.com/stretchr/testify/require" -) - -func TestClearPrefix(t *testing.T) { - require := require.New(t) - db := rawdb.NewMemoryDatabase() - // add a key that should be cleared - require.NoError(WriteSyncSegment(db, common.Hash{1}, common.Hash{})) - - // add a key that should not be cleared - key := slices.Concat(syncSegmentsPrefix, []byte("foo")) - require.NoError(db.Put(key, []byte("bar"))) - - require.NoError(ClearAllSyncSegments(db)) - - count := 0 - it := db.NewIterator(syncSegmentsPrefix, nil) - defer it.Release() - for it.Next() { - count++ - } - require.NoError(it.Error()) - require.Equal(1, count) -} diff --git a/plugin/evm/customrawdb/database_ext.go b/plugin/evm/customrawdb/database_ext.go deleted file mode 100644 index c301a5bfff..0000000000 --- a/plugin/evm/customrawdb/database_ext.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "bytes" - "fmt" - - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/rawdb" - "github.com/ava-labs/libevm/ethdb" -) - -// InspectDatabase traverses the entire database and checks the size -// of all different categories of data. -func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { - type stat = rawdb.DatabaseStat - stats := []struct { - name string - keyLen int - keyPrefix []byte - stat *stat - }{ - {"Trie segments", syncSegmentsKeyLength, syncSegmentsPrefix, &stat{}}, - {"Storage tries to fetch", syncStorageTriesKeyLength, syncStorageTriesPrefix, &stat{}}, - {"Code to fetch", codeToFetchKeyLength, CodeToFetchPrefix, &stat{}}, - {"Block numbers synced to", syncPerformedKeyLength, syncPerformedPrefix, &stat{}}, - } - - options := []rawdb.InspectDatabaseOption{ - rawdb.WithDatabaseMetadataKeys(func(key []byte) bool { - return bytes.Equal(key, snapshotBlockHashKey) || - bytes.Equal(key, syncRootKey) - }), - rawdb.WithDatabaseStatRecorder(func(key []byte, size common.StorageSize) bool { - for _, s := range stats { - if len(key) == s.keyLen && bytes.HasPrefix(key, s.keyPrefix) { - s.stat.Add(size) - return true - } - } - return false - }), - rawdb.WithDatabaseStatsTransformer(func(rows [][]string) [][]string { - newRows := make([][]string, 0, len(rows)) - for _, row := range rows { - switch db, cat := row[0], row[1]; { - // Discard rows specific to libevm (geth) but irrelevant to coreth. - case db == "Key-Value store" && (cat == "Difficulties" || cat == "Beacon sync headers"): - case db == "Ancient store (Chain)": - default: - newRows = append(newRows, row) - } - } - for _, s := range stats { - newRows = append(newRows, []string{"State sync", s.name, s.stat.Size(), s.stat.Count()}) - } - return newRows - }), - } - - return rawdb.InspectDatabase(db, keyPrefix, keyStart, options...) -} - -// ParseStateSchemeExt parses the state scheme from the provided string. -func ParseStateSchemeExt(provided string, disk ethdb.Database) (string, error) { - // Check for custom scheme - if provided == FirewoodScheme { - if diskScheme := rawdb.ReadStateScheme(disk); diskScheme != "" { - // Valid scheme on disk mismatched - return "", fmt.Errorf("state scheme %s already set on disk, can't use Firewood", diskScheme) - } - // If no conflicting scheme is found, is valid. - return FirewoodScheme, nil - } - - // Check for valid eth scheme - return rawdb.ParseStateScheme(provided, disk) -} diff --git a/plugin/evm/customrawdb/database_ext_test.go b/plugin/evm/customrawdb/database_ext_test.go deleted file mode 100644 index 2b786b7f81..0000000000 --- a/plugin/evm/customrawdb/database_ext_test.go +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "fmt" - - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/rawdb" - "github.com/ava-labs/libevm/ethdb" -) - -func ExampleInspectDatabase() { - db := &stubDatabase{ - iterator: &stubIterator{}, - } - - // Extra metadata keys: (17 + 32) + (12 + 32) = 93 bytes - WriteSnapshotBlockHash(db, common.Hash{}) - rawdb.WriteSnapshotRoot(db, common.Hash{}) - // Trie segments: (77 + 2) + 1 = 80 bytes - _ = WriteSyncSegment(db, common.Hash{}, common.Hash{}) - // Storage tries to fetch: 76 + 1 = 77 bytes - _ = WriteSyncStorageTrie(db, common.Hash{}, common.Hash{}) - // Code to fetch: 34 + 0 = 34 bytes - AddCodeToFetch(db, common.Hash{}) - // Block numbers synced to: 22 + 1 = 23 bytes - _ = WriteSyncPerformed(db, 0) - - keyPrefix := []byte(nil) - keyStart := []byte(nil) - - err := InspectDatabase(db, keyPrefix, keyStart) - if err != nil { - fmt.Println(err) - } - // Output: - // +-----------------+-------------------------+----------+-------+ - // | DATABASE | CATEGORY | SIZE | ITEMS | - // +-----------------+-------------------------+----------+-------+ - // | Key-Value store | Headers | 0.00 B | 0 | - // | Key-Value store | Bodies | 0.00 B | 0 | - // | Key-Value store | Receipt lists | 0.00 B | 0 | - // | Key-Value store | Block number->hash | 0.00 B | 0 | - // | Key-Value store | Block hash->number | 0.00 B | 0 | - // | Key-Value store | Transaction index | 0.00 B | 0 | - // | Key-Value store | Bloombit index | 0.00 B | 0 | - // | Key-Value store | Contract codes | 0.00 B | 0 | - // | Key-Value store | Hash trie nodes | 0.00 B | 0 | - // | Key-Value store | Path trie state lookups | 0.00 B | 0 | - // | Key-Value store | Path trie account nodes | 0.00 B | 0 | - // | Key-Value store | Path trie storage nodes | 0.00 B | 0 | - // | Key-Value store | Trie preimages | 0.00 B | 0 | - // | Key-Value store | Account snapshot | 0.00 B | 0 | - // | Key-Value store | Storage snapshot | 0.00 B | 0 | - // | Key-Value store | Clique snapshots | 0.00 B | 0 | - // | Key-Value store | Singleton metadata | 93.00 B | 2 | - // | Light client | CHT trie nodes | 0.00 B | 0 | - // | Light client | Bloom trie nodes | 0.00 B | 0 | - // | State sync | Trie segments | 78.00 B | 1 | - // | State sync | Storage tries to fetch | 77.00 B | 1 | - // | State sync | Code to fetch | 34.00 B | 1 | - // | State sync | Block numbers synced to | 23.00 B | 1 | - // +-----------------+-------------------------+----------+-------+ - // | TOTAL | 305.00 B | | - // +-----------------+-------------------------+----------+-------+ -} - -type stubDatabase struct { - ethdb.Database - iterator *stubIterator -} - -func (s *stubDatabase) NewIterator(_, _ []byte) ethdb.Iterator { - return s.iterator -} - -// AncientSize is used in [InspectDatabase] to determine the ancient sizes. -func (*stubDatabase) AncientSize(string) (uint64, error) { - return 0, nil -} - -func (*stubDatabase) Ancients() (uint64, error) { - return 0, nil -} - -func (*stubDatabase) Tail() (uint64, error) { - return 0, nil -} - -func (s *stubDatabase) Put(key, value []byte) error { - s.iterator.kvs = append(s.iterator.kvs, keyValue{key: key, value: value}) - return nil -} - -func (*stubDatabase) Get([]byte) ([]byte, error) { - return nil, nil -} - -func (*stubDatabase) ReadAncients(func(ethdb.AncientReaderOp) error) error { - return nil -} - -type stubIterator struct { - ethdb.Iterator - i int // see [stubIterator.pos] - kvs []keyValue -} - -type keyValue struct { - key []byte - value []byte -} - -// pos returns the true iterator position, which is otherwise off by one because -// Next() is called _before_ usage. -func (s *stubIterator) pos() int { - return s.i - 1 -} - -func (s *stubIterator) Next() bool { - s.i++ - return s.pos() < len(s.kvs) -} - -func (*stubIterator) Release() {} - -func (s *stubIterator) Key() []byte { - return s.kvs[s.pos()].key -} - -func (s *stubIterator) Value() []byte { - return s.kvs[s.pos()].value -} diff --git a/plugin/evm/customrawdb/schema_ext.go b/plugin/evm/customrawdb/schema_ext.go deleted file mode 100644 index d13f2f7e24..0000000000 --- a/plugin/evm/customrawdb/schema_ext.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package customrawdb - -import ( - "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/libevm/common" -) - -var ( - // snapshotBlockHashKey tracks the block hash of the last snapshot. - snapshotBlockHashKey = []byte("SnapshotBlockHash") - // offlinePruningKey tracks runs of offline pruning - offlinePruningKey = []byte("OfflinePruning") - // populateMissingTriesKey tracks runs of trie backfills - populateMissingTriesKey = []byte("PopulateMissingTries") - // pruningDisabledKey tracks whether the node has ever run in archival mode - // to ensure that a user does not accidentally corrupt an archival node. - pruningDisabledKey = []byte("PruningDisabled") - // acceptorTipKey tracks the tip of the last accepted block that has been fully processed. - acceptorTipKey = []byte("AcceptorTipKey") -) - -// State sync progress keys and prefixes -var ( - // syncRootKey indicates the root of the main account trie currently being synced - syncRootKey = []byte("sync_root") - // syncStorageTriesPrefix is the prefix for storage tries that need to be fetched. - // syncStorageTriesPrefix + trie root + account hash: indicates a storage trie must be fetched for the account - syncStorageTriesPrefix = []byte("sync_storage") - // syncSegmentsPrefix is the prefix for segments. - // syncSegmentsPrefix + trie root + 32-byte start key: indicates the trie at root has a segment starting at the specified key - syncSegmentsPrefix = []byte("sync_segments") - // CodeToFetchPrefix is the prefix for code hashes that need to be fetched. - // CodeToFetchPrefix + code hash -> empty value tracks the outstanding code hashes we need to fetch. - CodeToFetchPrefix = []byte("CP") -) - -// State sync progress key lengths -var ( - syncStorageTriesKeyLength = len(syncStorageTriesPrefix) + 2*common.HashLength - syncSegmentsKeyLength = len(syncSegmentsPrefix) + 2*common.HashLength - codeToFetchKeyLength = len(CodeToFetchPrefix) + common.HashLength -) - -// State sync metadata -var ( - syncPerformedPrefix = []byte("sync_performed") - // syncPerformedKeyLength is the length of the key for the sync performed metadata key, - // and is equal to [syncPerformedPrefix] + block number as uint64. - syncPerformedKeyLength = len(syncPerformedPrefix) + wrappers.LongLen -) - -var FirewoodScheme = "firewood" diff --git a/plugin/evm/customtypes/block_test.go b/plugin/evm/customtypes/block_test.go index 6c2446e9ed..8d34ec8df8 100644 --- a/plugin/evm/customtypes/block_test.go +++ b/plugin/evm/customtypes/block_test.go @@ -34,14 +34,15 @@ import ( "testing" "github.com/ava-labs/avalanchego/vms/evm/acp226" - "github.com/ava-labs/coreth/internal/blocktest" - "github.com/ava-labs/coreth/params" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/math" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/crypto" "github.com/ava-labs/libevm/rlp" + "github.com/ava-labs/coreth/internal/blocktest" + "github.com/ava-labs/coreth/params" + // This test file has to be in package types_test to avoid a circular // dependency when importing `params`. We dot-import the package to mimic // regular same-package behaviour. diff --git a/plugin/evm/customtypes/hashing_test.go b/plugin/evm/customtypes/hashing_test.go index ca1958e043..71fd7a1618 100644 --- a/plugin/evm/customtypes/hashing_test.go +++ b/plugin/evm/customtypes/hashing_test.go @@ -32,7 +32,6 @@ import ( "fmt" "io" "math/big" - mrand "math/rand" "testing" "github.com/ava-labs/libevm/common" @@ -43,6 +42,8 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/ava-labs/libevm/trie" "github.com/ava-labs/libevm/triedb" + + mrand "math/rand" ) func TestDeriveSha(t *testing.T) { diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 548072c786..804b2cf816 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -35,6 +35,7 @@ import ( "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" "github.com/ava-labs/avalanchego/vms/evm/acp226" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/firewood-go-ethhash/ffi" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" @@ -68,7 +69,6 @@ import ( "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/params/extras" "github.com/ava-labs/coreth/plugin/evm/config" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/extension" "github.com/ava-labs/coreth/plugin/evm/gossip" "github.com/ava-labs/coreth/plugin/evm/message" diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index 11c205c887..cdf9c92598 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -26,6 +26,7 @@ import ( "github.com/ava-labs/avalanchego/vms/evm/acp176" "github.com/ava-labs/avalanchego/vms/evm/acp226" "github.com/ava-labs/avalanchego/vms/evm/predicate" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/math" @@ -47,7 +48,6 @@ import ( "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/params/paramstest" "github.com/ava-labs/coreth/plugin/evm/customheader" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/plugin/evm/extension" "github.com/ava-labs/coreth/plugin/evm/message" diff --git a/plugin/evm/vmtest/test_syncervm.go b/plugin/evm/vmtest/test_syncervm.go index be7703d039..e514899841 100644 --- a/plugin/evm/vmtest/test_syncervm.go +++ b/plugin/evm/vmtest/test_syncervm.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/chain" "github.com/ava-labs/avalanchego/vms/evm/predicate" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" @@ -35,7 +36,6 @@ import ( "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/coretest" "github.com/ava-labs/coreth/params/paramstest" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/plugin/evm/database" "github.com/ava-labs/coreth/plugin/evm/extension" diff --git a/plugin/evm/vmtest/test_vm.go b/plugin/evm/vmtest/test_vm.go index 69cab9ad67..353ef3941c 100644 --- a/plugin/evm/vmtest/test_vm.go +++ b/plugin/evm/vmtest/test_vm.go @@ -15,11 +15,11 @@ import ( "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/enginetest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/extension" "github.com/ava-labs/coreth/utils/utilstest" diff --git a/scripts/build_test.sh b/scripts/build_test.sh index b2390e53ea..1e17b97f61 100755 --- a/scripts/build_test.sh +++ b/scripts/build_test.sh @@ -33,15 +33,18 @@ do if [[ ${command_status:-0} == 0 ]]; then rm test.out exit 0 - else + else unset command_status # Clear the error code for the next run fi # If the test failed, print the output unexpected_failures=$( # First grep pattern corresponds to test failures, second pattern corresponds to test panics due to timeouts + # NOTE: comm requires BOTH inputs to be sorted. We sort -u the left (extracted failures) + # and right (known_flakes.txt) sides with LC_ALL=C to ensure bytewise, stable ordering + # across environments and to deduplicate entries so comm order checks are satisfied. (grep "^--- FAIL" test.out | awk '{print $3}' || grep -E '^\s+Test.+ \(' test.out | awk '{print $1}') | - sort -u | comm -23 - <(sed 's/\r$//' ./scripts/known_flakes.txt) + LC_ALL=C sort -u | comm -23 - <(sed 's/\r$//' ./scripts/known_flakes.txt | LC_ALL=C sort -u) ) if [ -n "${unexpected_failures}" ]; then echo "Unexpected test failures: ${unexpected_failures}" diff --git a/sync/statesync/code_queue.go b/sync/statesync/code_queue.go index af31f62988..e703a3cb1c 100644 --- a/sync/statesync/code_queue.go +++ b/sync/statesync/code_queue.go @@ -8,12 +8,11 @@ import ( "fmt" "sync" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb" "github.com/ava-labs/libevm/libevm/options" - - "github.com/ava-labs/coreth/plugin/evm/customrawdb" ) const defaultQueueCapacity = 5000 diff --git a/sync/statesync/code_queue_test.go b/sync/statesync/code_queue_test.go index b46ad1d07f..fe082dc41b 100644 --- a/sync/statesync/code_queue_test.go +++ b/sync/statesync/code_queue_test.go @@ -10,14 +10,13 @@ import ( "time" "github.com/ava-labs/avalanchego/utils/set" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/crypto" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" "go.uber.org/goleak" - - "github.com/ava-labs/coreth/plugin/evm/customrawdb" ) func TestCodeQueue(t *testing.T) { diff --git a/sync/statesync/code_syncer.go b/sync/statesync/code_syncer.go index 3fdda1f6c9..508b525861 100644 --- a/sync/statesync/code_syncer.go +++ b/sync/statesync/code_syncer.go @@ -8,13 +8,13 @@ import ( "fmt" "sync" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb" "github.com/ava-labs/libevm/libevm/options" "golang.org/x/sync/errgroup" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/message" syncpkg "github.com/ava-labs/coreth/sync" diff --git a/sync/statesync/code_syncer_test.go b/sync/statesync/code_syncer_test.go index 05b50e810a..c738b9c532 100644 --- a/sync/statesync/code_syncer_test.go +++ b/sync/statesync/code_syncer_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/crypto" @@ -15,7 +16,6 @@ import ( "github.com/ava-labs/libevm/ethdb/memorydb" "github.com/stretchr/testify/require" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/message" "github.com/ava-labs/coreth/sync/handlers" "github.com/ava-labs/coreth/utils/utilstest" diff --git a/sync/statesync/sync_test.go b/sync/statesync/sync_test.go index 2ca779819a..e4708a7fe7 100644 --- a/sync/statesync/sync_test.go +++ b/sync/statesync/sync_test.go @@ -11,6 +11,7 @@ import ( "sync/atomic" "testing" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" @@ -23,7 +24,6 @@ import ( "golang.org/x/sync/errgroup" "github.com/ava-labs/coreth/core/state/snapshot" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/message" "github.com/ava-labs/coreth/sync/handlers" "github.com/ava-labs/coreth/sync/statesync/statesynctest" diff --git a/sync/statesync/trie_queue.go b/sync/statesync/trie_queue.go index f95594216e..95e7a6b1e0 100644 --- a/sync/statesync/trie_queue.go +++ b/sync/statesync/trie_queue.go @@ -4,10 +4,9 @@ package statesync import ( + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/ethdb" - - "github.com/ava-labs/coreth/plugin/evm/customrawdb" ) // trieQueue persists storage trie roots with their associated diff --git a/sync/statesync/trie_segments.go b/sync/statesync/trie_segments.go index e1dcaf9a32..e43f8012e3 100644 --- a/sync/statesync/trie_segments.go +++ b/sync/statesync/trie_segments.go @@ -11,13 +11,13 @@ import ( "sync" "github.com/ava-labs/avalanchego/utils/wrappers" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/ethdb" "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/trie" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/message" "github.com/ava-labs/coreth/utils" diff --git a/tests/state_test_util.go b/tests/state_test_util.go index badd8cd65c..9b04f3e0cf 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -31,9 +31,9 @@ import ( "os" "path/filepath" + "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/coreth/core/extstate" "github.com/ava-labs/coreth/core/state/snapshot" - "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/triedb/firewood" "github.com/ava-labs/coreth/triedb/hashdb" "github.com/ava-labs/coreth/triedb/pathdb"