Skip to content
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(blockifier): move test_stack_overflow from out_of_gas.rs to transaction_executor_test.rs #3515

Merged

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

avivg-starkware commented Jan 20, 2025

Copy link
Contributor

@meship-starkware meship-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 1 files reviewed, 1 unresolved discussion (waiting on @avivg-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 405 at r1 (raw file):

fn test_stack_overflow(
    #[case] initial_gas: u64,
    #[case] _gas_consumed: u64, // TODO (AvivG): Should check gas consumed?

Yes, this is an important part of the test. We want to see that it is close to the initial gas

Code quote:

#[case] _gas_consumed: u64, // TODO (AvivG): Should check gas consumed?

@meship-starkware meship-starkware force-pushed the meship/blockifier/change_stack_size branch from cb853f5 to 0617d3d Compare January 20, 2025 14:01
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 2 times, most recently from 4762b09 to 3b6254d Compare January 20, 2025 14:52
@meship-starkware meship-starkware force-pushed the meship/blockifier/change_stack_size branch 2 times, most recently from 416f160 to 0acadec Compare January 20, 2025 15:15
Copy link
Contributor

@meship-starkware meship-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 @avivg-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 440 at r1 (raw file):

        // let result = result.as_ref().unwrap();
        // assert!(result.is_reverted());
        Ok(execution_res) => execution_res.revert_error.clone().unwrap().to_string(),

When do we expect to get an error and not a reverted transaction?

Code quote:

        Err(execution_err) => execution_err.to_string(),
        // Reverted transaction, error info within revert_error.
        // TODO(AvivG): should check "is_reverted"?
        // let result = result.as_ref().unwrap();
        // assert!(result.is_reverted());
        Ok(execution_res) => execution_res.revert_error.clone().unwrap().to_string(),

Copy link
Contributor

@meship-starkware meship-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, 3 unresolved discussions (waiting on @avivg-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

    #[case] initial_gas: u64,
    #[case] _gas_consumed: u64, // TODO (AvivG): Should check gas consumed?
    #[values(CairoVersion::Cairo1(RunnableCairo1::Native))] cairo_version: CairoVersion,

Why? its only have one value I don't see a reason to add this. I don't think checking casm or cairo0 in this test would benefit us

Code quote:

 #[values(CairoVersion::Cairo1(RunnableCairo1::Native))] cairo_version: CairoVersion,

@avivg-starkware avivg-starkware force-pushed the meship/blockifier/change_stack_size branch from 0acadec to 0617d3d Compare January 20, 2025 15:55
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 2 times, most recently from f65be4a to a14dbd3 Compare January 20, 2025 17:15
Copy link
Contributor Author

@avivg-starkware avivg-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, 3 unresolved discussions (waiting on @meship-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 405 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Yes, this is an important part of the test. We want to see that it is close to the initial gas

Done.


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Why? its only have one value I don't see a reason to add this. I don't think checking casm or cairo0 in this test would benefit us

wanted to ask whether testing other values is needed. if this val is the only one needed - will remove


crates/blockifier/src/blockifier/transaction_executor_test.rs line 440 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

When do we expect to get an error and not a reverted transaction?

when resources aren't enough for validate

@meship-starkware meship-starkware force-pushed the meship/blockifier/change_stack_size branch 8 times, most recently from dbd0978 to 0e2a570 Compare January 21, 2025 14:11
Base automatically changed from meship/blockifier/change_stack_size to main-v0.13.4 January 21, 2025 15:04
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 2 times, most recently from f27522f to 7140ff9 Compare January 21, 2025 18:03
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 2 times, most recently from 4ae46bf to 006d508 Compare January 22, 2025 09:50
Copy link
Contributor

@meship-starkware meship-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 4 of 13 files at r4.
Reviewable status: 1 of 13 files reviewed, 1 unresolved discussion (waiting on @noaov1)

Copy link
Contributor

@meship-starkware meship-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: 1 of 13 files reviewed, 1 unresolved discussion (waiting on @noaov1)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

The problem with the stack only arises when running with native, but I think that in this state, the runnable version does not matter because it will be decided by the Sierra version. Now that I think about it, @noaov1, do we even run native in this case? What is the state reader?

It seems like we are using the DictStateReader, which cannot run native yet. Can we use the Papyrus State here and add Native to the contract_class_manager cache to make sure we are running in native? maybe we will have to move this test to the native blockifier tests

Copy link
Contributor

@meship-starkware meship-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: 1 of 13 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 437 at r5 (raw file):

    };
    print!("{}", resource_bounds.get_l2_bounds());
    // assert!(false);

Remove

Code quote:

    print!("{}", resource_bounds.get_l2_bounds());
    // assert!(false);

Copy link
Contributor

@meship-starkware meship-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: 1 of 13 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 4 times, most recently from 6ba358b to f7bc101 Compare January 22, 2025 15:44
Copy link
Contributor Author

@avivg-starkware avivg-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 15 files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

It seems like we are using the DictStateReader, which cannot run native yet. Can we use the Papyrus State here and add Native to the contract_class_manager cache to make sure we are running in native? maybe we will have to move this test to the native blockifier tests

I'm not sure I understand your intention regarding DictStateReader and Papyrus State, however I do think I can address your concern-
I added a print under native_entry_point_execution::execute_entry_point_call --> that was indeed outputted.
I also managed to reach stack overflow which (if i'm not mistaken -) confirms the use of Native.


crates/blockifier/src/blockifier/transaction_executor_test.rs line 437 at r5 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Remove

Done.

Copy link
Collaborator

@noaov1 noaov1 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 4 files at r6, all commit messages.
Reviewable status: 1 of 15 files reviewed, 5 unresolved discussions (waiting on @avivg-starkware and @meship-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

which cannot run native yet.

Why? If you set the native class in class_hash_to_class it will extract the native.


crates/blockifier/src/blockifier/transaction_executor_test.rs line 384 at r6 (raw file):

/// overflow.
///
/// Note: Testing the VM is unnecessary here as it does not utilize the stack.

Suggestion:

/// Note: Testing the VM is unnecessary here as it simulates the stack where the stack in the heap as a memory segment.

crates/blockifier/src/blockifier/transaction_executor_test.rs line 402 at r6 (raw file):

    let entry_point_args = vec![depth];
    let calldata = create_calldata(contract_address, "test_stack_overflow", &entry_point_args);
    let tx = executable_invoke_tx(invoke_tx_args! {

Suggestion:

let invoke_tx = executable_invoke_tx(invoke_tx_args! {

crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r6 (raw file):

        calldata,
        nonce: nonce_manager.next(account_address),
    });

Can you please make sure that the ls_max_amount is at least execute_max_sierra_gas + validate_max_sierra_gas?

Code quote:

    let tx = executable_invoke_tx(invoke_tx_args! {
        sender_address: account_address,
        calldata,
        nonce: nonce_manager.next(account_address),
    });

Copy link
Contributor

@meship-starkware meship-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: 1 of 15 files reviewed, 4 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

which cannot run native yet.

Why? If you set the native class in class_hash_to_class it will extract the native.

Oh I see when creating the state we use the get_runnable_version. So the runnable version is important and we only need to use native for now

Copy link
Contributor

@meship-starkware meship-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 3 of 4 files at r6, all commit messages.
Reviewable status: 4 of 15 files reviewed, 3 unresolved discussions (waiting on @avivg-starkware and @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch 2 times, most recently from b010ece to 2da3998 Compare January 27, 2025 11:03
Copy link
Contributor Author

@avivg-starkware avivg-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: 1 of 15 files reviewed, 1 unresolved discussion (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 406 at r6 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Can you please make sure that the ls_max_amount is at least execute_max_sierra_gas + validate_max_sierra_gas?

Done.


crates/blockifier/src/blockifier/transaction_executor_test.rs line 384 at r6 (raw file):

/// overflow.
///
/// Note: Testing the VM is unnecessary here as it does not utilize the stack.

Done


crates/blockifier/src/blockifier/transaction_executor_test.rs line 402 at r6 (raw file):

    let entry_point_args = vec![depth];
    let calldata = create_calldata(contract_address, "test_stack_overflow", &entry_point_args);
    let tx = executable_invoke_tx(invoke_tx_args! {

Done

Copy link
Collaborator

@noaov1 noaov1 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 3 of 14 files at r7, all commit messages.
Reviewable status: 4 of 15 files reviewed, all discussions resolved (waiting on @meship-starkware)

Copy link
Contributor Author

@avivg-starkware avivg-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 4 files at r6, 14 of 14 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

Copy link
Contributor

@meship-starkware meship-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 14 of 14 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

Copy link
Collaborator

@noaov1 noaov1 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 @avivg-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 395 at r7 (raw file):

    //      use crate::abi::constants::MAX_POSSIBLE_SIERRA_GAS;
    //      let os_constants = Arc::make_mut(&mut block_context.versioned_constants.os_constants);
    //      os_constants.execute_max_sierra_gas = MAX_POSSIBLE_SIERRA_GAS.into();

Please remove :)

Code quote:

    // TODO (AvivG): remove this comment:
    // To reach stack overflow, increase maximum gas by refactoring os_constants
    //      let mut block_context = BlockContext::create_for_account_testing();
    //      use std::sync::Arc;
    //      use crate::abi::constants::MAX_POSSIBLE_SIERRA_GAS;
    //      let os_constants = Arc::make_mut(&mut block_context.versioned_constants.os_constants);
    //      os_constants.execute_max_sierra_gas = MAX_POSSIBLE_SIERRA_GAS.into();

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_test_stack_overflow branch from 2da3998 to 85fe137 Compare January 27, 2025 14:55
@avivg-starkware
Copy link
Contributor Author

crates/blockifier/src/blockifier/transaction_executor_test.rs line 395 at r7 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Please remove :)

Done.

Copy link
Collaborator

@noaov1 noaov1 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 r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

@avivg-starkware avivg-starkware merged commit 9390153 into main-v0.13.4 Jan 27, 2025
11 checks passed
@avivg-starkware avivg-starkware deleted the avivg/blockifier/move_test_stack_overflow branch January 27, 2025 16:18
@avivg-starkware avivg-starkware restored the avivg/blockifier/move_test_stack_overflow branch January 27, 2025 16:18
@avivg-starkware avivg-starkware deleted the avivg/blockifier/move_test_stack_overflow branch January 28, 2025 15:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2025
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