Skip to content

Commit

Permalink
core/state: apply suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed May 14, 2024
1 parent 68052fb commit cd1fa81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/holiman/uint256"
"slices"
)

type revision struct {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,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.
Expand Down

0 comments on commit cd1fa81

Please sign in to comment.