Skip to content

Commit 0cb4b14

Browse files
chore: bump up sdk version in zkquiz (#657)
1 parent 1213fe7 commit 0cb4b14

3 files changed

Lines changed: 32 additions & 64 deletions

File tree

examples/zkquiz/quiz/script/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/zkquiz/quiz/script/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66

77
[dependencies]
88
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "v1.0.8-testnet" }
9-
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer" }
9+
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag="v0.3.0" }
1010
ethers = { tag = "v2.0.15-fix-reconnections", features = ["ws", "rustls"], git = "https://github.com/yetanotherco/ethers-rs.git" }
1111
rpassword = "7.3.1"
1212
tokio = { version = "1.0.0", features = ["rt", "rt-multi-thread", "macros"] }

examples/zkquiz/quiz/script/src/main.rs

Lines changed: 30 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@ use std::io;
44
use std::str::FromStr;
55
use std::sync::Arc;
66

7-
use aligned_sdk::sdk::{submit, verify_proof_onchain};
8-
use aligned_sdk::types::{AlignedVerificationData, Chain, ProvingSystemId, VerificationData};
7+
use aligned_sdk::core::types::{AlignedVerificationData, Chain, ProvingSystemId, VerificationData};
8+
use aligned_sdk::sdk::submit_and_wait;
99
use clap::Parser;
1010
use dialoguer::Confirm;
11-
use ethers::core::k256::ecdsa::SigningKey;
1211
use ethers::prelude::*;
1312
use ethers::providers::{Http, Provider};
1413
use ethers::signers::{LocalWallet, Signer};
1514
use ethers::types::{Address, Bytes, H160, U256};
1615
use sp1_sdk::{ProverClient, SP1Stdin};
1716

18-
abigen!(
19-
VerifierContract,
20-
"VerifierContract.json",
21-
);
17+
abigen!(VerifierContract, "VerifierContract.json",);
2218

2319
const BATCHER_URL: &str = "wss://batcher.alignedlayer.com";
2420
const BATCHER_PAYMENTS_ADDRESS: &str = "0x815aeCA64a974297942D2Bbf034ABEe22a38A003";
@@ -112,24 +108,36 @@ async fn main() {
112108
pub_input: None,
113109
};
114110

115-
match submit_proof_and_wait_for_verification(
116-
verification_data,
111+
match submit_and_wait(
112+
BATCHER_URL,
113+
&rpc_url,
114+
Chain::Holesky,
115+
&verification_data,
117116
wallet.clone(),
118-
rpc_url.clone(),
119-
).await {
120-
Ok(aligned_verification_data) => {
121-
println!("Proof verified in Aligned, claiming prize...");
122-
123-
if let Err(e) = verify_batch_inclusion(
124-
aligned_verification_data.clone(),
125-
signer.clone(),
126-
args.verifier_contract_address,
127-
)
117+
)
118+
.await
119+
{
120+
Ok(maybe_aligned_verification_data) => match maybe_aligned_verification_data {
121+
Some(aligned_verification_data) => {
122+
println!(
123+
"Proof submitted and verified successfully on batch {}, claiming prize...",
124+
hex::encode(aligned_verification_data.batch_merkle_root)
125+
);
126+
127+
if let Err(e) = verify_batch_inclusion(
128+
aligned_verification_data.clone(),
129+
signer.clone(),
130+
args.verifier_contract_address,
131+
)
128132
.await
129-
{
130-
println!("Failed to claim prize: {:?}", e);
133+
{
134+
println!("Failed to claim prize: {:?}", e);
135+
}
131136
}
132-
}
137+
None => {
138+
println!("Proof submission failed. No verification data");
139+
}
140+
},
133141
Err(e) => {
134142
println!("Proof verification failed: {:?}", e);
135143
}
@@ -178,46 +186,6 @@ fn read_answer() -> char {
178186
}
179187
}
180188

181-
async fn submit_proof_and_wait_for_verification(
182-
verification_data: VerificationData,
183-
wallet: Wallet<SigningKey>,
184-
rpc_url: String,
185-
) -> anyhow::Result<AlignedVerificationData> {
186-
let res = submit(BATCHER_URL, &verification_data, wallet.clone())
187-
.await
188-
.map_err(|e| anyhow::anyhow!("Failed to submit proof for verification: {:?}", e))?;
189-
190-
match res {
191-
Some(aligned_verification_data) => {
192-
println!(
193-
"Proof submitted successfully on batch {}, waiting for verification...",
194-
hex::encode(aligned_verification_data.batch_merkle_root)
195-
);
196-
197-
for _ in 0..10 {
198-
if verify_proof_onchain(
199-
aligned_verification_data.clone(),
200-
Chain::Holesky,
201-
rpc_url.as_str(),
202-
)
203-
.await
204-
.is_ok_and(|r| r)
205-
{
206-
return Ok(aligned_verification_data);
207-
}
208-
209-
println!("Proof not verified yet. Waiting 10 seconds before checking again...");
210-
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
211-
}
212-
213-
anyhow::bail!("Proof verification failed");
214-
}
215-
None => {
216-
anyhow::bail!("Proof submission failed, no verification data");
217-
}
218-
}
219-
}
220-
221189
async fn pay_batcher(
222190
from: Address,
223191
signer: Arc<SignerMiddleware<Provider<Http>, LocalWallet>>,

0 commit comments

Comments
 (0)