Repository navigation
Conversation
|
this seems better, and I couldn't detect any obvious performance impact. Code being easier to read is a bonus |
A short ID collision can invalidate a mempool-sourced transaction after an unrelated transaction was found in `extra_txn`. Track each slot's state so `extra_count` is decremented only when invalidating an extra-sourced transaction. Mark collided slots explicitly to preserve the rule that later candidates do not refill them.
l0rinc
force-pushed
the
l0rinc/extra-count-source-accounting
branch
from
July 16, 2026 17:51
0c69909 to
1c9ce58
Compare
| // If we find two mempool txn that match the short id, just request it. | ||
| // This should be rare enough that the extra bandwidth doesn't matter, | ||
| // but eating a round-trip due to FillBlock failure would be annoying | ||
| if (txn_available[idit->second]) { |
There was a problem hiding this comment.
This should probably become
Suggested change
| if (txn_available[idit->second]) { | |
| if (tx_source[idit->second] != TxSource::CONFLICTED) { |
and ikewise below
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: When an
extra_txncandidate collides with a transaction already found in the mempool,InitData()decrementsextra_counteven though the invalidated transaction did not come fromextra_txn.bitcoin#35727 prevents underflow at zero with a saturating decrement, but that still consumes the credit for an unrelated extra transaction when the count is positive, leaving the logged count incorrect.
Fix: Track whether each short-ID slot was filled from the mempool or
extra_txn, and decrementextra_countonly when a collision invalidates an extra-sourced transaction.The source remains set after a collision, preserving the existing behavior that later candidates cannot refill that slot.