aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-17 00:53:18 +0800
committerGitHub <noreply@github.com>2017-11-17 00:53:18 +0800
commitb0190189a386d13eb2e8bbdb6d64d9ef8c0e572a (patch)
tree527d628292c98a8b550584fa0483a85c55779b50 /internal
parent87f5b4123c6e2a48ad67426a34763acc50c821f8 (diff)
downloadgo-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.gz
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.bz2
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.lz
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.xz
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.zst
go-tangerine-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.zip
core/vm, internal/ethapi: tracer no full storage, nicer json output (#15499)
* core/vm, internal/ethapi: tracer no full storage, nicer json output * core/vm, internal/ethapi: omit disabled trace fields
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go57
1 files changed, 32 insertions, 25 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 59a29d722..cf15d1c71 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -710,45 +710,52 @@ type ExecutionResult struct {
// StructLogRes stores a structured log emitted by the EVM while replaying a
// transaction in debug mode
type StructLogRes struct {
- Pc uint64 `json:"pc"`
- Op string `json:"op"`
- Gas uint64 `json:"gas"`
- GasCost uint64 `json:"gasCost"`
- Depth int `json:"depth"`
- Error error `json:"error"`
- Stack []string `json:"stack"`
- Memory []string `json:"memory"`
- Storage map[string]string `json:"storage"`
+ Pc uint64 `json:"pc"`
+ Op string `json:"op"`
+ Gas uint64 `json:"gas"`
+ GasCost uint64 `json:"gasCost"`
+ Depth int `json:"depth"`
+ Error error `json:"error,omitempty"`
+ Stack *[]string `json:"stack,omitempty"`
+ Memory *[]string `json:"memory,omitempty"`
+ Storage *map[string]string `json:"storage,omitempty"`
}
// formatLogs formats EVM returned structured logs for json output
-func FormatLogs(structLogs []vm.StructLog) []StructLogRes {
- formattedStructLogs := make([]StructLogRes, len(structLogs))
- for index, trace := range structLogs {
- formattedStructLogs[index] = StructLogRes{
+func FormatLogs(logs []vm.StructLog) []StructLogRes {
+ formatted := make([]StructLogRes, len(logs))
+ for index, trace := range logs {
+ formatted[index] = StructLogRes{
Pc: trace.Pc,
Op: trace.Op.String(),
Gas: trace.Gas,
GasCost: trace.GasCost,
Depth: trace.Depth,
Error: trace.Err,
- Stack: make([]string, len(trace.Stack)),
- Storage: make(map[string]string),
}
-
- for i, stackValue := range trace.Stack {
- formattedStructLogs[index].Stack[i] = fmt.Sprintf("%x", math.PaddedBigBytes(stackValue, 32))
+ if trace.Stack != nil {
+ 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 {
- formattedStructLogs[index].Memory = append(formattedStructLogs[index].Memory, fmt.Sprintf("%x", trace.Memory[i:i+32]))
+ if trace.Memory != nil {
+ 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 {
- formattedStructLogs[index].Storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
+ if trace.Storage != nil {
+ 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