Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 0xPolygonZero/erigon
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: feat/zero
Choose a base ref
...
head repository: cffls/erigon
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feat/zero
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 5, 2024

  1. Copy the full SHA
    eb7aecc View commit details
  2. Change IsDirty to Transaction level

    We don't want a reverted transaction to show up in written trace because it was touched by a previous transaction.
    cffls committed Nov 5, 2024
    Copy the full SHA
    37883dd View commit details

Commits on Nov 6, 2024

  1. Add storage read whenever there is a sstore

    This fixes an issue when a storage slot is
    * written but got reverted
    * never read by sLoad opcode
    
    When this happens, we still need to include the storage slot in the trace.
    cffls committed Nov 6, 2024
    Copy the full SHA
    ea8cd3c View commit details
Showing with 8 additions and 1 deletion.
  1. +5 −0 core/state/intra_block_state.go
  2. +1 −0 core/vm/evmtypes/evmtypes.go
  3. +2 −1 eth/tracers/native/zero.go
5 changes: 5 additions & 0 deletions core/state/intra_block_state.go
Original file line number Diff line number Diff line change
@@ -426,6 +426,11 @@ func (sdb *IntraBlockState) SeenAccount(addr libcommon.Address) bool {
return ok
}

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 {
if stateObject := sdb.stateObjects[addr]; stateObject != nil {
if _, ok := stateObject.originStorage[*key]; ok {
1 change: 1 addition & 0 deletions core/vm/evmtypes/evmtypes.go
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ type IntraBlockState interface {
SetState(common.Address, *common.Hash, uint256.Int)
HasLiveAccount(addr common.Address) bool
SeenAccount(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
3 changes: 2 additions & 1 deletion eth/tracers/native/zero.go
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ func (t *zeroTracer) CaptureTxEnd(restGas uint64) {
trace.StorageRead = nil
}

if len(trace.StorageWritten) == 0 || !hasLiveAccount {
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.
@@ -379,6 +379,7 @@ func (t *zeroTracer) addSLOADToAccount(addr libcommon.Address, key libcommon.Has

func (t *zeroTracer) addSSTOREToAccount(addr libcommon.Address, key libcommon.Hash, value *uint256.Int) {
t.tx.Traces[addr].StorageWritten[key] = value
t.tx.Traces[addr].StorageReadMap[key] = struct{}{}
t.addOpCodeToAccount(addr, vm.SSTORE)
}