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

Integration test #299

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 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
2eb6198
Add integration test and CI job
gabrielbosio Jul 26, 2024
9faecc9
Add steps section in integration job
gabrielbosio Jul 26, 2024
78c3bca
Fix steps section
gabrielbosio Jul 26, 2024
b5d4499
Fix tabs and add checkout
gabrielbosio Jul 26, 2024
c095e40
Move runs-on outside steps
gabrielbosio Jul 26, 2024
241f582
Replace 'with' with 'env'
gabrielbosio Jul 26, 2024
0615e16
Change SSH for HTTPS in repo cloning
gabrielbosio Jul 26, 2024
3741026
Add Foundry and Go installation steps
gabrielbosio Jul 26, 2024
085a380
Fix indentation in Go version
gabrielbosio Jul 26, 2024
9fcc9a4
Remove Go installation step
gabrielbosio Jul 26, 2024
3794b02
Add Go installation step with cache
gabrielbosio Jul 26, 2024
cfabb07
Disable caching in Go installation step
gabrielbosio Jul 26, 2024
1613e47
Set 'GOCACHE' to 'off'
gabrielbosio Jul 26, 2024
0470aa1
Fix 'GOCACHE' setting in workflow
gabrielbosio Jul 26, 2024
2ce920f
Enable caching in Go installation step
gabrielbosio Jul 26, 2024
079f7fe
Set GOCACHE to absolute path
gabrielbosio Jul 26, 2024
91c210a
Use bash instead of sh
gabrielbosio Jul 26, 2024
7c0c899
Fix bash if condition
gabrielbosio Jul 26, 2024
aa9cdb7
Set 'TARGET' env var in test step
gabrielbosio Jul 26, 2024
e4cea7a
Change how 'PATH' env var is set
gabrielbosio Jul 26, 2024
22de514
Add Cargo to Github path
gabrielbosio Jul 26, 2024
e530db7
Add Rust installation step
gabrielbosio Jul 26, 2024
0e20f02
Change what Rust action is used
gabrielbosio Jul 26, 2024
3ee5f61
Remove Rust installation and Cargo alias
gabrielbosio Jul 26, 2024
4fa11e9
Change alias with PATH env var
gabrielbosio Jul 26, 2024
5072d0c
Fix path setup
gabrielbosio Jul 26, 2024
dbf0571
Use PATH instead of GITHUB_PATH
gabrielbosio Jul 26, 2024
a05b02f
Use 'env.PATH' instead of 'PATH'
gabrielbosio Jul 26, 2024
a9a6772
Use 'env.GITHUB_PATH' instead of 'env.PATH'
gabrielbosio Jul 26, 2024
fb45a44
Use '' instead of 'env.GITHUB_PATH'
gabrielbosio Jul 26, 2024
c77f011
Use 'env.PATH'
gabrielbosio Jul 26, 2024
ec42cd3
Add cargo path to GITHUB_PATH
gabrielbosio Jul 26, 2024
1897d5b
Export PATH with Cargo
gabrielbosio Jul 26, 2024
eb5e56b
Add env setup line
gabrielbosio Jul 26, 2024
6c49f80
Write env file in core dir
gabrielbosio Jul 26, 2024
e30d979
Use core dir from workspace
gabrielbosio Jul 29, 2024
e8c9064
Fix env path
gabrielbosio Jul 29, 2024
4651a95
Add GOMODCACHE env var
gabrielbosio Jul 29, 2024
2124779
Harcode golang path in GOMODCACHE
gabrielbosio Jul 29, 2024
f03e48a
Change how GOMODCACHE env var is set
gabrielbosio Jul 29, 2024
3b2adc9
Remove Go cache
gabrielbosio Jul 29, 2024
1e4d69c
Enable caching in Go step
gabrielbosio Jul 29, 2024
8773b86
Use v3 for Go installation
gabrielbosio Jul 29, 2024
d6ab74e
Set cache to false
gabrielbosio Jul 29, 2024
eab855b
Add GOCACHE env var
gabrielbosio Jul 29, 2024
a04ae9d
Set GOMODCACHE env var
gabrielbosio Jul 29, 2024
9d7f853
Smart contract utility (#298)
xqft Jul 29, 2024
b4e71db
Merge branch 'aligned' into integration_test
gabrielbosio Jul 30, 2024
5e86152
Use Github runner
gabrielbosio Jul 30, 2024
a4cf627
Add workspace echo
gabrielbosio Jul 30, 2024
7f8363c
Update env path
gabrielbosio Jul 30, 2024
ec6d9f7
Remove ls cmd
gabrielbosio Jul 30, 2024
530fc33
Harcode workspace and set shell to bash
gabrielbosio Jul 30, 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
9 changes: 9 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ETH_CHAIN=<devnet/holesky>
MINA_RPC_URL=<url>

## These can be skipped if using devnet with Anvil.
# BATCHER_ADDR=<optional>
# BATCHER_ETH_ADDR=<optional>
# ETH_RPC_URL=<optional>
# KEYSTORE_PATH=<optional>
# PRIVATE_KEY=<optional>
164 changes: 56 additions & 108 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,113 +1,61 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches: ["*"]
push:
branches:
- main
pull_request:
branches: ["*"]

jobs:
public_input_gen:
name: Public input generation
uses: ./.github/workflows/rust_ci.yaml
core:
name: Test Core
uses: ./.github/workflows/rust_ci.yaml
with:
skip_run: true
directory: core

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
uses: ./.github/workflows/rust_ci.yaml
with:
skip_run: true
directory: state_utility/parser

integration:
name: Test integration
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
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
uses: ./.github/workflows/rust_ci.yaml
with:
skip_run: true
directory: state_utility/parser
go-version: '1.22'
cache: false

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run test
env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_BUCKET_NAME: mina-bridge
TARGET: linux
shell: bash
run: |
echo "ETH_CHAIN=devnet\nMINA_RPC_URL=http://5.9.57.89:3085/graphql\n" > /home/runner/work/mina_bridge/mina_bridge/.env
make setup_test

8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/proof.json
/proof.mpk
monitor/priv/native/libverifier.so
.DS_Store
mina_3_0_0_devnet
protocol_state.pub
protocol_state.proof
aligned_verification_data
integration_test
.env
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
[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
80 changes: 16 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,21 @@
.PHONY: run check_account sepolia.wrap_and_deploy sepolia.verify
.PHONY: run gen_contract_abi deploy_contract setup_test

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)'"
@cargo run --manifest-path core/Cargo.toml --release

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!"
setup_test:
@bash integration_test.sh

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_abi:
forge build --root contract/
cp contract/out/MinaBridge.sol/MinaBridge.json core/abi/MinaBridge.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_anvil:
forge script \
--non-interactive \
--root contract/ \
--broadcast \
--rpc-url http://localhost:8545 \
--private-key 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 \
contract/script/MinaBridge.s.sol:MinaBridgeDeployer
# deploy_contract_anvil uses Anvil wallet 9, same as Aligned for deploying its contracts.
Loading
Loading