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)
|
stackLen := len(stackData)
|
||||||
// Copy a snapshot of the current storage to a new container
|
// Copy a snapshot of the current storage to a new container
|
||||||
var storage Storage
|
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
|
// initialise new changed values storage container for this contract
|
||||||
// if not present.
|
// if not present.
|
||||||
if l.storage[contract.Address()] == nil {
|
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)
|
value = l.env.StateDB.GetState(contract.Address(), address)
|
||||||
)
|
)
|
||||||
l.storage[contract.Address()][address] = value
|
l.storage[contract.Address()][address] = value
|
||||||
storage = l.storage[contract.Address()].Copy()
|
recordStorageDetail = true
|
||||||
|
if !l.cfg.DisableStorage {
|
||||||
|
storage = l.storage[contract.Address()].Copy()
|
||||||
|
}
|
||||||
} else if op == vm.SSTORE && stackLen >= 2 {
|
} else if op == vm.SSTORE && stackLen >= 2 {
|
||||||
// capture SSTORE opcodes and record the written entry in the local storage.
|
// capture SSTORE opcodes and record the written entry in the local storage.
|
||||||
var (
|
var (
|
||||||
|
|
@ -240,7 +244,10 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
||||||
address = common.Hash(stackData[stackLen-1].Bytes32())
|
address = common.Hash(stackData[stackLen-1].Bytes32())
|
||||||
)
|
)
|
||||||
l.storage[contract.Address()][address] = value
|
l.storage[contract.Address()][address] = value
|
||||||
storage = l.storage[contract.Address()].Copy()
|
recordStorageDetail = true
|
||||||
|
if !l.cfg.DisableStorage {
|
||||||
|
storage = l.storage[contract.Address()].Copy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var rdata []byte
|
var rdata []byte
|
||||||
|
|
@ -251,7 +258,7 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
|
||||||
// create a new snapshot of the EVM.
|
// 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}
|
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 {
|
if err := traceStorage(l, scope, structLog.getOrInitExtraData()); err != nil {
|
||||||
log.Error("Failed to trace data", "opcode", op.String(), "err", err)
|
log.Error("Failed to trace data", "opcode", op.String(), "err", err)
|
||||||
}
|
}
|
||||||
|
|
@ -600,6 +607,7 @@ func FormatLogs(logs []StructLog) []types.StructLogRes {
|
||||||
Depth: trace.Depth,
|
Depth: trace.Depth,
|
||||||
Error: trace.ErrorString(),
|
Error: trace.ErrorString(),
|
||||||
RefundCounter: trace.RefundCounter,
|
RefundCounter: trace.RefundCounter,
|
||||||
|
ExtraData: trace.ExtraData,
|
||||||
}
|
}
|
||||||
if trace.Stack != nil {
|
if trace.Stack != nil {
|
||||||
stack := make([]string, len(trace.Stack))
|
stack := make([]string, len(trace.Stack))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue