diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go index 17b5b49fa71..6e9f9e15b96 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc.go +++ b/cmd/rpcdaemon/commands/trace_adhoc.go @@ -334,7 +334,7 @@ type StateDiff struct { sdMap map[common.Address]*StateDiffAccount } -func (sd *StateDiff) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { +func (sd *StateDiff) UpdateAccountData(address common.Address, original, account *accounts.Account) error { if _, ok := sd.sdMap[address]; !ok { sd.sdMap[address] = &StateDiffAccount{Storage: make(map[common.Hash]map[string]interface{})} } @@ -348,14 +348,14 @@ func (sd *StateDiff) UpdateAccountCode(address common.Address, incarnation uint6 return nil } -func (sd *StateDiff) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { +func (sd *StateDiff) DeleteAccount(address common.Address, original *accounts.Account) error { if _, ok := sd.sdMap[address]; !ok { sd.sdMap[address] = &StateDiffAccount{Storage: make(map[common.Hash]map[string]interface{})} } return nil } -func (sd *StateDiff) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (sd *StateDiff) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { if *original == *value { return nil } diff --git a/cmd/snapshots/debug/debug_test.go b/cmd/snapshots/debug/debug_test.go index 359d77867c2..737c58940cc 100644 --- a/cmd/snapshots/debug/debug_test.go +++ b/cmd/snapshots/debug/debug_test.go @@ -260,13 +260,13 @@ func (d *DebugReaderWriter) WriteHistory() error { return d.w.WriteHistory() } -func (d *DebugReaderWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { +func (d *DebugReaderWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { b, err := rlp.EncodeToBytes(account) if err != nil { return err } d.updatedAcc[address] = b - return d.w.UpdateAccountData(ctx, address, original, account) + return d.w.UpdateAccountData(address, original, account) } func (d *DebugReaderWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error { @@ -274,15 +274,15 @@ func (d *DebugReaderWriter) UpdateAccountCode(address common.Address, incarnatio return d.w.UpdateAccountCode(address, incarnation, codeHash, code) } -func (d *DebugReaderWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { +func (d *DebugReaderWriter) DeleteAccount(address common.Address, original *accounts.Account) error { d.updatedAcc[address] = nil //d.deletedAcc[address]= struct{}{} - return d.w.DeleteAccount(ctx, address, original) + return d.w.DeleteAccount(address, original) } -func (d *DebugReaderWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (d *DebugReaderWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { d.updatedStorage[string(dbutils.PlainGenerateCompositeStorageKey(address.Bytes(), incarnation, key.Bytes()))] = value.Bytes() - return d.w.WriteAccountStorage(ctx, address, incarnation, key, original, value) + return d.w.WriteAccountStorage(address, incarnation, key, original, value) } func (d *DebugReaderWriter) CreateContract(address common.Address) error { diff --git a/core/state/cached_writer.go b/core/state/cached_writer.go index 9f3459e3efb..388aefae0a0 100644 --- a/core/state/cached_writer.go +++ b/core/state/cached_writer.go @@ -1,8 +1,6 @@ package state import ( - "context" - "github.com/holiman/uint256" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types/accounts" @@ -20,8 +18,8 @@ func NewCachedWriter(w WriterWithChangeSets, cache *shards.StateCache) *CachedWr return &CachedWriter{w: w, cache: cache} } -func (cw *CachedWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { - if err := cw.w.UpdateAccountData(ctx, address, original, account); err != nil { +func (cw *CachedWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { + if err := cw.w.UpdateAccountData(address, original, account); err != nil { return err } cw.cache.SetAccountWrite(address.Bytes(), account) @@ -36,16 +34,16 @@ func (cw *CachedWriter) UpdateAccountCode(address common.Address, incarnation ui return nil } -func (cw *CachedWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { - if err := cw.w.DeleteAccount(ctx, address, original); err != nil { +func (cw *CachedWriter) DeleteAccount(address common.Address, original *accounts.Account) error { + if err := cw.w.DeleteAccount(address, original); err != nil { return err } cw.cache.SetAccountDelete(address.Bytes()) return nil } -func (cw *CachedWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { - if err := cw.w.WriteAccountStorage(ctx, address, incarnation, key, original, value); err != nil { +func (cw *CachedWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { + if err := cw.w.WriteAccountStorage(address, incarnation, key, original, value); err != nil { return err } if *original == *value { diff --git a/core/state/change_set_writer.go b/core/state/change_set_writer.go index 1b753081eb1..521791f7fff 100644 --- a/core/state/change_set_writer.go +++ b/core/state/change_set_writer.go @@ -1,7 +1,6 @@ package state import ( - "context" "fmt" "github.com/holiman/uint256" @@ -84,7 +83,7 @@ func accountsEqual(a1, a2 *accounts.Account) bool { return true } -func (w *ChangeSetWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { +func (w *ChangeSetWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { if !accountsEqual(original, account) || w.storageChanged[address] { w.accountChanges[address] = originalAccountData(original, true /*omitHashes*/) } @@ -95,12 +94,12 @@ func (w *ChangeSetWriter) UpdateAccountCode(address common.Address, incarnation return nil } -func (w *ChangeSetWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { +func (w *ChangeSetWriter) DeleteAccount(address common.Address, original *accounts.Account) error { w.accountChanges[address] = originalAccountData(original, false) return nil } -func (w *ChangeSetWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (w *ChangeSetWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { if *original == *value { return nil } diff --git a/core/state/database.go b/core/state/database.go index db4f6f3e1a3..0bcf0d0b2f5 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -18,8 +18,6 @@ package state import ( - "context" - "github.com/holiman/uint256" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types/accounts" @@ -41,10 +39,10 @@ type StateReader interface { } type StateWriter interface { - UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error + UpdateAccountData(address common.Address, original, account *accounts.Account) error UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error - DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error - WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error + DeleteAccount(address common.Address, original *accounts.Account) error + WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error CreateContract(address common.Address) error } @@ -63,11 +61,11 @@ func NewNoopWriter() *NoopWriter { return noopWriter } -func (nw *NoopWriter) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error { +func (nw *NoopWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { return nil } -func (nw *NoopWriter) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error { +func (nw *NoopWriter) DeleteAccount(address common.Address, original *accounts.Account) error { return nil } @@ -75,7 +73,7 @@ func (nw *NoopWriter) UpdateAccountCode(address common.Address, incarnation uint return nil } -func (nw *NoopWriter) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (nw *NoopWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { return nil } diff --git a/core/state/db_state_writer.go b/core/state/db_state_writer.go index 313850e1a9f..f6c834f7fe8 100644 --- a/core/state/db_state_writer.go +++ b/core/state/db_state_writer.go @@ -2,7 +2,6 @@ package state import ( "bytes" - "context" "encoding/binary" "fmt" @@ -60,8 +59,8 @@ func originalAccountData(original *accounts.Account, omitHashes bool) []byte { return originalData } -func (dsw *DbStateWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { - if err := dsw.csw.UpdateAccountData(ctx, address, original, account); err != nil { +func (dsw *DbStateWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { + if err := dsw.csw.UpdateAccountData(address, original, account); err != nil { return err } addrHash, err := common.HashData(address[:]) @@ -76,8 +75,8 @@ func (dsw *DbStateWriter) UpdateAccountData(ctx context.Context, address common. return nil } -func (dsw *DbStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { - if err := dsw.csw.DeleteAccount(ctx, address, original); err != nil { +func (dsw *DbStateWriter) DeleteAccount(address common.Address, original *accounts.Account) error { + if err := dsw.csw.DeleteAccount(address, original); err != nil { return err } addrHash, err := common.HashData(address[:]) @@ -116,9 +115,9 @@ func (dsw *DbStateWriter) UpdateAccountCode(address common.Address, incarnation return nil } -func (dsw *DbStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (dsw *DbStateWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { // We delegate here first to let the changeSetWrite make its own decision on whether to proceed in case *original == *value - if err := dsw.csw.WriteAccountStorage(ctx, address, incarnation, key, original, value); err != nil { + if err := dsw.csw.WriteAccountStorage(address, incarnation, key, original, value); err != nil { return err } if *original == *value { diff --git a/core/state/history_test.go b/core/state/history_test.go index eff700a974b..a111af15e66 100644 --- a/core/state/history_test.go +++ b/core/state/history_test.go @@ -1,7 +1,6 @@ package state import ( - "context" "fmt" "math/rand" "reflect" @@ -31,11 +30,10 @@ func TestMutationDeleteTimestamp(t *testing.T) { acc := make([]*accounts.Account, 10) addr := make([]common.Address, 10) blockWriter := NewPlainStateWriter(tx, tx, 1) - ctx := context.Background() emptyAccount := accounts.NewAccount() for i := range acc { acc[i], addr[i] = randomAccount(t) - if err := blockWriter.UpdateAccountData(ctx, addr[i], &emptyAccount /* original */, acc[i]); err != nil { + if err := blockWriter.UpdateAccountData(addr[i], &emptyAccount, acc[i]); err != nil { t.Fatal(err) } } @@ -221,7 +219,6 @@ func generateAccountsWithStorageAndHistory(t *testing.T, blockWriter *PlainState accStateStorage := make([]map[common.Hash]uint256.Int, numOfAccounts) accHistoryStateStorage := make([]map[common.Hash]uint256.Int, numOfAccounts) addrs := make([]common.Address, numOfAccounts) - ctx := context.Background() for i := range accHistory { accHistory[i], addrs[i] = randomAccount(t) accHistory[i].Balance = *uint256.NewInt(100) @@ -245,11 +242,11 @@ func generateAccountsWithStorageAndHistory(t *testing.T, blockWriter *PlainState value := uint256.NewInt(uint64(10 + j)) accHistoryStateStorage[i][key] = *value - if err := blockWriter.WriteAccountStorage(ctx, addrs[i], accHistory[i].Incarnation, &key, value, newValue); err != nil { + if err := blockWriter.WriteAccountStorage(addrs[i], accHistory[i].Incarnation, &key, value, newValue); err != nil { t.Fatal(err) } } - if err := blockWriter.UpdateAccountData(ctx, addrs[i], accHistory[i] /* original */, accState[i]); err != nil { + if err := blockWriter.UpdateAccountData(addrs[i], accHistory[i], accState[i]); err != nil { t.Fatal(err) } } @@ -1097,11 +1094,11 @@ type accData struct { func writeBlockData(t *testing.T, blockWriter *PlainStateWriter, data []accData) { for i := range data { if data[i].newVal != nil { - if err := blockWriter.UpdateAccountData(context.Background(), data[i].addr, data[i].oldVal, data[i].newVal); err != nil { + if err := blockWriter.UpdateAccountData(data[i].addr, data[i].oldVal, data[i].newVal); err != nil { t.Fatal(err) } } else { - if err := blockWriter.DeleteAccount(context.Background(), data[i].addr, data[i].oldVal); err != nil { + if err := blockWriter.DeleteAccount(data[i].addr, data[i].oldVal); err != nil { t.Fatal(err) } } @@ -1126,12 +1123,7 @@ type storageData struct { func writeStorageBlockData(t *testing.T, blockWriter *PlainStateWriter, data []storageData) { for i := range data { - if err := blockWriter.WriteAccountStorage(context.Background(), - data[i].addr, - data[i].inc, - &data[i].key, - data[i].oldVal, - data[i].newVal); err != nil { + if err := blockWriter.WriteAccountStorage(data[i].addr, data[i].inc, &data[i].key, data[i].oldVal, data[i].newVal); err != nil { t.Fatal(err) } } diff --git a/core/state/intra_block_state.go b/core/state/intra_block_state.go index 3bf12c074e4..f3acdcaf712 100644 --- a/core/state/intra_block_state.go +++ b/core/state/intra_block_state.go @@ -702,10 +702,10 @@ func (sdb *IntraBlockState) GetRefund() uint64 { return sdb.refund } -func updateAccount(ctx context.Context, stateWriter StateWriter, addr common.Address, stateObject *stateObject, isDirty bool) error { - emptyRemoval := params.GetForkFlag(ctx, params.IsEIP158Enabled) && stateObject.empty() +func updateAccount(EIP158Enabled bool, stateWriter StateWriter, addr common.Address, stateObject *stateObject, isDirty bool) error { + emptyRemoval := EIP158Enabled && stateObject.empty() if stateObject.suicided || (isDirty && emptyRemoval) { - if err := stateWriter.DeleteAccount(ctx, addr, &stateObject.original); err != nil { + if err := stateWriter.DeleteAccount(addr, &stateObject.original); err != nil { return err } stateObject.deleted = true @@ -723,10 +723,10 @@ func updateAccount(ctx context.Context, stateWriter StateWriter, addr common.Add return err } } - if err := stateObject.updateTrie(ctx, stateWriter); err != nil { + if err := stateObject.updateTrie(stateWriter); err != nil { return err } - if err := stateWriter.UpdateAccountData(ctx, addr, &stateObject.original, &stateObject.data); err != nil { + if err := stateWriter.UpdateAccountData(addr, &stateObject.original, &stateObject.data); err != nil { return err } } @@ -735,6 +735,7 @@ func updateAccount(ctx context.Context, stateWriter StateWriter, addr common.Add // FinalizeTx should be called after every transaction. func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWriter) error { + EIP158Enabled := params.GetForkFlag(ctx, params.IsEIP158Enabled) for addr := range sdb.journal.dirties { stateObject, exist := sdb.stateObjects[addr] if !exist { @@ -747,7 +748,7 @@ func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWri continue } - if err := updateAccount(ctx, stateWriter, addr, stateObject, true); err != nil { + if err := updateAccount(EIP158Enabled, stateWriter, addr, stateObject, true); err != nil { return err } @@ -761,12 +762,13 @@ func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWri // CommitBlock finalizes the state by removing the self destructed objects // and clears the journal as well as the refunds. func (sdb *IntraBlockState) CommitBlock(ctx context.Context, stateWriter StateWriter) error { + EIP158Enabled := params.GetForkFlag(ctx, params.IsEIP158Enabled) for addr := range sdb.journal.dirties { sdb.stateObjectsDirty[addr] = struct{}{} } for addr, stateObject := range sdb.stateObjects { _, isDirty := sdb.stateObjectsDirty[addr] - if err := updateAccount(ctx, stateWriter, addr, stateObject, isDirty); err != nil { + if err := updateAccount(EIP158Enabled, stateWriter, addr, stateObject, isDirty); err != nil { return err } } diff --git a/core/state/plain_readonly.go b/core/state/plain_readonly.go index 988a994bb99..8416b716a94 100644 --- a/core/state/plain_readonly.go +++ b/core/state/plain_readonly.go @@ -262,11 +262,11 @@ func (dbs *PlainDBState) ReadAccountIncarnation(address common.Address) (uint64, return acc.Incarnation - 1, nil } -func (dbs *PlainDBState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error { +func (dbs *PlainDBState) UpdateAccountData(address common.Address, original, account *accounts.Account) error { return nil } -func (dbs *PlainDBState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error { +func (dbs *PlainDBState) DeleteAccount(address common.Address, original *accounts.Account) error { return nil } @@ -274,7 +274,7 @@ func (dbs *PlainDBState) UpdateAccountCode(address common.Address, incarnation u return nil } -func (dbs *PlainDBState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (dbs *PlainDBState) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { t, ok := dbs.storage[address] if !ok { t = llrb.New() @@ -470,11 +470,11 @@ func (s *PlainKVState) ReadAccountIncarnation(address common.Address) (uint64, e return acc.Incarnation - 1, nil } -func (s *PlainKVState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error { +func (s *PlainKVState) UpdateAccountData(address common.Address, original, account *accounts.Account) error { return nil } -func (s *PlainKVState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error { +func (s *PlainKVState) DeleteAccount(address common.Address, original *accounts.Account) error { return nil } @@ -482,7 +482,7 @@ func (s *PlainKVState) UpdateAccountCode(address common.Address, incarnation uin return nil } -func (s *PlainKVState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (s *PlainKVState) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { t, ok := s.storage[address] if !ok { t = llrb.New() diff --git a/core/state/plain_state_writer.go b/core/state/plain_state_writer.go index cbeaecdae0b..369b07e4c5e 100644 --- a/core/state/plain_state_writer.go +++ b/core/state/plain_state_writer.go @@ -1,7 +1,6 @@ package state import ( - "context" "encoding/binary" "github.com/holiman/uint256" @@ -42,9 +41,9 @@ func (w *PlainStateWriter) SetAccumulator(accumulator *shards.Accumulator) *Plai return w } -func (w *PlainStateWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error { +func (w *PlainStateWriter) UpdateAccountData(address common.Address, original, account *accounts.Account) error { if w.csw != nil { - if err := w.csw.UpdateAccountData(ctx, address, original, account); err != nil { + if err := w.csw.UpdateAccountData(address, original, account); err != nil { return err } } @@ -71,9 +70,9 @@ func (w *PlainStateWriter) UpdateAccountCode(address common.Address, incarnation return w.db.Put(dbutils.PlainContractCodeBucket, dbutils.PlainGenerateStoragePrefix(address[:], incarnation), codeHash[:]) } -func (w *PlainStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error { +func (w *PlainStateWriter) DeleteAccount(address common.Address, original *accounts.Account) error { if w.csw != nil { - if err := w.csw.DeleteAccount(ctx, address, original); err != nil { + if err := w.csw.DeleteAccount(address, original); err != nil { return err } } @@ -93,9 +92,9 @@ func (w *PlainStateWriter) DeleteAccount(ctx context.Context, address common.Add return nil } -func (w *PlainStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { +func (w *PlainStateWriter) WriteAccountStorage(address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error { if w.csw != nil { - if err := w.csw.WriteAccountStorage(ctx, address, incarnation, key, original, value); err != nil { + if err := w.csw.WriteAccountStorage(address, incarnation, key, original, value); err != nil { return err } } diff --git a/core/state/state_object.go b/core/state/state_object.go index 211722ed83c..82369cf3c3b 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -18,7 +18,6 @@ package state import ( "bytes" - "context" "fmt" "io" "math/big" @@ -237,12 +236,12 @@ func (so *stateObject) setState(key *common.Hash, value uint256.Int) { } // updateTrie writes cached storage modifications into the object's storage trie. -func (so *stateObject) updateTrie(ctx context.Context, stateWriter StateWriter) error { +func (so *stateObject) updateTrie(stateWriter StateWriter) error { for key, value := range so.dirtyStorage { value := value original := so.blockOriginStorage[key] so.originStorage[key] = value - if err := stateWriter.WriteAccountStorage(ctx, so.address, so.data.GetIncarnation(), &key, &original, &value); err != nil { + if err := stateWriter.WriteAccountStorage(so.address, so.data.GetIncarnation(), &key, &original, &value); err != nil { return err } } diff --git a/core/state/state_test.go b/core/state/state_test.go index 24b3519cfe5..a9543a93873 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -54,9 +54,9 @@ func (s *StateSuite) TestDump(c *checker.C) { // write some of them to the trie ctx := context.TODO() - err := s.w.UpdateAccountData(ctx, obj1.address, &obj1.data, new(accounts.Account)) + err := s.w.UpdateAccountData(obj1.address, &obj1.data, new(accounts.Account)) c.Check(err, checker.IsNil) - err = s.w.UpdateAccountData(ctx, obj2.address, &obj2.data, new(accounts.Account)) + err = s.w.UpdateAccountData(obj2.address, &obj2.data, new(accounts.Account)) c.Check(err, checker.IsNil) err = s.state.FinalizeTx(ctx, s.w) @@ -301,11 +301,11 @@ func TestDump(t *testing.T) { // write some of them to the trie ctx := context.TODO() - err := w.UpdateAccountData(ctx, obj1.address, &obj1.data, new(accounts.Account)) + err := w.UpdateAccountData(obj1.address, &obj1.data, new(accounts.Account)) if err != nil { t.Fatal(err) } - err = w.UpdateAccountData(ctx, obj2.address, &obj2.data, new(accounts.Account)) + err = w.UpdateAccountData(obj2.address, &obj2.data, new(accounts.Account)) if err != nil { t.Fatal(err) } diff --git a/eth/stagedsync/testutil.go b/eth/stagedsync/testutil.go index 3a9d9985726..d0b1ec58f37 100644 --- a/eth/stagedsync/testutil.go +++ b/eth/stagedsync/testutil.go @@ -1,7 +1,6 @@ package stagedsync import ( - "context" "fmt" "math/big" "testing" @@ -90,7 +89,6 @@ func generateBlocks(t *testing.T, from uint64, numberOfBlocks uint64, stateWrite &acc1, &acc2, } - ctx := context.Background() for blockNumber := uint64(1); blockNumber < from+numberOfBlocks; blockNumber++ { updateIncarnation := difficulty != staticCodeStaticIncarnations && blockNumber%10 == 0 @@ -131,13 +129,13 @@ func generateBlocks(t *testing.T, from uint64, numberOfBlocks uint64, stateWrite var location common.Hash location.SetBytes(big.NewInt(int64(blockNumber)).Bytes()) if blockNumber >= from { - if err := blockWriter.WriteAccountStorage(ctx, addr, newAcc.Incarnation, &location, &oldValue, &newValue); err != nil { + if err := blockWriter.WriteAccountStorage(addr, newAcc.Incarnation, &location, &oldValue, &newValue); err != nil { t.Fatal(err) } } } if blockNumber >= from { - if err := blockWriter.UpdateAccountData(ctx, addr, oldAcc /* original */, newAcc /* new account */); err != nil { + if err := blockWriter.UpdateAccountData(addr, oldAcc, newAcc); err != nil { t.Fatal(err) } }