diff --git a/core/state_transition.go b/core/state_transition.go index a41b62f0ec88..3b5f81b16632 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -288,11 +288,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { return nil, err } - var err error if st.evm.Config.Debug { st.evm.Config.Tracer.CaptureTxStart(st.initialGas) defer func() { - st.evm.Config.Tracer.CaptureTxEnd(st.gas, err) + st.evm.Config.Tracer.CaptureTxEnd(st.gas) }() } @@ -301,11 +300,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { sender = vm.AccountRef(msg.From()) rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil) contractCreation = msg.To() == nil - gas uint64 ) // Check clauses 4-5, subtract intrinsic gas if everything is correct - gas, err = IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, rules.IsHomestead, rules.IsIstanbul) + gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, rules.IsHomestead, rules.IsIstanbul) if err != nil { return nil, err } diff --git a/core/vm/logger.go b/core/vm/logger.go index 6b5ba08c6049..1067947d47cd 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -31,7 +31,7 @@ import ( type EVMLogger interface { // Transaction level CaptureTxStart(gasLimit uint64) - CaptureTxEnd(remainingGas uint64, err error) + CaptureTxEnd(restGas uint64) // Top call frame CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) diff --git a/eth/tracers/js/tracer.go b/eth/tracers/js/tracer.go index 37208c5ff5e1..a71d2920ffaa 100644 --- a/eth/tracers/js/tracer.go +++ b/eth/tracers/js/tracer.go @@ -679,13 +679,18 @@ func wrapError(context string, err error) error { return fmt.Errorf("%v in server-side tracer function '%v'", err, context) } +// CaptureTxStart implements the Tracer interface and is invoked at the beginning of +// transaction processing. func (jst *jsTracer) CaptureTxStart(gasLimit uint64) { jst.gasLimit = gasLimit } -func (*jsTracer) CaptureTxEnd(remainingGas uint64, _ error) {} +// CaptureTxStart implements the Tracer interface and is invoked at the end of +// transaction processing. +func (*jsTracer) CaptureTxEnd(restGas uint64) {} -// CaptureStart implements the Tracer interface to initialize the tracing operation. +// CaptureStart implements the Tracer interface and is invoked before executing the +// top-level call frame of a transaction. func (jst *jsTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { jst.env = env jst.ctx["type"] = "CALL" @@ -760,7 +765,7 @@ func (jst *jsTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, sco } } -// CaptureEnd is called after the call finishes to finalize the tracing. +// CaptureEnd is called after the top-level call finishes. func (jst *jsTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) { jst.ctx["output"] = output jst.ctx["time"] = t.String() diff --git a/eth/tracers/logger/access_list_tracer.go b/eth/tracers/logger/access_list_tracer.go index 74f9a5f4d9bc..37f71a05abfb 100644 --- a/eth/tracers/logger/access_list_tracer.go +++ b/eth/tracers/logger/access_list_tracer.go @@ -174,8 +174,9 @@ func (*AccessListTracer) CaptureEnter(typ vm.OpCode, from common.Address, to com func (*AccessListTracer) CaptureExit(output []byte, gasUsed uint64, err error) {} -func (*AccessListTracer) CaptureTxStart(_ uint64) {} -func (*AccessListTracer) CaptureTxEnd(_ uint64, _ error) {} +func (*AccessListTracer) CaptureTxStart(gasLimit uint64) {} + +func (*AccessListTracer) CaptureTxEnd(restGas uint64) {} // AccessList returns the current accesslist maintained by the tracer. func (a *AccessListTracer) AccessList() types.AccessList { diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index 443b233c5552..fe15c97ef7cd 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -223,8 +223,9 @@ func (l *StructLogger) CaptureEnter(typ vm.OpCode, from common.Address, to commo func (l *StructLogger) CaptureExit(output []byte, gasUsed uint64, err error) {} -func (*StructLogger) CaptureTxStart(_ uint64) {} -func (*StructLogger) CaptureTxEnd(_ uint64, _ error) {} +func (*StructLogger) CaptureTxStart(gasLimit uint64) {} + +func (*StructLogger) CaptureTxEnd(restGas uint64) {} // StructLogs returns the captured log entries. func (l *StructLogger) StructLogs() []StructLog { return l.logs } @@ -351,5 +352,6 @@ func (t *mdLogger) CaptureEnter(typ vm.OpCode, from common.Address, to common.Ad func (t *mdLogger) CaptureExit(output []byte, gasUsed uint64, err error) {} -func (*mdLogger) CaptureTxStart(_ uint64) {} -func (*mdLogger) CaptureTxEnd(_ uint64, _ error) {} +func (*mdLogger) CaptureTxStart(gasLimit uint64) {} + +func (*mdLogger) CaptureTxEnd(restGas uint64) {} diff --git a/eth/tracers/logger/logger_json.go b/eth/tracers/logger/logger_json.go index 8ea0bea2b3d1..72ad0199c946 100644 --- a/eth/tracers/logger/logger_json.go +++ b/eth/tracers/logger/logger_json.go @@ -99,5 +99,6 @@ func (l *JSONLogger) CaptureEnter(typ vm.OpCode, from common.Address, to common. func (l *JSONLogger) CaptureExit(output []byte, gasUsed uint64, err error) {} -func (*JSONLogger) CaptureTxStart(_ uint64) {} -func (*JSONLogger) CaptureTxEnd(_ uint64, _ error) {} +func (l *JSONLogger) CaptureTxStart(gasLimit uint64) {} + +func (l *JSONLogger) CaptureTxEnd(restGas uint64) {} diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go index 4b2fe265e307..5d4057689c91 100644 --- a/eth/tracers/native/4byte.go +++ b/eth/tracers/native/4byte.go @@ -131,8 +131,9 @@ func (t *fourByteTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, func (t *fourByteTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) { } -func (*fourByteTracer) CaptureTxStart(_ uint64) {} -func (*fourByteTracer) CaptureTxEnd(_ uint64, _ error) {} +func (*fourByteTracer) CaptureTxStart(gasLimit uint64) {} + +func (*fourByteTracer) CaptureTxEnd(restGas uint64) {} // GetResult returns the json-encoded nested list of call traces, and any // error arising from the encoding or forceful termination (via `Stop`). diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 9a7cb80f0ece..843c1a18f437 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -142,8 +142,9 @@ func (t *callTracer) CaptureExit(output []byte, gasUsed uint64, err error) { t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call) } -func (*callTracer) CaptureTxStart(_ uint64) {} -func (*callTracer) CaptureTxEnd(_ uint64, _ error) {} +func (*callTracer) CaptureTxStart(gasLimit uint64) {} + +func (*callTracer) CaptureTxEnd(restGas uint64) {} // GetResult returns the json-encoded nested list of call traces, and any // error arising from the encoding or forceful termination (via `Stop`). diff --git a/eth/tracers/native/noop.go b/eth/tracers/native/noop.go index 9e541d622c5c..566a8a652f3a 100644 --- a/eth/tracers/native/noop.go +++ b/eth/tracers/native/noop.go @@ -64,9 +64,9 @@ func (t *noopTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common. func (t *noopTracer) CaptureExit(output []byte, gasUsed uint64, err error) { } -func (*noopTracer) CaptureTxStart(_ uint64) {} +func (*noopTracer) CaptureTxStart(gasLimit uint64) {} -func (*noopTracer) CaptureTxEnd(_ uint64, _ error) {} +func (*noopTracer) CaptureTxEnd(restGas uint64) {} // GetResult returns an empty json object. func (t *noopTracer) GetResult() (json.RawMessage, error) { diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 72222533ae18..111d35996f9c 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -142,7 +142,7 @@ func (t *prestateTracer) CaptureTxStart(gasLimit uint64) { t.gasLimit = gasLimit } -func (t *prestateTracer) CaptureTxEnd(restGas uint64, err error) {} +func (t *prestateTracer) CaptureTxEnd(restGas uint64) {} // GetResult returns the json-encoded nested list of call traces, and any // error arising from the encoding or forceful termination (via `Stop`).