-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Tests for Segment Proving Without Keccak Tables #648
Conversation
84860a9
to
f63363b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general rule, we try to not add any #[ignore]
tests as these end up being forgotten / outdated (this happened more than once in the past).
I'm also curious about the main goal behind this. Is it purely for testing the functionality, or benchmarking it (cf the timing.print()
)? Either way, it may be best to craft / fetch an actual payload that would achieve what we want. We could replace some of the currently used block artifacts if you wanted to test this on a regular basis (i.e. through a CI job).
#[test] | ||
#[ignore] | ||
fn test_segment_proof_generation_without_keccak() -> anyhow::Result<()> { | ||
let timing = &mut TimingTree::new("Segment Proof Generation", log::Level::Info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will capture everything, I'd assume you want to initialize it right before proving?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is what I intend to do. I also want to know recursive circuits generation time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the timing tree name is slightly misleading then but not really blocking,
let max_cpu_len_log = 9; | ||
let segment_iterator = SegmentDataIterator::<F>::new(&dummy_payload, Some(max_cpu_len_log)); | ||
|
||
let mut proofs_without_keccak = vec![]; | ||
|
||
let skip_proofs_before_index = 3; | ||
for (i, segment_run) in segment_iterator.enumerate() { | ||
if i < skip_proofs_before_index { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems highly specific, as any modification in the KERNEL ASM may break your assumption that the 3rd segment has no keccak operation.
Also this is breaking compilation with cdk_erigon
feature flag, as in this case we're missing a range for the Poseidon table in the initialization of AllRecursiveCircuits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. Do you have any suggestions on how to craft a payload that generates segments without Keccak? Regarding cdk_erigon, I can add a feature flag to disable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we'd need some around segment generation. Basically we'd want to do the same as in init_exc_stop.rs
but I don't think this will play well with how we actually generate segment data.
The main purpose of this PR is to add a test for root proving without Keccak tables. I will remove the #[ignore] attribute when I upload the main PR. I’m not entirely sure how to craft a payload that achieves the desired outcome. This is the fastest test I could come up with for now. |
I think the cleanest way would be to add a dummy segment to a complete transaction. It was done before, but I believe the logic got scrapped at some point since we don't need them anymore. |
I will try to improve this test, but this does not block merging other PRs related to #620 |
Thanks for the reviews! I have made the following changes to the unit tests:
|
Yes empty payloads would still need some light keccak ops. I'll try crafting / refactoring the segment generation handling tomorrow so that you can use it as is in your test without needing a convoluted (and not super future-proof) approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want this to be blocking you, so I'll leave an approval as the test works for now, and would panic if we were to hit a KECCAK instruction in this given segment.
As a general indication for a clean way to generate fully dummy segments (just the init
portion in the KERNEL), the issue lies in the initialization of the GenerationState
which, as it is only used for actual proof runs (unlike the interpreter state), is using the hardcoded halt_final
offset as only halting point, and doesn't take customizable ones unlike segment data generation (cc @hratoanina).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (especially given the discussion)
This has already been addressed per our offline discussion. |
This PR prepares tests for the Issue: #620
Extracted from #624
[2024-09-23T17:07:54Z INFO evm_arithmetization::generation] CPU trace padded to 512 cycles
[2024-09-23T17:07:54Z INFO evm_arithmetization::witness::traces] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 121, byte_packing_len: 2, cpu_len: 512, keccak_len: 0, keccak_sponge_len: 0, logic_len: 4, memory_len: 67684 }, mem_before_len: 66136, mem_after_len: 66173
[2024-09-23T17:08:10Z INFO plonky2::util::timing] 29.7726s to Segment Proof Generation
[2024-09-23T17:08:10Z INFO plonky2::util::timing] | 14.2296s to Create all recursive circuits
[2024-09-23T17:08:10Z INFO plonky2::util::timing] | 0.0000s to Generate dummy payload
[2024-09-23T17:08:10Z INFO plonky2::util::timing] | 15.5369s to Prove segment
[2024-09-23T17:08:10Z INFO plonky2::util::timing] | 0.0034s to Verify segment proof
test fixed_recursive_verifier::tests::test_segment_proof_generation_without_keccak ... ok