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

Axiom V2 Release #24

Merged
merged 4 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 48 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,64 @@ name: Tests

on:
push:
branches: ["main"]
branches: ["main", "develop"]
pull_request:
branches: ["main"]
branches: ["main", "develop", "release*", "release/*", "rc*", "*-audit*", "v0.13", "v0.12"]

env:
CARGO_TERM_COLOR: always
INFURA_ID: ${{ vars.INFURA_ID }}
JSON_RPC_URL: ${{ vars.JSON_RPC_URL }}

jobs:
build:
runs-on: ubuntu-latest-m
runs-on: ubuntu-latest-64core-256ram

steps:
- uses: actions/checkout@v3

- name: Build
run: cargo build --verbose
run: |
export AXIOM_SKIP_CONSTANT_GEN=1
cargo build --verbose

- name: Run axiom-eth tests MockProver
working-directory: "axiom-eth"
run: |
export ALCHEMY_KEY=${{ secrets.ALCHEMY_KEY}}
export JSON_RPC_URL=${{ secrets.JSON_RPC_URL }}
cargo t test_keccak
cargo t rlc::tests
cargo t rlp::tests
cargo t keccak::tests
cargo t block_header::tests
cargo t mpt
cargo t storage::tests::test_mock
cargo t transaction::tests
BLOCK_NUM=17000000 cargo test receipt::tests
cargo t solidity::tests::mapping::test_mock
cargo t solidity::tests::nested_mappings::test_mock
cargo t solidity::tests::mapping_storage::test_mock

- name: Run axiom-eth tests real prover
working-directory: "axiom-eth"
run: |
export ALCHEMY_KEY=${{ secrets.ALCHEMY_KEY }}
export JSON_RPC_URL=${{ secrets.JSON_RPC_URL }}
cargo t --release -- test_one_mainnet_header_prover
cargo t --release -- bench_mpt_inclusion_fixed --ignored
cargo t --release utils::component::

- name: Run axiom-core tests
working-directory: "axiom-core"
run: |
export ALCHEMY_KEY=${{ secrets.ALCHEMY_KEY }}
export JSON_RPC_URL=${{ secrets.JSON_RPC_URL }}
cargo t

- name: Run axiom-query tests
working-directory: "axiom-query"
run: |
export INFURA_ID=${{ vars.INFURA_ID }}
export JSON_RPC_URL=${{ vars.JSON_RPC_URL }}
cd axiom-eth
cargo test -- test_mock_account_queries_empty
cargo test -- test_mock_account_queries_genesis
cargo test -- test_mock_account_queries_simple
cargo test -- test_genesis_block
cargo test -- test_mock_block_queries_random
cargo test -- test_mock_row_consistency_nouns
cargo test -- test_default_storage_query
cargo test -- test_mock_storage_queries_empty
cargo test -- test_mock_storage_queries_mapping
cargo test -- test_mock_storage_queries_slot0
cargo test -- test_mock_storage_queries_uni_v3
cargo test -- test_multi_goerli_header_mock
cargo test -- test_one_mainnet_header_before_london_mock
cargo test -- test_one_mainnet_header_mock
cargo test -- test_one_mainnet_header_withdrawals_mock
cargo test -- test_keccak
cargo test -- test_mock_mpt_inclusion_fixed
cargo test -- test_mpt_empty_root
cargo test -- test_mpt_noninclusion_branch_fixed
cargo test -- test_mpt_noninclusion_extension_fixed
cargo test -- test_mock_rlc
cargo test -- test_mock_rlp_array
cargo test -- test_mock_rlp_field
cargo test -- test_mock_rlp_literal
cargo test -- test_mock_rlp_long_field
cargo test -- test_mock_rlp_long_long_field
cargo test -- test_mock_rlp_short_field
cargo test -- test_mock_single_eip1186
export AXIOM_SKIP_CONSTANT_GEN=1
export ALCHEMY_KEY=${{ secrets.ALCHEMY_KEY }}
export JSON_RPC_URL=${{ secrets.JSON_RPC_URL }}
mkdir -p data/test
cargo t --no-default-features --features "halo2-axiom, jemallocator"
34 changes: 34 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lints

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
lint:
name: Lint
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: false
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Run fmt
run: |
export AXIOM_SKIP_CONSTANT_GEN=1
cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all -- -D warnings
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
=======
/target
# =======
target/
params/
!params/integration_test

*.png

/halo2_ecc/src/bn254/data/
/halo2_ecc/src/secp256k1/data/
**/.env

*.pk
*.snark
.DS_Store
14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[workspace]
members = [
"axiom-eth",
"any_circuit_derive"
]
members = ["axiom-eth", "axiom-core", "axiom-query", "axiom-codec"]
resolver = "2"

[profile.dev]
opt-level = 3
debug = 1 # change to 0 or 2 for more or less debug info
debug = 2 # change to 0 or 2 for more or less debug info
overflow-checks = true
incremental = true

