From fc8ca4ba4f3ed6ed085e605dd9569033dd4644dd Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 11 May 2023 17:04:33 -0700 Subject: [PATCH] less max lag --- README.md | 2 +- web3_proxy/src/rpcs/blockchain.rs | 2 ++ web3_proxy/src/rpcs/consensus.rs | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c1931e5..8f70d866 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ Flame graphs make a developer's join of finding slow code painless: 4 $ echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid -1 - $ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin web3_proxy --no-inline + $ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin web3_proxy_cli --no-inline -- proxyd Be sure to use `--no-inline` or perf will be VERY slow diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index 34a09e7a..356a8fa8 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -436,6 +436,8 @@ impl Web3Rpcs { Ok(Some(x)) => x, }; + trace!("new_synced_connections: {:?}", new_synced_connections); + let watch_consensus_head_sender = self.watch_consensus_head_sender.as_ref().unwrap(); let consensus_tier = new_synced_connections.tier; // TODO: think more about this unwrap diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index a352c7f9..a20f55f9 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -218,8 +218,8 @@ impl ConsensusFinder { trace!("lowest_block_number: {}", lowest_block.number()); - let max_lag_block_number = highest_block_number - .saturating_sub(self.max_block_lag.unwrap_or_else(|| U64::from(10))); + let max_lag_block_number = + highest_block_number.saturating_sub(self.max_block_lag.unwrap_or_else(|| U64::from(5))); trace!("max_lag_block_number: {}", max_lag_block_number); @@ -231,6 +231,7 @@ impl ConsensusFinder { if num_known < web3_rpcs.min_head_rpcs { // this keeps us from serving requests when the proxy first starts + trace!("not enough servers known"); return Ok(None); } @@ -250,18 +251,22 @@ impl ConsensusFinder { .0 .tier; + trace!("first_tier: {}", current_tier); + // loop over all the rpc heads (grouped by tier) and their parents to find consensus // TODO: i'm sure theres a lot of shortcuts that could be taken, but this is simplest to implement for (rpc, rpc_head) in self.rpc_heads.iter() { if current_tier != rpc.tier { // we finished processing a tier. check for primary results if let Some(consensus) = self.count_votes(&primary_votes, web3_rpcs) { + trace!("found enough votes on tier {}", current_tier); return Ok(Some(consensus)); } // only set backup consensus once. we don't want it to keep checking on worse tiers if it already found consensus if backup_consensus.is_none() { if let Some(consensus) = self.count_votes(&backup_votes, web3_rpcs) { + trace!("found backup votes on tier {}", current_tier); backup_consensus = Some(consensus) } }