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
refactor: consolidate MempoolAcceptResult processing #29619
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
Concept ACK
just inline nits for now
Note to reviewers: this PR isn't supposed to change behavior at all. I have a spreadsheet here enumerating what we do on master, and this PR should match that. |
Deduplicate code that exists in both tx processing and ProcessOrphanTx. Additionally, this can be reused in a function that handles multiple MempoolAcceptResults from package submission.
9696d66
to
a407f10
Compare
Deduplicate code that exists in both tx processing and ProcessOrphanTx. Additionally, this can be reused in a function that handles multiple MempoolAcceptResults from package submission.
a407f10
to
07cd510
Compare
thanks for doing this! concept ACK |
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.
ACK 07cd510
I can't find any behavior differences in this attempt, and it seems to be straight forwardly useful in the follow-up 1p1c PR.
Looking forward to making better unit test coverage; it's really quite lacking sadly.
RelayTransaction(tx.GetHash(), tx.GetWitnessHash()); | ||
m_orphanage.AddChildrenToWorkSet(tx); | ||
|
||
ProcessValidTx(pfrom.GetId(), ptx, result.m_replaced_transactions.value()); |
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.
value_or
here as well for belt and suspenders?
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.
Adding in the next PR, or will squash if I retouch 👍
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.
done in #28970
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.
ACK 07cd510
// We only add the txid if it differs from the wtxid, to | ||
// avoid wasting entries in the rolling bloom filter. |
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 07cd510 "[refactor] consolidate invalid MempoolAcceptResult processing"
This comment is lost.
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.
added back in #28970
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.
Code review ACK 07cd510
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.
ACK 07cd510
@@ -3037,6 +3046,63 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer, | |||
return; | |||
} | |||
|
|||
void PeerManagerImpl::ProcessInvalidTx(NodeId nodeid, const CTransactionRef& ptx, const TxValidationState& state, |
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.
Nit: The var names differ from the declaration for CTransactionsRef&
and TxValidationState&
. Is there a reason for the p
in ptx
?
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.
p
as in "pointer". I usually use CMutableTransaction mtx
and CTransaction tx
. Though I agree there's a mix...
Every time we try to
ProcessTransaction
(i.e. submit a tx to mempool), we use the result to update a few net processing data structures. For example, after a failure, the {wtxid, txid, both, neither} (depending on reason) should be cached inm_recent_rejects
so we don't try to download/validate it again.There are 2 current places and at least 1 future place where we need to process
MempoolAcceptResult
:ProcessMessage
logic after receiving and validating a txProcessOrphanTx
where we retry orphansConsolidate this code so it isn't repeated in 2 places and so we can reuse it in a future PR.