2015-07-07 00:54:22 +00:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-07-22 16:48:40 +00:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 00:54:22 +00:00
|
|
|
//
|
2015-07-23 16:35:11 +00:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 00:54:22 +00: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 16:48:40 +00:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 00:54:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 16:48:40 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 00:54:22 +00: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 16:48:40 +00:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 00:54:22 +00:00
|
|
|
|
2015-06-10 17:56:40 +00:00
|
|
|
package vm
|
2015-06-10 10:23:49 +00:00
|
|
|
|
|
|
|
import (
|
2020-08-07 12:25:40 +00:00
|
|
|
"github.com/holiman/uint256"
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
2015-06-10 10:23:49 +00:00
|
|
|
)
|
|
|
|
|
2022-12-23 05:43:08 +00:00
|
|
|
// EVMLogger is used to collect execution traces from an EVM transaction
|
2016-08-19 14:19:51 +00: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.
|
2022-12-23 05:43:08 +00:00
|
|
|
type EVMLogger interface {
|
2022-12-18 04:36:57 +00:00
|
|
|
// Transaction level
|
|
|
|
CaptureTxStart(gasLimit uint64)
|
|
|
|
CaptureTxEnd(restGas uint64)
|
2022-12-18 16:11:31 +00:00
|
|
|
// Top call frame
|
2023-10-05 05:23:08 +00:00
|
|
|
CaptureStart(env *EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte)
|
2022-12-23 05:43:08 +00:00
|
|
|
CaptureEnd(output []byte, usedGas uint64, err error)
|
2022-12-18 16:11:31 +00:00
|
|
|
// Rest of the frames
|
2023-01-13 18:12:18 +00:00
|
|
|
CaptureEnter(typ OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte)
|
2022-12-23 05:43:08 +00:00
|
|
|
CaptureExit(output []byte, usedGas uint64, err error)
|
2022-12-18 04:36:57 +00:00
|
|
|
// Opcode level
|
2022-12-18 17:06:40 +00:00
|
|
|
CaptureState(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error)
|
|
|
|
CaptureFault(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, depth int, err error)
|
2016-08-19 14:19:51 +00:00
|
|
|
}
|
|
|
|
|
2022-07-07 11:47:00 +00:00
|
|
|
// FlushableTracer is a Tracer extension whose accumulated traces has to be
|
|
|
|
// flushed once the tracing is completed.
|
|
|
|
type FlushableTracer interface {
|
2022-12-23 05:43:08 +00:00
|
|
|
EVMLogger
|
2022-07-07 11:47:00 +00:00
|
|
|
Flush(tx types.Transaction)
|
|
|
|
}
|