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"`
- [ ] weighted random choice should still prioritize non-archive servers
- 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!"

View File

@ -11,7 +11,7 @@ use axum::{
use derive_more::From;
use http::header::InvalidHeaderValue;
use ipnet::AddrParseError;
use log::warn;
use log::{trace, warn};
use migration::sea_orm::DbErr;
use redis_rate_limiter::redis::RedisError;
use reqwest::header::ToStrError;
@ -185,15 +185,17 @@ impl IntoResponse for FrontendErrorResponse {
return r;
}
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
// trace!(?status_code, ?err_msg, ?err);
// different status codes should get different error levels. 500s should warn. 400s should stat
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,
JsonRpcForwardedResponse::from_str(
&err_msg,
Some(status_code.as_u16().into()),
None,
),
JsonRpcForwardedResponse::from_str(&err_msg, Some(code.into()), None),
)
}
Self::HeaderToString(err) => {

View File

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

View File

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

View File

@ -5,7 +5,7 @@ use super::connection::Web3Connection;
use super::connections::Web3Connections;
use super::request::OpenRequestResult;
use ethers::prelude::{ProviderError, Transaction, TxHash};
use log::{debug, Level};
use log::{debug, trace, Level};
use std::sync::Arc;
use tokio::sync::broadcast;
@ -43,12 +43,12 @@ impl Web3Connections {
return Ok(None);
}
Err(err) => {
// trace!(
// ?pending_tx_id,
// ?rpc,
// ?err,
// "cancelled funneling transaction"
// );
trace!(
"cancelled funneling transaction {} from {}: {:?}",
pending_tx_id,
rpc,
err,
);
return Ok(None);
}
};
@ -94,14 +94,14 @@ impl Web3Connections {
Ok(Some(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
return Ok(());
}
Ok(None) => {}
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
// TODO: retry with exponential backoff with jitter starting from a much smaller time
// sleep(Duration::from_millis(100)).await;