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

Integrate Range Check 128 Builtin #357

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

Gali-StarkWare
Copy link
Contributor

@Gali-StarkWare Gali-StarkWare commented Jan 15, 2025

This change is Reviewable

Copy link
Contributor Author

Gali-StarkWare commented Jan 15, 2025

Comment on lines 127 to 105
let (mut trace, mut lookup_data, mut sub_components_inputs) = unsafe {
(
ComponentTrace::<N_TRACE_COLUMNS>::uninitialized(log_size),
LookupData::uninitialized(log_n_packed_rows),
SubComponentInputs::uninitialized(log_size),
)
};
Copy link

@semgrep-code-starkware-libs semgrep-code-starkware-libs bot Jan 15, 2025

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 e66d428 🚀

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare left a comment

Choose a reason for hiding this comment

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

Dismissed @semgrep-code-starkware-libs[bot] from a discussion.
Reviewable status: 0 of 6 files reviewed, all discussions resolved (waiting on @shaharsamocha7)

@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_rc128_builtin branch 4 times, most recently from bc3afc7 to 4d9ea3d Compare January 20, 2025 08:23
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_rc128_builtin branch 3 times, most recently from c1d308c to 575e11c Compare January 21, 2025 13:13
@Gali-StarkWare Gali-StarkWare changed the base branch from main to gali/rc128 January 21, 2025 13:13
@Gali-StarkWare Gali-StarkWare changed the title Add Range Check 128 Builtin Integrate Range Check 128 Builtin Jan 21, 2025
@Gali-StarkWare Gali-StarkWare marked this pull request as ready for review January 21, 2025 14:25
@Gali-StarkWare Gali-StarkWare requested a review from alon-f January 21, 2025 14:26
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_rc128_builtin branch 2 times, most recently from 8d22c27 to e9b8976 Compare January 22, 2025 13:02
Copy link
Contributor

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6, 6 of 7 files at r7, all commit messages.
Reviewable status: 7 of 8 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, and @Gali-StarkWare)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 38 at r7 (raw file):

pub struct BuiltinsClaimGenerator {
    range_check_128_builtin_trace_generator: Option<range_check_builtin_bits_128::ClaimGenerator>,

consider to rename

Suggestion:

range_check_128

stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

                .map(|range_check_bits_128| {
                    range_check_builtin_bits_128::ClaimGenerator::new(
                        (range_check_bits_128.stop_ptr - range_check_bits_128.begin_addr).ilog2(),

Can you change this to checked_ilog2()?

Code quote:

(range_check_bits_128.stop_ptr - range_check_bits_128.begin_addr).ilog2(),

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare left a 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 8 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 38 at r7 (raw file):

Previously, shaharsamocha7 wrote…

consider to rename

IMO it should stay the same for consistency with the other components (we can change all of them in a different PR if you want)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

Previously, shaharsamocha7 wrote…

Can you change this to checked_ilog2()?

Done.

Copy link
Contributor

@shaharsamocha7 shaharsamocha7 left a 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: 7 of 8 files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, and @Gali-StarkWare)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

Previously, Gali-StarkWare wrote…

Done.

ty but the error message is incorrect

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare left a 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 8 files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

Previously, shaharsamocha7 wrote…

ty but the error message is incorrect

checked_ilog2() returns None in case of a 0 input (and Some(log_size rounded down) else) so it's not a check for receiving a power of 2 from air-infra. Is this better?

Copy link
Contributor

@shaharsamocha7 shaharsamocha7 left a 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: 3 of 8 files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, and @Gali-StarkWare)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

Previously, Gali-StarkWare wrote…

checked_ilog2() returns None in case of a 0 input (and Some(log_size rounded down) else) so it's not a check for receiving a power of 2 from air-infra. Is this better?

I don't understand, we want to make sure that this is a power of 2.

Copy link
Contributor

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r9.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, and @Gali-StarkWare)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 54 at r9 (raw file):

                        (range_check_bits_128.stop_ptr - range_check_bits_128.begin_addr).ilog2(),
                        range_check_bits_128.begin_addr as u32,
                    )

consider to move this to a util function in a later pr.

Code quote:

                    assert!(
                        (range_check_bits_128.stop_ptr - range_check_bits_128.begin_addr)
                            .is_power_of_two(),
                        "range_check_bits_128 segment length is not a power of two"
                    );
                    range_check_builtin_bits_128::ClaimGenerator::new(
                        (range_check_bits_128.stop_ptr - range_check_bits_128.begin_addr).ilog2(),
                        range_check_bits_128.begin_addr as u32,
                    )

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare left a 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 @alon-f and @andrewmilson)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 47 at r7 (raw file):

Previously, shaharsamocha7 wrote…

I don't understand, we want to make sure that this is a power of 2.

I know, now we do. Using checked_ilog2() wasn't enough

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare left a 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 @alon-f, @andrewmilson, and @Gali-StarkWare)


stwo_cairo_prover/crates/prover/src/cairo_air/builtins_air.rs line 54 at r9 (raw file):

Previously, shaharsamocha7 wrote…

consider to move this to a util function in a later pr.

Will do

Copy link
Contributor Author

Gali-StarkWare commented Jan 27, 2025

Merge activity

  • Jan 27, 9:29 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 27, 9:31 AM EST: Graphite rebased this pull request as part of a merge.
  • Jan 27, 10:33 AM EST: A user merged this pull request with Graphite.

@Gali-StarkWare Gali-StarkWare changed the base branch from gali/rc128 to graphite-base/357 January 27, 2025 14:29
@Gali-StarkWare Gali-StarkWare changed the base branch from graphite-base/357 to main January 27, 2025 14:29
Copy link
Contributor

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r10, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alon-f and @andrewmilson)

@Gali-StarkWare Gali-StarkWare merged commit 8369484 into main Jan 27, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants