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

test(mempool): impl update gas price threshold flow test #1882

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

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Nov 7, 2024

I've made update_gas_price_threshold API to be public, so I can use it flow test.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 3.02%. Comparing base (e3165c4) to head (fd719f9).
Report is 337 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #1882       +/-   ##
==========================================
- Coverage   40.10%   3.02%   -37.09%     
==========================================
  Files          26     108       +82     
  Lines        1895   13766    +11871     
  Branches     1895   13766    +11871     
==========================================
- Hits          760     416      -344     
- Misses       1100   13332    +12232     
+ Partials       35      18       -17     

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

@MohammadNassar1 MohammadNassar1 changed the title test(mempool) impl update-gas-price-threshold flow test test(mempool) impl update gas price threshold flow test Nov 7, 2024
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool-test/impl-update-gas-price-threshold-flow-test branch from 1600fe6 to 8648666 Compare November 10, 2024 10:54
@MohammadNassar1 MohammadNassar1 changed the title test(mempool) impl update gas price threshold flow test test(mempool): impl update gas price threshold flow test Nov 10, 2024
Copy link
Contributor

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

Reviewed 2 of 4 files at r1, all commit messages.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

    // Setup.
    let input_tip_100_gas_price_20 =
        add_tx_input!(tx_hash: 1, address: "0x0", tip: 100, max_l2_gas_price: 20);

why do we need to mention the tip?

Code quote:

tip: 100

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: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

why do we need to mention the tip?

I added tip in the name as it's the priority order, and to show that although the first tx has a higher tip, mempool couldn't get the first tx as the gas price threshold is high.
wdyt?

Copy link
Contributor

@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: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

I added tip in the name as it's the priority order, and to show that although the first tx has a higher tip, mempool couldn't get the first tx as the gas price threshold is high.
wdyt?

I think the tip should be tested in a unitest: create a mempool with high threshold, and one tx with high tip, low gas price, and call get_txs.

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: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

I think the tip should be tested in a unitest: create a mempool with high threshold, and one tx with high tip, low gas price, and call get_txs.

I already have a unit test that checks get_txs functionality with different gas price values.

This test checks both update_gas_price_threshold and get_txs.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/mempool-test/impl-update-gas-price-threshold-flow-test branch from 8648666 to fd719f9 Compare November 12, 2024 16:39
Copy link
Contributor

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

:lgtm:

Reviewed 1 of 4 files at r1, 4 of 4 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

I already have a unit test that checks get_txs functionality with different gas price values.

This test checks both update_gas_price_threshold and get_txs.

Ok, I'm not sure it's necessary since it's being checked in a unit test, but it's up to you.

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)


crates/mempool/tests/flow_test.rs line 298 at r2 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

Ok, I'm not sure it's necessary since it's being checked in a unit test, but it's up to you.

I've implemented a unit test that checks get_txs with pending queue.

We need this flow test, as it checks a flow that can happened and verify the invariant that mempool pops out only txs with gas prices higher than the threshold while updating the gas threshold.


crates/mempool/tests/flow_test.rs line 311 at r2 (raw file):

    mempool.update_gas_price_threshold(GasPrice(30));
    get_txs_and_assert_expected(&mut mempool, 2, &[input_tip_50_gas_price_30.tx]);

In a real scenario, we would call update_gas_price_threshold only after a new round, which occurs after commit_block.

I didn't add commit_block in this test to simplify it, as including it wouldn't affect the test outcome.

wdyt?

Code quote:

    mempool.update_gas_price_threshold(GasPrice(40));
    get_txs_and_assert_expected(&mut mempool, 2, &[]);

    mempool.update_gas_price_threshold(GasPrice(30));
    get_txs_and_assert_expected(&mut mempool, 2, &[input_tip_50_gas_price_30.tx]);

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