Skip to content

Commit

Permalink
Bump plonky2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Sep 11, 2024
1 parent b7bee72 commit 2dd5d42
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 26 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ rpc = { path = "zero_bin/rpc", default-features = false }
zero_bin_common = { path = "zero_bin/common", default-features = false }

# plonky2-related dependencies
plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }
plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "349beae1431ecffc1bf8c044d6c00e2bf194b74a" }
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" }
plonky2_util = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "349beae1431ecffc1bf8c044d6c00e2bf194b74a" }
starky = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "349beae1431ecffc1bf8c044d6c00e2bf194b74a" }

# proc macro related dependencies
proc-macro2 = "1.0"
Expand Down
5 changes: 5 additions & 0 deletions evm_arithmetization/src/all_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ impl Table {
}
}

/// The total number of CTLs used by the zkEVM.
pub(crate) const NUM_CTLS: usize = if cfg!(feature = "cdk_erigon") { 13 } else { 10 };
/// The position of the Memory CTL within all CTLs of the zkEVM.
pub(crate) const MEMORY_CTL_IDX: usize = 6;

/// Returns all the `CrossTableLookups` used for proving the EVM.
pub(crate) fn all_cross_table_lookups<F: Field>() -> Vec<CrossTableLookup<F>> {
vec![
Expand Down
32 changes: 19 additions & 13 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_IDX, NUM_CTLS, NUM_TABLES,
};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::generation::segments::{GenerationSegmentData, SegmentDataIterator, SegmentError};
use crate::generation::{GenerationInputs, TrimmedGenerationInputs};
Expand Down Expand Up @@ -885,26 +887,30 @@ 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];
let mut extra_looking_sums = HashMap::from_iter(
(0..NUM_CTLS).map(|i| (i, vec![builder.zero(); stark_config.num_challenges])),
);

// 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();
extra_looking_sums.insert(
MEMORY_CTL_IDX,
(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
8 changes: 5 additions & 3 deletions evm_arithmetization/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{ensure, Result};
use ethereum_types::{BigEndianHash, U256};
use hashbrown::HashMap;
use itertools::Itertools;
use plonky2::field::extension::Extendable;
use plonky2::field::polynomial::PolynomialValues;
Expand All @@ -15,7 +16,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_IDX, NUM_CTLS, NUM_TABLES};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
use crate::memory::segments::Segment;
Expand Down Expand Up @@ -248,7 +249,8 @@ fn verify_proof<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const

// 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..NUM_CTLS).map(|i| (i, vec![F::ZERO; config.num_challenges])));

// Memory
extra_looking_sums[*Table::Memory] = (0..config.num_challenges)
Expand All @@ -261,7 +263,7 @@ fn verify_proof<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const
.multi_proof
.stark_proofs
.map(|p| p.proof.openings.ctl_zs_first.unwrap()),
Some(&extra_looking_sums),
&extra_looking_sums,
config,
)
}
Expand Down

0 comments on commit 2dd5d42

Please sign in to comment.