github.com/tacshi/go-ethereum@v0.0.0-20230616113857-84a434e20921/arbitrum/config.go (about) 1 package arbitrum 2 3 import ( 4 "time" 5 6 flag "github.com/spf13/pflag" 7 "github.com/tacshi/go-ethereum/eth/ethconfig" 8 "github.com/tacshi/go-ethereum/params" 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 // Parameters for the filter system 27 FilterLogCacheSize int `koanf:"filter-log-cache-size"` 28 FilterTimeout time.Duration `koanf:"filter-timeout"` 29 30 // FeeHistoryMaxBlockCount limits the number of historical blocks a fee history request may cover 31 FeeHistoryMaxBlockCount uint64 `koanf:"feehistory-max-block-count"` 32 33 ArbDebug ArbDebugConfig `koanf:"arbdebug"` 34 35 ClassicRedirect string `koanf:"classic-redirect"` 36 ClassicRedirectTimeout time.Duration `koanf:"classic-redirect-timeout"` 37 } 38 39 type ArbDebugConfig struct { 40 BlockRangeBound uint64 `koanf:"block-range-bound"` 41 TimeoutQueueBound uint64 `koanf:"timeout-queue-bound"` 42 } 43 44 func ConfigAddOptions(prefix string, f *flag.FlagSet) { 45 f.Uint64(prefix+".gas-cap", DefaultConfig.RPCGasCap, "cap on computation gas that can be used in eth_call/estimateGas (0=infinite)") 46 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)") 47 f.Duration(prefix+".evm-timeout", DefaultConfig.RPCEVMTimeout, "timeout used for eth_call (0=infinite)") 48 f.Uint64(prefix+".bloom-bits-blocks", DefaultConfig.BloomBitsBlocks, "number of blocks a single bloom bit section vector holds") 49 f.Uint64(prefix+".bloom-confirms", DefaultConfig.BloomConfirms, "number of confirmation blocks before a bloom section is considered final") 50 f.Uint64(prefix+".feehistory-max-block-count", DefaultConfig.FeeHistoryMaxBlockCount, "max number of blocks a fee history request may cover") 51 f.String(prefix+".classic-redirect", DefaultConfig.ClassicRedirect, "url to redirect classic requests, use \"error:[CODE:]MESSAGE\" to return specified error instead of redirecting") 52 f.Duration(prefix+".classic-redirect-timeout", DefaultConfig.ClassicRedirectTimeout, "timeout for forwarded classic requests, where 0 = no timeout") 53 f.Int(prefix+".filter-log-cache-size", DefaultConfig.FilterLogCacheSize, "log filter system maximum number of cached blocks") 54 f.Duration(prefix+".filter-timeout", DefaultConfig.FilterTimeout, "log filter system maximum time filters stay active") 55 56 arbDebug := DefaultConfig.ArbDebug 57 f.Uint64(prefix+".arbdebug.block-range-bound", arbDebug.BlockRangeBound, "bounds the number of blocks arbdebug calls may return") 58 f.Uint64(prefix+".arbdebug.timeout-queue-bound", arbDebug.TimeoutQueueBound, "bounds the length of timeout queues arbdebug calls may return") 59 } 60 61 var DefaultConfig = Config{ 62 RPCGasCap: ethconfig.Defaults.RPCGasCap, // 50,000,000 63 RPCTxFeeCap: ethconfig.Defaults.RPCTxFeeCap, // 1 ether 64 RPCEVMTimeout: ethconfig.Defaults.RPCEVMTimeout, // 5 seconds 65 BloomBitsBlocks: params.BloomBitsBlocks * 4, // we generally have smaller blocks 66 BloomConfirms: params.BloomConfirms, 67 FilterLogCacheSize: 32, 68 FilterTimeout: 5 * time.Minute, 69 FeeHistoryMaxBlockCount: 1024, 70 ClassicRedirect: "", 71 ArbDebug: ArbDebugConfig{ 72 BlockRangeBound: 256, 73 TimeoutQueueBound: 512, 74 }, 75 }