Merge pull request #5029 from PastaPastaPasta/backport/18.0.2-backports

Backport: 18.0.2 backports
This commit is contained in:
UdjinM6 2022-09-30 18:53:59 +03:00 committed by GitHub
commit 4d4ebfa7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 580 additions and 298 deletions

View File

@ -1,7 +1,7 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 18)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_BUILD, 2)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2022)

View File

@ -1,14 +1,11 @@
Dash Core version v18.0.1
=========================
Dash Core version 18.0.2
========================
Release is now available from:
<https://www.dash.org/downloads/#wallets>
This is a new major version release, bringing new features, various bugfixes
and other improvements.
This release is mandatory for all nodes.
This is a new hotfix release.
Please report bugs using the issue tracker at github:
@ -54,246 +51,30 @@ is not recommended.
Notable changes
===============
Quorum rotation
--------------
InstantSend quorums will now use a new quorum type and a new algorithm for
establishing quorums. The upcoming DIP-0024 will provide comprehensive details.
This release resolves some excessive memory usage via the "evo" database (evodb).
Quorum rotation is activated via a BIP9 style hard fork that will begin
signalling on August 15, 2022 using bit 7. New quorums will start forming in
1152-1440 block range after the activation. Any nodes that do not upgrade by
that time will diverge from the rest of the network.
18.0.2 Change log
===================
Deterministic InstantSend
-------------------------
Deterministically verifying InstantSend locks at any point in the future has
been added to support Dash Platform. This update introduces versioning to
InstantSend messages and adds quorum information to them. While the previous
design was sufficient for core chain payments, the platform chain will benefit
from this enhanced verification capability. Details about deterministic
InstantSend are provided in [DIP-0022](https://github.com/dashpay/dips/blob/master/dip-0022.md).
See detailed [set of changes](https://github.com/dashpay/dash/compare/v18.0.1...dashpay:v18.0.2`).
Deterministic InstantSend will be activated with the DIP0024 hard fork.
Governance
----------
Several improvements have been made to Dashs DAO governance system.
The governance proposal fee has been reduced from 5 Dash to 1 Dash following
a vote by masternode owners to do so. For improved security and flexibility,
proposal payouts to pay-to-script-hash (P2SH) addresses are now supported.
These changes will be activated with the DIP0024 hard fork.
Governance proposals can now be viewed in GUI Governance tab (must be enabled
in Preferences first).
Initial Enhanced Hard Fork support
----------------------------------
The masternode hard fork signal special transaction has been added as the first
step in enabling an improved hard fork mechanism. This enhancement enables
future hard forks to be activated quickly and safely without any
“race conditions” if miners and masternodes update at significantly different
speeds. Effectively there will be a masternode signal on chain in addition to
the miner one to ensure smooth transitions. Details of the enhanced hard fork
system are provided in [DIP-0023](https://github.com/dashpay/dips/blob/master/dip-0023.md).
Network improvements
--------------------
We implemented and backported implementations of several improvement proposals.
You can read more about implemented changes in the following documents:
- [`DIP-0025`](https://gist.github.com/thephez/6c4c2a7747298e8b3e528c0c4e98a68c): Compressed headers.
- [`BIP 155`](https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki): The 'addrv2' and 'sendaddrv2' messages which enable relay of Tor V3 addresses (and other networks).
- [`BIP 158`](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki): Compact Block Filters for Light Clients.
KeePass support removed
-----------------------
Please make sure to move your coins to a wallet with a regular passphrase.
Wallet changes
--------------
We continued backporting wallet functionality updates. Most notable changes
are:
- Added support for empty, encrypted-on-creation and watch-only wallets.
- Wallets can now be created, opened and closed via a GUI menu.
- No more `salvagewallet` option in cmd-line and Repair tab in GUI. Check the
`salvage` command in the `dash-wallet` tool.
Indexes
-------
The transaction index is moved into `indexes/` folder. The migration of the old
data is done on the first run and does not require reindexing. Note that the data
in the old path is removed which means that this change is not backwards
compatible and you'll have to reindex the whole blockchain if you decide to
downgrade to a pre-v18.0.1 version.
Remote Procedure Call (RPC) Changes
-----------------------------------
Most changes here were introduced through Bitcoin backports mostly related to
the deprecation of wallet accounts in DashCore v0.17 and introduction of PSBT
format.
The new RPCs are:
- `combinepsbt`
- `converttopsbt`
- `createpsbt`
- `decodepsbt`
- `deriveaddresses`
- `finalizepsbt`
- `getblockfilter`
- `getdescriptorinfo`
- `getnodeaddresses`
- `getrpcinfo`
- `joinpsbts`
- `listwalletdir`
- `quorum rotationinfo`
- `scantxoutset`
- `submitheader`
- `testmempoolaccept`
- `utxoupdatepsbt`
- `walletcreatefundedpsbt`
- `walletprocesspsbt`
The removed RPCs are:
- `estimatefee`
- `getinfo`
- `getreceivedbyaccount`
- `keepass`
- `listaccounts`
- `listreceivedbyaccount`
- `move`
- `resendwallettransactions`
- `sendfrom`
- `signrawtransaction`
Changes in existing RPCs introduced through bitcoin backports:
- The `testnet` field in `dash-cli -getinfo` has been renamed to `chain` and
now returns the current network name as defined in BIP70 (main, test, regtest).
- Added `window_final_block_height` in `getchaintxstats`
- Added `feerate_percentiles` object with feerates at the 10th, 25th, 50th,
75th, and 90th percentile weight unit instead of `medianfeerate` in
`getblockstats`
- In `getmempoolancestors`, `getmempooldescendants`, `getmempoolentry` and
`getrawmempool` RPCs, to be consistent with the returned value and other RPCs
such as `getrawtransaction`, `vsize` has been added and `size` is now
deprecated. `size` will only be returned if `dashd` is started with
`-deprecatedrpc=size`.
- Added `loaded` in mempool related RPCs indicates whether the mempool is fully
loaded or not
- Added `localservicesnames` in `getnetworkinfo` list the services the node
offers to the network, in human-readable form (in addition to an already
existing `localservices` hex string)
- Added `hwm` in `getzmqnotifications`
- `createwallet` can create blank, encrypted or watch-only wallets now.
- Added `private_keys_enabled` in `getwalletinfo`
- Added `solvable`, `desc`, `ischange` and `hdmasterfingerprint` in `getaddressinfo`
- Added `desc` in `listunspent`
Dash-specific changes in existing RPCs:
- Added `quorumIndex` in `quorum getinfo` and `quorum memberof`
- In rpc `masternodelist` with parameters `full`, `info` and `json` the PoS penalty score of the MN will be returned. For `json` parameter, the field `pospenaltyscore` was added.
Please check `help <command>` for more detailed information on specific RPCs.
Command-line options
--------------------
Most changes here were introduced through Bitcoin backports.
New cmd-line options:
- `asmap`
- `avoidpartialspends`
- `blockfilterindex`
- `blocksonly`
- `llmqinstantsenddip0024`
- `llmqtestinstantsendparams`
- `maxuploadtarget`
- `natpmp`
- `peerblockfilters`
- `powtargetspacing`
- `stdinwalletpassphrase`
- `zmqpubhashchainlock`
- `zmqpubrawchainlock`
The option to set the PUB socket's outbound message high water mark
(SNDHWM) may be set individually for each notification:
- `-zmqpubhashtxhwm=n`
- `-zmqpubhashblockhwm=n`
- `-zmqpubhashchainlockhwm=n`
- `-zmqpubhashtxlockhwm=n`
- `-zmqpubhashgovernancevotehwm=n`
- `-zmqpubhashgovernanceobjecthwm=n`
- `-zmqpubhashinstantsenddoublespendhwm=n`
- `-zmqpubhashrecoveredsighwm=n`
- `-zmqpubrawblockhwm=n`
- `-zmqpubrawtxhwm=n`
- `-zmqpubrawchainlockhwm=n`
- `-zmqpubrawchainlocksighwm=n`
- `-zmqpubrawtxlockhwm=n`
- `-zmqpubrawtxlocksighwm=n`
- `-zmqpubrawgovernancevotehwm=n`
- `-zmqpubrawgovernanceobjecthwm=n`
- `-zmqpubrawinstantsenddoublespendhwm=n`
- `-zmqpubrawrecoveredsighwm=n`
Removed cmd-line options:
- `keepass`
- `keepassport`
- `keepasskey`
- `keepassid`
- `keepassname`
- `salvagewallet`
Changes in existing cmd-line options:
Please check `Help -> Command-line options` in Qt wallet or `dashd --help` for
more information.
Backports from Bitcoin Core
---------------------------
This release introduces over 1000 updates from Bitcoin v0.18/v0.19/v0.20 as well as numerous updates from Bitcoin v0.21 and more recent versions. This includes multi-wallet support in the GUI, support for partially signed transactions (PSBT), Tor version 3 support, and a number of other updates that will benefit Dash users. Bitcoin changes that do not align with Dashs product needs, such as SegWit and RBF, are excluded from our backporting. For additional detail on whats included in Bitcoin, please refer to their release notes v0.18, v0.19, v0.20.
Miscellaneous
-------------
A lot of refactoring, code cleanups and other small fixes were done in this release.
v18.0.1 Change log
==================
See detailed [set of changes](https://github.com/dashpay/dash/compare/v0.17.0.3...dashpay:v18.0.1).
- [`666ff7bff9`](https://github.com/dashpay/dash/commit/666ff7bff9) merge bitcoin#14193: Add missing mempool locks
- [`96f4022a6a`](https://github.com/dashpay/dash/commit/96f4022a6a) chore: archive release-nodes.md
- [`0b60096d8a`](https://github.com/dashpay/dash/commit/0b60096d8a) chore: bump version to 18.0.2
- [`e8afde2740`](https://github.com/dashpay/dash/commit/e8afde2740) fix: Flush chainstate (and evodb) cache whenever evodb mem usage is getting too high (#5007)
- [`8efd7f04c6`](https://github.com/dashpay/dash/commit/8efd7f04c6) Merge bitcoin/bitcoin#25739: Update leveldb subtree (#5005)
- [`c92cbce6a5`](https://github.com/dashpay/dash/commit/c92cbce6a5) trivial: Fix trailing whitespaces in release notes (#4989)
Credits
=======
Thanks to everyone who directly contributed to this release:
- AJ ONeal (coolaj86)
- Christian Fifi Culp (christiancfifi)
- dustinface (xdustinface)
- gabriel-bjg
- Holger Schinzel (schinzelh)
- humbleDasher
- Kittywhiskers Van Gogh (kittywhiskers)
- Konstantin Akimov (knst)
- ktechmidas
- linuxsh2
- Munkybooty
- Nathan Marley (nmarley)
- Odysseas Gabrielides (ogabrielides)
- kittywhiskers
- PastaPastaPasta
- pravblockc
- rkarthik2k21
- Stefan (5tefan)
- strophy
- TheLazieR Yip (thelazier)
- thephez
- UdjinM6
- Vijay (vijaydasmp)
- Vlad K (dzutto)
As well as everyone that submitted issues, reviewed pull requests, helped debug the release candidates, and write DIPs that were implemented in this release. Notable mentions include:
- Samuel Westrich (quantumexplorer)
- Virgile Bartolo
- xkcd
As well as everyone that submitted issues and reviewed pull requests.
Older releases
==============
@ -318,6 +99,7 @@ Dash Core tree 0.12.1.x was a fork of Bitcoin Core tree 0.12.
These release are considered obsolete. Old release notes can be found here:
- [v18.0.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-18.0.1.md) released Aug/17/2022
- [v0.17.0.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.17.0.3.md) released June/07/2021
- [v0.17.0.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.17.0.2.md) released May/19/2021
- [v0.16.1.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.16.1.1.md) released November/17/2020

View File

@ -0,0 +1,350 @@
Dash Core version v18.0.1
=========================
Release is now available from:
<https://www.dash.org/downloads/#wallets>
This is a new major version release, bringing new features, various bugfixes
and other improvements.
This release is mandatory for all nodes.
Please report bugs using the issue tracker at github:
<https://github.com/dashpay/dash/issues>
Upgrading and downgrading
=========================
How to Upgrade
--------------
If you are running an older version, shut it down. Wait until it has completely
shut down (which might take a few minutes for older versions), then run the
installer (on Windows) or just copy over /Applications/Dash-Qt (on Mac) or
dashd/dash-qt (on Linux). If you upgrade after DIP0003 activation and you were
using version < 0.13 you will have to reindex (start with -reindex-chainstate
or -reindex) to make sure your wallet has all the new data synced. Upgrading
from version 0.13 should not require any additional actions.
When upgrading from a version prior to 18.0.1, the
first startup of Dash Core will run a migration process which can take anywhere
from a few minutes to thirty minutes to finish. After the migration, a
downgrade to an older version is only possible with a reindex
(or reindex-chainstate).
Downgrade warning
-----------------
### Downgrade to a version < v18.0.1
Downgrading to a version older than v18.0.1 is not supported due to changes in
the indexes database folder. If you need to use an older version, you must
either reindex or re-sync the whole chain.
### Downgrade of masternodes to < v18.0.1
Starting with the 0.16 release, masternodes verify the protocol version of other
masternodes. This results in PoSe punishment/banning for outdated masternodes,
so downgrading even prior to the activation of the introduced hard-fork changes
is not recommended.
Notable changes
===============
Quorum rotation
--------------
InstantSend quorums will now use a new quorum type and a new algorithm for
establishing quorums. The upcoming DIP-0024 will provide comprehensive details.
Quorum rotation is activated via a BIP9 style hard fork that will begin
signalling on August 15, 2022 using bit 7. New quorums will start forming in
1152-1440 block range after the activation. Any nodes that do not upgrade by
that time will diverge from the rest of the network.
Deterministic InstantSend
-------------------------
Deterministically verifying InstantSend locks at any point in the future has
been added to support Dash Platform. This update introduces versioning to
InstantSend messages and adds quorum information to them. While the previous
design was sufficient for core chain payments, the platform chain will benefit
from this enhanced verification capability. Details about deterministic
InstantSend are provided in [DIP-0022](https://github.com/dashpay/dips/blob/master/dip-0022.md).
Deterministic InstantSend will be activated with the DIP0024 hard fork.
Governance
----------
Several improvements have been made to Dashs DAO governance system.
The governance proposal fee has been reduced from 5 Dash to 1 Dash following
a vote by masternode owners to do so. For improved security and flexibility,
proposal payouts to pay-to-script-hash (P2SH) addresses are now supported.
These changes will be activated with the DIP0024 hard fork.
Governance proposals can now be viewed in GUI Governance tab (must be enabled
in Preferences first).
Initial Enhanced Hard Fork support
----------------------------------
The masternode hard fork signal special transaction has been added as the first
step in enabling an improved hard fork mechanism. This enhancement enables
future hard forks to be activated quickly and safely without any
“race conditions” if miners and masternodes update at significantly different
speeds. Effectively there will be a masternode signal on chain in addition to
the miner one to ensure smooth transitions. Details of the enhanced hard fork
system are provided in [DIP-0023](https://github.com/dashpay/dips/blob/master/dip-0023.md).
Network improvements
--------------------
We implemented and backported implementations of several improvement proposals.
You can read more about implemented changes in the following documents:
- [`DIP-0025`](https://gist.github.com/thephez/6c4c2a7747298e8b3e528c0c4e98a68c): Compressed headers.
- [`BIP 155`](https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki): The 'addrv2' and 'sendaddrv2' messages which enable relay of Tor V3 addresses (and other networks).
- [`BIP 158`](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki): Compact Block Filters for Light Clients.
KeePass support removed
-----------------------
Please make sure to move your coins to a wallet with a regular passphrase.
Wallet changes
--------------
We continued backporting wallet functionality updates. Most notable changes
are:
- Added support for empty, encrypted-on-creation and watch-only wallets.
- Wallets can now be created, opened and closed via a GUI menu.
- No more `salvagewallet` option in cmd-line and Repair tab in GUI. Check the
`salvage` command in the `dash-wallet` tool.
Indexes
-------
The transaction index is moved into `indexes/` folder. The migration of the old
data is done on the first run and does not require reindexing. Note that the data
in the old path is removed which means that this change is not backwards
compatible and you'll have to reindex the whole blockchain if you decide to
downgrade to a pre-v18.0.1 version.
Remote Procedure Call (RPC) Changes
-----------------------------------
Most changes here were introduced through Bitcoin backports mostly related to
the deprecation of wallet accounts in DashCore v0.17 and introduction of PSBT
format.
The new RPCs are:
- `combinepsbt`
- `converttopsbt`
- `createpsbt`
- `decodepsbt`
- `deriveaddresses`
- `finalizepsbt`
- `getblockfilter`
- `getdescriptorinfo`
- `getnodeaddresses`
- `getrpcinfo`
- `joinpsbts`
- `listwalletdir`
- `quorum rotationinfo`
- `scantxoutset`
- `submitheader`
- `testmempoolaccept`
- `utxoupdatepsbt`
- `walletcreatefundedpsbt`
- `walletprocesspsbt`
The removed RPCs are:
- `estimatefee`
- `getinfo`
- `getreceivedbyaccount`
- `keepass`
- `listaccounts`
- `listreceivedbyaccount`
- `move`
- `resendwallettransactions`
- `sendfrom`
- `signrawtransaction`
Changes in existing RPCs introduced through bitcoin backports:
- The `testnet` field in `dash-cli -getinfo` has been renamed to `chain` and
now returns the current network name as defined in BIP70 (main, test, regtest).
- Added `window_final_block_height` in `getchaintxstats`
- Added `feerate_percentiles` object with feerates at the 10th, 25th, 50th,
75th, and 90th percentile weight unit instead of `medianfeerate` in
`getblockstats`
- In `getmempoolancestors`, `getmempooldescendants`, `getmempoolentry` and
`getrawmempool` RPCs, to be consistent with the returned value and other RPCs
such as `getrawtransaction`, `vsize` has been added and `size` is now
deprecated. `size` will only be returned if `dashd` is started with
`-deprecatedrpc=size`.
- Added `loaded` in mempool related RPCs indicates whether the mempool is fully
loaded or not
- Added `localservicesnames` in `getnetworkinfo` list the services the node
offers to the network, in human-readable form (in addition to an already
existing `localservices` hex string)
- Added `hwm` in `getzmqnotifications`
- `createwallet` can create blank, encrypted or watch-only wallets now.
- Added `private_keys_enabled` in `getwalletinfo`
- Added `solvable`, `desc`, `ischange` and `hdmasterfingerprint` in `getaddressinfo`
- Added `desc` in `listunspent`
Dash-specific changes in existing RPCs:
- Added `quorumIndex` in `quorum getinfo` and `quorum memberof`
- In rpc `masternodelist` with parameters `full`, `info` and `json` the PoS penalty score of the MN will be returned. For `json` parameter, the field `pospenaltyscore` was added.
Please check `help <command>` for more detailed information on specific RPCs.
Command-line options
--------------------
Most changes here were introduced through Bitcoin backports.
New cmd-line options:
- `asmap`
- `avoidpartialspends`
- `blockfilterindex`
- `blocksonly`
- `llmqinstantsenddip0024`
- `llmqtestinstantsendparams`
- `maxuploadtarget`
- `natpmp`
- `peerblockfilters`
- `powtargetspacing`
- `stdinwalletpassphrase`
- `zmqpubhashchainlock`
- `zmqpubrawchainlock`
The option to set the PUB socket's outbound message high water mark
(SNDHWM) may be set individually for each notification:
- `-zmqpubhashtxhwm=n`
- `-zmqpubhashblockhwm=n`
- `-zmqpubhashchainlockhwm=n`
- `-zmqpubhashtxlockhwm=n`
- `-zmqpubhashgovernancevotehwm=n`
- `-zmqpubhashgovernanceobjecthwm=n`
- `-zmqpubhashinstantsenddoublespendhwm=n`
- `-zmqpubhashrecoveredsighwm=n`
- `-zmqpubrawblockhwm=n`
- `-zmqpubrawtxhwm=n`
- `-zmqpubrawchainlockhwm=n`
- `-zmqpubrawchainlocksighwm=n`
- `-zmqpubrawtxlockhwm=n`
- `-zmqpubrawtxlocksighwm=n`
- `-zmqpubrawgovernancevotehwm=n`
- `-zmqpubrawgovernanceobjecthwm=n`
- `-zmqpubrawinstantsenddoublespendhwm=n`
- `-zmqpubrawrecoveredsighwm=n`
Removed cmd-line options:
- `keepass`
- `keepassport`
- `keepasskey`
- `keepassid`
- `keepassname`
- `salvagewallet`
Changes in existing cmd-line options:
Please check `Help -> Command-line options` in Qt wallet or `dashd --help` for
more information.
Backports from Bitcoin Core
---------------------------
This release introduces over 1000 updates from Bitcoin v0.18/v0.19/v0.20 as well as numerous updates from Bitcoin v0.21 and more recent versions. This includes multi-wallet support in the GUI, support for partially signed transactions (PSBT), Tor version 3 support, and a number of other updates that will benefit Dash users. Bitcoin changes that do not align with Dashs product needs, such as SegWit and RBF, are excluded from our backporting. For additional detail on whats included in Bitcoin, please refer to their release notes v0.18, v0.19, v0.20.
Miscellaneous
-------------
A lot of refactoring, code cleanups and other small fixes were done in this release.
v18.0.1 Change log
==================
See detailed [set of changes](https://github.com/dashpay/dash/compare/v0.17.0.3...dashpay:v18.0.1).
Credits
=======
Thanks to everyone who directly contributed to this release:
- AJ ONeal (coolaj86)
- Christian Fifi Culp (christiancfifi)
- dustinface (xdustinface)
- gabriel-bjg
- Holger Schinzel (schinzelh)
- humbleDasher
- Kittywhiskers Van Gogh (kittywhiskers)
- Konstantin Akimov (knst)
- ktechmidas
- linuxsh2
- Munkybooty
- Nathan Marley (nmarley)
- Odysseas Gabrielides (ogabrielides)
- PastaPastaPasta
- pravblockc
- rkarthik2k21
- Stefan (5tefan)
- strophy
- TheLazieR Yip (thelazier)
- thephez
- UdjinM6
- Vijay (vijaydasmp)
- Vlad K (dzutto)
As well as everyone that submitted issues, reviewed pull requests, helped debug the release candidates, and write DIPs that were implemented in this release. Notable mentions include:
- Samuel Westrich (quantumexplorer)
- Virgile Bartolo
- xkcd
Older releases
==============
Dash was previously known as Darkcoin.
Darkcoin tree 0.8.x was a fork of Litecoin tree 0.8, original name was XCoin
which was first released on Jan/18/2014.
Darkcoin tree 0.9.x was the open source implementation of masternodes based on
the 0.8.x tree and was first released on Mar/13/2014.
Darkcoin tree 0.10.x used to be the closed source implementation of Darksend
which was released open source on Sep/25/2014.
Dash Core tree 0.11.x was a fork of Bitcoin Core tree 0.9,
Darkcoin was rebranded to Dash.
Dash Core tree 0.12.0.x was a fork of Bitcoin Core tree 0.10.
Dash Core tree 0.12.1.x was a fork of Bitcoin Core tree 0.12.
These release are considered obsolete. Old release notes can be found here:
- [v0.17.0.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.17.0.3.md) released June/07/2021
- [v0.17.0.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.17.0.2.md) released May/19/2021
- [v0.16.1.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.16.1.1.md) released November/17/2020
- [v0.16.1.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.16.1.0.md) released November/14/2020
- [v0.16.0.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.16.0.1.md) released September/30/2020
- [v0.15.0.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.15.0.0.md) released Febrary/18/2020
- [v0.14.0.5](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.5.md) released December/08/2019
- [v0.14.0.4](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.4.md) released November/22/2019
- [v0.14.0.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.3.md) released August/15/2019
- [v0.14.0.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.2.md) released July/4/2019
- [v0.14.0.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.1.md) released May/31/2019
- [v0.14.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.14.0.md) released May/22/2019
- [v0.13.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.13.3.md) released Apr/04/2019
- [v0.13.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.13.2.md) released Mar/15/2019
- [v0.13.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.13.1.md) released Feb/9/2019
- [v0.13.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.13.0.md) released Jan/14/2019
- [v0.12.3.4](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.3.4.md) released Dec/14/2018
- [v0.12.3.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.3.3.md) released Sep/19/2018
- [v0.12.3.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.3.2.md) released Jul/09/2018
- [v0.12.3.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.3.1.md) released Jul/03/2018
- [v0.12.2.3](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.2.3.md) released Jan/12/2018
- [v0.12.2.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.2.2.md) released Dec/17/2017
- [v0.12.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.2.md) released Nov/08/2017
- [v0.12.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.1.md) released Feb/06/2017
- [v0.12.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.12.0.md) released Aug/15/2015
- [v0.11.2](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.11.2.md) released Mar/04/2015
- [v0.11.1](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.11.1.md) released Feb/10/2015
- [v0.11.0](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.11.0.md) released Jan/15/2015
- [v0.10.x](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.10.0.md) released Sep/25/2014
- [v0.9.x](https://github.com/dashpay/dash/blob/master/doc/release-notes/dash/release-notes-0.9.0.md) released Mar/13/2014

View File

@ -142,7 +142,8 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& msg_typ
return;
}
LOCK2(cs_main, cs);
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
LOCK(cs);
if (mapObjects.count(nHash) || mapPostponedObjects.count(nHash) || mapErasedGovernanceObjects.count(nHash)) {
// TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
@ -261,7 +262,8 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
govobj.UpdateSentinelVariables(); //this sets local vars in object
LOCK2(cs_main, cs);
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
LOCK(cs);
std::string strError;
// MAKE SURE THIS OBJECT IS OK
@ -320,7 +322,8 @@ void CGovernanceManager::UpdateCachesAndClean()
std::vector<uint256> vecDirtyHashes = mmetaman.GetAndClearDirtyGovernanceObjectHashes();
LOCK2(cs_main, cs);
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
LOCK(cs);
for (const uint256& nHash : vecDirtyHashes) {
auto it = mapObjects.find(nHash);
@ -835,7 +838,8 @@ void CGovernanceManager::CheckPostponedObjects(CConnman& connman)
{
if (!masternodeSync.IsSynced()) return;
LOCK2(cs_main, cs);
LOCK2(cs_main, ::mempool.cs); // Lock mempool because of GetTransaction deep inside
LOCK(cs);
// Check postponed proposals
for (auto it = mapPostponedObjects.begin(); it != mapPostponedObjects.end();) {

View File

@ -438,7 +438,7 @@ UniValue CGovernanceObject::ToJson() const
void CGovernanceObject::UpdateLocalValidity()
{
LOCK(cs_main);
AssertLockHeld(cs_main);
// THIS DOES NOT CHECK COLLATERAL, THIS IS CHECKED UPON ORIGINAL ARRIVAL
fCachedLocalValidity = IsValidLocally(strLocalValidityError, false);
}
@ -526,6 +526,9 @@ CAmount CGovernanceObject::GetMinCollateralFee(bool fork_active) const
bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
{
AssertLockHeld(cs_main);
AssertLockHeld(::mempool.cs); // because of GetTransaction
strError = "";
fMissingConfirmations = false;
uint256 nExpectedHash = GetHash();

View File

@ -1932,7 +1932,7 @@ bool AppInitMain(InitInterfaces& interfaces)
nTotalCache -= nCoinDBCache;
nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t nEvoDbCache = 1024 * 1024 * 16; // TODO
int64_t nEvoDbCache = 1024 * 1024 * 64; // TODO
LogPrintf("Cache configuration:\n");
LogPrintf("* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {

View File

@ -49,7 +49,7 @@ constexpr const int kDefaultMmapLimit = (sizeof(void*) >= 8) ? 4096 : 0;
int g_mmap_limit = kDefaultMmapLimit;
// Common flags defined for all posix open operations
#if defined(HAVE_O_CLOEXEC)
#if HAVE_O_CLOEXEC
constexpr const int kOpenBaseFlags = O_CLOEXEC;
#else
constexpr const int kOpenBaseFlags = 0;

View File

@ -4629,7 +4629,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
//
std::vector<CInv> vInv;
{
LOCK(pto->cs_inventory);
LOCK2(mempool.cs, pto->cs_inventory);
size_t reserve = std::min<size_t>(pto->setInventoryTxToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize() / 1000000);
reserve = std::max<size_t>(reserve, pto->vInventoryBlockToSend.size());

View File

@ -392,7 +392,7 @@ static UniValue gobject_submit(const JSONRPCRequest& request)
g_txindex->BlockUntilSyncedToCurrentChain();
}
LOCK(cs_main);
LOCK2(cs_main, ::mempool.cs);
if (!govobj.IsValidLocally(strError, fMissingConfirmations, true) && !fMissingConfirmations) {
LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError);
throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError);

View File

@ -501,7 +501,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
}
// Release the wallet and main lock while waiting
// Release lock while waiting
LEAVE_CRITICAL_SECTION(cs_main);
{
checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
@ -512,6 +512,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
if (g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout)
{
// Timeout: Check transactions for update
// without holding ::mempool.cs to avoid deadlocks
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP)
break;
checktxtime += std::chrono::seconds(10);

View File

@ -5,11 +5,13 @@
#include <boost/test/unit_test.hpp>
#include <chainparams.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <miner.h>
#include <pow.h>
#include <random.h>
#include <script/standard.h>
#include <test/util/setup_common.h>
#include <util/time.h>
#include <validation.h>
@ -17,6 +19,8 @@
#include <thread>
static const std::vector<unsigned char> V_OP_TRUE{OP_TRUE};
BOOST_FIXTURE_TEST_SUITE(validation_block_tests, RegTestingSetup)
struct TestSubscriber : public CValidationInterface {
@ -59,6 +63,23 @@ std::shared_ptr<CBlock> Block(const uint256& prev_hash)
pblock->hashPrevBlock = prev_hash;
pblock->nTime = ++time;
pubKey.clear();
{
pubKey << OP_HASH160 << ToByteVector(CScriptID(CScript() << OP_TRUE))
<< OP_EQUAL;
}
// Make the coinbase transaction with two outputs:
// One zero-value one that has a unique pubkey to make sure that blocks at
// the same height can have a different hash. Another one that has the
// coinbase reward in a P2SH with OP_TRUE as scriptPubKey to make it easy to
// spend
CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.vout.resize(2);
txCoinbase.vout[1].scriptPubKey = pubKey;
txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue;
txCoinbase.vout[0].nValue = 0;
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
return pblock;
}
@ -74,13 +95,13 @@ std::shared_ptr<CBlock> FinalizeBlock(std::shared_ptr<CBlock> pblock)
}
// construct a valid block
const std::shared_ptr<const CBlock> GoodBlock(const uint256& prev_hash)
std::shared_ptr<const CBlock> GoodBlock(const uint256& prev_hash)
{
return FinalizeBlock(Block(prev_hash));
}
// construct an invalid block (but with a valid header)
const std::shared_ptr<const CBlock> BadBlock(const uint256& prev_hash)
std::shared_ptr<const CBlock> BadBlock(const uint256& prev_hash)
{
auto pblock = Block(prev_hash);
@ -180,4 +201,136 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
BOOST_CHECK_EQUAL(sub.m_expected_tip, ::ChainActive().Tip()->GetBlockHash());
}
/**
* Test that mempool updates happen atomically with reorgs.
*
* This prevents RPC clients, among others, from retrieving immediately-out-of-date mempool data
* during large reorgs.
*
* The test verifies this by creating a chain of `num_txs` blocks, matures their coinbases, and then
* submits txns spending from their coinbase to the mempool. A fork chain is then processed,
* invalidating the txns and evicting them from the mempool.
*
* We verify that the mempool updates atomically by polling it continuously
* from another thread during the reorg and checking that its size only changes
* once. The size changing exactly once indicates that the polling thread's
* view of the mempool is either consistent with the chain state before reorg,
* or consistent with the chain state after the reorg, and not just consistent
* with some intermediate state during the reorg.
*/
BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
{
bool ignored;
auto ProcessBlock = [&ignored](std::shared_ptr<const CBlock> block) -> bool {
return ProcessNewBlock(Params(), block, /* fForceProcessing */ true, /* fNewBlock */ &ignored);
};
// Process all mined blocks
BOOST_REQUIRE(ProcessBlock(std::make_shared<CBlock>(Params().GenesisBlock())));
auto last_mined = GoodBlock(Params().GenesisBlock().GetHash());
BOOST_REQUIRE(ProcessBlock(last_mined));
// Run the test multiple times
for (int test_runs = 3; test_runs > 0; --test_runs) {
BOOST_CHECK_EQUAL(last_mined->GetHash(), ::ChainActive().Tip()->GetBlockHash());
// Later on split from here
const uint256 split_hash{last_mined->hashPrevBlock};
// Create a bunch of transactions to spend the miner rewards of the
// most recent blocks
std::vector<CTransactionRef> txs;
for (int num_txs = 22; num_txs > 0; --num_txs) {
CMutableTransaction mtx;
mtx.vin.push_back(
CTxIn(COutPoint(last_mined->vtx[0]->GetHash(), 1),
CScript() << ToByteVector(CScript() << OP_TRUE)));
// Two outputs to make sure the transaction is larger than 100 bytes
for (int i = 1; i < 3; ++i) {
mtx.vout.emplace_back(
CTxOut(50000,
CScript() << OP_DUP << OP_HASH160
<< ToByteVector(CScriptID(CScript() << i))
<< OP_EQUALVERIFY << OP_CHECKSIG));
}
txs.push_back(MakeTransactionRef(mtx));
last_mined = GoodBlock(last_mined->GetHash());
BOOST_REQUIRE(ProcessBlock(last_mined));
}
// Mature the inputs of the txs
for (int j = COINBASE_MATURITY; j > 0; --j) {
last_mined = GoodBlock(last_mined->GetHash());
BOOST_REQUIRE(ProcessBlock(last_mined));
}
// Mine a reorg (and hold it back) before adding the txs to the mempool
const uint256 tip_init{last_mined->GetHash()};
std::vector<std::shared_ptr<const CBlock>> reorg;
last_mined = GoodBlock(split_hash);
reorg.push_back(last_mined);
for (size_t j = COINBASE_MATURITY + txs.size() + 1; j > 0; --j) {
last_mined = GoodBlock(last_mined->GetHash());
reorg.push_back(last_mined);
}
// Add the txs to the tx pool
{
LOCK(cs_main);
CValidationState state;
for (const auto& tx : txs) {
BOOST_REQUIRE(AcceptToMemoryPool(
::mempool,
state,
tx,
/* pfMissingInputs */ &ignored,
/* bypass_limits */ false,
/* nAbsurdFee */ 0));
}
}
// Check that all txs are in the pool
{
LOCK(::mempool.cs);
BOOST_CHECK_EQUAL(::mempool.mapTx.size(), txs.size());
}
// Run a thread that simulates an RPC caller that is polling while
// validation is doing a reorg
std::thread rpc_thread{[&]() {
// This thread is checking that the mempool either contains all of
// the transactions invalidated by the reorg, or none of them, and
// not some intermediate amount.
while (true) {
LOCK(::mempool.cs);
if (::mempool.mapTx.size() == 0) {
// We are done with the reorg
break;
}
// Internally, we might be in the middle of the reorg, but
// externally the reorg to the most-proof-of-work chain should
// be atomic. So the caller assumes that the returned mempool
// is consistent. That is, it has all txs that were there
// before the reorg.
assert(::mempool.mapTx.size() == txs.size());
continue;
}
LOCK(cs_main);
// We are done with the reorg, so the tip must have changed
assert(tip_init != ::ChainActive().Tip()->GetBlockHash());
}};
// Submit the reorg in this thread to invalidate and remove the txs from the tx pool
for (const auto& b : reorg) {
ProcessBlock(b);
}
// Check that the reorg was eventually successful
BOOST_CHECK_EQUAL(last_mined->GetHash(), ::ChainActive().Tip()->GetBlockHash());
// We can join the other thread, which returns when the reorg was successful
rpc_thread.join();
}
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -112,7 +112,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan
// for each such descendant, also update the ancestor state to include the parent.
void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashesToUpdate)
{
LOCK(cs);
AssertLockHeld(cs);
// For each entry in vHashesToUpdate, store the set of in-mempool, but not
// in-vHashesToUpdate transactions, so that we don't have to recalculate
// descendants when we come across a previously seen entry.
@ -332,8 +332,8 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
assert(int(nSigOpCountWithAncestors) >= 0);
}
CTxMemPool::CTxMemPool(CBlockPolicyEstimator* estimator) :
nTransactionsUpdated(0), minerPolicyEstimator(estimator), m_epoch(0), m_has_epoch_guard(false)
CTxMemPool::CTxMemPool(CBlockPolicyEstimator* estimator)
: nTransactionsUpdated(0), minerPolicyEstimator(estimator), m_epoch(0), m_has_epoch_guard(false)
{
_clear(); //lock free clear
@ -351,13 +351,11 @@ bool CTxMemPool::isSpent(const COutPoint& outpoint) const
unsigned int CTxMemPool::GetTransactionsUpdated() const
{
LOCK(cs);
return nTransactionsUpdated;
}
void CTxMemPool::AddTransactionsUpdated(unsigned int n)
{
LOCK(cs);
nTransactionsUpdated += n;
}
@ -722,8 +720,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries& setDescendants
void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReason reason)
{
// Remove transaction from memory pool
{
LOCK(cs);
AssertLockHeld(cs);
setEntries txToRemove;
txiter origit = mapTx.find(origTx.GetHash());
if (origit != mapTx.end()) {
@ -749,12 +746,11 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso
RemoveStaged(setAllRemoves, false, reason);
}
}
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
LOCK(cs);
AssertLockHeld(cs);
setEntries txToRemove;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
@ -969,7 +965,7 @@ void CTxMemPool::removeProTxConflicts(const CTransaction &tx)
*/
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
{
LOCK(cs);
AssertLockHeld(cs);
std::vector<const CTxMemPoolEntry*> entries;
for (const auto& tx : vtx)
{
@ -1436,7 +1432,7 @@ void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPool
}
int CTxMemPool::Expire(int64_t time) {
LOCK(cs);
AssertLockHeld(cs);
indexed_transaction_set::index<entry_time>::type::iterator it = mapTx.get<entry_time>().begin();
setEntries toremove;
while (it != mapTx.get<entry_time>().end() && it->GetTime() < time) {
@ -1534,7 +1530,7 @@ void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
}
void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining) {
LOCK(cs);
AssertLockHeld(cs);
unsigned nTxnRemoved = 0;
CFeeRate maxFeeRateRemoved(0);

View File

@ -6,11 +6,12 @@
#ifndef BITCOIN_TXMEMPOOL_H
#define BITCOIN_TXMEMPOOL_H
#include <set>
#include <atomic>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <addressindex.h>
#include <spentindex.h>
@ -449,7 +450,7 @@ class CTxMemPool
{
private:
uint32_t nCheckFrequency GUARDED_BY(cs); //!< Value n means that n times in 2^32 we check.
unsigned int nTransactionsUpdated; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
std::atomic<unsigned int> nTransactionsUpdated; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
CBlockPolicyEstimator* minerPolicyEstimator;
uint64_t totalTxSize; //!< sum of all mempool tx' byte sizes
@ -521,21 +522,12 @@ public:
* `mempool.cs` whenever adding transactions to the mempool and whenever
* changing the chain tip. It's necessary to keep both mutexes locked until
* the mempool is consistent with the new chain tip and fully populated.
*
* @par Consistency bug
*
* The second guarantee above is not currently enforced, but
* https://github.com/bitcoin/bitcoin/pull/14193 will fix it. No known code
* in bitcoin currently depends on second guarantee, but it is important to
* fix for third party code that needs be able to frequently poll the
* mempool without locking `cs_main` and without encountering missing
* transactions during reorgs.
*/
mutable RecursiveMutex cs;
indexed_transaction_set mapTx GUARDED_BY(cs);
using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
std::vector<std::pair<uint256, txiter> > vTxHashes; //!< All tx hashes/entries in mapTx, in random order
std::vector<std::pair<uint256, txiter> > vTxHashes GUARDED_BY(cs); //!< All tx hashes/entries in mapTx, in random order
struct CompareIteratorByHash {
bool operator()(const txiter &a, const txiter &b) const {
@ -617,8 +609,8 @@ public:
bool getSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value);
bool removeSpentIndex(const uint256 txhash);
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeForReorg(const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
void removeConflicts(const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CBLSPublicKey &pubKey) EXCLUSIVE_LOCKS_REQUIRED(cs);
@ -626,7 +618,7 @@ public:
void removeProTxSpentCollateralConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxKeyChangedConflicts(const CTransaction &tx, const uint256& proTxHash, const uint256& newKeyHash) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight);
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
void clear();
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
@ -639,7 +631,7 @@ public:
* Check that none of this transactions inputs are in the mempool, and thus
* the tx is not dependent on other mempool transactions to be included in a block.
*/
bool HasNoInputsOf(const CTransaction& tx) const;
bool HasNoInputsOf(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs);
/** Affect CreateNewBlock prioritisation of transactions */
void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
@ -673,7 +665,7 @@ public:
* for). Note: vHashesToUpdate should be the set of transactions from the
* disconnected block that have been accepted back into the mempool.
*/
void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
/** Try to calculate all in-mempool ancestors of entry.
* (these are all calculated including the tx itself)
@ -704,10 +696,10 @@ public:
* pvNoSpendsRemaining, if set, will be populated with the list of outpoints
* which are not in mempool which no longer have any spends in this mempool.
*/
void TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining=nullptr);
void TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** Expire all transaction (and their dependencies) in the mempool older than time. Return the number of removed transactions. */
int Expire(int64_t time);
int Expire(int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs);
/**
* Calculate the ancestor and descendant count for the given transaction.

View File

@ -394,8 +394,7 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
// Returns the script flags which should be checked for a given block
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& chainparams);
static void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age)
EXCLUSIVE_LOCKS_REQUIRED(pool.cs, ::cs_main)
static void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) EXCLUSIVE_LOCKS_REQUIRED(pool.cs, ::cs_main)
{
int expired = pool.Expire(GetTime() - age);
if (expired != 0) {
@ -433,7 +432,7 @@ static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
* and instead just erase from the mempool as needed.
*/
static void UpdateMempoolForReorg(DisconnectedBlockTransactions &disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static void UpdateMempoolForReorg(DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
{
AssertLockHeld(cs_main);
std::vector<uint256> vHashUpdate;
@ -469,12 +468,9 @@ static void UpdateMempoolForReorg(DisconnectedBlockTransactions &disconnectpool,
// We also need to remove any now-immature transactions
mempool.removeForReorg(&::ChainstateActive().CoinsTip(), ::ChainActive().Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
{
LOCK(mempool.cs);
// Re-limit mempool size, in case we added any transactions
LimitMempoolSize(mempool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
}
}
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool
// were somehow broken and returning the wrong scriptPubKeys
@ -2433,8 +2429,6 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
int64_t nTotalSpace =
max_coins_cache_size_bytes + std::max<int64_t>(max_mempool_size_bytes - nMempoolUsage, 0);
cacheSize += evoDb->GetMemoryUsage();
//! No need to periodic flush if at least this much space still available.
static constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES = 10 * 1024 * 1024; // 10MB
int64_t large_threshold =
@ -2502,12 +2496,14 @@ bool CChainState::FlushStateToDisk(
bool fCacheLarge = mode == FlushStateMode::PERIODIC && cache_state >= CoinsCacheSizeState::LARGE;
// The cache is over the limit, we have to write now.
bool fCacheCritical = mode == FlushStateMode::IF_NEEDED && cache_state >= CoinsCacheSizeState::CRITICAL;
// The evodb cache is too large
bool fEvoDbCacheCritical = mode == FlushStateMode::IF_NEEDED && evoDb != nullptr && evoDb->GetMemoryUsage() >= (64 << 20);
// It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash.
bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > nLastWrite + DATABASE_WRITE_INTERVAL;
// It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage.
bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > nLastFlush + DATABASE_FLUSH_INTERVAL;
// Combine all conditions that result in a full cache flush.
fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune;
fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fEvoDbCacheCritical || fPeriodicFlush || fFlushForPrune;
// Write blocks and block index to disk.
if (fDoFullFlush || fPeriodicWrite) {
// Depend on nMinDiskSpace to ensure we can write block index
@ -3097,7 +3093,7 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
LimitValidationInterfaceQueue();
{
LOCK(cs_main);
LOCK2(cs_main, ::mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
CBlockIndex* starting_tip = m_chain.Tip();
bool blocks_connected = false;
do {
@ -3260,6 +3256,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
LimitValidationInterfaceQueue();
LOCK(cs_main);
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
if (!m_chain.Contains(pindex)) break;
pindex_was_in_chain = true;
CBlockIndex *invalid_walk_tip = m_chain.Tip();
@ -3414,6 +3411,8 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
pindexBestHeader = pindexBestHeader->pprev;
}
{
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
DisconnectedBlockTransactions disconnectpool;
while (m_chain.Contains(pindex)) {
const CBlockIndex* pindexOldTip = m_chain.Tip();
@ -3446,6 +3445,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
// DisconnectTip will add transactions to disconnectpool; try to add these
// back to the mempool.
UpdateMempoolForReorg(disconnectpool, true);
} // ::mempool.cs
// The resulting new best tip may not be in setBlockIndexCandidates anymore, so
// add it again.

View File

@ -20,6 +20,7 @@
#include <script/script_error.h>
#include <sync.h>
#include <txdb.h>
#include <txmempool.h> // For CTxMemPool::cs
#include <versionbits.h>
#include <spentindex.h>
@ -671,7 +672,7 @@ public:
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
// Apply the effects of a block disconnection on the UTXO set.
bool DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
// Manual block validity manipulation:
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
@ -713,8 +714,8 @@ public:
size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
private:
bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
bool ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
void InvalidBlockFound(CBlockIndex* pindex, const CValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);