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

refactor(blockifier): change return type of invoke_tx deploy_account_tx to account_transaction #1643

Merged

Conversation

avivg-starkware
Copy link
Contributor

…tx to account_transaction

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.65%. Comparing base (e3165c4) to head (ca4a66d).
Report is 293 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1643       +/-   ##
===========================================
+ Coverage   40.10%   67.65%   +27.54%     
===========================================
  Files          26      102       +76     
  Lines        1895    13868    +11973     
  Branches     1895    13868    +11973     
===========================================
+ Hits          760     9382     +8622     
- Misses       1100     4085     +2985     
- Partials       35      401      +366     

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 0a374ef to 8e13fb4 Compare October 29, 2024 10:30
Copy link

Artifacts upload triggered. View details here

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


crates/blockifier/src/concurrency/versioned_state_test.rs line 238 at r1 (raw file):

    // Prepare transactions
    let account_tx_1 = deploy_account_tx(

Please revert (more informative)
(in the entire file)

Code quote:

 let account_tx_1 = deploy_account_tx(

crates/blockifier/src/test_utils/invoke.rs line 30 at r1 (raw file):

        false => AccountTransaction::Invoke(InvokeTransaction::new(invoke_tx, tx_hash)),
    }
}

Suggestion:

    let invoke_tx = match only_query {
        true => InvokeTransaction::new_for_query(invoke_tx, tx_hash),
        false => InvokeTransaction::new(invoke_tx, tx_hash),
    };
    AccountTransaction::Invoke(invoke_tx
}

crates/blockifier/src/transaction/account_transaction.rs line 239 at r1 (raw file):

            Self::DeployAccount(tx) => tx.constructor_calldata(),
            Self::Invoke(tx) => tx.calldata(),
        }

Please revert. See my comment below.

Code quote:

    pub fn calldata_length(&self) -> usize {
        self.calldata().0.len()
    }

    pub fn calldata(&self) -> Calldata {
        match self {
            Self::Declare(_tx) => calldata![],
            Self::DeployAccount(tx) => tx.constructor_calldata(),
            Self::Invoke(tx) => tx.calldata(),
        }

crates/blockifier/src/transaction/test_utils.rs line 141 at r1 (raw file):

) -> (AccountTransaction, ContractAddress) {
    // Deploy an account contract.
    let account_tx = deploy_account_tx(deploy_tx_args, nonce_manager);

Please revert the name

Code quote:

 let account_tx = deploy_account_tx(deploy_tx_args, nonce_manager);

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

    // transaction.
    let calldata = Calldata(Arc::clone(&account_tx.calldata().0)); //Aviv how to access?
    let calldata_length = account_tx.calldata_length();

Suggestion:

    let calldata = create_trivial_calldata(test_contract_address);
    let account_tx = invoke_tx(invoke_tx_args! {
        sender_address: account_contract_address,
        calldata
        resource_bounds: default_l1_resource_bounds,
    });

    // Extract invoke transaction fields for testing, as it is consumed when creating an account
    // transaction.
    let calldata_length = account_tx.calldata_length();

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/make_execution_tx_compatible_w_blockifier_tx branch from b35e972 to 6ab33b3 Compare November 4, 2024 11:53
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 8e13fb4 to 8d98dc1 Compare November 4, 2024 12:43
Copy link

github-actions bot commented Nov 4, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 8d98dc1 to 1b6ef79 Compare November 4, 2024 15:51
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 8 files reviewed, 4 unresolved discussions (waiting on @noaov1)


crates/blockifier/src/concurrency/versioned_state_test.rs line 238 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Please revert (more informative)
(in the entire file)

Done.


crates/blockifier/src/test_utils/invoke.rs line 30 at r1 (raw file):

        false => AccountTransaction::Invoke(InvokeTransaction::new(invoke_tx, tx_hash)),
    }
}

Done


crates/blockifier/src/transaction/account_transaction.rs line 239 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Please revert. See my comment below.

Done.


crates/blockifier/src/transaction/test_utils.rs line 141 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Please revert the name

Done.


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

    // transaction.
    let calldata = Calldata(Arc::clone(&account_tx.calldata().0)); //Aviv how to access?
    let calldata_length = account_tx.calldata_length();

Partially done, please see my fix; As 'calldata' is used twice, it doesn't work without a clone.

Copy link

github-actions bot commented Nov 4, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/make_execution_tx_compatible_w_blockifier_tx branch from 6ab33b3 to f3a7c10 Compare November 4, 2024 17:39
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 1b6ef79 to 8af325a Compare November 4, 2024 17:43
Copy link

github-actions bot commented Nov 4, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 8af325a to 94a2163 Compare November 5, 2024 08:58
Copy link

github-actions bot commented Nov 5, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 94a2163 to ed0d822 Compare November 5, 2024 09:06
Copy link

github-actions bot commented Nov 5, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from ed0d822 to 2cd23a7 Compare November 5, 2024 09:12
Copy link

github-actions bot commented Nov 5, 2024

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/make_execution_tx_compatible_w_blockifier_tx branch from f3a7c10 to dacda4c Compare November 5, 2024 14:46
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 2cd23a7 to 9bdbcae Compare November 5, 2024 14:47
Copy link

github-actions bot commented Nov 5, 2024

Artifacts upload triggered. View details here

@ArniStarkware ArniStarkware requested a review from noaov1 November 5, 2024 14:59
Copy link
Contributor

@ArniStarkware ArniStarkware 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 7 files at r1, 2 of 5 files at r3.
Reviewable status: 3 of 8 files reviewed, 6 unresolved discussions (waiting on @avivg-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/transaction/account_transaction.rs line 235 at r4 (raw file):

            Self::DeployAccount(tx) => tx.constructor_calldata(),
            Self::Invoke(tx) => tx.calldata(),
        };

If we are already here...

Suggestion:

        let calldata = match self {
            Self::Declare(_tx) => return 0,
            Self::DeployAccount(tx) => tx.constructor_calldata(),
            Self::Invoke(tx) => tx.calldata(),
        };

crates/blockifier/src/transaction/account_transactions_test.rs line 212 at r4 (raw file):

    let result = account_tx.execute(state, &block_context, enforce_fee, true);
    // Execution should fail if the fee is enforced because the account doesn't have sufficient
    // balance.

Suggestion:

    let deploy_account_tx = deploy_account_tx(
        deploy_account_tx_args! {
            class_hash: account.get_class_hash(),
            max_fee: Fee(if zero_bounds { 0 } else { MAX_FEE.0 }),
            resource_bounds: match gas_bounds_mode {
                GasVectorComputationMode::NoL2Gas => l1_resource_bounds(
                    (if zero_bounds { 0 } else { DEFAULT_L1_GAS_AMOUNT.0 }).into(),
                    DEFAULT_STRK_L1_GAS_PRICE.into()
                ),
                GasVectorComputationMode::All => create_all_resource_bounds(
                    (if zero_bounds { 0 } else { DEFAULT_L1_GAS_AMOUNT.0 }).into(),
                    DEFAULT_STRK_L1_GAS_PRICE.into(),
                    (if zero_bounds { 0 } else { DEFAULT_L2_GAS_MAX_AMOUNT.0 }).into(),
                    DEFAULT_STRK_L2_GAS_PRICE.into(),
                    (if zero_bounds { 0 } else { DEFAULT_L1_DATA_GAS_MAX_AMOUNT.0 }).into(),
                    DEFAULT_STRK_L1_DATA_GAS_PRICE.into(),
                ),
            },
            version,
        },
        &mut NonceManager::default(),
    );

    let enforce_fee = deploy_account_tx.create_tx_info().enforce_fee();
    assert_ne!(zero_bounds, enforce_fee);
    let result = deploy_account_tx.execute(state, &block_context, enforce_fee, true);
    // Execution should fail if the fee is enforced because the account doesn't have sufficient
    // balance.

Copy link
Contributor

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

@ArniStarkware
Copy link
Contributor

crates/blockifier/src/transaction/transactions_test.rs line 1721 at r6 (raw file):

    // Build expected validate call info.
    // TODO (AvivG) Temp implementation until AccountTransaction refactor PR.

Suggestion:

    // TODO(AvivG): When the AccountTransaction refactor is complete, simplify the creation of `validate_calldata` by doing 1.2.3...

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 9df07b4 to 8f7eddc Compare November 10, 2024 11:49
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: 6 of 8 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @meship-starkware, and @noaov1)


crates/blockifier/src/transaction/transactions_test.rs line 1721 at r6 (raw file):

    // Build expected validate call info.
    // TODO (AvivG) Temp implementation until AccountTransaction refactor PR.

Done.

Copy link

Artifacts upload triggered. View details here

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, 1 of 1 files at r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)

Copy link
Contributor

@ArniStarkware ArniStarkware 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 8f7eddc to 30c58aa Compare November 11, 2024 08:16
@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/make_execution_tx_compatible_w_blockifier_tx to main November 11, 2024 08:16
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/change_invoke_deploy_return_accounttx branch from 30c58aa to ca4a66d Compare November 11, 2024 09:59
Copy link
Contributor Author

avivg-starkware commented Nov 11, 2024

Copy link

Artifacts upload triggered. View details here

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

Copy link
Contributor

@ArniStarkware ArniStarkware 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

Copy link
Contributor

@ArniStarkware ArniStarkware 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/test_utils/deploy_account.rs line 16 at r10 (raw file):

    );

    // TODO(AvivG): use the "new" method.

Delete the todo. It will be addressed in future PR.
Please link in this thread which PR addresses this issue.

(Non-blocking, this todo can be deleted later).

Code quote:

    // TODO(AvivG): use the "new" method.

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)


crates/blockifier/src/test_utils/deploy_account.rs line 16 at r10 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Delete the todo. It will be addressed in future PR.
Please link in this thread which PR addresses this issue.

(Non-blocking, this todo can be deleted later).

Thanks! the PR is #1688
A short explanation: after this PR, using "new" is longer needed here as we're no longer manually setting only_query to false, but rather this is done in ".into()"

@avivg-starkware avivg-starkware merged commit 44866d0 into main Nov 11, 2024
12 checks passed
@avivg-starkware avivg-starkware deleted the avivg/blockifier/change_invoke_deploy_return_accounttx branch November 11, 2024 11:20
@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 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.

5 participants