tendermint / light-client

DEPRECATED: A light client for tendermint, supporting signatures, proofs, and validation (see github.com/tendermint/tendermint/lite)
Other
17 stars 9 forks source link

Notes #10

Closed ebuchman closed 7 years ago

ebuchman commented 7 years ago
ethanfrey commented 7 years ago

The more aesthetic points (the last ones are more logic and will do next).

(All fixed as of 657adca)

ethanfrey commented 7 years ago
ethanfrey commented 7 years ago

This last point is super critical and I would like another review of it:

Is this right: https://github.com/tendermint/light-client/blob/master/certifiers/dynamic.go#L149 ? It's saying that we'll accept the commit if +2/3 of the new validators consist of old validators, even if its not +2/3 of the old validators. I believe we need to insist that its signed by +2/3 of the old validators.

My understanding.... it starts with two validator sets (old and current), and it keeps a tally for each. For each signature, if it was valid in the old set, then add the count to the oldVotes. If it was valid in old and current, then add the count to curVotes.

At the end, only accept it if the oldVotes > 2/3 of the total votes in the old set, and the curVotes is > 2/3 of the votes in the current set.

Thus, it must be signed by +2/3 of the old validators. And those signing old validators must also make up +2/3 of the current set. I think this might be too restrictive if anything, as current validators that were not in the old set are not counted for anything. Thus, if all old validators sign, but we added an equal number of votes to new validators (who also all signed), this would be rejected.

@ebuchman Please take another look at this code to make sure it does what I describe here. And whether this restriction on the current (new) validator set is good as it is, or whether it can be relaxed to just have +2/3 of old set and +2/3 of current set.

ebuchman commented 7 years ago

As per the unmarshaller, can we just put it on the proof itself ? is that a bad pattern?

ebuchman commented 7 years ago

As for the logic of the cur set - you're just saying we need to actually verify this Commit, right? I think it would be good if we separated the logic (first authenticate the new validator set, then confirm that the new set committed the block). I also think we're missing a check that the new ValidatorHash is actually in the header!

Also, I think we only need +1/3 of the old validators. Since 1/3+ can cause a fork, they can cause there to be two new validator sets for height H, each with +2/3 signatures.

So I think we should be doing something like the following:

1) Check that the new validator set hash is in the header 2) Check that +1/3 of the old validators signed the header (this authorizes the new validator set) 3) Check that +2/3 of the new validators signed the header (this authorizes the new checkpoint)

I believe that matches the description in https://github.com/tendermint/tendermint/issues/406

ebuchman commented 7 years ago

Actually, do we have another problem where the next validator set isn't getting signed? We could add NextValidatorSet to a header but maybe there's a better way. Thinking aloud ...

The header for block H says validator set is X. block H is committed with +2/3 from X. block H returns some diff in the EndBlock which changes the validator set to Y. so block H+1 has validator set Y. block H+1 is committed with +2/3 from Y. If the max change in a block is -1/3, then we are guaranteed that the +2/3 from Y contains +1/3 from X. Thus we'd have +1/3 from X signing on the new validator set (but not +2/3). I think thats ok.

ethanfrey commented 7 years ago
As per the unmarshaller, can we just put it on the proof itself ? is that a bad pattern?

When I add support for saving proofs to disk and loading them back, then I will actually have code using it. If I can add it to the Proof itself, I will do that. Maybe the same PubKey{PubKeyInner} trick we use elsewhere.

about the logic of validation. let's sit together at the retreat for 30 minutes and make sure this is all kosher.