diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index 3d5badeddd..5d20130bdb 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -125,10 +125,7 @@ func TestWaitDeployedCornerCases(t *testing.T) { // Create a transaction to an account. code := "6060604052600a8060106000396000f360606040526008565b00" tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code)) - tx, err := types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey) - if err != nil { - t.Fatalf("Failed to sign transaction: %s", err) - } + tx, _ = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey) ctx, cancel := context.WithCancel(context.Background()) defer cancel() if err := backend.Client().SendTransaction(ctx, tx); err != nil { diff --git a/core/extstate/statedb.go b/core/extstate/statedb.go index 04fb7cb36c..5f3769c332 100644 --- a/core/extstate/statedb.go +++ b/core/extstate/statedb.go @@ -52,7 +52,8 @@ func (s *StateDB) GetLogData() (topics [][]common.Hash, data [][]byte) { return topics, data } -// GetPredicateStorageSlots returns the storage slots associated with the address, index pair. +// GetPredicateStorageSlots returns the storage slots associated with the address+index pair as +// a byte slice as well as a boolean indicating if the address+index pair exists. // A list of access tuples can be included within transaction types post EIP-2930. The address // is declared directly on the access tuple and the index is the i'th occurrence of an access // tuple with the specified address. diff --git a/core/state/statedb.go b/core/state/statedb.go index 211c926157..ee1d6a6c81 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -118,19 +118,3 @@ func (s *StateDB) Copy() *StateDB { txIndex: s.txIndex, } } - -// NormalizeCoinID ORs the 0th bit of the first byte in -// `coinID`, which ensures this bit will be 1 and all other -// bits are left the same. -// This partitions multicoin storage from normal state storage. -func NormalizeCoinID(coinID *common.Hash) { - coinID[0] |= 0x01 -} - -// NormalizeStateKey ANDs the 0th bit of the first byte in -// `key`, which ensures this bit will be 0 and all other bits -// are left the same. -// This partitions normal state storage from multicoin storage. -func NormalizeStateKey(key *common.Hash) { - key[0] &= 0xfe -} diff --git a/utils/key.go b/internal/testutils/key.go similarity index 91% rename from utils/key.go rename to internal/testutils/key.go index cc4efa6751..4dc53edd26 100644 --- a/utils/key.go +++ b/internal/testutils/key.go @@ -1,7 +1,7 @@ -// (c) 2024, Ava Labs, Inc. All rights reserved. +// (c) 2024-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package utils +package testutils import ( "crypto/ecdsa" diff --git a/params/extras/config.go b/params/extras/config.go index f27847e402..7de800c2bf 100644 --- a/params/extras/config.go +++ b/params/extras/config.go @@ -126,16 +126,16 @@ type ChainConfig struct { UpgradeConfig `json:"-"` // Config specified in upgradeBytes (avalanche network upgrades or enable/disabling precompiles). Not serialized. } -func (c *ChainConfig) CheckConfigCompatible(newcfg_ *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError { +func (c *ChainConfig) CheckConfigCompatible(newConfig *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError { if c == nil { return nil } - newcfg, ok := newcfg_.Hooks().(*ChainConfig) + newcfg, ok := newConfig.Hooks().(*ChainConfig) if !ok { // Proper registration of the extras on the libevm side should prevent this from happening. // Return an error to prevent the chain from starting, just in case. return ethparams.NewTimestampCompatError( - fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newcfg_.Hooks()), + fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newConfig.Hooks()), utils.NewUint64(0), nil, ) diff --git a/plugin/evm/syncervm_test.go b/plugin/evm/syncervm_test.go index 3a687b7ab3..be67409c9b 100644 --- a/plugin/evm/syncervm_test.go +++ b/plugin/evm/syncervm_test.go @@ -37,12 +37,12 @@ import ( "github.com/ava-labs/subnet-evm/consensus/dummy" "github.com/ava-labs/subnet-evm/constants" "github.com/ava-labs/subnet-evm/core" + "github.com/ava-labs/subnet-evm/internal/testutils" "github.com/ava-labs/subnet-evm/plugin/evm/customrawdb" "github.com/ava-labs/subnet-evm/plugin/evm/database" "github.com/ava-labs/subnet-evm/predicate" statesyncclient "github.com/ava-labs/subnet-evm/sync/client" "github.com/ava-labs/subnet-evm/sync/statesync" - "github.com/ava-labs/subnet-evm/utils" ) func TestSkipStateSync(t *testing.T) { @@ -369,7 +369,7 @@ type syncVMSetup struct { serverVM *VM serverAppSender *enginetest.Sender - fundedAccounts map[*utils.Key]*types.StateAccount + fundedAccounts map[*testutils.Key]*types.StateAccount syncerVM *VM syncerDB avalanchedatabase.Database diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index c51c269b0d..871beb9f50 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -44,6 +44,7 @@ import ( "github.com/ava-labs/subnet-evm/core" "github.com/ava-labs/subnet-evm/core/txpool" "github.com/ava-labs/subnet-evm/eth" + "github.com/ava-labs/subnet-evm/internal/testutils" "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/params/extras" "github.com/ava-labs/subnet-evm/plugin/evm/config" @@ -361,7 +362,7 @@ func TestBuildEthTxBlock(t *testing.T) { newTxPoolHeadChan := make(chan core.NewTxPoolReorgEvent, 1) vm.txPool.SubscribeNewReorgEvent(newTxPoolHeadChan) - key := utils.NewKey(t) + key := testutils.NewKey(t) tx := types.NewTransaction(uint64(0), key.Address, firstTxAmount, 21000, big.NewInt(testMinGasPrice), nil) signedTx, err := types.SignTx(tx, types.NewEIP155Signer(vm.chainConfig.ChainID), testKeys[0]) @@ -2947,7 +2948,7 @@ func TestSkipChainConfigCheckCompatible(t *testing.T) { newTxPoolHeadChan := make(chan core.NewTxPoolReorgEvent, 1) vm.txPool.SubscribeNewReorgEvent(newTxPoolHeadChan) - key := utils.NewKey(t) + key := testutils.NewKey(t) tx := types.NewTransaction(uint64(0), key.Address, firstTxAmount, 21000, big.NewInt(testMinGasPrice), nil) signedTx, err := types.SignTx(tx, types.NewEIP155Signer(vm.chainConfig.ChainID), testKeys[0]) diff --git a/precompile/contract/interfaces.go b/precompile/contract/interfaces.go index 6892b7961a..5ec0a74213 100644 --- a/precompile/contract/interfaces.go +++ b/precompile/contract/interfaces.go @@ -40,7 +40,7 @@ type StateDB interface { AddLog(*ethtypes.Log) GetLogData() (topics [][]common.Hash, data [][]byte) - GetPredicateStorageSlots(address common.Address, index int) ([]byte, bool) + GetPredicateStorageSlots(address common.Address, index int) (predicate []byte, exists bool) SetPredicateStorageSlots(address common.Address, predicates [][]byte) GetTxHash() common.Hash diff --git a/sync/statesync/test_sync.go b/sync/statesync/test_sync.go index ed3bbf587c..5fde5aa535 100644 --- a/sync/statesync/test_sync.go +++ b/sync/statesync/test_sync.go @@ -15,9 +15,9 @@ import ( "github.com/ava-labs/libevm/ethdb" "github.com/ava-labs/libevm/rlp" "github.com/ava-labs/libevm/triedb" + "github.com/ava-labs/subnet-evm/internal/testutils" "github.com/ava-labs/subnet-evm/plugin/evm/customrawdb" "github.com/ava-labs/subnet-evm/sync/syncutils" - "github.com/ava-labs/subnet-evm/utils" "github.com/stretchr/testify/assert" ) @@ -117,7 +117,7 @@ func fillAccountsWithStorage(t *testing.T, serverDB ethdb.Database, serverTrieDB // returns the new trie root and a map of funded keys to StateAccount structs. func FillAccountsWithOverlappingStorage( t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int, numOverlappingStorageRoots int, -) (common.Hash, map[*utils.Key]*types.StateAccount) { +) (common.Hash, map[*testutils.Key]*types.StateAccount) { storageRoots := make([]common.Hash, 0, numOverlappingStorageRoots) for i := 0; i < numOverlappingStorageRoots; i++ { storageRoot, _, _ := syncutils.GenerateTrie(t, trieDB, 16, common.HashLength) diff --git a/sync/syncutils/test_trie.go b/sync/syncutils/test_trie.go index 0dbb027e58..97f0e124a0 100644 --- a/sync/syncutils/test_trie.go +++ b/sync/syncutils/test_trie.go @@ -13,7 +13,7 @@ import ( "github.com/ava-labs/libevm/trie" "github.com/ava-labs/libevm/trie/trienode" "github.com/ava-labs/libevm/triedb" - "github.com/ava-labs/subnet-evm/utils" + "github.com/ava-labs/subnet-evm/internal/testutils" "github.com/holiman/uint256" "github.com/ava-labs/libevm/common" @@ -146,12 +146,12 @@ func CorruptTrie(t *testing.T, diskdb ethdb.Batcher, tr *trie.Trie, n int) { func FillAccounts( t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int, onAccount func(*testing.T, int, types.StateAccount) types.StateAccount, -) (common.Hash, map[*utils.Key]*types.StateAccount) { +) (common.Hash, map[*testutils.Key]*types.StateAccount) { var ( minBalance = uint256.NewInt(3000000000000000000) randBalance = uint256.NewInt(1000000000000000000) maxNonce = 10 - accounts = make(map[*utils.Key]*types.StateAccount, numAccounts) + accounts = make(map[*testutils.Key]*types.StateAccount, numAccounts) ) tr, err := trie.NewStateTrie(trie.TrieID(root), trieDB) @@ -175,7 +175,7 @@ func FillAccounts( t.Fatalf("failed to rlp encode account: %v", err) } - key := utils.NewKey(t) + key := testutils.NewKey(t) tr.MustUpdate(key.Address[:], accBytes) accounts[key] = &acc }