Skip to content

Commit

Permalink
fix: call digest processing from block executor
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
  • Loading branch information
xDimon committed Nov 14, 2022
1 parent 7c75ac9 commit 09baaf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions core/consensus/babe/impl/babe_config_repository_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ namespace kagome::consensus::babe {
EpochNumber epoch_number = slotToEpoch(digest.slot_number);

auto node = getNode(block);
BOOST_ASSERT(node != nullptr);

SL_LOG(logger_,
node->epoch != epoch_number ? log::Level::DEBUG : log::Level::TRACE,
Expand Down
27 changes: 14 additions & 13 deletions core/consensus/babe/impl/block_executor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,6 @@ namespace kagome::consensus {

auto consistency_guard = consistency_keeper_->start(block_info);

// observe digest of block
// (must be done strictly after block will be added)
auto digest_tracking_res =
digest_tracker_->onDigest(block_info, block.header.digest);
if (digest_tracking_res.has_error()) {
SL_ERROR(logger_,
"Error while tracking digest of block {}: {}",
block_info,
digest_tracking_res.error());
return digest_tracking_res.as_failure();
}

auto babe_config = babe_config_repo_->config(block_info, epoch_number);
if (babe_config == nullptr) {
return Error::INVALID_BLOCK; // TODO Change to more appropriate error
Expand Down Expand Up @@ -259,6 +247,18 @@ namespace kagome::consensus {
OUTCOME_TRY(block_tree_->addBlock(block));
}

// observe digest of block
// (must be done strictly after block will be added)
auto digest_tracking_res =
digest_tracker_->onDigest(block_info, block.header.digest);
if (digest_tracking_res.has_error()) {
SL_ERROR(logger_,
"Error while tracking digest of block {}: {}",
block_info,
digest_tracking_res.error());
return digest_tracking_res.as_failure();
}

// try to apply postponed justifications first if any
if (not postponed_justifications_.empty()) {
std::vector<primitives::BlockInfo> to_remove;
Expand All @@ -280,7 +280,8 @@ namespace kagome::consensus {
// apply justification if any (must be done strictly after block will be
// added and his consensus-digests will be handled)
if (b.justification.has_value()) {
SL_VERBOSE(logger_, "Apply justification received for block {}", block_info);
SL_VERBOSE(
logger_, "Apply justification received for block {}", block_info);

auto res = applyJustification(block_info, b.justification.value());
if (res.has_error()) {
Expand Down

0 comments on commit 09baaf8

Please sign in to comment.