diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index a7c2c81f..754f0d12 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -196,7 +196,7 @@ impl Web3Rpcs { // TODO: should this be spawned and then we just hold onto the handle here? let mut consensus_finder = - ConsensusFinder::new(Some(self.max_head_block_age), Some(self.max_head_block_lag)); + ConsensusFinder::new(Some(self.max_head_block_age), self.max_head_block_lag); // TODO: what timeout on block receiver? we want to keep consensus_finder fresh so that server tiers are correct let triple_block_time = average_block_interval(self.chain_id).mul_f32(3.0); diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index 73436aee..1c9a5876 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -354,14 +354,14 @@ pub struct ConsensusFinder { rpc_heads: HashMap, Web3ProxyBlock>, /// no consensus if the best known block is too old max_head_block_age: Option, - /// tier 0 will be prefered as long as the distance between it and the other tiers is <= max_tier_lag - max_head_block_lag: Option, + /// no consensus if the best consensus block is too far behind the best known + max_head_block_lag: U64, /// Block Hash -> First Seen Instant. used to track rpc.head_delay. The same cache should be shared between all ConnectionsGroups first_seen: FirstSeenCache, } impl ConsensusFinder { - pub fn new(max_head_block_age: Option, max_head_block_lag: Option) -> Self { + pub fn new(max_head_block_age: Option, max_head_block_lag: U64) -> Self { // TODO: what's a good capacity for this? it shouldn't need to be very large let first_seen = Cache::new(16); @@ -782,8 +782,7 @@ impl ConsensusFinder { // TODO: move this default. should be in config, not here // TODO: arbitrum needs more slack - let max_lag_block_number = highest_block_number - .saturating_sub(self.max_head_block_lag.unwrap_or_else(|| U64::from(5))); + let max_lag_block_number = highest_block_number.saturating_sub(self.max_head_block_lag); trace!("max_lag_block_number: {}", max_lag_block_number);