Skip to content

Commit b1d4d89

Browse files
authored
chore(all): minor changes post-libevm merge (#1552)
1 parent 28ea93a commit b1d4d89

File tree

10 files changed

+20
-37
lines changed

10 files changed

+20
-37
lines changed

accounts/abi/bind/util_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
125125
// Create a transaction to an account.
126126
code := "6060604052600a8060106000396000f360606040526008565b00"
127127
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
128-
tx, err := types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
129-
if err != nil {
130-
t.Fatalf("Failed to sign transaction: %s", err)
131-
}
128+
tx, _ = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
132129
ctx, cancel := context.WithCancel(context.Background())
133130
defer cancel()
134131
if err := backend.Client().SendTransaction(ctx, tx); err != nil {

core/extstate/statedb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func (s *StateDB) GetLogData() (topics [][]common.Hash, data [][]byte) {
5252
return topics, data
5353
}
5454

55-
// GetPredicateStorageSlots returns the storage slots associated with the address, index pair.
55+
// GetPredicateStorageSlots returns the storage slots associated with the address+index pair as
56+
// a byte slice as well as a boolean indicating if the address+index pair exists.
5657
// A list of access tuples can be included within transaction types post EIP-2930. The address
5758
// is declared directly on the access tuple and the index is the i'th occurrence of an access
5859
// tuple with the specified address.

core/state/statedb.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,3 @@ func (s *StateDB) Copy() *StateDB {
118118
txIndex: s.txIndex,
119119
}
120120
}
121-
122-
// NormalizeCoinID ORs the 0th bit of the first byte in
123-
// `coinID`, which ensures this bit will be 1 and all other
124-
// bits are left the same.
125-
// This partitions multicoin storage from normal state storage.
126-
func NormalizeCoinID(coinID *common.Hash) {
127-
coinID[0] |= 0x01
128-
}
129-
130-
// NormalizeStateKey ANDs the 0th bit of the first byte in
131-
// `key`, which ensures this bit will be 0 and all other bits
132-
// are left the same.
133-
// This partitions normal state storage from multicoin storage.
134-
func NormalizeStateKey(key *common.Hash) {
135-
key[0] &= 0xfe
136-
}

utils/key.go renamed to internal/testutils/key.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// (c) 2024, Ava Labs, Inc. All rights reserved.
1+
// (c) 2024-2025, Ava Labs, Inc. All rights reserved.
22
// See the file LICENSE for licensing terms.
33

4-
package utils
4+
package testutils
55

66
import (
77
"crypto/ecdsa"

params/extras/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ type ChainConfig struct {
126126
UpgradeConfig `json:"-"` // Config specified in upgradeBytes (avalanche network upgrades or enable/disabling precompiles). Not serialized.
127127
}
128128

129-
func (c *ChainConfig) CheckConfigCompatible(newcfg_ *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError {
129+
func (c *ChainConfig) CheckConfigCompatible(newConfig *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError {
130130
if c == nil {
131131
return nil
132132
}
133-
newcfg, ok := newcfg_.Hooks().(*ChainConfig)
133+
newcfg, ok := newConfig.Hooks().(*ChainConfig)
134134
if !ok {
135135
// Proper registration of the extras on the libevm side should prevent this from happening.
136136
// Return an error to prevent the chain from starting, just in case.
137137
return ethparams.NewTimestampCompatError(
138-
fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newcfg_.Hooks()),
138+
fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newConfig.Hooks()),
139139
utils.NewUint64(0),
140140
nil,
141141
)

plugin/evm/syncervm_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ import (
3737
"github.com/ava-labs/subnet-evm/consensus/dummy"
3838
"github.com/ava-labs/subnet-evm/constants"
3939
"github.com/ava-labs/subnet-evm/core"
40+
"github.com/ava-labs/subnet-evm/internal/testutils"
4041
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
4142
"github.com/ava-labs/subnet-evm/plugin/evm/database"
4243
"github.com/ava-labs/subnet-evm/predicate"
4344
statesyncclient "github.com/ava-labs/subnet-evm/sync/client"
4445
"github.com/ava-labs/subnet-evm/sync/statesync"
45-
"github.com/ava-labs/subnet-evm/utils"
4646
)
4747

4848
func TestSkipStateSync(t *testing.T) {
@@ -369,7 +369,7 @@ type syncVMSetup struct {
369369
serverVM *VM
370370
serverAppSender *enginetest.Sender
371371

372-
fundedAccounts map[*utils.Key]*types.StateAccount
372+
fundedAccounts map[*testutils.Key]*types.StateAccount
373373

374374
syncerVM *VM
375375
syncerDB avalanchedatabase.Database

plugin/evm/vm_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"github.com/ava-labs/subnet-evm/core"
4545
"github.com/ava-labs/subnet-evm/core/txpool"
4646
"github.com/ava-labs/subnet-evm/eth"
47+
"github.com/ava-labs/subnet-evm/internal/testutils"
4748
"github.com/ava-labs/subnet-evm/params"
4849
"github.com/ava-labs/subnet-evm/params/extras"
4950
"github.com/ava-labs/subnet-evm/plugin/evm/config"
@@ -361,7 +362,7 @@ func TestBuildEthTxBlock(t *testing.T) {
361362
newTxPoolHeadChan := make(chan core.NewTxPoolReorgEvent, 1)
362363
vm.txPool.SubscribeNewReorgEvent(newTxPoolHeadChan)
363364

364-
key := utils.NewKey(t)
365+
key := testutils.NewKey(t)
365366

366367
tx := types.NewTransaction(uint64(0), key.Address, firstTxAmount, 21000, big.NewInt(testMinGasPrice), nil)
367368
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(vm.chainConfig.ChainID), testKeys[0])
@@ -2947,7 +2948,7 @@ func TestSkipChainConfigCheckCompatible(t *testing.T) {
29472948
newTxPoolHeadChan := make(chan core.NewTxPoolReorgEvent, 1)
29482949
vm.txPool.SubscribeNewReorgEvent(newTxPoolHeadChan)
29492950

2950-
key := utils.NewKey(t)
2951+
key := testutils.NewKey(t)
29512952

29522953
tx := types.NewTransaction(uint64(0), key.Address, firstTxAmount, 21000, big.NewInt(testMinGasPrice), nil)
29532954
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(vm.chainConfig.ChainID), testKeys[0])

precompile/contract/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type StateDB interface {
4040

4141
AddLog(*ethtypes.Log)
4242
GetLogData() (topics [][]common.Hash, data [][]byte)
43-
GetPredicateStorageSlots(address common.Address, index int) ([]byte, bool)
43+
GetPredicateStorageSlots(address common.Address, index int) (predicate []byte, exists bool)
4444
SetPredicateStorageSlots(address common.Address, predicates [][]byte)
4545

4646
GetTxHash() common.Hash

sync/statesync/test_sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"github.com/ava-labs/libevm/ethdb"
1616
"github.com/ava-labs/libevm/rlp"
1717
"github.com/ava-labs/libevm/triedb"
18+
"github.com/ava-labs/subnet-evm/internal/testutils"
1819
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
1920
"github.com/ava-labs/subnet-evm/sync/syncutils"
20-
"github.com/ava-labs/subnet-evm/utils"
2121
"github.com/stretchr/testify/assert"
2222
)
2323

@@ -117,7 +117,7 @@ func fillAccountsWithStorage(t *testing.T, serverDB ethdb.Database, serverTrieDB
117117
// returns the new trie root and a map of funded keys to StateAccount structs.
118118
func FillAccountsWithOverlappingStorage(
119119
t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int, numOverlappingStorageRoots int,
120-
) (common.Hash, map[*utils.Key]*types.StateAccount) {
120+
) (common.Hash, map[*testutils.Key]*types.StateAccount) {
121121
storageRoots := make([]common.Hash, 0, numOverlappingStorageRoots)
122122
for i := 0; i < numOverlappingStorageRoots; i++ {
123123
storageRoot, _, _ := syncutils.GenerateTrie(t, trieDB, 16, common.HashLength)

sync/syncutils/test_trie.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/ava-labs/libevm/trie"
1414
"github.com/ava-labs/libevm/trie/trienode"
1515
"github.com/ava-labs/libevm/triedb"
16-
"github.com/ava-labs/subnet-evm/utils"
16+
"github.com/ava-labs/subnet-evm/internal/testutils"
1717
"github.com/holiman/uint256"
1818

1919
"github.com/ava-labs/libevm/common"
@@ -146,12 +146,12 @@ func CorruptTrie(t *testing.T, diskdb ethdb.Batcher, tr *trie.Trie, n int) {
146146
func FillAccounts(
147147
t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int,
148148
onAccount func(*testing.T, int, types.StateAccount) types.StateAccount,
149-
) (common.Hash, map[*utils.Key]*types.StateAccount) {
149+
) (common.Hash, map[*testutils.Key]*types.StateAccount) {
150150
var (
151151
minBalance = uint256.NewInt(3000000000000000000)
152152
randBalance = uint256.NewInt(1000000000000000000)
153153
maxNonce = 10
154-
accounts = make(map[*utils.Key]*types.StateAccount, numAccounts)
154+
accounts = make(map[*testutils.Key]*types.StateAccount, numAccounts)
155155
)
156156

157157
tr, err := trie.NewStateTrie(trie.TrieID(root), trieDB)
@@ -175,7 +175,7 @@ func FillAccounts(
175175
t.Fatalf("failed to rlp encode account: %v", err)
176176
}
177177

178-
key := utils.NewKey(t)
178+
key := testutils.NewKey(t)
179179
tr.MustUpdate(key.Address[:], accBytes)
180180
accounts[key] = &acc
181181
}

0 commit comments

Comments
 (0)