Skip to content

Commit 123c99b

Browse files
authored
fix(examples): use new version of the SDK on validating public input example (#1798)
1 parent f14862f commit 123c99b

File tree

3 files changed

+99
-11
lines changed

3 files changed

+99
-11
lines changed

docs/3_guides/3_validating_public_input.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,21 @@ This command will log the address of the deployed contract like so:
175175

176176
```
177177
== Return ==
178-
0: address 0x5081a39b8A5f0E35a8D959395a630b68B74Dd30f
178+
0: address 0xFE5aBfb5E754e4AeFE1e8eC413ca6D2CCF99d5Ed
179179
```
180180

181181
Make sure to save this address, as you'll need it for the next step.
182182

183183
Now, to call our verifier contract and check the inclusion of the proof along with the validation of the public inputs, use the following command based on the verifier you used:
184184

185185
- For Risc0:
186+
186187
```bash
187188
make verify_risc0_batch_inclusion FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>
188189
```
189190

190191
- For SP1:
192+
191193
```bash
192194
make verify_sp1_batch_inclusion FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>
193195
```

examples/validating-public-input/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ generate_sp1_fibonacci_proof:
1313

1414
submit_fibonacci_sp1_proof_devnet:
1515
@cd aligned-integration && \
16-
RUST_LOG=info cargo run --release -- --proving-system "SP1" --network "devnet" --batcher-url "ws://localhost:8080" --rpc-url "http://localhost:8545"
16+
RUST_LOG=info cargo run --release -- --proving-system "SP1" --network "devnet" --rpc-url "http://localhost:8545"
1717

1818
submit_fibonacci_sp1_proof:
1919
@cd aligned-integration && \
20-
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "SP1"
20+
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "SP1" --network "holesky"
2121

2222
submit_fibonacci_risc0_proof_devnet:
2323
@cd aligned-integration && \
24-
RUST_LOG=info cargo run --release -- --proving-system "Risc0" --network "devnet" --batcher-url "ws://localhost:8080" --rpc-url "http://localhost:8545"
24+
RUST_LOG=info cargo run --release -- --proving-system "Risc0" --network "devnet" --rpc-url "http://localhost:8545"
2525

2626
submit_fibonacci_risc0_proof:
2727
@cd aligned-integration && \
28-
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "Risc0"
28+
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "Risc0" --network "holesky"
2929

3030
verify_sp1_batch_inclusion:
3131
@. ./contracts/.env && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) SP1

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

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub enum ProvingSystemArg {
4545
struct Args {
4646
#[arg(short, long, default_value = "wss://batcher.alignedlayer.com")]
4747
batcher_url: String,
48-
#[arg(short, long, default_value = "holesky")]
49-
network: Network,
48+
#[clap(flatten)]
49+
network: NetworkArg,
5050
#[arg(short, long)]
5151
keystore_path: Option<String>,
5252
#[arg(short, long)]
@@ -59,6 +59,93 @@ struct Args {
5959
rpc_url: String,
6060
}
6161

62+
#[derive(Debug, Clone, Copy)]
63+
enum NetworkNameArg {
64+
Devnet,
65+
Holesky,
66+
HoleskyStage,
67+
Mainnet,
68+
}
69+
70+
impl FromStr for NetworkNameArg {
71+
type Err = String;
72+
73+
fn from_str(s: &str) -> Result<Self, Self::Err> {
74+
match s {
75+
"devnet" => Ok(NetworkNameArg::Devnet),
76+
"holesky" => Ok(NetworkNameArg::Holesky),
77+
"holesky-stage" => Ok(NetworkNameArg::HoleskyStage),
78+
"mainnet" => Ok(NetworkNameArg::Mainnet),
79+
_ => Err(
80+
"Unknown network. Possible values: devnet, holesky, holesky-stage, mainnet"
81+
.to_string(),
82+
),
83+
}
84+
}
85+
}
86+
87+
#[derive(Debug, clap::Args, Clone)]
88+
struct NetworkArg {
89+
#[arg(
90+
name = "The working network's name",
91+
long = "network",
92+
default_value = "devnet",
93+
help = "[possible values: devnet, holesky, holesky-stage, mainnet]"
94+
)]
95+
network: Option<NetworkNameArg>,
96+
#[arg(
97+
name = "Aligned Service Manager Contract Address",
98+
long = "aligned_service_manager",
99+
conflicts_with("The working network's name"),
100+
requires("Batcher Payment Service Contract Address"),
101+
requires("Batcher URL")
102+
)]
103+
aligned_service_manager_address: Option<String>,
104+
105+
#[arg(
106+
name = "Batcher Payment Service Contract Address",
107+
long = "batcher_payment_service",
108+
conflicts_with("The working network's name"),
109+
requires("Aligned Service Manager Contract Address"),
110+
requires("Batcher URL")
111+
)]
112+
batcher_payment_service_address: Option<String>,
113+
114+
#[arg(
115+
name = "Batcher URL",
116+
long = "batcher_url",
117+
conflicts_with("The working network's name"),
118+
requires("Aligned Service Manager Contract Address"),
119+
requires("Batcher Payment Service Contract Address")
120+
)]
121+
batcher_url: Option<String>,
122+
}
123+
124+
impl From<NetworkArg> for Network {
125+
fn from(network_arg: NetworkArg) -> Self {
126+
let mut processed_network_argument = network_arg.clone();
127+
128+
if network_arg.batcher_url.is_some()
129+
|| network_arg.aligned_service_manager_address.is_some()
130+
|| network_arg.batcher_payment_service_address.is_some()
131+
{
132+
processed_network_argument.network = None; // We need this because network is Devnet as default, which is not true for a Custom network
133+
}
134+
135+
match processed_network_argument.network {
136+
None => Network::Custom(
137+
network_arg.aligned_service_manager_address.unwrap(),
138+
network_arg.batcher_payment_service_address.unwrap(),
139+
network_arg.batcher_url.unwrap(),
140+
),
141+
Some(NetworkNameArg::Devnet) => Network::Devnet,
142+
Some(NetworkNameArg::Holesky) => Network::Holesky,
143+
Some(NetworkNameArg::HoleskyStage) => Network::HoleskyStage,
144+
Some(NetworkNameArg::Mainnet) => Network::Mainnet,
145+
}
146+
}
147+
}
148+
62149
#[tokio::main]
63150
async fn main() -> Result<(), SubmitError> {
64151
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
@@ -73,7 +160,7 @@ async fn main() -> Result<(), SubmitError> {
73160
.await
74161
.expect("Failed to get chain_id");
75162

76-
let network: Network = args.network;
163+
let network: Network = args.network.clone().into();
77164
let wallet = match network {
78165
Network::Holesky => {
79166
let keystore_password = rpassword::prompt_password("Enter keystore password: ")
@@ -128,15 +215,14 @@ async fn main() -> Result<(), SubmitError> {
128215
// Set a fee of 0.01 Eth
129216
let max_fee = U256::from(100_000_000_000_000u128);
130217

131-
let nonce = get_nonce_from_ethereum(&args.rpc_url, wallet.address(), network)
218+
let nonce = get_nonce_from_ethereum(&args.rpc_url, wallet.address(), network.clone())
132219
.await
133220
.expect("Failed to get next nonce");
134221

135222
info!("Submitting Fibonacci proof to Aligned and waiting for verification...");
136223
let aligned_verification_data = submit_and_wait_verification(
137-
&args.batcher_url,
138224
&args.rpc_url,
139-
network,
225+
network.clone().into(),
140226
&verification_data,
141227
max_fee,
142228
wallet,

0 commit comments

Comments
 (0)