-
Notifications
You must be signed in to change notification settings - Fork 52
feat(starknet_os): inline ark_poly bit_reversal algorithm #5110
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
feat(starknet_os): inline ark_poly bit_reversal algorithm #5110
Conversation
7d8c3a5
to
d8a5f6a
Compare
cbc6c81
to
a16f05d
Compare
d8a5f6a
to
fcbd745
Compare
a16f05d
to
8c5b064
Compare
fcbd745
to
2b1cb0f
Compare
8c5b064
to
1d067ea
Compare
2b1cb0f
to
f9a03bd
Compare
1d067ea
to
8bde8f3
Compare
f9a03bd
to
f95f6e8
Compare
8bde8f3
to
92bfdda
Compare
f95f6e8
to
9138d42
Compare
0c38e02
to
173019e
Compare
173019e
to
84d251f
Compare
What's going on here? (I mean, bit manipulation is hard to follow, so maybe consider an explanation\reference on why it works?) Code quote: fn bitreverse(mut n: usize) -> usize {
let mut r = 0;
for _ in 0..WIDTH {
r = (r << 1) | (n & 1);
n >>= 1;
}
r
} |
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 3 files at r1, 1 of 2 files at r3, 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @Yoni-Starkware)
84d251f
to
2303ab8
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 2 files at r7, 2 of 2 files at r8, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Yoni-Starkware)
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 169 at r8 (raw file):
} /// Reverses the bits of `n`, assuming it has a width (in bits) of `WIDTH`.
Maybe?
Suggestion:
; assumes `n` is at most `WIDTH` bits.
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 184 at r8 (raw file):
// As bitreverse(bitreverse(i)) = i, by swapping only when i < reversed_i we avoid swapping // the same element twice. When the loop terminates, each index will have swapped locations // with it's reversed, as required.
It's a bit verbose; consider shortening.
Code quote:
// As bitreverse(bitreverse(i)) = i, by swapping only when i < reversed_i we avoid swapping
// the same element twice. When the loop terminates, each index will have swapped locations
// with it's reversed, as required.
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: all files reviewed, 1 unresolved discussion (waiting on @aner-starkware and @Yoni-Starkware)
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 169 at r8 (raw file):
Previously, aner-starkware wrote…
Maybe?
no, this is not an upper bound; if n=7
then bitreverse(n, 3) == 7
but bitreverse(n, 4) == 14
. n
can be "smaller than the width".
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 184 at r8 (raw file):
Previously, aner-starkware wrote…
It's a bit verbose; consider shortening.
what would you suggest?
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: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @Yoni-Starkware)
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 169 at r8 (raw file):
Previously, dorimedini-starkware wrote…
no, this is not an upper bound; if
n=7
thenbitreverse(n, 3) == 7
butbitreverse(n, 4) == 14
.n
can be "smaller than the width".
Ah, right, so maybe "where n
is represented by WIDTH
bits". Is WIDTH
the best name, btw?
crates/starknet_os/src/hints/hint_implementation/kzg/utils.rs
line 184 at r8 (raw file):
Previously, dorimedini-starkware wrote…
what would you suggest?
Maybe "Applies the bit-reversal permutation on all elements. Swaps only when i < reversed_i to avoid swapping the same element twice."
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: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @Yoni-Starkware)
* feat(starknet_os): copy get_deprecated_contract_class_struct from moonsong's repo * feat(starknet_os): implement LoadCairoObject trait for DeprecatedContractClass * feat(starknet_os): copy load_deprecated_class_inner hint implementation from moonsong's repo * feat(starknet_os): implement load deprecated class inner hint
2303ab8
to
dabe98d
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: 2 of 4 files reviewed, all discussions resolved (waiting on @aner-starkware and @Yoni-Starkware)
config/sequencer/presets/consolidated_node/application_configs/node.json
line 306 at r9 (raw file):
"versioned_constants_overrides.max_recursion_depth": 50, "versioned_constants_overrides.validate_max_n_steps": 1000000 }
I have no idea why the latest gt sync
cause so many conflicts, but this JSON was missing a trailing newline... unrelated to my PR but no damage
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 2 files at r9.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @Yoni-Starkware)
-- commits
line 10 at r9:
What's this?
Code quote:
New commits in r9 on 3/25/2025 at 11:48 AM by rotem-starkware:
- dabe98d: feat(starknet_os): implement load deprecated class inner hint (#5108)
* feat(starknet_os): copy get_deprecated_contract_class_struct from moonsong's repo
* feat(starknet_os): implement LoadCairoObject trait for DeprecatedContractClass
* feat(starknet_os): copy load_deprecated_class_inner hint implementation from moonsong's repo
* feat(starknet_os): implement load deprecated class inner hint
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: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @aner-starkware and @Yoni-Starkware)
Previously, aner-starkware wrote…
What's this?
gt sync
issue... commits will be squashed anyway, as long as the diff is fine it's fine.
not sure what happened here
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: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @aner-starkware and @Yoni-Starkware)
Previously, dorimedini-starkware wrote…
gt sync
issue... commits will be squashed anyway, as long as the diff is fine it's fine.
not sure what happened here
the commit message will be the PR title
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 all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Yoni-Starkware)
feat(starknet_os): inline ark_poly bit_reversal algorithm
feat(starknet_os): refactor bit_reversal for our needs
Signed-off-by: Dori Medini dori@starkware.co