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

Proposal gate #1623

Merged
merged 1 commit into from
Aug 17, 2018
Merged

Proposal gate #1623

merged 1 commit into from
Aug 17, 2018

Conversation

lebdron
Copy link
Contributor

@lebdron lebdron commented Aug 1, 2018

Description of the Change

YAC proposal gate implementation:

  • Use hash gate for consensus
  • Hash provider with round number as round indentifier and optional with vote

Unrelated changes note

Bind operator operator| was updated to allow non-copyable objects. "Legacy" code in old model and iroha-cli was not compliant with changes and had to be updated.

// generate order of peers
EXPECT_CALL(*peer_orderer, getOrdering(_)).WillOnce(Return(order));

// ya consensus
Copy link
Contributor

Choose a reason for hiding this comment

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

yac

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since YAC stands for Yet Another Consensus, "yac consensus" is yet another consensus consensus ^^

* Vote for proposal
* @param vote - structure with optional proposal and round number
*/
virtual void vote(ProposalVote vote) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it be const ref?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably yes, but semantic will be different. Because vote contains a unique pointer, value argument means that vote should be moved inside proposal gate. It is done because vote is stored inside proposal gate for commit comparison.

auto order = orderer_->getOrdering(hash);
if (not order) {
log_->error("ordering doesn't provide peers => pass round");
return;
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 execution flow in failure case? Will Iroha available to vote after it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This behavior is defined by the caller. Method will return Result, which wil allow to distinguish bad outcomes.

[&](RejectMessage reject) -> ProposalOutcomeType {
return ProposalReject{model_hash.round};
});
current_proposal_.reset();
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 point to reset here? As I expected, we have to change current_proposal on commit\reject of the block and reject of proposals, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably naming is not the best, because it represents "last voted value", which is reset after consensus outcome is received.

* @param hash - for converting
* @return proposal information
*/
virtual ProposalInfo toModelHash(const YacHash &hash) const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Model here a little bit misleading. Maybe rename it somehow?

namespace iroha {
namespace network {

struct ProposalVote {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add documentation for this structure, the structure below and type name.

decltype(f(*t))>::type {
if (t) {
return f(*t);
auto operator|(T &&t, Transform &&f) -> std::enable_if_t<
Copy link
Contributor

Choose a reason for hiding this comment

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

Nowadays, operator bind seems very complicated. I suggest to add documentation about sfinae here.


/**
* @given non-empty proposal optional and round number
* @when proposal, round -> yac hash -> proposal info
Copy link
Contributor

Choose a reason for hiding this comment

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

-> is not so understandable here, maybe rework it with a verb?

@lebdron lebdron requested a review from muratovv August 14, 2018 14:01
@lebdron lebdron added needs-review pr awaits review from maintainers ordering labels Aug 14, 2018
@lebdron lebdron force-pushed the feature/proposal-gate branch 2 times, most recently from 6a98ae4 to 4581ff0 Compare August 14, 2018 14:06
auto hash = hash_provider_->makeHash(vote);
log_->info("vote for proposal ({}, {}, {})",
vote.proposal ? vote.proposal.value()->hash().toString() : "''",
vote.round.first,
vote.round.second);
auto order = orderer_->getOrdering(hash);
if (not order) {
log_->error("ordering doesn't provide peers => pass round");
return;
return expected::makeError("ordering doesn't provide peers => pass round");
Copy link
Contributor

Choose a reason for hiding this comment

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

"=> pass round" is redundant because a strategy is provided by outer scope.

auto hash = hash_provider_->makeHash(vote);
log_->info("vote for proposal ({}, {}, {})",
vote.proposal ? vote.proposal.value()->hash().toString() : "''",
vote.round.first,
vote.round.second);
auto order = orderer_->getOrdering(hash);
if (not order) {
log_->error("ordering doesn't provide peers => pass round");
return;
return expected::makeError("ordering doesn't provide peers => pass round");
Copy link
Contributor

Choose a reason for hiding this comment

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

"=> pass round" is redundant because a strategy is provided by outer scope.

@lebdron lebdron changed the base branch from trunk/bft_os to trunk/bft-os August 16, 2018 12:31
@sorabot
Copy link

sorabot commented Aug 17, 2018

SonarQube analysis reported 2 issues

  1. MINOR interactive_common_cli.cpp#L43: Return value of function to_string() is not used. rule
  2. MINOR yac_gate_impl.hpp#L68: Unused private function: 'YacGateImpl::copySignatures' rule

@lebdron lebdron merged commit c89bd5f into trunk/bft-os Aug 17, 2018
@lebdron lebdron deleted the feature/proposal-gate branch August 17, 2018 14:59
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants