diff --git a/README.md b/README.md index bd72948d..9cc7553a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/web3_proxy/src/stats/mod.rs b/web3_proxy/src/stats/mod.rs index d4b571f9..08db04b4 100644 --- a/web3_proxy/src/stats/mod.rs +++ b/web3_proxy/src/stats/mod.rs @@ -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, /// None if the public url was used. rpc_secret_key_id: Option, /// 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)