Skip to content
Merged
5 changes: 1 addition & 4 deletions accounts/abi/bind/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/extstate/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 0 additions & 16 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions utils/key.go → internal/testutils/key.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions params/extras/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/syncervm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion precompile/contract/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sync/statesync/test_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions sync/syncutils/test_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
Loading