lint more

This commit is contained in:
Bryan Stitt 2022-11-16 07:19:56 +00:00
parent 186218b8b9
commit 2829ce7a7d
5 changed files with 33 additions and 24 deletions

View File

@ -247,6 +247,10 @@ These are roughly in order of completition
- [ ] tests should use `test-env-log = "0.2.8"` - [ ] tests should use `test-env-log = "0.2.8"`
- [ ] weighted random choice should still prioritize non-archive servers - [ ] weighted random choice should still prioritize non-archive servers
- maybe shuffle randomly and then sort by (block_limit, random_index)? - maybe shuffle randomly and then sort by (block_limit, random_index)?
- maybe sum available_requests grouped by archive/non-archive. only limit to non-archive if they have enough?
- [ ] cli commands to search users by key
- [ ] cli command to change user_tier by key
- [ ] change invite codes to set the user_tier
- [ ] actually block unauthenticated requests instead of emitting warning of "allowing without auth during development!" - [ ] actually block unauthenticated requests instead of emitting warning of "allowing without auth during development!"

View File

@ -11,7 +11,7 @@ use axum::{
use derive_more::From; use derive_more::From;
use http::header::InvalidHeaderValue; use http::header::InvalidHeaderValue;
use ipnet::AddrParseError; use ipnet::AddrParseError;
use log::warn; use log::{trace, warn};
use migration::sea_orm::DbErr; use migration::sea_orm::DbErr;
use redis_rate_limiter::redis::RedisError; use redis_rate_limiter::redis::RedisError;
use reqwest::header::ToStrError; use reqwest::header::ToStrError;
@ -185,15 +185,17 @@ impl IntoResponse for FrontendErrorResponse {
return r; return r;
} }
Self::StatusCode(status_code, err_msg, err) => { Self::StatusCode(status_code, err_msg, err) => {
// TODO: warn is way too loud. different status codes should get different error levels. 500s should warn. 400s should stat // different status codes should get different error levels. 500s should warn. 400s should stat
// trace!(?status_code, ?err_msg, ?err); let code = status_code.as_u16();
if (500..600).contains(&code) {
warn!("user error {} {:?}: {:?}", code, err_msg, err);
} else {
trace!("user error {} {:?}: {:?}", code, err_msg, err);
}
( (
status_code, status_code,
JsonRpcForwardedResponse::from_str( JsonRpcForwardedResponse::from_str(&err_msg, Some(code.into()), None),
&err_msg,
Some(status_code.as_u16().into()),
None,
),
) )
} }
Self::HeaderToString(err) => { Self::HeaderToString(err) => {

View File

@ -21,7 +21,7 @@ use futures::{
use handlebars::Handlebars; use handlebars::Handlebars;
use hashbrown::HashMap; use hashbrown::HashMap;
use http::StatusCode; use http::StatusCode;
use log::{error, info}; use log::{error, info, trace};
use serde_json::{json, value::RawValue}; use serde_json::{json, value::RawValue};
use std::sync::Arc; use std::sync::Arc;
use std::{str::from_utf8_mut, sync::atomic::AtomicUsize}; use std::{str::from_utf8_mut, sync::atomic::AtomicUsize};
@ -276,9 +276,12 @@ async fn read_web3_socket(
) )
.await .await
} }
Message::Ping(x) => Message::Pong(x), Message::Ping(x) => {
trace!("ping: {:?}", x);
Message::Pong(x)
}
Message::Pong(x) => { Message::Pong(x) => {
// // trace!("pong: {:?}", x); trace!("pong: {:?}", x);
continue; continue;
} }
Message::Close(_) => { Message::Close(_) => {
@ -324,8 +327,8 @@ async fn write_web3_socket(
// forward the response to through the websocket // forward the response to through the websocket
if let Err(err) = ws_tx.send(msg).await { if let Err(err) = ws_tx.send(msg).await {
// this isn't a problem. this is common and happens whenever a client disconnects // this is common. it happens whenever a client disconnects
// trace!(?err, "unable to write to websocket"); trace!("unable to write to websocket: {:?}", err);
break; break;
}; };
} }

View File

@ -8,7 +8,7 @@ use entities::revert_log;
use entities::sea_orm_active_enums::Method; use entities::sea_orm_active_enums::Method;
use ethers::providers::{HttpClientError, ProviderError, WsClientError}; use ethers::providers::{HttpClientError, ProviderError, WsClientError};
use ethers::types::{Address, Bytes}; use ethers::types::{Address, Bytes};
use log::{debug, error, warn, Level}; use log::{debug, error, trace, warn, Level};
use metered::metered; use metered::metered;
use metered::HitCount; use metered::HitCount;
use metered::ResponseTime; use metered::ResponseTime;
@ -117,7 +117,7 @@ impl Authorization {
// TODO: what log level? // TODO: what log level?
// TODO: better format // TODO: better format
// trace!(?rl); trace!("revert_log: {:?}", rl);
// TODO: return something useful // TODO: return something useful
Ok(()) Ok(())

View File

@ -5,7 +5,7 @@ use super::connection::Web3Connection;
use super::connections::Web3Connections; use super::connections::Web3Connections;
use super::request::OpenRequestResult; use super::request::OpenRequestResult;
use ethers::prelude::{ProviderError, Transaction, TxHash}; use ethers::prelude::{ProviderError, Transaction, TxHash};
use log::{debug, Level}; use log::{debug, trace, Level};
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::broadcast; use tokio::sync::broadcast;
@ -43,12 +43,12 @@ impl Web3Connections {
return Ok(None); return Ok(None);
} }
Err(err) => { Err(err) => {
// trace!( trace!(
// ?pending_tx_id, "cancelled funneling transaction {} from {}: {:?}",
// ?rpc, pending_tx_id,
// ?err, rpc,
// "cancelled funneling transaction" err,
// ); );
return Ok(None); return Ok(None);
} }
}; };
@ -94,14 +94,14 @@ impl Web3Connections {
Ok(Some(tx_state)) => { Ok(Some(tx_state)) => {
let _ = pending_tx_sender.send(tx_state); let _ = pending_tx_sender.send(tx_state);
// trace!(?pending_tx_id, "sent"); trace!("sent tx {:?}", pending_tx_id);
// we sent the transaction. return now. don't break looping because that gives a warning // we sent the transaction. return now. don't break looping because that gives a warning
return Ok(()); return Ok(());
} }
Ok(None) => {} Ok(None) => {}
Err(err) => { Err(err) => {
// trace!(?err, ?pending_tx_id, "failed fetching transaction"); trace!("failed fetching transaction {:?}: {:?}", pending_tx_id, err);
// unable to update the entry. sleep and try again soon // unable to update the entry. sleep and try again soon
// TODO: retry with exponential backoff with jitter starting from a much smaller time // TODO: retry with exponential backoff with jitter starting from a much smaller time
// sleep(Duration::from_millis(100)).await; // sleep(Duration::from_millis(100)).await;