-
Notifications
You must be signed in to change notification settings - Fork 100
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
add(mempool): Verify orphaned mempool transactions #8857
base: main
Are you sure you want to change the base?
Conversation
… mempool setup argument, adds and uses an `init_test()` fn for passing a closed channel receiver in tests where no mempool service is needed in the transaction verifier.
…nd a `new_for_tests()` constructor for convenience)
…t receiver, updates tests.
…ol service handle.
…dSet` `transactions()` return type.
…om the mempool's verified set
…m the tx verifier response
…nsparent outputs has been verified. adds a TODO for adding a `pending_outputs` field to the mempool Storage
…ng outputs requests when inserting new transactions into the mempool's verified set
… the caller handle it (required to avoid moving zip317 tx selection code to mempool)
…nless their dependencies have already been added.
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.
I'm still reviewing but I added a comment
tip_rejected_exact: HashMap<UnminedTxId, ExactTipRejectionError>, | ||
tip_rejected_exact: HashMap<transaction::Hash, ExactTipRejectionError>, |
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.
What is the reason for this change? The semantics of tip_rejected_exact
is for it to incude transactions that have failed to validate e.g. due to an invalid signature. If this is changed to a Hash, then a transaction with e.g. the same data but a valid signature would be rejected when it shouldn't.
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.
What is the reason for this change?
I think the broader change to mined ids was to avoid iterating through the verified set to find the auth digest when adding transaction dependencies (since OutPoint
only includes the mined id).
The change to tip_rejected_exact
was a mistake, it would work fine for the sendrawtransaction
RPC, but I see it would incorrectly reject gossiped transaction ids when it should try to download and verify them.
Restored its type to the full UnminedTxId
in ce6d169.
pub fn insert( | ||
&mut self, | ||
tx: VerifiedUnminedTx, | ||
spent_mempool_outpoints: Vec<transparent::OutPoint>, |
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.
Please document the new argument
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.
Thank you for catching that, documented in cc76b40.
…thod without calling it.
… mined onto the best chain.
Motivation
We want to verify transactions in the mempool that spend the transparent outputs of other transactions in the mempool.
Closes #8777.
Solution
AwaitOutput
request in the mempool servicespent_utxos()
method in the transaction verifier to try querying the mempool for spent outpoints before returning aTransparentInputNotFound
error.getblocktemplate
method and ZIP-317 transaction selection to include transactions that spent the outputs of other transactions in the mempool when all of their dependencies have been selectedTests
Added tests to check that:
Storage.remove()
method works as expected (the rest ofevict_one()
should be covered already)AwaitOutput
requests when the output for the queried outpoint is:AwaitOutput
requests as expected and processesUnspentOutput
responses correctlyspent_mempool_outpoints
in its responseIf needed, this PR could also add tests for:
getblocktemplate
method returns transactions with dependencies in the right order when the transaction hashes would have them sorted in the wrong orderFollow Up Work
The mempool's
Downloads
sends a result to the response channel too early, it should wait until the transaction is being inserted into the mempool's verified set.PR Author's Checklist
PR Reviewer's Checklist