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

continuations: Remove the need for dummy segments #245

Merged
merged 38 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
02a2849
Implement single-segment aggregations
hratoanina Apr 24, 2024
65d8771
Change log test
hratoanina Apr 25, 2024
6141e52
Don't generate dummy segment data
hratoanina Apr 25, 2024
b7c0fe0
Fix dummy proof setting
hratoanina Apr 25, 2024
5b22d34
Make dummy proof out of dummy circuit
hratoanina Apr 25, 2024
db9a8f2
Try to generate dummy proof
hratoanina Apr 26, 2024
26d02b6
Add import
hratoanina Apr 26, 2024
187e96e
Add pis to dummy proof
hratoanina Apr 26, 2024
f8806fd
Update method name
hratoanina Apr 26, 2024
2a2d4a4
Fix PV connection
Nashtare Apr 29, 2024
4c00a54
Fix wire set twice
LindaGuiga Apr 29, 2024
2891246
Update ranges
Nashtare Apr 29, 2024
7c9f63a
Merge remote-tracking branch 'origin/feat/continuations' into no_dumm…
Nashtare Apr 29, 2024
0804c38
Add getter and handle single segment
Nashtare Apr 30, 2024
ee16349
Dummy segments, new version
hratoanina May 21, 2024
73fdf94
Fix AggChildWithDummy
LindaGuiga May 21, 2024
2941d72
Update to latest version of zkevm_no_dummy_segment
LindaGuiga May 21, 2024
483de98
Add is_dummy to ProverOutputData, remove the special logic for dummy …
LindaGuiga May 21, 2024
bc3933b
Update proof_gen
LindaGuiga May 23, 2024
540949e
Merge branch 'feat/continuations' into no_dummy_segment_no_pis
LindaGuiga May 24, 2024
58d1e6a
Cleanup and add missing connections in create_segment_aggregation_cir…
LindaGuiga May 24, 2024
37fdf73
Merge branch 'feat/continuations' into no_dummy_segment_no_pis
LindaGuiga May 28, 2024
8205e53
Merge branch 'feat/continuations' into no_dummy_segment_no_pis
LindaGuiga May 30, 2024
08dd0ab
Create generate_next_segment and make_dummy_segment
LindaGuiga May 29, 2024
5578e8b
Add debug log
LindaGuiga May 29, 2024
717d29c
Have teh SegmentDataIterator in zk_evm and change prove_all_segments …
LindaGuiga May 30, 2024
3261e62
Remove dummy segment in SegmentDataIterator
LindaGuiga May 31, 2024
a289b7a
Clippy and cleanup
LindaGuiga May 31, 2024
6eee424
Merge branch 'feat/continuations' into no_dummy_segment_no_pis
LindaGuiga Jun 5, 2024
60f67a8
Apply comments
LindaGuiga Jun 6, 2024
0153a62
Remove segments from AggregatableTxnProofs
LindaGuiga Jun 6, 2024
0f5c185
Rename SegmentAggregatableProof variant
hratoanina Jun 6, 2024
cfd1fcf
Fix generate_segment_agg_proof
LindaGuiga Jun 7, 2024
e3d7220
Merge branch 'feat/continuations' into no_dummy_segment_no_pis
LindaGuiga Jun 7, 2024
354db88
Merge branch 'continuations-next-segment' into no_dummy_segment_no_pis
hratoanina Jun 10, 2024
87fa930
Apply comments
LindaGuiga Jun 11, 2024
1380841
Use reference for GenerationInputs in SegmentDataIterator
LindaGuiga Jun 13, 2024
b9c1ce7
Reintroduce changes to TxnAggregatableProof for zero-bin compatibility
LindaGuiga Jun 14, 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
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ serde = "1.0.166"
serde_json = "1.0.96"
serde-big-array = "0.5.1"
thiserror = "1.0.49"
hashbrown = "0.14.0"

# plonky2-related dependencies
plonky2 = "0.2.2"
plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }
plonky2_maybe_rayon = "0.2.0"
plonky2_util = "0.2.0"
starky = "0.4.0"
plonky2_util = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }
starky = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" }
Comment on lines +25 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be doing a release this week normally, so can probably hold off until then and revert to using version tags

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end we didn't end up using the API changes on plonky2 right? With the new approach for dummy segment removal. Do we still need a version bump there? (It's not included in #276 as per discussion in the sync meeting).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I had missed this comment before: we still need methods such as conditional_assert_eq which are not on Plonky2 v.0.2.2.

