github.com/tacshi/go-ethereum@v0.0.0-20230616113857-84a434e20921/core/arbitrum_hooks.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 core
    18  
    19  import (
    20  	"context"
    21  
    22  	"github.com/tacshi/go-ethereum/common"
    23  	"github.com/tacshi/go-ethereum/core/state"
    24  	"github.com/tacshi/go-ethereum/core/types"
    25  	"github.com/tacshi/go-ethereum/core/vm"
    26  	"github.com/tacshi/go-ethereum/params"
    27  	"github.com/tacshi/go-ethereum/rpc"
    28  )
    29  
    30  // Installs an Arbitrum TxProcessor, enabling ArbOS for this state transition (see vm/evm_arbitrum.go)
    31  var ReadyEVMForL2 func(evm *vm.EVM, msg *Message)
    32  
    33  // Allows ArbOS to swap out or return early from an RPC message to support the NodeInterface virtual contract
    34  var InterceptRPCMessage = func(
    35  	msg *Message,
    36  	ctx context.Context,
    37  	statedb *state.StateDB,
    38  	header *types.Header,
    39  	backend NodeInterfaceBackendAPI,
    40  ) (*Message, *ExecutionResult, error) {
    41  	return msg, nil, nil
    42  }
    43  
    44  // Gets ArbOS's maximum intended gas per second
    45  var GetArbOSSpeedLimitPerSecond func(statedb *state.StateDB) (uint64, error)
    46  
    47  // Allows ArbOS to update the gas cap so that it ignores the message's specific L1 poster costs.
    48  var InterceptRPCGasCap = func(gascap *uint64, msg *Message, header *types.Header, statedb *state.StateDB) {}
    49  
    50  // Renders a solidity error in human-readable form
    51  var RenderRPCError func(data []byte) error
    52  
    53  type NodeInterfaceBackendAPI interface {
    54  	ChainConfig() *params.ChainConfig
    55  	CurrentBlock() *types.Header
    56  	BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
    57  	GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error)
    58  	GetEVM(ctx context.Context, msg *Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config) (*vm.EVM, func() error, error)
    59  }