-
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
test(blockifier): parametrize feature contracts and tests by runnable type #2344
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
449ed3d
to
0fc5731
Compare
96f1aea
to
b32d82d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2344 +/- ##
==========================================
+ Coverage 40.10% 49.59% +9.49%
==========================================
Files 26 291 +265
Lines 1895 32936 +31041
Branches 1895 32936 +31041
==========================================
+ Hits 760 16336 +15576
- Misses 1100 15505 +14405
- Partials 35 1095 +1060 ☔ View full report in Codecov by Sentry. |
b32d82d
to
34d67ed
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 45 files reviewed, all discussions resolved
a discussion (no related file):
This PR will not get in until native compiled contracts exist in our test framework (and even then may indicate more required work).
What was done here:
- Created a RunnableContractVersion enum for the FeatureContracts variants.
- Stopped using CairoVersion for FeatureContracts variants (and removed native variant in the next PR)
- Updated test utils that construct feature contracts to accept the new enum instead of CairoVersion
- Updated and parametrized tests (or marked with TODOs to parametrize).
- Note that parametrization creates a lot of boilerplate, e.g:
#[rstest]
fn test(#[values(Cairo0, Cairo1)] cairo_version)
now becomes
#[rstest]
#[case(Cairo0)]
#[case(Cairo1Casm)]
#[cfg_attr(feature = "cairo_native", case(Cairo1Native))]
fn test(#[case] cairo_version, #[case] some_bool)
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 9 of 44 files at r1, 35 of 36 files at r2, all commit messages.
Reviewable status: 44 of 45 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/test_utils/transfers_generator.rs
line 12 at r2 (raw file):
use starknet_types_core::felt::Felt; use super::contracts::RunnableContractVersion;
Please Avoid using super
Code quote:
use super::contracts::RunnableContractVersion;
crates/blockifier/src/concurrency/worker_logic_test.rs
line 535 at r2 (raw file):
#[cfg_attr( feature = "cairo_native", case::declare_cairo1(RunnableContractVersion::Cairo1Casm, TransactionVersion::THREE)
Shouldn't it be native?
Code quote:
case::declare_cairo1(RunnableContractVersion::Cairo1Casm
crates/blockifier/src/execution/stack_trace_test.rs
line 289 at r2 (raw file):
"fail", "0x6661696c ('fail')", (0_u16, 0_u16)) )]
Note to self: see if it makes the NM stack_trace test PR irrelevant.
Code quote:
"invoke_call_chain",
"0x4469766973696f6e2062792030 ('Division by 0')", (0_u16, 0_u16))
)]
#[cfg_attr(feature = "cairo_native", case(
RunnableContractVersion::Cairo1Native,
"fail",
"0x6661696c ('fail')", (0_u16, 0_u16))
)]
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: 44 of 45 files reviewed, 3 unresolved discussions (waiting on @meship-starkware)
crates/blockifier/src/concurrency/worker_logic_test.rs
line 535 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Shouldn't it be native?
whoops! done, thanks
crates/blockifier/src/test_utils/transfers_generator.rs
line 12 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Please Avoid using super
Done.
34d67ed
to
e3deb79
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 r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware)
43aab81
to
29115d1
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: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @dorimedini-starkware)
crates/blockifier/src/execution/stack_trace_test.rs
line 289 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Note to self: see if it makes the NM stack_trace test PR irrelevant.
The answer is no, but there will be merge conflicts.
https://reviewable.io/reviews/starkware-libs/sequencer/2164#-
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 (commit messages unreviewed), 5 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/test_utils/contracts.rs
line 104 at r4 (raw file):
Self::Cairo0 } }
Why is the default cairo0? I Would have chosen Cairo1Casm as the default.
Code quote:
impl Default for RunnableContractVersion {
fn default() -> Self {
Self::Cairo0
}
}
crates/blockifier/src/test_utils/contracts.rs
line 118 at r4 (raw file):
panic!("Transaction version {:?} is not supported.", tx_version) } }
Will this support Native as well? If so, would we choose according to the Sierra version (after AvivY will add the Sierra to the declared TX)?
Code quote:
pub fn from_declare_tx_version(tx_version: TransactionVersion) -> Self {
if tx_version == TransactionVersion::ZERO || tx_version == TransactionVersion::ONE {
Self::Cairo0
} else if tx_version == TransactionVersion::TWO || tx_version == TransactionVersion::THREE {
Self::Cairo1Casm
} else {
panic!("Transaction version {:?} is not supported.", tx_version)
}
}
crates/blockifier/src/test_utils/contracts.rs
line 127 at r4 (raw file):
RunnableContractVersion::Cairo1Casm => Self::Cairo1, #[cfg(feature = "cairo_native")] RunnableContractVersion::Cairo1Native => Self::Native,
The intention is for Cairo1Native to also return to Cairo1, right? Do you wait until we can remove the cairo_native folder to do so?
Code quote:
RunnableContractVersion::Cairo0 => Self::Cairo0,
RunnableContractVersion::Cairo1Casm => Self::Cairo1,
#[cfg(feature = "cairo_native")]
RunnableContractVersion::Cairo1Native => Self::Native,
crates/blockifier/src/test_utils/contracts.rs
line 475 at r4 (raw file):
RunnableContractVersion::Cairo0, "Default version in iteration must be Cairo0 for this logic to be correct." );
Why? Because we only handle the cairo1 cases? Can't it be casm, and we will change the handling of casm to cairo0?
Code quote:
assert_eq!(
contract.runnable_contract_version(),
RunnableContractVersion::Cairo0,
"Default version in iteration must be Cairo0 for this logic to be correct."
);
29115d1
to
5e99ac5
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: all files reviewed (commit messages unreviewed), 2 unresolved discussions (waiting on @meship-starkware)
crates/blockifier/src/test_utils/contracts.rs
line 104 at r4 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Why is the default cairo0? I Would have chosen Cairo1Casm as the default.
because the default CairoVersion is Cairo0, I am being consistent
crates/blockifier/src/test_utils/contracts.rs
line 118 at r4 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Will this support Native as well? If so, would we choose according to the Sierra version (after AvivY will add the Sierra to the declared TX)?
I am assuming the difference between casm and native is irrelevant for declares... a declare declares sierra anyway
crates/blockifier/src/test_utils/contracts.rs
line 127 at r4 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
The intention is for Cairo1Native to also return to Cairo1, right? Do you wait until we can remove the cairo_native folder to do so?
yes, done here (next PR)
crates/blockifier/src/test_utils/contracts.rs
line 475 at r4 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Why? Because we only handle the cairo1 cases? Can't it be casm, and we will change the handling of casm to cairo0?
the logic of the has_all_runnable_versions
case is: add cairo1 and native instances.
if the original instance is not cairo0, this logic is incorrect.
want me to explicitly add the three contract versions here? that sounds better even, I can use EnumIter on RunnableContractVersion and I won't need the #[cfg]
here at all...
done
5e99ac5
to
d7f6041
Compare
No description provided.