github.com/MikyChow/arbitrum-go-ethereum@v0.0.0-20230306102812-078da49636de/arbitrum/config.go (about) 1 package arbitrum 2 3 import ( 4 "time" 5 6 "github.com/MikyChow/arbitrum-go-ethereum/eth/ethconfig" 7 "github.com/MikyChow/arbitrum-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 // 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+".feehistory-max-block-count", DefaultConfig.FeeHistoryMaxBlockCount, "max number of blocks a fee history request may cover") 50 f.String(prefix+".classic-redirect", DefaultConfig.ClassicRedirect, "url to redirect classic requests, use \"error:[CODE:]MESSAGE\" to return specified error instead of redirecting") 51 f.Duration(prefix+".classic-redirect-timeout", DefaultConfig.ClassicRedirectTimeout, "timeout for forwarded classic requests, where 0 = no timeout") 52 f.Int(prefix+".filter-log-cache-size", DefaultConfig.FilterLogCacheSize, "log filter system maximum number of cached blocks") 53 f.Duration(prefix+".filter-timeout", DefaultConfig.FilterTimeout, "log filter system maximum time filters stay active") 54 55 arbDebug := DefaultConfig.ArbDebug 56 f.Uint64(prefix+".arbdebug.block-range-bound", arbDebug.BlockRangeBound, "bounds the number of blocks arbdebug calls may return") 57 f.Uint64(prefix+".arbdebug.timeout-queue-bound", arbDebug.TimeoutQueueBound, "bounds the length of timeout queues arbdebug calls may return") 58 } 59 60 var DefaultConfig = Config{ 61 RPCGasCap: ethconfig.Defaults.RPCGasCap, // 50,000,000 62 RPCTxFeeCap: ethconfig.Defaults.RPCTxFeeCap, // 1 ether 63 RPCEVMTimeout: ethconfig.Defaults.RPCEVMTimeout, // 5 seconds 64 BloomBitsBlocks: params.BloomBitsBlocks * 4, // we generally have smaller blocks 65 BloomConfirms: params.BloomConfirms, 66 FilterLogCacheSize: 32, 67 FilterTimeout: 5 * time.Minute, 68 FeeHistoryMaxBlockCount: 1024, 69 ClassicRedirect: "", 70 ArbDebug: ArbDebugConfig{ 71 BlockRangeBound: 256, 72 TimeoutQueueBound: 512, 73 }, 74 }