-
Notifications
You must be signed in to change notification settings - Fork 34
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
babe indexer #1661
babe indexer #1661
Conversation
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
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.
Sorry for so many naming comments, but I comment when I genuinely get confused while reading.
…inalized already indexed Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
} | ||
|
||
std::shared_ptr<blockchain::BlockTree> block_tree_; | ||
mutable std::vector<primitives::BlockInfo> path_; |
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.
кажется, что std::deque тут будет лучше
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.
либо резервировать по высоте |to.num - start.num|
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.
Возможно дистанция может быть очень большой, имеет смысл ограничить глубину?
std::shared_ptr<storage::BufferStorage> db_; | ||
std::shared_ptr<blockchain::BlockTree> block_tree_; | ||
primitives::BlockInfo last_finalized_indexed_; | ||
std::map<primitives::BlockInfo, Indexed<T>> map_; |
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.
Возможно тут map<> не нужен, у нас в список элементы кладутся уже сортированными и правая часть(до финализации) непрерывкная. Можно организовать поиск за O(1) по индексу заместо O(log N) по мапе.
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.
- проверяем по индексу за O(1), если лежит то что искали, то ок - выходим. Лучший случай
- если не то что надо, то за O(log N) через lower_bound. Худший случай.
Signed-off-by: turuslan <[email protected]> # Conflicts: # core/consensus/babe/impl/babe_config_repository_impl.cpp # core/consensus/babe/impl/babe_impl.cpp # core/injector/application_injector.cpp # test/core/network/state_protocol_observer_test.cpp
Signed-off-by: turuslan <[email protected]>
Referenced issues
Description of the Change
Indexer
.value
for each chain in block from it's parents.Descent
remembers unindexed blocks info.Indexed::inherit=true
means block is indexed and value is in blockIndexed::prev
.BabeConfigRepository
to useIndexer
.BabeIndexedValue::state
from runtime for genesis and warp sync'ed blocks.BabeIndexedValue::config
, because digest changing it is rare.BabeIndexedValue::next_state
fromBabeIndexedValue::config
and digests.BabeConfigRepository::readFromState(BlockInfo)
toBabeConfigRepository::warp(BlockInfo)
.BabeConfigRepository
toWarpSync
.BabeDigestObserver
fromDigestTracker
.SCALE_TIE_ONLY(field1, field2, ...)
macro.InMemoryCursor
.MapCursor::seekReverse(prefix)
.getNextEpochDigest
toHasAuthoritySetChange
.BlockTree::isFinalized(BlockInfo)
.BlockTree::hasDirectChain(BlockInfo, BlockInfo)
stub.BlockHeader::parentInfo()
.Benefits
Possible Drawbacks
WarpSync::applyInner
call), or will miss digests for old blocks. (or special struct for warp sync blocks/gaps)