-
Notifications
You must be signed in to change notification settings - Fork 120
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
change(mempool): Contextually validates mempool transactions in best chain #5716
Conversation
updates TransactionContextualValidity request to check sprout anchors adds comment mentioning TransactionContextualValidity ignores UTXOs
updates tests
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, seems like it should work!
Since the mempool currently has a lot of very large transactions, we need to be careful of performance. I've also made some suggestions for improving various APIs so they are easier to call correctly.
I'd like to see some unit tests for the new and modified consensus-critical checks.
Co-authored-by: teor <teor@riseup.net>
moves if let statement into for loop
renames transaction_in_state to transaction_in_chain
deletes broken test
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #5716 +/- ##
==========================================
+ Coverage 78.67% 78.79% +0.12%
==========================================
Files 306 306
Lines 38552 38676 +124
==========================================
+ Hits 30331 30475 +144
+ Misses 8221 8201 -20 |
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, I just have some questions and ideas around error handling.
Good catch with the expensive Sprout checks!
Co-authored-by: teor <teor@riseup.net>
rustfmt
updates comments and naming
slightly improves formatting
388a3f4
to
513b811
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.
Looking good, I don't mind if we do the joinsplit parallelisation in a different PR.
(But it's important to do soon, because it is a denial of service risk.)
Co-authored-by: teor <teor@riseup.net>
Any idea what "the trait bound Worked fine locally. 😢 |
As far as I can see, |
Feel free to wrap it in an |
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.
Thanks, looks good!
…chain (#5716) - manual conflicts with getblocktemplate-rpcs * updates comments * adds check nullifier no dup fns for transactions * Adds: - check::anchors fn for tx iter - TODO comments for unifying nullifiers and anchors checks - new state request Updates unknown anchor errors to accomodate tx-only check Calls new state fn from transaction verifier * updates check::anchors fns to use transactions updates TransactionContextualValidity request to check sprout anchors adds comment mentioning TransactionContextualValidity ignores UTXOs * conditions new state req call on is_mempool updates tests * fix doc link / lint error * checks for duplicate nullifiers with closures * Update zebra-state/src/service/check/nullifier.rs Co-authored-by: teor <teor@riseup.net> * documents find_duplicate_nullifier params moves if let statement into for loop * renames new state req/res * asserts correct response variant in tx verifier * adds CheckBestChainTipShieldedSpends call in tx verifier to async checks * re-adds tracing instrumentation to check::anchors fn renames transaction_in_state to transaction_in_chain * adds block/tx wrapper fns for anchors checks * uses UnminedTx instead of transaction.hash() deletes broken test * updates new state req/res name * updates tests and uses par_iter for anchors checks * Updates check::anchors pub fn docs. * Adds: - comments / docs - a TransactionError variant for ValidateContextError * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> * moves downcast to From impl rustfmt * moves the ValidateContextError into an Arc updates comments and naming * leaves par_iter for another PR * puts io::Error in an Arc * updates anchors tests to call tx_anchors check * updates tests to call tx_no_duplicates_in_chain slightly improves formatting * Update zebra-consensus/src/error.rs Co-authored-by: teor <teor@riseup.net> * moves Arc from HistoryError to ValidateContextError Co-authored-by: teor <teor@riseup.net>
Motivation
Mempool transactions collected into a block template need to be contextually valid in the best chain to produce a block template that's contextually valid on the best chain.
Closes #5376
Solution
check::nullifiers::no_duplicates_in_chain
that searches the non-finalized state as well as the finalized state for duplicate nullifierscheck::anchors
fns and errors accommodate transactions without aPreparedBlock
Review
This PR is part of regular scheduled work.
Reviewer Checklist