Skip to content

Commit

Permalink
Remove all side effects from zero tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls committed Aug 20, 2024
1 parent 644a2bf commit 2fd6ff4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions eth/tracers/native/zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ func (t *zeroTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco
t.addAccountToTrace(addr)
t.addOpCodeToAccount(addr, op)
case op == vm.CREATE:
nonce := t.env.IntraBlockState().GetNonce(caller)
nonce := uint64(0)
if t.env.IntraBlockState().HasLiveAccount(caller) {
nonce = t.env.IntraBlockState().GetNonce(caller)
}
addr := crypto.CreateAddress(caller, nonce)
t.addAccountToTrace(addr)
t.addOpCodeToAccount(addr, op)
Expand Down Expand Up @@ -348,12 +351,19 @@ func (t *zeroTracer) addAccountToTrace(addr libcommon.Address) {
return
}

nonce := uint256.NewInt(t.env.IntraBlockState().GetNonce(addr))
codeHash := t.env.IntraBlockState().GetCodeHash(addr)
balance := uint256.NewInt(0)
nonce := uint256.NewInt(0)
codeHash := libcommon.Hash{}

if t.env.IntraBlockState().HasLiveAccount(addr) {
nonce = uint256.NewInt(t.env.IntraBlockState().GetNonce(addr))
balance = t.env.IntraBlockState().GetBalance(addr)
codeHash = t.env.IntraBlockState().GetCodeHash(addr)
}

t.tx.Traces[addr] = &types.TxnTrace{
Balance: t.env.IntraBlockState().GetBalance(addr).Clone(),
Nonce: nonce,
Balance: balance.Clone(),
Nonce: nonce.Clone(),
CodeUsage: &types.ContractCodeUsage{Read: &codeHash},
StorageWritten: make(map[libcommon.Hash]*uint256.Int),
StorageRead: make([]libcommon.Hash, 0),
Expand Down

0 comments on commit 2fd6ff4

Please sign in to comment.