fix some lint errors (TODO: merge this commit into the 7928 changes

This commit is contained in:
Jared Wasinger 2026-03-03 18:23:23 -05:00
parent 2135705bd4
commit 6d1df21ef9
6 changed files with 57 additions and 55 deletions

View file

@ -165,7 +165,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
blockchain.reportBadBlock(block, res, err) blockchain.reportBadBlock(block, res, err)
return err return err
} }
err = blockchain.validator.ValidateState(block, statedb, res, true, false) err = blockchain.validator.ValidateState(block, statedb, res, true)
if err != nil { if err != nil {
blockchain.reportBadBlock(block, res, err) blockchain.reportBadBlock(block, res, err)
return err return err

View file

@ -1296,12 +1296,13 @@ func TestDeleteStorage(t *testing.T) {
obj := fastState.getOrNewStateObject(addr) obj := fastState.getOrNewStateObject(addr)
storageRoot := obj.data.Root storageRoot := obj.data.Root
_, _, fastNodes, err := fastState.deleteStorage(addr, crypto.Keccak256Hash(addr[:]), storageRoot) // TODO (jwasinger): verify that the invocation of fast/slowDeleteStorage have correct params here
_, _, fastNodes, err := fastDeleteStorage(storageRoot, fastState.db.Snapshot(), crypto.Keccak256Hash(addr[:]), root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
_, _, slowNodes, err := slowState.deleteStorage(addr, crypto.Keccak256Hash(addr[:]), storageRoot) _, _, slowNodes, err := slowDeleteStorage(slowState.db, slowState.trie, storageRoot, addr, crypto.Keccak256Hash(addr[:]), root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -36,56 +36,48 @@ func equalBALs(a *BlockAccessList, b *BlockAccessList) bool {
return true return true
} }
func makeTestConstructionBAL() *AccessListBuilder { func makeTestConstructionBAL() ConstructionBlockAccessList {
return &AccessListBuilder{ return map[common.Address]*ConstructionAccountAccesses{
FinalizedAccesses: map[common.Address]*ConstructionAccountAccesses{ common.BytesToAddress([]byte{0xff, 0xff}): {
common.BytesToAddress([]byte{0xff, 0xff}): { StorageWrites: map[common.Hash]map[uint16]common.Hash{
StorageWrites: map[common.Hash]map[uint16]common.Hash{ common.BytesToHash([]byte{0x01}): {
common.BytesToHash([]byte{0x01}): { 1: common.BytesToHash([]byte{1, 2, 3, 4}),
1: common.BytesToHash([]byte{1, 2, 3, 4}), 2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
},
common.BytesToHash([]byte{0x10}): {
20: common.BytesToHash([]byte{1, 2, 3, 4}),
},
}, },
StorageReads: map[common.Hash]struct{}{ common.BytesToHash([]byte{0x10}): {
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7}): {}, 20: common.BytesToHash([]byte{1, 2, 3, 4}),
}, },
BalanceChanges: map[uint16]*uint256.Int{
1: uint256.NewInt(100),
2: uint256.NewInt(500),
},
NonceChanges: map[uint16]uint64{
1: 2,
2: 6,
},
CodeChanges: map[uint16]CodeChange{0: {
TxIdx: 0,
Code: common.Hex2Bytes("deadbeef"),
}},
}, },
common.BytesToAddress([]byte{0xff, 0xff, 0xff}): { StorageReads: map[common.Hash]struct{}{
StorageWrites: map[common.Hash]map[uint16]common.Hash{ common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7}): {},
common.BytesToHash([]byte{0x01}): { },
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}), BalanceChanges: map[uint16]*uint256.Int{
3: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}), 1: uint256.NewInt(100),
}, 2: uint256.NewInt(500),
common.BytesToHash([]byte{0x10}): { },
21: common.BytesToHash([]byte{1, 2, 3, 4, 5}), NonceChanges: map[uint16]uint64{
}, 1: 2,
}, 2: 6,
StorageReads: map[common.Hash]struct{}{ },
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}): {}, CodeChanges: map[uint16][]byte{0: common.Hex2Bytes("deadbeef")},
}, },
BalanceChanges: map[uint16]*uint256.Int{ common.BytesToAddress([]byte{0xff, 0xff, 0xff}): {
2: uint256.NewInt(100), StorageWrites: map[common.Hash]map[uint16]common.Hash{
3: uint256.NewInt(500), common.BytesToHash([]byte{0x01}): {
}, 2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
NonceChanges: map[uint16]uint64{ 3: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
1: 2,
}, },
}, },
StorageReads: map[common.Hash]struct{}{
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}): {},
},
BalanceChanges: map[uint16]*uint256.Int{
2: uint256.NewInt(100),
3: uint256.NewInt(500),
},
NonceChanges: map[uint16]uint64{
1: 2,
},
}, },
} }
} }
@ -93,8 +85,7 @@ func makeTestConstructionBAL() *AccessListBuilder {
// TestBALEncoding tests that a populated access list can be encoded/decoded correctly. // TestBALEncoding tests that a populated access list can be encoded/decoded correctly.
func TestBALEncoding(t *testing.T) { func TestBALEncoding(t *testing.T) {
var buf bytes.Buffer var buf bytes.Buffer
balBuilder := makeTestConstructionBAL() bal := makeTestConstructionBAL()
bal := balBuilder.FinalizedAccesses
err := bal.EncodeRLP(&buf) err := bal.EncodeRLP(&buf)
if err != nil { if err != nil {
t.Fatalf("encoding failed: %v\n", err) t.Fatalf("encoding failed: %v\n", err)
@ -184,10 +175,10 @@ func makeTestAccountAccess(sort bool) AccountAccess {
StorageReads: encodedStorageReads, StorageReads: encodedStorageReads,
BalanceChanges: balances, BalanceChanges: balances,
NonceChanges: nonces, NonceChanges: nonces,
CodeChanges: []CodeChange{ CodeChanges: []encodingCodeChange{
{ {
TxIdx: 100, TxIndex: 100,
Code: testrand.Bytes(256), Code: testrand.Bytes(256),
}, },
}, },
} }
@ -250,7 +241,7 @@ func TestBlockAccessListValidation(t *testing.T) {
} }
// Validate the derived block access list // Validate the derived block access list
cBAL := makeTestConstructionBAL().FinalizedAccesses cBAL := makeTestConstructionBAL()
listB := cBAL.ToEncodingObj() listB := cBAL.ToEncodingObj()
if err := listB.Validate(testBALMaxIndex); err != nil { if err := listB.Validate(testBALMaxIndex); err != nil {
t.Fatalf("Unexpected validation error: %v", err) t.Fatalf("Unexpected validation error: %v", err)

View file

@ -620,7 +620,7 @@ func TestSelfdestructStateTracer(t *testing.T) {
} }
context := core.NewEVMBlockContext(block.Header(), blockchain, nil) context := core.NewEVMBlockContext(block.Header(), blockchain, nil)
evm := vm.NewEVM(context, hookedState, tt.genesis.Config, vm.Config{Tracer: tracer.Hooks()}) evm := vm.NewEVM(context, hookedState, tt.genesis.Config, vm.Config{Tracer: tracer.Hooks()})
_, err = core.ApplyTransactionWithEVM(msg, core.NewGasPool(msg.GasLimit), statedb, block.Number(), block.Hash(), block.Time(), tx, evm) _, _, err = core.ApplyTransactionWithEVM(msg, core.NewGasPool(msg.GasLimit), statedb, block.Number(), block.Hash(), block.Time(), tx, evm)
if err != nil { if err != nil {
t.Fatalf("failed to execute transaction: %v", err) t.Fatalf("failed to execute transaction: %v", err)
} }

View file

@ -558,6 +558,11 @@ func (b testBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.
} }
panic("unknown type rpc.BlockNumberOrHash") panic("unknown type rpc.BlockNumberOrHash")
} }
func (b testBackend) BlockAccessListByNumberOrHash(block rpc.BlockNumberOrHash) (interface{}, error) {
panic("not implemented")
}
func (b testBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) { func (b testBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
return b.chain.GetBlock(hash, uint64(number.Int64())).Body(), nil return b.chain.GetBlock(hash, uint64(number.Int64())).Body(), nil
} }

View file

@ -356,6 +356,11 @@ func (b *backendMock) BlockByHash(ctx context.Context, hash common.Hash) (*types
func (b *backendMock) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) { func (b *backendMock) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) {
return nil, nil return nil, nil
} }
func (b *backendMock) BlockAccessListByNumberOrHash(block rpc.BlockNumberOrHash) (interface{}, error) {
panic("not implemented")
}
func (b *backendMock) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) { func (b *backendMock) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
return nil, nil return nil, nil
} }