From 8c02e4420d74d25e1b919a57538e33fa60dec852 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 13 Jan 2023 13:45:48 -0800 Subject: [PATCH] remove weight now that we use tiers --- TODO.md | 1 + web3_proxy/src/rpcs/connection.rs | 6 +----- web3_proxy/src/rpcs/connections.rs | 9 ++++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 6ca8ddf9..5b10936b 100644 --- a/TODO.md +++ b/TODO.md @@ -299,6 +299,7 @@ These are not yet ordered. There might be duplicates. We might not actually need - i think this was done, but am not positive. - [x] if private txs are disabled, only send trasactions to some of our servers. we were DOSing ourselves with transactions and slowing down sync - [x] retry if we get "the method X is not available" +- [x] remove weight. we don't use it anymore. tiers are what we use now - [-] let users choose a % of reverts to log (or maybe x/second). someone like curve logging all reverts will be a BIG database very quickly - this must be opt-in and spawned in the background since it will slow things down and will make their calls less private - [ ] automatic pruning of old revert logs once too many are collected diff --git a/web3_proxy/src/rpcs/connection.rs b/web3_proxy/src/rpcs/connection.rs index 6b283ae7..a4e83a76 100644 --- a/web3_proxy/src/rpcs/connection.rs +++ b/web3_proxy/src/rpcs/connection.rs @@ -1119,7 +1119,7 @@ impl Serialize for Web3Connection { S: Serializer, { // 3 is the number of fields in the struct. - let mut state = serializer.serialize_struct("Web3Connection", 9)?; + let mut state = serializer.serialize_struct("Web3Connection", 8)?; // the url is excluded because it likely includes private information. just show the name that we use in keys state.serialize_field("name", &self.name)?; @@ -1137,10 +1137,6 @@ impl Serialize for Web3Connection { state.serialize_field("tier", &self.tier)?; - let faked_weight = 100u64.saturating_sub(self.tier) as f64 / 100.0; - - state.serialize_field("weight", &faked_weight)?; - state.serialize_field("soft_limit", &self.soft_limit)?; state.serialize_field( diff --git a/web3_proxy/src/rpcs/connections.rs b/web3_proxy/src/rpcs/connections.rs index a6cd18a9..fbd75b3f 100644 --- a/web3_proxy/src/rpcs/connections.rs +++ b/web3_proxy/src/rpcs/connections.rs @@ -512,11 +512,11 @@ impl Web3Connections { if minimum < 0.0 { available_request_map = available_request_map .into_iter() - .map(|(rpc, weight)| { + .map(|(rpc, available_requests)| { // TODO: is simple addition the right way to shift everyone? // TODO: probably want something non-linear - // minimum is negative, so we subtract - let x = weight - minimum; + // minimum is negative, so we subtract to make available requests bigger + let x = available_requests - minimum; (rpc, x) }) @@ -530,12 +530,11 @@ impl Web3Connections { } else { let mut rng = thread_fast_rng::thread_fast_rng(); - // TODO: sort or weight the non-archive nodes to be first usable_rpcs .choose_multiple_weighted(&mut rng, usable_rpcs.len(), |rpc| { *available_request_map .get(rpc) - .expect("rpc should always be in the weight map") + .expect("rpc should always be in available_request_map") }) .unwrap() .collect::>()