-
Notifications
You must be signed in to change notification settings - Fork 26
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
refactor: feature contracts to use native together with casm #1455
Conversation
20a94f3
to
a0aef94
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1455 +/- ##
===========================================
+ Coverage 40.10% 68.91% +28.81%
===========================================
Files 26 105 +79
Lines 1895 13687 +11792
Branches 1895 13687 +11792
===========================================
+ Hits 760 9433 +8673
- Misses 1100 3851 +2751
- Partials 35 403 +368 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
dd2bc78
to
2bfec09
Compare
8b9e3b3
to
ba03f27
Compare
c728762
to
4cf52c8
Compare
215d8dd
to
86fcfd5
Compare
Artifacts upload triggered. View details here |
86fcfd5
to
4839720
Compare
Artifacts upload triggered. View details here |
20a94f3
to
bf0b41c
Compare
Artifacts upload triggered. View details here |
a00994e
to
e2c9fe8
Compare
d0aca03
to
bf0b41c
Compare
6815d18
to
a3166cf
Compare
c50e8c7
to
7166b97
Compare
Artifacts upload triggered. View details here |
a3166cf
to
eb637b2
Compare
2acc000
to
9da70d6
Compare
Artifacts upload triggered. View details here |
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 3 files at r16, all commit messages.
Reviewable status: 19 of 20 files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @noaov1, and @varex83)
crates/blockifier/src/test_utils/cairo_compile.rs
line 213 at r16 (raw file):
// remove the file manually to continue. // """ static GIT_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
@dorimedini-starkware WDYT?
Code quote:
static GIT_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
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 3 files at r16, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1 and @varex83)
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 @meship-starkware, @noaov1, and @varex83)
crates/blockifier/src/test_utils/cairo_compile.rs
line 213 at r16 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
@dorimedini-starkware WDYT?
can you explain why this is needed? not sure it's a good idea (let's chat)
crates/blockifier/src/test_utils.rs
line 88 at r16 (raw file):
} } }
I don't think you really need this... and converting 2
to Native
is non-intuitive
Code quote:
impl From<isize> for CairoVersion {
fn from(value: isize) -> Self {
match value {
0 => Self::Cairo0,
1 => Self::Cairo1,
#[cfg(feature = "cairo_native")]
2 => Self::Native,
_ => panic!("Invalid value for CairoVersion: {}", value),
}
}
}
crates/blockifier/src/test_utils/contracts.rs
line 120 at r16 (raw file):
/// /// This order is defined in [CairoVersion] enum. fn supported_versions(&self) -> u32 {
please use more explicit typing...
Suggestion:
HashSet<CairoVersion>
crates/blockifier/src/test_utils/contracts.rs
line 333 at r16 (raw file):
#[cfg(feature = "cairo_native")] CairoVersion::Native => "_sierra", },
Suggestion:
"feature_contracts/cairo{}/{}{}.json",
match cairo_version {
CairoVersion::Cairo0 => "0/compiled",
CairoVersion::Cairo1 => "1/compiled_casm",
#[cfg(feature = "cairo_native")]
CairoVersion::Native => "1/compiled_sierra",
},
crates/blockifier/src/test_utils/contracts.rs
line 460 at r16 (raw file):
.into_iter() } })
refactor: just iterate over supported versions and add the different variants (see above, supported_versions should return a set of versions, not a u32)
Code quote:
Self::iter().flat_map(|contract| {
// If only one supported version exists, add the contract to the array as is.
if contract.supported_versions().is_power_of_two() {
vec![contract].into_iter()
} else {
let supported_versions = contract.supported_versions();
#[cfg(feature = "cairo_native")]
let range = 0..3isize;
#[cfg(not(feature = "cairo_native"))]
let range = 0..2isize;
// If multiple supported versions exist, add each supported version of the
// contract to the array.
range
.filter(|i| supported_versions & (1u32 << i) != 0)
.map(move |i| {
let mut contract = contract;
contract.set_cairo_version(CairoVersion::from(i));
contract
})
.collect::<Vec<_>>()
.into_iter()
}
})
9da70d6
to
060a784
Compare
Artifacts upload triggered. View details here |
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 8 files at r17, all commit messages.
Reviewable status: 17 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, @noaov1, and @varex83)
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 8 files at r17, all commit messages.
Reviewable status: 18 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @noaov1, and @varex83)
Previously, dorimedini-starkware wrote…
As far as I understood, CI errors may appear when running git commands in the function |
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: 18 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, @noaov1, and @varex83)
crates/blockifier/src/test_utils/cairo_compile.rs
line 213 at r16 (raw file):
Previously, avi-starkware wrote…
As far as I understood, CI errors may appear when running git commands in the function
prepare_cairo1_compiler_deps
because it is run concurrently in tests, causing a race condition on theindex.lock
file.
who runs it concurrently?
there is an open task to do this, it is not simple for this reason.
we do not want to parallelize blindly.
different cairo1 compiler versions used should be checked out sequentially, so we don't build the same tag multiple times.
when parallelizing, we should group compile jobs by compiler version, and execute groups sequentially,
or checkout different copies of the compiler repo (worktrees?) to be able to compile different versions in parallel
Previously, dorimedini-starkware wrote…
I think it is used in multiple tests and |
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: 18 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, @noaov1, and @varex83)
crates/blockifier/src/test_utils/cairo_compile.rs
line 213 at r16 (raw file):
Previously, avi-starkware wrote…
I think it is used in multiple tests and
cargo test
runs these tests concurrently in the CI
then this is new.
since when do multiple tests recompile?
this is not intended, and if it is done, the cairo repo should be explicitly checked out to a different directory
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: 18 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, @noaov1, and @varex83)
crates/blockifier/src/test_utils/cairo_compile.rs
line 213 at r16 (raw file):
Previously, dorimedini-starkware wrote…
then this is new.
since when do multiple tests recompile?
this is not intended, and if it is done, the cairo repo should be explicitly checked out to a different directory
or, implement "smart" parallelization...
waiting for a lock is not a good solution, we will end up recompiling the same compiler tag multiple times
060a784
to
0d99611
Compare
Artifacts upload triggered. View details here |
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 1 files at r18, all commit messages.
Reviewable status: 18 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @noaov1, and @varex83)
0d99611
to
e83dcd7
Compare
Artifacts upload triggered. View details here |
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.
Can we avoid the extra casm compilation here?
Reviewed 2 of 15 files at r9, 1 of 13 files at r13, 4 of 8 files at r17, 1 of 1 files at r18, all commit messages.
Reviewable status: 17 of 20 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, @noaov1, and @varex83)
e83dcd7
to
e70e320
Compare
Artifacts upload triggered. View details here |
e70e320
to
b80eda2
Compare
Artifacts upload triggered. View details here |
Closing PR since a bigger rework is required which will include this fix as part of it |
No description provided.