Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing view change #427

Merged
merged 6 commits into from
Mar 3, 2020
Merged

fixing view change #427

merged 6 commits into from
Mar 3, 2020

Conversation

HagarMeir
Copy link
Contributor

Signed-off-by: Hagar Meir [email protected]

Signed-off-by: Hagar Meir <[email protected]>
Signed-off-by: Hagar Meir <[email protected]>
Signed-off-by: Hagar Meir <[email protected]>
return false
}
v.Logger.Debugf("Node %d got %s from %d, the in flight proposal is valid", v.SelfID, viewDataToString(vd), sender)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line doesn't exist in the new version, and is pretty valuable

return true, lastDecisionMD.LatestSequence
}

if lastDecisionMD.LatestSequence == mySequence+1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps check the complement condition and fail fast (return false) instead of indenting this whole block

Payload: vd.LastDecision.Payload,
VerificationSequence: int64(vd.LastDecision.VerificationSequence),
}
signatures := make([]types.Signature, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

var signatures []types.Signature

}
v.Logger.Debugf("Node %d checked the in flight and it was valid", v.SelfID)
// create the new view message
signedMsgs := make([]*protos.SignedViewData, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

var signedMsgs []*protos.SignedViewData

myMsg := v.prepareViewDataMsg() // since it might have changed by now
signedMsgs = append(signedMsgs, myMsg.GetViewData()) // leader's message will always be the first
close(v.viewDataMsgs.votes)
for vote := range v.viewDataMsgs.votes {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should never have "processed" our own view data message in the first place, but let's take care of it in a subsequent PR

@@ -714,189 +827,231 @@ func CheckInFlight(messages []*protos.ViewData, f int, quorum int, N uint64, ver
func maxLastDecisionSequence(messages []*protos.ViewData, quorum int, N uint64, verifier api.Verifier) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

these quorum, N, verifier are not used anymore. please remove them?

@@ -714,189 +827,231 @@ func CheckInFlight(messages []*protos.ViewData, f int, quorum int, N uint64, ver
func maxLastDecisionSequence(messages []*protos.ViewData, quorum int, N uint64, verifier api.Verifier) uint64 {
max := uint64(0)
for _, vd := range messages {
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be paranoid but I think we should add a parameter to this method that is the current sequence, and then just check if there is a sequence that is our seq + 1 and return 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.

added a comment to clarify

if vd.LastDecision.Metadata == nil { // this is a genesis proposal
if mySequence > 0 {
// can't validate the signature since I am ahead
if err := ValidateInFlight(vd.InFlightProposal, 0); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're ahead then why don't we also check that the content of the in flight proposal is equal to our latest decision?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We check the in flight proposals later
We don't compare it now since the in flight proposal might be different then the last decision and the view data message is still considered valid


if lastDecisionMD.LatestSequence < mySequence { // this is a decision in the past
// can't validate the signature since I am ahead
if err := ValidateInFlight(vd.InFlightProposal, lastDecisionMD.LatestSequence); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we also check the content of the in flight?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as the last comment

}
signatures = append(signatures, signature)
}
v.deliverDecision(proposal, signatures)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we blindly deliver this without calling v.Verifier.VerifyProposal() beforehand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't...we deliver only after calling ValidateLastDecision

case change := <-v.startChangeChan:
v.startViewChange(change)
if !noInFlight {
if !v.commitInFlightProposal(inFlightProposal) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be collapsed into a single if condition

@@ -1187,6 +1217,69 @@ func TestGradualStart(t *testing.T) {

}

func TestReconfigAndViewChange(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add some comments to explain what is going on in this test?

Signed-off-by: Hagar Meir <[email protected]>
Signed-off-by: Hagar Meir <[email protected]>
@yacovm yacovm merged commit f2a2545 into hyperledger-labs:master Mar 3, 2020
yacovm added a commit that referenced this pull request Mar 5, 2020
* fix the ending of view change (#424)

Signed-off-by: Hagar Meir <[email protected]>

* sync avoid write to view change channel (#425)

Signed-off-by: Hagar Meir <[email protected]>

* fixing view change (#427)

* fixing view change

Signed-off-by: Hagar Meir <[email protected]>

* test view data

Signed-off-by: Hagar Meir <[email protected]>

* test new view

Signed-off-by: Hagar Meir <[email protected]>

* after review

Signed-off-by: Hagar Meir <[email protected]>

* update protos

Signed-off-by: Hagar Meir <[email protected]>

* change comment

* add return reconfig in test

Signed-off-by: Hagar Meir <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants