-
Notifications
You must be signed in to change notification settings - Fork 297
On-demand ordering gate and related fixes #1675
Conversation
* @param round current round | ||
* @return next reject round | ||
*/ | ||
constexpr transport::RoundType nextRejectRound( |
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.
What is the reason for constexpr here?
visit_in_place(event, | ||
[this](BlockEvent block) { | ||
// block committed, increment block round | ||
current_round_ = {block.height, 1}; |
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, also, possible to move in the separate function as nextRejectRound
.
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 is used only once now, so it should not be required.
|
||
return visit_in_place( | ||
outcome, | ||
[&](network::ProposalCommit 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.
Is it true that outcome value will move to commit variable? Or this is just redundant copy?
|
||
rxcpp::observable<std::shared_ptr<shared_model::interface::Proposal>> | ||
OnDemandOrderingGate::on_proposal() { | ||
using RetType = decltype(on_proposal()); |
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 set more meaningful name for the type?
[&] { return reject_case(commit.round); }); | ||
}, | ||
[&](network::ProposalReject reject) { | ||
return reject_case(reject.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.
Why have we reject case here? I expected that this logic will be in block agreement, isn't it?
std::function<shared_model::interface::TransactionBatch( | ||
std::shared_ptr<const shared_model::interface::Transaction>)> | ||
batch_factory_; | ||
rxcpp::composite_subscription subscription_; |
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.
subscription_
name is not obvious for a reader. Maybe rename it with a business logic oriented name?
const validation::FieldValidator &field_validator); | ||
|
||
} // namespace interface | ||
} // namespace shared_model |
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.
Add a new line, plz.
void OnDemandOrderingGate::propagateTransaction( | ||
std::shared_ptr<const shared_model::interface::Transaction> transaction) | ||
const { | ||
propagateBatch(batch_factory_(std::move(transaction))); |
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.
I suggest not doing support this method because we have been moving to batch API.
So, maybe throw an exception instead?
67ea0b5
to
f8be7cc
Compare
e36513c
to
fc30972
Compare
void OnDemandOrderingServiceImpl::onCollaborationOutcome( | ||
transport::RoundType round) { | ||
log_->info( | ||
"onCollaborationOutcome => round[{}, {}]", round.first, round.second); |
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.
Can we change round type, so that we can write round.block_round, round.reject_round instead of round.first and round.second. It is really hard to read sometimes
|
||
void OnDemandOrderingGate::propagateBatch( | ||
const shared_model::interface::TransactionBatch &batch) const { | ||
// shared lock |
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.
Seems like an obvious comment
namespace shared_model { | ||
namespace interface { | ||
|
||
class TransactionBatchFactory { |
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 short description of the class
std::lock_guard<std::shared_timed_mutex> lock(mutex_); | ||
|
||
visit_in_place(event, | ||
[this](BlockEvent block) { |
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 not const ref?
// block committed, increment block round | ||
current_round_ = {block.height, 1}; | ||
}, | ||
[this](EmptyEvent empty) { |
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 not const ref?
}, | ||
[this](EmptyEvent empty) { | ||
// no blocks committed, increment reject round | ||
current_round_ = {current_round_.first, |
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.
can we use something else instead of pair. I mean round.first and round.second is hard to understand if you don't know that round is pair of (current round and reject round if I am not mistaken)
b176b5c
to
6c9835e
Compare
void OnDemandOrderingGate::propagateTransaction( | ||
std::shared_ptr<const shared_model::interface::Transaction> transaction) | ||
const { | ||
throw std::logic_error("Not implemented"); |
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 write "deprecated" instead of "logic error"?
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.
I miss with that. I mean "deprecated" instead of "Not implemented". Sorry about that.
|
||
void OnDemandOrderingGate::setPcs( | ||
const iroha::network::PeerCommunicationService &pcs) { | ||
throw std::logic_error("Not implemented"); |
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.
Here is also, possibly to provide the reason of an exception, isn't it?
6c9835e
to
c82d3ea
Compare
Signed-off-by: Andrei Lebedev <lebdron@gmail.com> Refactor ordering gate Signed-off-by: Andrei Lebedev <lebdron@gmail.com> Add a comment for reject case Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
f693862
to
e672a04
Compare
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
SonarQube analysis reported 2 issues
|
Description of the Change
On-demand ordering gate, which requests proposals from the on-demand ordering service, and uses voting to pass committed proposal to the pipeline
Benefits
Ordering gate which does not require block reject if peers do not agree on a proposal
Possible Drawbacks
TransactionBatch is modified because it was impossible to build ordering gate with validator linking issues