diff --git a/utils/pathfinder-probe/Cargo.lock b/utils/pathfinder-probe/Cargo.lock index a02cfffaef..57a284f1ed 100644 --- a/utils/pathfinder-probe/Cargo.lock +++ b/utils/pathfinder-probe/Cargo.lock @@ -53,12 +53,13 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8175979259124331c1d7bf6586ee7e0da434155e4b2d48ec2c8386281d8df39" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", + "axum-macros", "bitflags", "bytes", "futures-util", @@ -100,6 +101,18 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-macros" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "backtrace" version = "0.3.68" @@ -387,6 +400,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.2" diff --git a/utils/pathfinder-probe/Cargo.toml b/utils/pathfinder-probe/Cargo.toml index 031da579f1..1aee6bb08f 100644 --- a/utils/pathfinder-probe/Cargo.toml +++ b/utils/pathfinder-probe/Cargo.toml @@ -7,7 +7,7 @@ rust-version = "1.73" [dependencies] anyhow = "1.0.71" -axum = { workspace = true } +axum = { version = "0.6.19", features = ["macros"] } futures = "0.3.28" metrics = "0.21.1" metrics-exporter-prometheus = "0.12.1" diff --git a/utils/pathfinder-probe/README.md b/utils/pathfinder-probe/README.md index e0ddd12772..e61d8713c3 100644 --- a/utils/pathfinder-probe/README.md +++ b/utils/pathfinder-probe/README.md @@ -18,7 +18,7 @@ Environment="RUST_LOG=info" ExecStart=/var/lib/pathfinder/pathfinder-probe \ 0.0.0.0:19999 \ https://alpha-mainnet.starknet.io \ -http://127.0.0.1:9545 \ +http://127.0.0.1:9545/rpc/v0.5 \ 5 SyslogIdentifier=pathfinder-probe Restart=always diff --git a/utils/pathfinder-probe/src/main.rs b/utils/pathfinder-probe/src/main.rs index d98e357ae1..18731e6bb6 100644 --- a/utils/pathfinder-probe/src/main.rs +++ b/utils/pathfinder-probe/src/main.rs @@ -34,6 +34,17 @@ async fn main() -> anyhow::Result<()> { setup.poll_delay, )) .for_each(|(gw, pf)| { + tracing::info!( + block = gw.block_number, + time = gw.block_timestamp, + "gateway" + ); + tracing::info!( + block = pf.block_number, + time = pf.block_timestamp, + "pathfinder" + ); + let blocks_missing = gw.block_number - pf.block_number; metrics::gauge!("blocks_missing", blocks_missing as f64); @@ -97,7 +108,13 @@ where T: Clone + Debug + Default + 'a, { futures::stream::unfold(T::default(), move |old| async move { - let new = f(url).await.unwrap_or(old); + let new = match f(url).await { + Ok(new) => new, + Err(e) => { + tracing::error!(tag, "error: {e}"); + old + } + }; tracing::debug!(%tag, ?new, "stream"); tokio::time::sleep(delay).await; Some((new.clone(), new)) @@ -129,10 +146,10 @@ async fn get_gateway_latest(gateway_url: &Url) -> anyhow::Result { }) } -// curl -H 'Content-type: application/json' -d '{"jsonrpc":"2.0","method":"starknet_getBlockWithTxHashes","params":["latest"],"id":1}' http://127.0.0.1:9000/rpc/v0.3 +// curl -H 'Content-type: application/json' -d '{"jsonrpc":"2.0","method":"starknet_getBlockWithTxHashes","params":["latest"],"id":1}' http://127.0.0.1:9000/rpc/v0.5 async fn get_pathfinder_head(pathfinder_url: &Url) -> anyhow::Result { let json: serde_json::Value = reqwest::ClientBuilder::new().build()? - .post(pathfinder_url.join("rpc/v0.3")?) + .post(pathfinder_url.to_owned()) .header("Content-type", "application/json") .json(&serde_json::json!({"jsonrpc":"2.0","method":"starknet_getBlockWithTxHashes","params":["latest"],"id":1})) .timeout(REQUEST_TIMEOUT)