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

feat(mempool): remove addresses of reverted transactions from queue in commit block method #508

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Jul 18, 2024

…n commit block method


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.53%. Comparing base (44e4e35) to head (511bc56).

Files Patch % Lines
crates/mempool/src/mempool.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           mohammad/mempool/add-mempool-state     #508      +/-   ##
======================================================================
- Coverage                               80.80%   80.53%   -0.27%     
======================================================================
  Files                                      42       42              
  Lines                                    1849     1855       +6     
  Branches                                 1849     1855       +6     
======================================================================
  Hits                                     1494     1494              
- Misses                                    279      285       +6     
  Partials                                   76       76              

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

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block/remove-reverted-txs branch from 583bd99 to 4d97dab Compare July 18, 2024 12:57
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/add-mempool-state branch 2 times, most recently from 380e27f to 071bd79 Compare July 18, 2024 15:50
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block/remove-reverted-txs branch from 4d97dab to 056d4e9 Compare July 22, 2024 11:53
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/add-mempool-state branch from 071bd79 to c67cc0a Compare July 23, 2024 07:39
Copy link
Collaborator

@elintul elintul 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 @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 87 at r2 (raw file):

        state_changes: HashMap<ContractAddress, AccountState>,
    ) -> MempoolResult<()> {
        for (&address, AccountState { nonce }) in state_changes.iter() {

Why is this change needed? Isn't for x in iterable sugar for that?

Code quote:

for (&address, AccountState { nonce }) in state_changes.iter()

crates/mempool/src/mempool.rs line 104 at r2 (raw file):

        }
        // TODO: update the tx_queue with the new state changes.

This is not necessarily true, right? The bouncer might have rejected them, so they're still valid.

Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 87 at r2 (raw file):

Previously, elintul (Elin) wrote…

Why is this change needed? Isn't for x in iterable sugar for that?

Not sure I get it. What so you suggest?
My code extracts address, and nonce.


crates/mempool/src/mempool.rs line 104 at r2 (raw file):

Previously, elintul (Elin) wrote…

This is not necessarily true, right? The bouncer might have rejected them, so they're still valid.

Correct, I wrote " as they were not included in the block." So it's a generic comment. A TX can be rejected by the bouncer or by the executor.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block/remove-reverted-txs branch from 056d4e9 to addf42e Compare July 23, 2024 09:21
Copy link
Collaborator

@elintul elintul 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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 87 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Not sure I get it. What so you suggest?
My code extracts address, and nonce.

What happens if you remove .iter()?

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/add-mempool-state branch 5 times, most recently from cf24cda to 44e4e35 Compare July 23, 2024 14:14
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)


crates/mempool/src/mempool.rs line 87 at r2 (raw file):

Previously, elintul (Elin) wrote…

What happens if you remove .iter()?

.iter() returns ref.
if I remove it, so this line:
if !state_changes.contains_key(address)
would fail on borrowing issue

Copy link
Collaborator

@elintul elintul 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, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 87 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

.iter() returns ref.
if I remove it, so this line:
if !state_changes.contains_key(address)
would fail on borrowing issue

Will looping over &state_changes work?

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block/remove-reverted-txs branch from addf42e to 511bc56 Compare July 24, 2024 05:13
Copy link
Collaborator

@elintul elintul 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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware and @giladchase)

Copy link
Collaborator

@elintul elintul 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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool.rs line 116 at r4 (raw file):

        self.mempool_state.clear();

        Ok(())

Suggestion:

        // Rewind nonces of addresses that were not included in block.
        let addresses_not_included_in_block =
            self.mempool_state.keys().filter(|&key| !state_changes.contains_key(key));
        for address in addresses_not_included_in_block {
            self.tx_queue.remove(*address);
        }
        
        self.mempool_state.clear();

        Ok(())

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool/add-mempool-state branch from 44e4e35 to d43df34 Compare July 24, 2024 12:47
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block/remove-reverted-txs branch from 511bc56 to 3b938f5 Compare July 24, 2024 12:56
Copy link
Collaborator

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

@elintul elintul closed this Jul 25, 2024
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.

3 participants