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
Allow all mempool txs to be replaced after a configurable timeout (default 6h) #10823
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,20 @@ bool SignalsOptInRBF(const CTransaction &tx) | |
return false; | ||
} | ||
|
||
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) | ||
bool ExpiredOptInRBFPolicy(const int64_t now, const int64_t accepted, const int64_t timeout) | ||
{ | ||
return now - accepted >= timeout; | ||
} | ||
|
||
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool, const int64_t now, const int64_t timeout, const bool enabled_replacement_timeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of changing the semantics of this function. Previously it meant "does this transaction (or one of its unconfirmed parents) signal opt-in RBF?". Now it means "does my mempool configuration allow this tx to be replaced?" That means that the |
||
{ | ||
AssertLockHeld(pool.cs); | ||
|
||
CTxMemPool::setEntries setAncestors; | ||
|
||
// First check the transaction itself. | ||
if (SignalsOptInRBF(tx)) { | ||
const int64_t conflicting_time = pool.info(tx.GetHash()).nTime; | ||
if ((enabled_replacement_timeout && ExpiredOptInRBFPolicy(now, conflicting_time, timeout)) || SignalsOptInRBF(tx)) { | ||
return RBFTransactionState::REPLACEABLE_BIP125; | ||
} | ||
|
||
|
@@ -33,13 +39,14 @@ RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) | |
|
||
// If all the inputs have nSequence >= maxint-1, it still might be | ||
// signaled for RBF if any unconfirmed parents have signaled. | ||
uint64_t noLimit = std::numeric_limits<uint64_t>::max(); | ||
const uint64_t noLimit = std::numeric_limits<uint64_t>::max(); | ||
std::string dummy; | ||
CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); | ||
const CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); | ||
pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); | ||
|
||
for (CTxMemPool::txiter it : setAncestors) { | ||
if (SignalsOptInRBF(it->GetTx())) { | ||
for (const CTxMemPool::txiter it : setAncestors) { | ||
greenaddress marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const int64_t ancestor_time = pool.info(it->GetTx().GetHash()).nTime; | ||
if ((enabled_replacement_timeout && ExpiredOptInRBFPolicy(now, ancestor_time, timeout)) || SignalsOptInRBF(it->GetTx())) { | ||
return RBFTransactionState::REPLACEABLE_BIP125; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,13 @@ static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100; | |
static const bool DEFAULT_PERSIST_MEMPOOL = true; | ||
/** Default for -mempoolreplacement */ | ||
static const bool DEFAULT_ENABLE_REPLACEMENT = true; | ||
/** Default for -mempoolreplacementtimeout in seconds after which transactions in mempool are replaceable (i.e. 6 hours) */ | ||
static const int64_t DEFAULT_REPLACEMENT_TIMEOUT = 6 * 60 * 60; | ||
/** Default for buffer in seconds on top of the timeout after which transactions in mempool are replaceable (i.e. 6 hours) in the GUI | ||
* This buffer is needed because otherwise is more likely ours peers will reject the transaction in case they received it substantial time after us */ | ||
static const int64_t REPLACEMENT_TIMEOUT_BUFFER = 5 * 60; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this constant to |
||
/** Default to enable/disable wallet/rpc ability to replace timeout transactions */ | ||
static const bool DEFAULT_WALLET_REPLACEMENT_TIMEOUT = false; | ||
/** Default for using fee filter */ | ||
static const bool DEFAULT_FEEFILTER = true; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this option entirely and replace it with an argument to
bumpfee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this option entirely and add wallet and rpc support after the p2p change is merged