-
Notifications
You must be signed in to change notification settings - Fork 30
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
chore: wrap cairo lang version id for code dedup #83
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @ArniStarkware and the rest of your teammates on Graphite |
f4e1e45
to
6513dc1
Compare
Why don't we use the type directly from Cairo? |
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: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @Yael-Starkware and @yair-starkware)
a discussion (no related file):
Previously, yair-starkware (Yair) wrote…
Why don't we use the type directly from Cairo?
The issue is that Cairo-lang does not implement Serialize
and Deserialize.
We define a wrapper that will have the required functionality.
crates/gateway/src/compiler_version.rs
line 22 at r1 (raw file):
#[derive(Clone, Copy, Debug, PartialEq)] pub struct VersionId(pub CairoLangVersionId);
@yair-starkware Your question is about this line.
The issue is that Cairo-lang does not implement Serialize
and Deserialize.
We define a wrapper that will have the required functionality.
Code quote:
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct VersionId(pub CairoLangVersionId);
6513dc1
to
37bed1e
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 4 of 5 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)
37bed1e
to
82f73f8
Compare
Previously, ArniStarkware (Arnon Hod) wrote…
+reviewer:@elintul |
ae82e5b
to
4a9a9a1
Compare
I reordered the PRs. This struct offers additional functionality for serialization as this object is used for configuration. |
23f9e9a
to
f89b7dc
Compare
4a9a9a1
to
b38f02f
Compare
f89b7dc
to
8189e02
Compare
b38f02f
to
050b7b4
Compare
8189e02
to
a5f2ac3
Compare
4f163f1
to
c5367e3
Compare
5e941e5
to
2e651a8
Compare
c5367e3
to
cee6c24
Compare
2e651a8
to
5b652d5
Compare
cee6c24
to
f92adc2
Compare
5b652d5
to
c72b5d4
Compare
c72b5d4
to
e5a33dd
Compare
Open a PR in compilers for them to implement serialization/deserialization on Version Id. |
e5a33dd
to
6b9b5a5
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: 0 of 5 files reviewed, all discussions resolved (waiting on @elintul, @Yael-Starkware, and @yair-starkware)
a discussion (no related file):
Previously, ArniStarkware (Arnon Hod) wrote…
Open a PR in compilers for them to implement serialization/deserialization on Version Id.
Done.
6b9b5a5
to
71fd727
Compare
@yair-starkware - You already said - we should remove the Code quote: safe_slice(&sierra_program, 0..6).map_err(|_| VersionIdError::InvalidVersion {
message: format!("Sierra program is too short."), |
2ba5a8a
to
97f3e51
Compare
Previously, ArniStarkware (Arnon Hod) wrote…
Not sure what you mean, but maybe the error should be: "Couldn't get version from the program - program too short (expecting at least 6 felts, got {}." |
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 5 files at r4, 1 of 2 files at r5, 1 of 3 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware, @elintul, and @Yael-Starkware)
crates/gateway/src/stateless_transaction_validator_test.rs
line 34 at r7 (raw file):
static MIN_SIERRA_VERSION: OnceLock<VersionId> = OnceLock::new(); MIN_SIERRA_VERSION.get_or_init(|| VersionId::new(1, 1, 0)) }
Can you use LazyLock instead of OnceLock?
https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
Code quote:
fn min_sierra_version() -> &'static VersionId {
static MIN_SIERRA_VERSION: OnceLock<VersionId> = OnceLock::new();
MIN_SIERRA_VERSION.get_or_init(|| VersionId::new(1, 1, 0))
}
crates/gateway/src/utils.rs
line 168 at r7 (raw file):
// TODO(Arni): Move this to a more general location. pub fn safe_slice<T, R>(slice: &[T], range: R) -> Result<&[T], ()>
Why not to use get?
https://doc.rust-lang.org/stable/std/primitive.slice.html#method.get
97f3e51
to
22f89d8
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 6 files reviewed, 2 unresolved discussions (waiting on @elintul, @Yael-Starkware, and @yair-starkware)
crates/gateway/src/compiler_version.rs
line 44 at r6 (raw file):
Previously, yair-starkware (Yair) wrote…
Not sure what you mean, but maybe the error should be: "Couldn't get version from the program - program too short (expecting at least 6 felts, got {}."
I used ChatGPT for phrasing.
Done.
crates/gateway/src/stateless_transaction_validator_test.rs
line 34 at r7 (raw file):
Previously, yair-starkware (Yair) wrote…
Can you use LazyLock instead of OnceLock?
https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
The compiler tells me: error[E0658]: use of unstable library feature 'lazy_cell'
.
crates/gateway/src/utils.rs
line 168 at r7 (raw file):
Previously, yair-starkware (Yair) wrote…
Why not to use get?
https://doc.rust-lang.org/stable/std/primitive.slice.html#method.get
Done.
22f89d8
to
8574bb6
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 5 of 5 files at r8, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)
Pull Request type
Please check the type of change your PR introduces:
What is the current behavior?
There is code duplication between Cairo-Lang's version ID and the gateway's version ID.
What is the new behavior?
Does this introduce a breaking change?
Other information
This change is