Skip to content

Conversation

@einat-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

einat-starkware commented Jul 7, 2025

@einat-starkware einat-starkware marked this pull request as ready for review July 7, 2025 10:27
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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");
}

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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 variable is_l3 and check th expected result according to it

Same re the deprecated test

@einat-starkware einat-starkware force-pushed the einat/test_L3_compatability branch from 9563356 to a041516 Compare July 8, 2025 14:04
Copy link
Contributor Author

@einat-starkware einat-starkware left a 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.

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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);

@einat-starkware einat-starkware force-pushed the einat/test_L3_compatability branch from a041516 to 210ac7b Compare July 9, 2025 06:12
Copy link
Contributor Author

@einat-starkware einat-starkware left a 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 :)

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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) {

Copy link
Contributor Author

@einat-starkware einat-starkware left a 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 :/

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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,
) {

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a 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")

@einat-starkware einat-starkware changed the base branch from einat/add_l1_address to graphite-base/7816 July 9, 2025 07:07
@einat-starkware einat-starkware force-pushed the einat/test_L3_compatability branch from 210ac7b to 776b9e9 Compare July 9, 2025 07:28
@einat-starkware einat-starkware changed the base branch from graphite-base/7816 to einat/add_l1_address July 9, 2025 07:28
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

Copy link
Contributor Author

@einat-starkware einat-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: 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.

@einat-starkware einat-starkware changed the base branch from einat/add_l1_address to graphite-base/7816 July 9, 2025 08:19
@einat-starkware einat-starkware force-pushed the einat/test_L3_compatability branch from 776b9e9 to 34f3008 Compare July 9, 2025 08:19
@einat-starkware einat-starkware changed the base branch from graphite-base/7816 to main July 9, 2025 08:19
@einat-starkware einat-starkware enabled auto-merge July 9, 2025 08:23
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

@einat-starkware einat-starkware added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit 3b978f2 Jul 9, 2025
20 of 58 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2025
@einat-starkware einat-starkware deleted the einat/test_L3_compatability branch July 15, 2025 08:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants