A0-3582: Deal with block limit #1
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
PR removing the limit of 32 blocks on the same level (having the same number) in substrate. This limit is enforced only by one some component of
state-dbthat keeps imported, noncanonicalized blocks and it seems it is only enforced for the sake of simpler implementation in paritytech/substrate#8494.This PR removes that limit by applying the suggestion in the introducing PR, by keeping the span (length) of the overlay level in noncanonicalized blocks. To avoid making extra db queries, the span is kept only if we have more than 32 blocks on the same level (should be an extremely rare case, as these blocks are validated). Moreover, blocks on one were previously indexed on overlay level using a bitmask of length 64. This is changed now to keeping an ordered set of unused indices, adding an
O(log b)overhead, where |b| is the number of blocks on the same level.Tested in aleph-node on test client (using db backend) - successfully imported 10k blocks on the same level, and then finalized the last one. It took 8.01s on my laptop, while, for comparison, importing a branch of 10k blocks took 6.39s.