From b87c988439e8fb81c0e5334cbd888ee7cc6a290d Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 1 Mar 2023 11:23:59 -0800 Subject: [PATCH] lint --- entities/src/admin.rs | 1 - .../m20230130_124740_read_only_login_logic.rs | 21 +++-- ...65144_prepare_admin_imitation_pre_login.rs | 38 ++++----- migration/src/m20230215_152254_admin_trail.rs | 6 +- web3_proxy/src/admin_queries.rs | 73 +++++++++-------- .../change_user_admin_status.rs | 19 ++--- web3_proxy/src/frontend/admin.rs | 82 ++++++++++--------- web3_proxy/src/frontend/authorization.rs | 2 +- web3_proxy/src/frontend/rpc_proxy_http.rs | 72 +++++++++++++++- web3_proxy/src/frontend/users.rs | 21 ++--- web3_proxy/src/rpcs/one.rs | 2 +- web3_proxy/src/user_queries.rs | 1 - 12 files changed, 198 insertions(+), 140 deletions(-) diff --git a/entities/src/admin.rs b/entities/src/admin.rs index dc8a737d..d1d46999 100644 --- a/entities/src/admin.rs +++ b/entities/src/admin.rs @@ -1,6 +1,5 @@ //! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6 -use crate::serialization; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/migration/src/m20230130_124740_read_only_login_logic.rs b/migration/src/m20230130_124740_read_only_login_logic.rs index 064dc683..d15c955f 100644 --- a/migration/src/m20230130_124740_read_only_login_logic.rs +++ b/migration/src/m20230130_124740_read_only_login_logic.rs @@ -11,12 +11,10 @@ impl MigrationTrait for Migration { .alter_table( Table::alter() .table(Login::Table) - .add_column( - ColumnDef::new(Login::ReadOnly) - .boolean() - .not_null() - ).to_owned() - ).await + .add_column(ColumnDef::new(Login::ReadOnly).boolean().not_null()) + .to_owned(), + ) + .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { @@ -26,8 +24,9 @@ impl MigrationTrait for Migration { Table::alter() .table(Login::Table) .drop_column(Login::ReadOnly) - .to_owned() - ).await + .to_owned(), + ) + .await } } @@ -35,8 +34,8 @@ impl MigrationTrait for Migration { #[derive(Iden)] enum Login { Table, - Id, - BearerToken, + // Id, + // BearerToken, ReadOnly, - UserId, + // UserId, } diff --git a/migration/src/m20230130_165144_prepare_admin_imitation_pre_login.rs b/migration/src/m20230130_165144_prepare_admin_imitation_pre_login.rs index ff6ec868..4b363447 100644 --- a/migration/src/m20230130_165144_prepare_admin_imitation_pre_login.rs +++ b/migration/src/m20230130_165144_prepare_admin_imitation_pre_login.rs @@ -10,19 +10,18 @@ impl MigrationTrait for Migration { .alter_table( Table::alter() .table(PendingLogin::Table) - .add_column( - ColumnDef::new(PendingLogin::ImitatingUser) - .big_unsigned() + .add_column(ColumnDef::new(PendingLogin::ImitatingUser).big_unsigned()) + .add_foreign_key( + TableForeignKey::new() + .name("fk-pending_login-imitating_user") + .from_tbl(PendingLogin::Table) + .to_tbl(User::Table) + .from_col(PendingLogin::ImitatingUser) + .to_col(User::Id), ) - .add_foreign_key(&TableForeignKey::new() - .name("fk-pending_login-imitating_user") - .from_tbl(PendingLogin::Table) - .to_tbl(User::Table) - .from_col(PendingLogin::ImitatingUser) - .to_col(User::Id) - ) - .to_owned() - ).await + .to_owned(), + ) + .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { @@ -32,8 +31,9 @@ impl MigrationTrait for Migration { .table(PendingLogin::Table) .drop_foreign_key(Alias::new("fk-pending_login-imitating_user")) .drop_column(PendingLogin::ImitatingUser) - .to_owned() - ).await + .to_owned(), + ) + .await } } @@ -41,10 +41,10 @@ impl MigrationTrait for Migration { #[derive(Iden)] enum PendingLogin { Table, - Id, - Nonce, - Message, - ExpiresAt, + // Id, + // Nonce, + // Message, + // ExpiresAt, ImitatingUser, } @@ -52,5 +52,5 @@ enum PendingLogin { #[derive(Iden)] enum User { Table, - Id + Id, } diff --git a/migration/src/m20230215_152254_admin_trail.rs b/migration/src/m20230215_152254_admin_trail.rs index 994361ee..67e386a8 100644 --- a/migration/src/m20230215_152254_admin_trail.rs +++ b/migration/src/m20230215_152254_admin_trail.rs @@ -87,7 +87,7 @@ enum AdminTrail { enum User { Table, Id, - Address, - Description, - Email, + // Address, + // Description, + // Email, } \ No newline at end of file diff --git a/web3_proxy/src/admin_queries.rs b/web3_proxy/src/admin_queries.rs index 0f8de6e1..85ec37b7 100644 --- a/web3_proxy/src/admin_queries.rs +++ b/web3_proxy/src/admin_queries.rs @@ -2,50 +2,58 @@ use crate::app::Web3ProxyApp; use crate::frontend::errors::FrontendErrorResponse; use crate::user_queries::get_user_id_from_params; use anyhow::Context; -use axum::{ - Json, - headers::{authorization::Bearer, Authorization}, - TypedHeader, -}; use axum::response::{IntoResponse, Response}; +use axum::{ + headers::{authorization::Bearer, Authorization}, + Json, TypedHeader, +}; use entities::{admin, login, user, user_tier}; use ethers::prelude::Address; -use ethers::types::Bytes; -use ethers::utils::keccak256; use hashbrown::HashMap; -use http::StatusCode; -use migration::sea_orm::{self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter}; -use log::{info, debug}; -use redis_rate_limiter::redis::AsyncCommands; +use log::{debug, info}; +use migration::sea_orm::{ + self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, +}; // TODO: Add some logic to check if the operating user is an admin // If he is, return true // If he is not, return false // This function is used to give permission to certain users - pub async fn query_admin_modify_usertier<'a>( app: &'a Web3ProxyApp, bearer: Option>>, - params: &'a HashMap + params: &'a HashMap, ) -> Result { - // Quickly return if any of the input tokens are bad let user_address: Vec = params .get("user_address") - .ok_or_else(|| FrontendErrorResponse::BadRequest("Unable to find user_address key in request".to_string()))? + .ok_or_else(|| { + FrontendErrorResponse::BadRequest( + "Unable to find user_address key in request".to_string(), + ) + })? .parse::
() - .map_err(|_| FrontendErrorResponse::BadRequest("Unable to parse user_address as an Address".to_string()))? - .to_fixed_bytes().into(); - let user_tier_title = params - .get("user_tier_title") - .ok_or_else(||FrontendErrorResponse::BadRequest("Unable to get the user_tier_title key from the request".to_string()))?; + .map_err(|_| { + FrontendErrorResponse::BadRequest( + "Unable to parse user_address as an Address".to_string(), + ) + })? + .to_fixed_bytes() + .into(); + let user_tier_title = params.get("user_tier_title").ok_or_else(|| { + FrontendErrorResponse::BadRequest( + "Unable to get the user_tier_title key from the request".to_string(), + ) + })?; // Prepare output body let mut response_body = HashMap::new(); // Establish connections - let db_conn = app.db_conn().context("query_admin_modify_user needs a db")?; + let db_conn = app + .db_conn() + .context("query_admin_modify_user needs a db")?; let db_replica = app .db_replica() .context("query_user_stats needs a db replica")?; @@ -57,16 +65,16 @@ pub async fn query_admin_modify_usertier<'a>( // Will modify logic here - // Try to get the user who is calling from redis (if existent) / else from the database // TODO: Make a single query, where you retrieve the user, and directly from it the secondary user (otherwise we do two jumpy, which is unnecessary) // get the user id first. if it is 0, we should use a cache on the app - let caller_id = get_user_id_from_params(&mut redis_conn, &db_conn, &db_replica, bearer, ¶ms).await?; + let caller_id = + get_user_id_from_params(&mut redis_conn, &db_conn, &db_replica, bearer, params).await?; debug!("Caller id is: {:?}", caller_id); // Check if the caller is an admin (i.e. if he is in an admin table) - let admin: admin::Model = admin::Entity::find() + let _admin: admin::Model = admin::Entity::find() .filter(admin::Column::UserId.eq(caller_id)) .one(&db_conn) .await? @@ -79,7 +87,9 @@ pub async fn query_admin_modify_usertier<'a>( .filter(user::Column::Address.eq(user_address)) .one(&db_conn) .await? - .ok_or(FrontendErrorResponse::BadRequest("No user with this id found".to_string()))?; + .ok_or(FrontendErrorResponse::BadRequest( + "No user with this id found".to_string(), + ))?; // Return early if the target user_tier_id is the same as the original user_tier_id response_body.insert( "user_tier_title", @@ -91,7 +101,9 @@ pub async fn query_admin_modify_usertier<'a>( .filter(user_tier::Column::Title.eq(user_tier_title.clone())) .one(&db_conn) .await? - .ok_or(FrontendErrorResponse::BadRequest("User Tier name was not found".to_string()))?; + .ok_or(FrontendErrorResponse::BadRequest( + "User Tier name was not found".to_string(), + ))?; if user.user_tier_id == new_user_tier.id { info!("user already has that tier"); @@ -105,18 +117,11 @@ pub async fn query_admin_modify_usertier<'a>( info!("user's tier changed"); } - // Query the login table, and get all bearer tokens by this user - let bearer_tokens = login::Entity::find() - .filter(login::Column::UserId.eq(user.id)) - .all(&db_conn) - .await?; - - // Now delete these tokens ... + // Now delete all bearer tokens of this user login::Entity::delete_many() .filter(login::Column::UserId.eq(user.id)) .exec(&db_conn) .await?; Ok(Json(&response_body).into_response()) - } diff --git a/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs b/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs index 081cd8a0..82e1495f 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs @@ -1,15 +1,11 @@ use anyhow::Context; use argh::FromArgs; use entities::{admin, login, user}; -use ethers::types::{Address, Bytes}; -use ethers::utils::keccak256; -use http::StatusCode; -use log::{debug, info}; +use ethers::types::Address; +use log::debug; use migration::sea_orm::{ - self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, ModelTrait, IntoActiveModel, - QueryFilter, + self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, ModelTrait, QueryFilter, }; -use web3_proxy::frontend::errors::FrontendErrorResponse; /// change a user's admin status. eiter they are an admin, or they aren't #[derive(FromArgs, PartialEq, Eq, Debug)] @@ -44,7 +40,8 @@ impl ChangeUserAdminStatusSubCommand { match admin::Entity::find() .filter(admin::Column::UserId.eq(address)) .one(db_conn) - .await? { + .await? + { Some(old_admin) if !should_be_admin => { // User is already an admin, but shouldn't be old_admin.delete(db_conn).await?; @@ -65,12 +62,6 @@ impl ChangeUserAdminStatusSubCommand { } } - // Get the bearer tokens of this user and delete them ... - let bearer_tokens = login::Entity::find() - .filter(login::Column::UserId.eq(user.id)) - .all(db_conn) - .await?; - // Remove any user logins from the database (incl. bearer tokens) let delete_result = login::Entity::delete_many() .filter(login::Column::UserId.eq(user.id)) diff --git a/web3_proxy/src/frontend/admin.rs b/web3_proxy/src/frontend/admin.rs index 286c1d44..4d55af2a 100644 --- a/web3_proxy/src/frontend/admin.rs +++ b/web3_proxy/src/frontend/admin.rs @@ -1,16 +1,13 @@ //! Handle admin helper logic -use super::authorization::{login_is_authorized, RpcSecretKey}; +use super::authorization::login_is_authorized; use super::errors::FrontendResult; +use crate::admin_queries::query_admin_modify_usertier; use crate::app::Web3ProxyApp; -use crate::user_queries::{get_page_from_params, get_user_id_from_params}; -use crate::user_queries::{ - get_chain_id_from_params, get_query_start_from_params, query_user_stats, StatResponse, -}; -use entities::prelude::{User, SecondaryUser}; +use crate::frontend::errors::FrontendErrorResponse; use crate::user_token::UserBearerToken; +use crate::PostLogin; use anyhow::Context; -use axum::headers::{Header, Origin, Referer, UserAgent}; use axum::{ extract::{Path, Query}, headers::{authorization::Bearer, Authorization}, @@ -20,20 +17,15 @@ use axum::{ use axum_client_ip::InsecureClientIp; use axum_macros::debug_handler; use chrono::{TimeZone, Utc}; -use entities::sea_orm_active_enums::{LogLevel, Role}; -use entities::{admin, admin_trail, login, pending_login, revert_log, rpc_key, secondary_user, user, user_tier}; +use entities::{admin_trail, login, pending_login, rpc_key, user}; use ethers::{abi::AbiEncode, prelude::Address, types::Bytes}; use hashbrown::HashMap; -use http::{HeaderValue, StatusCode}; -use ipnet::IpNet; -use itertools::Itertools; -use log::{debug, info, warn}; +use http::StatusCode; +use log::{debug, warn}; use migration::sea_orm::prelude::Uuid; use migration::sea_orm::{ - self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, PaginatorTrait, QueryFilter, - QueryOrder, TransactionTrait, TryIntoModel, + self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, }; -use serde::Deserialize; use serde_json::json; use siwe::{Message, VerificationOpts}; use std::ops::Add; @@ -41,9 +33,6 @@ use std::str::FromStr; use std::sync::Arc; use time::{Duration, OffsetDateTime}; use ulid::Ulid; -use crate::admin_queries::query_admin_modify_usertier; -use crate::frontend::errors::FrontendErrorResponse; -use crate::{PostLogin, PostLoginQuery}; /// `GET /admin/modify_role` -- As an admin, modify a user's user-tier /// @@ -95,18 +84,34 @@ pub async fn admin_login_get( // get the admin field ... let admin_address: Address = params .get("admin_address") - .ok_or_else(|| FrontendErrorResponse::BadRequest("Unable to find admin_address key in request".to_string()))? + .ok_or_else(|| { + FrontendErrorResponse::BadRequest( + "Unable to find admin_address key in request".to_string(), + ) + })? .parse::
() - .map_err(|err| { FrontendErrorResponse::BadRequest("Unable to parse user_address as an Address".to_string()) })?; - + .map_err(|_err| { + FrontendErrorResponse::BadRequest( + "Unable to parse admin_address as an Address".to_string(), + ) + })?; // Fetch the user_address parameter from the login string ... (as who we want to be logging in ...) let user_address: Vec = params .get("user_address") - .ok_or_else(|| FrontendErrorResponse::BadRequest("Unable to find user_address key in request".to_string()))? + .ok_or_else(|| { + FrontendErrorResponse::BadRequest( + "Unable to find user_address key in request".to_string(), + ) + })? .parse::
() - .map_err(|err| { FrontendErrorResponse::BadRequest("Unable to parse user_address as an Address".to_string(), ) })? - .to_fixed_bytes().into(); + .map_err(|_err| { + FrontendErrorResponse::BadRequest( + "Unable to parse user_address as an Address".to_string(), + ) + })? + .to_fixed_bytes() + .into(); // We want to login to llamanodes.com let login_domain = app @@ -141,7 +146,9 @@ pub async fn admin_login_get( }; let db_conn = app.db_conn().context("login requires a database")?; - let db_replica = app.db_replica().context("login requires a replica database")?; + let db_replica = app + .db_replica() + .context("login requires a replica database")?; // Get the user that we want to imitate from the read-only database (their id ...) // TODO: Only get the id, not the whole user object ... @@ -149,13 +156,17 @@ pub async fn admin_login_get( .filter(user::Column::Address.eq(user_address)) .one(db_replica.conn()) .await? - .ok_or(FrontendErrorResponse::BadRequest("Could not find user in db".to_string()))?; + .ok_or(FrontendErrorResponse::BadRequest( + "Could not find user in db".to_string(), + ))?; let admin = user::Entity::find() .filter(user::Column::Address.eq(admin_address.encode())) .one(db_replica.conn()) .await? - .ok_or(FrontendErrorResponse::BadRequest("Could not find admin in db".to_string()))?; + .ok_or(FrontendErrorResponse::BadRequest( + "Could not find admin in db".to_string(), + ))?; // Note that the admin is trying to log in as this user let trail = admin_trail::ActiveModel { @@ -187,7 +198,7 @@ pub async fn admin_login_get( nonce: sea_orm::Set(uuid), message: sea_orm::Set(message.to_string()), expires_at: sea_orm::Set(expires_at), - imitating_user: sea_orm::Set(Some(user.id)) + imitating_user: sea_orm::Set(Some(user.id)), }; user_pending_login @@ -221,7 +232,6 @@ pub async fn admin_login_get( pub async fn admin_login_post( Extension(app): Extension>, InsecureClientIp(ip): InsecureClientIp, - Query(query): Query, Json(payload): Json, ) -> FrontendResult { login_is_authorized(&app, ip).await?; @@ -293,7 +303,6 @@ pub async fn admin_login_post( .verify_eip191(&their_sig) .context("verifying eip191 signature against our local message") { - // delete ALL expired rows. let now = Utc::now(); let delete_result = pending_login::Entity::delete_many() @@ -309,12 +318,12 @@ pub async fn admin_login_post( err_1, err_191 ) - .into()); + .into()); } } - // TODO: Maybe add a context? - let imitating_user_id = user_pending_login.imitating_user + let imitating_user_id = user_pending_login + .imitating_user .context("getting address of the imitating user")?; // TODO: limit columns or load whole user? @@ -386,9 +395,9 @@ pub async fn admin_login_post( let user_login = login::ActiveModel { id: sea_orm::NotSet, bearer_token: sea_orm::Set(user_bearer_token.uuid()), - user_id: sea_orm::Set(imitating_user.id), // Yes, this should be the user ... because the rest of the applications takes this item, from the initial user + user_id: sea_orm::Set(imitating_user.id), // Yes, this should be the user ... because the rest of the applications takes this item, from the initial user expires_at: sea_orm::Set(expires_at), - read_only: sea_orm::Set(true) + read_only: sea_orm::Set(true), }; user_login @@ -405,7 +414,6 @@ pub async fn admin_login_post( } Ok(response) - } // TODO: This is basically an exact copy of the user endpoint, I should probabl refactor this code ... diff --git a/web3_proxy/src/frontend/authorization.rs b/web3_proxy/src/frontend/authorization.rs index 342addfc..6d014ebd 100644 --- a/web3_proxy/src/frontend/authorization.rs +++ b/web3_proxy/src/frontend/authorization.rs @@ -9,7 +9,7 @@ use axum::headers::authorization::Bearer; use axum::headers::{Header, Origin, Referer, UserAgent}; use chrono::Utc; use deferred_rate_limiter::DeferredRateLimitResult; -use entities::{admin, login, rpc_key, user, user_tier}; +use entities::{login, rpc_key, user, user_tier}; use ethers::types::Bytes; use ethers::utils::keccak256; use futures::TryFutureExt; diff --git a/web3_proxy/src/frontend/rpc_proxy_http.rs b/web3_proxy/src/frontend/rpc_proxy_http.rs index 7f3e87e4..781df406 100644 --- a/web3_proxy/src/frontend/rpc_proxy_http.rs +++ b/web3_proxy/src/frontend/rpc_proxy_http.rs @@ -74,13 +74,40 @@ async fn _proxy_web3_rpc( // TODO: this might be slow. think about this more // TODO: special string if no rpcs were used (cache hit)? - let rpcs: String = rpcs.into_iter().map(|x| x.name.clone()).join(","); + let mut backup_used = false; + + let rpcs: String = rpcs + .into_iter() + .map(|x| { + if x.backup { + backup_used = true; + } + x.name.clone() + }) + .join(","); headers.insert( - "W3P-BACKEND-RPCS", + "X-W3P-BACKEND-RPCS", rpcs.parse().expect("W3P-BACKEND-RPCS should always parse"), ); + headers.insert( + "X-W3P-BACKUP-RPC", + backup_used + .to_string() + .parse() + .expect("W3P-BACKEND-RPCS should always parse"), + ); + + // TODO: add a header if a backend rpc was used + + headers.insert( + "X-W3P-CLIENT-IP", + ip.to_string() + .parse() + .expect("X-CLIENT-IP should always parse"), + ); + Ok(response) } @@ -184,6 +211,8 @@ async fn _proxy_web3_rpc_with_key( let authorization = Arc::new(authorization); + let rpc_secret_key_id = authorization.checks.rpc_secret_key_id; + let (response, rpcs, _semaphore) = app .proxy_web3_rpc(authorization, payload, proxy_mode) .await @@ -193,13 +222,48 @@ async fn _proxy_web3_rpc_with_key( let headers = response.headers_mut(); + let mut backup_used = false; + // TODO: special string if no rpcs were used (cache hit)? or is an empty string fine? maybe the rpc name + "cached" - let rpcs: String = rpcs.into_iter().map(|x| x.name.clone()).join(","); + let rpcs: String = rpcs + .into_iter() + .map(|x| { + if x.backup { + backup_used = true; + } + x.name.clone() + }) + .join(","); headers.insert( - "W3P-BACKEND-RPCs", + "X-W3P-BACKEND-RPCs", rpcs.parse().expect("W3P-BACKEND-RPCS should always parse"), ); + headers.insert( + "X-W3P-BACKUP-RPC", + backup_used + .to_string() + .parse() + .expect("W3P-BACKEND-RPCS should always parse"), + ); + + headers.insert( + "X-W3P-CLIENT-IP", + ip.to_string() + .parse() + .expect("X-CLIENT-IP should always parse"), + ); + + if let Some(rpc_secret_key_id) = rpc_secret_key_id { + headers.insert( + "X-W3P-KEY-ID", + rpc_secret_key_id + .to_string() + .parse() + .expect("X-CLIENT-IP should always parse"), + ); + } + Ok(response) } diff --git a/web3_proxy/src/frontend/users.rs b/web3_proxy/src/frontend/users.rs index 9fada899..67b33f93 100644 --- a/web3_proxy/src/frontend/users.rs +++ b/web3_proxy/src/frontend/users.rs @@ -1,14 +1,13 @@ //! Handle registration, logins, and managing account data. - use super::authorization::{login_is_authorized, RpcSecretKey}; use super::errors::FrontendResult; use crate::app::Web3ProxyApp; -use crate::user_queries::{get_page_from_params, get_user_id_from_params}; +use crate::user_queries::get_page_from_params; use crate::user_queries::{ get_chain_id_from_params, get_query_start_from_params, query_user_stats, StatResponse, }; -use entities::prelude::{User, SecondaryUser}; use crate::user_token::UserBearerToken; +use crate::{PostLogin, PostLoginQuery}; use anyhow::Context; use axum::headers::{Header, Origin, Referer, UserAgent}; use axum::{ @@ -20,14 +19,14 @@ use axum::{ use axum_client_ip::InsecureClientIp; use axum_macros::debug_handler; use chrono::{TimeZone, Utc}; -use entities::sea_orm_active_enums::{LogLevel, Role}; -use entities::{login, pending_login, revert_log, rpc_key, secondary_user, user, user_tier}; +use entities::sea_orm_active_enums::LogLevel; +use entities::{login, pending_login, revert_log, rpc_key, user}; use ethers::{prelude::Address, types::Bytes}; use hashbrown::HashMap; use http::{HeaderValue, StatusCode}; use ipnet::IpNet; use itertools::Itertools; -use log::{debug, info, warn}; +use log::{debug, warn}; use migration::sea_orm::prelude::Uuid; use migration::sea_orm::{ self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, PaginatorTrait, QueryFilter, @@ -41,12 +40,6 @@ use std::str::FromStr; use std::sync::Arc; use time::{Duration, OffsetDateTime}; use ulid::Ulid; -use entities::user::Relation::UserTier; -use migration::extension::postgres::Type; -use thread_fast_rng::rand; -use crate::admin_queries::query_admin_modify_usertier; -use crate::frontend::errors::FrontendErrorResponse; -use crate::{PostLogin, PostLoginQuery}; /// `GET /user/login/:user_address` or `GET /user/login/:user_address/:message_eip` -- Start the "Sign In with Ethereum" (siwe) login flow. /// @@ -135,7 +128,7 @@ pub async fn user_login_get( nonce: sea_orm::Set(uuid), message: sea_orm::Set(message.to_string()), expires_at: sea_orm::Set(expires_at), - imitating_user: sea_orm::Set(None) + imitating_user: sea_orm::Set(None), }; user_pending_login @@ -355,7 +348,7 @@ pub async fn user_login_post( bearer_token: sea_orm::Set(user_bearer_token.uuid()), user_id: sea_orm::Set(u.id), expires_at: sea_orm::Set(expires_at), - read_only: sea_orm::Set(false) + read_only: sea_orm::Set(false), }; user_login diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index 1b814eb1..8186fbc6 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -117,7 +117,7 @@ pub struct Web3Rpc { /// use web3 queries to find the block data limit for archive/pruned nodes pub(super) automatic_block_limit: bool, /// only use this rpc if everything else is lagging too far. this allows us to ignore fast but very low limit rpcs - pub(super) backup: bool, + pub backup: bool, /// TODO: have an enum for this so that "no limit" prints pretty? pub(super) block_data_limit: AtomicU64, /// Lower tiers are higher priority when sending requests diff --git a/web3_proxy/src/user_queries.rs b/web3_proxy/src/user_queries.rs index ad448b6c..42bc8893 100644 --- a/web3_proxy/src/user_queries.rs +++ b/web3_proxy/src/user_queries.rs @@ -9,7 +9,6 @@ use axum::{ TypedHeader, }; use chrono::{NaiveDateTime, Utc}; -use ethers::prelude::Address; use entities::{login, rpc_accounting, rpc_key}; use hashbrown::HashMap; use http::StatusCode;