-
Notifications
You must be signed in to change notification settings - Fork 95
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 PreprocessedColumn Structs #966
base: dev
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #966 +/- ##
==========================================
- Coverage 92.26% 92.13% -0.14%
==========================================
Files 105 105
Lines 14293 14314 +21
Branches 14293 14314 +21
==========================================
Hits 13188 13188
- Misses 1032 1053 +21
Partials 73 73 ☔ View full report in Codecov by Sentry. |
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.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @Gali-StarkWare and @shaharsamocha7)
crates/prover/src/constraint_framework/preprocessed_columns.rs
line 169 at r1 (raw file):
// TODO(Gali): Add documentation. #[derive(Debug)] pub struct Plonk {
can you not include this?
crates/prover/src/constraint_framework/preprocessed_columns.rs
line 201 at r1 (raw file):
/// A column with `1` at every `2^log_step` positions, `0` elsewhere, shifted by offset. #[derive(Debug)] pub struct IsStepWithOffset {
same, if theyre not used, add a todo to implement them
I suspect no one will do those todos for a while, or ever.
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.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)
crates/prover/src/constraint_framework/preprocessed_columns.rs
line 201 at r1 (raw file):
Previously, ohad-starkware (Ohad) wrote…
same, if theyre not used, add a todo to implement them
I suspect no one will do those todos for a while, or ever.
They are used in the examples (I guess this is the reason they exist in the first place), that's why I asked you if this is the right place for them, or maybe now is the time to move their declaration to be in the examples themselves.
Previously, Gali-StarkWare wrote…
Right, I wrote a suggestion in #965 to rid of this |
1bb5639
to
663fec9
Compare
bc0097b
to
6ba7258
Compare
unsafe { | ||
PackedM31::from_simd_unchecked(Simd::from_array(std::array::from_fn(|i| { | ||
if i == 0 { | ||
1 | ||
} else { | ||
0 | ||
} | ||
}))) | ||
} |
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.
Detected 'unsafe' usage, please audit for secure usage
🎉 Removed in commit c58dc9d 🎉
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.
Semgrep Assistant suggests the following fix: Ensure safe usage of PackedM31::from_simd_unchecked
by verifying input validity or using a safe alternative.
View step-by-step instructions
- Review the
PackedM31::from_simd_unchecked
function to understand why it requiresunsafe
and what invariants must be upheld for safe usage. - Check if there is a safe alternative to
from_simd_unchecked
that can be used instead. If such a function exists, replacePackedM31::from_simd_unchecked
with the safe alternative. - If no safe alternative exists, ensure that the input to
from_simd_unchecked
is always valid and does not violate any invariants required by the function. This may involve adding checks or assertions before theunsafe
block to guarantee safety. - Document the reason for using
unsafe
and the guarantees that are being upheld in a comment above theunsafe
block. This will help future developers understand whyunsafe
is necessary and how it is being used safely.
This code change should be a good starting point:
unsafe { | |
PackedM31::from_simd_unchecked(Simd::from_array(std::array::from_fn(|i| { | |
if i == 0 { | |
1 | |
} else { | |
0 | |
} | |
}))) | |
} | |
// Ensure that the input to `from_simd_unchecked` is valid. | |
// In this case, we are creating a SIMD vector with a specific pattern | |
// that is known to be safe for the `PackedM31` type. | |
// The use of `unsafe` is justified because we are controlling the input | |
// and ensuring it adheres to the expected invariants. | |
let simd_array = Simd::from_array(std::array::from_fn(|i| { | |
if i == 0 { | |
1 | |
} else { | |
0 | |
} | |
})); | |
PackedM31::from_simd(simd_array) |
Leave feedback with a 👍 / 👎. Save a memory with /remember <your custom instructions>
.
6ba7258
to
c58dc9d
Compare
Semgrep found 1 Detected 'unsafe' usage, please audit for secure usage |
c58dc9d
to
3428754
Compare
663fec9
to
c3740fe
Compare
3428754
to
52a4b0a
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.
Reviewable status: 0 of 10 files reviewed, 3 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)
crates/prover/src/constraint_framework/preprocessed_columns.rs
line 169 at r1 (raw file):
Previously, ohad-starkware (Ohad) wrote…
can you not include this?
Done.
crates/prover/src/constraint_framework/preprocessed_columns.rs
line 201 at r1 (raw file):
Previously, ohad-starkware (Ohad) wrote…
Right, I wrote a suggestion in #965 to rid of this
Done.
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.
Reviewed 1 of 6 files at r3.
Reviewable status: 1 of 10 files reviewed, 2 unresolved discussions (waiting on @Gali-StarkWare and @shaharsamocha7)
crates/prover/src/examples/state_machine/mod.rs
line 29 at r4 (raw file):
use crate::core::vcs::blake2_merkle::{Blake2sMerkleChannel, Blake2sMerkleHasher}; pub fn gen_is_first_columns(
why is this here? you're not using it
also, this should be inlined, it doesn't save code really.
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.
Reviewable status: 1 of 10 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)
crates/prover/src/examples/state_machine/mod.rs
line 29 at r4 (raw file):
Previously, ohad-starkware (Ohad) wrote…
why is this here? you're not using it
also, this should be inlined, it doesn't save code really.
I will be using it instead of gen_preprocessed_columns. I will inline it.
c3740fe
to
c7e7607
Compare
52a4b0a
to
ddb66cd
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.
Reviewed 2 of 9 files at r2, 2 of 6 files at r3, 1 of 2 files at r4, all commit messages.
Reviewable status: 6 of 10 files reviewed, 1 unresolved discussion (waiting on @Gali-StarkWare and @shaharsamocha7)
ddb66cd
to
9def2ec
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.
Reviewed 1 of 9 files at r2, 1 of 6 files at r3, 1 of 1 files at r5, 4 of 4 files at r6, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Gali-StarkWare)
crates/prover/src/examples/plonk/preprocessed_columns.rs
line 14 at r6 (raw file):
format!("preprocessed_plonk_{}", self.wire) } }
I'm not sure this worth it's own file
You can add it to the regular plonk file and please document rather than add TODO
Code quote:
// TODO(Gali): Add documentation.
#[derive(Debug)]
pub struct Plonk {
pub wire: usize,
}
impl Plonk {
pub const fn new(wire: usize) -> Self {
Self { wire }
}
pub fn id(&self) -> String {
format!("preprocessed_plonk_{}", self.wire)
}
}
crates/prover/src/examples/blake/preprocessed_columns.rs
line 4 at r6 (raw file):
#[allow(dead_code)] #[derive(Debug)] pub struct XorTable {
Consider to move the XorTable generate_constant_trace to here
Code quote:
pub struct XorTable {
9def2ec
to
01a4251
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.
Reviewable status: 7 of 10 files reviewed, 3 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)
crates/prover/src/examples/blake/preprocessed_columns.rs
line 4 at r6 (raw file):
Previously, shaharsamocha7 wrote…
Consider to move the XorTable generate_constant_trace to here
Done.
crates/prover/src/examples/plonk/preprocessed_columns.rs
line 14 at r6 (raw file):
Previously, shaharsamocha7 wrote…
I'm not sure this worth it's own file
You can add it to the regular plonk file and please document rather than add TODO
Done.
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.
Reviewable status: 7 of 10 files reviewed, 3 unresolved discussions (waiting on @Gali-StarkWare and @shaharsamocha7)
No description provided.