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

Tidy up example #352

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
aca4a54
Project cleanup (#287)
gabrielbosio Jul 16, 2024
5ab9681
Fetch Mina state hash and proof (#288)
gabrielbosio Jul 23, 2024
dff28c5
Send hardcoded tip for consensus check (#292)
gabrielbosio Jul 24, 2024
6d4ad4b
State size in protocol state public input (#297)
gabrielbosio Jul 25, 2024
94d49e4
Core program and Aligned polling serivce (#296)
xqft Jul 25, 2024
82f7ed1
Smart contract (#295)
xqft Jul 25, 2024
9d7f853
Smart contract utility (#298)
xqft Jul 29, 2024
678a9a5
Clean core (#301)
xqft Jul 30, 2024
fb383c7
Started README specification section (#300)
xqft Jul 31, 2024
bbd6cd7
Verify account inclusion locally (#290)
gabrielbosio Aug 1, 2024
dc91d49
Refactor mina service to use `graphql_client` (#306)
xqft Aug 7, 2024
e6eef29
Remove state_utility directory (#304)
gabrielbosio Aug 7, 2024
5ab8f1a
Add account inclusion job (#305)
gabrielbosio Aug 7, 2024
24e95d4
Use tip state from bridge contract (#307)
xqft Aug 9, 2024
1302c38
Update Aligned SDK (#314)
gabrielbosio Aug 9, 2024
cce6341
Update README.md (#313)
xqft Aug 13, 2024
b0d252d
Remove root state hash, fix pub input hash variable (#320)
xqft Aug 14, 2024
5d0b446
Aligned Layer with Holesky (#303)
gabrielbosio Aug 16, 2024
9b55219
Remove account inclusion crate's GraphQL query, improve mina_polling_…
xqft Aug 23, 2024
5bff160
Delete nonce file on submit error (#325)
gabrielbosio Aug 23, 2024
0dbf7a3
Account verifier (#322)
xqft Aug 26, 2024
4861170
Point Aligned back to Mina (#329)
gabrielbosio Aug 30, 2024
28d62a1
Relative finalization (#327)
xqft Sep 3, 2024
153b804
Remove account hashes from contract storage (#331)
xqft Sep 5, 2024
be70567
Use new GraphQL API for account inclusion (#332)
xqft Sep 6, 2024
d90b702
Sync with Aligned 0.5 (#333)
gabrielbosio Sep 9, 2024
22336ab
Sync with Aligned 0.5.2 (#335)
gabrielbosio Sep 13, 2024
ce3d4b1
Add Solidity-friendly account structure as public input for the accou…
xqft Sep 16, 2024
132e4ea
Update Aligned to 0.6.0 (#336)
gabrielbosio Sep 16, 2024
f6c43af
Fix Aligned SDK dependency (#339)
xqft Sep 17, 2024
473f0d0
Point Aligned SDK to mina branch (#340)
gabrielbosio Sep 19, 2024
34de880
Update Aligned to 0.7.0 (#341)
gabrielbosio Sep 24, 2024
48e5c43
Sudoku example app (#338)
xqft Sep 25, 2024
f9396d9
Rename MinaBridge to MinaStateSettlement (#345)
xqft Sep 25, 2024
b9ca11d
Check Proving system ID (#342)
gabrielbosio Sep 25, 2024
7dac115
Parameterize Holesky contract addresses (#343)
gabrielbosio Sep 25, 2024
f550222
Update README and code doc (#347)
xqft Sep 26, 2024
09b3469
Fix README links (#349)
gabrielbosio Sep 26, 2024
91efe0d
Fix Tock constraint domain size and add Book reference (#350)
gabrielbosio Sep 26, 2024
cc1a5e7
Add verification key check
xqft Sep 27, 2024
152292b
Merge branch 'aligned' into verif_key_check
xqft Sep 27, 2024
e9afbf0
Fix zkapp address
xqft Sep 27, 2024
32e9732
Add sudoku validity holesky address as env var
xqft Sep 27, 2024
c211338
Update README
xqft Sep 27, 2024
0de6199
Fix (#353)
xqft Sep 30, 2024
f22ebea
Merge branch 'aligned' into verif_key_check
xqft Oct 1, 2024
60ef22b
Update zkapp address
xqft Oct 1, 2024
0a7063b
Select Mina state proof source (#351)
gabrielbosio Oct 2, 2024
f3bb736
Parameterize Sudoku Holesky address (#355)
gabrielbosio Oct 2, 2024
16bc6df
Usage and Setup sections (#348)
gabrielbosio Oct 3, 2024
8b6b717
Merge branch 'aligned' into verif_key_check
xqft Oct 3, 2024
b2776fe
Fix conflict
xqft Oct 3, 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
21 changes: 21 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ETH_CHAIN=<devnet/holesky>
MINA_RPC_URL=<url>
SAVE_PROOF=true/false # also false if other than "true" or variable were to be not defined

## These are necessary for running the Sudoku example
#FEEPAYER_KEY=<mina_private_key>
#SUDOKU_VALIDITY_HOLESKY_ADDRESS=<contract_addr>

## These can be skipped if using devnet with Anvil.
# BATCHER_ADDR=<optional>
# BATCHER_ETH_ADDR=<optional>
# ETH_RPC_URL=<optional>
# PROOF_GENERATOR_ADDR=<optional>
# BRIDGE_HOLESKY_ETH_ADDR=<optional>
# BRIDGE_ACCOUNT_HOLESKY_ETH_ADDR=<optional>
# ALIGNED_SM_HOLESKY_ETH_ADDR=<optional>

## You can choose to use a keystore or private key for your signing wallet.
## Leave empty if choosing Anvil Devnet.
# KEYSTORE_PATH=<optional>
# PRIVATE_KEY=<optional>
104 changes: 3 additions & 101 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,107 +7,9 @@ on:
branches: ["*"]

jobs:
public_input_gen:
name: Public input generation
uses: ./.github/workflows/rust_ci.yaml
with:
directory: public_input_gen

verifier_circuit_tests:
name: Execute o1js verifier circuit Rust tests for comparison
uses: ./.github/workflows/rust_ci.yaml
with:
directory: verifier_circuit_tests

verifier_circuit:
name: Build and test o1js verifier circuit
runs-on: ubuntu-selfhosted
defaults:
run:
working-directory: ./verifier_circuit
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup o1js submodule
run: git submodule update --init --recursive

- name: Set up dependencies
run: npm ci

- name: Run npm build
run: npm run build

- name: Run npm test
run: npm run test

integration:
name: Integration test
runs-on: ubuntu-selfhosted
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/[email protected]

- name: Run integration test
run: |
export HOME="/root/"
export PATH="/.foundry/bin:/root/.cargo/bin:$PATH"
export GOPATH="/root/go"
export MINA_RPC_URL="http://5.9.57.89:3085/graphql"
make

eth_verifier:
name: Test EVM verifier
runs-on: ubuntu-selfhosted
defaults:
run:
working-directory: ./eth_verifier
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/[email protected]

- name: Run tests
run: |
export HOME="/root/"
#export PATH="/.foundry/bin:/root/.cargo/bin:$PATH"
export GOPATH="/root/go"
make test > ../gasreport.ansi
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
- name: Compare gas reports
uses: Rubilmax/[email protected]
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
sortOrders: desc,asc # and directions
id: gas_diff

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}

merkle_path:
name: Test Merkle Path parser
uses: ./.github/workflows/rust_ci.yaml
with:
skip_run: true
directory: state_utility/merkle_path

merkle_root_parser:
name: Test Merkle Root parser
core:
name: Test Core
uses: ./.github/workflows/rust_ci.yaml
with:
skip_run: true
directory: state_utility/parser
directory: core
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/proof.json
/proof.mpk
monitor/priv/native/libverifier.so
.DS_Store
mina_3_0_0_devnet
mina_state.pub
mina_state.proof
mina_account.pub
mina_account.proof
aligned_verification_data
.env
nonce_*.bin
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@
[submodule "eth_verifier/lib/forge-std"]
path = eth_verifier/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contract/lib/forge-std"]
path = contract/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contract/lib/aligned_layer"]
path = contract/lib/aligned_layer
url = https://github.com/lambdaclass/aligned_layer
[submodule "app/eth_contract/lib/forge-std"]
path = app/eth_contract/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "example/eth_contract/lib/forge-std"]
path = example/eth_contract/lib/forge-std
url = https://github.com/foundry-rs/forge-std
87 changes: 22 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,26 @@
.PHONY: run check_account sepolia.wrap_and_deploy sepolia.verify
.PHONY: submit-state submit-account gen_contract_abi deploy_contract

run:
@echo "Setting up o1js..."
@git submodule update --init --recursive
@echo "Fetching state proof from Mina node..."
@cd polling_service && sh run.sh
@echo "Done!"
@echo "Fetching Merkle root..."
@cd state_utility && sh run.sh
@echo "Done!"
@echo "Creating circuit gates..."
@cd verifier_circuit && npm i && make
@echo "Done!"
@echo "Creating KZG proof..."
@cd kzg_prover && cargo r --release
@echo "Done!"
@echo "Deploying and verifying in Anvil..."
@cd eth_verifier && make setup && sh run.sh
@echo "Done!"
@echo "Save the last contract address, this is your verifier!"
@echo "You can use cast to interact with it. Try calling:"
@echo " cast call <CONTRACT_ADDR> 'is_state_available()(bool)'"
@echo "to check if verification succeded. If so, then you can retrieve state data:"
@echo " cast call <CONTRACT_ADDR> 'retrieve_state_creator()(string)'"
@echo " cast call <CONTRACT_ADDR> 'retrieve_state_hash()(uint256)'"
@echo " cast call <CONTRACT_ADDR> 'retrieve_state_height()(uint256)'"
submit_state:
@cargo run --manifest-path core/Cargo.toml --release -- submit-state

check_account:
@echo "Fetching Merkle path and leaf hash..."
@cd state_utility/merkle_path && cargo r --release -- $(MINA_RPC_URL) ../../public_key.txt
@echo "Done!"
@echo "Verifying Merkle proof inclusion..."
@cd eth_verifier && make setup && make merkle_locally
@echo "Done!"
submit_account:
@cargo run --manifest-path core/Cargo.toml --release -- submit-account ${PUBLIC_KEY} ${STATE_HASH}

sepolia.wrap_and_deploy:
@echo "Setting up o1js..."
@git submodule update --init --recursive
@echo "Fetching state proof from Mina node..."
@cd polling_service && sh run.sh
@echo "Done!"
@echo "Creating circuit gates..."
@cd verifier_circuit && npm i && make
@echo "Done!"
@echo "Creating KZG proof..."
@cd kzg_prover && cargo r --release
@echo "Done!"
@echo "Fetching Merkle root..."
@cd state_utility && sh run.sh
@echo "Done!"
@echo "Deploying verifier in Sepolia..."
@cd eth_verifier && make sepolia.deploy_deser
@echo "Done!"
@echo "Once the verifier deployment is confirmed, set CONTRACT_ADDRESS env var and run:"
@echo " make sepolia.verify"
gen_contract_abis:
forge build --root contract/
forge build --root example/eth_contract
cp contract/out/MinaStateSettlement.sol/MinaStateSettlement.json core/abi/MinaStateSettlement.json
cp contract/out/MinaAccountValidation.sol/MinaAccountValidation.json core/abi/MinaAccountValidation.json
cp example/eth_contract/out/SudokuValidity.sol/SudokuValidity.json example/app/abi/SudokuValidity.json

sepolia.verify:
@echo "Uploading proof and Merkle root to Sepolia..."
@cd eth_verifier && make sepolia.upload_proof_and_merkle_root
@echo "Done!"
@echo "Once the upload is confirmed in Sepolia, press any key to continue."; read REPLY
@echo "Verifying uploaded proof in Sepolia..."
@cd eth_verifier && make sepolia.verify
@echo "Done!"
@echo "Once the proof verification is confirmed in Sepolia, press any key to continue."; read REPLY
@echo "Verifying Merkle proof inclusion in Sepolia..."
@cd eth_verifier && make sepolia.merkle_verify
@echo "Done!"
deploy_contract: gen_contract_abis
@cargo run --manifest-path contract_deployer/Cargo.toml --release

deploy_example_contract: gen_contract_abis
@cargo run --manifest-path example/app/Cargo.toml --release -- deploy-contract

execute_example:
cd example/mina_zkapp; \
npm run build; \
node build/src/run.js
cargo run --manifest-path example/app/Cargo.toml --release -- validate-solution
Loading