-
Notifications
You must be signed in to change notification settings - Fork 989
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
NRD rules and "recent" kernel pos index #3302
Conversation
next and prev and Vec<u8> lmdb keys
…e coinbase maturity
cleanup
test coverage for pop_pos_back
pos must always increase in the index
…t reality (tx/block validation rules etc.)
// Process the header first. | ||
// If invalid then fail early. | ||
// If valid then continue with block processing with header_head committed to db etc. | ||
self.process_block_header(&b.header, opts)?; |
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 what cases would we call process_block_single without having validated/processed the header already?
(I would naively expect never)
Does header validation not commit it to db?
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 most cases we will have processed "header first".
The first broadcast hop from a miner after mining a new block is done as a "full block" and skips the "header first" propagation as we know nobody has seen this block yet.
In this case the receiving node is here in the code, processing the new block without having seen the header yet.
We were validating the header in the later call to pipe::process_block()
.
We want to validate/process the header here, in a db transaction and a write to the MMR backend files, before we begin processing/validating the full block.
The issue was that if the full block failed validation for any reason then the entire db transaction rolled back, including the header processing. But leaving the header MMR updated with the latest header.
Merging this to master. |
// Start at 2 here to differentiate from ListWrapperVariant above. | ||
Head = 2, | ||
Tail = 3, | ||
Middle = 4, |
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.
Do we really need a linked list with 5 different variants?
Doesn't the database readily support maps from 64-bit ints to 64-bit ints?
We could map the MMR leaf position of an NRD-kernel to the next lower leaf position of an NRD-kernel with the same top k bits, if any. Besides that, we have a 2^k entry map giving the largest MMR leaf position of any NRD-kernel with those top k bits. I guess we could start with k=8 and it would take a long time before NRD kernel usage increases to the point where we'd want to migrate to k=16 in order to keep the lists relatively short.
The new NRD kernel variant was introduced in #3303.
This PR adds the kernel_pos index to track "recent" NRD kernel history for efficient validation of the NRD relative lock height rule.
LMDB index impl
NRD rule validation
Txpool
Rebuild Index
Fast Sync