Skip to content

Commit

Permalink
fetch justification range after sync (#1933)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
  • Loading branch information
turuslan authored Jan 17, 2024
1 parent 942411e commit 9cac834
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/consensus/grandpa/impl/verified_justification_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "blockchain/block_tree.hpp"
#include "consensus/grandpa/authority_manager.hpp"
#include "consensus/grandpa/has_authority_set_change.hpp"
#include "consensus/timeline/timeline.hpp"
#include "network/synchronizer.hpp"
#include "utils/weak_io_context_post.hpp"

Expand All @@ -22,11 +23,13 @@ namespace kagome::consensus::grandpa {
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<AuthorityManager> authority_manager,
LazySPtr<network::Synchronizer> synchronizer,
LazySPtr<Timeline> timeline,
primitives::events::ChainSubscriptionEnginePtr chain_sub_engine)
: main_thread_{std::move(main_thread)},
block_tree_{std::move(block_tree)},
authority_manager_{std::move(authority_manager)},
synchronizer_{std::move(synchronizer)},
timeline_{std::move(timeline)},
chain_sub_{chain_sub_engine},
log_{log::createLogger("VerifiedJustificationQueue")} {
app_state_manager.takeControl(*this);
Expand Down Expand Up @@ -201,6 +204,9 @@ namespace kagome::consensus::grandpa {
}

void VerifiedJustificationQueue::rangeLoop() {
if (not timeline_.get()->wasSynchronized()) {
return;
}
auto finalized = block_tree_->getLastFinalized().number;
auto best = block_tree_->bestBlock().number;
if (best - finalized < kRangeStart) {
Expand Down
6 changes: 6 additions & 0 deletions core/consensus/grandpa/impl/verified_justification_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ namespace kagome::blockchain {
class BlockTree;
} // namespace kagome::blockchain

namespace kagome::consensus {
class Timeline;
} // namespace kagome::consensus

namespace kagome::network {
class Synchronizer;
} // namespace kagome::network
Expand All @@ -41,6 +45,7 @@ namespace kagome::consensus::grandpa {
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<AuthorityManager> authority_manager,
LazySPtr<network::Synchronizer> synchronizer,
LazySPtr<Timeline> timeline,
primitives::events::ChainSubscriptionEnginePtr chain_sub_engine);

bool start();
Expand All @@ -63,6 +68,7 @@ namespace kagome::consensus::grandpa {
std::shared_ptr<blockchain::BlockTree> block_tree_;
std::shared_ptr<AuthorityManager> authority_manager_;
LazySPtr<network::Synchronizer> synchronizer_;
LazySPtr<Timeline> timeline_;
primitives::events::ChainSub chain_sub_;
log::Logger log_;

Expand Down

0 comments on commit 9cac834

Please sign in to comment.