Skip to content

Commit 2168ad6

Browse files
authored
beefy vote synchronized (#1832)
Signed-off-by: turuslan <[email protected]>
1 parent 0f99a96 commit 2168ad6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

core/network/beefy/beefy.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "blockchain/block_tree_error.hpp"
1212
#include "consensus/beefy/digest.hpp"
1313
#include "consensus/beefy/sig.hpp"
14+
#include "consensus/timeline/timeline.hpp"
1415
#include "crypto/crypto_store/session_keys.hpp"
1516
#include "metrics/histogram_timer.hpp"
1617
#include "network/beefy/protocol.hpp"
@@ -40,6 +41,7 @@ namespace kagome::network {
4041
std::shared_ptr<storage::SpacedStorage> db,
4142
std::shared_ptr<ThreadPool> thread_pool,
4243
std::shared_ptr<boost::asio::io_context> main_thread,
44+
LazySPtr<consensus::Timeline> timeline,
4345
std::shared_ptr<crypto::SessionKeys> session_keys,
4446
LazySPtr<BeefyProtocol> beefy_protocol,
4547
std::shared_ptr<primitives::events::ChainSubscriptionEngine>
@@ -51,6 +53,7 @@ namespace kagome::network {
5153
strand_inner_{thread_pool->io_context()},
5254
strand_{*strand_inner_},
5355
main_thread_{std::move(main_thread)},
56+
timeline_{std::move(timeline)},
5457
session_keys_{std::move(session_keys)},
5558
beefy_protocol_{std::move(beefy_protocol)},
5659
min_delta_{chain_spec.isWococo() ? 4u : 8u},
@@ -382,6 +385,9 @@ namespace kagome::network {
382385
}
383386

384387
outcome::result<void> Beefy::vote() {
388+
if (not timeline_.get()->wasSynchronized()) {
389+
return outcome::success();
390+
}
385391
auto next_session = sessions_.upper_bound(beefy_finalized_ + 1);
386392
if (next_session == sessions_.begin()) {
387393
SL_VERBOSE(log_, "can't vote: no sessions");

core/network/beefy/beefy.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ namespace kagome::blockchain {
2929
class BlockTree;
3030
} // namespace kagome::blockchain
3131

32+
namespace kagome::consensus {
33+
class Timeline;
34+
} // namespace kagome::consensus
35+
3236
namespace kagome::crypto {
3337
class EcdsaProvider;
3438
class SessionKeys;
@@ -55,6 +59,7 @@ namespace kagome::network {
5559
std::shared_ptr<storage::SpacedStorage> db,
5660
std::shared_ptr<ThreadPool> thread_pool,
5761
std::shared_ptr<boost::asio::io_context> main_thread,
62+
LazySPtr<consensus::Timeline> timeline,
5863
std::shared_ptr<crypto::SessionKeys> session_keys,
5964
LazySPtr<BeefyProtocol> beefy_protocol,
6065
std::shared_ptr<primitives::events::ChainSubscriptionEngine>
@@ -103,6 +108,7 @@ namespace kagome::network {
103108
std::shared_ptr<boost::asio::io_context> strand_inner_;
104109
boost::asio::io_context::strand strand_;
105110
std::shared_ptr<boost::asio::io_context> main_thread_;
111+
LazySPtr<consensus::Timeline> timeline_;
106112
std::shared_ptr<crypto::SessionKeys> session_keys_;
107113
LazySPtr<BeefyProtocol> beefy_protocol_;
108114
primitives::BlockNumber min_delta_;

0 commit comments

Comments
 (0)