-
Notifications
You must be signed in to change notification settings - Fork 107
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(rpc): check contextual validity of getblocktemplate response #5630
Conversation
fa1b535
to
b3bc9cf
Compare
uses it to build a new NonFinalizedState with only the best chain updates initial_contextual_validity call to use only the best chain
b3bc9cf
to
a6eb045
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #5630 +/- ##
==========================================
- Coverage 78.72% 78.72% -0.01%
==========================================
Files 305 305
Lines 38503 38503
==========================================
- Hits 30313 30310 -3
- Misses 8190 8193 +3 |
) -> Result<(), crate::ValidateContextError> { | ||
if let Some(best_chain) = self.latest_non_finalized_state().best_chain() { | ||
let best_chain_latest_non_finalized_state = NonFinalizedState::build(self.network) | ||
.insert_chain(Arc::clone(best_chain)) |
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.
qualifying the Arc::clone
so it's obvious that nothing's being copied without looking at the type.
@Mergifyio update |
✅ Branch has been successfully updated |
Sounds good, I'd also prefer #5659 go first so this PR could use the populated |
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 think the ticket for this PR was a bit confusing. We need to change how the mempool checks transactions, so it always uses the best chain.
If we wait until the transactions are in the getblocktemplate
response, it is too late, because all we can do is return an error to the caller. We don't know which transactions to remove to make the block valid.
Edit: It is also going to be tricky to verify the block, because the solution in the header requires Proof of Work. (Correct equihash solutions are expensive to create, so we can't do that in tests or in the RPC.)
We might want to turn this PR into a ticket, because the code looks like it could be useful for testing.
I'll add some specific notes to the ticket about where we want to change things.
Oops. 🤦 I thought I just hadn't come across the code that was checking the nullifiers, I understand now.
I believe the solution in the header is only checked by the block verifier. I created issue #5681 for adding this as a test. I'm closing this because it would needlessly hurt performance in production. |
Motivation
The getblocktemplate response must be contextually valid based on the best tip in the state.
Needs other getblocktemplate fields for testing the success case.
Closes #5376
Solution
nonce
andsolution
fields to use the new state request.Validated
response.Review
This PR is part of regular scheduled work.
Reviewer Checklist