github.com/Cleverse/go-ethereum@v0.0.0-20220927095127-45113064e7f2/arbitrum/config.go (about)

     1  package arbitrum
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/ethereum/go-ethereum/eth/ethconfig"
     7  	"github.com/ethereum/go-ethereum/params"
     8  	flag "github.com/spf13/pflag"
     9  )
    10  
    11  type Config struct {
    12  	// RPCGasCap is the global gas cap for eth-call variants.
    13  	RPCGasCap uint64 `koanf:"gas-cap"`
    14  
    15  	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
    16  	// send-transction variants. The unit is ether.
    17  	RPCTxFeeCap float64 `koanf:"tx-fee-cap"`
    18  
    19  	// RPCEVMTimeout is the global timeout for eth-call.
    20  	RPCEVMTimeout time.Duration `koanf:"evm-timeout"`
    21  
    22  	// Parameters for the bloom indexer
    23  	BloomBitsBlocks uint64 `koanf:"bloom-bits-blocks"`
    24  	BloomConfirms   uint64 `koanf:"bloom-confirms"`
    25  
    26  	// FeeHistoryMaxBlockCount limits the number of historical blocks a fee history request may cover
    27  	FeeHistoryMaxBlockCount uint64 `koanf:"feehistory-max-block-count"`
    28  
    29  	ArbDebug ArbDebugConfig `koanf:"arbdebug"`
    30  
    31  	ClassicRedirect        string        `koanf:"classic-redirect"`
    32  	ClassicRedirectTimeout time.Duration `koanf:"classic-redirect-timeout"`
    33  }
    34  
    35  type ArbDebugConfig struct {
    36  	BlockRangeBound   uint64 `koanf:"block-range-bound"`
    37  	TimeoutQueueBound uint64 `koanf:"timeout-queue-bound"`
    38  }
    39  
    40  func ConfigAddOptions(prefix string, f *flag.FlagSet) {
    41  	f.Uint64(prefix+".gas-cap", DefaultConfig.RPCGasCap, "cap on computation gas that can be used in eth_call/estimateGas (0=infinite)")
    42  	f.Float64(prefix+".tx-fee-cap", DefaultConfig.RPCTxFeeCap, "cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)")
    43  	f.Duration(prefix+".evm-timeout", DefaultConfig.RPCEVMTimeout, "timeout used for eth_call (0=infinite)")
    44  	f.Uint64(prefix+".bloom-bits-blocks", DefaultConfig.BloomBitsBlocks, "number of blocks a single bloom bit section vector holds")
    45  	f.Uint64(prefix+".feehistory-max-block-count", DefaultConfig.FeeHistoryMaxBlockCount, "max number of blocks a fee history request may cover")
    46  	f.String(prefix+".classic-redirect", DefaultConfig.ClassicRedirect, "url to redirect classic requests, use \"error:[CODE:]MESSAGE\" to return specified error instead of redirecting")
    47  	f.Duration(prefix+".classic-redirect-timeout", DefaultConfig.ClassicRedirectTimeout, "timeout for forwarded classic requests, where 0 = no timeout")
    48  
    49  	arbDebug := DefaultConfig.ArbDebug
    50  	f.Uint64(prefix+".arbdebug.block-range-bound", arbDebug.BlockRangeBound, "bounds the number of blocks arbdebug calls may return")
    51  	f.Uint64(prefix+".arbdebug.timeout-queue-bound", arbDebug.TimeoutQueueBound, "bounds the length of timeout queues arbdebug calls may return")
    52  }
    53  
    54  var DefaultConfig = Config{
    55  	RPCGasCap:               ethconfig.Defaults.RPCGasCap,     // 50,000,000
    56  	RPCTxFeeCap:             ethconfig.Defaults.RPCTxFeeCap,   // 1 ether
    57  	RPCEVMTimeout:           ethconfig.Defaults.RPCEVMTimeout, // 5 seconds
    58  	BloomBitsBlocks:         params.BloomBitsBlocks * 4,       // we generally have smaller blocks
    59  	BloomConfirms:           params.BloomConfirms,
    60  	FeeHistoryMaxBlockCount: 1024,
    61  	ClassicRedirect:         "",
    62  	ArbDebug: ArbDebugConfig{
    63  		BlockRangeBound:   256,
    64  		TimeoutQueueBound: 512,
    65  	},
    66  }