Page MenuHomePhabricator

[avalanche] Properly clean up the finalized transactions from the ancestor of the finalized block
ClosedPublic

Authored by Fabien on Jul 23 2025, 13:11.

Details

Summary

Make sure that we remove the finalized transaction that are confirmed in a block which is an ancestor of the finalized block.
Otherwise it is possible that several blocks are mined in a row and the tip finalized, causing the transactions from the previous block to remain in the radix tree.

Depends on D18414.

Test Plan
ninja check check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien published this revision for review.Jul 23 2025, 14:00
PiRK added inline comments.
src/txmempool.cpp
341 ↗(On Diff #54980)
PiRK requested changes to this revision.Jul 24 2025, 11:53
PiRK added inline comments.
src/net_processing.cpp
6963–6968 ↗(On Diff #54980)

it would be good to assert here that pindex is indeed an ancestor of the active chain tip, or test first that the below call for m_chainman.ActiveChainstate().AvalancheFinalizeBlock(pindex, *m_avalanche) (which checks for the block being in the active chain) returns True

This revision now requires changes to proceed.Jul 24 2025, 11:53

Suggested comment improvement.

Other than that, the code logic makes sense to me.

src/net_processing.cpp
6959 ↗(On Diff #54980)

I find this comment slightly confusing, as the "protect" part doesn't happen here but is later.

Suggested rewording to clarify:

"If the finalized block is not the tip, we need to keep track of the transactions from the non final block, in case they were finalized by pre-consensus. We build a set of their txids."

src/net_processing.cpp
6959 ↗(On Diff #54980)

Or:

"If the finalized block is not the tip, we need to keep track of the transactions from the non final block, so that we can check if they were finalized by pre-consensus. We build a set of their txids."

Improve comment and the logic flow by first calling AvalancheFinalizeBlock (if needed).

This revision is now accepted and ready to land.Jul 25 2025, 09:34