change rpm to u64 and create RevertLogs table

This commit is contained in:
Bryan Stitt 2022-09-21 19:54:40 +00:00
parent 37a1aa554b
commit 339bd41f50
6 changed files with 19 additions and 13 deletions

@ -154,6 +154,8 @@ These are roughly in order of completition
- WARN http_request: redis_rate_limit::errors: redis error err=Response was of incompatible type: "Response type not string compatible." (response was int(500237)) id=01GC6514JWN5PS1NCWJCGJTC94 method=POST
- [x] web3_proxy_error_count{path = "backend_rpc/request"} is inflated by a bunch of reverts. do not log reverts as warn.
- erigon gives `method=eth_call reqid=986147 t=1.151551ms err="execution reverted"`
- [x] database migration to change user_keys.requests_per_minute to bigunsigned (max of 18446744073709551615)
- [x] change user creation script to have a "unlimited requests per minute" flag that sets it to u64::MAX (18446744073709551615)
- [ ] opt-in debug mode that inspects responses for reverts and saves the request to the database for the user. let them choose a % to log (or maybe x/second). someone like curve logging all reverts will be a BIG database very quickly
- this must be opt-in or spawned since it will slow things down and will make their calls less private
- [-] add configurable size limits to all the Caches
@ -166,8 +168,6 @@ These are roughly in order of completition
- since users are actively using our service, we will need to support both
- [ ] Ulid instead of Uuid for database ids
- might have to use Uuid in sea-orm and then convert to Ulid on display
- [ ] database migration to change user_keys.requests_per_minute to bigint (max of 18446744073709551615)
- [ ] change user creation script to have a "unlimited requests per minute" flag that sets it to u64::MAX (18446744073709551615)
## V1

@ -15,7 +15,7 @@ pub struct Model {
pub description: Option<String>,
pub private_txs: bool,
pub active: bool,
pub requests_per_minute: u32,
pub requests_per_minute: u64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

@ -1,12 +1,16 @@
pub use sea_orm_migration::prelude::*;
mod m20220101_000001_create_table;
pub mod m20220101_000001_create_table;
pub mod m20220921_181610_log_reverts;
pub struct Migrator;
#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![Box::new(m20220101_000001_create_table::Migration)]
vec![
Box::new(m20220101_000001_create_table::Migration),
Box::new(m20220921_181610_log_reverts::Migration),
]
}
}

@ -174,7 +174,7 @@ enum SecondaryUser {
-- TODO: more security features. likely similar to infura
*/
#[derive(Iden)]
enum UserKeys {
pub enum UserKeys {
Table,
Id,
UserId,

@ -7,8 +7,9 @@ use tracing::info;
use uuid::Uuid;
use web3_proxy::users::new_api_key;
fn default_rpm() -> u32 {
6_000_000
/// default to max int which the code sees as "unlimited" requests
fn default_rpm() -> u64 {
u64::MAX
}
#[derive(FromArgs, PartialEq, Debug, Eq)]
@ -30,7 +31,7 @@ pub struct CreateUserSubCommand {
#[argh(option, default = "default_rpm()")]
/// maximum requests per minute
rpm: u32,
rpm: u64,
}
impl CreateUserSubCommand {

@ -54,7 +54,7 @@ pub struct AppConfig {
/// If none, the minimum * 2 is used
pub db_max_connections: Option<u32>,
#[serde(default = "default_default_requests_per_minute")]
pub default_requests_per_minute: u32,
pub default_requests_per_minute: u64,
pub invite_code: Option<String>,
#[serde(default = "default_min_sum_soft_limit")]
pub min_sum_soft_limit: u32,
@ -75,9 +75,10 @@ pub struct AppConfig {
pub redirect_user_url: String,
}
// TODO: what should we default to? have different tiers for different paid amounts?
fn default_default_requests_per_minute() -> u32 {
1_000_000 * 60
/// default to unlimited requests
/// TODO: pick a lower limit so we don't get DOSd
fn default_default_requests_per_minute() -> u64 {
u64::MAX
}
fn default_min_sum_soft_limit() -> u32 {