@@ -35,7 +35,6 @@ export class CommonConfig {
3535 HUB_CHAIN_ID ,
3636 POLLING_DELAY ,
3737 MAX_BLOCK_LOOK_BACK ,
38- MAX_TX_WAIT_DURATION ,
3938 SEND_TRANSACTIONS ,
4039 SPOKE_POOL_CHAINS_OVERRIDE ,
4140 ACROSS_BOT_VERSION ,
@@ -44,7 +43,20 @@ export class CommonConfig {
4443 ARWEAVE_GATEWAY ,
4544 } = env ;
4645
46+ const mergeConfig = < T > ( config : T , envVar : string ) : T => {
47+ const shallowCopy = { ...config } ;
48+ Object . entries ( JSON . parse ( envVar ?? "{}" ) ) . forEach ( ( [ k , v ] ) => {
49+ assert (
50+ typeof v === typeof shallowCopy [ k ] || ! isDefined ( shallowCopy [ k ] ) ,
51+ `Invalid ${ envVar } configuration on key ${ k } (${ typeof v } != ${ typeof shallowCopy [ k ] } )`
52+ ) ;
53+ shallowCopy [ k ] = v ;
54+ } ) ;
55+ return shallowCopy ;
56+ } ;
57+
4758 this . version = ACROSS_BOT_VERSION ?? "unknown" ;
59+ this . hubPoolChainId = Number ( HUB_CHAIN_ID ?? CHAIN_IDs . MAINNET ) ;
4860
4961 this . timeToCache = Number ( HUB_POOL_TIME_TO_CACHE ?? 60 * 60 ) ; // 1 hour by default.
5062 if ( Number . isNaN ( this . timeToCache ) || this . timeToCache < 0 ) {
@@ -57,22 +69,18 @@ export class CommonConfig {
5769 this . maxConfigVersion = Number ( ACROSS_MAX_CONFIG_VERSION ?? Constants . CONFIG_STORE_VERSION ) ;
5870 assert ( ! isNaN ( this . maxConfigVersion ) , `Invalid maximum config version: ${ this . maxConfigVersion } ` ) ;
5971
60- this . blockRangeEndBlockBuffer = BLOCK_RANGE_END_BLOCK_BUFFER
61- ? JSON . parse ( BLOCK_RANGE_END_BLOCK_BUFFER )
62- : Constants . BUNDLE_END_BLOCK_BUFFERS ;
72+ this . blockRangeEndBlockBuffer = mergeConfig ( Constants . BUNDLE_END_BLOCK_BUFFERS , BLOCK_RANGE_END_BLOCK_BUFFER ) ;
6373
6474 this . ignoredAddresses = JSON . parse ( IGNORED_ADDRESSES ?? "[]" ) . map ( ( address ) => ethers . utils . getAddress ( address ) ) ;
6575
6676 // `maxRelayerLookBack` is how far we fetch events from, modifying the search config's 'fromBlock'
6777 this . maxRelayerLookBack = Number ( MAX_RELAYER_DEPOSIT_LOOK_BACK ?? Constants . MAX_RELAYER_DEPOSIT_LOOK_BACK ) ;
68- this . hubPoolChainId = Number ( HUB_CHAIN_ID ?? CHAIN_IDs . MAINNET ) ;
6978 this . pollingDelay = Number ( POLLING_DELAY ?? 60 ) ;
70- this . spokePoolChainsOverride = SPOKE_POOL_CHAINS_OVERRIDE ? JSON . parse ( SPOKE_POOL_CHAINS_OVERRIDE ) : [ ] ;
71- this . maxBlockLookBack = MAX_BLOCK_LOOK_BACK ? JSON . parse ( MAX_BLOCK_LOOK_BACK ) : { } ;
72- if ( Object . keys ( this . maxBlockLookBack ) . length === 0 ) {
73- this . maxBlockLookBack = Constants . CHAIN_MAX_BLOCK_LOOKBACK ;
74- }
75- this . maxTxWait = Number ( MAX_TX_WAIT_DURATION ?? 180 ) ; // 3 minutes
79+ this . spokePoolChainsOverride = JSON . parse ( SPOKE_POOL_CHAINS_OVERRIDE ?? "[]" ) ;
80+
81+ // Inherit the default eth_getLogs block range config, then sub in any env-based overrides.
82+ this . maxBlockLookBack = mergeConfig ( Constants . CHAIN_MAX_BLOCK_LOOKBACK , MAX_BLOCK_LOOK_BACK ) ;
83+
7684 this . sendingTransactionsEnabled = SEND_TRANSACTIONS === "true" ;
7785
7886 // Load the Arweave gateway from the environment.
0 commit comments