Copy link
Collaborator

@Nashtare Nashtare Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but we won't be bumping plonky2 yet (because of the STARK batching thing), so we can keep the main reference / commit rev for the time being.



[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rlp = { workspace = true }
rlp-derive = { workspace = true }
serde = { workspace = true, features = ["derive"] }
static_assertions = "1.1.0"
hashbrown = { version = "0.14.0" }
hashbrown = { workspace = true }
tiny-keccak = "2.0.2"
serde_json = { workspace = true }
serde-big-array = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl<F: Field> Interpreter<F> {
}

pub(crate) fn run(&mut self) -> Result<(RegistersState, Option<MemoryState>), anyhow::Error> {
let (final_registers, final_mem) = self.run_cpu(self.max_cpu_len_log, self.is_dummy)?;
let (final_registers, final_mem) = self.run_cpu(self.max_cpu_len_log)?;

#[cfg(debug_assertions)]
{
Expand Down
3 changes: 1 addition & 2 deletions evm_arithmetization/src/cpu/kernel/tests/bignum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use itertools::Itertools;
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 +89,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
46 changes: 40 additions & 6 deletions evm_arithmetization/src/cpu/kernel/tests/init_exc_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ use crate::generation::state::State;
use crate::generation::TrieInputs;
use crate::generation::NUM_EXTRA_CYCLES_AFTER;
use crate::generation::NUM_EXTRA_CYCLES_BEFORE;
use crate::memory::segments::Segment;
use crate::proof::BlockMetadata;
use crate::proof::RegistersData;
use crate::proof::RegistersIdx;
use crate::proof::TrieRoots;
use crate::witness::memory::MemoryAddress;
use crate::witness::state::RegistersState;
use crate::{proof::BlockHashes, GenerationInputs, Node};

Expand Down Expand Up @@ -89,19 +93,49 @@ fn test_init_exc_stop() {
"Incorrect registers for dummy run."
);

let main_offset = KERNEL.global_labels["main"];
let mut interpreter: Interpreter<F> =
Interpreter::new_dummy_with_generation_inputs(initial_offset, vec![], &inputs);
let exc_stop_offset = KERNEL.global_labels["exc_stop"];

let pc_u256 = U256::from(interpreter.get_registers().program_counter);
let exit_info = pc_u256 + (U256::one() << 32);
interpreter.push(exit_info).unwrap();
interpreter.get_mut_registers().program_counter = exc_stop_offset;
interpreter.halt_offsets = vec![KERNEL.global_labels["halt_final"]];
interpreter.set_is_kernel(true);
interpreter.clock = 0;

// Set the program counter and `is_kernel` at the end of the execution. The
// `registers_before` and `registers_after` are stored contiguously in the
// `RegistersState` segment. We need to update `registers_after` here, hence the
// offset by `RegistersData::SIZE`.
let regs_to_set = [
(
MemoryAddress {
context: 0,
segment: Segment::RegistersStates.unscale(),
virt: RegistersData::SIZE + RegistersIdx::ProgramCounter as usize,
},
pc_u256,
),
(
MemoryAddress {
context: 0,
segment: Segment::RegistersStates.unscale(),
virt: RegistersData::SIZE + RegistersIdx::IsKernel as usize,
},
U256::one(),
),
];
interpreter.set_memory_multi_addresses(&regs_to_set);

interpreter.run().expect("Running dummy exc_stop failed.");

// The "-1" comes from the fact that we stop 1 cycle before the max, to allow
// for one padding row, which is needed for CPU STARK.
// The "-2" comes from the fact that:
// - we stop 1 cycle before the max, to allow for one padding row, which is
// needed for CPU STARK.
// - we need one additional cycle to enter `exc_stop`.
assert_eq!(
interpreter.get_clock(),
NUM_EXTRA_CYCLES_BEFORE + NUM_EXTRA_CYCLES_AFTER - 1,
NUM_EXTRA_CYCLES_AFTER - 2,
"NUM_EXTRA_CYCLES_AFTER is set incorrectly."
);
}
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
Loading