Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into einar/prefetch_tra…
Browse files Browse the repository at this point in the history
…nsaction_jumps/pr
  • Loading branch information
einar-polygon committed Sep 26, 2024
2 parents 6bff4e4 + fc28337 commit 5e4162d
Show file tree
Hide file tree
Showing 88 changed files with 1,653 additions and 1,756 deletions.
5 changes: 0 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
- changed-files:
- any-glob-to-any-file: trace_decoder/**

# Add 'crate: proof_gen' label to any changes within 'proof_gen' folder.
'crate: proof_gen':
- changed-files:
- any-glob-to-any-file: proof_gen/**

# Add 'crate: zero_bin' label to any changes within 'zero' folder.
'crate: zero_bin':
- changed-files:
Expand Down
43 changes: 6 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -57,8 +56,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
Expand All @@ -71,31 +69,6 @@ jobs:
- name: test
run: cargo test --release --manifest-path trace_decoder/Cargo.toml -- --nocapture

test_proof_gen:
name: Test proof_gen
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ ! contains(toJSON(github.event.commits.*.message), '[skip-ci]') }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly

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

- name: Test in proof_gen subdirectory
run: cargo test --manifest-path proof_gen/Cargo.toml
env:
RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0
RUST_LOG: 1
CARGO_INCREMENTAL: 1
RUST_BACKTRACE: 1

test_evm_arithmetization:
name: Test evm_arithmetization
runs-on: ubuntu-latest
Expand All @@ -105,8 +78,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
Expand All @@ -130,8 +102,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
Expand All @@ -157,8 +128,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up rust cache
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -215,8 +185,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

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

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/jerigon-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
ref: "feat/kurtosis-network"
path: jerigon-test-network

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/jerigon-zero.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ jobs:
ref: 'feat/kurtosis-network'
path: jerigon-test-network

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down
17 changes: 3 additions & 14 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"evm_arithmetization",
"mpt_trie",
"proc_macro",
"proof_gen",
"smt_trie",
"trace_decoder",
"zero",
Expand Down Expand Up @@ -108,7 +107,6 @@ winnow = "0.6.13"
# local dependencies
evm_arithmetization = { path = "evm_arithmetization", version = "0.4.0", default-features = false }
mpt_trie = { path = "mpt_trie", version = "0.4.1" }
proof_gen = { path = "proof_gen", version = "0.4.0", default-features = false }
smt_trie = { path = "smt_trie", version = "0.1.1" }
trace_decoder = { path = "trace_decoder", version = "0.6.0", default-features = false }
zk_evm_common = { path = "common", version = "0.1.0" }
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ understood by the zkEVM prover.
* [evm_arithmetization](./evm_arithmetization/README.md): Defines all the STARK constraints and recursive circuits to generate succinct proofs of EVM execution.
It uses starky and plonky2 as proving backend: https://github.com/0xPolygonZero/plonky2.

* [proof_gen](./proof_gen/README.md): A convenience library for generating proofs from inputs already in Intermediate Representation (IR) format.

* [zero_bin](./zero_bin/README.md): A composition of [`paladin`](https://github.com/0xPolygonZero/paladin) and [`proof_gen`](./proof_gen/README.md) to generate
* [zero_bin](./zero_bin/README.md): A composition of [`paladin`](https://github.com/0xPolygonZero/paladin) and [`evm_arithmetization`](./evm_arithmetization/README.md) to generate
EVM block proofs.

## Dependency graph
Expand All @@ -44,18 +42,14 @@ flowchart LR
B[mpt_trie]
C[evm_arithmetization]
D[trace_decoder]
E[proof_gen]
B --> C
B ---> D
C ---> D
C --> E
D --> E
F{zero-bin}
C --> F
D --> F
E --> F
end
```

Expand Down
5 changes: 2 additions & 3 deletions evm_arithmetization/benches/fibonacci_25m_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ use evm_arithmetization::testing_utils::{
beacon_roots_account_nibbles, beacon_roots_contract_from_storage,
preinitialized_state_and_storage_tries, update_beacon_roots_account_storage,
};
use evm_arithmetization::Node;
use evm_arithmetization::{Node, EMPTY_CONSOLIDATED_BLOCKHASH};
use hex_literal::hex;
use keccak_hash::keccak;
use mpt_trie::nibbles::Nibbles;
use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie};
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::field::types::Field;
use plonky2::hash::hash_types::NUM_HASH_OUT_ELTS;

type F = GoldilocksField;

Expand Down Expand Up @@ -183,7 +182,7 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
checkpoint_state_trie_root: H256(hex!(
"fe07ff6d1ab215df17884b89112ccf2373597285a56c5902150313ad1a53ee57"
)),
checkpoint_consolidated_hash: [F::ZERO; NUM_HASH_OUT_ELTS],
checkpoint_consolidated_hash: EMPTY_CONSOLIDATED_BLOCKHASH.map(F::from_canonical_u64),
ger_data: None,
block_metadata,
txn_number_before: 0.into(),
Expand Down
3 changes: 2 additions & 1 deletion evm_arithmetization/src/arithmetic/arithmetic_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ impl<F: RichField, const D: usize> ArithmeticStark<F, D> {
}

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for ArithmeticStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = EvmStarkFrame<P, FE, NUM_ARITH_COLUMNS>
type EvaluationFrame<FE, P, const D2: usize>
= EvmStarkFrame<P, FE, NUM_ARITH_COLUMNS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down
3 changes: 2 additions & 1 deletion evm_arithmetization/src/byte_packing/byte_packing_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ impl<F: RichField + Extendable<D>, const D: usize> BytePackingStark<F, D> {
}

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for BytePackingStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = EvmStarkFrame<P, FE, NUM_COLUMNS>
type EvaluationFrame<FE, P, const D2: usize>
= EvmStarkFrame<P, FE, NUM_COLUMNS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down
3 changes: 2 additions & 1 deletion evm_arithmetization/src/cpu/cpu_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ pub(crate) struct CpuStark<F, const D: usize> {
}

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for CpuStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = EvmStarkFrame<P, FE, NUM_CPU_COLUMNS>
type EvaluationFrame<FE, P, const D2: usize>
= EvmStarkFrame<P, FE, NUM_CPU_COLUMNS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down
1 change: 0 additions & 1 deletion evm_arithmetization/src/cpu/kernel/asm/beacon_roots.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ global set_beacon_root:
%slot_to_storage_key
// stack: timestamp_slot_key, timestamp, retdest
PUSH @BEACON_ROOTS_CONTRACT_STATE_KEY
%addr_to_state_key
%parent_beacon_block_root
// stack: calldata, state_key, timestamp_slot_key, timestamp, retdest
PUSH @HISTORY_BUFFER_LENGTH
Expand Down
5 changes: 5 additions & 0 deletions evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ global init_access_lists:
// Store the segment scaled length
%increment
%mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_STORAGE_KEYS_LEN)
// Reset the access lists pointers in the `GenerationState`
PROVER_INPUT(access_lists::reset)
POP // reset pushed a 0

JUMP

%macro init_access_lists
Expand Down
11 changes: 5 additions & 6 deletions evm_arithmetization/src/cpu/kernel/asm/memory/metadata.asm
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,16 @@ zero_hash:
// stack: sum
%endmacro

// Adds the two top elements of the stack, and faults in case of overflow modulo 2^32.
%macro add_u32_or_fault
// Checks that the addition of the two top elements of the stack does not overflow modulo 2^32.
%macro check_u32_add
// stack: x, y
%add_or_fault
DUP1
// stack: sum, sum
// stack: sum
PUSH 0xffffffff // 2^32 - 1
LT
// stack: is_overflow, sum
// stack: is_overflow
%jumpi(fault_exception)
// stack: sum
// stack: (empty)
%endmacro

%macro call_depth
Expand Down
15 changes: 8 additions & 7 deletions evm_arithmetization/src/cpu/kernel/asm/memory/syscalls.asm
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,7 @@ calldataload_large_offset:
// stack: kexit_info, dest_offset, offset, size
%wcopy_charge_gas

// Ensure that `offset + size` won't overflow the reserved 32-bit limb
// of the `virtual` component of the source memory address.
DUP4 DUP4
// stack: offset, size, kexit_info, dest_offset, offset, size
%add_u32_or_fault

%stack (offset_plus_size, kexit_info, dest_offset, offset, size) ->
%stack (kexit_info, dest_offset, offset, size) ->
(dest_offset, size, kexit_info, dest_offset, offset, size)
%add_or_fault
// stack: expanded_num_bytes, kexit_info, dest_offset, offset, size, kexit_info
Expand All @@ -98,6 +92,13 @@ calldataload_large_offset:
// stack: offset, total_size, kexit_info, dest_offset, offset, size
GT %jumpi(wcopy_large_offset)

// stack: kexit_info, dest_offset, offset, size
// Ensure that `offset + size` won't overflow the reserved 32-bit limb
// of the `virtual` component of the source memory address.
DUP4 DUP4
// stack: offset, size, kexit_info, dest_offset, offset, size
%check_u32_add

// stack: kexit_info, dest_offset, offset, size
GET_CONTEXT
PUSH $segment
Expand Down
Loading

0 comments on commit 5e4162d

Please sign in to comment.