From 0178d09b79d17029958431d400f4498d5f161077 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 25 Jul 2022 18:21:58 +0000 Subject: [PATCH] make missing docs a warning --- TODO.md | 2 +- redis-cell-client/src/lib.rs | 2 ++ web3-proxy/src/connections.rs | 12 +++++++++--- web3-proxy/src/main.rs | 19 +++++++------------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/TODO.md b/TODO.md index 02114395..2f8ad160 100644 --- a/TODO.md +++ b/TODO.md @@ -58,8 +58,8 @@ - we can improve this by only publishing the synced connections once a threshold of total available soft and hard limits is passed. how can we do this without hammering redis? at least its only once per block per server - [x] instead of tracking `pending_synced_connections`, have a mapping of where all connections are individually. then each change, re-check for consensus. - [x] synced connections swap threshold set to 1 so that it always serves something -- [ ] basic request method stats - [ ] nice output when cargo doc is run +- [ ] basic request method stats ## V1 diff --git a/redis-cell-client/src/lib.rs b/redis-cell-client/src/lib.rs index 99c6ba8c..8118f28b 100644 --- a/redis-cell-client/src/lib.rs +++ b/redis-cell-client/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(missing_docs)] + use bb8_redis::redis::cmd; pub use bb8_redis::redis::RedisError; diff --git a/web3-proxy/src/connections.rs b/web3-proxy/src/connections.rs index c981234d..35ad6561 100644 --- a/web3-proxy/src/connections.rs +++ b/web3-proxy/src/connections.rs @@ -44,9 +44,11 @@ struct SyncedConnections { impl fmt::Debug for SyncedConnections { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // TODO: the default formatter takes forever to write. this is too quiet though + // TODO: print the actual conns? f.debug_struct("SyncedConnections") .field("head_num", &self.head_block_num) .field("head_hash", &self.head_block_hash) + .field("num_conns", &self.conns.len()) .finish_non_exhaustive() } } @@ -702,6 +704,9 @@ impl Web3Connections { // TODO: default_min_soft_limit? without, we start serving traffic at the start too quickly // let min_soft_limit = total_soft_limit / 2; let min_soft_limit = 1; + let num_possible_heads = rpcs_by_hash.len(); + + trace!(?rpcs_by_hash); struct State<'a> { block: &'a Arc>, @@ -724,8 +729,6 @@ impl Web3Connections { } } - trace!(?rpcs_by_hash); - // TODO: i'm always getting None if let Some(x) = rpcs_by_hash .into_iter() @@ -773,9 +776,11 @@ impl Web3Connections { best_head_hash ); } else { + // TODO: this isn't necessarily a fork. this might just be an rpc being slow + // TODO: log all the heads? warn!( "chain is forked! {} possible heads. {}/{}/{}/{} rpcs have {}", - "?", // TODO: how should we get this? + num_possible_heads, best_rpcs.len(), synced_rpcs.len(), connection_heads.len(), @@ -805,6 +810,7 @@ impl Web3Connections { if new_head_block { self.chain.add_block(new_block.clone(), true); + // TODO: include the fastest rpc here? info!( "{}/{} rpcs at {} ({}). publishing new head!", pending_synced_connections.conns.len(), diff --git a/web3-proxy/src/main.rs b/web3-proxy/src/main.rs index abbbd7ea..887ae807 100644 --- a/web3-proxy/src/main.rs +++ b/web3-proxy/src/main.rs @@ -1,13 +1,7 @@ -#![forbid(unsafe_code)] +//! Run the web3 proxy -mod app; -mod bb8_helpers; -mod config; -mod connection; -mod connections; -mod firewall; -mod frontend; -mod jsonrpc; +#![forbid(unsafe_code)] +#![warn(missing_docs)] use parking_lot::deadlock; use std::fs; @@ -18,8 +12,9 @@ use tokio::runtime; use tracing::{debug, info}; use tracing_subscriber::EnvFilter; -use crate::app::{flatten_handle, Web3ProxyApp}; -use crate::config::{AppConfig, CliConfig}; +use web3_proxy::app::{flatten_handle, Web3ProxyApp}; +use web3_proxy::config::{AppConfig, CliConfig}; +use web3_proxy::frontend; fn run( shutdown_receiver: flume::Receiver<()>, @@ -148,7 +143,7 @@ mod tests { use hashbrown::HashMap; use std::env; - use crate::config::{RpcSharedConfig, Web3ConnectionConfig}; + use web3_proxy::config::{RpcSharedConfig, Web3ConnectionConfig}; use super::*;