diff --git a/TODO.md b/TODO.md index e61a9390..1686f86a 100644 --- a/TODO.md +++ b/TODO.md @@ -205,6 +205,7 @@ These are roughly in order of completition - [ ] graceful shutdown. stop taking new requests and don't stop until all outstanding queries are handled - https://github.com/tokio-rs/mini-redis/blob/master/src/shutdown.rs - we need this because we need to be sure all the queries are saved in the db. maybe put stuff in Drop + - need an flume::watch on unflushed stats that we can subscribe to. wait for it to flip to true - [ ] include if archive query or not in the stats - this is already partially done, but we need to double check it works. preferrably with tests - [ ] WARN http_request:request: web3_proxy::block_number: could not get block from params err=unexpected params length id=01GF4HTRKM4JV6NX52XSF9AYMW method=POST authorized_request=User(Some(SqlxMySqlPoolConnection), AuthorizedKey { ip: 10.11.12.15, origin: None, user_key_id: 4, log_revert_chance: 0.0000 }) diff --git a/web3_proxy/src/frontend/rpc_proxy_http.rs b/web3_proxy/src/frontend/rpc_proxy_http.rs index e8b322ba..05775dc6 100644 --- a/web3_proxy/src/frontend/rpc_proxy_http.rs +++ b/web3_proxy/src/frontend/rpc_proxy_http.rs @@ -9,12 +9,14 @@ use axum::headers::{Authorization, Origin, Referer, UserAgent}; use axum::TypedHeader; use axum::{response::IntoResponse, Extension, Json}; use axum_client_ip::ClientIp; +use axum_macros::debug_handler; use std::sync::Arc; use tracing::{error_span, Instrument}; /// POST /rpc -- Public entrypoint for HTTP JSON-RPC requests. Web3 wallets use this. /// Defaults to rate limiting by IP address, but can also read the Authorization header for a bearer token. /// If possible, please use a WebSocket instead. +#[debug_handler] pub async fn proxy_web3_rpc( Extension(app): Extension>, bearer: Option>>, @@ -61,6 +63,7 @@ pub async fn proxy_web3_rpc( /// Rate limit and billing based on the api key in the url. /// Can optionally authorized based on origin, referer, or user agent. /// If possible, please use a WebSocket instead. +#[debug_handler] pub async fn proxy_web3_rpc_with_key( Extension(app): Extension>, ClientIp(ip): ClientIp, diff --git a/web3_proxy/src/frontend/status.rs b/web3_proxy/src/frontend/status.rs index 92814a84..6e594867 100644 --- a/web3_proxy/src/frontend/status.rs +++ b/web3_proxy/src/frontend/status.rs @@ -8,8 +8,10 @@ use axum::{http::StatusCode, response::IntoResponse, Extension, Json}; use moka::future::ConcurrentCacheExt; use serde_json::json; use std::sync::Arc; +use axum_macros::debug_handler; /// Health check page for load balancers to use. +#[debug_handler] pub async fn health(Extension(app): Extension>) -> impl IntoResponse { // TODO: also check that the head block is not too old if app.balanced_rpcs.synced() { @@ -22,6 +24,7 @@ pub async fn health(Extension(app): Extension>) -> impl IntoRe /// Prometheus metrics. /// /// TODO: when done debugging, remove this and only allow access on a different port +#[debug_handler] pub async fn prometheus(Extension(app): Extension>) -> impl IntoResponse { app.prometheus_metrics() } @@ -29,6 +32,7 @@ pub async fn prometheus(Extension(app): Extension>) -> impl In /// Very basic status page. /// /// TODO: replace this with proper stats and monitoring +#[debug_handler] pub async fn status(Extension(app): Extension>) -> impl IntoResponse { app.pending_transactions.sync(); app.user_key_cache.sync(); diff --git a/web3_proxy/src/user_stats.rs b/web3_proxy/src/user_stats.rs index 38b510b8..419c310f 100644 --- a/web3_proxy/src/user_stats.rs +++ b/web3_proxy/src/user_stats.rs @@ -6,6 +6,14 @@ use sea_orm::{ }; use tracing::{debug, info, trace}; +pub async fn get_rpc_stats(chain_id: u64) -> u64 { + todo!(); +} + +pub async fn get_user_stats() -> u64 { + todo!(); +} + pub async fn get_aggregate_stats( chain_id: u64, db: &DatabaseConnection,