-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ChainDB: optimise chain selection for forks
Fixes #1223. When a block fits onto a fork, we construct the fragment all the way going back to the immutable tip instead of just a `ChainDiff` to the most recent intersection with the current chain. For example, when switching to a fork that requires rolling back 2 blocks, previously, we'd construct a fragment containing `k` headers. Now, we'll construct a `ChainDiff` with rollback = 2 and a fragment of 2 headers. * `VolDB`: introduce `ReversePath` and `computeReversePath` which lazily computes a reverse path through the VolatileDB. By using these paths everywhere, we no longer have to think about looking things up in the VolatileDB. * `VolDB`: let `isReachable` return a `PointChainDiff` instead of a list of hashes going all the way back to the immutable tip. This `PointChainDiff` can later be translated to a `ChainDiff`. * Add property tests for `isReachable`, which helped catch a tricky corner case involving EBBs. * `VolDB`: rewrite `computePath` using `computeReversePath`. * `Fragment.Diff`: promote the internal `mkRollback` to the public `mkDiff` smart constructor, now used by chain selection for forks. * We can now use `RealPoint`s instead of `HeaderHash`s in many functions and types: `IteratorBlockGCed`, `ChainDB.Iterator`s, `VolDB.Path`, some trace events, etc. We don't yet take advantage of the `RealPoint` in the implementation of `ChainDB.Iterator`s.
- Loading branch information
Showing
11 changed files
with
805 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.