Skip to content

feat(starknet_os): implement assign bytecode segments hint #5004

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

Merged

Conversation

nimrod-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

nimrod-starkware commented Mar 18, 2025

@nimrod-starkware nimrod-starkware self-assigned this Mar 18, 2025
@nimrod-starkware nimrod-starkware marked this pull request as ready for review March 18, 2025 08:48
@nimrod-starkware nimrod-starkware force-pushed the nimrod/hints/compiled_class/assign_bytecode_segments branch from 0f0127c to 3f1b5e9 Compare March 18, 2025 08:56
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a 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 r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

    } else {
        unreachable!("assign_bytecode_segments should not be called on a leaf node.");
    }

I think technically this can happen, right?
I cannot - in a context-free way - see why the else is unreachable...
how about this?

Suggestion:

    match bytecode_segment_structure {
        BytecodeSegmentNode::InnerNode(node) => {
            exec_scopes.insert_value(Scope::BytecodeSegments.into(), node.segments.into_iter());
            Ok(())
        }
        BytecodeSegmentNode::Leaf(_) => Err(OsHintError::AssignedLeafBytecode)
    }

Copy link
Contributor Author

@nimrod-starkware nimrod-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 @dorimedini-starkware and @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

Previously, dorimedini-starkware wrote…

I think technically this can happen, right?
I cannot - in a context-free way - see why the else is unreachable...
how about this?

yes, technically, it is possible, but within the flow of the OS code, it's not.
PTAL here , if the variant is a leaf then the function will return early and won't reach that hint.
(returning an error is also fine IMO, just want to clarify this should be unreachable)

Copy link
Collaborator

@dorimedini-starkware dorimedini-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 @nimrod-starkware and @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

Previously, nimrod-starkware wrote…

yes, technically, it is possible, but within the flow of the OS code, it's not.
PTAL here , if the variant is a leaf then the function will return early and won't reach that hint.
(returning an error is also fine IMO, just want to clarify this should be unreachable)

let's go with errors, we are writing a library here

Copy link
Contributor Author

@nimrod-starkware nimrod-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 @dorimedini-starkware and @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

Previously, dorimedini-starkware wrote…

let's go with errors, we are writing a library here

Done.

@nimrod-starkware nimrod-starkware force-pushed the nimrod/hints/compiled_class/assign_bytecode_segments branch from 3f1b5e9 to 1eec0db Compare March 18, 2025 12:30
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a 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 r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware and @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

Previously, nimrod-starkware wrote…

Done.

please use match - it protects against addition of another variant without handling it correctly

Copy link
Contributor Author

@nimrod-starkware nimrod-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 @dorimedini-starkware and @yoavGrs)


crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs line 39 at r1 (raw file):

Previously, dorimedini-starkware wrote…

please use match - it protects against addition of another variant without handling it correctly

Done.

@nimrod-starkware nimrod-starkware force-pushed the nimrod/hints/compiled_class/assign_bytecode_segments branch from 1eec0db to eb8ed48 Compare March 18, 2025 12:58
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware 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 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)

@nimrod-starkware nimrod-starkware added this pull request to the merge queue Mar 18, 2025
Merged via the queue into main with commit 68d680d Mar 18, 2025
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants