Skip to content

Commit 96af3e3

Browse files
chore: update risc0 version in validating public inputs example (#891)
Co-authored-by: Mariano Nicolini <[email protected]>
1 parent af3d9c8 commit 96af3e3

File tree

13 files changed

+328
-269
lines changed

13 files changed

+328
-269
lines changed

examples/validating-public-input/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ docs/
1212

1313
# Dotenv file
1414
.env
15+
16+
risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.proof
17+
risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub
18+
risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_id.bin

examples/validating-public-input/aligned-integration/Cargo.lock

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

examples/validating-public-input/aligned-integration/Cargo.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag="v0.4.0" }
8-
tokio = { version = "1.37.0", features = ["io-std", "time", "macros", "rt", "rt-multi-thread", "sync"] }
9-
ethers = { tag = "v2.0.15-fix-reconnections", features = ["ws", "rustls"], git = "https://github.com/yetanotherco/ethers-rs.git" }
7+
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag = "v0.5.2" }
8+
tokio = { version = "1.37.0", features = [
9+
"io-std",
10+
"time",
11+
"macros",
12+
"rt",
13+
"rt-multi-thread",
14+
"sync",
15+
] }
16+
ethers = { tag = "v2.0.15-fix-reconnections", features = [
17+
"ws",
18+
"rustls",
19+
], git = "https://github.com/yetanotherco/ethers-rs.git" }
1020
serde = { version = "1.0.201", features = ["derive"] }
1121
serde_json = "1.0.117"
1222
log = "0.4.21"

examples/validating-public-input/aligned-integration/src/main.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::env;
12
use std::fs::File;
23
use std::io::Write;
34
use std::path::PathBuf;
@@ -6,7 +7,7 @@ use std::str::FromStr;
67
use aligned_sdk::core::errors::SubmitError;
78
use aligned_sdk::core::types::Chain::Holesky;
89
use aligned_sdk::core::types::{AlignedVerificationData, ProvingSystemId, VerificationData};
9-
use aligned_sdk::sdk::{get_next_nonce, submit_and_wait};
10+
use aligned_sdk::sdk::{get_next_nonce, submit_and_wait_verification};
1011
use env_logger::Env;
1112
use ethers::signers::{LocalWallet, Signer};
1213
use ethers::types::Address;
@@ -49,14 +50,17 @@ async fn main() -> Result<(), SubmitError> {
4950
proof_generator_addr,
5051
};
5152

52-
let wallet = LocalWallet::from_str(WALLET_PRIVATE_KEY).expect("Failed to create wallet");
53+
// Create a wallet and set chain id to holesky
54+
let wallet = LocalWallet::from_str(WALLET_PRIVATE_KEY)
55+
.expect("Failed to create wallet")
56+
.with_chain_id(17000u64);
5357

5458
let nonce = get_next_nonce(RPC_URL, wallet.address(), BATCHER_PAYMENTS_ADDRESS)
5559
.await
5660
.expect("Failed to get next nonce");
5761

5862
info!("Submitting Fibonacci proof to Aligned and waiting for verification...");
59-
let aligned_verification_data = submit_and_wait(
63+
let aligned_verification_data = submit_and_wait_verification(
6064
BATCHER_URL,
6165
RPC_URL,
6266
Holesky,
@@ -66,20 +70,24 @@ async fn main() -> Result<(), SubmitError> {
6670
)
6771
.await?;
6872

69-
let batch_inclusion_data_directory_path = PathBuf::from("./batch_inclusion_data");
73+
let batch_inclusion_data_directory_path = PathBuf::from("batch_inclusion_data");
7074

7175
info!(
7276
"Saving verification data to {:?}",
7377
batch_inclusion_data_directory_path
7478
);
75-
if let Some(aligned_verification_data) = aligned_verification_data {
76-
save_response(
77-
batch_inclusion_data_directory_path,
78-
&aligned_verification_data,
79-
)?;
80-
} else {
81-
return Err(SubmitError::EmptyVerificationDataList);
82-
}
79+
80+
info!("Proof submitted to aligned. See the batch in the explorer:");
81+
82+
info!(
83+
"https://explorer.alignedlayer.com/batches/0x{}",
84+
hex::encode(aligned_verification_data.batch_merkle_root)
85+
);
86+
87+
save_response(
88+
batch_inclusion_data_directory_path,
89+
&aligned_verification_data,
90+
)?;
8391

8492
Ok(())
8593
}
@@ -104,13 +112,19 @@ fn save_response(
104112
let batch_inclusion_data_path =
105113
batch_inclusion_data_directory_path.join(batch_inclusion_data_file_name);
106114

107-
let data = serde_json::to_vec(&aligned_verification_data)?;
115+
let data = serde_json::to_vec(&aligned_verification_data).unwrap();
108116

109117
let mut file = File::create(&batch_inclusion_data_path)
110118
.map_err(|e| SubmitError::IoError(batch_inclusion_data_path.clone(), e))?;
111-
112119
file.write_all(data.as_slice())
113120
.map_err(|e| SubmitError::IoError(batch_inclusion_data_path.clone(), e))?;
114121

122+
let current_dir = env::current_dir().expect("Failed to get current directory");
123+
124+
info!(
125+
"Saved batch inclusion data to {:?}",
126+
current_dir.join(batch_inclusion_data_path)
127+
);
128+
115129
Ok(())
116130
}

0 commit comments

Comments
 (0)