Repository navigation
fix: drop mempool provider transactions a reorg invalidated #8214
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
base: develop
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -371,6 +371,31 @@ static bool IsCurrentForFeeEstimation(Chainstate& active_chainstate) EXCLUSIVE_L | |
| return true; | ||
| } | ||
|
|
||
| void Chainstate::RemoveProviderTxsInvalidAtTip() | ||
| { | ||
| AssertLockHeld(cs_main); | ||
| AssertLockHeld(m_mempool->cs); | ||
| m_provider_txs_need_recheck = false; | ||
| const CBlockIndex* tip{m_chain.Tip()}; | ||
| if (!tip) return; | ||
|
|
||
| const SpecialTxRules rules{GetSpecialTxRules(tip, m_chainman)}; | ||
| std::vector<CTransactionRef> invalid; | ||
| for (const CTxMemPoolEntry& entry : m_mempool->entryAll()) { | ||
| const CTransaction& tx{entry.GetTx()}; | ||
| if (!IsProviderTx(tx)) continue; | ||
| TxValidationState state; | ||
| if (!m_special_tx.CheckSpecialTx(tx, tip, rules, CoinsTip(), /*check_sigs=*/true, state)) { | ||
| LogPrint(BCLog::MEMPOOL, "%s: removing %s, invalid after the reorg: %s\n", __func__, | ||
| tx.GetHash().ToString(), state.ToString()); | ||
| invalid.push_back(entry.GetSharedTx()); | ||
| } | ||
| } | ||
| for (const auto& tx : invalid) { | ||
| m_mempool->removeRecursive(*tx, MemPoolRemovalReason::REORG); | ||
| } | ||
| } | ||
|
|
||
| void Chainstate::MaybeUpdateMempoolForReorg( | ||
| DisconnectedBlockTransactions& disconnectpool, | ||
| bool fAddToMempool) | ||
|
|
@@ -3444,6 +3469,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra | |
| } | ||
|
|
||
| m_chain.SetTip(*pindexDelete->pprev); | ||
| m_provider_txs_need_recheck = true; | ||
|
Comment on lines
3471
to
+3472
Collaborator
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.
🔴 Blocking: Recheck provider transactions after an InstantSend disconnect that skips activation
source:
Member
Author
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. Real, fixed in b5f5842.
I used a key change, not a registration, in those blocks: a registration there changes the masternode-list root two blocks later, which the scenario's hand-built ChainLock block cannot follow. 🤖 Posted autonomously by Claude (claude-fable-5-2) on behalf of pasta.
Collaborator
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. Resolved (re-reviewed at
Member
Author
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. This thread shows as open again at 9e1c2a9. The rollback still rechecks without activating the conflicting branch. At 6ff3c89 it does so once, after all conflicting blocks are invalidated and before their failure flags are reset (see the per-block thread). 🤖 Posted autonomously by Claude (claude-fable-5-2) on behalf of pasta.
Collaborator
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. Still applies (re-reviewed at
Collaborator
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. Resolved (re-reviewed at
Member
Author
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. Deferring this one after all, as of 747e1eb. The fix for it (activating in the missing-transaction rollback) is what the newer thread shows can cost a pending lock its transaction, so it is reverted and the InstantSend path is as on develop. What remains is narrower than on develop: stale provider transactions stay only until the next 🤖 Posted autonomously by Claude (claude-fable-5-2) on behalf of pasta.
Collaborator
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. Still applies (re-reviewed at
Member
Author
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. Tracked in #8219: recheck at the rollback boundary, with the whole rollback serialized under 🤖 Posted autonomously by Claude (claude-fable-5-2) on behalf of pasta.
Collaborator
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. Deferred (re-reviewed at |
||
|
|
||
| UpdateTip(pindexDelete->pprev); | ||
| // Let wallets know transactions went from 1-confirmed to | ||
|
|
@@ -3935,6 +3961,10 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< | |
| break; | ||
| } | ||
| } while (!m_chain.Tip() || (starting_tip && CBlockIndexWorkComparator()(m_chain.Tip(), starting_tip))); | ||
| if (m_mempool && m_provider_txs_need_recheck && !m_provider_txs_recheck_held && | ||
| (!pindexMostWork || pindexMostWork == m_chain.Tip()) && FindMostWorkChain() == m_chain.Tip()) { | ||
| RemoveProviderTxsInvalidAtTip(); | ||
| } | ||
| if (!blocks_connected) return true; | ||
|
|
||
| const CBlockIndex* pindexFork = m_chain.FindFork(starting_tip); | ||
|
|
@@ -3981,6 +4011,19 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< | |
| return true; | ||
| } | ||
|
|
||
| void Chainstate::ReleaseProviderTxRecheck() | ||
| { | ||
| AssertLockNotHeld(m_chainstate_mutex); | ||
| AssertLockNotHeld(::cs_main); | ||
|
|
||
| LOCK(m_chainstate_mutex); | ||
| LOCK(cs_main); | ||
| m_provider_txs_recheck_held = false; | ||
| if (!m_mempool || !m_provider_txs_need_recheck) return; | ||
| LOCK(m_mempool->cs); | ||
| if (FindMostWorkChain() == m_chain.Tip()) RemoveProviderTxsInvalidAtTip(); | ||
|
Comment on lines
+4019
to
+4024
Collaborator
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.
🔴 Blocking: Do not suppress an unrelated reorg’s provider scan for an off-chain conflict The release takes the same locks as activation, but it checks the candidate set after the InstantSend handler has changed it. If an unrelated activation settles on branch B during the hold, it skips the provider scan and moves the recorded conflict block A off-chain. source:
Member
Author
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. The interleaving is real. Deferring it to #8219, where I have added it. It needs a descendant of the conflicting block that was invalidated earlier and has more work than the tip, an unrelated reorg that settles inside the hold, and a lock that is still missing its transaction. In that state The fix you describe, one Chainstate operation for the conflict batch, is the fix #8219 asks for: 🤖 Posted autonomously by Claude (claude-fable-5-2) on behalf of pasta.
Collaborator
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 fine deferring this to #8219: the off-chain reset can delay the scan, but it leaves the recheck pending for the next settled activation, and the stale mempool state in the meantime already occurs on develop. Tracked in #8219. Deferred on a maintainer's call: this finding no longer blocks this pull request. |
||
| } | ||
|
|
||
| bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex) | ||
| { | ||
| AssertLockNotHeld(m_chainstate_mutex); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.