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

Pre 0.4.0 release #269

Closed
wants to merge 6 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.0] - TBD

### Changed
- Some cleanup ([#190](https://github.com/0xPolygonZero/zk_evm/pull/190))
- Silence jumpdest analysis logs ([#193](https://github.com/0xPolygonZero/zk_evm/pull/193))
- Charge call value gas prior to call ([#199](https://github.com/0xPolygonZero/zk_evm/pull/199))
- refactor: fix todos ([#162](https://github.com/0xPolygonZero/zk_evm/pull/162))
- Remove print call in trace_decoder ([#208](https://github.com/0xPolygonZero/zk_evm/pull/208))
- Update CODEOWNERS ([#224](https://github.com/0xPolygonZero/zk_evm/pull/224))
- Fix access lists pointers check ([#217](https://github.com/0xPolygonZero/zk_evm/pull/217))
- Add a few QoL useability functions to the interface ([#169](https://github.com/0xPolygonZero/zk_evm/pull/169))
- Amortize `sha2` compression loop ([#231](https://github.com/0xPolygonZero/zk_evm/pull/231))
- ci: add cargo audit job ([#236](https://github.com/0xPolygonZero/zk_evm/pull/236))
- fix: Revert interpreter stack display ([#238](https://github.com/0xPolygonZero/zk_evm/pull/238))
- Fix clippy `doc_lazy_continuation` ([#247](https://github.com/0xPolygonZero/zk_evm/pull/247))
- perf: Improve `blake2` precompile ([#239](https://github.com/0xPolygonZero/zk_evm/pull/239))
- fix: rustdoc and tests ([#255](https://github.com/0xPolygonZero/zk_evm/pull/255))
- Native trace processing support ([#246](https://github.com/0xPolygonZero/zk_evm/pull/246))
- Added `Clone` to a few error types in `mpt_trie` ([#259](https://github.com/0xPolygonZero/zk_evm/pull/259))
- cleanup: remove outdated segment ([#262](https://github.com/0xPolygonZero/zk_evm/pull/262))
- fix: add G2 subgroup check for `ECPAIRING` ([#268](https://github.com/0xPolygonZero/zk_evm/pull/268))
- add partial trie builder ([#258](https://github.com/0xPolygonZero/zk_evm/pull/258))

## [0.3.1] - 2024-04-22

Expand Down
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ serde_json = "1.0.96"
thiserror = "1.0.49"

# plonky2-related dependencies
plonky2 = "0.2.2"
plonky2_maybe_rayon = "0.2.0"
plonky2_util = "0.2.0"
starky = "0.4.0"

plonky2 = { git = "https://github.com/0xPolygonZero/plonky2", branch = "main" }
plonky2_maybe_rayon = { git = "https://github.com/0xPolygonZero/plonky2", branch = "main" }
plonky2_util = { git = "https://github.com/0xPolygonZero/plonky2", branch = "main" }
starky = { git = "https://github.com/0xPolygonZero/plonky2", branch = "main" }

[workspace.package]
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "evm_arithmetization"
description = "Implementation of STARKs for the Ethereum Virtual Machine"
version = "0.1.3"
version = "0.2.0"
authors = ["Daniel Lubarov <daniel@lubarov.com>", "William Borgeaud <williamborgeaud@gmail.com>"]
readme = "README.md"
categories = ["cryptography"]
Expand Down Expand Up @@ -41,7 +41,7 @@ tiny-keccak = "2.0.2"
serde_json = { workspace = true }

# Local dependencies
mpt_trie = { version = "0.2.1", path = "../mpt_trie" }
mpt_trie = { version = "0.3.0", path = "../mpt_trie" }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"
Expand Down
7 changes: 7 additions & 0 deletions evm_arithmetization/src/all_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ pub(crate) fn all_cross_table_lookups<F: Field>() -> Vec<CrossTableLookup<F>> {
]
}

/// Total number of CTLs returned by `all_cross_table_lookups()`.
pub(crate) const TOTAL_NUM_CTLS: usize = 7;

/// Position of the Memory CTL within the vector of CTLs returned by
/// `all_cross_table_lookups()`.
pub(crate) const MEMORY_CTL_INDEX: usize = TOTAL_NUM_CTLS - 1;

/// `CrossTableLookup` for `ArithmeticStark`, to connect it with the `Cpu`
/// module.
fn ctl_arithmetic<F: Field>() -> CrossTableLookup<F> {
Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/src/cpu/kernel/tests/bignum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::path::PathBuf;
use anyhow::Result;
use ethereum_types::U256;
use itertools::Itertools;
use num::integer::div_ceil;
use num::{BigUint, One, Zero};
use num_bigint::RandBigInt;
use plonky2::field::goldilocks_field::GoldilocksField as F;
use plonky2_util::ceil_div_usize;
use rand::Rng;

use crate::cpu::kernel::aggregator::KERNEL;
Expand Down Expand Up @@ -90,7 +90,7 @@ fn max_bignum(bit_size: usize) -> BigUint {
}

fn bignum_len(a: &BigUint) -> usize {
ceil_div_usize(a.bits() as usize, BIGNUM_LIMB_BITS)
(a.bits() as usize).div_ceil(BIGNUM_LIMB_BITS)
}

fn run_test(fn_label: &str, memory: Vec<U256>, stack: Vec<U256>) -> Result<(Vec<U256>, Vec<U256>)> {
Expand Down
3 changes: 1 addition & 2 deletions evm_arithmetization/src/cpu/kernel/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::fmt::Debug;

use ethereum_types::U256;
use plonky2_util::ceil_div_usize;

/// Enumerate the length `W` windows of `vec`, and run `maybe_replace` on each
/// one.
Expand All @@ -28,7 +27,7 @@ where
}

pub(crate) fn u256_to_trimmed_be_bytes(u256: &U256) -> Vec<u8> {
let num_bytes = ceil_div_usize(u256.bits(), 8);
let num_bytes = u256.bits().div_ceil(8);
// `byte` is little-endian, so we manually reverse it.
(0..num_bytes).rev().map(|i| u256.byte(i)).collect()
}
Expand Down
35 changes: 20 additions & 15 deletions evm_arithmetization/src/fixed_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ use starky::lookup::{get_grand_product_challenge_set_target, GrandProductChallen
use starky::proof::StarkProofWithMetadata;
use starky::stark::Stark;

use crate::all_stark::{all_cross_table_lookups, AllStark, Table, NUM_TABLES};
use crate::all_stark::{
all_cross_table_lookups, AllStark, Table, MEMORY_CTL_INDEX, NUM_TABLES, TOTAL_NUM_CTLS,
};
use crate::generation::GenerationInputs;
use crate::get_challenges::observe_public_values_target;
use crate::proof::{
Expand Down Expand Up @@ -587,26 +589,29 @@ where

// Extra sums to add to the looked last value.
// Only necessary for the Memory values.
let mut extra_looking_sums =
vec![vec![builder.zero(); stark_config.num_challenges]; NUM_TABLES];

// Memory
extra_looking_sums[*Table::Memory] = (0..stark_config.num_challenges)
.map(|c| {
get_memory_extra_looking_sum_circuit(
&mut builder,
&public_values,
ctl_challenges.challenges[c],
)
})
.collect_vec();
let mut extra_looking_sums = HashMap::from_iter(
(0..TOTAL_NUM_CTLS).map(|i| (i, vec![builder.zero(); stark_config.num_challenges])),
);

extra_looking_sums.insert(
MEMORY_CTL_INDEX,
(0..stark_config.num_challenges)
.map(|c| {
get_memory_extra_looking_sum_circuit(
&mut builder,
&public_values,
ctl_challenges.challenges[c],
)
})
.collect_vec(),
);

// Verify the CTL checks.
verify_cross_table_lookups_circuit::<F, D, NUM_TABLES>(
&mut builder,
all_cross_table_lookups(),
pis.map(|p| p.ctl_zs_first),
Some(&extra_looking_sums),
&extra_looking_sums,
stark_config,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use plonky2::iop::ext_target::ExtensionTarget;
use plonky2::timed;
use plonky2::util::timing::TimingTree;
use plonky2::util::transpose;
use plonky2_util::ceil_div_usize;
use starky::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
use starky::evaluation_frame::StarkEvaluationFrame;
use starky::lookup::{Column, Filter, Lookup};
Expand Down Expand Up @@ -137,7 +136,7 @@ pub(crate) fn ctl_looking_memory<F: Field>(i: usize) -> Vec<Column<F>> {
/// Returns the number of `KeccakSponge` tables looking into the `LogicStark`.
pub(crate) const fn num_logic_ctls() -> usize {
const U8S_PER_CTL: usize = 32;
ceil_div_usize(KECCAK_RATE_BYTES, U8S_PER_CTL)
KECCAK_RATE_BYTES.div_ceil(U8S_PER_CTL)
}

/// Creates the vector of `Columns` required to perform the `i`th logic CTL.
Expand Down
3 changes: 1 addition & 2 deletions evm_arithmetization/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use plonky2::hash::hash_types::RichField;
use plonky2::iop::ext_target::ExtensionTarget;
use plonky2::timed;
use plonky2::util::timing::TimingTree;
use plonky2_util::ceil_div_usize;
use starky::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
use starky::evaluation_frame::StarkEvaluationFrame;
use starky::lookup::{Column, Filter};
Expand All @@ -28,7 +27,7 @@ const VAL_BITS: usize = 256;
pub(crate) const PACKED_LIMB_BITS: usize = 32;
/// Number of field elements needed to store each input/output at the specified
/// packing.
const PACKED_LEN: usize = ceil_div_usize(VAL_BITS, PACKED_LIMB_BITS);
const PACKED_LEN: usize = VAL_BITS.div_ceil(PACKED_LIMB_BITS);

/// `LogicStark` columns.
pub(crate) mod columns {
Expand Down
18 changes: 11 additions & 7 deletions evm_arithmetization/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use ethereum_types::{BigEndianHash, U256};
use hashbrown::HashMap;
use itertools::Itertools;
use plonky2::field::extension::Extendable;
use plonky2::hash::hash_types::RichField;
Expand All @@ -10,7 +11,7 @@ use starky::lookup::GrandProductChallenge;
use starky::stark::Stark;
use starky::verifier::verify_stark_proof_with_challenges;

use crate::all_stark::{AllStark, Table, NUM_TABLES};
use crate::all_stark::{AllStark, Table, MEMORY_CTL_INDEX, NUM_TABLES, TOTAL_NUM_CTLS};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
use crate::memory::segments::Segment;
Expand Down Expand Up @@ -117,20 +118,23 @@ where

// Extra sums to add to the looked last value.
// Only necessary for the Memory values.
let mut extra_looking_sums = vec![vec![F::ZERO; config.num_challenges]; NUM_TABLES];
let mut extra_looking_sums =
HashMap::from_iter((0..TOTAL_NUM_CTLS).map(|i| (i, vec![F::ZERO; config.num_challenges])));

// Memory
extra_looking_sums[Table::Memory as usize] = (0..config.num_challenges)
.map(|i| get_memory_extra_looking_sum(&public_values, ctl_challenges.challenges[i]))
.collect_vec();
extra_looking_sums.insert(
MEMORY_CTL_INDEX,
(0..config.num_challenges)
.map(|c| get_memory_extra_looking_sum(&public_values, ctl_challenges.challenges[c]))
.collect_vec(),
);

verify_cross_table_lookups::<F, D, NUM_TABLES>(
cross_table_lookups,
all_proof
.multi_proof
.stark_proofs
.map(|p| p.proof.openings.ctl_zs_first.unwrap()),
Some(&extra_looking_sums),
&extra_looking_sums,
config,
)
}
Expand Down
2 changes: 1 addition & 1 deletion mpt_trie/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mpt_trie"
description = "Types and utility functions for building/working with partial Ethereum tries."
version = "0.2.1"
version = "0.3.0"
authors = ["Polygon Zero <bgluth@polygon.technology>"]
readme = "README.md"
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion proof_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ plonky2 = { workspace = true }
serde = { workspace = true }

# Local dependencies
evm_arithmetization = { version = "0.1.3", path = "../evm_arithmetization" }
evm_arithmetization = { version = "0.2.0", path = "../evm_arithmetization" }
6 changes: 3 additions & 3 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "trace_decoder"
description = "Processes trace payloads into Intermediate Representation (IR) format."
authors = ["Polygon Zero <bgluth@polygon.technology>"]
version = "0.3.1"
version = "0.4.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand All @@ -27,8 +27,8 @@ serde_with = "3.4.0"
thiserror = { workspace = true }

# Local dependencies
mpt_trie = { version = "0.2.1", path = "../mpt_trie" }
evm_arithmetization = { version = "0.1.3", path = "../evm_arithmetization" }
mpt_trie = { version = "0.3.0", path = "../mpt_trie" }
evm_arithmetization = { version = "0.2.0", path = "../evm_arithmetization" }

[dev-dependencies]
pretty_env_logger = "0.5.0"
Loading