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.
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.
In 7e475b9:
I think having the
if/else
path in this commit is helpful, since it distinguishes between when we cast the txid and when we don't.nit: I think this already works pretty well, but some bits (e.g. "guess what the wtxid is") are not super clear imo. I've summarized my understanding into the below, feel free to use what you like.
side-note rant: I think the fact that we need such a verbose comment is a pretty strong sign
AlreadyHaveTx
should be refactored, e.g. using{Wt,T}xid
types as I suggested here, but I appreciate that it's mostly orthogonal to this PR. RenamingAlreadyHaveTx
to e.g.ShouldRequestTx
or something would probably already clarify quite a bit, too (although also not blocking for this PR either).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.
Looks correct to me
I think it's really a sign to ban txid-based transaction relay. Just kidding. I agree it's hard to reason about logic dealing with a hash that can be txid, wtxid, or bot. I think it's just one of the common things that trips people in tx relay, just like everybody's mempool fuzzer gets snagged on CPFP carve out, and that
for
loop in init.cpp that claims reviewer victims every time it's touched.Yeah,
AlreadyHaveTx
should probably have a name that reflects its purpose of "should I bother {requesting, downloading, validating} this tx".Do note that #30110 makes
AlreadyHaveTx
a function internal to theTxDownloadImpl
, i.e. no longer something that peerman knows about. Funnily,TxDownloadImpl::AlreadyHaveTx
might be a fine name when it's in that context. I get that it's confusing, but I'd ask that we defer renaming until after that PR since it would conflict + maybe be less problematic afterwards.