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

[Core] MemPool package tracking and limits #1647

Merged

Conversation

random-zebra
Copy link

@random-zebra random-zebra commented May 26, 2020

built on top of

This PR pulls some updates from upstream in the mempool area, adding the required adjustments for legacy zerocoin txes and updating the functional test suite.

Specifically, here we:

  • track mempool descendants (in-mempool transactions that depend on other mempool transactions)
  • turn mapTx into a boost::multi_index_container that sorts the mempool on 3 criteria:
    • transaction hash
    • fee rate
    • time in the mempool
  • Add a max size for the mempool (throwing away the cheapest txs and bumping the min relay fee, when full)
  • Implement on-the-fly mempool size limit with the flag -maxmempool
  • Implement -checkmempool=N to customize the frequency of the mempool check
  • Implement helper for CTxMemPoolEntry for the unit tests.

Backports:

[*] excluding bitcoin@9e93640 as our default minimum tx fee rate of 10k satoshis is only 0,00003 USD at the time of writing.

@random-zebra random-zebra added Upstream Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes Mempool TX fees and policy labels May 26, 2020
@random-zebra random-zebra added this to the 5.0.0 milestone May 26, 2020
@random-zebra random-zebra self-assigned this May 26, 2020
@random-zebra random-zebra force-pushed the 202005_mempool-package-tracking branch from 49ffb88 to 016291c Compare June 3, 2020 09:36
@random-zebra
Copy link
Author

Rebased on top of master, now that #1645 has been merged.

- backports bitcoin/bitcoin@34628a1

Indexes on:
- Tx Hash
- Fee Rate (fee-per-kb)
@random-zebra random-zebra force-pushed the 202005_mempool-package-tracking branch from 016291c to 66b2e39 Compare June 9, 2020 14:27
@random-zebra
Copy link
Author

Rebased

furszy
furszy previously approved these changes Jun 11, 2020
Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Nice one, ACK 66b2e39 .

@random-zebra
Copy link
Author

Included cherry-picks 6776, 6896 and 7020 and updated PR description.

@random-zebra random-zebra force-pushed the 202005_mempool-package-tracking branch from f31051b to 9889ed0 Compare June 13, 2020 10:44
@random-zebra random-zebra added RPC and removed RPC labels Jun 13, 2020
@random-zebra random-zebra force-pushed the 202005_mempool-package-tracking branch from 9889ed0 to 891842e Compare June 13, 2020 22:45
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

Nit: untranslated help message strings

src/init.cpp Outdated Show resolved Hide resolved
- backports bitcoin/bitcoin@5add7a7

Associate with each CTxMemPoolEntry all the size/fees of descendant
mempool transactions.  Sort mempool by max(feerate of entry, feerate
of descendants).  Update statistics on-the-fly as transactions enter
or leave the mempool.

Also add ancestor and descendant limiting, so that transactions can
be rejected if the number or size of unconfirmed ancestors exceeds
a target, or if adding a transaction would cause some other mempool
entry to have too many (or too large) a set of unconfirmed in-
mempool descendants.
- backports bitcoin/bitcoin@49b6fd5

(note the 9x multiplier on (void*)'s for CTxMemPool::DynamicMemoryUsage
 was accidentally introduced in 5add7a7 but should have waited for this
 commit which adds the extra index)
- backports bitcoin/bitcoin@794a8ce

After each transaction which is added to mempool, we first call
Expire() to remove old transactions, then throwing away the
lowest-feerate transactions.

After throwing away transactions by feerate, we set the minimum
relay fee to the maximum fee transaction-and-dependant-set we
removed, plus the default minimum relay fee.

After the next block is received, the minimum relay fee is allowed
to decrease exponentially. Its halflife defaults to 12 hours, but
is decreased to 6 hours if the mempool is smaller than half its
maximum size, and 3 hours if the mempool is smaller than a quarter
its maximum size.

The minimum -maxmempool size is 40*-limitdescendantsize, as it is
easy for an attacker to play games with the cheapest
-limitdescendantsize transactions. -maxmempool defaults to 300MB.

This disables high-priority transaction relay when the min relay
fee adjustment is >0 (ie when the mempool is full). When the relay
fee adjustment drops below the default minimum relay fee / 2 it is
set to 0 (re-enabling priority-based free relay).
random-zebra and others added 9 commits June 14, 2020 01:26
- backports bitcoin/bitcoin@0d699fc

Current master crashes on OSX with an exception: "boost: mutex lock
failed in pthread_mutex_lock: Invalid argument"
- backports bitcoin/bitcoin@971a4e6

Reduce the default limits on maximum number of transactions and the
cumulative size of those transactions in both ancestor and descendant
packages to 25 txs and 101kb total size.
@random-zebra random-zebra force-pushed the 202005_mempool-package-tracking branch from 891842e to 2105947 Compare June 13, 2020 23:27
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

utACK 2105947

@random-zebra random-zebra requested a review from furszy June 14, 2020 13:35
Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Re utACK 2105947 and merging this nice upgrade :) .

perpetual updating PIVX Core to BTC Core automation moved this from In Progress to Ready Jun 14, 2020
@furszy furszy merged commit eb00d0f into PIVX-Project:master Jun 14, 2020
perpetual updating PIVX Core to BTC Core automation moved this from Ready to Done Jun 14, 2020
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Jun 24, 2020
Document the changes introduced in:

- PIVX-Project#1549: Nuke zPIV from the GUI
- PIVX-Project#1586: Minimum value for stake split threshold
- PIVX-Project#1633: Bitcoin 0.12-0.14 serialization improvements
- PIVX-Project#1645: Implement accurate memory accounting for mempool
- PIVX-Project#1647: MemPool package tracking and limits
- PIVX-Project#1650: Benchmarking Framework
- PIVX-Project#1688: TopBar navigation (sync/peers)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Jun 24, 2020
Document the changes introduced in:

- PIVX-Project#1549: Nuke zPIV from the GUI
- PIVX-Project#1586: Minimum value for stake split threshold
- PIVX-Project#1633: Bitcoin 0.12-0.14 serialization improvements
- PIVX-Project#1645: Implement accurate memory accounting for mempool
- PIVX-Project#1647: MemPool package tracking and limits
- PIVX-Project#1650: Benchmarking Framework
- PIVX-Project#1688: TopBar navigation (sync/peers)
random-zebra added a commit that referenced this pull request Jun 29, 2020
4819ee7 [Doc] Add/Update some release notes for 4.2 (random-zebra)

Pull request description:

  Document the changes introduced in:

  - #1549: Nuke zPIV from the GUI
  - #1586: Minimum value for stake split threshold
  - #1633: Bitcoin 0.12-0.14 serialization improvements
  - #1645: Implement accurate memory accounting for mempool
  - #1647: MemPool package tracking and limits
  - #1650: Benchmarking Framework
  - #1688: TopBar navigation (sync/peers)

ACKs for top commit:
  furszy:
    utACK 4819ee7
  Fuzzbawls:
    ACK 4819ee7

Tree-SHA512: 62ad949ea26a2f877ef0b40ec86616cc8105f81e1fcd380c8162cd93af04a46f1093f878c0668408654f198a0059b240798b83af3bf1d5e6c1c1d8611276a325
@random-zebra random-zebra removed the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Jun 29, 2020
Liquid369 added a commit to Liquid369/PIVX that referenced this pull request Jun 30, 2020
[Doc] Add/Update some release notes for 4.2

Document the changes introduced in:

- PIVX-Project#1549: Nuke zPIV from the GUI
- PIVX-Project#1586: Minimum value for stake split threshold
- PIVX-Project#1633: Bitcoin 0.12-0.14 serialization improvements
- PIVX-Project#1645: Implement accurate memory accounting for mempool
- PIVX-Project#1647: MemPool package tracking and limits
- PIVX-Project#1650: Benchmarking Framework
- PIVX-Project#1688: TopBar navigation (sync/peers)

Update settingsfaqwidget.ui

Fix Linter
Liquid369 added a commit to Liquid369/PIVX that referenced this pull request Jun 30, 2020
[Doc] Add/Update some release notes for 4.2

Document the changes introduced in:

- PIVX-Project#1549: Nuke zPIV from the GUI
- PIVX-Project#1586: Minimum value for stake split threshold
- PIVX-Project#1633: Bitcoin 0.12-0.14 serialization improvements
- PIVX-Project#1645: Implement accurate memory accounting for mempool
- PIVX-Project#1647: MemPool package tracking and limits
- PIVX-Project#1650: Benchmarking Framework
- PIVX-Project#1688: TopBar navigation (sync/peers)

Update settingsfaqwidget.ui

Fix Linter

[RPC] Register calls where they are defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

5 participants