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): add a check on deploy syscall gas cost in the happ… #478

Merged

Conversation

meship-starkware
Copy link
Contributor

@meship-starkware meship-starkware commented Aug 15, 2024

…y flows of deploy tests


This change is Reviewable

Copy link
Contributor

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


crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 63 at r1 (raw file):

        deploy_constractor_call.execution,
        CallExecution { retdata: retdata![], gas_consumed: 0, ..CallExecution::default() }
    );

Btw, why do we even need to look at the call info of the constructor call? If it has 0 gas_consumed anyway, shouldn't we just remove this part?

Suggestion:

    // Note, this is the CallInfo of the constructor call. Meaning the CallExecution is the
    // execution of the constructor and not the deploy syscall.
    let deploy_constructor_call = &deploy_call.inner_calls[0];

    assert_eq!(deploy_constructor_call.call.storage_address, deployed_contract_address);
    assert_eq!(
        deploy_constructor_call.execution,
        CallExecution { retdata: retdata![], gas_consumed: 0, ..CallExecution::default() }
    );

crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 97 at r1 (raw file):

    deployer_contract: FeatureContract,
    expected_gas: u64,
    expected_constractor_gas: u64,

Suggestion:

    expected_constructor_gas: u64,

crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 151 at r1 (raw file):

            gas_consumed: expected_constractor_gas,
            ..CallExecution::default()
        }

Suggestion:

    // execution of the constructor and not the deploy syscall.
    let deploy_constructor_call = &deploy_call.inner_calls[0];

    assert_eq!(deploy_constructor_call.call.storage_address, contract_address);
    assert_eq!(
        deploy_constructor_call.execution,
        CallExecution {
            // The test contract constructor returns its first argument.
            retdata: retdata![constructor_calldata[0]],
            // This reflects the gas cost of storage write syscall.
            gas_consumed: expected_constructor_gas,
            ..CallExecution::default()
        }

@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from adbb59e to c6e29e5 Compare August 18, 2024 13:47
Copy link
Contributor Author

@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, 3 unresolved discussions (waiting on @ArniStarkware, @avi-starkware, and @noaov1)


crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 63 at r1 (raw file):

Previously, avi-starkware wrote…

Btw, why do we even need to look at the call info of the constructor call? If it has 0 gas_consumed anyway, shouldn't we just remove this part?

It's a good question. I am not sure; I think Arni wrote this test, maybe it's worth asking him.
@ArniStarkware WDYT?
I think the objective is to confirm that if we are not calling the constructor the gas_cost is zero


crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 97 at r1 (raw file):

    deployer_contract: FeatureContract,
    expected_gas: u64,
    expected_constractor_gas: u64,

Done.


crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 151 at r1 (raw file):

            gas_consumed: expected_constractor_gas,
            ..CallExecution::default()
        }

Done.

@meship-starkware meship-starkware force-pushed the meship/blockifier/update_gas_cost_in_versioned_contants branch from 3daa4c5 to d8a248b Compare August 19, 2024 08:24
@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from c6e29e5 to edf4da7 Compare August 19, 2024 08:26
@meship-starkware meship-starkware force-pushed the meship/blockifier/update_gas_cost_in_versioned_contants branch from d8a248b to 3294ee4 Compare August 19, 2024 09:50
@ArniStarkware
Copy link
Contributor

crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 63 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

It's a good question. I am not sure; I think Arni wrote this test, maybe it's worth asking him.
@ArniStarkware WDYT?
I think the objective is to confirm that if we are not calling the constructor the gas_cost is zero

Talked F2f.
We want to check that the inner call consumes no gas, but we do want to check that the Tx at large consumes some gas.

Copy link
Contributor

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

Copy link
Contributor

@avi-starkware avi-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:

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

@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from edf4da7 to 2cb57a7 Compare August 19, 2024 10:43
@meship-starkware meship-starkware force-pushed the meship/blockifier/update_gas_cost_in_versioned_contants branch from 3294ee4 to c5d6b28 Compare August 19, 2024 11:02
@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from 2cb57a7 to 79eaab5 Compare August 19, 2024 11:03
@meship-starkware meship-starkware force-pushed the meship/blockifier/update_gas_cost_in_versioned_contants branch from c5d6b28 to f653849 Compare August 20, 2024 07:01
@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from 79eaab5 to aad3541 Compare August 20, 2024 07:02
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 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @meship-starkware)


crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 56 at r3 (raw file):

    // Note, this is the CallInfo of the constructor call. Meaning the CallExecution is the
    // execution of the constructor and not the deploy syscall.

I think that this can be removed. Same below.

Code quote:

    // Note, this is the CallInfo of the constructor call. Meaning the CallExecution is the
    // execution of the constructor and not the deploy syscall.

crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs line 57 at r3 (raw file):

    // Note, this is the CallInfo of the constructor call. Meaning the CallExecution is the
    // execution of the constructor and not the deploy syscall.
    let deploy_constructor_call = &deploy_call.inner_calls[0];

Same below.

Suggestion:

let constructor_call = &deploy_call.inner_calls[0];

Base automatically changed from meship/blockifier/update_gas_cost_in_versioned_contants to main August 26, 2024 06:55
@meship-starkware meship-starkware force-pushed the meship/blockifier/add_test_for_deploy_syscall_gas branch from aad3541 to 1ffcc7f Compare August 26, 2024 07:16
Copy link

codecov bot commented Aug 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.45%. Comparing base (be0f73a) to head (1ffcc7f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #478      +/-   ##
==========================================
+ Coverage   76.42%   76.45%   +0.03%     
==========================================
  Files         349      349              
  Lines       36939    36962      +23     
  Branches    36939    36962      +23     
==========================================
+ Hits        28231    28260      +29     
+ Misses       6383     6380       -3     
+ Partials     2325     2322       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

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

@meship-starkware meship-starkware merged commit 41b6672 into main Aug 26, 2024
15 checks passed
@meship-starkware meship-starkware deleted the meship/blockifier/add_test_for_deploy_syscall_gas branch August 26, 2024 13:15
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2024
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