-
Notifications
You must be signed in to change notification settings - Fork 106
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
Reject conflicting mempool transactions #2765
Reject conflicting mempool transactions #2765
Conversation
I posted this on Discord, but for the record:
|
3832ea4
to
22d8ffd
Compare
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.
This PR looks good.
There's a non-blocking performance issue that we will probably want to fix later, once more mempool components are in place.
I'm looking forward to seeing some tests, when the testing framework all comes together.
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 missed some Conflict
to SpendConflict
tweaks.
4f1c778
to
d94a58f
Compare
d94a58f
to
17f217b
Compare
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.
Updated. Changes can be seen here.
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 great, just one documentation clarification
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.
This looks great!
I opened #2787 to check for duplicate spends within the same mempool transaction.
(Currently, that consensus rule is checked in zebra-state, so it doesn't apply to mempool transactions.)
I've implemented a test case, but it's currently blocked by depending on #2771. If that gets merged, I can update this PR and remove the draft status. In the meantime, here's the test code in case you want to take an initial look. I thought about implementing the same test case using nullifiers for the different pools, but I'm not 100% sure how to create mock transactions with them 😅 |
It's so complicated, and it works differently for every shielded pool. zebra/zebra-state/src/service/check/tests/nullifier.rs Lines 460 to 475 in e2cc6e1
Feel free to copy and paste the 3 similar tests for each pool. |
8df91d9
to
0af839d
Compare
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 good, feel free to merge once you've resolved the conflicts.
(As long as the tests run for a reasonable amount of time.)
Returns an iterator over the UTXO `OutPoint`s spent by the transaction.
An error representing that a transaction was rejected because it conflicts with another transaction that's already in the mempool.
Reject including a transaction in the mempool if it spends outputs already spent by, or reveals nullifiers already revealed by another transaction in the mempool.
Remove the `r` that was incorrectly added. Co-authored-by: teor <teor@riseup.net>
Make the situation clearer, because there are other types of conflict. Co-authored-by: teor <teor@riseup.net>
Because otherwise it could lead to confusion because it could also mean the outputs of the transaction represented as `OutPoint` references. Co-authored-by: teor <teor@riseup.net>
Refactor to follow the convention used for other tests.
A getter to allow changing the first element.
Allow appending elements to the collection.
This is just to make the code that generates arbitrary anchors a bit simpler.
Generate two transactions (either V4 or V5) and insert a conflicting spend, which can be either a transparent UTXO, or a nullifier for one of the shielded pools. Check that any attempt to insert both transactions causes one to be accepted and the other to be rejected.
0af839d
to
c87b067
Compare
I've updated the PR to fix the merge conflict, fix a clippy lint and add some more documentation. I know you said I could merge this, but I thought the documentation might want another quick round of check. Feel free to change anything and merge it afterwards 👍 The isolated changes can be seen here. |
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 good to me, I just removed an outdated TODO comment
Motivation
The mempool should ideally provide a set of transactions that can be included in a block to be mined. This means that it should not contain any conflicting transactions, i.e., transactions that spend the same UTXOs or reveal the same nullifiers.
This closes #2682.
Specifications
Solution
Change the
mempool::Storage
to check if transactions to be included don't conflict with any existing transactions. Reject transactions that conflict with any existing transactions in the mempool.Review
Reviewer Checklist
Follow Up Work