Skip to content

Commit

Permalink
Change IsDirty to Transaction level
Browse files Browse the repository at this point in the history
We don't want a reverted transaction to show up in written trace because it was touched by a previous transaction.
  • Loading branch information
cffls committed Nov 5, 2024
1 parent eb7aecc commit 37883dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions core/state/intra_block_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,9 @@ func (sdb *IntraBlockState) SeenAccount(addr libcommon.Address) bool {
return ok
}

func (sdb *IntraBlockState) IsDirty(addr libcommon.Address) bool {
_, dirtyObj := sdb.stateObjectsDirty[addr]
_, dirtyJournal := sdb.journal.dirties[addr]
return dirtyObj || dirtyJournal
func (sdb *IntraBlockState) IsDirtyJournal(addr libcommon.Address) bool {
_, ok := sdb.journal.dirties[addr]
return ok
}

func (sdb *IntraBlockState) HasLiveState(addr libcommon.Address, key *libcommon.Hash) bool {
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evmtypes/evmtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type IntraBlockState interface {
SetState(common.Address, *common.Hash, uint256.Int)
HasLiveAccount(addr common.Address) bool
SeenAccount(addr common.Address) bool
IsDirty(addr common.Address) bool
IsDirtyJournal(addr common.Address) bool
HasLiveState(addr common.Address, key *common.Hash) bool

GetTransientState(addr common.Address, key common.Hash) uint256.Int
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/native/zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (t *zeroTracer) CaptureTxEnd(restGas uint64) {
trace.StorageRead = nil
}

if len(trace.StorageWritten) == 0 || !hasLiveAccount || !t.env.IntraBlockState().IsDirty(addr) {
if len(trace.StorageWritten) == 0 || !hasLiveAccount || !t.env.IntraBlockState().IsDirtyJournal(addr) {
trace.StorageWritten = nil
} else {
// A slot write could be reverted if the transaction is reverted. We will need to read the value from the statedb again to get the correct value.
Expand Down

0 comments on commit 37883dd

Please sign in to comment.