diff --git a/executor/extension/primer/primer.go b/executor/extension/primer/primer.go index 415f64c4c..5329465f4 100644 --- a/executor/extension/primer/primer.go +++ b/executor/extension/primer/primer.go @@ -168,7 +168,10 @@ func (p *stateDbPrimer[T]) prime(stateDb state.StateDB) error { return fmt.Errorf("cannot generate update-set; %w", err) } if hasPrimed { - p.ctx.SuicideAccounts(stateDb, deletedAccounts) + err = p.ctx.SuicideAccounts(stateDb, deletedAccounts) + if err != nil { + return err + } } if err = p.ctx.PrimeStateDB(substatecontext.NewWorldState(update), stateDb); err != nil { return fmt.Errorf("cannot prime state-db; %w", err) diff --git a/utils/prime_ctx.go b/utils/prime_ctx.go index c110a63b8..77f57fbb5 100644 --- a/utils/prime_ctx.go +++ b/utils/prime_ctx.go @@ -231,11 +231,17 @@ func (pc *PrimeContext) PrimeStateDBRandom(ws txcontext.WorldState, db state.Sta } // SuicideAccounts clears storage of all input accounts. -func (pc *PrimeContext) SuicideAccounts(db state.StateDB, accounts []common.Address) { +func (pc *PrimeContext) SuicideAccounts(db state.StateDB, accounts []common.Address) error { count := 0 db.BeginSyncPeriod(0) - db.BeginBlock(pc.block) - db.BeginTransaction(0) + err := db.BeginBlock(pc.block) + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts BeginBlock: %w", err) + } + err = db.BeginTransaction(0) + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts BeginTransaction: %w", err) + } for _, addr := range accounts { if db.Exist(addr) { db.Suicide(addr) @@ -244,8 +250,14 @@ func (pc *PrimeContext) SuicideAccounts(db state.StateDB, accounts []common.Addr pc.exist[addr] = false } } - db.EndTransaction() - db.EndBlock() + err = db.EndTransaction() + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts EndTransaction: %w", err) + } + err = db.EndBlock() + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts EndBlock: %w", err) + } db.EndSyncPeriod() pc.block++ pc.log.Infof("\t\t %v suicided accounts were removed from statedb (before priming).", count) diff --git a/utils/statedb.go b/utils/statedb.go index ecb48166b..cbbc50243 100644 --- a/utils/statedb.go +++ b/utils/statedb.go @@ -260,14 +260,26 @@ func DeleteDestroyedAccountsFromStateDB(db state.StateDB, cfg *Config, target ui return nil } db.BeginSyncPeriod(0) - db.BeginBlock(target) - db.BeginTransaction(0) + err = db.BeginBlock(target) + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts BeginBlock: %w", err) + } + err = db.BeginTransaction(0) + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts BeginTransaction: %w", err) + } for _, addr := range accounts { db.Suicide(addr) log.Debugf("Perform suicide on %v", addr) } - db.EndTransaction() - db.EndBlock() + err = db.EndTransaction() + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts EndTransaction: %w", err) + } + err = db.EndBlock() + if err != nil { + return fmt.Errorf("DeleteDestroyedAccounts EndBlock: %w", err) + } db.EndSyncPeriod() return nil }