Skip to content

Commit

Permalink
handle /proofs/queued endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
leruaa committed Jan 16, 2025
1 parent 236e0d2 commit 9477603
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
23 changes: 23 additions & 0 deletions bin/host/src/eth_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ impl EthProofsClient {
}
}

pub async fn queued(&self, block_number: u64) -> eyre::Result<()> {
let json = &serde_json::json!({
"block_number": block_number,
"cluster_id": self.cluster_id,
});

let response = self
.client
.post(format!("{}/proofs/queued", self.endpoint))
.header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {}", self.api_token))
.json(json)
.send()
.await?;

println!("Queued submission status: {}", response.status());
if !response.status().is_success() {
println!("Error response: {}", response.text().await?);
}

Ok(())
}

pub async fn proving(&self, block_number: u64) -> eyre::Result<()> {
let json = &serde_json::json!({
"block_number": block_number,
Expand Down
27 changes: 18 additions & 9 deletions bin/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ async fn main() -> eyre::Result<()> {

// Parse the command line arguments.
let args = HostArgs::parse();
let provider_config = args.provider.into_provider().await?;
let provider_config = args.provider.clone().into_provider().await?;
let eth_proofs_client = EthProofsClient::new(
args.eth_proofs_cluster_id,
args.eth_proofs_endpoint,
args.eth_proofs_api_token,
);

if let Some(eth_proofs_client) = &eth_proofs_client {
eth_proofs_client.queued(args.block_number).await?;
}

let variant = match provider_config.chain_id {
CHAIN_ID_ETH_MAINNET => ChainVariant::Ethereum,
Expand Down Expand Up @@ -100,7 +109,7 @@ async fn main() -> eyre::Result<()> {
.await
.expect("failed to execute host");

if let Some(cache_dir) = args.cache_dir {
if let Some(ref cache_dir) = args.cache_dir {
let input_folder = cache_dir.join(format!("input/{}", provider_config.chain_id));
if !input_folder.exists() {
std::fs::create_dir_all(&input_folder)?;
Expand Down Expand Up @@ -141,19 +150,19 @@ async fn main() -> eyre::Result<()> {
let block_hash = public_values.read::<B256>();
println!("success: block_hash={block_hash}");

if args.eth_proofs_endpoint.is_none() {
if eth_proofs_client.is_none() {
// Process the execute report, print it out, and save data to a CSV specified by
// report_path.
process_execution_report(variant, client_input, &execution_report, args.report_path)?;
process_execution_report(
variant,
client_input,
&execution_report,
args.report_path.clone(),
)?;
}

if args.prove {
println!("Starting proof generation.");
let eth_proofs_client = EthProofsClient::new(
args.eth_proofs_cluster_id,
args.eth_proofs_endpoint,
args.eth_proofs_api_token,
);

if let Some(eth_proofs_client) = &eth_proofs_client {
eth_proofs_client.proving(args.block_number).await?;
Expand Down

0 comments on commit 9477603

Please sign in to comment.