Skip to content

Commit

Permalink
Use AlignedLayer Bridge (#344)
Browse files Browse the repository at this point in the history
* Project cleanup (#287)

* Remove modules that won't be used in the Aligned version

* Fix Markdown lint issues

* Forward GraphQL port in CI

* Remove domain name usage

* Remove tunneling and comment Merkle path job

* Uncomment Merkle path job and comment nextest step

* Try port forwarding to access GraphQL

* Revert "Try port forwarding to access GraphQL"

This reverts commit 79084b9.

* Fetch Mina state hash and proof (#288)

* Remove modules that won't be used in the Aligned version

* Fix Markdown lint issues

* Forward GraphQL port in CI

* Remove domain name usage

* Remove tunneling and comment Merkle path job

* Uncomment Merkle path job and comment nextest step

* Try port forwarding to access GraphQL

* Revert "Try port forwarding to access GraphQL"

This reverts commit 79084b9.

* Fetch state hash and proof and parse them

* Simplify input parsing

* Revert "Simplify input parsing"

This reverts commit 91a1621.

* Separate queries for hash and proof

* Integrate with Aligned

* Add test

* Remove unwraps

* Add usage section

* Fetch last block from Mina (#291)

* Fetch last block and simplify polling

* Add public input generation

* Add integration test

* Read protocol state proof

* Remove unnecessary ignored file

* Use mina-builder as GraphQL server

* Add Polling service job

* Make test generate files in same dir

* Fix clippy issue

* Send hardcoded tip for consensus check (#292)

* Send hardocoded (for now) tip data

* Adapt to new state size

* State size in protocol state public input (#297)

* Add state size to public input

* Cast state len to u32

* Core program and Aligned polling serivce (#296)

* Renamed polling service to core

* Reorg core

* WIP aligned_polling_service

* Implemented submit function to aligned service

* Added tokio and called submit proof function

* Added dotenv and default values for some variables

* Added logging

* Fixed batcher address

* Better logging

* Update logs

* Update Makefile

* Update README

* Fix CI

* Smart contract (#295)

* chore: forge init

* forge install: forge-std

v1.9.1

* Contract baseline

* Rename files and contract

* forge install: aligned_layer

mina

* Fix remappings

* Fix versions and remappings

* First version of updateLastVerifiedState function

* Smart contract utility (#298)

* Create smart contract utility

* Add contract ABI

* WIP call contract

* Finish function to update smart contract

* WIP Deploy contract

* Finished bridge contract deployment

* WIP Hash public inputs

* Finished smart contract utility

* Remove unused env vars

* Fix mina bridge script

* Update readme

* Clarify Makefile comment

* Fix module doc

* Move smart contract update comment

* Update README.md

---------

Co-authored-by: Gabriel Bosio <[email protected]>

* Clean core (#301)

* Create smart contract utility

* Add contract ABI

* WIP call contract

* Finish function to update smart contract

* WIP Deploy contract

* Finished bridge contract deployment

* WIP Hash public inputs

* Finished smart contract utility

* Remove unused env vars

* Fix mina bridge script

* Update readme

* Clarify Makefile comment

* Fix module doc

* Move smart contract update comment

* Refactor constants into their own file

* Better logging

* Change variable name

* Change log

* Refactor environment variables

* Refactor env.rs and constants.rs into utils mod

* Refactor wallet setup

* Add missing env var

* Default env vars as constants

* Fix test

* Remove git diff marker

* Remove git diff marker

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

* Refactor closure

---------

Co-authored-by: Gabriel Bosio <[email protected]>

* Started README specification section (#300)

* Started README specification section

* Architecture updated

* Architecture links updated

* update Mina Polling Service Architecture

* Update specification

* README fixes

* Fix warning

* Fix usage section

* Update consensus checks

* Fix header

* Fix about

* Fix about

* Fix links

* Fix links

* Update README.md

---------

Co-authored-by: Eduardo Veralli <[email protected]>

* Verify account inclusion locally (#290)

* Remove modules that won't be used in the Aligned version

* Fix Markdown lint issues

* Forward GraphQL port in CI

* Remove domain name usage

* Remove tunneling and comment Merkle path job

* Uncomment Merkle path job and comment nextest step

* Try port forwarding to access GraphQL

* Revert "Try port forwarding to access GraphQL"

This reverts commit 79084b9.

* Fetch state hash and proof and parse them

* Simplify input parsing

* Revert "Simplify input parsing"

This reverts commit 91a1621.

* Separate queries for hash and proof

* Integrate with Aligned

* Add test

* Remove unwraps

* Add usage section

* Add initial SP1 project for account inclusion

* Simplify and add make cmd

* Match SP1 version with Aligned one

* Query and parse Merkle root

* Fix parser lockfile

* WIP Merkle path verification

* Query merkle root

* Verify merkle

* Moved query merkle root fn to test module

* Move merkle_path.rs to lib.rs

* Remove SP1 project, move tests crate out

* Small fixes

* Added query merkle root

* WIP get tip state hash

* Finished account inclusion

* Update contract names

* Update README.md

* Apply suggestions from code review

Co-authored-by: Gabriel Bosio <[email protected]>

* Add newline to .gitignore

---------

Co-authored-by: Estéfano Bargas <[email protected]>

* Refactor mina service to use `graphql_client` (#306)

* Remove modules that won't be used in the Aligned version

* Fix Markdown lint issues

* Forward GraphQL port in CI

* Remove domain name usage

* Remove tunneling and comment Merkle path job

* Uncomment Merkle path job and comment nextest step

* Try port forwarding to access GraphQL

* Revert "Try port forwarding to access GraphQL"

This reverts commit 79084b9.

* Fetch state hash and proof and parse them

* Simplify input parsing

* Revert "Simplify input parsing"

This reverts commit 91a1621.

* Separate queries for hash and proof

* Integrate with Aligned

* Add test

* Remove unwraps

* Add usage section

* Add initial SP1 project for account inclusion

* Simplify and add make cmd

* Match SP1 version with Aligned one

* Query and parse Merkle root

* Fix parser lockfile

* WIP

* WIP Merkle path verification

* Query merkle root

* Verify merkle

* Moved query merkle root fn to test module

* Move merkle_path.rs to lib.rs

* Remove SP1 project, move tests crate out

* Small fixes

* Added query merkle root

* WIP get tip state hash

* Finished account inclusion

* Update contract names

* WIP use graphql_client

* Fix and add debug comments

* Remove conflict

---------

Co-authored-by: gabrielbosio <[email protected]>

* Remove state_utility directory (#304)

* Add account inclusion job (#305)

Co-authored-by: Estéfano Bargas <[email protected]>

* Use tip state from bridge contract (#307)

* Remove modules that won't be used in the Aligned version

* Fix Markdown lint issues

* Forward GraphQL port in CI

* Remove domain name usage

* Remove tunneling and comment Merkle path job

* Uncomment Merkle path job and comment nextest step

* Try port forwarding to access GraphQL

* Revert "Try port forwarding to access GraphQL"

This reverts commit 79084b9.

* Fetch state hash and proof and parse them

* Simplify input parsing

* Revert "Simplify input parsing"

This reverts commit 91a1621.

* Separate queries for hash and proof

* Integrate with Aligned

* Add test

* Remove unwraps

* Add usage section

* Add initial SP1 project for account inclusion

* Simplify and add make cmd

* Match SP1 version with Aligned one

* Query and parse Merkle root

* Fix parser lockfile

* WIP

* WIP Merkle path verification

* Query merkle root

* Verify merkle

* Moved query merkle root fn to test module

* Move merkle_path.rs to lib.rs

* Remove SP1 project, move tests crate out

* Small fixes

* Added query merkle root

* WIP get tip state hash

* Finished account inclusion

* Update contract names

* WIP use graphql_client

* Fix and add debug comments

* Use tip state from bridge contract

* Fix bad candidate hash

* Fix test and remove unused functions

* Add tip hash check in contract

* Serialize hashes first in pub inputs

* Add option to save proof files

* Use root state as initial tip for bridge (#308)

* Add root state hash argument to contract and deploy it using ethers

* Add contract_deployer crate

* Added root query

* Deploy contract with root

* Deploy contract with alloy

* Fix aligned contract address

* Add abi gen to deploy contract make rule

* Fix clippy

* Add error message to test

* Remove test (for now we cant execute it until we have an integration test)

* Fix account inclusion test

* Fix account inclusion test

* Update .gitignore

* Ignore test

---------

Co-authored-by: gabrielbosio <[email protected]>

* Update Aligned SDK (#314)

* Update README.md (#313)

* Update README.md

* readme update

* Update readme file

* Update readme file Transition frontier

* Small fixes

* Update README.md

* Format

---------

Co-authored-by: Eduardo Veralli <[email protected]>
Co-authored-by: gabrielbosio <[email protected]>

* Remove root state hash, fix pub input hash variable (#320)

* Aligned Layer with Holesky (#303)

* Add Holesky vars

* Update Mina contract

* Make it work for Holesky

* Fix clippy issues

* Log verification time

* Add Holesky constants and update dependencies

* Update Holesky contract

* Add newline in gitignore

* Move proof generator addr to Aligned group

* Revert Aligned SM address in Forge script

This script will be removed in another PR because it was replaced
with the contract_deployer.

* Integrate private key and keystore with contract deployment

* Point aligned branch back to mina

* Update Mina Holesky contract

* Remove account inclusion crate's GraphQL query, improve mina_polling_service's one (#317)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Delete account_inclusion directory

* Update ci.yaml

* Delete nonce file on submit error (#325)

* Delete nonce file on submit error

* Update Holesky contract

* Account verifier (#322)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Removed account_inclusion crate

* Take into account mina account proofs

* Add CLI commands

* Implement submission code for account proof

* Add ledger hash to state verifier

* Add accountIdHash and account verification feature for smart contract

* Add eth call for update account

* Fix clippy

* Update makefile rules

* Update specification

* Added doc to smart contract

* Fix clippy

* Update README.md

* Update Makefile

* Fix aligned sdk git dependency

* Update cargo.lock

* Point Aligned back to Mina (#329)

* Relative finalization (#327)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Removed account_inclusion crate

* Take into account mina account proofs

* Add CLI commands

* Implement submission code for account proof

* Add ledger hash to state verifier

* Add accountIdHash and account verification feature for smart contract

* Add eth call for update account

* Fix clippy

* Update makefile rules

* Update specification

* Added doc to smart contract

* Fix clippy

* Update README.md

* Query candidate chain, use bincode

* Update Makefile

* Fix aligned sdk git dependency

* Update cargo.lock

* Define new state proof, serialize with bincode

* Change proof field types

* Refactor proof definition

* Add entire states to Mina state proof

* Change version of clap to work with aligned

* Fix tip state

* Change core crate name

* Make serialization mod public

* Add contract support for relative finalization

* Fixed smart contract update function

* Check state hashes

* Fix hash store

* Fix clippy

* Remove unnecessary match case

* Fix aligned-sdk dependency

* Remove account hashes from contract storage (#331)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Removed account_inclusion crate

* Take into account mina account proofs

* Add CLI commands

* Implement submission code for account proof

* Add ledger hash to state verifier

* Add accountIdHash and account verification feature for smart contract

* Add eth call for update account

* Fix clippy

* Update makefile rules

* Update specification

* Added doc to smart contract

* Fix clippy

* Update README.md

* Query candidate chain, use bincode

* Update Makefile

* Fix aligned sdk git dependency

* Update cargo.lock

* Define new state proof, serialize with bincode

* Change proof field types

* Refactor proof definition

* Add entire states to Mina state proof

* Change version of clap to work with aligned

* Fix tip state

* Change core crate name

* Make serialization mod public

* Add contract support for relative finalization

* Fixed smart contract update function

* Check state hashes

* Fix hash store

* Fix clippy

* Remove account hash from contract storage

* Fix clippy

* Use new GraphQL API for account inclusion (#332)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Removed account_inclusion crate

* Take into account mina account proofs

* Add CLI commands

* Implement submission code for account proof

* Add ledger hash to state verifier

* Add accountIdHash and account verification feature for smart contract

* Add eth call for update account

* Fix clippy

* Update makefile rules

* Update specification

* Added doc to smart contract

* Fix clippy

* Update README.md

* Query candidate chain, use bincode

* Update Makefile

* Fix aligned sdk git dependency

* Update cargo.lock

* Define new state proof, serialize with bincode

* Change proof field types

* Refactor proof definition

* Add entire states to Mina state proof

* Change version of clap to work with aligned

* Fix tip state

* Change core crate name

* Make serialization mod public

* Add contract support for relative finalization

* Fixed smart contract update function

* Check state hashes

* Fix hash store

* Fix clippy

* Remove account hash from contract storage

* Fix clippy

* New account proof WIP

* Finish new account proof

* Remove unused dependencies

* Add new schema

* Intergrate new account query schema

* Change mina proof to store account

* Replace ledger hash with Fp

* Update comment

* Fix variable name

* Change staged ledger hash to snarked

* Fix clippy

* Sync with Aligned 0.5 (#333)

* Update Aligned

* Make aligned SDK point to correct branch

* Fix wallet chain ID

* Update dependencies

* Make aligned SDK point to mina branch

* Sync with Aligned 0.5.2 (#335)

* Add Solidity-friendly account structure as public input for the account inclusion proof (#334)

* Added merkle query

* Rename query_and_serialize

* WIP merkle query

* Fix test

* WIP Account query

* Finished account query

* Fixed TokenId deserialization

* Remove account query

* Fix clippy

* Removed account_inclusion crate

* Take into account mina account proofs

* Add CLI commands

* Implement submission code for account proof

* Add ledger hash to state verifier

* Add accountIdHash and account verification feature for smart contract

* Add eth call for update account

* Fix clippy

* Update makefile rules

* Update specification

* Added doc to smart contract

* Fix clippy

* Update README.md

* Query candidate chain, use bincode

* Update Makefile

* Fix aligned sdk git dependency

* Update cargo.lock

* Define new state proof, serialize with bincode

* Change proof field types

* Refactor proof definition

* Add entire states to Mina state proof

* Change version of clap to work with aligned

* Fix tip state

* Change core crate name

* Make serialization mod public

* Add contract support for relative finalization

* Fixed smart contract update function

* Check state hashes

* Fix hash store

* Fix clippy

* Remove account hash from contract storage

* Fix clippy

* New account proof WIP

* Finish new account proof

* Remove unused dependencies

* Add new schema

* Intergrate new account query schema

* Change mina proof to store account

* Replace ledger hash with Fp

* Update comment

* Fix variable name

* Change staged ledger hash to snarked

* Fix clippy

* MinaAccountValidation lib

* Gen abi of new lib

* Add Mina account solidity struct

* Update contract

* Refactor serialization, add account conversion

* Doc

* Change mina account proof to use encoded account

* Readd mina account in proof

* Handle new proof in smart contract

* Fix contract

* Update Aligned to 0.6.0 (#336)

* Sync with Aligned 0.5.2

* Start updating Aligned to 0.6.0

* Fix Aligned version update

* Fix Aligned SDK dependency (#339)

Currently points to the `update_to_06` branch which no longer exists

* Point Aligned SDK to mina branch (#340)

* Point SDK to mina branch

* Point Aligned submodule to mina branch

* Update Aligned to 0.7.0 (#341)

* [WIP] Update Aligned to 0.7.0

We must wait until Aligned uploads the release for 0.7.0.

Once it's uploaded we need to add a batcher payment service arg
to the `updateChain` call in the Aligned polling service.

* Update Aligned to 0.7.0

* Update Aligned branch

* Update Aligned and Bridge contracts

* Update Aligned Foundry submodule

* Sudoku example app (#338)

* Init bun project

* Refactor

* chore: forge init

* forge install: forge-std

v1.9.2

* Rename Counter to Sudoku

* forge install: mina_bridge

132e4ea

* Contract mockup

* Add remappings, fix version

* Remove unused files, add contract constructor

* Remove mina_bridge submodule

* Rename zkapp

* Rename app to example

* forge install: forge-std

v1.9.2

* Created Rust app project

* zkApp script

* Fiz zkapp script

* Core refactor

* Add sdk

* Complete app

* Change zkapp address to constant

* Updated rust app

* Rename mina_contract to mina_zkapp

* Completed sudoku eth contract

* [WIP] Update Aligned to 0.7.0

We must wait until Aligned uploads the release for 0.7.0.

Once it's uploaded we need to add a batcher payment service arg
to the `updateChain` call in the Aligned polling service.

* Update Aligned to 0.7.0

* Update Aligned branch

* Finish sudoku contract deployer

* Rename sudoku contract

* Fix contract deployer

* Update Aligned and Bridge contracts

* Update Aligned Foundry submodule

* Add call to SudokuValidity, small fixes to contract

* Update makefile

* Add better log and getter function for timestamp

* Fix contract validateAccount call

* Add retrying logic for mina zkapp

* Fix Makefile

* Zkapp fixes

* Fix ledger hash search

* Add log

* Fix boolean comparison

* Add debug to query_candidate_chain()

* Update app

* Update to aligned 0.7

* Update constants

* Change zkapp config

* Fix clippy

* Add example diagram

---------

Co-authored-by: gabrielbosio <[email protected]>

* Rename MinaBridge to MinaStateSettlement (#345)

* Check Proving system ID (#342)

* [WIP] Update Aligned to 0.7.0

We must wait until Aligned uploads the release for 0.7.0.

Once it's uploaded we need to add a batcher payment service arg
to the `updateChain` call in the Aligned polling service.

* Update Aligned to 0.7.0

* Update Aligned branch

* Update Aligned and Bridge contracts

* Update Aligned Foundry submodule

* Add Proving system ID commitment check

* Update core lockfile

* Fix ABIs

* Remove unused Solidity error

* Update ABIs

* Parameterize Holesky contract addresses (#343)

* [WIP] Update Aligned to 0.7.0

We must wait until Aligned uploads the release for 0.7.0.

Once it's uploaded we need to add a batcher payment service arg
to the `updateChain` call in the Aligned polling service.

* Update Aligned to 0.7.0

* Update Aligned branch

* Update Aligned and Bridge contracts

* Update Aligned Foundry submodule

* Remove bridge addr constants and parameterize them

* Update README and code doc (#347)

* Fix state proof doc

* Fix account proof doc

* Update example

* Update README

* Update README'

* Add new specification

* Update table of contents

* Fix specification paragraph

* Add sdk docs

* Update use case readme

* Small changes

* Fix identation

* Fix identation

* Fix identation

* Modify top level desc

* Update config.json

* Update zkapp config

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

---------

Co-authored-by: Gabriel Bosio <[email protected]>

* Fix README links (#349)

* Fix Tock constraint domain size and add Book reference (#350)

* Fix (#353)

* Select Mina state proof source (#351)

* [WIP] Start adding devnet flag

* Add devnet flag

* Point SDK to Mina branch

* Lock SDK branch

* Fix settlement contract

* Parameterize state and account contract addresses

* Update example address and unwrap bridge addresses

* Update Aligned

* Reuse BATCHER_ETH_ADDR

* Point SDK to VK branch

* Replace aligned SM env var name with used in SDK

* Fix clippy

* Remove zkapp state logging

* Parameterize Sudoku Holesky address (#355)

* [WIP] Start adding devnet flag

* Add devnet flag

* Point SDK to Mina branch

* Lock SDK branch

* Fix settlement contract

* Parameterize state and account contract addresses

* Update example address and unwrap bridge addresses

* Update Aligned

* Reuse BATCHER_ETH_ADDR

* Point SDK to VK branch

* Replace aligned SM env var name with used in SDK

* Fix clippy

* Remove zkapp state logging

* Parameterize Sudoku Holesky address

* Usage and Setup sections (#348)

* Add details on usage section

* Start adding Ethereum testnet section

* Complete setup section

* Fix Mainnet image link

* Fix Aligned fork branch

* Add staking step in Testnet setup

* Complete Aligned Testnet setup

* Update README.md

* Revert "Update README.md"

This reverts commit 2f68a5d.

* Update submit state command

* Fix Testnet setup ordered list

* Update batcher deployment result paragraph

---------

Co-authored-by: Estéfano Bargas <[email protected]>

* Usage and setup changes (#354)

* Add details on usage section

* Start adding Ethereum testnet section

* Complete setup section

* Add step to deploy contracts

* Fix Mainnet image link

* Fix Aligned fork branch

* Add staking step in Testnet setup

* Complete Aligned Testnet setup

* Update README.md

* Revert "Update README.md"

This reverts commit 2f68a5d.

* Update README.md

* Update submit state command

* Fix Testnet setup ordered list

* Update batcher deployment result paragraph

---------

Co-authored-by: gabrielbosio <[email protected]>

* Remove duplicated section on README (#358)

* Update README (#357)

* Add details on usage section

* Start adding Ethereum testnet section

* Complete setup section

* Fix Mainnet image link

* Fix Aligned fork branch

* Add staking step in Testnet setup

* Complete Aligned Testnet setup

* Update README.md

* Revert "Update README.md"

This reverts commit 2f68a5d.

* Update submit state command

* Fix Testnet setup ordered list

* Update batcher deployment result paragraph

* Add initial disclaimer

* Qualify Bridge contracts

* Move table of contents up

* Fix headings identation

* Fix links in table of contents

* Remove div tag

* Update repo description

* Update README.md

Co-authored-by: Estéfano Bargas <[email protected]>

---------

Co-authored-by: Estéfano Bargas <[email protected]>

---------

Co-authored-by: Gabriel Bosio <[email protected]>
Co-authored-by: Eduardo Veralli <[email protected]>
Co-authored-by: gabrielbosio <[email protected]>
  • Loading branch information
4 people authored Oct 3, 2024
1 parent 66d3579 commit b3723b0
Show file tree
Hide file tree
Showing 299 changed files with 40,209 additions and 57,979 deletions.
19 changes: 19 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ETH_CHAIN=<devnet/holesky>
MINA_RPC_URL=<url>
STATE_SETTLEMENT_ETH_ADDR=<address>
ACCOUNT_VALIDATION_ETH_ADDR=<address>
SAVE_PROOF=true/false # also false if other than "true" or variable were to be not defined

## 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_SERVICE_MANAGER_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
90 changes: 25 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,29 @@
.PHONY: run check_account sepolia.wrap_and_deploy sepolia.verify
.PHONY: submit_mainnet_state submit_devnet_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_mainnet_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_devnet_state:
@cargo run --manifest-path core/Cargo.toml --release -- submit-state --devnet

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"
submit_account:
@cargo run --manifest-path core/Cargo.toml --release -- submit-account ${PUBLIC_KEY} ${STATE_HASH}

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!"
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

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

0 comments on commit b3723b0

Please sign in to comment.