From 01f050b96ed5a1c9721107167023e0e64464cb15 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 27 Aug 2024 13:54:26 +0800 Subject: [PATCH] core/state: address comments --- core/state/journal.go | 8 ++++---- core/state/state_object.go | 2 +- core/state/statedb.go | 3 --- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index 4b69f97caa..f180a5dae4 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -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] @@ -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}) } diff --git a/core/state/state_object.go b/core/state/state_object.go index 87e15e3383..366bdc2747 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -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) diff --git a/core/state/statedb.go b/core/state/statedb.go index d9bf8d8126..29bc830f09 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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) - } stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct) } // If it is already marked as self-destructed, we do not need to add it