Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

BFT-aware Synchronizer #1762

Merged
merged 9 commits into from
Nov 2, 2018
Merged

BFT-aware Synchronizer #1762

merged 9 commits into from
Nov 2, 2018

Conversation

l4l
Copy link
Contributor

@l4l l4l commented Oct 7, 2018

Description of the Change

This pr fixes SynchronizerImpl to function with YacGateImpl, so it can handle ConsensusGate::GateObject and operate accordingly to the emitted variant.

Benefits

One more step toward bft consensus

Possible Drawbacks

Tests aren't fixed
AgreementOnNone isn't properly handled
No decision on behavior of reject cases

@l4l l4l added needs-review pr awaits review from maintainers synchronization labels Oct 7, 2018
@l4l l4l requested review from kamilsa and lebdron October 7, 2018 16:09
- Extended SyncEvent with height and kNothing outcome
- Updated tests
- Fixed accordingly GateObjects (Rejects & Agreement on None)

Signed-off-by: Kitsu <mail@kitsu.me>
@l4l l4l changed the title Draft on BFT-aware Synchronizer BFT-aware Synchronizer Oct 22, 2018
Signed-off-by: Kitsu <mail@kitsu.me>
/**
* Processing last committed block
*/
virtual void process_commit(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add processing methods to the interface.

std::shared_ptr<shared_model::interface::Block> commit_message) {
log_->info("at handleNext");
std::unique_ptr<ametsuchi::MutableStorage> storage = getStorage();
if (storage == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use nullptr as no-value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an internal function, is it a big deal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a convention used in the project

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, would be nice to write it down to CONTRIBUTING or similar

@@ -36,6 +36,7 @@ namespace iroha {
struct SynchronizationEvent {
Chain synced_blocks;
SynchronizationOutcomeType sync_outcome;
shared_model::interface::types::HeightType height;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reject round number is also required in ordering gate, so HeightType is better replaced with Round.

*/
TEST_F(SynchronizerTest, RetrieveBlockTwoFailures) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this test case removed? It looks valid, however it seems better to check that it will be called n+1 times if required, where n is number of signatures in commit message.

rxcpp::observable<std::shared_ptr<shared_model::interface::Block>>
commit_message_blocks = rxcpp::observable<>::just(commit_message);
TEST_F(SynchronizerTest, RejectOutcome) {
constexpr int height = 1337;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to fixture? Height it used in all test cases.

commit_message_blocks = rxcpp::observable<>::just(commit_message);
TEST_F(SynchronizerTest, RejectOutcome) {
constexpr int height = 1337;
EXPECT_CALL(*consensus_gate, onOutcome())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expectation seems to be set in all test cases, so it can be moved to setup.

DefaultValue<expected::Result<std::unique_ptr<MutableStorage>, std::string>>::
SetFactory(&createMockMutableStorage);
EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1);
init();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method and its calls can be removed if previous expectation is set in setup.


EXPECT_CALL(*block_loader, retrieveBlocks(_))
.WillRepeatedly(Return(commit_message_blocks));
gate_outcome.get_subscriber().on_next(BlockReject{height});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case for proposal reject should be added.

Signed-off-by: Kitsu <mail@kitsu.me>
Signed-off-by: Kitsu <mail@kitsu.me>
Signed-off-by: Kitsu <mail@kitsu.me>

init();
}
TEST_F(SynchronizerTest, ValidWhenInitialized) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this test.

Signed-off-by: Kitsu <mail@kitsu.me>
Signed-off-by: Kitsu <mail@kitsu.me>
log_->info("processing commit");

auto mutable_storage_var = mutable_factory_->createMutableStorage();
boost::optional<std::unique_ptr<ametsuchi::MutableStorage>> getStorage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make it a class member to avoid passing private members as arguments?

@@ -66,41 +89,56 @@ namespace iroha {
and validator_->validateChain(chain, *storage)) {
mutable_factory_->commit(std::move(storage));

return {chain, SynchronizationOutcomeType::kCommit};
return {chain, SynchronizationOutcomeType::kCommit, {}};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like round from GateObject is lost, so it should be passed here as well.

notifier_.get_subscriber().on_next(
SynchronizationEvent{rxcpp::observable<>::just(commit_message),
SynchronizationOutcomeType::kCommit,
{}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for missing round from GateObject.

@@ -151,7 +151,8 @@ class QueueBehaviorTest : public ::testing::Test {
std::static_pointer_cast<shared_model::interface::Block>(
std::make_shared<shared_model::proto::Block>(
TestBlockBuilder().height(height).build()))),
SynchronizationOutcomeType::kCommit});
SynchronizationOutcomeType::kCommit,
{}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it should be {height, 1}.

commit_subject.get_subscriber().on_next(
SynchronizationEvent{rxcpp::observable<>::just(block),
SynchronizationOutcomeType::kCommit,
{}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{block->height(), 1}.


init();
}
TEST_F(SynchronizerTest, ValidWhenInitialized) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this test.

});

gate_outcome.get_subscriber().on_next(
consensus::BlockReject{consensus::Round{}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProposalReject handler is still not covered by tests, please add one.

- Add Round to positive consensus outcomes
- Make GetStorage class method
- Fix related tests

Signed-off-by: Kitsu <mail@kitsu.me>
#include "consensus/round.hpp"
#include "interfaces/common_objects/types.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is types include required here?

@@ -7,9 +7,12 @@
#define IROHA_CONSENSUS_GATE_HPP

#include <boost/optional.hpp>
#include <boost/variant.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already included in gate_object.hpp, so it can be removed.

Signed-off-by: Kitsu <mail@kitsu.me>
@l4l l4l merged commit cf87670 into trunk/bft_yac Nov 2, 2018
@l4l l4l deleted the feature/synchronizer_bft branch November 2, 2018 11:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-review pr awaits review from maintainers synchronization
Development

Successfully merging this pull request may close these issues.

3 participants