diff --git a/sz-poc-offsite-2025/evm/lightnode/src/lib.rs b/sz-poc-offsite-2025/evm/lightnode/src/lib.rs index 8c33d70..41d40e9 100644 --- a/sz-poc-offsite-2025/evm/lightnode/src/lib.rs +++ b/sz-poc-offsite-2025/evm/lightnode/src/lib.rs @@ -1,15 +1,13 @@ use std::ops::Range; -use executor_http_client::{BasicAuthCredentials, ExecutorHttpClient}; use nomos::{CryptarchiaInfo, HeaderId}; -use reqwest::{RequestBuilder, Url}; -use serde::{Deserialize, Serialize}; +use reqwest::Url; use tracing::{error, info}; pub const CRYPTARCHIA_INFO: &str = "cryptarchia/info"; pub const STORAGE_BLOCK: &str = "storage/block"; -mod nomos; +pub mod nomos; #[derive(Clone, Debug)] pub struct Credentials { @@ -36,14 +34,11 @@ impl NomosClient { let url = self.base_url.join(CRYPTARCHIA_INFO).expect("Invalid URL"); info!("Requesting cryptarchia info from {}", url); - let request = self.reqwest_client.get(url).basic_auth( &self.basic_auth.username, self.basic_auth.password.as_deref(), ); - info!("Sending request with creds {:?}", self.basic_auth); - let response = request.send().await.map_err(|e| { error!("Failed to send request: {}", e); "Failed to send request".to_string() @@ -65,7 +60,6 @@ impl NomosClient { let url = self.base_url.join(STORAGE_BLOCK).expect("Invalid URL"); info!("Requesting block with HeaderId {}", id); - let request = self .reqwest_client .post(url) diff --git a/sz-poc-offsite-2025/evm/lightnode/src/main.rs b/sz-poc-offsite-2025/evm/lightnode/src/main.rs index 19b674f..b5f1e9e 100644 --- a/sz-poc-offsite-2025/evm/lightnode/src/main.rs +++ b/sz-poc-offsite-2025/evm/lightnode/src/main.rs @@ -1,6 +1,5 @@ use clap::Parser; -use evm_lightnode::{Credentials, NomosClient}; -use executor_http_client::BasicAuthCredentials; +use evm_lightnode::{Credentials, NomosClient, nomos::HeaderId}; use url::Url; use std::error; @@ -34,11 +33,18 @@ async fn main() -> Result<(), Box> { let consensus = NomosClient::new(Url::parse(&url).unwrap(), basic_auth); - let info = consensus.get_cryptarchia_info().await?; - println!("Cryptarchia Info: {:?}", info); + let mut current_tip = HeaderId::default(); + loop { + let info = consensus.get_cryptarchia_info().await?; + println!("Cryptarchia Info: {:?}", info); - let block = consensus.get_block(info.tip).await?; - println!("Block: {:?}", block); + if info.tip != current_tip { + current_tip = info.tip; + println!("New tip: {:?}", current_tip); + let block = consensus.get_block(info.tip).await?; + println!("Block: {:?}", block); + } - Ok(()) + tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; + } } diff --git a/sz-poc-offsite-2025/evm/lightnode/src/nomos.rs b/sz-poc-offsite-2025/evm/lightnode/src/nomos.rs index 781d1b4..14cdcd1 100644 --- a/sz-poc-offsite-2025/evm/lightnode/src/nomos.rs +++ b/sz-poc-offsite-2025/evm/lightnode/src/nomos.rs @@ -13,7 +13,7 @@ pub struct CryptarchiaInfo { pub height: u64, } -#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash, PartialOrd, Ord)] +#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash, PartialOrd, Ord, Default)] pub struct HeaderId([u8; 32]); impl<'de> Deserialize<'de> for HeaderId {