diff --git a/core/vm/arbitrum_evm.go b/core/vm/arbitrum_evm.go deleted file mode 100644 index 231085129199..000000000000 --- a/core/vm/arbitrum_evm.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// 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. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package vm - -type TxProcessingHook interface { - StartTxHook() bool - GasChargingHook(gasRemaining *uint64) error - EndTxHook(totalGasUsed uint64, success bool) - NonrefundableGas() uint64 -} - -type DefaultTxProcessor struct{} - -func (p DefaultTxProcessor) StartTxHook() bool { - return false -} - -func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) error { - return nil -} - -func (p DefaultTxProcessor) EndTxHook(totalGasUsed uint64, success bool) { - return -} - -func (p DefaultTxProcessor) NonrefundableGas() uint64 { - return 0 -} diff --git a/core/vm/evm_arbitrum.go b/core/vm/evm_arbitrum.go index d3a2cc5448f0..2142e1561fee 100644 --- a/core/vm/evm_arbitrum.go +++ b/core/vm/evm_arbitrum.go @@ -16,7 +16,44 @@ package vm +import "github.com/ethereum/go-ethereum/common" + // Depth returns the current depth func (evm *EVM) Depth() int { return evm.depth } + +type TxProcessingHook interface { + StartTxHook() bool + GasChargingHook(gasRemaining *uint64) error + EndTxHook(totalGasUsed uint64, success bool) + NonrefundableGas() uint64 + PushCaller(addr common.Address) + PopCaller() +} + +type DefaultTxProcessor struct{} + +func (p DefaultTxProcessor) StartTxHook() bool { + return false +} + +func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) error { + return nil +} + +func (p DefaultTxProcessor) EndTxHook(totalGasUsed uint64, success bool) { + return +} + +func (p DefaultTxProcessor) NonrefundableGas() uint64 { + return 0 +} + +func (p DefaultTxProcessor) PushCaller(addr common.Address) { + return +} + +func (p DefaultTxProcessor) PopCaller() { + return +} diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 4315750baa6e..b1ec94e54283 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -119,7 +119,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // Increment the call depth which is restricted to 1024 in.evm.depth++ + in.evm.ProcessingHook.PushCaller(contract.Caller()) defer func() { in.evm.depth-- }() + defer func() { in.evm.ProcessingHook.PopCaller() }() // Make sure the readOnly is only set if we aren't in readOnly yet. // This also makes sure that the readOnly flag isn't removed for child calls.