From a69737db982edfc89215b7406c6426b743f45b41 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 22 Mar 2023 14:23:14 -0700 Subject: [PATCH] serialize best_rpcs --- TODO.md | 2 ++ web3_proxy/src/rpcs/blockchain.rs | 2 +- web3_proxy/src/rpcs/consensus.rs | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 4336e32f..468ed917 100644 --- a/TODO.md +++ b/TODO.md @@ -565,6 +565,8 @@ These are not ordered. I think some rows also accidently got deleted here. Check - look at average request time for getBlock? i'm not sure how good a proxy that will be for serving eth_call, but its a start - https://crates.io/crates/histogram-sampler - [ ] interval for http subscriptions should be based on block time. load from config is easy, but better to query. currently hard coded to 13 seconds +- [ ] check code to keep us from going backwards. maybe that is causing outages +- [ ] min_backup_rpcs seperate from min_synced_rpcs in another repo: event subscriber - [ ] watch for transfer events to our contract and submit them to /payment/$tx_hash diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index b90b9958..543513e6 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -517,7 +517,7 @@ impl Web3Rpcs { // this is unlikely but possible // TODO: better log warn!( - "chain rolled back t{}/{} {}{}/{}/{} con={} old={} rpc={}@{}", + "chain rolled back {}/{} {}{}/{}/{} con={} old={} rpc={}@{}", consensus_tier, total_tiers, backups_voted_str, diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index 943dd051..a6f94523 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -7,7 +7,7 @@ use anyhow::Context; use ethers::prelude::{H256, U64}; use hashbrown::{HashMap, HashSet}; use itertools::{Itertools, MinMaxResult}; -use log::{trace, warn}; +use log::{trace, warn, debug}; use moka::future::Cache; use serde::Serialize; use std::cmp::Reverse; @@ -21,8 +21,6 @@ use tokio::time::Instant; pub struct ConsensusWeb3Rpcs { pub(super) tier: u64, pub(super) head_block: Web3ProxyBlock, - // TODO: this should be able to serialize, but it isn't - #[serde(skip_serializing)] pub(super) best_rpcs: Vec>, // TODO: functions like "compare_backup_vote()" // pub(super) backups_voted: Option, @@ -323,6 +321,8 @@ impl ConsensusFinder { continue; } + trace!("rpc_names: {:#?}", rpc_names); + // consensus likely found! load the rpcs to make sure they all have active connections let consensus_rpcs: Vec<_> = rpc_names.into_iter().filter_map(|x| web3_rpcs.get(x)).collect();