diff --git a/cmd/state/commands/opcode_tracer.go b/cmd/state/commands/opcode_tracer.go index 50672c4df..0ac9f9d07 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -114,7 +114,7 @@ type opcodeTracer struct { saveBblocks bool blockNumber uint64 depth int - env vm.VMInterface + env *vm.EVM } func NewOpcodeTracer(blockNum uint64, saveOpcodes bool, saveBblocks bool) *opcodeTracer { @@ -195,7 +195,7 @@ func (ot *opcodeTracer) captureStartOrEnter(from, to libcommon.Address, create b ot.stack = append(ot.stack, &newTx) } -func (ot *opcodeTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (ot *opcodeTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { ot.env = env ot.depth = 0 ot.captureStartOrEnter(from, to, create, input) diff --git a/cmd/state/exec3/calltracer_v3.go b/cmd/state/exec3/calltracer_v3.go index 31e25fa00..951e114df 100644 --- a/cmd/state/exec3/calltracer_v3.go +++ b/cmd/state/exec3/calltracer_v3.go @@ -22,7 +22,7 @@ func (ct *CallTracer) Tos() map[libcommon.Address]struct{} { return ct.tos } func (ct *CallTracer) CaptureTxStart(gasLimit uint64) {} func (ct *CallTracer) CaptureTxEnd(restGas uint64) {} -func (ct *CallTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (ct *CallTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { if ct.froms == nil { ct.froms = map[libcommon.Address]struct{}{} ct.tos = map[libcommon.Address]struct{}{} diff --git a/core/state_processor.go b/core/state_processor.go index 672385fa7..be097186f 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -34,7 +34,7 @@ import ( // indicating the block was invalid. func applyTransaction(config *chain.Config, engine consensus.EngineReader, gp *GasPool, ibs *state.IntraBlockState, stateWriter state.StateWriter, header *types.Header, tx types.Transaction, usedGas, usedBlobGas *uint64, - evm vm.VMInterface, cfg vm.Config) (*types.Receipt, []byte, error) { + evm *vm.EVM, cfg vm.Config) (*types.Receipt, []byte, error) { rules := evm.ChainRules() msg, err := tx.AsMessage(*types.MakeSigner(config, header.Number.Uint64(), header.Time), header.BaseFee, rules) if err != nil { diff --git a/core/state_transition.go b/core/state_transition.go index 5ab9d196d..8b3f4aaa6 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -66,7 +66,7 @@ type StateTransition struct { value *uint256.Int data []byte state evmtypes.IntraBlockState - evm vm.VMInterface + evm *vm.EVM //some pre-allocated intermediate variables sharedBuyGas *uint256.Int @@ -151,7 +151,7 @@ func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation } // NewStateTransition initialises and returns a new state transition object. -func NewStateTransition(evm vm.VMInterface, msg Message, gp *GasPool) *StateTransition { +func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition { isBor := evm.ChainConfig().Bor != nil return &StateTransition{ gp: gp, @@ -181,7 +181,7 @@ func NewStateTransition(evm vm.VMInterface, msg Message, gp *GasPool) *StateTran // `refunds` is false when it is not required to apply gas refunds // `gasBailout` is true when it is not required to fail transaction if the balance is not enough to pay gas. // for trace_call to replicate OE/Pariry behaviour -func ApplyMessage(evm vm.VMInterface, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*ExecutionResult, error) { +func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*ExecutionResult, error) { return NewStateTransition(evm, msg, gp).TransitionDb(refunds, gasBailout) } diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index f4495765f..90b39100c 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -68,7 +68,7 @@ func memoryGasCost(mem *Memory, newMemSize uint64) (uint64, error) { // EXTCODECOPY (stack position 3) // RETURNDATACOPY (stack position 2) func memoryCopierGas(stackpos int) gasFunc { - return func(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { + return func(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { // Gas for expanding the memory gas, err := memoryGasCost(mem, memorySize) if err != nil { @@ -99,7 +99,7 @@ var ( gasReturnDataCopy = memoryCopierGas(2) ) -func gasSStore(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasSStore(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { value, x := stack.Back(1), stack.Back(0) key := libcommon.Hash(x.Bytes32()) var current uint256.Int @@ -182,7 +182,7 @@ func gasSStore(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *M // 2.2.2. If original value equals new value (this storage slot is reset): // 2.2.2.1. If original value is 0, add SSTORE_SET_GAS - SLOAD_GAS to refund counter. // 2.2.2.2. Otherwise, add SSTORE_RESET_GAS - SLOAD_GAS gas to refund counter. -func gasSStoreEIP2200(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasSStoreEIP2200(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { // If we fail the minimum gas availability invariant, fail (0) if contract.Gas <= params.SstoreSentryGasEIP2200 { return 0, errors.New("not enough gas for reentrancy sentry") @@ -226,7 +226,7 @@ func gasSStoreEIP2200(evm VMInterpreter, contract *Contract, stack *stack.Stack, } func makeGasLog(n uint64) gasFunc { - return func(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { + return func(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { requestedSize, overflow := stack.Back(1).Uint64WithOverflow() if overflow { return 0, ErrGasUintOverflow @@ -255,7 +255,7 @@ func makeGasLog(n uint64) gasFunc { } } -func gasKeccak256(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasKeccak256(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -276,7 +276,7 @@ func gasKeccak256(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem * // pureMemoryGascost is used by several operations, which aside from their // static cost have a dynamic cost which is solely based on the memory // expansion -func pureMemoryGascost(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func pureMemoryGascost(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { return memoryGasCost(mem, memorySize) } @@ -289,7 +289,7 @@ var ( gasCreate = pureMemoryGascost ) -func gasCreate2(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasCreate2(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -310,7 +310,7 @@ func gasCreate2(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Me return gas, nil } -func gasCreateEip3860(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasCreateEip3860(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -329,7 +329,7 @@ func gasCreateEip3860(_ VMInterpreter, contract *Contract, stack *stack.Stack, m return gas, nil } -func gasCreate2Eip3860(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasCreate2Eip3860(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -348,7 +348,7 @@ func gasCreate2Eip3860(_ VMInterpreter, contract *Contract, stack *stack.Stack, return gas, nil } -func gasExpFrontier(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasExpFrontier(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { expByteLen := uint64(libcommon.BitLenToByteLen(stack.Data[stack.Len()-2].BitLen())) var ( @@ -361,7 +361,7 @@ func gasExpFrontier(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem return gas, nil } -func gasExpEIP160(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasExpEIP160(_ *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { expByteLen := uint64(libcommon.BitLenToByteLen(stack.Data[stack.Len()-2].BitLen())) var ( @@ -374,7 +374,7 @@ func gasExpEIP160(_ VMInterpreter, contract *Contract, stack *stack.Stack, mem * return gas, nil } -func gasCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasCall(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { var ( gas uint64 transfersValue = !stack.Back(2).IsZero() @@ -412,7 +412,7 @@ func gasCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Mem return gas, nil } -func gasCallCode(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasCallCode(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { memoryGas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -440,7 +440,7 @@ func gasCallCode(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem return gas, nil } -func gasDelegateCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasDelegateCall(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -460,7 +460,7 @@ func gasDelegateCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, return gas, nil } -func gasStaticCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasStaticCall(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { gas, err := memoryGasCost(mem, memorySize) if err != nil { return 0, err @@ -480,7 +480,7 @@ func gasStaticCall(evm VMInterpreter, contract *Contract, stack *stack.Stack, me return gas, nil } -func gasSelfdestruct(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasSelfdestruct(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { var gas uint64 // TangerineWhistle (EIP150) gas reprice fork: if evm.ChainRules().IsTangerineWhistle { diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index a6ca2efbe..79dbf1161 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -99,7 +99,7 @@ type EVMInterpreter struct { // //nolint:structcheck type VM struct { - evm VMInterpreter + evm *EVM cfg Config hasher keccakState // Keccak256 hasher instance shared across opcodes @@ -121,7 +121,7 @@ func copyJumpTable(jt *JumpTable) *JumpTable { } // NewEVMInterpreter returns a new instance of the Interpreter. -func NewEVMInterpreter(evm VMInterpreter, cfg Config) *EVMInterpreter { +func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { var jt *JumpTable switch { case evm.ChainRules().IsPrague: diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 6e6d146c4..047c9f538 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -25,7 +25,7 @@ import ( type ( executionFunc func(pc *uint64, interpreter *EVMInterpreter, callContext *ScopeContext) ([]byte, error) - gasFunc func(VMInterpreter, *Contract, *stack.Stack, *Memory, uint64) (uint64, error) // last parameter is the requested memory size as a uint64 + gasFunc func(*EVM, *Contract, *stack.Stack, *Memory, uint64) (uint64, error) // last parameter is the requested memory size as a uint64 // memorySizeFunc returns the required size, and whether the operation overflowed a uint64 memorySizeFunc func(*stack.Stack) (size uint64, overflow bool) ) diff --git a/core/vm/logger.go b/core/vm/logger.go index ff76ae71e..5677233f9 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -33,7 +33,7 @@ type EVMLogger interface { CaptureTxStart(gasLimit uint64) CaptureTxEnd(restGas uint64) // Top call frame - CaptureStart(env VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) + CaptureStart(env *EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) CaptureEnd(output []byte, usedGas uint64, err error) // Rest of the frames CaptureEnter(typ OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go index 177be61b4..6256ae574 100644 --- a/core/vm/operations_acl.go +++ b/core/vm/operations_acl.go @@ -28,7 +28,7 @@ import ( ) func makeGasSStoreFunc(clearingRefund uint64) gasFunc { - return func(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { + return func(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { // If we fail the minimum gas availability invariant, fail (0) if contract.Gas <= params.SstoreSentryGasEIP2200 { return 0, errors.New("not enough gas for reentrancy sentry") @@ -40,6 +40,7 @@ func makeGasSStoreFunc(clearingRefund uint64) gasFunc { current uint256.Int cost = uint64(0) ) + evm.IntraBlockState().GetState(contract.Address(), &slot, ¤t) // If the caller cannot afford the cost, this change will be rolled back if _, slotMod := evm.IntraBlockState().AddSlotToAccessList(contract.Address(), slot); slotMod { @@ -99,12 +100,11 @@ func makeGasSStoreFunc(clearingRefund uint64) gasFunc { // whose storage is being read) is not yet in accessed_storage_keys, // charge 2100 gas and add the pair to accessed_storage_keys. // If the pair is already in accessed_storage_keys, charge 100 gas. -func gasSLoadEIP2929(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasSLoadEIP2929(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { loc := stack.Peek() - slot := libcommon.Hash(loc.Bytes32()) // If the caller cannot afford the cost, this change will be rolled back // If he does afford it, we can skip checking the same thing later on, during execution - if _, slotMod := evm.IntraBlockState().AddSlotToAccessList(contract.Address(), slot); slotMod { + if _, slotMod := evm.IntraBlockState().AddSlotToAccessList(contract.Address(), loc.Bytes32()); slotMod { return params.ColdSloadCostEIP2929, nil } return params.WarmStorageReadCostEIP2929, nil @@ -115,7 +115,7 @@ func gasSLoadEIP2929(evm VMInterpreter, contract *Contract, stack *stack.Stack, // > If the target is not in accessed_addresses, // > charge COLD_ACCOUNT_ACCESS_COST gas, and add the address to accessed_addresses. // > Otherwise, charge WARM_STORAGE_READ_COST gas. -func gasExtCodeCopyEIP2929(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasExtCodeCopyEIP2929(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { // memory expansion first (dynamic part of pre-2929 implementation) gas, err := gasExtCodeCopy(evm, contract, stack, mem, memorySize) if err != nil { @@ -141,7 +141,7 @@ func gasExtCodeCopyEIP2929(evm VMInterpreter, contract *Contract, stack *stack.S // - extcodehash, // - extcodesize, // - (ext) balance -func gasEip2929AccountCheck(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { +func gasEip2929AccountCheck(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { addr := libcommon.Address(stack.Peek().Bytes20()) // If the caller cannot afford the cost, this change will be rolled back if evm.IntraBlockState().AddAddressToAccessList(addr) { @@ -152,7 +152,7 @@ func gasEip2929AccountCheck(evm VMInterpreter, contract *Contract, stack *stack. } func makeCallVariantGasCallEIP2929(oldCalculator gasFunc) gasFunc { - return func(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { + return func(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { addr := libcommon.Address(stack.Back(1).Bytes20()) // The WarmStorageReadCostEIP2929 (100) is already deducted in the form of a constant cost, so // the cost to charge for cold access, if any, is Cold - Warm @@ -215,7 +215,7 @@ var ( // makeSelfdestructGasFn can create the selfdestruct dynamic gas function for EIP-2929 and EIP-2539 func makeSelfdestructGasFn(refundsEnabled bool) gasFunc { - gasFunc := func(evm VMInterpreter, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { + gasFunc := func(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { var ( gas uint64 address = libcommon.Address(stack.Peek().Bytes20()) diff --git a/core/vm/stack/stack.go b/core/vm/stack/stack.go index e92888a21..119d8b61f 100644 --- a/core/vm/stack/stack.go +++ b/core/vm/stack/stack.go @@ -107,42 +107,3 @@ func ReturnNormalStack(s *Stack) { s.Data = s.Data[:0] stackPool.Put(s) } - -var rStackPool = sync.Pool{ - New: func() interface{} { - return &ReturnStack{data: make([]uint32, 0, 10)} - }, -} - -func ReturnRStack(rs *ReturnStack) { - rs.data = rs.data[:0] - rStackPool.Put(rs) -} - -// ReturnStack is an object for basic return stack operations. -type ReturnStack struct { - data []uint32 -} - -func NewReturnStack() *ReturnStack { - rStack, ok := rStackPool.Get().(*ReturnStack) - if !ok { - log.Error("Type assertion failure", "err", "cannot get ReturnStack pointer from rStackPool") - } - return rStack -} - -func (st *ReturnStack) Push(d uint32) { - st.data = append(st.data, d) -} - -// A uint32 is sufficient as for code below 4.2G -func (st *ReturnStack) Pop() (ret uint32) { - ret = st.data[len(st.data)-1] - st.data = st.data[:len(st.data)-1] - return -} - -func (st *ReturnStack) Data() []uint32 { - return st.data -} diff --git a/eth/calltracer/calltracer.go b/eth/calltracer/calltracer.go index 7271a088f..c4ca57e06 100644 --- a/eth/calltracer/calltracer.go +++ b/eth/calltracer/calltracer.go @@ -45,7 +45,7 @@ func (ct *CallTracer) captureStartOrEnter(from, to libcommon.Address, create boo } } -func (ct *CallTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (ct *CallTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { ct.captureStartOrEnter(from, to, create, code) } func (ct *CallTracer) CaptureEnter(typ vm.OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go index cd057c9f5..7ca6ec73a 100644 --- a/eth/tracers/js/goja.go +++ b/eth/tracers/js/goja.go @@ -95,7 +95,7 @@ func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString b // JS functions on the relevant EVM hooks. It uses Goja as its JS engine. type jsTracer struct { vm *goja.Runtime - env vm.VMInterface + env *vm.EVM toBig toBigFn // Converts a hex string into a JS bigint toBuf toBufFn // Converts a []byte into a JS buffer fromBuf fromBufFn // Converts an array, hex string or Uint8Array to a []byte @@ -224,7 +224,7 @@ func (t *jsTracer) CaptureTxEnd(restGas uint64) { } // CaptureStart implements the Tracer interface to initialize the tracing operation. -func (t *jsTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *jsTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.env = env db := &dbObj{ibs: env.IntraBlockState(), vm: t.vm, toBig: t.toBig, toBuf: t.toBuf, fromBuf: t.fromBuf} t.dbValue = db.setupObject() diff --git a/eth/tracers/logger/access_list_tracer.go b/eth/tracers/logger/access_list_tracer.go index 328634e0b..f9f9f981c 100644 --- a/eth/tracers/logger/access_list_tracer.go +++ b/eth/tracers/logger/access_list_tracer.go @@ -149,7 +149,7 @@ func (a *AccessListTracer) CaptureTxStart(gasLimit uint64) {} func (a *AccessListTracer) CaptureTxEnd(restGas uint64) {} -func (a *AccessListTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (a *AccessListTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { } func (a *AccessListTracer) CaptureEnter(typ vm.OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { diff --git a/eth/tracers/logger/json_stream.go b/eth/tracers/logger/json_stream.go index 3f272ed61..5b616e81e 100644 --- a/eth/tracers/logger/json_stream.go +++ b/eth/tracers/logger/json_stream.go @@ -30,7 +30,7 @@ type JsonStreamLogger struct { logs []StructLog output []byte //nolint err error //nolint - env vm.VMInterface + env *vm.EVM } // NewStructLogger returns a new logger @@ -52,7 +52,7 @@ func (l *JsonStreamLogger) CaptureTxStart(gasLimit uint64) {} func (l *JsonStreamLogger) CaptureTxEnd(restGas uint64) {} // CaptureStart implements the Tracer interface to initialize the tracing operation. -func (l *JsonStreamLogger) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (l *JsonStreamLogger) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { l.env = env } diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index 3beb7e7d9..9e5ddb088 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -116,7 +116,7 @@ type StructLogger struct { logs []StructLog output []byte err error - env vm.VMInterface + env *vm.EVM } // NewStructLogger returns a new logger @@ -135,7 +135,7 @@ func (l *StructLogger) CaptureTxStart(gasLimit uint64) {} func (l *StructLogger) CaptureTxEnd(restGas uint64) {} // CaptureStart implements the Tracer interface to initialize the tracing operation. -func (l *StructLogger) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (l *StructLogger) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { l.env = env } @@ -339,7 +339,7 @@ func WriteLogs(writer io.Writer, logs []*types.Log) { type mdLogger struct { out io.Writer cfg *LogConfig - env vm.VMInterface + env *vm.EVM } // NewMarkdownLogger creates a logger which outputs information in a format adapted @@ -373,7 +373,7 @@ func (t *mdLogger) captureStartOrEnter(from, to libcommon.Address, create bool, `) } -func (t *mdLogger) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { //nolint:interfacer +func (t *mdLogger) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { //nolint:interfacer t.env = env t.captureStartOrEnter(from, to, create, input, gas, value) } diff --git a/eth/tracers/logger/logger_json.go b/eth/tracers/logger/logger_json.go index b2c90f350..c06b47692 100644 --- a/eth/tracers/logger/logger_json.go +++ b/eth/tracers/logger/logger_json.go @@ -32,7 +32,7 @@ import ( type JSONLogger struct { encoder *json.Encoder cfg *LogConfig - env vm.VMInterface + env *vm.EVM } // NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects @@ -49,7 +49,7 @@ func (l *JSONLogger) CaptureTxStart(gasLimit uint64) {} func (l *JSONLogger) CaptureTxEnd(restGas uint64) {} -func (l *JSONLogger) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (l *JSONLogger) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { l.env = env } diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go index 41900f17b..608f4990b 100644 --- a/eth/tracers/native/4byte.go +++ b/eth/tracers/native/4byte.go @@ -81,7 +81,7 @@ func (t *fourByteTracer) store(id []byte, size int) { } // CaptureStart implements the EVMLogger interface to initialize the tracing operation. -func (t *fourByteTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *fourByteTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { // Update list of precompiles based on current block rules := env.ChainConfig().Rules(env.Context().BlockNumber, env.Context().Time) t.activePrecompiles = vm.ActivePrecompiles(rules) diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 520e953b9..0b7c60845 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -132,7 +132,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Tracer, e } // CaptureStart implements the EVMLogger interface to initialize the tracing operation. -func (t *callTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *callTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.callstack[0] = callFrame{ Type: vm.CALL, From: from, diff --git a/eth/tracers/native/mux.go b/eth/tracers/native/mux.go index 77809c64f..e8a14bb4a 100644 --- a/eth/tracers/native/mux.go +++ b/eth/tracers/native/mux.go @@ -60,7 +60,7 @@ func newMuxTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Tracer, er } // CaptureStart implements the EVMLogger interface to initialize the tracing operation. -func (t *muxTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *muxTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { for _, t := range t.tracers { t.CaptureStart(env, from, to, precompile, create, input, gas, value, code) } diff --git a/eth/tracers/native/noop.go b/eth/tracers/native/noop.go index ff04a23a0..29365d00d 100644 --- a/eth/tracers/native/noop.go +++ b/eth/tracers/native/noop.go @@ -40,7 +40,7 @@ func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (tracers.Tracer, err } // CaptureStart implements the EVMLogger interface to initialize the tracing operation. -func (t *noopTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *noopTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { } // CaptureEnd is called after the call finishes to finalize the tracing. diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 8398af06c..1494fb479 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -59,7 +59,7 @@ type accountMarshaling struct { type prestateTracer struct { noopTracer - env vm.VMInterface + env *vm.EVM pre state post state create bool @@ -93,7 +93,7 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Trace } // CaptureStart implements the EVMLogger interface to initialize the tracing operation. -func (t *prestateTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precomplile, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *prestateTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.env = env t.create = create t.to = to diff --git a/turbo/jsonrpc/otterscan_default_tracer.go b/turbo/jsonrpc/otterscan_default_tracer.go index 1b312e59b..4c8807eb3 100644 --- a/turbo/jsonrpc/otterscan_default_tracer.go +++ b/turbo/jsonrpc/otterscan_default_tracer.go @@ -17,7 +17,7 @@ func (t *DefaultTracer) CaptureTxStart(gasLimit uint64) {} func (t *DefaultTracer) CaptureTxEnd(restGas uint64) {} -func (t *DefaultTracer) CaptureStart(env vm.VMInterface, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *DefaultTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { } func (t *DefaultTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { diff --git a/turbo/jsonrpc/otterscan_trace_contract_creator.go b/turbo/jsonrpc/otterscan_trace_contract_creator.go index 8d55e3305..3f0bb4b6a 100644 --- a/turbo/jsonrpc/otterscan_trace_contract_creator.go +++ b/turbo/jsonrpc/otterscan_trace_contract_creator.go @@ -50,7 +50,7 @@ func (t *CreateTracer) captureStartOrEnter(from, to common.Address, create bool) t.Creator = from } -func (t *CreateTracer) CaptureStart(env vm.VMInterface, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *CreateTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.captureStartOrEnter(from, to, create) } diff --git a/turbo/jsonrpc/otterscan_trace_touch.go b/turbo/jsonrpc/otterscan_trace_touch.go index 06c3c2960..17fddfdd9 100644 --- a/turbo/jsonrpc/otterscan_trace_touch.go +++ b/turbo/jsonrpc/otterscan_trace_touch.go @@ -27,7 +27,7 @@ func (t *TouchTracer) captureStartOrEnter(from, to common.Address) { } } -func (t *TouchTracer) CaptureStart(env vm.VMInterface, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *TouchTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.captureStartOrEnter(from, to) } diff --git a/turbo/jsonrpc/otterscan_trace_transaction.go b/turbo/jsonrpc/otterscan_trace_transaction.go index 7959871aa..5c252f053 100644 --- a/turbo/jsonrpc/otterscan_trace_transaction.go +++ b/turbo/jsonrpc/otterscan_trace_transaction.go @@ -93,7 +93,7 @@ func (t *TransactionTracer) captureStartOrEnter(typ vm.OpCode, from, to common.A } } -func (t *TransactionTracer) CaptureStart(env vm.VMInterface, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (t *TransactionTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { t.depth = 0 t.captureStartOrEnter(vm.CALL, from, to, precompile, input, value) } diff --git a/turbo/jsonrpc/trace_adhoc.go b/turbo/jsonrpc/trace_adhoc.go index b47da577b..d87097dc6 100644 --- a/turbo/jsonrpc/trace_adhoc.go +++ b/turbo/jsonrpc/trace_adhoc.go @@ -353,7 +353,7 @@ func (ot *OeTracer) captureStartOrEnter(deep bool, typ vm.OpCode, from libcommon ot.traceStack = append(ot.traceStack, trace) } -func (ot *OeTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { +func (ot *OeTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { ot.captureStartOrEnter(false /* deep */, vm.CALL, from, to, precompile, create, input, gas, value, code) }