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 struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags #2429

Merged

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 53.40909% with 41 lines in your changes missing coverage. Please review.

Project coverage is 61.10%. Comparing base (e3165c4) to head (0557829).
Report is 727 commits behind head on main.

Files with missing lines Patch % Lines
crates/native_blockifier/src/py_transaction.rs 0.00% 19 Missing ⚠️
...ution/src/state_reader/reexecution_state_reader.rs 0.00% 11 Missing ⚠️
crates/papyrus_execution/src/lib.rs 61.11% 6 Missing and 1 partial ⚠️
...lockifier/src/transaction/transaction_execution.rs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2429       +/-   ##
===========================================
+ Coverage   40.10%   61.10%   +21.00%     
===========================================
  Files          26      206      +180     
  Lines        1895    22859    +20964     
  Branches     1895    22859    +20964     
===========================================
+ Hits          760    13969    +13209     
- Misses       1100     7894     +6794     
- Partials       35      996      +961     

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 721db4f to 1a788e4 Compare December 3, 2024 13:01
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx branch from b076c16 to a9f4ae2 Compare December 3, 2024 13:07
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 1a788e4 to 3c34814 Compare December 3, 2024 13:08
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx branch from a9f4ae2 to ab0a55d Compare December 3, 2024 13:10
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 3c34814 to 0ebdd7d Compare December 3, 2024 13:11
@avivg-starkware avivg-starkware changed the title chore(blockifier): add struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags chore(blockifier): add struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags Dec 3, 2024
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 0ebdd7d to 313f055 Compare December 3, 2024 14:07
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx branch 2 times, most recently from 8b56643 to bac51a0 Compare December 3, 2024 14:09
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 313f055 to 32c94bb Compare December 3, 2024 14:09
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx branch from bac51a0 to 0d554b2 Compare December 3, 2024 14:09
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 32c94bb to ccec3e2 Compare December 3, 2024 14:10
@avivg-starkware avivg-starkware changed the title chore(blockifier): add struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags chore(blockifier): add struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags Dec 3, 2024
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from ccec3e2 to 43209f7 Compare December 3, 2024 14:46
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 20 files at r1, all commit messages.
Reviewable status: 1 of 22 files reviewed, 1 unresolved discussion (waiting on @avivg-starkware)


crates/native_blockifier/src/py_transaction.rs line 149 at r2 (raw file):

                ..ExecutionFlags::default()
            };
            AccountTransaction { tx, execution_flags }.into()

Save this code duplication - add a constructor that gets the tx.
new_for_sequencing or something like this

Code quote:

            let execution_flags = ExecutionFlags {
                only_query,
                charge_fee: enforce_fee(&tx, only_query),
                ..ExecutionFlags::default()
            };
            AccountTransaction { tx, execution_flags }.into()

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 13 files at r2.
Reviewable status: 2 of 22 files reviewed, 3 unresolved discussions (waiting on @avivg-starkware)


crates/starknet_gateway/src/stateful_transaction_validator.rs line 81 at r2 (raw file):

        let only_query = false;
        let charge_fee = enforce_fee(&executable_tx, only_query);
        let execution_flags = ExecutionFlags { only_query, charge_fee, validate: true };

Should it be !skip_validate?

Code quote:

validate: true }

crates/starknet_batcher/src/block_builder.rs line 177 at r2 (raw file):

                                charge_fee,
                                validate: true,
                            },

Use the new_for_sequencing c-tor

Code quote:

                        let only_query = false;
                        let charge_fee = enforce_fee(account_tx, only_query);
                        BlockifierTransaction::Account(AccountTransaction {
                            // TODO(yair): Avoid this clone.
                            tx: account_tx.clone(),
                            execution_flags: ExecutionFlags {
                                only_query,
                                charge_fee,
                                validate: true,
                            },

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 43209f7 to ccb5c8d Compare December 3, 2024 15:25
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx branch from bac51a0 to b523e04 Compare December 3, 2024 15:34
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from ccb5c8d to db01d8d Compare December 3, 2024 15:34
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: 2 of 22 files reviewed, 4 unresolved discussions (waiting on @avivg-starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 136 at r2 (raw file):

    );
    let only_query = false;
    let charge_fee = enforce_fee(&declare_tx, only_query);

What is this func? are you sure it is necessary?
Seems like you can use the new_for_sequencing c-tor everywhere here

Code quote:

enforce_fee

@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/use_invoke_tx_instead_of_account_invoke_tx to graphite-base/2429 December 4, 2024 13:14
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from db01d8d to c75942e Compare December 4, 2024 14:00
@avivg-starkware avivg-starkware changed the base branch from graphite-base/2429 to main December 4, 2024 14:00
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 22 files reviewed, 4 unresolved discussions (waiting on @Yoni-Starkware)


crates/blockifier/src/blockifier/transaction_executor_test.rs line 136 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

What is this func? are you sure it is necessary?
Seems like you can use the new_for_sequencing c-tor everywhere here

enforce_fee is the func created in the prev PR to allow computing 'charge_fee' before creating AccountTransaction #2377

and defiantly for using 'new_for_sequencing', in the following PR: #2431


crates/native_blockifier/src/py_transaction.rs line 149 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Save this code duplication - add a constructor that gets the tx.
new_for_sequencing or something like this

Defiantly! added in the next PR as I'm anyway creating a constructor there. #2431


crates/starknet_batcher/src/block_builder.rs line 177 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Use the new_for_sequencing c-tor

Done in #2431


crates/starknet_gateway/src/stateful_transaction_validator.rs line 81 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Should it be !skip_validate?

Seems right. thank you.

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


crates/blockifier/src/transaction/transactions_test.rs line 1976 at r5 (raw file):

        validate_constructor,
        validate: true,
        charge_fee: false, // We test `__validate__`, and don't care about the cahrge fee flow.

Suggestion:

charge fee flow

crates/blockifier/src/transaction/account_transaction.rs line 724 at r5 (raw file):

        state: &mut TransactionalState<'_, U>,
        block_context: &BlockContext,
        execution_flags_: TransactionExecutionFlags,

Consider passing concurrecy_mode without this struct

Code quote:

execution_flags_: TransactionExecutionFlags,

crates/blockifier/src/transaction/account_transaction.rs line 756 at r5 (raw file):

            tx_context.clone(),
            self.execution_flags.validate,
            self.execution_flags.charge_fee,

Be sure to push these inside instead of passing them as arguments (now that they are part of self)

Code quote:

            self.execution_flags.validate,
            self.execution_flags.charge_fee,

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from c75942e to b6d3db3 Compare December 5, 2024 09:57
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from b6d3db3 to 8fdc0c9 Compare December 5, 2024 10:00
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: 20 of 22 files reviewed, 2 unresolved discussions (waiting on @Yoni-Starkware)


crates/blockifier/src/transaction/account_transaction.rs line 724 at r5 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Consider passing concurrecy_mode without this struct

added a PR #2470


crates/blockifier/src/transaction/account_transaction.rs line 756 at r5 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Be sure to push these inside instead of passing them as arguments (now that they are part of self)

WOW, yes. will do


crates/blockifier/src/transaction/transactions_test.rs line 1976 at r5 (raw file):

        validate_constructor,
        validate: true,
        charge_fee: false, // We test `__validate__`, and don't care about the cahrge fee flow.

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.

:lgtm:

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

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


crates/blockifier/src/transaction/account_transaction.rs line 756 at r5 (raw file):

Previously, avivg-starkware wrote…

WOW, yes. will do

#2491

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch 2 times, most recently from c594964 to be786da Compare December 5, 2024 15:46
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 6 of 20 files at r1, 8 of 13 files at r2, 2 of 5 files at r5, 6 of 6 files at r7, 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/new_struct_execution_flags_in_acc_tx branch from be786da to 5c9934e Compare December 5, 2024 19:51
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch from 5c9934e to 0557829 Compare December 5, 2024 20:22
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 1 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 94a6727 into main Dec 5, 2024
19 checks passed
FrancoGiachetta added a commit to lambdaclass/sequencer that referenced this pull request Dec 6, 2024
* chore(starknet_batcher): delete obsolete todo (starkware-libs#2389)

* chore(blockifier): add global max_sierra_gas to versioned constants (starkware-libs#2330)

* feat(starknet_api): checked mul for gas vector (starkware-libs#2300)

* feat(consensus): proposer rotates across validators (starkware-libs#2405)

* feat(sequencing): validate streamed proposals (starkware-libs#2305)

* feat(ci): deny rust warnings in all workflows (starkware-libs#2388)

Signed-off-by: Dori Medini <dori@starkware.co>

* feat(blockifier): compute allocation cost (starkware-libs#2301)

* chore(starknet_sequencer_infra): add dynamic logging util fn

commit-id:9ffe9fbe

* chore(starknet_sequencer_infra): add tracing test

commit-id:76d16e9a

* chore(starknet_sequencer_infra): add run_until utility fn

commit-id:194a4b6c

* chore(infra_utils): change run_until to support async functions

commit-id:92e1f8a3

* chore(starknet_integration_tests): use run_until to await for block creation

commit-id:667e001c

* chore(infra_utils): rename logger struct

commit-id:6520ae54

* chore(blockifier): explicit creation of AccountTransaction (starkware-libs#2331)

* test(starknet_integration_tests): test commit blocks by running multiple heights

* chore(starknet_batcher): set temp gas prices in propose block input (starkware-libs#2341)

* chore(starknet_batcher): set use_kzg_da flag in build block input (starkware-libs#2345)

* feat(ci): inherit the rust toolchain toml in moonrepo action (starkware-libs#2423)

Signed-off-by: Dori Medini <dori@starkware.co>

* chore(blockifier): enforce_fee() impl by api::executable_transaction::AccountTransaction (starkware-libs#2377)

* chore(starknet_integration_tests): inherit sequencer node's stdout (starkware-libs#2427)

* chore(blockifier): invoke() declare() deploy_account() change ret val to api_tx (starkware-libs#2412)

* chore(starknet_consensus_manager): set proposer address in propose block input (starkware-libs#2346)

* feat(consensus): add observer mode

* feat(consensus): sequencer context broadcasts votes (starkware-libs#2422)

* chore(deployment): support unified deployment config (starkware-libs#2378)

* feat(starknet_api): add sierra version to class info (starkware-libs#2313)

* refactor(starknet_api): change default sierra contract class to valid one (starkware-libs#2439)

* feat(starknet_l1_provider): add uninitiailized state and make it the default (starkware-libs#2434)

This is to comply with upcoming integration with infra, which separates
instantiation with initialization. In particular, `Pending` state should
be already post-syncing with L1, whereas `Uninitialized` is unsynced and
unusable.

Co-Authored-By: Gilad Chase <gilad@starkware.com>

* feat(papyrus_storage)!: bump storage version for version 13.4 (starkware-libs#2333)

* feat(native_blockifier): allow deserialization of  python l1_data_gas (starkware-libs#2447)

* refactor(blockifier): split FC to groups base on their tags (starkware-libs#2236)

* test(consensus): remove warning on into mock propsal part (starkware-libs#2448)

* chore(blockifier): use test_utils::invoke_tx() instead of trans::test_utils::account_invoke_tx() (starkware-libs#2428)

* chore(blockifier): save sierra to Feature contracts (starkware-libs#2370)

* feat(blockifier): don't count Sierra gas in CairoSteps mode (starkware-libs#2440)

* chore(blockifier): convert Sierra gas to L1 gas if in L1 gas mode (starkware-libs#2451)

* feat(blockifier): add comprehensive state diff versioned constant (starkware-libs#2407)

* chore(starknet_consensus_manager): add chain_id to config

* refactor(papyrus_p2p_sync): add random_header utility function (starkware-libs#2381)

* chore(starknet_batcher): pass block info from consensus to batcher (starkware-libs#2238)

* test(starknet_mempool): tx added to mempool are forwarded to propagator client (starkware-libs#2288)

* fix: fix CR comments

* test(starknet_mempool): tx added to mempool are forwarded to propagator client

* feat(sequencing): cache proposals from bigger heights(starkware-libs#2325)

* fix: change to latest ubuntu version in feature combo CI (starkware-libs#2414)

* chore(blockifier): replace entry_point_gas_cost with initial_budget (starkware-libs#2247)

* test(starknet_gateway): handle todo in test_get_block_info (starkware-libs#2267)

* chore(starknet_api): revert use get_packaget_dir instead of env var

This reverts commit c45f5cc.

commit-id:a48736e7

* chore(starknet_api): rely on env::current_dir() instead of CARGO_MANIFEST_DIR

commit-id:301ed4eb

* chore(blockifier): move env var from run time to compile time

commit-id:80a7265d

* chore(starknet_sierra_compile): move env var from run time to compile time

commit-id:6e7f2a75

* chore: remove the use of zero as a validator id (starkware-libs#2411)

* refactor(papyrus_p2p_sync): add_test receives query size instead of constant (starkware-libs#2379)

* fix(blockifier): merge state diff with squash (starkware-libs#2310)

* feat(blockifier): get revert receipt only in case of revert (starkware-libs#2471)

* chore(starknet_integration_tests): create chain info once (starkware-libs#2482)

* chore(starknet_sierra_compile): split build utils

commit-id:0f504fd7

* chore(starknet_sierra_compile): set runtime-accessible out_dir env var

commit-id:539f16db

* chore(starknet_sierra_compile): avoid using OUT_DIR in run time

commit-id:cd6fba29

* refactor(starknet_api): use const in sierra version (starkware-libs#2477)

* chore: cleanups of OUT_DIR env var (starkware-libs#2484)

commit-id:18d61b1d

* chore(starknet_api): shorten executable_transaction  usage path

* fix(sequencing): remove old proposal pipes from consensus (starkware-libs#2452)

* test(starknet_integration_tests): match sequencer address with default validator id (starkware-libs#2486)

* fix(ci): move specific versioned deps to root toml (starkware-libs#2487)

* fix(ci): move specific versioned deps to root toml

Signed-off-by: Dori Medini <dori@starkware.co>

* fix(starknet_sierra_compile): fix build.rs

Signed-off-by: Dori Medini <dori@starkware.co>

* chore(starknet_batcher): in block builder use the consensus suplied sequncer address (starkware-libs#2409)

* chore: cleanups of CARGO_MANIFEST_DIR env var

commit-id:c96f2d88

* fix(starknet_sierra_compile): missing import in feature (starkware-libs#2495)

commit-id:abd0a286

* chore(blockifier): add keccak_builtin_gas_cost (starkware-libs#2327)

* chore(blockifier): add struct ExecutionFlags to AccTx & use instead of transaction::ExecutionFlags (starkware-libs#2429)

* chore(blockifier): add new constructor to AccountTransaction (starkware-libs#2431)

* chore(blockifier): remove only_qury from IvokeTxArgs (starkware-libs#2437)

* chore(blockifier): remove struct ExecutionFlags and replace w concurrency_mode bool (starkware-libs#2470)

* chore(blockifier): remove declare.rs deploy_account.rs invoke.rs from blockifier (starkware-libs#2478)

---------

Signed-off-by: Dori Medini <dori@starkware.co>
Co-authored-by: YaelD <70628564+Yael-Starkware@users.noreply.github.com>
Co-authored-by: aner-starkware <147302140+aner-starkware@users.noreply.github.com>
Co-authored-by: yoavGrs <97383386+yoavGrs@users.noreply.github.com>
Co-authored-by: matan-starkware <97523054+matan-starkware@users.noreply.github.com>
Co-authored-by: guy-starkware <guy.n@starkware.co>
Co-authored-by: dorimedini-starkware <dori@starkware.co>
Co-authored-by: Itay Tsabary <itayt@starkware.co>
Co-authored-by: avivg-starkware <aviv.g@starkware.co>
Co-authored-by: Yair Bakalchuk <yair@starkware.co>
Co-authored-by: Arnon Hod <arnon@starkware.co>
Co-authored-by: Alon Haramati <91828241+alonh5@users.noreply.github.com>
Co-authored-by: Asmaa Magdoub <asmaa@starkware.co>
Co-authored-by: alon-dotan-starkware <alon.dotan@starkware.co>
Co-authored-by: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com>
Co-authored-by: giladchase <gilad@starkware.co>
Co-authored-by: Gilad Chase <gilad@starkware.com>
Co-authored-by: DvirYo-starkware <115620476+DvirYo-starkware@users.noreply.github.com>
Co-authored-by: nimrod-starkware <143319383+nimrod-starkware@users.noreply.github.com>
Co-authored-by: Meshi Peled <141231558+meship-starkware@users.noreply.github.com>
Co-authored-by: Yoni <78365039+Yoni-Starkware@users.noreply.github.com>
Co-authored-by: Yael Doweck <yael@starkware.co>
Co-authored-by: ShahakShama <70578257+ShahakShama@users.noreply.github.com>
Co-authored-by: Alon-Lukatch-Starkware <alon.l@starkware.co>
Co-authored-by: Yonatan-Starkware <yonatan.k@starkware.co>
Co-authored-by: Yair <92672946+yair-starkware@users.noreply.github.com>
Co-authored-by: Itay-Tsabary-Starkware <106665835+Itay-Tsabary-Starkware@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2024
@avivg-starkware avivg-starkware deleted the avivg/blockifier/new_struct_execution_flags_in_acc_tx branch December 8, 2024 09:31
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.

3 participants