mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge 3966b0a0b6 into merged_master (Bitcoin PR bitcoin/bitcoin#28472)
This commit is contained in:
commit
1c95683b4f
5 changed files with 70 additions and 19 deletions
|
|
@ -450,8 +450,7 @@ public:
|
|||
m_pool(mempool),
|
||||
m_view(&m_dummy),
|
||||
m_viewmempool(&active_chainstate.CoinsTip(), m_pool),
|
||||
m_active_chainstate(active_chainstate),
|
||||
m_limits{m_pool.m_limits}
|
||||
m_active_chainstate(active_chainstate)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -703,8 +702,6 @@ private:
|
|||
|
||||
Chainstate& m_active_chainstate;
|
||||
|
||||
CTxMemPool::Limits m_limits;
|
||||
|
||||
/** Whether the transaction(s) would replace any mempool transactions. If so, RBF rules apply. */
|
||||
bool m_rbf{false};
|
||||
};
|
||||
|
|
@ -962,6 +959,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
if (!bypass_limits && !args.m_package_feerates && !CheckFeeRate(package_size, ws.m_modified_fees, state)) return false;
|
||||
|
||||
ws.m_iters_conflicting = m_pool.GetIterSet(ws.m_conflicts);
|
||||
|
||||
// Note that these modifications are only applicable to single transaction scenarios;
|
||||
// carve-outs and package RBF are disabled for multi-transaction evaluations.
|
||||
CTxMemPool::Limits maybe_rbf_limits = m_pool.m_limits;
|
||||
|
||||
// Calculate in-mempool ancestors, up to a limit.
|
||||
if (ws.m_conflicts.size() == 1) {
|
||||
// In general, when we receive an RBF transaction with mempool conflicts, we want to know whether we
|
||||
|
|
@ -994,11 +996,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
assert(ws.m_iters_conflicting.size() == 1);
|
||||
CTxMemPool::txiter conflict = *ws.m_iters_conflicting.begin();
|
||||
|
||||
m_limits.descendant_count += 1;
|
||||
m_limits.descendant_size_vbytes += conflict->GetSizeWithDescendants();
|
||||
maybe_rbf_limits.descendant_count += 1;
|
||||
maybe_rbf_limits.descendant_size_vbytes += conflict->GetSizeWithDescendants();
|
||||
}
|
||||
|
||||
auto ancestors{m_pool.CalculateMemPoolAncestors(*entry, m_limits)};
|
||||
auto ancestors{m_pool.CalculateMemPoolAncestors(*entry, maybe_rbf_limits)};
|
||||
if (!ancestors) {
|
||||
// If CalculateMemPoolAncestors fails second time, we want the original error string.
|
||||
// Contracting/payment channels CPFP carve-out:
|
||||
|
|
@ -1014,9 +1016,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
// this, see https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
|
||||
CTxMemPool::Limits cpfp_carve_out_limits{
|
||||
.ancestor_count = 2,
|
||||
.ancestor_size_vbytes = m_limits.ancestor_size_vbytes,
|
||||
.descendant_count = m_limits.descendant_count + 1,
|
||||
.descendant_size_vbytes = m_limits.descendant_size_vbytes + EXTRA_DESCENDANT_TX_SIZE_LIMIT,
|
||||
.ancestor_size_vbytes = maybe_rbf_limits.ancestor_size_vbytes,
|
||||
.descendant_count = maybe_rbf_limits.descendant_count + 1,
|
||||
.descendant_size_vbytes = maybe_rbf_limits.descendant_size_vbytes + EXTRA_DESCENDANT_TX_SIZE_LIMIT,
|
||||
};
|
||||
const auto error_message{util::ErrorString(ancestors).original};
|
||||
if (ws.m_vsize > EXTRA_DESCENDANT_TX_SIZE_LIMIT) {
|
||||
|
|
@ -1099,7 +1101,7 @@ bool MemPoolAccept::PackageMempoolChecks(const std::vector<CTransactionRef>& txn
|
|||
{ return !m_pool.exists(GenTxid::Txid(tx->GetHash()));}));
|
||||
|
||||
std::string err_string;
|
||||
if (!m_pool.CheckPackageLimits(txns, m_limits, err_string)) {
|
||||
if (!m_pool.CheckPackageLimits(txns, err_string)) {
|
||||
// This is a package-wide error, separate from an individual transaction error.
|
||||
return package_state.Invalid(PackageValidationResult::PCKG_POLICY, "package-mempool-limits", err_string);
|
||||
}
|
||||
|
|
@ -1266,7 +1268,7 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
|
|||
// Re-calculate mempool ancestors to call addUnchecked(). They may have changed since the
|
||||
// last calculation done in PreChecks, since package ancestors have already been submitted.
|
||||
{
|
||||
auto ancestors{m_pool.CalculateMemPoolAncestors(*ws.m_entry, m_limits)};
|
||||
auto ancestors{m_pool.CalculateMemPoolAncestors(*ws.m_entry, m_pool.m_limits)};
|
||||
if(!ancestors) {
|
||||
results.emplace(ws.m_ptx->GetWitnessHash(), MempoolAcceptResult::Failure(ws.m_state));
|
||||
// Since PreChecks() and PackageMempoolChecks() both enforce limits, this should never fail.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue