Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:0xPolygonZero/zk_evm into arpit/507
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Sep 26, 2024
2 parents 285b164 + fc28337 commit b8ee941
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 245 deletions.
18 changes: 6 additions & 12 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 @@ -80,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 @@ -105,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 @@ -132,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 @@ -190,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
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
11 changes: 6 additions & 5 deletions evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! the future execution and generate nondeterministically the corresponding
//! jumpdest table, before the actual CPU carries on with contract execution.

use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::collections::{BTreeSet, HashMap};

use anyhow::anyhow;
use ethereum_types::{BigEndianHash, U256};
Expand All @@ -19,6 +19,7 @@ use crate::cpu::columns::CpuColumnsView;
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
use crate::generation::debug_inputs;
use crate::generation::linked_list::LinkedListsPtrs;
use crate::generation::mpt::{load_linked_lists_and_txn_and_receipt_mpts, TrieRootPtrs};
use crate::generation::rlp::all_rlp_prover_inputs_reversed;
use crate::generation::state::{
Expand Down Expand Up @@ -115,8 +116,8 @@ pub(crate) struct ExtraSegmentData {
pub(crate) ger_prover_inputs: Vec<U256>,
pub(crate) trie_root_ptrs: TrieRootPtrs,
pub(crate) jumpdest_table: Option<HashMap<usize, Vec<usize>>>,
pub(crate) accounts: BTreeMap<U256, usize>,
pub(crate) storage: BTreeMap<(U256, U256), usize>,
pub(crate) access_lists_ptrs: LinkedListsPtrs,
pub(crate) state_ptrs: LinkedListsPtrs,
pub(crate) next_txn_index: usize,
}

Expand Down Expand Up @@ -235,8 +236,8 @@ impl<F: RichField> Interpreter<F> {
// Initialize the MPT's pointers.
let (trie_root_ptrs, state_leaves, storage_leaves, trie_data) =
load_linked_lists_and_txn_and_receipt_mpts(
&mut self.generation_state.accounts_pointers,
&mut self.generation_state.storage_pointers,
&mut self.generation_state.state_ptrs.accounts,
&mut self.generation_state.state_ptrs.storage,
&inputs.tries,
)
.expect("Invalid MPT data for preinitialization");
Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/src/cpu/kernel/tests/account_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub(crate) fn initialize_mpts<F: RichField>(
// Load all MPTs.
let (mut trie_root_ptrs, state_leaves, storage_leaves, trie_data) =
load_linked_lists_and_txn_and_receipt_mpts(
&mut interpreter.generation_state.accounts_pointers,
&mut interpreter.generation_state.storage_pointers,
&mut interpreter.generation_state.state_ptrs.accounts,
&mut interpreter.generation_state.state_ptrs.storage,
trie_inputs,
)
.expect("Invalid MPT data for preinitialization");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rand::{thread_rng, Rng};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
use crate::cpu::kernel::interpreter::Interpreter;
use crate::generation::linked_list::LinkedList;
use crate::generation::linked_list::testing::LinkedList;
use crate::generation::linked_list::ACCOUNTS_LINKED_LIST_NODE_SIZE;
use crate::generation::linked_list::STORAGE_LINKED_LIST_NODE_SIZE;
use crate::memory::segments::Segment;
Expand Down
Loading

0 comments on commit b8ee941

Please sign in to comment.