get shares call

This commit is contained in:
Petar Radovic 2025-04-24 12:50:14 +02:00
parent db58324716
commit 3a963eb59b
3 changed files with 38 additions and 12 deletions

View File

@ -16,3 +16,5 @@ risc0-zkvm = { version = "2" }
indexmap = { version = "1.9.3" }
url = { version = "2" }
hex = { version = "0.4" }
futures = { version = "0.3" }
kzgrs-backend = { git = "https://github.com/logos-co/nomos", branch = "master" }

View File

@ -1,9 +1,14 @@
use std::collections::HashSet;
use executor_http_client::{BasicAuthCredentials, Error, ExecutorHttpClient};
use kzgrs_backend::common::share::{DaLightShare, DaShare};
use nomos::{CryptarchiaInfo, HeaderId};
use reqwest::Url;
use tracing::{error, info};
use tracing::{debug, error, info};
pub const CRYPTARCHIA_INFO: &str = "cryptarchia/info";
pub const STORAGE_BLOCK: &str = "storage/block";
use futures::Stream;
pub mod nomos;
pub mod proofcheck;
@ -18,6 +23,7 @@ pub struct NomosClient {
base_url: Url,
reqwest_client: reqwest::Client,
basic_auth: Credentials,
nomos_client: ExecutorHttpClient,
}
impl NomosClient {
@ -25,14 +31,18 @@ impl NomosClient {
Self {
base_url,
reqwest_client: reqwest::Client::new(),
basic_auth,
basic_auth: basic_auth.clone(),
nomos_client: ExecutorHttpClient::new(Some(BasicAuthCredentials::new(
basic_auth.username,
basic_auth.password,
))),
}
}
pub async fn get_cryptarchia_info(&self) -> Result<CryptarchiaInfo, String> {
let url = self.base_url.join(CRYPTARCHIA_INFO).expect("Invalid URL");
info!("Requesting cryptarchia info from {}", url);
debug!("Requesting cryptarchia info from {}", url);
let request = self.reqwest_client.get(url).basic_auth(
&self.basic_auth.username,
self.basic_auth.password.as_deref(),
@ -84,11 +94,21 @@ impl NomosClient {
"Failed to parse JSON".to_string()
})?;
info!(
"Block (raw): {}",
serde_json::to_string_pretty(&json).unwrap()
);
Ok(json)
}
pub async fn get_shares(
&self,
blob_id: [u8; 32],
) -> Result<impl Stream<Item = DaLightShare>, Error> {
self.nomos_client
.get_shares::<DaShare>(
self.base_url.clone(),
blob_id,
HashSet::new(),
HashSet::new(),
true,
)
.await
}
}

View File

@ -1,9 +1,9 @@
use clap::Parser;
use evm_lightnode::proofcheck;
use url::Url;
use std::path::PathBuf;
use std::error;
use std::path::PathBuf;
use tracing_subscriber::{EnvFilter, fmt};
use url::Url;
#[derive(Parser, Debug)]
#[clap(author, version, about = "Light Node validator")]
@ -41,8 +41,12 @@ async fn main() -> Result<(), Box<dyn error::Error>> {
args.batch_size,
&args.rpc,
&args.prover_url,
&args.zeth_binary_dir.unwrap_or_else(|| std::env::current_dir().unwrap()).join("zeth-ethereum"),
).await?;
&args
.zeth_binary_dir
.unwrap_or_else(|| std::env::current_dir().unwrap())
.join("zeth-ethereum"),
)
.await?;
Ok(())
}