Merge branch 'devel' of github.com:llamanodes/web3-proxy into devel

This commit is contained in:
yenicelik 2023-07-21 18:03:03 -04:00
commit 4fc745b52b
2 changed files with 6 additions and 20 deletions

@ -178,8 +178,8 @@ Test the proxy:
wrk -t12 -c400 -d30s --latency http://127.0.0.1:8544/health
wrk -t12 -c400 -d30s --latency http://127.0.0.1:8544/status
wrk -s ./wrk/getBlockNumber.lua -t12 -c400 -d30s --latency http://127.0.0.1:8544/u/$API_KEY
wrk -s ./wrk/getLatestBlockByNumber.lua -t12 -c400 -d30s --latency http://127.0.0.1:8544/u/$API_KEY
wrk -s ./wrk/getBlockNumber.lua -t12 -c400 -d30s --latency http://127.0.0.1:8544/rpc/$API_KEY
wrk -s ./wrk/getLatestBlockByNumber.lua -t12 -c400 -d30s --latency http://127.0.0.1:8544/rpc/$API_KEY
Test geth (assuming it is on 8545):
@ -197,4 +197,4 @@ Run [ethspam](https://github.com/INFURA/versus) and [versus](https://github.com/
ethspam --rpc http://127.0.0.1:8544 | versus --concurrency=10 --stop-after=1000 http://127.0.0.1:8544
ethspam --rpc http://127.0.0.1:8544/u/$API_KEY | versus --concurrency=100 --stop-after=10000 http://127.0.0.1:8544/u/$API_KEY
ethspam --rpc http://127.0.0.1:8544/rpc/$API_KEY | versus --concurrency=100 --stop-after=10000 http://127.0.0.1:8544/rpc/$API_KEY

@ -12,7 +12,6 @@ use crate::errors::{Web3ProxyError, Web3ProxyResult};
use crate::frontend::authorization::{Authorization, RequestMetadata};
use crate::rpcs::one::Web3Rpc;
use anyhow::{anyhow, Context};
use axum::headers::Origin;
use chrono::{DateTime, Months, TimeZone, Utc};
use derive_more::From;
use entities::{referee, referrer, rpc_accounting_v2};
@ -86,8 +85,6 @@ pub struct RpcQueryKey {
user_error_response: bool,
/// the rpc method used.
method: Cow<'static, str>,
/// origin tracking **was** opt-in. Now, it is always "None"
origin: Option<Origin>,
/// None if the public url was used.
rpc_secret_key_id: Option<NonZeroU64>,
/// None if the public url was used.
@ -113,27 +110,23 @@ impl RpcQueryStats {
fn accounting_key(&self, period_seconds: i64) -> RpcQueryKey {
let response_timestamp = round_timestamp(self.response_timestamp, period_seconds);
// TODO: change this to use 0 for anonymous queries
let rpc_secret_key_id = self.authorization.checks.rpc_secret_key_id;
let rpc_key_user_id = self.authorization.checks.user_id.try_into().ok();
let method = self.method.clone();
// we used to optionally store origin, but wallets don't set it, so its almost always None
let origin = None;
// user_error_response is always set to false because we don't bother tracking this in the database
let user_error_response = false;
// Depending on method, add some arithmetic around calculating credits_used
// I think balance should not go here, this looks more like a key thingy
RpcQueryKey {
response_timestamp,
archive_needed: self.archive_request,
error_response: self.error_response,
method,
response_timestamp,
rpc_key_user_id,
rpc_secret_key_id,
rpc_key_user_id: self.authorization.checks.user_id.try_into().ok(),
origin,
user_error_response,
}
}
@ -143,8 +136,6 @@ impl RpcQueryStats {
fn global_timeseries_key(&self) -> RpcQueryKey {
// we include the method because that can be helpful for predicting load
let method = self.method.clone();
// we don't store origin in the timeseries db. its only used for optional accounting
let origin = None;
// everyone gets grouped together
let rpc_secret_key_id = None;
let rpc_key_user_id = None;
@ -157,7 +148,6 @@ impl RpcQueryStats {
rpc_secret_key_id,
rpc_key_user_id,
user_error_response: self.user_error_response,
origin,
}
}
@ -167,9 +157,6 @@ impl RpcQueryStats {
return None;
}
// we don't store origin in the timeseries db. its only optionaly used for accounting
let origin = None;
let method = self.method.clone();
let key = RpcQueryKey {
@ -180,7 +167,6 @@ impl RpcQueryStats {
rpc_secret_key_id: self.authorization.checks.rpc_secret_key_id,
rpc_key_user_id: self.authorization.checks.user_id.try_into().ok(),
user_error_response: self.user_error_response,
origin,
};
Some(key)