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

Pass the mempool config to the mempool #2861

Merged
merged 6 commits into from
Oct 12, 2021
Merged

Pass the mempool config to the mempool #2861

merged 6 commits into from
Oct 12, 2021

Conversation

teor2345
Copy link
Contributor

Motivation

To implement ZIP-401, we need to pass the mempool config to the mempool.

This is a high priority, because ZIP-401 is on the critical path.
This PR is unexpected work - it wasn't done as part of creating the mempool config.

Solution

Functionality:

  • Pass the mempool config to the mempool

Refactors:

  • Split mempool config into its own module
  • Create the transaction sender channel inside the mempool
    • Refactor a setup function out of the mempool unit tests

Review

@dconnolly might want to review this PR, because the config is needed for ticket #2780.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Also:
- expand config docs
- clean up mempool imports
This simplifies all the code that calls the mempool.

Also:
- update the mempool enabled state before returning the new mempool
- add some test module doc comments
Also:
- update the setup function to handle the latest mempool changes
@teor2345 teor2345 added A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement C-cleanup Category: This is a cleanup P-High labels Oct 12, 2021
@teor2345 teor2345 requested a review from dconnolly October 12, 2021 04:17
@teor2345 teor2345 self-assigned this Oct 12, 2021
@teor2345 teor2345 added this to the 2021 Sprint 20 milestone Oct 12, 2021
@teor2345 teor2345 changed the title Use mempool config Pass the mempool config to the mempool Oct 12, 2021
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

zebrad/src/components/mempool/tests/vector.rs Show resolved Hide resolved
@conradoplg conradoplg enabled auto-merge (squash) October 12, 2021 17:03
@conradoplg conradoplg merged commit b274ee4 into main Oct 12, 2021
@conradoplg conradoplg deleted the use-mempool-config branch October 12, 2021 17:31
Comment on lines +135 to +145
_config: &Config,
outbound: Outbound,
state: State,
tx_verifier: TxVerifier,
sync_status: SyncStatus,
latest_chain_tip: zs::LatestChainTip,
chain_tip_change: ChainTipChange,
transaction_sender: watch::Sender<HashSet<UnminedTxId>>,
) -> Self {
Mempool {
) -> (Self, watch::Receiver<HashSet<UnminedTxId>>) {
let (transaction_sender, transaction_receiver) =
tokio::sync::watch::channel(HashSet::new());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +157 to +159
// Make sure `is_enabled` is accurate.
// Otherwise, it is only updated in `poll_ready`, right before each service call.
service.update_state();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +10 to +27
/// The mempool transaction cost limit.
///
/// This limits the total serialized byte size of all transactions in the mempool.
///
/// This corresponds to `mempooltxcostlimit` from [ZIP-401](https://zips.z.cash/zip-0401#specification).
pub tx_cost_limit: u32,

/// The mempool transaction eviction age limit.
///
/// This limits the maximum amount of time evicted transaction IDs stay in the mempool rejection list.
/// Transactions are randomly evicted from the mempool when the mempool reaches [`tx_cost_limit`].
///
/// (Transactions can also be rejected by the mempool for other reasons.
/// Different rejection reasons can have different age limits.)
///
/// This corresponds to `mempoolevictionmemoryminutes` from
/// [ZIP-401](https://zips.z.cash/zip-0401#specification).
pub eviction_memory_time: Duration,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💖

Comment on lines +30 to +36
/// Consensus rules:
///
/// > There MUST be a configuration option mempooltxcostlimit,
/// > which SHOULD default to 80000000.
/// >
/// > There MUST be a configuration option mempoolevictionmemoryminutes,
/// > which SHOULD default to 60 [minutes].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +650 to +658
async fn setup(
network: Network,
) -> (
Mempool,
MockPeerSet,
StateService,
MockTxVerifier,
RecentSyncLengths,
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants