This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
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.
Closes #432
⚠ DEPENDS ON: paritytech/substrate#12005
(for correct blocks removal from the backend)
This PR prevents the
StateDbError::TooManySiblingBlocks
error from being triggered by eagerly removing leaves from the backend on block import and before the error condition is met.The strategy is to remove the older block to make space for a new fresh block when we reach a configurable upper bound.
To detect which is the older block at the given level currently we are relying on the implementation of the
Backend::leaves()
method that ships with substrate:https://github.com/paritytech/substrate/blob/6b8553511112afd5ae7e8e6877dc2f467850f155/client/api/src/leaves.rs#L204-L206
That is, our implementation already returns the leaves sorted by insertion time (older first).
(Before this, as an alternative - more portable but less elegant - implementation, I was maintaining for every leaf its import order, e.g. its timestamp).
In the end I've preferred to rely on the assumption that the leaves are already given ordered by insertion time to keep it simple.
If this strategy is good, then I suggest to modify the blockchain
Backend
traitleaves()
method documentation to better fit our ordering assumptions.https://github.com/paritytech/substrate/blob/6b8553511112afd5ae7e8e6877dc2f467850f155/primitives/blockchain/src/backend.rs#L98-L101
From:
To: