Skip to content

Commit 8f3c68d

Browse files
uri-99IAvecillaOppen
authored
refactor(example): enhance example for public inputs validation 2 (#1245)
Co-authored-by: IAvecilla <[email protected]> Co-authored-by: Mario Rugiero <[email protected]>
1 parent 7ff5f30 commit 8f3c68d

File tree

22 files changed

+14307
-363
lines changed

22 files changed

+14307
-363
lines changed

batcher/Cargo.lock

Lines changed: 154 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/3_guides/3_validating_public_input.md

Lines changed: 150 additions & 157 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
1-
generate_risc_zero_fibonacci_proof:
1+
SHELL := /bin/bash
2+
3+
generate_risc0_fibonacci_proof:
24
@cd risc_zero/fibonacci_proof_generator && \
3-
cargo run && \
5+
cargo run --release && \
46
echo "Fibonacci proof, pub input and image ID generated in risc_zero folder"
57

6-
submit_fibonacci_proof:
8+
generate_sp1_fibonacci_proof:
9+
@cd sp1/fibonacci/script && \
10+
cargo run --release && \
11+
echo "Fibonacci proof, pub input and image ID generated in sp1 folder"
12+
13+
14+
submit_fibonacci_sp1_proof_devnet:
15+
@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"
17+
18+
submit_fibonacci_sp1_proof:
19+
@cd aligned-integration && \
20+
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "SP1"
21+
22+
submit_fibonacci_risc0_proof_devnet:
723
@cd aligned-integration && \
8-
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH)
24+
RUST_LOG=info cargo run --release -- --proving-system "Risc0" --network "devnet" --batcher-url "ws://localhost:8080" --rpc-url "http://localhost:8545"
25+
26+
submit_fibonacci_risc0_proof:
27+
@cd aligned-integration && \
28+
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "Risc0"
29+
30+
verify_sp1_batch_inclusion:
31+
@. ./contracts/.env && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) SP1
32+
33+
verify_risc0_batch_inclusion:
34+
@. ./contracts/.env && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) Risc0
35+
36+
verify_risc0_batch_inclusion_devnet:
37+
@. ./contracts/.env.devnet && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) Risc0
38+
39+
verify_sp1_batch_inclusion_devnet:
40+
@. ./contracts/.env.devnet && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) SP1
941

1042
deploy_fibonacci_validator:
1143
@. ./contracts/.env && . ./contracts/deploy.sh
44+
45+
deploy_fibonacci_validator_devnet:
46+
@. ./contracts/.env.devnet && . ./contracts/deploy.sh
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Validating public input
2+
3+
## Testing locally
4+
5+
Set up all the components of aligned locally following the [aligned setup guide](../../docs/3_guides/6_setup_aligned.md).
6+
7+
This example is designed to do either with SP1 or risc0 proofs these are the commands to use depending on which verifier want to be used.
8+
9+
### Risc0
10+
11+
1. `make generate_risc0_fibonacci_proof`
12+
13+
2. `make submit_fibonacci_risc0_proof_devnet`
14+
15+
> The batch needs at least two proofs to be sealed, in another terminal run `make batcher_send_risc0_task` to actually submit the batch to aligned.
16+
17+
The command will log the file where all the aligned verification data was saved like so:
18+
19+
```
20+
[2024-10-09T15:54:42Z INFO aligned_integration] Saved batch inclusion data to ".../aligned_test/examples/validating-public-input/aligned-integration/batch_inclusion_data/<DATA_FILE_NAME>"
21+
```
22+
23+
Save the name since it will be necessary, you can found it in the path logged in the previous command otherwise.
24+
25+
3. `make deploy_fibonacci_validator_devnet`
26+
27+
The command will log the address where the validator was deployed:
28+
29+
```
30+
##### anvil-hardhat
31+
✅ [Success]Hash: 0xe0c216a3a24d5bd0551924592e42c6d96a889e3082ba3d7fff413336fba66815
32+
Contract Address: 0x5081a39b8A5f0E35a8D959395a630b68B74Dd30f
33+
Block: 585
34+
Paid: 0.000000000005889224 ETH (736153 gas * 0.000000008 gwei)
35+
```
36+
37+
save the contract address for the next command.
38+
39+
4. `make verify_risc0_batch_inclusion_devnet FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>`
40+
41+
Where `FIBONACCI_VALIDATOR_ADDRESS` is the address of the deployed validator contract and `DATA_FILE_NAME` the name of the file where the aligned verification data was saved (including the extension `.json`).
42+
43+
If everything goes well you should see a transaction receipt with a `success` label in the status:
44+
45+
```
46+
...
47+
root <ROOT_HASH>
48+
status 1 (success)
49+
transactionHash <TX_HASH>
50+
...
51+
```
52+
53+
### SP1
54+
55+
1. `make generate_sp1_fibonacci_proof`
56+
57+
2. `make submit_fibonacci_sp1_proof_devnet`
58+
59+
> The batch needs at least two proofs to be selaed, in another terminal run `make batcher_send_sp1_task` to actually submit the batch to aligned.
60+
61+
The command will log the file where all the aligned verification data was saved like so:
62+
63+
```
64+
[2024-10-09T15:54:42Z INFO aligned_integration] Saved batch inclusion data to "aligned-layer/examples/validating-public-input/aligned-integration/batch_inclusion_data/<DATA_FILE_NAME>"
65+
```
66+
67+
Save the name since it will be necessary, you can found it in the path logged in the previous command otherwise.
68+
69+
3. `make deploy_fibonacci_validator_devnet`
70+
71+
The command will log the address where the validator was deployed:
72+
73+
```
74+
##### anvil-hardhat
75+
✅ [Success]Hash: 0xe0c216a3a24d5bd0551924592e42c6d96a889e3082ba3d7fff413336fba66815
76+
Contract Address: 0x5081a39b8A5f0E35a8D959395a630b68B74Dd30f
77+
Block: 585
78+
Paid: 0.000000000005889224 ETH (736153 gas * 0.000000008 gwei)
79+
```
80+
81+
save the contract address for the next command.
82+
83+
4. `make verify_sp1_batch_inclusion_devnet FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>`
84+
85+
Where `FIBONACCI_VALIDATOR_ADDRESS` is the address of the deployed validator contract and `DATA_FILE_NAME` the name of the file where the aligned verification data was saved (including the extension `.json`).
86+
87+
If everything goes well you should see a transaction receipt with a `success` label in the status:
88+
89+
```
90+
...
91+
root <ROOT_HASH>
92+
status 1 (success)
93+
transactionHash <TX_HASH>
94+
...
95+
```

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

Lines changed: 49 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)