mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 7143d43884 into merged_master (Bitcoin PR bitcoin/bitcoin#28948)
This commit is contained in:
commit
474dd0f6f9
24 changed files with 1238 additions and 142 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include <node/blockstorage.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <pegins.h>
|
||||
#include <policy/v3_policy.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/rbf.h>
|
||||
#include <policy/settings.h>
|
||||
|
|
@ -346,7 +347,9 @@ void Chainstate::MaybeUpdateMempoolForReorg(
|
|||
// Also updates valid entries' cached LockPoints if needed.
|
||||
// If false, the tx is still valid and its lockpoints are updated.
|
||||
// If true, the tx would be invalid in the next block; remove this entry and all of its descendants.
|
||||
const auto filter_final_and_mature = [this](CTxMemPool::txiter it)
|
||||
// Note that v3 rules are not applied here, so reorgs may cause violations of v3 inheritance or
|
||||
// topology restrictions.
|
||||
const auto filter_final_and_mature = [&](CTxMemPool::txiter it)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(m_mempool->cs, ::cs_main) {
|
||||
AssertLockHeld(m_mempool->cs);
|
||||
AssertLockHeld(::cs_main);
|
||||
|
|
@ -601,8 +604,9 @@ private:
|
|||
// explicit Workspace(const CTransactionRef& ptx) : m_ptx(ptx), m_hash(ptx->GetHash()) {} // ELEMENTS: unused since we need the genesis block hash
|
||||
explicit Workspace(const CTransactionRef& ptx, const uint256& hash_genesis_block) : m_ptx(ptx), m_hash(ptx->GetHash()), m_precomputed_txdata(hash_genesis_block) {} // ELEMENTS
|
||||
/** Txids of mempool transactions that this transaction directly conflicts with. */
|
||||
std::set<uint256> m_conflicts;
|
||||
std::set<std::pair<uint256, COutPoint> > m_set_pegins_spent;
|
||||
std::set<Txid> m_conflicts;
|
||||
/** ELEMENTS: keep a set of spent peg-ins */
|
||||
std::set<std::pair<uint256, COutPoint>> m_set_pegins_spent;
|
||||
/** Iterators to mempool entries that this transaction directly conflicts with. */
|
||||
CTxMemPool::setEntries m_iters_conflicting;
|
||||
/** Iterators to all mempool entries that would be replaced by this transaction, including
|
||||
|
|
@ -794,9 +798,12 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
// check all unconfirmed ancestors; otherwise an opt-in ancestor
|
||||
// might be replaced, causing removal of this descendant.
|
||||
//
|
||||
// If replaceability signaling is ignored due to node setting,
|
||||
// replacement is always allowed.
|
||||
if (!m_pool.m_full_rbf && !SignalsOptInRBF(*ptxConflicting)) {
|
||||
// All V3 transactions are considered replaceable.
|
||||
//
|
||||
// Replaceability signaling of the original transactions may be
|
||||
// ignored due to node setting.
|
||||
const bool allow_rbf{m_pool.m_full_rbf || SignalsOptInRBF(*ptxConflicting) || ptxConflicting->nVersion == 3};
|
||||
if (!allow_rbf) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "txn-mempool-conflict");
|
||||
}
|
||||
|
||||
|
|
@ -958,7 +965,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
// while a tx could be package CPFP'd when entering the mempool, we do not have a DoS-resistant
|
||||
// method of ensuring the tx remains bumped. For example, the fee-bumping child could disappear
|
||||
// due to a replacement.
|
||||
if (!bypass_limits && ws.m_modified_fees < m_pool.m_min_relay_feerate.GetFee(package_size)) {
|
||||
// The only exception is v3 transactions.
|
||||
if (!bypass_limits && ws.m_ptx->nVersion != 3 && ws.m_modified_fees < m_pool.m_min_relay_feerate.GetFee(package_size)) {
|
||||
// Even though this is a fee-related failure, this result is TX_MEMPOOL_POLICY, not
|
||||
// TX_RECONSIDERABLE, because it cannot be bypassed using package validation.
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met",
|
||||
|
|
@ -1040,6 +1048,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
}
|
||||
|
||||
ws.m_ancestors = *ancestors;
|
||||
if (const auto err_string{SingleV3Checks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "v3-rule-violation", *err_string);
|
||||
}
|
||||
|
||||
// A transaction that spends outputs that would be replaced by it is invalid. Now
|
||||
// that we have the set of all ancestors we can detect this
|
||||
|
|
@ -1408,6 +1419,15 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
|||
m_viewmempool.PackageAddTransaction(ws.m_ptx);
|
||||
}
|
||||
|
||||
// At this point we have all in-mempool ancestors, and we know every transaction's vsize.
|
||||
// Run the v3 checks on the package.
|
||||
for (Workspace& ws : workspaces) {
|
||||
if (auto err{PackageV3Checks(ws.m_ptx, ws.m_vsize, txns, ws.m_ancestors)}) {
|
||||
package_state.Invalid(PackageValidationResult::PCKG_POLICY, "v3-violation", err.value());
|
||||
return PackageMempoolAcceptResult(package_state, {});
|
||||
}
|
||||
}
|
||||
|
||||
// Transactions must meet two minimum feerates: the mempool minimum fee and min relay fee.
|
||||
// For transactions consisting of exactly one child and its parents, it suffices to use the
|
||||
// package feerate (total modified fees / total virtual size) to check this requirement.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue