Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(example): enhance example for public inputs validation 2 #1245

Merged
merged 28 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d83511f
feat: add sp1 to the example of validating public input
IAvecilla Oct 7, 2024
46e9b57
chore: add n as public input in risc0 example
IAvecilla Oct 7, 2024
c0a7310
feat: generate network from string
IAvecilla Oct 7, 2024
2c6df70
feat: update fibonacci validator to work with the new example
IAvecilla Oct 7, 2024
8ebec3c
feat: update aligned integration to work with both verifiers
IAvecilla Oct 7, 2024
669e2a4
chore: update lock files
IAvecilla Oct 7, 2024
2b40713
chore: add docs to run example locally
IAvecilla Oct 7, 2024
f84ee99
feat: update docs for the new example
IAvecilla Oct 7, 2024
a79ee71
feat: update makefile with new targets to make example easier to run
IAvecilla Oct 7, 2024
9b8a1e1
feat: add bash script to test batch inclusion easily
IAvecilla Oct 7, 2024
ff2bb73
chore: fix toml EOL
IAvecilla Oct 7, 2024
3ae9c4c
chore: address review comments
IAvecilla Oct 9, 2024
70900d6
chore: add output examples for each command to be easier to follow
IAvecilla Oct 9, 2024
2b0df85
docs: add disclaimer when sending proofs to actually seal the batch
IAvecilla Oct 9, 2024
12b5bf7
fix: remove duplicated import
uri-99 Oct 14, 2024
2be439b
fix: update cargo.lock
uri-99 Oct 14, 2024
182f248
fix: update cargo.lock
uri-99 Oct 14, 2024
0b90f73
feat: better revert if invalid ELF, and updated risc0 elf
uri-99 Oct 14, 2024
224ff02
chore: add error code
uri-99 Oct 14, 2024
cd43ddc
fix: rebuild elf file if its removed
IAvecilla Oct 16, 2024
6e8fe35
chore: delete fibonacci lib in sp1 example
IAvecilla Oct 18, 2024
1c9016d
chore: update sp1 version and sp1 commitment
IAvecilla Oct 18, 2024
91498b6
chore: remove unused variable
IAvecilla Oct 22, 2024
f01e2fa
Update examples/validating-public-input/README.md
uri-99 Oct 22, 2024
9e50a16
fix: pr comment of unrelated change
uri-99 Oct 22, 2024
6bb9fb5
fix: add abs path to validating_public_inputs.md
uri-99 Oct 22, 2024
49f3574
fix: readme paths and makefile for linux
IAvecilla Oct 28, 2024
7d55b04
Merge branch 'testnet' into removing-staging-from-validating-pub-inputs
IAvecilla Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion batcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions batcher/aligned-sdk/src/core/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::str::FromStr;

use ethers::core::k256::ecdsa::SigningKey;
use ethers::signers::Signer;
use ethers::signers::Wallet;
Expand All @@ -14,6 +12,7 @@ use lambdaworks_crypto::merkle_tree::{
};
use serde::{Deserialize, Serialize};
use sha3::{Digest, Keccak256};
use std::str::FromStr;

uri-99 marked this conversation as resolved.
Show resolved Hide resolved
use super::errors::VerifySignatureError;

Expand Down
307 changes: 150 additions & 157 deletions docs/3_guides/3_validating_public_input.md

Large diffs are not rendered by default.

41 changes: 37 additions & 4 deletions examples/validating-public-input/Makefile
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
generate_risc_zero_fibonacci_proof:
generate_risc0_fibonacci_proof:
@cd risc_zero/fibonacci_proof_generator && \
cargo run && \
cargo run --release && \
echo "Fibonacci proof, pub input and image ID generated in risc_zero folder"

submit_fibonacci_proof:
generate_sp1_fibonacci_proof:
@cd sp1/fibonacci/script && \
cargo run --release && \
echo "Fibonacci proof, pub input and image ID generated in sp1 folder"


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

submit_fibonacci_sp1_proof:
@cd aligned-integration && \
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH)
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "SP1"

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

submit_fibonacci_risc0_proof:
@cd aligned-integration && \
RUST_LOG=info cargo run --release -- --keystore-path $(KEYSTORE_PATH) --proving-system "Risc0"

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

verify_risc0_batch_inclusion:
@. ./contracts/.env && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) Risc0

verify_risc0_batch_inclusion_devnet:
@. ./contracts/.env.devnet && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) Risc0

verify_sp1_batch_inclusion_devnet:
@. ./contracts/.env.devnet && . ./contracts/validate_batch_inclusion.sh $(FIBONACCI_VALIDATOR_ADDRESS) $(DATA_FILE_NAME) SP1

deploy_fibonacci_validator:
@. ./contracts/.env && . ./contracts/deploy.sh

deploy_fibonacci_validator_devnet:
@. ./contracts/.env.devnet && . ./contracts/deploy.sh
95 changes: 95 additions & 0 deletions examples/validating-public-input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Validating public input

## Testing locally

Set up all the components of aligned locally following the [aligned setup guide](../../docs/3_guides/6_setup_aligned.md).

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.

### Risc0

1. `make generate_risc0_fibonacci_proof`

2. `make submit_fibonacci_risc0_proof_devnet`

> The batch needs at least two proofs to be selaed, in another terminal run `make batcher_send_risc0_task` to actually submit the batch to aligned.
uri-99 marked this conversation as resolved.
Show resolved Hide resolved

The command will log the file where all the aligned verification data was saved like so:

```
[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>"
```

Save the name since it will be necessary, you can see it in `aligned-layer/examples/validating-public-input/batch_inclusion_data` otherwise.

3. `make deploy_fibonacci_validator_devnet`

The command will log the address where the validator was deployed:

```
##### anvil-hardhat
✅ [Success]Hash: 0xe0c216a3a24d5bd0551924592e42c6d96a889e3082ba3d7fff413336fba66815
Contract Address: 0x5081a39b8A5f0E35a8D959395a630b68B74Dd30f
Block: 585
Paid: 0.000000000005889224 ETH (736153 gas * 0.000000008 gwei)
```

save the contract address for the next command.

4. `make verify_risc0_batch_inclusion_devnet FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>`

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`).

If everything goes well you should see a transaction receipt with a `success` label in the status:

```
...
root <ROOT_HASH>
status 1 (success)
transactionHash <TX_HASH>
...
```

### SP1

1. `make generate_sp1_fibonacci_proof`

2. `make submit_fibonacci_sp1_proof_devnet`

> 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.

The command will log the file where all the aligned verification data was saved like so:

```
[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>"
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
```

Save the name since it will be necessary, you can see it in `aligned-layer/examples/validating-public-input/batch_inclusion_data` otherwise.
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved

3. `make deploy_fibonacci_validator_devnet`

The command will log the address where the validator was deployed:

```
##### anvil-hardhat
✅ [Success]Hash: 0xe0c216a3a24d5bd0551924592e42c6d96a889e3082ba3d7fff413336fba66815
Contract Address: 0x5081a39b8A5f0E35a8D959395a630b68B74Dd30f
Block: 585
Paid: 0.000000000005889224 ETH (736153 gas * 0.000000008 gwei)
```

save the contract address for the next command.

4. `make verify_sp1_batch_inclusion_devnet FIBONACCI_VALIDATOR_ADDRESS=<FIBONACCI_VALIDATOR_ADDRESS> DATA_FILE_NAME=<DATA_FILE_NAME>`

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`).

If everything goes well you should see a transaction receipt with a `success` label in the status:

```
...
root <ROOT_HASH>
status 1 (success)
transactionHash <TX_HASH>
...
```
55 changes: 49 additions & 6 deletions examples/validating-public-input/aligned-integration/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading