-
Notifications
You must be signed in to change notification settings - Fork 549
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
Conversation
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 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 {
...
}
...
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 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
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 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)
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 2 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @orizi)
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, 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.
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, 5 unresolved discussions (waiting on @liorgold2)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r1 (raw file):
Previously, liorgold2 wrote…
I guess this appears in the libfunc as well, so I prefer to have it defined once, in a starknet module and not here.
Done.
c7d7e1e
to
df56776
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 all commit messages.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions
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 r2.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @orizi)
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 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r2 (raw file):
return validate_const_nz_data(context, &inner_type_info, inner_data); } let type_range = if *inner_generic_id == ContractAddressType::id() {
Why these cases are not in from_type_info
Code quote:
let type_range = if *inner_generic_id == ContractAddressType::id() {
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 @shaharsamocha7)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r2 (raw file):
Previously, shaharsamocha7 wrote…
Why these cases are not in from_type_info
they'd be considered a valid BoundedInt in that case, and this is probably bad.
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 @shaharsamocha7)
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 @orizi)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r2 (raw file):
Previously, orizi wrote…
they'd be considered a valid BoundedInt in that case, and this is probably bad.
you also have bytes31 there.
Unblocking
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: complete! all files reviewed, all discussions resolved (waiting on @orizi)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r2 (raw file):
Previously, shaharsamocha7 wrote…
you also have bytes31 there.
Unblocking
I consider Bytes31 as u248, more than i consider ContractAddress and ClassHash as u251.
No description provided.