remove weight now that we use tiers

This commit is contained in:
Bryan Stitt 2023-01-13 13:45:48 -08:00
parent 8ddfd111d5
commit 8c02e4420d
3 changed files with 6 additions and 10 deletions

@ -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

@ -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(

@ -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::<Vec<_>>()