Skip to content

Commit

Permalink
beefy vote synchronized (#1832)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan authored Oct 6, 2023
1 parent 0f99a96 commit 2168ad6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/network/beefy/beefy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "blockchain/block_tree_error.hpp"
#include "consensus/beefy/digest.hpp"
#include "consensus/beefy/sig.hpp"
#include "consensus/timeline/timeline.hpp"
#include "crypto/crypto_store/session_keys.hpp"
#include "metrics/histogram_timer.hpp"
#include "network/beefy/protocol.hpp"
Expand Down Expand Up @@ -40,6 +41,7 @@ namespace kagome::network {
std::shared_ptr<storage::SpacedStorage> db,
std::shared_ptr<ThreadPool> thread_pool,
std::shared_ptr<boost::asio::io_context> main_thread,
LazySPtr<consensus::Timeline> timeline,
std::shared_ptr<crypto::SessionKeys> session_keys,
LazySPtr<BeefyProtocol> beefy_protocol,
std::shared_ptr<primitives::events::ChainSubscriptionEngine>
Expand All @@ -51,6 +53,7 @@ namespace kagome::network {
strand_inner_{thread_pool->io_context()},
strand_{*strand_inner_},
main_thread_{std::move(main_thread)},
timeline_{std::move(timeline)},
session_keys_{std::move(session_keys)},
beefy_protocol_{std::move(beefy_protocol)},
min_delta_{chain_spec.isWococo() ? 4u : 8u},
Expand Down Expand Up @@ -382,6 +385,9 @@ namespace kagome::network {
}

outcome::result<void> Beefy::vote() {
if (not timeline_.get()->wasSynchronized()) {
return outcome::success();
}
auto next_session = sessions_.upper_bound(beefy_finalized_ + 1);
if (next_session == sessions_.begin()) {
SL_VERBOSE(log_, "can't vote: no sessions");
Expand Down
6 changes: 6 additions & 0 deletions core/network/beefy/beefy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ namespace kagome::blockchain {
class BlockTree;
} // namespace kagome::blockchain

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

namespace kagome::crypto {
class EcdsaProvider;
class SessionKeys;
Expand All @@ -55,6 +59,7 @@ namespace kagome::network {
std::shared_ptr<storage::SpacedStorage> db,
std::shared_ptr<ThreadPool> thread_pool,
std::shared_ptr<boost::asio::io_context> main_thread,
LazySPtr<consensus::Timeline> timeline,
std::shared_ptr<crypto::SessionKeys> session_keys,
LazySPtr<BeefyProtocol> beefy_protocol,
std::shared_ptr<primitives::events::ChainSubscriptionEngine>
Expand Down Expand Up @@ -103,6 +108,7 @@ namespace kagome::network {
std::shared_ptr<boost::asio::io_context> strand_inner_;
boost::asio::io_context::strand strand_;
std::shared_ptr<boost::asio::io_context> main_thread_;
LazySPtr<consensus::Timeline> timeline_;
std::shared_ptr<crypto::SessionKeys> session_keys_;
LazySPtr<BeefyProtocol> beefy_protocol_;
primitives::BlockNumber min_delta_;
Expand Down

0 comments on commit 2168ad6

Please sign in to comment.