mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-09 16:43:09 +00:00
check binary
This commit is contained in:
parent
3170ebe8be
commit
1bb9aaa34f
@ -6,6 +6,7 @@ pub const CRYPTARCHIA_INFO: &str = "cryptarchia/info";
|
||||
pub const STORAGE_BLOCK: &str = "storage/block";
|
||||
|
||||
pub mod nomos;
|
||||
pub mod proofcheck;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Credentials {
|
||||
|
||||
@ -1,18 +1,33 @@
|
||||
use clap::Parser;
|
||||
use evm_lightnode::{Credentials, NomosClient, nomos::HeaderId};
|
||||
use evm_lightnode::{Credentials, NomosClient, nomos::HeaderId, proofcheck};
|
||||
use tracing::info;
|
||||
use url::Url;
|
||||
|
||||
use std::path::PathBuf;
|
||||
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")]
|
||||
#[clap(author, version, about = "Light Node validator")]
|
||||
struct Args {
|
||||
#[clap(long, default_value = "info")]
|
||||
log_level: String,
|
||||
|
||||
#[clap(long, default_value = "http://localhost:8546")]
|
||||
rpc: Url,
|
||||
|
||||
#[clap(long, default_value = "http://localhost:8070")]
|
||||
prover_url: Url,
|
||||
|
||||
#[clap(long)]
|
||||
start_block: u64,
|
||||
|
||||
#[clap(long, default_value = "10")]
|
||||
batch_size: u64,
|
||||
|
||||
#[clap(long)]
|
||||
zeth_binary_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@ -27,6 +42,14 @@ async fn main() -> Result<(), Box<dyn error::Error>> {
|
||||
password: Some(password),
|
||||
};
|
||||
|
||||
proofcheck::verify_proof(
|
||||
args.start_block,
|
||||
args.batch_size,
|
||||
&args.rpc,
|
||||
&args.prover_url,
|
||||
&args.zeth_binary_dir.unwrap_or_else(|| std::env::current_dir().unwrap()).join("zeth-ethereum"),
|
||||
).await?;
|
||||
|
||||
let filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(&args.log_level));
|
||||
|
||||
@ -48,4 +71,6 @@ async fn main() -> Result<(), Box<dyn error::Error>> {
|
||||
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
54
sz-poc-offsite-2025/evm/lightnode/src/proofcheck.rs
Normal file
54
sz-poc-offsite-2025/evm/lightnode/src/proofcheck.rs
Normal file
@ -0,0 +1,54 @@
|
||||
use tokio::process::Command;
|
||||
use std::path::Path;
|
||||
use reqwest::Url;
|
||||
use tracing::{error, info};
|
||||
|
||||
pub async fn verify_proof(
|
||||
block_number: u64,
|
||||
block_count: u64,
|
||||
rpc: &Url,
|
||||
prover_url: &Url,
|
||||
zeth_bin: &Path,
|
||||
) -> Result<(), String> {
|
||||
info!(
|
||||
"Verifying proof for blocks {}-{}",
|
||||
block_number,
|
||||
block_number + block_count - 1
|
||||
);
|
||||
|
||||
let proof = reqwest::get(format!(
|
||||
"{}/?block_start={}&block_count={}",
|
||||
prover_url, block_number, block_count
|
||||
)).await
|
||||
.map_err(|e| format!("Failed to fetch proof: {}", e))?
|
||||
.bytes()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to read proof response: {}", e))?;
|
||||
let filename = format!("{}-{}.zkp", block_number, block_count + block_number);
|
||||
tokio::fs::write(&filename, &proof)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to write proof to file: {}", e))?;
|
||||
|
||||
|
||||
let output = Command::new(zeth_bin)
|
||||
.args([
|
||||
"verify",
|
||||
&format!("--rpc={}", rpc),
|
||||
&format!("--block-number={}", block_number),
|
||||
&format!("--block-count={}", block_count),
|
||||
&format!("--file={}", filename),
|
||||
])
|
||||
.output().await
|
||||
.map_err(|e| format!("Failed to execute zeth-ethereum verify: {}", e))?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
error!("zeth-ethereum verify command failed: {}", stderr);
|
||||
return Err(format!(
|
||||
"zeth-ethereum verify command failed with status: {}\nStderr: {}",
|
||||
output.status, stderr
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user