Expand All @@ -16,7 +14,7 @@ inherits = "dev"
opt-level = 3
# Set this to 1 or 2 to get more useful backtraces
debug = 1
debug-assertions = true
debug-assertions = true
panic = 'unwind'
# better recompile times
incremental = true
Expand All @@ -27,9 +25,9 @@ codegen-units = 16
opt-level = 3
debug = false
debug-assertions = false
lto = "fat"
lto = "fat"
# `codegen-units = 1` can lead to WORSE performance - always bench to find best profile for your machine!
# codegen-units = 1
codegen-units = 1
panic = "abort"
incremental = false

Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# axiom-eth
# Axiom ZK Circuits

This repository builds on [halo2-lib](https://github.com/axiom-crypto/halo2-lib/releases/tag/v0.3.0) and [snark-verifier](https://github.com/axiom-crypto/snark-verifier/tree/v0.1.1) to create a library of zero-knowledge proof circuits that [Axiom](https://axiom.xyz) uses to read data from the Ethereum virtual machine (EVM).
This repository builds on [halo2-lib](https://github.com/axiom-crypto/halo2-lib/tree/main) and [snark-verifier](https://github.com/axiom-crypto/snark-verifier/) to create a library of zero-knowledge proof circuits that [Axiom](https://axiom.xyz) uses to read data from the Ethereum virtual machine (EVM).

This monorepo consists of multiple crates:

## `axiom-eth`

This is the main library of chips and frameworks for building ZK circuits that prove data from the Ethereum virtual machine (EVM). For more details, see the [README](./axiom-eth/README.md).

## `axiom-core`

This contains the ZK circuits that generate proofs for the `AxiomV2Core` smart contract. These circuits read the RLP encoded block headers for a chain of blocks and verify that the block headers form a chain. They output a Merkle Mountain Range of the block hashes of the chain. This crate also contains aggregation circuits to aggregate multiple circuits for the purpose of proving longer chains. For more details, see the [README](./axiom-core/README.md).

## `axiom-query`

This contains the ZK circuits that generate proofs for the `AxiomV2Query` smart contract. For more details, see the [README](./axiom-query/README.md).

### `axiom-codec`

This crate does not contain any ZK circuits, but it contains Rust types for Axiom queries and specifies how to encode/decode them to field elements for in-circuit use.
12 changes: 0 additions & 12 deletions any_circuit_derive/Cargo.toml

This file was deleted.

100 changes: 0 additions & 100 deletions any_circuit_derive/src/lib.rs

This file was deleted.

37 changes: 37 additions & 0 deletions axiom-codec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "axiom-codec"
version = "0.2.0"
authors = ["Intrinsic Technologies"]
license = "MIT"
edition = "2021"
repository = "https://github.com/axiom-crypto/axiom-eth"
readme = "README.md"
description = "This crate contains Rust types for Axiom queries and specifies how to encode/decode them to field elements for in-circuit use."
rust-version = "1.73.0"

[dependencies]
byteorder = { version = "1.4.3" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false }
serde_repr = "0.1"
base64 = { version = "0.21", optional = true }
serde_with = { version = "2.2", optional = true }
anyhow = "1.0"

# halo2, features turned on by axiom-eth
axiom-eth = { version = "=0.4.0", path = "../axiom-eth", default-features = false }

# ethereum
ethers-core = { version = "2.0.10" }

[dev-dependencies]
hex = "0.4.3"

[build-dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

[features]
default = ["halo2-axiom"]
# halo2-pse = ["axiom-eth/halo2-pse"]
halo2-axiom = ["axiom-eth/halo2-axiom"]
20 changes: 20 additions & 0 deletions axiom-codec/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pub const ENCODED_K_BYTES: usize = 1;
pub const ENCODED_VKEY_LENGTH_BYTES: usize = 1;
pub const FIELD_IDX_BITS: usize = 32;
pub const FIELD_IDX_BYTES: usize = 4;
pub const MAX_SOLIDITY_MAPPING_KEYS: usize = 4;
pub const MAX_SUBQUERY_INPUTS: usize = 13;
pub const MAX_SUBQUERY_OUTPUTS: usize = 2;
pub const NUM_SUBQUERY_TYPES: usize = 7;
pub const SOURCE_CHAIN_ID_BYTES: usize = 8;
pub const SUBQUERY_TYPE_BYTES: usize = 2;
pub const USER_ADVICE_COLS: usize = 4;
pub const USER_FIXED_COLS: usize = 1;
pub const USER_INSTANCE_COLS: usize = 1;
pub const USER_LOOKUP_ADVICE_COLS: usize = 1;
pub const USER_MAX_OUTPUTS: usize = 128;
pub const USER_MAX_SUBQUERIES: usize = 128;
pub const USER_PROOF_LEN_BYTES: usize = 4;
pub const USER_RESULT_BYTES: usize = 32;
pub const USER_RESULT_FIELD_ELEMENTS: usize = 2;
pub const USER_RESULT_LEN_BYTES: usize = 2;
Loading
Loading