Skip to content

Commit 2a2c432

Browse files
committed
core/state: apply suggestions from review
1 parent 66fc14a commit 2a2c432

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

core/state/journal.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package state
1919
import (
2020
"fmt"
2121
"maps"
22+
"slices"
2223
"sort"
2324

2425
"github.com/ethereum/go-ethereum/common"
@@ -68,7 +69,7 @@ func newJournal() *journal {
6869
func (j *journal) Reset() {
6970
j.entries = j.entries[:0]
7071
j.validRevisions = j.validRevisions[:0]
71-
j.dirties = make(map[common.Address]int)
72+
clear(j.dirties)
7273
j.nextRevisionId = 0
7374
}
7475

@@ -140,8 +141,10 @@ func (j *journal) copy() *journal {
140141
entries = append(entries, j.entries[i].copy())
141142
}
142143
return &journal{
143-
entries: entries,
144-
dirties: maps.Clone(j.dirties),
144+
entries: entries,
145+
dirties: maps.Clone(j.dirties),
146+
validRevisions: slices.Clone(j.validRevisions),
147+
nextRevisionId: j.nextRevisionId,
145148
}
146149
}
147150

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,10 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
500500
// Regardless of whether it is already destructed or not, we do have to
501501
// journal the balance-change, if we set it to zero here.
502502
if !stateObject.Balance().IsZero() {
503-
stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct)
504503
if s.logger != nil && s.logger.OnBalanceChange != nil {
505504
s.logger.OnBalanceChange(addr, stateObject.Balance().ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct)
506505
}
506+
stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct)
507507
}
508508
// If it is already marked as self-destructed, we do not need to add it
509509
// for journalling a second time.

0 commit comments

Comments
 (0)