-
Notifications
You must be signed in to change notification settings - Fork 65
blockifier: test L3 compatability in syscalls #7816
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Artifacts upload workflows: |
Yoni-Starkware
left a comment
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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 136 at r1 (raw file):
BlockContext { chain_info: chain_info.clone(), ..BlockContext::create_for_testing() }; let invalid_to_address = felt!("0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
Please choose a tight value (+1 the limit).
Code quote:
felt!("0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 156 at r1 (raw file):
let result = entry_point_call.execute_directly_given_block_context(&mut state, block_context); assert!(result.is_ok(), "Expected execution to succeed on L3 chain"); }
Please join these two into a single test, to save code duplication.
Add a variable is_l3 and check th expected result according to it
Code quote:
#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native; "Native"))]
#[test_case(RunnableCairo1::Casm; "VM")]
fn test_send_message_to_l1_invalid_address(runnable_version: RunnableCairo1) {
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
let chain_info = &ChainInfo::create_for_testing();
let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1)]);
let invalid_to_address = felt!("0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
let payload = vec![felt!(2019_u16), felt!(2020_u16)];
let calldata = Calldata(
concat(vec![
vec![
invalid_to_address,
felt!(u64::try_from(payload.len()).expect("Failed to convert usize to u64.")),
],
payload.clone(),
])
.into(),
);
let entry_point_call = CallEntryPoint {
entry_point_selector: selector_from_name("test_send_message_to_l1"),
calldata,
..trivial_external_entry_point_new(test_contract)
};
let result = entry_point_call.execute_directly(&mut state);
assert!(result.is_err(), "Expected execution to fail with invalid address");
// Verify the error is related to address format
let error = result.unwrap_err();
let error_string = error.to_string();
assert!(
error_string.contains("Out of range"),
"Expected error containing 'Out of range', got: {}",
error_string
);
}
#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native; "Native"))]
#[test_case(RunnableCairo1::Casm; "VM")]
fn test_send_message_to_l1_l3_address(runnable_version: RunnableCairo1) {
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
let mut chain_info = ChainInfo::create_for_testing();
chain_info.is_l3 = true;
let mut state = test_state(&chain_info, BALANCE, &[(test_contract, 1)]);
let block_context =
BlockContext { chain_info: chain_info.clone(), ..BlockContext::create_for_testing() };
let invalid_to_address = felt!("0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
let payload = vec![felt!(2019_u16), felt!(2020_u16)];
let calldata = Calldata(
concat(vec![
vec![
invalid_to_address,
felt!(u64::try_from(payload.len()).expect("Failed to convert usize to u64.")),
],
payload.clone(),
])
.into(),
);
let entry_point_call = CallEntryPoint {
entry_point_selector: selector_from_name("test_send_message_to_l1"),
calldata,
..trivial_external_entry_point_new(test_contract)
};
let result = entry_point_call.execute_directly_given_block_context(&mut state, block_context);
assert!(result.is_ok(), "Expected execution to succeed on L3 chain");
}
Yoni-Starkware
left a comment
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 2 files reviewed, 2 unresolved discussions (waiting on @einat-starkware and @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 156 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Please join these two into a single test, to save code duplication.
Add a variableis_l3and check th expected result according to it
Same re the deprecated test
9563356 to
a041516
Compare
920da05 to
9990172
Compare
einat-starkware
left a comment
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 2 files reviewed, 2 unresolved discussions (waiting on @noaov1 and @Yoni-Starkware)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 136 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Please choose a tight value (+1 the limit).
Done.
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 156 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Same re the deprecated test
Done.
Yoni-Starkware
left a comment
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: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native, true; "Native-L3"))] #[test_case(RunnableCairo1::Casm, true; "VM-L3")] fn test_send_message_to_l1_invalid_address(runnable_version: RunnableCairo1, is_l3: bool) {
Nice syntax for simple cases
Same in deprecated test
Suggestion:
#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native; "Native"))]
#[test_case(RunnableCairo1::Casm; "VM")]
fn test_send_message_to_l1_invalid_address(runnable_version: RunnableCairo1, #[values(true, false)] is_l3: bool) {crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 121 at r2 (raw file):
} else { entry_point_call.execute_directly(&mut state) };
Simpler, and does not rely on the implicit default value of block context
Same in deprecated test
Suggestion:
let block_context =
BlockContext { chain_info: chain_info.clone(), ..BlockContext::create_for_testing();
let result = entry_point_call.execute_directly_given_block_context(&mut state, block_context);a041516 to
210ac7b
Compare
einat-starkware
left a comment
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 2 files reviewed, 1 unresolved discussion (waiting on @noaov1 and @Yoni-Starkware)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Nice syntax for simple cases
Same in deprecated test
Changed in the deprecated syscall but not here - it combines two different packages for testing and I couldn't get it to compile without explicitly defining the 4 test cases like before.
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 121 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Simpler, and does not rely on the implicit default value of block context
Same in deprecated test
Done both here and in the deprecated syscall :)
Yoni-Starkware
left a comment
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 r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @einat-starkware and @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, einat-starkware wrote…
Changed in the deprecated syscall but not here - it combines two different packages for testing and I couldn't get it to compile without explicitly defining the 4 test cases like before.
Try:
[rstest]
#[cfg_attr(feature = "cairo_native", case(RunnableCairo1::Native; "Native"))]
#[case(RunnableCairo1::Casm; "VM")]
fn test_send_message_to_l1_invalid_address(#[case] runnable_version: RunnableCairo1, #[values(true, false)] is_l3: bool) {
einat-starkware
left a comment
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 @noaov1 and @Yoni-Starkware)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Try:
[rstest] #[cfg_attr(feature = "cairo_native", case(RunnableCairo1::Native; "Native"))] #[case(RunnableCairo1::Casm; "VM")] fn test_send_message_to_l1_invalid_address(#[case] runnable_version: RunnableCairo1, #[values(true, false)] is_l3: bool) {
Still didn't work unfortunately :/
Yoni-Starkware
left a comment
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 @einat-starkware and @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, einat-starkware wrote…
Still didn't work unfortunately :/
Checking
Yoni-Starkware
left a comment
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 @einat-starkware and @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Checking
#[rstest]
#[cfg_attr(feature = "cairo_native", case::native(RunnableCairo1::Native))]
#[case::vm(RunnableCairo1::Casm)]
fn test_send_message_to_l1_invalid_address(
#[case] runnable_version: RunnableCairo1,
#[values(true, false)] is_l3: bool,
) {
Yoni-Starkware
left a comment
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, 2 unresolved discussions (waiting on @einat-starkware and @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 97 at r3 (raw file):
let mut state = test_state(&chain_info, BALANCE, &[(test_contract, 1)]); let invalid_to_address = felt!("0x100000000000000000000000000000000000000001");
Not tight :)
Code quote:
felt!("0x100000000000000000000000000000000000000001")9990172 to
6e4c317
Compare
210ac7b to
776b9e9
Compare
Yoni-Starkware
left a comment
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:complete! all files reviewed, all discussions resolved (waiting on @noaov1)
einat-starkware
left a comment
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 @noaov1)
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 91 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
#[rstest] #[cfg_attr(feature = "cairo_native", case::native(RunnableCairo1::Native))] #[case::vm(RunnableCairo1::Casm)] fn test_send_message_to_l1_invalid_address( #[case] runnable_version: RunnableCairo1, #[values(true, false)] is_l3: bool, ) {
Done.
crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs line 97 at r3 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Not tight :)
Oh oops, added an extra digit, should be good now.
6e4c317 to
7eb420d
Compare
776b9e9 to
34f3008
Compare
Yoni-Starkware
left a comment
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 @noaov1)

No description provided.