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): test negative consumed gas #3005

Merged

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@avivg-starkware avivg-starkware marked this pull request as ready for review December 29, 2024 15:19
Copy link
Contributor Author

avivg-starkware commented Dec 29, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch 2 times, most recently from 1b51909 to 9d3f004 Compare January 1, 2025 10:07
@avivg-starkware avivg-starkware changed the base branch from main to main-v0.13.4 January 1, 2025 10:07
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch 2 times, most recently from bdd0ae2 to 46b555b Compare January 1, 2025 11:28
@avivg-starkware avivg-starkware changed the title chore(blockifier): test egative consumed gas chore(blockifier): test negative consumed gas Jan 1, 2025
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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avivg-starkware and @meship-starkware)


crates/blockifier/src/transaction/transactions_test.rs line 2889 at r1 (raw file):

#[case(RunnableCairo1::Casm)]
#[cfg_attr(feature = "cairo_native", case(RunnableCairo1::Native))]
fn test_empty_function_flow(#[case] runnable: RunnableCairo1) {

Maybe it's better to move this test to the call_contract.rs file.
WDYT?

Code quote:

fn test_empty_function_flow(#[case] runnable: RunnableCairo1) {

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


crates/blockifier/src/transaction/transactions_test.rs line 2902 at r1 (raw file):

    let calldata = create_calldata(
        test_contract_address,
        "empty_function",

Can you add it as a constant EMPTY_FUNCTION_SELECTOR

Code quote:

  "empty_function",

crates/blockifier/src/transaction/transactions_test.rs line 2912 at r1 (raw file):

    let execution_info = invoke_tx.execute(state, block_context).unwrap();
    println!("{:?}", execution_info);

Remove

Code quote:

 println!("{:?}", execution_info);

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch from 46b555b to d888817 Compare January 2, 2025 11:40
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: 3 of 5 files reviewed, 3 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/transaction/transactions_test.rs line 2889 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Maybe it's better to move this test to the call_contract.rs file.
WDYT?

Sounds good, Done


crates/blockifier/src/transaction/transactions_test.rs line 2902 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Can you add it as a constant EMPTY_FUNCTION_SELECTOR

not sure where to take this from.
I only found 2 mentions to this, but no definition. in both it's accessed through:
SecurityTestContract.EMPTY_FUNCTION_SELECTOR,

which is defined in a cairo file: security_test_contract.cairo

could you clarify your intention?


crates/blockifier/src/transaction/transactions_test.rs line 2912 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Remove

Done.

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 1 of 2 files at r2.
Reviewable status: 4 of 5 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/transaction/transactions_test.rs line 2902 at r1 (raw file):

Previously, avivg-starkware wrote…

not sure where to take this from.
I only found 2 mentions to this, but no definition. in both it's accessed through:
SecurityTestContract.EMPTY_FUNCTION_SELECTOR,

which is defined in a cairo file: security_test_contract.cairo

could you clarify your intention?

I meant to add a constant with the name EMPTY_FUNCTION_SELECTOR. If the transaction has a test utils, I would drop it there. If not, then just on top of the test file.

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 1 of 2 files at r2.
Reviewable status: all files reviewed (commit messages unreviewed), 2 unresolved discussions (waiting on @avivg-starkware and @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.

Reviewed all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @noaov1)

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 r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avivg-starkware)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 406 at r2 (raw file):

    let execution_info = invoke_tx.execute(state, block_context).unwrap();
    assert!(!execution_info.is_reverted());

No need the account transaction for this test.

Suggestion:

    let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable));
    let chain_info = &ChainInfo::create_for_testing();
    let state = &mut test_state(chain_info, BALANCE, &[(account_contract, 1), (test_contract, 1)]);
    let test_contract_address = test_contract.get_instance_address(0);
  
    let calldata = create_calldata(
        test_contract_address,
        "empty_function",
        &[], // Calldata.
    );
    let outer_entry_point_selector = selector_from_name("test_call_contract");
    let entry_point_call = CallEntryPoint {
        entry_point_selector: outer_entry_point_selector,
        calldata,
        ..trivial_external_entry_point_new(outer_contract)
    };

    assert_eq!(
        !entry_point_call.execute_directly(&mut state).unwrap().execution.failed,
    );

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch 3 times, most recently from bf92faa to 2c3b034 Compare January 5, 2025 13:50
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: 3 of 5 files reviewed, 1 unresolved discussion (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 406 at r2 (raw file):

Previously, noaov1 (Noa Oved) wrote…

No need the account transaction for this test.

Done.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch from 2c3b034 to 7a0aa5c Compare January 5, 2025 16:51
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 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/test_negative_consumed_gas branch from 7a0aa5c to 22b3112 Compare January 6, 2025 09:41
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 r1, 1 of 2 files at r3, 4 of 4 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

@avivg-starkware avivg-starkware merged commit 7ee6f4c into main-v0.13.4 Jan 6, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants