From 897164c14bfba23edcafb87ea6e17a7bfc55b686 Mon Sep 17 00:00:00 2001 From: turuslan Date: Wed, 24 May 2023 10:18:07 +0300 Subject: [PATCH] remove babe delay Signed-off-by: turuslan --- core/consensus/babe/impl/babe_impl.cpp | 14 +------------- test/core/consensus/babe/babe_test.cpp | 20 +++----------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/core/consensus/babe/impl/babe_impl.cpp b/core/consensus/babe/impl/babe_impl.cpp index 2375e675fa..033d0d1d67 100644 --- a/core/consensus/babe/impl/babe_impl.cpp +++ b/core/consensus/babe/impl/babe_impl.cpp @@ -761,10 +761,6 @@ namespace kagome::consensus::babe { } } while (rewind_slots); - // Slot processing begins in 1/3 slot time after start - auto finish_time = babe_util_->slotStartTime(current_slot_) - + babe_config_repo_->slotDuration() / 3; - SL_VERBOSE(log_, "Starting a slot {} in epoch {} (remains {:.2f} sec.)", current_slot_, @@ -774,15 +770,7 @@ namespace kagome::consensus::babe { .count() / 1000.); - // everything is OK: wait for the end of the slot - timer_->expiresAt(finish_time); - timer_->asyncWait([this, now](auto &&ec) { - if (ec) { - log_->error("error happened while waiting on the timer: {}", ec); - return; - } - processSlot(now); - }); + processSlot(now); } void BabeImpl::processSlot(clock::SystemClock::TimePoint slot_timestamp) { diff --git a/test/core/consensus/babe/babe_test.cpp b/test/core/consensus/babe/babe_test.cpp index b4b0f6676b..6bd6a97b9f 100644 --- a/test/core/consensus/babe/babe_test.cpp +++ b/test/core/consensus/babe/babe_test.cpp @@ -318,19 +318,13 @@ TEST_F(BabeTest, Success) { auto breaker = [](const boost::system::error_code &ec) { throw std::logic_error("Must not be called"); }; - std::function on_process_slot_1 = - breaker; std::function on_run_slot_2 = breaker; - std::function on_process_slot_2 = - breaker; std::function on_run_slot_3 = breaker; EXPECT_CALL(*timer_, asyncWait(_)) .InSequence(s) - .WillOnce(testing::SaveArg<0>(&on_process_slot_1)) .WillOnce(testing::SaveArg<0>(&on_run_slot_2)) - .WillOnce(testing::SaveArg<0>(&on_process_slot_2)) .WillOnce(testing::SaveArg<0>(&on_run_slot_3)); EXPECT_CALL(*timer_, expiresAt(_)).WillRepeatedly(Return()); @@ -362,9 +356,7 @@ TEST_F(BabeTest, Success) { .WillOnce(CheckBlockHeader(created_block_.header)); babe_->runEpoch(epoch_); - ASSERT_NO_THROW(on_process_slot_1({})); ASSERT_NO_THROW(on_run_slot_2({})); - ASSERT_NO_THROW(on_process_slot_2({})); } /** @@ -374,23 +366,17 @@ TEST_F(BabeTest, Success) { */ TEST_F(BabeTest, NotAuthority) { EXPECT_CALL(*clock_, now()); - EXPECT_CALL(*babe_config_repo_, slotDuration()); EXPECT_CALL(*babe_util_, slotFinishTime(_)).Times(testing::AnyNumber()); - EXPECT_CALL(*babe_util_, syncEpoch(_)); - EXPECT_CALL(*timer_, expiresAt(_)); - std::function process_slot; - EXPECT_CALL(*timer_, asyncWait(_)) - .WillOnce(testing::SaveArg<0>(&process_slot)); - babe_->runEpoch(epoch_); EXPECT_CALL(*block_tree_, bestLeaf()).WillRepeatedly(Return(best_leaf)); EXPECT_CALL(*block_tree_, getBlockHeader(best_block_hash_)) .WillOnce(Return(best_block_header_)); - EXPECT_CALL(*babe_util_, syncEpoch(_)); + EXPECT_CALL(*babe_util_, syncEpoch(_)).Times(2); EXPECT_CALL(*babe_util_, slotStartTime(_)); expected_epoch_digest.authorities.clear(); EXPECT_CALL(*timer_, expiresAt(_)); EXPECT_CALL(*timer_, asyncWait(_)); - process_slot({}); + + babe_->runEpoch(epoch_); }