2021-11-25 15:17:09 +03:00
|
|
|
// Copyright 2021 The go-ethereum Authors
|
2015-07-22 19:48:40 +03:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 03:54:22 +03:00
|
|
|
//
|
2015-07-23 19:35:11 +03:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 03:54:22 +03:00
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2015-07-22 19:48:40 +03:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 03:54:22 +03:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 19:48:40 +03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 03:54:22 +03:00
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2015-07-22 19:48:40 +03:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 03:54:22 +03:00
|
|
|
|
2015-06-10 20:56:40 +03:00
|
|
|
package vm
|
2015-06-10 13:23:49 +03:00
|
|
|
|
|
|
|
import (
|
2016-02-04 00:46:27 +02:00
|
|
|
"math/big"
|
2017-06-07 18:09:08 +03:00
|
|
|
"time"
|
2015-06-10 13:23:49 +03:00
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
)
|
|
|
|
|
2021-11-05 13:48:21 +03:00
|
|
|
// EVMLogger is used to collect execution traces from an EVM transaction
|
2016-08-19 17:19:51 +03:00
|
|
|
// execution. CaptureState is called for each step of the VM with the
|
|
|
|
// current VM state.
|
|
|
|
// Note that reference types are actual VM data structures; make copies
|
|
|
|
// if you need to retain them beyond the current call.
|
2021-11-05 13:48:21 +03:00
|
|
|
type EVMLogger interface {
|
2022-03-31 12:51:44 +03:00
|
|
|
// Transaction level
|
|
|
|
CaptureTxStart(gasLimit uint64)
|
|
|
|
CaptureTxEnd(restGas uint64)
|
|
|
|
// Top call frame
|
2021-03-25 12:13:14 +03:00
|
|
|
CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)
|
2022-03-31 12:51:44 +03:00
|
|
|
CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)
|
|
|
|
// Rest of call frames
|
core,eth: call frame tracing (#23087)
This change introduces 2 new optional methods; `enter()` and `exit()` for js tracers, and makes `step()` optiona. The two new methods are invoked when entering and exiting a call frame (but not invoked for the outermost scope, which has it's own methods). Currently these are the data fields passed to each of them:
enter: type (opcode), from, to, input, gas, value
exit: output, gasUsed, error
The PR also comes with a re-write of the callTracer. As a backup we keep the previous tracing script under the name `callTracerLegacy`. Behaviour of both tracers are equivalent for the most part, although there are some small differences (improvements), where the new tracer is more correct / has more information.
2021-09-17 10:31:22 +03:00
|
|
|
CaptureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)
|
|
|
|
CaptureExit(output []byte, gasUsed uint64, err error)
|
2022-03-31 12:51:44 +03:00
|
|
|
// Opcode level
|
|
|
|
CaptureState(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error)
|
2021-11-09 14:09:35 +03:00
|
|
|
CaptureFault(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, depth int, err error)
|
2016-08-19 17:19:51 +03:00
|
|
|
}
|