Revert "Merge branch 'devel' of github.com:llamanodes/web3-proxy into devel"
This reverts commit 4fc745b52b90b72fdd2d9e8e990ec2d42d9f680d, reversing changes made to bc6d18041d652502f83d44aedbea234e02b59f6f.
This commit is contained in:
parent
4fc745b52b
commit
f7cfd39d93
@ -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/health
|
||||||
wrk -t12 -c400 -d30s --latency http://127.0.0.1:8544/status
|
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/rpc/$API_KEY
|
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/rpc/$API_KEY
|
wrk -s ./wrk/getLatestBlockByNumber.lua -t12 -c400 -d30s --latency http://127.0.0.1:8544/u/$API_KEY
|
||||||
|
|
||||||
Test geth (assuming it is on 8545):
|
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 | versus --concurrency=10 --stop-after=1000 http://127.0.0.1:8544
|
||||||
|
|
||||||
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
|
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
|
||||||
|
@ -12,6 +12,7 @@ use crate::errors::{Web3ProxyError, Web3ProxyResult};
|
|||||||
use crate::frontend::authorization::{Authorization, RequestMetadata};
|
use crate::frontend::authorization::{Authorization, RequestMetadata};
|
||||||
use crate::rpcs::one::Web3Rpc;
|
use crate::rpcs::one::Web3Rpc;
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
|
use axum::headers::Origin;
|
||||||
use chrono::{DateTime, Months, TimeZone, Utc};
|
use chrono::{DateTime, Months, TimeZone, Utc};
|
||||||
use derive_more::From;
|
use derive_more::From;
|
||||||
use entities::{referee, referrer, rpc_accounting_v2};
|
use entities::{referee, referrer, rpc_accounting_v2};
|
||||||
@ -85,6 +86,8 @@ pub struct RpcQueryKey {
|
|||||||
user_error_response: bool,
|
user_error_response: bool,
|
||||||
/// the rpc method used.
|
/// the rpc method used.
|
||||||
method: Cow<'static, str>,
|
method: Cow<'static, str>,
|
||||||
|
/// origin tracking **was** opt-in. Now, it is always "None"
|
||||||
|
origin: Option<Origin>,
|
||||||
/// None if the public url was used.
|
/// None if the public url was used.
|
||||||
rpc_secret_key_id: Option<NonZeroU64>,
|
rpc_secret_key_id: Option<NonZeroU64>,
|
||||||
/// None if the public url was used.
|
/// None if the public url was used.
|
||||||
@ -110,23 +113,27 @@ impl RpcQueryStats {
|
|||||||
fn accounting_key(&self, period_seconds: i64) -> RpcQueryKey {
|
fn accounting_key(&self, period_seconds: i64) -> RpcQueryKey {
|
||||||
let response_timestamp = round_timestamp(self.response_timestamp, period_seconds);
|
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_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();
|
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
|
// user_error_response is always set to false because we don't bother tracking this in the database
|
||||||
let user_error_response = false;
|
let user_error_response = false;
|
||||||
|
|
||||||
// Depending on method, add some arithmetic around calculating credits_used
|
// Depending on method, add some arithmetic around calculating credits_used
|
||||||
// I think balance should not go here, this looks more like a key thingy
|
// I think balance should not go here, this looks more like a key thingy
|
||||||
RpcQueryKey {
|
RpcQueryKey {
|
||||||
|
response_timestamp,
|
||||||
archive_needed: self.archive_request,
|
archive_needed: self.archive_request,
|
||||||
error_response: self.error_response,
|
error_response: self.error_response,
|
||||||
method,
|
method,
|
||||||
response_timestamp,
|
|
||||||
rpc_key_user_id,
|
|
||||||
rpc_secret_key_id,
|
rpc_secret_key_id,
|
||||||
|
rpc_key_user_id: self.authorization.checks.user_id.try_into().ok(),
|
||||||
|
origin,
|
||||||
user_error_response,
|
user_error_response,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,6 +143,8 @@ impl RpcQueryStats {
|
|||||||
fn global_timeseries_key(&self) -> RpcQueryKey {
|
fn global_timeseries_key(&self) -> RpcQueryKey {
|
||||||
// we include the method because that can be helpful for predicting load
|
// we include the method because that can be helpful for predicting load
|
||||||
let method = self.method.clone();
|
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
|
// everyone gets grouped together
|
||||||
let rpc_secret_key_id = None;
|
let rpc_secret_key_id = None;
|
||||||
let rpc_key_user_id = None;
|
let rpc_key_user_id = None;
|
||||||
@ -148,6 +157,7 @@ impl RpcQueryStats {
|
|||||||
rpc_secret_key_id,
|
rpc_secret_key_id,
|
||||||
rpc_key_user_id,
|
rpc_key_user_id,
|
||||||
user_error_response: self.user_error_response,
|
user_error_response: self.user_error_response,
|
||||||
|
origin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +167,9 @@ impl RpcQueryStats {
|
|||||||
return None;
|
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 method = self.method.clone();
|
||||||
|
|
||||||
let key = RpcQueryKey {
|
let key = RpcQueryKey {
|
||||||
@ -167,6 +180,7 @@ impl RpcQueryStats {
|
|||||||
rpc_secret_key_id: self.authorization.checks.rpc_secret_key_id,
|
rpc_secret_key_id: self.authorization.checks.rpc_secret_key_id,
|
||||||
rpc_key_user_id: self.authorization.checks.user_id.try_into().ok(),
|
rpc_key_user_id: self.authorization.checks.user_id.try_into().ok(),
|
||||||
user_error_response: self.user_error_response,
|
user_error_response: self.user_error_response,
|
||||||
|
origin,
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(key)
|
Some(key)
|
||||||
|
Loading…
Reference in New Issue
Block a user