-
Notifications
You must be signed in to change notification settings - Fork 35
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(cairo_native): update native version #3986
base: main-v0.13.4
Are you sure you want to change the base?
Conversation
860e922
to
8f79ffb
Compare
Benchmark movements: |
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 6 of 9 files at r1, 1 of 2 files at r2, all commit messages.
Reviewable status: 7 of 9 files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
crates/bin/starknet-native-compile/src/main.rs
line 34 at r2 (raw file):
.into_iter() .map(|felt| felt.value) .collect::<Vec<_>>();
Isn't the sierra program of type Vec<BigUintAsHex>
? 🤔
Consider sharing code with this.
Code quote:
let raw_sierra_program = contract_class
.sierra_program
.clone()
.into_iter()
.map(|felt| felt.value)
.collect::<Vec<_>>();
crates/bin/starknet-native-compile/src/main.rs
line 35 at r2 (raw file):
.map(|felt| felt.value) .collect::<Vec<_>>(); let sierra_version = get_sierra_verizon_from_program(&raw_sierra_program);
Consider using extract_from_program
and converting the result.
Code quote:
let sierra_version = get_sierra_verizon_from_program(&raw_sierra_program);
crates/bin/starknet-native-compile/src/main.rs
line 37 at r2 (raw file):
let sierra_version = get_sierra_verizon_from_program(&raw_sierra_program); for _ in 0..N_RETRIES {
When do we expect it to fail?
I see in cairo native documentation that if it fails we should use AotContractExecutor::from_path
.
Code quote:
for _ in 0..N_RETRIES {
crates/starknet_api/src/contract_class.rs
line 36 at r2 (raw file):
fn u64_to_usize(val: u64) -> usize { val.try_into().expect("Failed to convert u64 version tag to usize.") }
See here. Consider extracting it to a utils crate.
Code quote:
fn u64_to_usize(val: u64) -> usize {
val.try_into().expect("Failed to convert u64 version tag to usize.")
}
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 9 files at r1, 1 of 2 files at r2.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
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 9 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/bin/starknet-native-compile/src/main.rs
line 34 at r2 (raw file):
Previously, noaov1 (Noa Oved) wrote…
Isn't the sierra program of type
Vec<BigUintAsHex>
? 🤔
Consider sharing code with this.
I can, but again we dont want this create to be dependent on starknet_api and I think that for our dependency
crates/bin/starknet-native-compile/src/main.rs
line 35 at r2 (raw file):
Previously, noaov1 (Noa Oved) wrote…
Consider using
extract_from_program
and converting the result.
@avi-starkware does not want the compilation crate to be dependent on starknet API, and I think that for our dependency tree starknet API shouldn't be dependent on the compilation crate
crates/bin/starknet-native-compile/src/main.rs
line 37 at r2 (raw file):
Previously, noaov1 (Noa Oved) wrote…
When do we expect it to fail?
I see in cairo native documentation that if it fails we should useAotContractExecutor::from_path
.
That might make sense becuse it fails when we are trying to create a compiled native for the same file
7892e64
to
29e0c58
Compare
Benchmark movements: |
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: 8 of 9 files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/starknet_api/src/contract_class.rs
line 36 at r2 (raw file):
Previously, noaov1 (Noa Oved) wrote…
See here. Consider extracting it to a utils crate.
Oh, the implementation I found returned an error I will extract it to a util in a separate PR
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: 8 of 9 files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/bin/starknet-native-compile/src/main.rs
line 34 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
I can, but again we dont want this create to be dependent on starknet_api and I think that for our dependency
it was cut in the middle I think that for our dependency tee straknet API shouldn't be dependent on our compilation crate
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: 8 of 9 files reviewed, 5 unresolved discussions (waiting on @meship-starkware and @noaov1)
crates/bin/starknet-native-compile/src/main.rs
line 34 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
I can, but again we dont want this create to be dependent on starknet_api and I think that for our dependency
@noaov1 I suggested not sharing code here. I don't think we should introduce dependencies to crates in our workspace from this crate. This crate should be seen as an extension of the cairo_native
repo.
crates/bin/starknet-native-compile/src/utils.rs
line 8 at r3 (raw file):
use cairo_lang_starknet_classes::contract_class::ContractClass; pub(crate) fn get_sierra_verizon_from_program<F>(sierra_program: &[F]) -> VersionId
Suggestion:
get_sierra_version_from_program
Previously, avi-starkware (Avi Cohen) wrote…
@meshi why not put this step inside the util function? (i.e., make it |
I discussed this with yoni yesterday and he said we shoul simpy panic if we get Code quote: for _ in 0..N_RETRIES {
if contract_executor.is_some() {
break;
}
eprintln!("Failed to take lock on path {} . Retrying...", output.display());
contract_executor = AotContractExecutor::from_path(&output).unwrap_or_else(|err| {
eprintln!("Error deserializing Sierra file into contract class: {}.", err);
process::exit(1);
});
}
} |
Previously, avi-starkware (Avi Cohen) wrote…
Actually, we can just make |
2ac74a3
to
8a2caa2
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: 7 of 9 files reviewed, 6 unresolved discussions (waiting on @avi-starkware, @meshi, and @noaov1)
crates/bin/starknet-native-compile/src/main.rs
line 34 at r2 (raw file):
Previously, avi-starkware (Avi Cohen) wrote…
Actually, we can just make
load_sierra_program_from_file
return the sierra version in addition to the contract class and sierra program
Done.
crates/bin/starknet-native-compile/src/main.rs
line 59 at r3 (raw file):
Previously, avi-starkware (Avi Cohen) wrote…
I discussed this with yoni yesterday and he said we shoul simpy panic if we get
None
, since we don't expect this behavior to happen and this indicates a bug. We shouldn't retry blindly.
Done.
crates/bin/starknet-native-compile/src/utils.rs
line 8 at r3 (raw file):
use cairo_lang_starknet_classes::contract_class::ContractClass; pub(crate) fn get_sierra_verizon_from_program<F>(sierra_program: &[F]) -> VersionId
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.
Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
crates/bin/starknet-native-compile/src/main.rs
line 59 at r3 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Done.
Yes..
crates/starknet_api/src/contract_class.rs
line 36 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Oh, the implementation I found returned an error I will extract it to a util in a separate PR
I'm confused. The implantation I am referring to is:
Code snippet:
pub fn u64_from_usize(val: usize) -> u64 {
val.try_into().expect("Conversion from usize to u64 should not fail.")
}
crates/bin/starknet-native-compile/src/utils.rs
line 35 at r4 (raw file):
.unwrap_or_else(|_| { eprintln!("Error parsing Sierra program to Sierra version"); process::exit(1);
Do we have to explicitly call it? What will happen if we simply panic?
Code quote:
process::exit(1);
crates/bin/starknet-native-compile/src/utils.rs
line 60 at r4 (raw file):
.into_iter() .map(|felt| felt.value) .collect::<Vec<_>>();
Can this done inside get_sierra_version_from_program
?
Suggestion:
let raw_sierra_program = contract_class
.sierra_program
.into_iter()
.map(|big_uint_as_hex| big_uint_as_hex.value)
.collect(),
8a2caa2
to
d75b93e
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: 8 of 10 files reviewed, 5 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/bin/starknet-native-compile/src/utils.rs
line 35 at r4 (raw file):
Previously, noaov1 (Noa Oved) wrote…
Do we have to explicitly call it? What will happen if we simply panic?
it's a different process so I think the error might appear in the main process if we simply panic @avi-starkware might know better
crates/bin/starknet-native-compile/src/utils.rs
line 60 at r4 (raw file):
Previously, noaov1 (Noa Oved) wrote…
Can this done inside
get_sierra_version_from_program
?
Done.
crates/starknet_api/src/contract_class.rs
line 36 at r2 (raw file):
Previously, noaov1 (Noa Oved) wrote…
I'm confused. The implantation I am referring to is:
Yes, I just think that if every place that uses u64_from_usize will use a different path, it might be a big change, so I rather do it in a different PR. I just saw a different implementation for u64_from_usize
d75b93e
to
20ea253
Compare
Previously, meship-starkware (Meshi Peled) wrote…
I don't think I checked this very thoroughly. The difference is that |
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: 7 of 10 files reviewed, 5 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/starknet_api/src/contract_class.rs
line 36 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Yes, I just think that if every place that uses u64_from_usize will use a different path, it might be a big change, so I rather do it in a different PR. I just saw a different implementation for u64_from_usize
This is the other way around. I added a todo to share this code
d571715
to
5438a76
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 2 of 2 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
crates/bin/starknet-native-compile/src/utils.rs
line 35 at r4 (raw file):
What do we do when compiling to casm?
panic!
causes unwinds the stack before terminating the process.
Is it bad?
5438a76
to
f6ba026
Compare
Previously, noaov1 (Noa Oved) wrote…
I looked into it. The idiomatic approach to handle errors in the CLI is to return result (rust knows how to convert the result to a nice error in a CLI). Moreover, using Using panic is not a best practice because it includes an unhelpful stack trace. |
f6ba026
to
c3d2c27
Compare
No description provided.