-
Notifications
You must be signed in to change notification settings - Fork 297
Conversation
- Extended SyncEvent with height and kNothing outcome - Updated tests - Fixed accordingly GateObjects (Rejects & Agreement on None) Signed-off-by: Kitsu <mail@kitsu.me>
4b11923
to
72a3ce7
Compare
Signed-off-by: Kitsu <mail@kitsu.me>
/** | ||
* Processing last committed block | ||
*/ | ||
virtual void process_commit( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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}); |
There was a problem hiding this comment.
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) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove that?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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, {}}; |
There was a problem hiding this comment.
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, | ||
{}}); |
There was a problem hiding this comment.
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, | |||
{}}); |
There was a problem hiding this comment.
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, | ||
{}}); |
There was a problem hiding this comment.
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) {} |
There was a problem hiding this comment.
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{}}); |
There was a problem hiding this comment.
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>
irohad/network/consensus_gate.hpp
Outdated
#include "consensus/round.hpp" | ||
#include "interfaces/common_objects/types.hpp" |
There was a problem hiding this comment.
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?
irohad/network/consensus_gate.hpp
Outdated
@@ -7,9 +7,12 @@ | |||
#define IROHA_CONSENSUS_GATE_HPP | |||
|
|||
#include <boost/optional.hpp> | |||
#include <boost/variant.hpp> |
There was a problem hiding this comment.
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>
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 fixedAgreementOnNone
isn't properly handledNo decision on behavior of reject cases