Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/state: semantic journalling (part 1) #28880

Merged
merged 9 commits into from
Aug 28, 2024
8 changes: 4 additions & 4 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func newJournal() *journal {
}
}

// reset clears the journal, after this operation the journal can be used
// as new. It is semantically similar to calling 'newJournal', but the underlying
// slices can be reused.
// reset clears the journal, after this operation the journal can be used anew.
// It is semantically similar to calling 'newJournal', but the underlying slices
// can be reused.
func (j *journal) reset() {
j.entries = j.entries[:0]
j.validRevisions = j.validRevisions[:0]
Expand Down Expand Up @@ -192,7 +192,7 @@ func (j *journal) balanceChange(addr common.Address, previous *uint256.Int) {
})
}

func (j *journal) codeChange(address common.Address) {
func (j *journal) setCode(address common.Address) {
j.append(codeChange{account: &address})
}

Expand Down
2 changes: 1 addition & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func (s *stateObject) CodeSize() int {
}

func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
s.db.journal.codeChange(s.address)
s.db.journal.setCode(s.address)
if s.db.logger != nil && s.db.logger.OnCodeChange != nil {
// TODO remove prevcode from this callback
s.db.logger.OnCodeChange(s.address, common.BytesToHash(s.CodeHash()), nil, codeHash, code)
Expand Down
3 changes: 0 additions & 3 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,6 @@ 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() {
if s.logger != nil && s.logger.OnBalanceChange != nil {
s.logger.OnBalanceChange(addr, stateObject.Balance().ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct)
}
rjl493456442 marked this conversation as resolved.
Show resolved Hide resolved
stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct)
}
// If it is already marked as self-destructed, we do not need to add it
Expand Down