mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
core/vm, internal/ethapi: omit disabled trace fields
This commit is contained in:
parent
8e1af23fed
commit
6002967886
2 changed files with 35 additions and 31 deletions
|
|
@ -135,14 +135,13 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
|
||||||
)
|
)
|
||||||
l.changedValues[contract.Address()][address] = value
|
l.changedValues[contract.Address()][address] = value
|
||||||
}
|
}
|
||||||
// copy a snapstot of the current memory state to a new buffer
|
// Copy a snapstot of the current memory state to a new buffer
|
||||||
var mem []byte
|
var mem []byte
|
||||||
if !l.cfg.DisableMemory {
|
if !l.cfg.DisableMemory {
|
||||||
mem = make([]byte, len(memory.Data()))
|
mem = make([]byte, len(memory.Data()))
|
||||||
copy(mem, memory.Data())
|
copy(mem, memory.Data())
|
||||||
}
|
}
|
||||||
|
// Copy a snapshot of the current stack state to a new buffer
|
||||||
// copy a snapshot of the current stack state to a new buffer
|
|
||||||
var stck []*big.Int
|
var stck []*big.Int
|
||||||
if !l.cfg.DisableStack {
|
if !l.cfg.DisableStack {
|
||||||
stck = make([]*big.Int, len(stack.Data()))
|
stck = make([]*big.Int, len(stack.Data()))
|
||||||
|
|
@ -150,13 +149,9 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
|
||||||
stck[i] = new(big.Int).Set(item)
|
stck[i] = new(big.Int).Set(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Copy a snapshot of the current storage to a new container
|
||||||
// Copy the storage based on the settings specified in the log config. If full storage
|
|
||||||
// is disabled (default) we can use the simple Storage.Copy method, otherwise we use
|
|
||||||
// the state object to query for all values (slow process).
|
|
||||||
var storage Storage
|
var storage Storage
|
||||||
if !l.cfg.DisableStorage {
|
if !l.cfg.DisableStorage {
|
||||||
// Copy a snapshot of the current storage to a new container.
|
|
||||||
storage = l.changedValues[contract.Address()].Copy()
|
storage = l.changedValues[contract.Address()].Copy()
|
||||||
}
|
}
|
||||||
// create a new snaptshot of the EVM.
|
// create a new snaptshot of the EVM.
|
||||||
|
|
|
||||||
|
|
@ -710,43 +710,52 @@ type ExecutionResult struct {
|
||||||
// StructLogRes stores a structured log emitted by the EVM while replaying a
|
// StructLogRes stores a structured log emitted by the EVM while replaying a
|
||||||
// transaction in debug mode
|
// transaction in debug mode
|
||||||
type StructLogRes struct {
|
type StructLogRes struct {
|
||||||
Pc uint64 `json:"pc"`
|
Pc uint64 `json:"pc"`
|
||||||
Op string `json:"op"`
|
Op string `json:"op"`
|
||||||
Gas uint64 `json:"gas"`
|
Gas uint64 `json:"gas"`
|
||||||
GasCost uint64 `json:"gasCost"`
|
GasCost uint64 `json:"gasCost"`
|
||||||
Depth int `json:"depth"`
|
Depth int `json:"depth"`
|
||||||
Error error `json:"error,omitempty"`
|
Error error `json:"error,omitempty"`
|
||||||
Stack []string `json:"stack"`
|
Stack *[]string `json:"stack,omitempty"`
|
||||||
Memory []string `json:"memory"`
|
Memory *[]string `json:"memory,omitempty"`
|
||||||
Storage map[string]string `json:"storage"`
|
Storage *map[string]string `json:"storage,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatLogs formats EVM returned structured logs for json output
|
// formatLogs formats EVM returned structured logs for json output
|
||||||
func FormatLogs(structLogs []vm.StructLog) []StructLogRes {
|
func FormatLogs(logs []vm.StructLog) []StructLogRes {
|
||||||
formattedStructLogs := make([]StructLogRes, len(structLogs))
|
formatted := make([]StructLogRes, len(logs))
|
||||||
for index, trace := range structLogs {
|
for index, trace := range logs {
|
||||||
formattedStructLogs[index] = StructLogRes{
|
formatted[index] = StructLogRes{
|
||||||
Pc: trace.Pc,
|
Pc: trace.Pc,
|
||||||
Op: trace.Op.String(),
|
Op: trace.Op.String(),
|
||||||
Gas: trace.Gas,
|
Gas: trace.Gas,
|
||||||
GasCost: trace.GasCost,
|
GasCost: trace.GasCost,
|
||||||
Depth: trace.Depth,
|
Depth: trace.Depth,
|
||||||
Error: trace.Err,
|
Error: trace.Err,
|
||||||
Stack: make([]string, len(trace.Stack)),
|
|
||||||
Memory: make([]string, 0, (len(trace.Memory)+31)/32),
|
|
||||||
Storage: make(map[string]string),
|
|
||||||
}
|
}
|
||||||
for i, stackValue := range trace.Stack {
|
if trace.Stack != nil {
|
||||||
formattedStructLogs[index].Stack[i] = fmt.Sprintf("%x", math.PaddedBigBytes(stackValue, 32))
|
stack := make([]string, len(trace.Stack))
|
||||||
|
for i, stackValue := range trace.Stack {
|
||||||
|
stack[i] = fmt.Sprintf("%x", math.PaddedBigBytes(stackValue, 32))
|
||||||
|
}
|
||||||
|
formatted[index].Stack = &stack
|
||||||
}
|
}
|
||||||
for i := 0; i+32 <= len(trace.Memory); i += 32 {
|
if trace.Memory != nil {
|
||||||
formattedStructLogs[index].Memory = append(formattedStructLogs[index].Memory, fmt.Sprintf("%x", trace.Memory[i:i+32]))
|
memory := make([]string, 0, (len(trace.Memory)+31)/32)
|
||||||
|
for i := 0; i+32 <= len(trace.Memory); i += 32 {
|
||||||
|
memory = append(memory, fmt.Sprintf("%x", trace.Memory[i:i+32]))
|
||||||
|
}
|
||||||
|
formatted[index].Memory = &memory
|
||||||
}
|
}
|
||||||
for i, storageValue := range trace.Storage {
|
if trace.Storage != nil {
|
||||||
formattedStructLogs[index].Storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
|
storage := make(map[string]string)
|
||||||
|
for i, storageValue := range trace.Storage {
|
||||||
|
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
|
||||||
|
}
|
||||||
|
formatted[index].Storage = &storage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formattedStructLogs
|
return formatted
|
||||||
}
|
}
|
||||||
|
|
||||||
// rpcOutputBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
|
// rpcOutputBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue