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(mempool): move account nonces update check to add tx test #878

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ayeletstarkware
Copy link
Contributor

@ayeletstarkware ayeletstarkware commented Sep 19, 2024

This change is Reviewable

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.26%. Comparing base (b0cfe82) to head (73a8306).
Report is 49 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (b0cfe82) and HEAD (73a8306). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (b0cfe82) HEAD (73a8306)
3 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #878       +/-   ##
===========================================
- Coverage   74.18%   15.26%   -58.93%     
===========================================
  Files         359       31      -328     
  Lines       36240     2738    -33502     
  Branches    36240     2738    -33502     
===========================================
- Hits        26886      418    -26468     
+ Misses       7220     2302     -4918     
+ Partials     2134       18     -2116     
Flag Coverage Δ
15.26% <ø> (-58.93%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/account_nonce/refactor-nonce-update-in-add-tx- branch from 96ce31e to e349c54 Compare September 22, 2024 13:37
Copy link
Contributor Author

@ayeletstarkware ayeletstarkware 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 2 files reviewed, 1 unresolved discussion


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

        .with_queue(expected_queue_txs)
        .build();
    expected_mempool_content.assert_eq_pool_and_queue_content(&mempool);

I think it would be better to delete this function since we now have more fields to assert, and we can check each one separately as needed.

Code quote:

assert_eq_pool_and_queue_content

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: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware)


Cargo.lock line 9793 at r2 (raw file):

dependencies = [
 "async-trait",
 "derive_more 0.99.17",

The lock was updated, but no toml files were updated. This seems odd...

Code quote:

 "derive_more 0.99.17"

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

Previously, ayeletstarkware (Ayelet Zilber) wrote…

I think it would be better to delete this function since we now have more fields to assert, and we can check each one separately as needed.

Delete it from this test - and not in general, I see.
Is this the intended behavior?


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

        .with_queue(expected_queue_txs)
        .with_account_nonces(expected_account_nonces)
        .build();

For the record, this suggested code does not require .collect. I am not sure it is a value we should aspire to, though. This suggestion is less readable.

Suggestion:

    // Assert: transactions are ordered by priority.
    let expected_mempool_content = MempoolContentBuilder::new()
        .with_account_nonces(add_tx_inputs.iter().map(|input| {
            let Account { sender_address, state: AccountState { nonce } } = input.account;
            (sender_address, nonce)
        }))
        .with_queue(add_tx_inputs.iter().map(|input| TransactionReference::new(&input.tx)))
        .with_pool(add_tx_inputs.into_iter().map(|input| input.tx))
        .build();

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

        .with_queue(expected_queue_txs)
        .with_account_nonces(expected_account_nonces)
        .build();

Please align the order of the itereables and the order of the with_ methods (If it is possible). (Not necessarily in the suggested order - but in a readable way).

Suggestion:

    // Assert: transactions are ordered by priority.
    let expected_account_nonces: Vec<(ContractAddress, Nonce)> = add_tx_inputs
        .iter()
        .map(|input| {
            let Account { sender_address, state: AccountState { nonce } } = input.account;
            (sender_address, nonce)
        })
        .collect();
    let expected_queue_txs: Vec<TransactionReference> =
        add_tx_inputs.iter().map(|input| TransactionReference::new(&input.tx)).collect();
    let expected_pool_txs = add_tx_inputs.into_iter().map(|input| input.tx);
    let expected_mempool_content = MempoolContentBuilder::new()
        .with_account_nonces(expected_account_nonces)
        .with_queue(expected_queue_txs)
        .with_pool(expected_pool_txs)
        .build();

@ArniStarkware
Copy link
Contributor

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

Previously, ArniStarkware (Arnon Hod) wrote…

For the record, this suggested code does not require .collect. I am not sure it is a value we should aspire to, though. This suggestion is less readable.

Collect is happening inside anyway.

@ArniStarkware
Copy link
Contributor

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

Previously, ArniStarkware (Arnon Hod) wrote…

Collect is happening inside anyway.

So, I regret that comment.

@ArniStarkware
Copy link
Contributor

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

Previously, ArniStarkware (Arnon Hod) wrote…

Please align the order of the itereables and the order of the with_ methods (If it is possible). (Not necessarily in the suggested order - but in a readable way).

Please also extend this order to the assert lines.

Copy link
Contributor Author

@ayeletstarkware ayeletstarkware 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 2 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware)


Cargo.lock line 9793 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

The lock was updated, but no toml files were updated. This seems odd...

removed


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

Previously, ArniStarkware (Arnon Hod) wrote…

Delete it from this test - and not in general, I see.
Is this the intended behavior?

I considered deleting this function, but it was decided to keep it, so I’m returning to using it.


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

Previously, ArniStarkware (Arnon Hod) wrote…

Please also extend this order to the assert lines.

Due to borrowing constraints, the iterators are in this order. I’ve arranged the following flow as optimally as possible.

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/account_nonce/refactor-nonce-update-in-add-tx- branch from e349c54 to 73a8306 Compare September 24, 2024 10: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.

:lgtm:

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)

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.

2 participants