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

On-demand ordering gate and related fixes #1675

Merged
merged 4 commits into from
Aug 31, 2018

Conversation

lebdron
Copy link
Contributor

@lebdron lebdron commented Aug 24, 2018

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

@l4l l4l added needs-review pr awaits review from maintainers ordering labels Aug 27, 2018
* @param round current round
* @return next reject round
*/
constexpr transport::RoundType nextRejectRound(
Copy link
Contributor

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};
Copy link
Contributor

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.

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 is used only once now, so it should not be required.


return visit_in_place(
outcome,
[&](network::ProposalCommit commit) {
Copy link
Contributor

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());
Copy link
Contributor

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);
Copy link
Contributor

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_;
Copy link
Contributor

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
Copy link
Contributor

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)));
Copy link
Contributor

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?

void OnDemandOrderingServiceImpl::onCollaborationOutcome(
transport::RoundType round) {
log_->info(
"onCollaborationOutcome => round[{}, {}]", round.first, round.second);
Copy link
Contributor

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
Copy link
Contributor

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 {
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 short description of the class

std::lock_guard<std::shared_timed_mutex> lock(mutex_);

visit_in_place(event,
[this](BlockEvent block) {
Copy link
Contributor

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) {
Copy link
Contributor

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,
Copy link
Contributor

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)

@lebdron lebdron changed the base branch from fix/bft-os-algo to trunk/bft-os August 31, 2018 06:06
@lebdron lebdron force-pushed the feature/bft-os-ordering-gate branch from b176b5c to 6c9835e Compare August 31, 2018 06:06
void OnDemandOrderingGate::propagateTransaction(
std::shared_ptr<const shared_model::interface::Transaction> transaction)
const {
throw std::logic_error("Not implemented");
Copy link
Contributor

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"?

Copy link
Contributor

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");
Copy link
Contributor

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?

@lebdron lebdron changed the base branch from trunk/bft-os to refactor/remove-proposal-gate August 31, 2018 10:45
@lebdron lebdron force-pushed the feature/bft-os-ordering-gate branch from 6c9835e to c82d3ea Compare August 31, 2018 10:45
@lebdron lebdron dismissed kamilsa’s stale review August 31, 2018 10:46

Issues addressed

@lebdron lebdron requested a review from kamilsa August 31, 2018 10:46
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>
@lebdron lebdron force-pushed the feature/bft-os-ordering-gate branch from f693862 to e672a04 Compare August 31, 2018 11:40
@lebdron lebdron changed the base branch from refactor/remove-proposal-gate to trunk/bft-os August 31, 2018 11:40
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
@sorabot
Copy link

sorabot commented Aug 31, 2018

SonarQube analysis reported 2 issues

  1. MINOR on_demand_ordering_service_impl.hpp#L57: Unused private function: 'OnDemandOrderingServiceImpl::packNextProposals' rule
  2. MINOR on_demand_ordering_service_impl.hpp#L64: Unused private function: 'OnDemandOrderingServiceImpl::tryErase' rule

@lebdron lebdron merged commit ba05083 into trunk/bft-os Aug 31, 2018
@lebdron lebdron deleted the feature/bft-os-ordering-gate branch August 31, 2018 15:43
lebdron added a commit that referenced this pull request Sep 4, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
nickaleks pushed a commit that referenced this pull request Sep 10, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
bakhtin pushed a commit that referenced this pull request Nov 2, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
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 ordering
Development

Successfully merging this pull request may close these issues.

None yet

5 participants