mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
fix(traces): several tracing fixes (#830)
* fix(trace): add `extraData` * fix(trace): fix `StructLogger`'s `CaptureState`
This commit is contained in:
parent
72577219c0
commit
5e255cf5b1
1 changed files with 12 additions and 4 deletions
|
|
@ -219,7 +219,8 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
|||
stackLen := len(stackData)
|
||||
// Copy a snapshot of the current storage to a new container
|
||||
var storage Storage
|
||||
if !l.cfg.DisableStorage && (op == vm.SLOAD || op == vm.SSTORE) {
|
||||
var recordStorageDetail bool
|
||||
if op == vm.SLOAD || op == vm.SSTORE {
|
||||
// initialise new changed values storage container for this contract
|
||||
// if not present.
|
||||
if l.storage[contract.Address()] == nil {
|
||||
|
|
@ -232,7 +233,10 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
|||
value = l.env.StateDB.GetState(contract.Address(), address)
|
||||
)
|
||||
l.storage[contract.Address()][address] = value
|
||||
recordStorageDetail = true
|
||||
if !l.cfg.DisableStorage {
|
||||
storage = l.storage[contract.Address()].Copy()
|
||||
}
|
||||
} else if op == vm.SSTORE && stackLen >= 2 {
|
||||
// capture SSTORE opcodes and record the written entry in the local storage.
|
||||
var (
|
||||
|
|
@ -240,9 +244,12 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
|||
address = common.Hash(stackData[stackLen-1].Bytes32())
|
||||
)
|
||||
l.storage[contract.Address()][address] = value
|
||||
recordStorageDetail = true
|
||||
if !l.cfg.DisableStorage {
|
||||
storage = l.storage[contract.Address()].Copy()
|
||||
}
|
||||
}
|
||||
}
|
||||
var rdata []byte
|
||||
if l.cfg.EnableReturnData {
|
||||
rdata = make([]byte, len(rData))
|
||||
|
|
@ -251,7 +258,7 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
|||
// create a new snapshot of the EVM.
|
||||
structLog := StructLog{pc, op, gas, cost, mem, memory.Len(), stck, rdata, storage, depth, l.env.StateDB.GetRefund(), err, nil}
|
||||
|
||||
if !l.cfg.DisableStorage && (op == vm.SLOAD || op == vm.SSTORE) {
|
||||
if recordStorageDetail {
|
||||
if err := traceStorage(l, scope, structLog.getOrInitExtraData()); err != nil {
|
||||
log.Error("Failed to trace data", "opcode", op.String(), "err", err)
|
||||
}
|
||||
|
|
@ -600,6 +607,7 @@ func FormatLogs(logs []StructLog) []types.StructLogRes {
|
|||
Depth: trace.Depth,
|
||||
Error: trace.ErrorString(),
|
||||
RefundCounter: trace.RefundCounter,
|
||||
ExtraData: trace.ExtraData,
|
||||
}
|
||||
if trace.Stack != nil {
|
||||
stack := make([]string, len(trace.Stack))
|
||||
|
|
|
|||
Loading…
Reference in a new issue