Skip to content

Commit

Permalink
feat: add ECDSA component
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang committed Mar 18, 2024
0 parents commit 7dca326
Show file tree
Hide file tree
Showing 440 changed files with 64,322 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/axiom-core-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests

on:
push:
branches: ["main", "develop"]
pull_request:
paths:
- "axiom-eth/**" # axiom-eth changes affect axiom-core
- "axiom-core/**"

env:
CARGO_TERM_COLOR: always

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

steps:
- uses: actions/checkout@v3

- 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
41 changes: 41 additions & 0 deletions .github/workflows/axiom-eth-mock-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: axiom-eth mock prover tests

on:
push:
branches: ["main"]
pull_request:
paths:
- "axiom-eth/**"

env:
CARGO_TERM_COLOR: always

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

steps:
- uses: actions/checkout@v3

- name: Build
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
28 changes: 28 additions & 0 deletions .github/workflows/axiom-eth-prover-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop", "release*", "release/*", "*audit*"]
paths:
- "axiom-eth/**"

env:
CARGO_TERM_COLOR: always

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

steps:
- uses: actions/checkout@v3

- 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::
28 changes: 28 additions & 0 deletions .github/workflows/axiom-query-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
push:
branches: ["main", "develop"]
pull_request:
paths:
- "axiom-eth/**" # axiom-eth changes affect axiom-query
- "axiom-query/**"

env:
CARGO_TERM_COLOR: always

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

steps:
- uses: actions/checkout@v3

- name: Run axiom-query tests
working-directory: "axiom-query"
run: |
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"
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build workspace

on:
push:
branches: ["main"]
pull_request: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export AXIOM_SKIP_CONSTANT_GEN=1
cargo build --verbose
33 changes: 33 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lints

on:
push:
branches: ["main"]
pull_request: {}

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
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

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

*.png

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

*.pk
*.snark
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "axiom-codec/axiom-tools"]
path = axiom-codec/axiom-tools
url = [email protected]:axiom-crypto/axiom-tools.git
54 changes: 54 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[workspace]
members = ["axiom-eth", "axiom-core", "axiom-query", "axiom-codec", "axiom-components"]
resolver = "2"

[workspace.dependencies]
ethers-core = { version = "=2.0.14", features = ["optimism"] } # fix the version as it affects what fields are included in the `Block` struct
# generating circuit inputs from blockchain
ethers-providers = { version = "=2.0.14", features = ["optimism"] }

# halo2
# halo2-base = { version = "=0.4.1", default-features = false, features = ["test-utils"] }
halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib.git", branch = "develop", default-features = false, features = ["test-utils"] }
halo2-ecc = { git = "https://github.com/axiom-crypto/halo2-lib.git", branch = "develop", default-features = false }
# zkevm-hashes = { version = "=0.2.1", default-features = false }
zkevm-hashes = { git = "https://github.com/axiom-crypto/halo2-lib.git", branch = "develop", default-features = false }
# snark-verifier = { version = "=0.1.7", default-features = false }
snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier.git", branch = "develop", default-features = false }
# snark-verifier-sdk = { version = "=0.1.7", default-features = false }
snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier.git", branch = "develop", default-features = false }


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

# Local "release" mode, more optimized than dev but faster to compile than release
[profile.local]
inherits = "dev"
opt-level = 3
# Set this to 1 or 2 to get more useful backtraces
debug = 1
debug-assertions = true
panic = 'unwind'
# better recompile times
incremental = true
lto = "thin"
codegen-units = 16

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = "fat"
# `codegen-units = 1` can lead to WORSE performance - always bench to find best profile for your machine!
codegen-units = 1
panic = "abort"
incremental = false

# For performance profiling
[profile.flamegraph]
inherits = "release"
debug = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Axiom

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Axiom ZK Circuits

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.
38 changes: 38 additions & 0 deletions axiom-codec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "axiom-codec"
version = "0.3.0-alpha.1"
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.1", path = "../axiom-eth", default-features = false }
axiom-components = { path = "../axiom-components", default-features = false }

# ethereum
ethers-core = { workspace = true }

[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"]
1 change: 1 addition & 0 deletions axiom-codec/axiom-tools
Submodule axiom-tools added at 43891b
Loading

0 comments on commit 7dca326

Please sign in to comment.