diff --git a/core/state/statedb.go b/core/state/statedb.go index 854aaf6109..8b09ea89f6 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -745,7 +745,7 @@ type removedAccountWithBalance struct { balance *uint256.Int } -// EmitLogsForBurnAccounts emits the eth burn logs for accounts scheduled for +// LogsForBurnAccounts returns the eth burn logs for accounts scheduled for // removal which still have positive balance. The purpose of this function is // to handle a corner case of EIP-7708 where a self-destructed account might // still receive funds between sending/burning its previous balance and actual @@ -755,7 +755,7 @@ type removedAccountWithBalance struct { // // This function should only be invoked at the transaction boundary, specifically // before the Finalise. -func (s *StateDB) EmitLogsForBurnAccounts() { +func (s *StateDB) LogsForBurnAccounts() []*types.Log { var list []removedAccountWithBalance for addr := range s.journal.dirties { if obj, exist := s.stateObjects[addr]; exist && obj.selfDestructed && !obj.Balance().IsZero() { @@ -765,14 +765,17 @@ func (s *StateDB) EmitLogsForBurnAccounts() { }) } } - if list != nil { - sort.Slice(list, func(i, j int) bool { - return list[i].address.Cmp(list[j].address) < 0 - }) + if list == nil { + return nil } - for _, acct := range list { - s.AddLog(types.EthBurnLog(acct.address, acct.balance)) + sort.Slice(list, func(i, j int) bool { + return list[i].address.Cmp(list[j].address) < 0 + }) + logs := make([]*types.Log, len(list)) + for i, acct := range list { + logs[i] = types.EthBurnLog(acct.address, acct.balance) } + return logs } // Finalise finalises the state by removing the destructed objects and clears diff --git a/core/state/statedb_hooked.go b/core/state/statedb_hooked.go index 8c217fba48..52cf98d19b 100644 --- a/core/state/statedb_hooked.go +++ b/core/state/statedb_hooked.go @@ -229,8 +229,8 @@ func (s *hookedStateDB) AddLog(log *types.Log) { } } -func (s *hookedStateDB) EmitLogsForBurnAccounts() { - s.inner.EmitLogsForBurnAccounts() +func (s *hookedStateDB) LogsForBurnAccounts() []*types.Log { + return s.inner.LogsForBurnAccounts() } func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) { diff --git a/core/state_transition.go b/core/state_transition.go index 52375bedaa..bd7e5daeff 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -584,7 +584,9 @@ func (st *stateTransition) execute() (*ExecutionResult, error) { } } if rules.IsAmsterdam { - st.evm.StateDB.EmitLogsForBurnAccounts() + for _, log := range st.evm.StateDB.LogsForBurnAccounts() { + st.evm.StateDB.AddLog(log) + } } return &ExecutionResult{ UsedGas: st.gasUsed(), diff --git a/core/vm/interface.go b/core/vm/interface.go index 6a93846ac5..d7c4340e06 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -87,7 +87,7 @@ type StateDB interface { Snapshot() int AddLog(*types.Log) - EmitLogsForBurnAccounts() + LogsForBurnAccounts() []*types.Log AddPreimage(common.Hash, []byte) Witness() *stateless.Witness