Skip to content

Commit

Permalink
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
Browse files Browse the repository at this point in the history
…verify_in_root_circuit
  • Loading branch information
sai-deng committed Oct 1, 2024
2 parents baba9da + ac41fa4 commit f24d028
Show file tree
Hide file tree
Showing 25 changed files with 629 additions and 604 deletions.
12 changes: 12 additions & 0 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Rust"
description: |
Common steps for CI
See <https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action>
runs:
using: composite
steps:
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,33 +175,3 @@ jobs:

- name: Run the script
run: ./scripts/prove_stdio.sh artifacts/witness_b3_b6.json

lints:
name: Rustdoc, Formatting and Clippy
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ ! contains(toJSON(github.event.commits.*.message), '[skip-ci]') }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Run cargo fmt
run: cargo fmt --all --check

- name: Run cargo clippy
run: cargo clippy --all-targets -- -D warnings -A incomplete-features

- name: Run cargo clippy (with `cdk_erigon` flag)
run: cargo clippy --package zero --all-targets --no-default-features --features cdk_erigon -- -D warnings -A incomplete-features

- name: Rustdoc
run: cargo doc --all
57 changes: 57 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: lint

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

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
BINSTALL_NO_CONFIRM: true
RUSTDOCFLAGS: "-D warnings"

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust
- run: cargo clippy --all-targets -- -D warnings
- run: cargo clippy --all-targets --no-default-features --features cdk_erigon -- -D warnings
udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust
- uses: taiki-e/install-action@v2
with:
tool: cargo-udeps
- run: cargo udeps --quiet
- run: cargo udeps --quiet --tests --benches --examples
rustdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust
- run: cargo doc --all --no-deps
cargo-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust
- run: cargo fmt --check
taplo-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust
- uses: taiki-e/install-action@v2
with:
tool: taplo-cli
- run: taplo fmt --check
51 changes: 1 addition & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,29 @@ paste = "1.0.15"
pest = "2.7.10"
pest_derive = "2.7.10"
pretty_env_logger = "0.5.0"
proc-macro2 = "1.0"
quote = "1.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
ripemd = "0.1.3"
rlp = "0.5.2"
rlp-derive = "0.1.0"
ruint = "1.12.3"
serde = "1.0.203"
serde-big-array = "0.5.1"
serde_json = "1.0.118"
serde_path_to_error = "0.1.16"
serde-big-array = "0.5.1"
sha2 = "0.10.8"
static_assertions = "1.1.0"
syn = "2.0"
thiserror = "1.0.61"
tiny-keccak = "2.0.2"
tokio = { version = "1.38.0", features = ["full"] }
toml = "0.8.14"
tower = "0.4"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
trybuild = "1.0"
u4 = "0.1.0"
uint = "0.9.5"
url = "2.5.2"
Expand All @@ -115,11 +119,5 @@ plonky2_maybe_rayon = "0.2.0"
plonky2_util = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }
starky = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }

# proc macro related dependencies
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0"
trybuild = "1.0"

[workspace.lints.clippy]
too_long_first_doc_paragraph = "allow"
8 changes: 4 additions & 4 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
ethereum-types = { workspace = true }
keccak-hash = { workspace = true }
ethereum-types.workspace = true

[dev-dependencies]
bytes = { workspace = true }
rlp = { workspace = true }
bytes.workspace = true
keccak-hash.workspace = true
rlp.workspace = true
4 changes: 2 additions & 2 deletions compat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
alloy = { workspace = true }
__compat_primitive_types = { workspace = true }
__compat_primitive_types.workspace = true
alloy.workspace = true
68 changes: 33 additions & 35 deletions evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,45 @@ homepage.workspace = true
keywords.workspace = true

[dependencies]
anyhow = { workspace = true }
bytes = { workspace = true }
env_logger = { workspace = true }
ethereum-types = { workspace = true }
anyhow.workspace = true
bytes.workspace = true
env_logger.workspace = true
ethereum-types.workspace = true
hashbrown.workspace = true
hex = { workspace = true, optional = true }
hex-literal = { workspace = true }
itertools = { workspace = true }
keccak-hash = { workspace = true }
log = { workspace = true }
plonky2_maybe_rayon = { workspace = true, features = ["parallel"] }
num = { workspace = true }
num-bigint = { workspace = true }
once_cell = { workspace = true }
pest = { workspace = true }
pest_derive = { workspace = true }
hex-literal.workspace = true
itertools.workspace = true
keccak-hash.workspace = true
log.workspace = true
mpt_trie.workspace = true
num.workspace = true
num-bigint.workspace = true
once_cell.workspace = true
pest.workspace = true
pest_derive.workspace = true
plonky2 = { workspace = true, features = ["parallel"] }
plonky2_util = { workspace = true }
starky = { workspace = true, features = ["parallel"] }
rand = { workspace = true }
rand_chacha = { workspace = true }
rlp = { workspace = true }
rlp-derive = { workspace = true }
plonky2_maybe_rayon = { workspace = true, features = ["parallel"] }
plonky2_util.workspace = true
rand.workspace = true
rand_chacha.workspace = true
rlp.workspace = true
rlp-derive.workspace = true
serde = { workspace = true, features = ["derive"] }
sha2 = { workspace = true }
static_assertions = { workspace = true }
hashbrown = { workspace = true }
thiserror = { workspace = true }
tiny-keccak = { workspace = true }
serde_json = { workspace = true }
serde-big-array = { workspace = true }

# Local dependencies
mpt_trie = { workspace = true }
serde-big-array.workspace = true
serde_json.workspace = true
sha2.workspace = true
smt_trie = { workspace = true, optional = true }
zk_evm_common = { workspace = true }
zk_evm_proc_macro = { workspace = true }
starky = { workspace = true, features = ["parallel"] }
static_assertions.workspace = true
thiserror.workspace = true
tiny-keccak.workspace = true
zk_evm_common.workspace = true
zk_evm_proc_macro.workspace = true

[dev-dependencies]
criterion = { workspace = true }
hex = { workspace = true }
ripemd = { workspace = true }
criterion.workspace = true
hex.workspace = true
ripemd.workspace = true

[features]
default = ["eth_mainnet"]
Expand Down
10 changes: 5 additions & 5 deletions evm_arithmetization/src/cpu/kernel/constants/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub mod cancun_constants {
pub mod global_exit_root {
use super::*;

/// Taken from https://github.com/0xPolygonHermez/cdk-erigon/blob/61f0b6912055c73f6879ea7e9b5bac22ea5fc85c/zk/utils/global_exit_root.go#L16.
/// Taken from <https://github.com/0xPolygonHermez/cdk-erigon/blob/61f0b6912055c73f6879ea7e9b5bac22ea5fc85c/zk/utils/global_exit_root.go#L16>.
pub const GLOBAL_EXIT_ROOT_MANAGER_L2: (&str, [u8; 20]) = (
"GLOBAL_EXIT_ROOT_MANAGER_L2",
GLOBAL_EXIT_ROOT_ADDRESS.to_fixed_bytes(),
Expand All @@ -486,7 +486,7 @@ pub mod global_exit_root {
"GLOBAL_EXIT_ROOT_MANAGER_L2_STATE_KEY",
GLOBAL_EXIT_ROOT_ADDRESS_HASHED.to_fixed_bytes(),
);
/// Taken from https://github.com/0xPolygonHermez/cdk-erigon/blob/dc3cbcc59a95769626056c7bc70aade501e7741d/core/state/intra_block_state_zkevm.go#L20.
/// Taken from <https://github.com/0xPolygonHermez/cdk-erigon/blob/dc3cbcc59a95769626056c7bc70aade501e7741d/core/state/intra_block_state_zkevm.go#L20>.
pub const ADDRESS_SCALABLE_L2: Address = H160(hex!("000000000000000000000000000000005ca1ab1e"));

pub const ADDRESS_SCALABLE_L2_ADDRESS_HASHED: H256 = H256(hex!(
Expand All @@ -497,16 +497,16 @@ pub mod global_exit_root {
"ADDRESS_SCALABLE_L2_STATE_KEY",
ADDRESS_SCALABLE_L2_ADDRESS_HASHED.to_fixed_bytes(),
);
/// Taken from https://github.com/0xPolygonHermez/cdk-erigon/blob/61f0b6912055c73f6879ea7e9b5bac22ea5fc85c/zk/utils/global_exit_root.go#L17.
/// Taken from <https://github.com/0xPolygonHermez/cdk-erigon/blob/61f0b6912055c73f6879ea7e9b5bac22ea5fc85c/zk/utils/global_exit_root.go#L17>.
pub const GLOBAL_EXIT_ROOT_STORAGE_POS: (&str, u64) = ("GLOBAL_EXIT_ROOT_STORAGE_POS", 0);

/// Taken from https://github.com/0xPolygonHermez/cdk-erigon/blob/dc3cbcc59a95769626056c7bc70aade501e7741d/core/state/intra_block_state_zkevm.go#L16.
/// Taken from <https://github.com/0xPolygonHermez/cdk-erigon/blob/dc3cbcc59a95769626056c7bc70aade501e7741d/core/state/intra_block_state_zkevm.go#L16>.
pub const LAST_BLOCK_STORAGE_POS: (&str, u64) = ("LAST_BLOCK_STORAGE_POS", 0);
pub const STATE_ROOT_STORAGE_POS: (&str, u64) = ("STATE_ROOT_STORAGE_POS", 1);
pub const TIMESTAMP_STORAGE_POS: (&str, u64) = ("TIMESTAMP_STORAGE_POS", 2);
pub const BLOCK_INFO_ROOT_STORAGE_POS: (&str, u64) = ("BLOCK_INFO_ROOT_STORAGE_POS", 3);

/// Taken from https://zkevm.polygonscan.com/address/0xa40D5f56745a118D0906a34E69aeC8C0Db1cB8fA#code.
/// Taken from <https://zkevm.polygonscan.com/address/0xa40D5f56745a118D0906a34E69aeC8C0Db1cB8fA#code>.
pub const GLOBAL_EXIT_ROOT_CONTRACT_CODE: [u8; 2112] = hex!("60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033");
pub const GLOBAL_EXIT_ROOT_CONTRACT_CODE_HASH: [u8; 32] =
hex!("6bec2bf64f7e824109f6ed55f77dd7665801d6195e461666ad6a5342a9f6daf5");
Expand Down
Loading

0 comments on commit f24d028

Please sign in to comment.