github.com/MikyChow/arbitrum-go-ethereum@v0.0.0-20230306102812-078da49636de/core/vm/evm_arbitrum.go (about) 1 // Copyright 2014 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package vm 18 19 import ( 20 "math/big" 21 22 "github.com/MikyChow/arbitrum-go-ethereum/common" 23 "github.com/MikyChow/arbitrum-go-ethereum/core/types" 24 ) 25 26 // Depth returns the current depth 27 func (evm *EVM) Depth() int { 28 return evm.depth 29 } 30 31 func (evm *EVM) IncrementDepth() { 32 evm.depth += 1 33 } 34 35 func (evm *EVM) DecrementDepth() { 36 evm.depth -= 1 37 } 38 39 type TxProcessingHook interface { 40 StartTxHook() (bool, uint64, error, []byte) // return 4-tuple rather than *struct to avoid an import cycle 41 GasChargingHook(gasRemaining *uint64) (common.Address, error) 42 PushCaller(addr common.Address) 43 PopCaller() 44 ForceRefundGas() uint64 45 NonrefundableGas() uint64 46 DropTip() bool 47 EndTxHook(totalGasUsed uint64, evmSuccess bool) 48 ScheduledTxes() types.Transactions 49 L1BlockNumber(blockCtx BlockContext) (uint64, error) 50 L1BlockHash(blockCtx BlockContext, l1BlocKNumber uint64) (common.Hash, error) 51 GasPriceOp(evm *EVM) *big.Int 52 FillReceiptInfo(receipt *types.Receipt) 53 } 54 55 type DefaultTxProcessor struct { 56 evm *EVM 57 } 58 59 func (p DefaultTxProcessor) StartTxHook() (bool, uint64, error, []byte) { 60 return false, 0, nil, nil 61 } 62 63 func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) (common.Address, error) { 64 return p.evm.Context.Coinbase, nil 65 } 66 67 func (p DefaultTxProcessor) PushCaller(addr common.Address) {} 68 69 func (p DefaultTxProcessor) PopCaller() {} 70 71 func (p DefaultTxProcessor) ForceRefundGas() uint64 { return 0 } 72 73 func (p DefaultTxProcessor) NonrefundableGas() uint64 { return 0 } 74 75 func (p DefaultTxProcessor) DropTip() bool { return false } 76 77 func (p DefaultTxProcessor) EndTxHook(totalGasUsed uint64, evmSuccess bool) {} 78 79 func (p DefaultTxProcessor) ScheduledTxes() types.Transactions { 80 return types.Transactions{} 81 } 82 83 func (p DefaultTxProcessor) L1BlockNumber(blockCtx BlockContext) (uint64, error) { 84 return blockCtx.BlockNumber.Uint64(), nil 85 } 86 87 func (p DefaultTxProcessor) L1BlockHash(blockCtx BlockContext, l1BlocKNumber uint64) (common.Hash, error) { 88 return blockCtx.GetHash(l1BlocKNumber), nil 89 } 90 91 func (p DefaultTxProcessor) GasPriceOp(evm *EVM) *big.Int { 92 return evm.GasPrice 93 } 94 95 func (p DefaultTxProcessor) FillReceiptInfo(*types.Receipt) {}