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

consensus: proposal#POLRound checking code might be incorrect #2702

Closed
melekes opened this issue Oct 25, 2018 · 5 comments
Closed

consensus: proposal#POLRound checking code might be incorrect #2702

melekes opened this issue Oct 25, 2018 · 5 comments
Labels
C:consensus Component: Consensus T:question Type: Question

Comments

@melekes
Copy link
Contributor

melekes commented Oct 25, 2018

tendermint/consensus/state.go

Lines 1428 to 1432 in bbf15b3

// Verify POLRound, which must be -1 or between 0 and proposal.Round exclusive.
if proposal.POLRound != -1 &&
(proposal.POLRound < 0 || proposal.Round <= proposal.POLRound) {
return ErrInvalidProposalPOLRound
}

Refs #2392 (comment)
In log-node2.txt I found

Okt 01 15:50:24 ip-172-31-9-150.us-east-2.compute.internal thorchaind[20170]: E[10-01|15:50:24.490] Error with msg                               module=consensus height=366511 round=0 type=*consensus.ProposalMessage peer= err="Error invalid proposal POL round" msg="[Proposal Proposal{366511/0 1:707EC619D399 (0,:0:000000000000) /EA1BAEEF4B7D.../ @ 2018-10-01T15:50:24.485Z}]"

Can't POLRound be 0? If not, what could've led the honest node to create such a proposal?

In any case, I'd prefer the above code to be rewritten:

	if !(proposal.POLRound == -1 ||
		(proposal.POLRound > 0 && proposal.POLRound < proposal.Round)) {
		return ErrInvalidProposalPOLRound
	}
@melekes melekes added T:question Type: Question C:consensus Component: Consensus labels Oct 25, 2018
@milosevic
Copy link
Contributor

This condition is really hard to get. Initially, lockedRound and validRound are set to -1 as we start with round 0. If some process locks a block in round 0, then 0 is valid proposal.POLRound in rounds > 0. I would suggest small modifications to your proposal:

	if !(proposal.POLRound < -1 ||
		(proposal.POLRound >= 0 && proposal.POLRound >= proposal.Round)) {
		return ErrInvalidProposalPOLRound
	}

melekes added a commit that referenced this issue Oct 25, 2018
…LRound in rounds > 0

This condition is really hard to get. Initially, lockedRound and
validRound are set to -1 as we start with round 0.

Refs #2702
@melekes
Copy link
Contributor Author

melekes commented Oct 25, 2018

Note here

Okt 01 15:50:24 ip-172-31-9-150.us-east-2.compute.internal thorchaind[20170]: E[10-01|15:50:24.490] Error with msg                               module=consensus height=366511 round=0 type=*consensus.ProposalMessage peer= err="Error invalid proposal POL round" msg="[Proposal Proposal{366511/0 1:707EC619D399 (0,:0:000000000000) /EA1BAEEF4B7D.../ @ 2018-10-01T15:50:24.485Z}]"

proposal.Round (0) == proposal.POLRound (0)

@ebuchman
Copy link
Contributor

	if !(proposal.POLRound < -1 ||
		(proposal.POLRound >= 0 && proposal.POLRound >= proposal.Round)) {
		return ErrInvalidProposalPOLRound
	}

This doesn't look right - wouldn't this return an error if POLRound == -1 ?

I think perhaps what's happening is that the proposer is receiving +2/3 prevotes for nil for the round before they even get a chance to make a proposal. So then POLInfo returns a 0 for POLRound since it's seen a +2/3 prevotes

@milosevic
Copy link
Contributor

@ebuchman You are right, it returns error for POLRound == -1; the original condition is correct. Regarding your other comment, it will not be a concern after we modify Proposal to use ValidRound instead of computing POLInfo (#2646).
We could potentially change condition slightly to make it more explicit:

	if (proposal.POLRound < 0 && proposal.POLRound != -1)  || proposal.POLRound >= proposal.Round {
		return ErrInvalidProposalPOLRound
	}

@ebuchman
Copy link
Contributor

Let's close this for #2646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:consensus Component: Consensus T:question Type: Question
Projects
None yet
Development

No branches or pull requests

3 participants