Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

refactor(execution): make the block state of TransactionExecutor an O… #1947

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

barak-b-starkware
Copy link
Collaborator

@barak-b-starkware barak-b-starkware commented Jun 4, 2024

…ption to allow moving it to chunks


This change is Reviewable

@barak-b-starkware barak-b-starkware force-pushed the barak/execute_chunk/1_block_state_option branch from 20479a4 to b8da0b4 Compare June 4, 2024 09:24
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 11 lines in your changes missing coverage. Please review.

Project coverage is 78.17%. Comparing base (a34e203) to head (e275fb3).

Files Patch % Lines
.../blockifier/src/blockifier/transaction_executor.rs 52.63% 9 Missing ⚠️
...es/blockifier/src/blockifier/stateful_validator.rs 85.71% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1947      +/-   ##
==========================================
- Coverage   78.18%   78.17%   -0.02%     
==========================================
  Files          62       62              
  Lines        8820     8842      +22     
  Branches     8820     8842      +22     
==========================================
+ Hits         6896     6912      +16     
- Misses       1486     1492       +6     
  Partials      438      438              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it 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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware, @barak-b-starkware, and @Yoni-Starkware)


crates/blockifier/src/blockifier/stateful_validator.rs line 113 at r1 (raw file):

        let charge_fee = true;
        tx.perform_pre_validation_stage(
            self.tx_executor.block_state.as_mut().expect("The block state should be `Some`."),

Consider defining a getter:
(you may also need a non-mutable reference)

Code quote (i):

          self.tx_executor.block_state.as_mut().expect("The block state should be `Some`."),

Code snippet (ii):

    pub fn mutable_block_state<'a>(&'a mut self) -> &'a mut CachedState<S> {
        self.block_state.as_mut().expect("The block state should be `Some`.")
    }

crates/blockifier/src/blockifier/transaction_executor.rs line 50 at r1 (raw file):

    // The transaction executor operates at the block level. It moves the block's state when
    // operating at the chunk level and gets it back after the chunk is committed, so it needs to
    // be wrapped with an Option<_>.

Suggestion:

    // The transaction executor operates at the block level. In the concurrent mpode, it moves the 
    // block's state when operating at the chunk level and gets it back after the chunk is committed, 
    // so it needs to be wrapped with an Option<_>.

@avi-starkware
Copy link
Collaborator

crates/blockifier/src/blockifier/transaction_executor.rs line 50 at r1 (raw file):

    // The transaction executor operates at the block level. It moves the block's state when
    // operating at the chunk level and gets it back after the chunk is committed, so it needs to
    // be wrapped with an Option<_>.

Suggestion:

    // The transaction executor operates at the block level. In concurrency mode, it moves the block state to the worker executor 
    // - operating at the chunk level - and gets it back after committing the chunk. The block state is 
    // wrapped with an Option<_> to allow setting it to `None` while it is moved to the worker executor.

Copy link
Collaborator

@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 all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @barak-b-starkware and @Yoni-Starkware)


crates/blockifier/src/blockifier/transaction_executor.rs line 177 at r1 (raw file):

        self.block_state
            .as_mut()
            .expect("The block state should be `Some`.")

Define a const with this error message. (Unless you define a getter as Noa suggested above.

Code quote:

"The block state should be `Some`."

Copy link
Collaborator Author

@barak-b-starkware barak-b-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: all files reviewed, 3 unresolved discussions (waiting on @avi-starkware, @MohammadNassar1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/blockifier/transaction_executor.rs line 50 at r1 (raw file):

    // The transaction executor operates at the block level. It moves the block's state when
    // operating at the chunk level and gets it back after the chunk is committed, so it needs to
    // be wrapped with an Option<_>.

Done.


crates/blockifier/src/blockifier/transaction_executor.rs line 50 at r1 (raw file):

    // The transaction executor operates at the block level. It moves the block's state when
    // operating at the chunk level and gets it back after the chunk is committed, so it needs to
    // be wrapped with an Option<_>.

Done. Took @avi-starkware 's suggestion that expands yours a little bit.

@barak-b-starkware barak-b-starkware force-pushed the barak/execute_chunk/1_block_state_option branch from b8da0b4 to 2433081 Compare June 4, 2024 13:45
Copy link
Collaborator

@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: all files reviewed, 2 unresolved discussions (waiting on @barak-b-starkware, @MohammadNassar1, @OriStarkware, and @Yoni-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.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @barak-b-starkware, @MohammadNassar1, @OriStarkware, and @Yoni-Starkware)

@barak-b-starkware barak-b-starkware force-pushed the barak/execute_chunk/1_block_state_option branch from 2433081 to 124d1a2 Compare June 5, 2024 11:48
Copy link
Collaborator Author

@barak-b-starkware barak-b-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: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @MohammadNassar1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/blockifier/stateful_validator.rs line 113 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Consider defining a getter:
(you may also need a non-mutable reference)

Done. @avi-starkware 's suggestion.


crates/blockifier/src/blockifier/transaction_executor.rs line 177 at r1 (raw file):

Previously, avi-starkware wrote…

Define a const with this error message. (Unless you define a getter as Noa suggested above.

Done.

avi-starkware
avi-starkware previously approved these changes Jun 5, 2024
Copy link
Collaborator

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

Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1, @OriStarkware, and @Yoni-Starkware)

noaov1
noaov1 previously approved these changes Jun 5, 2024
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 r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1, @OriStarkware, and @Yoni-Starkware)

@barak-b-starkware barak-b-starkware force-pushed the barak/execute_chunk/1_block_state_option branch from 124d1a2 to d90e9b9 Compare June 5, 2024 13:36
Yoni-Starkware
Yoni-Starkware previously approved these changes Jun 5, 2024
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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1 and @OriStarkware)

OriStarkware
OriStarkware previously approved these changes Jun 6, 2024
Copy link
Contributor

@OriStarkware OriStarkware 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 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1)

@barak-b-starkware barak-b-starkware force-pushed the barak/execute_chunk/1_block_state_option branch from 274dcfe to e275fb3 Compare June 6, 2024 11:50
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 r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1)

@barak-b-starkware barak-b-starkware merged commit 9fe3969 into main Jun 6, 2024
9 checks passed
@barak-b-starkware barak-b-starkware deleted the barak/execute_chunk/1_block_state_option branch June 6, 2024 11:55
gswirski pushed a commit to reilabs/blockifier that referenced this pull request Jun 26, 2024
…StateProvider::nonce()` of forked provider (starkware-libs#1947)

# Description

<!--
A description of what this PR is solving.
-->

## Related issue

<!--
Please link related issues: Fixes #<issue_number>
More info: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Tests

<!--
Please refer to the CONTRIBUTING.md file to know more about the testing process. Ensure you've tested at least the package you're modifying if running all the tests consumes too much memory on your system.
-->

- [ ] Yes
- [ ] No, because they aren't needed
- [ ] No, because I need help

## Added to documentation?

<!--
If the changes are small, code comments are enough, otherwise, the documentation is needed. It
may be a README.md file added to your module/package, a DojoBook PR or both.
-->

- [ ] README.md
- [ ] [Dojo Book](https://github.com/dojoengine/book)
- [ ] No documentation needed

## Checklist

- [ ] I've formatted my code (`scripts/prettier.sh`, `scripts/rust_fmt.sh`, `scripts/cairo_fmt.sh`)
- [ ] I've linted my code (`scripts/clippy.sh`, `scripts/docs.sh`)
- [ ] I've commented my code
- [ ] I've requested a review after addressing the comments
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.

6 participants