From eb196194a0823fd45ba541a0848ee3c96a87a23f Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 14 May 2024 09:38:22 +0200 Subject: [PATCH] core/state: apply suggestions from review --- core/state/journal.go | 9 ++++++--- core/state/statedb.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index d5c5eb3525e3e..0f7d0e61ab33f 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -19,6 +19,7 @@ package state import ( "fmt" "maps" + "slices" "sort" "github.com/ethereum/go-ethereum/common" @@ -68,7 +69,7 @@ func newJournal() *journal { func (j *journal) Reset() { j.entries = j.entries[:0] j.validRevisions = j.validRevisions[:0] - j.dirties = make(map[common.Address]int) + clear(j.dirties) j.nextRevisionId = 0 } @@ -140,8 +141,10 @@ func (j *journal) copy() *journal { entries = append(entries, j.entries[i].copy()) } return &journal{ - entries: entries, - dirties: maps.Clone(j.dirties), + entries: entries, + dirties: maps.Clone(j.dirties), + validRevisions: slices.Clone(j.validRevisions), + nextRevisionId: j.nextRevisionId, } } diff --git a/core/state/statedb.go b/core/state/statedb.go index b4db07d5e0d6f..3ca5437ff62e7 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -483,10 +483,10 @@ func (s *StateDB) SelfDestruct(addr common.Address) { // Regardless of whether it is already destructed or not, we do have to // journal the balance-change, if we set it to zero here. if !stateObject.Balance().IsZero() { - stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct) if s.logger != nil && s.logger.OnBalanceChange != nil { s.logger.OnBalanceChange(addr, stateObject.Balance().ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct) } + stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct) } // If it is already marked as self-destructed, we do not need to add it // for journalling a second time.