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

Enables optional verification of Keccak tables #657

Merged
merged 72 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
662c8db
refactoring
sai-deng Sep 21, 2024
d82b1a8
fix clippy
sai-deng Sep 21, 2024
4498870
fix clippy
sai-deng Sep 21, 2024
b14417f
wip
sai-deng Sep 22, 2024
eabcf5e
wip
sai-deng Sep 22, 2024
2ad3857
Merge branch 'develop' into sai/skip_table_in_root_circuit
sai-deng Sep 23, 2024
2b2e737
wip
sai-deng Sep 23, 2024
f63363b
cleanup
sai-deng Sep 23, 2024
cc9d41b
prove one segment
sai-deng Sep 23, 2024
fe88819
polish the code
sai-deng Sep 23, 2024
7ff2fb1
cleanup
sai-deng Sep 23, 2024
6ce3cbe
Revert "cleanup"
sai-deng Sep 23, 2024
8c940b0
add [ignore]
sai-deng Sep 23, 2024
d6af500
add challenger state check
sai-deng Sep 23, 2024
f5deedb
add more checks
sai-deng Sep 23, 2024
e39894a
cleanup
sai-deng Sep 23, 2024
948d742
add empty keccak tables bool
sai-deng Sep 24, 2024
49bb96b
enable no keccak recursion
sai-deng Sep 24, 2024
bbba820
refactor
sai-deng Sep 24, 2024
8c4a362
fix tests
sai-deng Sep 24, 2024
5cdb37d
rename
sai-deng Sep 24, 2024
2f0129e
fix pis
sai-deng Sep 24, 2024
36ace10
fix
sai-deng Sep 25, 2024
5b7f818
resolve conflicts
sai-deng Sep 25, 2024
56deaa3
done
sai-deng Sep 25, 2024
7a3fe08
polish the comments
sai-deng Sep 25, 2024
cfc6f24
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Sep 25, 2024
4d288f8
fix ci
sai-deng Sep 25, 2024
e6bed69
add comments
sai-deng Sep 25, 2024
0bd1448
fix ci
sai-deng Sep 25, 2024
3800986
update tests
sai-deng Sep 25, 2024
674485e
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
sai-deng Sep 25, 2024
daaabb6
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Sep 25, 2024
91dbeaa
fix ci
sai-deng Sep 25, 2024
bb79080
fix ci
sai-deng Sep 25, 2024
ed9637d
Merge branch 'develop' into sai/skip_table_in_root_circuit
sai-deng Sep 25, 2024
fd55d1a
fix ci
sai-deng Sep 25, 2024
6b27552
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
sai-deng Sep 25, 2024
ab2ec50
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Sep 25, 2024
4de4c64
empty payload and no keccak op check
sai-deng Sep 26, 2024
e34c59a
refactor
sai-deng Sep 26, 2024
be887e6
Update evm_arithmetization/src/fixed_recursive_verifier.rs
sai-deng Sep 30, 2024
d2ca0cc
Update evm_arithmetization/src/fixed_recursive_verifier.rs
sai-deng Sep 30, 2024
ce88ef8
empty payload and no keccak op check
sai-deng Sep 26, 2024
a23eaf0
fmt
sai-deng Sep 30, 2024
7d72eb9
Merge branch 'develop' into sai/skip_table_in_root_circuit
sai-deng Sep 30, 2024
baba9da
merge
sai-deng Sep 30, 2024
ec64af9
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Sep 30, 2024
ac41fa4
Merge branch 'develop' into sai/skip_table_in_root_circuit
sai-deng Oct 1, 2024
f24d028
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
sai-deng Oct 1, 2024
58f37e8
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Oct 1, 2024
c822a70
fix test
sai-deng Oct 1, 2024
2886fd8
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
sai-deng Oct 1, 2024
1540078
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Oct 1, 2024
12c61a8
fix ci with "cdk_erigon"
sai-deng Oct 1, 2024
447cfb9
fix ci error with "cdk_erigon"
sai-deng Oct 1, 2024
5f935c2
Merge branch 'sai/skip_table_in_root_circuit' into sai/conditionally_…
sai-deng Oct 1, 2024
42afc90
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Oct 1, 2024
40867c0
Merge branch 'develop' into sai/conditionally_verify_in_root_circuit
sai-deng Oct 2, 2024
e7ab9eb
Merge branch 'sai/conditionally_verify_in_root_circuit' into sai/enab…
sai-deng Oct 2, 2024
09a1a4a
enable test
sai-deng Oct 2, 2024
4a69e8a
Update evm_arithmetization/src/fixed_recursive_verifier.rs
sai-deng Oct 2, 2024
81d3681
address comments
sai-deng Oct 2, 2024
79aeb72
sync changes into get_challenges
sai-deng Oct 2, 2024
732020d
wip
sai-deng Oct 2, 2024
9f8ec9e
fix
sai-deng Oct 2, 2024
503085b
fix
sai-deng Oct 2, 2024
a36c5f7
fix tests
sai-deng Oct 3, 2024
640bae1
fix
sai-deng Oct 3, 2024
051702d
address comments
sai-deng Oct 6, 2024
93fff4b
merge develop
sai-deng Oct 7, 2024
7bc7c2c
common_date -> common_data
sai-deng Oct 7, 2024
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
4 changes: 4 additions & 0 deletions evm_arithmetization/src/all_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ pub const NUM_TABLES: usize = if cfg!(feature = "cdk_erigon") {
Table::MemAfter as usize + 1
};

/// Indices of Keccak Tables
pub const KECCAK_TABLES_INDICES: [usize; 2] =
[Table::Keccak as usize, Table::KeccakSponge as usize];

impl Table {
/// Returns all STARK table indices.
pub(crate) const fn all() -> [Self; NUM_TABLES] {
Expand Down
5 changes: 3 additions & 2 deletions evm_arithmetization/src/arithmetic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ethereum_types::U256;
use plonky2::field::types::PrimeField64;
use serde::{Deserialize, Serialize};

use self::columns::{
INPUT_REGISTER_0, INPUT_REGISTER_1, INPUT_REGISTER_2, OPCODE_COL, OUTPUT_REGISTER,
Expand All @@ -24,7 +25,7 @@ pub(crate) mod columns;
///
/// `Shl` and `Shr` are handled differently, by leveraging `Mul` and `Div`
/// respectively.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub(crate) enum BinaryOperator {
Add,
Mul,
Expand Down Expand Up @@ -114,7 +115,7 @@ impl BinaryOperator {

/// An enum representing different ternary operations.
#[allow(clippy::enum_variant_names)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub(crate) enum TernaryOperator {
AddMod,
MulMod,
Expand Down
14 changes: 10 additions & 4 deletions evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ pub(crate) struct Interpreter<F: RichField> {
/// halt_context
pub(crate) halt_context: Option<usize>,
/// Counts the number of appearances of each opcode. For debugging purposes.
#[allow(unused)]
pub(crate) opcode_count: [usize; 0x100],
pub(crate) opcode_count: HashMap<Operation, usize>,
jumpdest_table: HashMap<usize, BTreeSet<usize>>,
/// `true` if the we are currently carrying out a jumpdest analysis.
pub(crate) is_jumpdest_analysis: bool,
Expand Down Expand Up @@ -179,7 +178,7 @@ impl<F: RichField> Interpreter<F> {
// while the label `halt` is the halting label in the kernel.
halt_offsets: vec![DEFAULT_HALT_OFFSET, KERNEL.global_labels["halt_final"]],
halt_context: None,
opcode_count: [0; 256],
opcode_count: HashMap::new(),
jumpdest_table: HashMap::new(),
is_jumpdest_analysis: false,
clock: 0,
Expand Down Expand Up @@ -210,7 +209,7 @@ impl<F: RichField> Interpreter<F> {
generation_state: state.soft_clone(),
halt_offsets: vec![halt_offset],
halt_context: Some(halt_context),
opcode_count: [0; 256],
opcode_count: HashMap::new(),
jumpdest_table: HashMap::new(),
is_jumpdest_analysis: true,
clock: 0,
Expand Down Expand Up @@ -429,6 +428,10 @@ impl<F: RichField> Interpreter<F> {
self.max_cpu_len_log
}

pub(crate) fn reset_opcode_counts(&mut self) {
self.opcode_count = HashMap::new();
}

pub(crate) fn code(&self) -> &MemorySegmentState {
// The context is 0 if we are in kernel mode.
&self.generation_state.memory.contexts[(1 - self.is_kernel() as usize) * self.context()]
Expand Down Expand Up @@ -662,6 +665,9 @@ impl<F: RichField> State<F> for Interpreter<F> {

let op = decode(registers, opcode)?;

// Increment the opcode count
*self.opcode_count.entry(op).or_insert(0) += 1;

fill_op_flag(op, &mut row);

self.fill_stack_fields(&mut row)?;
Expand Down
Loading
Loading