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

Added const for starknet types. #6961

Open
wants to merge 1 commit into
base: dev-v2.10.0
Choose a base branch
from
Open

Conversation

orizi
Copy link
Collaborator

@orizi orizi commented Dec 31, 2024

No description provided.

@orizi orizi requested a review from liorgold2 December 31, 2024 09:50
@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@liorgold2 liorgold2 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 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @orizi)


a discussion (no related file):
Missing failure test (initializing with an invalid value)


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 12 at r1 (raw file):

use super::int::unsigned128::Uint128Type;
use super::non_zero::NonZeroType;
use super::starknet::interoperability::{ClassHashType, ContractAddressType};

Are we ok with this dependency? (I guess we are)


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 74 at r1 (raw file):

) -> Result<(), SpecializationError> {
    let inner_type_info = context.get_type_info(inner_ty.clone())?;
    let type_range = if inner_type_info.long_id.generic_id == StructType::ID {

This is slightly confusing.
Split to two paragraphs:

if ... {
    return validate...(...);
} else if ... {
    return validate...(...);
} else if ... {
    return validate...(...);
}

let type_range = if ... {
    ...
} else {
    ...
}
...

Copy link
Collaborator

@liorgold2 liorgold2 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: 1 of 2 files reviewed, 4 unresolved discussions (waiting on @orizi)


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 81 at r1 (raw file):

        return validate_const_nz_data(context, &inner_type_info, inner_data);
    } else if [ContractAddressType::id(), ClassHashType::id()]
        .contains(&inner_type_info.long_id.generic_id)

Move this to a variable. It appears many times in this function and will make this particular line shorter.

Code quote:

inner_type_info.long_id.generic_id

Copy link
Collaborator

@liorgold2 liorgold2 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: 1 of 2 files reviewed, 5 unresolved discussions (waiting on @orizi)


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 83 at r1 (raw file):

        .contains(&inner_type_info.long_id.generic_id)
    {
        Range::half_open(0, BigInt::one().shl(251))

I guess this appears in the libfunc as well, so I prefer to have it defined once, in a starknet module and not here.

Code quote:

BigInt::one().shl(251)

Copy link
Collaborator

@liorgold2 liorgold2 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 2 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @orizi)

Copy link
Collaborator Author

@orizi orizi 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, 5 unresolved discussions (waiting on @liorgold2)


a discussion (no related file):

Previously, liorgold2 wrote…

Missing failure test (initializing with an invalid value)

Done.


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 12 at r1 (raw file):

Previously, liorgold2 wrote…

Are we ok with this dependency? (I guess we are)

Don't think we have much of a choice.


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 74 at r1 (raw file):

Previously, liorgold2 wrote…

This is slightly confusing.
Split to two paragraphs:

if ... {
    return validate...(...);
} else if ... {
    return validate...(...);
} else if ... {
    return validate...(...);
}

let type_range = if ... {
    ...
} else {
    ...
}
...

Done.


crates/cairo-lang-sierra/src/extensions/modules/const_type.rs line 81 at r1 (raw file):

Previously, liorgold2 wrote…

Move this to a variable. It appears many times in this function and will make this particular line shorter.

Done.

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.

3 participants