mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-11 01:23:12 +00:00
lightnode
This commit is contained in:
parent
985a0e4840
commit
10ecbfffea
@ -1,5 +1,10 @@
|
||||
[workspace]
|
||||
members = ["evm/processor", "evm/sequencer-node", "evm/prover"]
|
||||
members = [
|
||||
"evm/processor",
|
||||
"evm/sequencer-node",
|
||||
"evm/prover",
|
||||
"evm/proof-checker",
|
||||
]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
@ -10,6 +15,7 @@ edition = "2024"
|
||||
evm-processor = { path = "evm/processor" }
|
||||
evm-sequencer-node = { path = "evm/sequencer-node" }
|
||||
evm-prover = { path = "evm/prover" }
|
||||
evm-proof-checker = { path = "evm/proof-checker" }
|
||||
|
||||
# External
|
||||
eyre = { version = "0.6" }
|
||||
|
||||
14
sz-poc-offsite-2025/evm/lightnode/Cargo.toml
Normal file
14
sz-poc-offsite-2025/evm/lightnode/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "evm-lightnode"
|
||||
edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
reqwest = { version = "0.11", features = ["blocking", "json"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
executor-http-client = { git = "https://github.com/logos-co/nomos", branch = "master" }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
kzgrs-backend = { git = "https://github.com/logos-co/nomos.git", branch = "master", package = "kzgrs-backend" }
|
||||
60
sz-poc-offsite-2025/evm/lightnode/src/lib.rs
Normal file
60
sz-poc-offsite-2025/evm/lightnode/src/lib.rs
Normal file
@ -0,0 +1,60 @@
|
||||
use std::ops::Range;
|
||||
|
||||
use executor_http_client::{BasicAuthCredentials, ExecutorHttpClient};
|
||||
use kzgrs_backend::common::share::DaShare;
|
||||
use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{error, error_span, info};
|
||||
|
||||
pub const DA_GET_RANGE: &str = "/da/get-range";
|
||||
|
||||
pub struct NomosDa {
|
||||
url: Url,
|
||||
client: ExecutorHttpClient,
|
||||
reqwest_client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl NomosDa {
|
||||
pub fn new(basic_auth: BasicAuthCredentials, url: Url) -> Self {
|
||||
Self {
|
||||
client: ExecutorHttpClient::new(Some(basic_auth)),
|
||||
url,
|
||||
reqwest_client: reqwest::Client::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_indexer_range(
|
||||
&self,
|
||||
app_id: [u8; 32],
|
||||
range: Range<[u8; 8]>,
|
||||
) -> Vec<([u8; 8], Vec<DaShare>)> {
|
||||
let endpoint = self
|
||||
.url
|
||||
.join(DA_GET_RANGE)
|
||||
.expect("Failed to construct valid URL");
|
||||
|
||||
match self
|
||||
.reqwest_client
|
||||
.post(endpoint)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(serde_json::to_string(&GetRangeReq { app_id, range }).unwrap())
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.json::<Vec<([u8; 8], Vec<DaShare>)>>()
|
||||
.await
|
||||
{
|
||||
Ok(data) => data,
|
||||
Err(e) => {
|
||||
error!("Failed to get indexer range: {e}");
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct GetRangeReq {
|
||||
pub app_id: [u8; 32],
|
||||
pub range: Range<[u8; 8]>,
|
||||
}
|
||||
53
sz-poc-offsite-2025/evm/lightnode/src/main.rs
Normal file
53
sz-poc-offsite-2025/evm/lightnode/src/main.rs
Normal file
@ -0,0 +1,53 @@
|
||||
use clap::Parser;
|
||||
use evm_proof_checker::NomosDa;
|
||||
use executor_http_client::BasicAuthCredentials;
|
||||
use reqwest::Url;
|
||||
use std::error;
|
||||
use tracing_subscriber::{EnvFilter, fmt};
|
||||
|
||||
const TESTNET_EXECUTOR: &str = "https://testnet.nomos.tech/node/3/";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about = "Ethereum Proof Generation Tool")]
|
||||
struct Args {
|
||||
// #[clap(long, required = true)]
|
||||
// block: u64,
|
||||
|
||||
// #[clap(long, required = true)]
|
||||
// proof_file_path: String,
|
||||
|
||||
// #[clap(long)]
|
||||
// zeth_binary_dir: Option<String>,
|
||||
#[clap(long, default_value = "info")]
|
||||
log_level: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn error::Error>> {
|
||||
let args = Args::parse();
|
||||
|
||||
let filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(&args.log_level));
|
||||
|
||||
fmt::fmt().with_env_filter(filter).with_target(false).init();
|
||||
|
||||
let url = std::env::var("NOMOS_EXECUTOR").unwrap_or(TESTNET_EXECUTOR.to_string());
|
||||
let user = std::env::var("NOMOS_USER").unwrap_or_default();
|
||||
let password = std::env::var("NOMOS_PASSWORD").unwrap_or_default();
|
||||
let da = NomosDa::new(
|
||||
BasicAuthCredentials::new(user, Some(password)),
|
||||
Url::parse(&url).unwrap(),
|
||||
);
|
||||
|
||||
let from = 0u64.to_be_bytes();
|
||||
let to = 1u64.to_be_bytes();
|
||||
|
||||
da.get_indexer_range([0; 32], from..to)
|
||||
.await
|
||||
.iter()
|
||||
.for_each(|(key, value)| {
|
||||
println!("Key: {:?}, Value: {:?}", key, value);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user