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

View File

@ -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 - 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. - [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"` - 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 - [ ] 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 - 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 - [-] 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 - since users are actively using our service, we will need to support both
- [ ] Ulid instead of Uuid for database ids - [ ] Ulid instead of Uuid for database ids
- might have to use Uuid in sea-orm and then convert to Ulid on display - 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 ## V1

View File

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

View File

@ -1,12 +1,16 @@
pub use sea_orm_migration::prelude::*; 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; pub struct Migrator;
#[async_trait::async_trait] #[async_trait::async_trait]
impl MigratorTrait for Migrator { impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> { 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),
]
} }
} }

View File

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

View File

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

View File

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