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

MVP Generic Sequential & Skipping Lite Client Verifiers #31

Merged
merged 39 commits into from
Nov 28, 2019
Merged

Conversation

ebuchman
Copy link
Member

@ebuchman ebuchman commented Sep 8, 2019

This is an MVP of generic lite client verifiers for the sequential and skipping (ie. bisection) cases. It defines traits for the key data types (Header, Validators, Validator, Commit, Vote) and exposes the minimal amount of info to express the core validation.

@ebuchman ebuchman changed the title MVP Generic Lite Client MVP Generic Sequential Lite Client Sep 8, 2019
@ebuchman
Copy link
Member Author

ebuchman commented Sep 8, 2019

Notes about the bisecting version:

  • we should just call it "SkippingVerifier" since it skips blocks. It does not have a notion of provider or request so the bisection actually takes place outside this module
  • we don't have the validator set for the commit we're verifying
  • we need the votes to return validator ids and we need to be able to fetch validators by id so we can verify the votes

The latter points are good justification for keeping the address in the actual vote structure included in the commit, as per tendermint/tendermint#3596 (comment). Otherwise, lite clients would have to also download the current validator set to know if the votes are from any validators they already trust.

It might also mean we need to use some different traits for the skipping verifier.

@ebuchman ebuchman changed the title MVP Generic Sequential Lite Client MVP Generic Sequential & Skipping Lite Client Verifiers Sep 9, 2019
Copy link
Contributor

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

Looks nice and clean. Will look more at the verification part soon.

lite/src/skipping.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

In the go client we get more data than shown here and we do more validation. Is this something that will be added later?

lite/src/sequential.rs Outdated Show resolved Hide resolved
lite/src/skipping.rs Outdated Show resolved Hide resolved
lite/src/sequential.rs Outdated Show resolved Hide resolved
lite/src/sequential.rs Outdated Show resolved Hide resolved
lite/src/skipping.rs Outdated Show resolved Hide resolved
lite/src/skipping.rs Outdated Show resolved Hide resolved
lite/src/sequential.rs Outdated Show resolved Hide resolved
lite/src/types.rs Outdated Show resolved Hide resolved
lite/src/types.rs Outdated Show resolved Hide resolved
@milosevic
Copy link
Contributor

Very nice and clean.

Copy link
Member Author

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Some responses

@melekes
Copy link
Contributor

melekes commented Sep 12, 2019

The two main differences between SequentialVerifier and SkippingVerifier seem to be:

  1. sequential height check
  2. amount of voting power needed to trust a new header

Can we maybe offload (1) to the caller and make (2) a parameter, so that we can merge SequentialVerifier and SkippingVerifier into Verifier

lite/src/skipping.rs Outdated Show resolved Hide resolved
ebuchman and others added 13 commits October 2, 2019 10:26
This reverts commit f521f04.
This is just the simplest way to move forward implementing the traits of
the lite package. There are alternatives:
We do not want a create a circular dependency between lite and
tendermint (which does not even compile). To avoid this we could:
1) make lite a module of tendermint, or, 2) replicate a lot of the types
of the tendermint crate in the lite package (e.g. Time, Ids etc), or 3)
have a dependency from tendermint to the lite package only (but then the
trait impls do need to live in the lite crate instead with the types in
the tendermint crate directly).

copied changes over from
d3ce237
@ebuchman
Copy link
Member Author

ebuchman commented Nov 1, 2019

After starting to work on tests I found myself essentially implementing a lot of types and functionality that already exists in the tendermint-rs and in #36, so starting to think that means we will actually test this using the real types and it's not worth it to duplicate all that in mocks. Not sure really how to interpret this yet, whether it means the the abstractions here aren't as useful as hoped or if they're maybe not abstract enough. The mocks would be a bit lighter than the real types, but it's not clear the effort of implementing them is really worth it ... would love more opinion.

So I would vote to merge this as is without tests (unless there are still unaddressed review comments but I think I got everything) and to work on the tests along with the trait implementations in #36.

Certainly this lends credence to lite not being it's own crate, so it can be tested using the real types.

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

The mocks would be a bit lighter than the real types, but it's not clear the effort of implementing them is really worth it ... would love more opinion.

I do not think we should write mock impls if they aren't useful and it means about the same effort as writing actual implementations.

So I would vote to merge this as is without tests (unless there are still unaddressed review comments but I think I got everything) and to work on the tests along with the trait implementations in #36.

I agree! Besides the impl lite::Header for Header this only contain traits. I think we can merge this as is.

There are follow-up PR with impls of this traits and a few tests (currently against this branch) and more tests to come. It would be cleaner to merge this and base the remaining light client PRs to master instead of this PR-branch here.

@liamsi liamsi requested a review from brapse November 28, 2019 14:15
@liamsi
Copy link
Member

liamsi commented Nov 28, 2019

@tarcieri / @tony-iqlusion: Do you usually merge or squash PRs here? The commit history on master looks like a mix of both.

@tarcieri
Copy link
Contributor

@liamsi I personally prefer merge commits, because they give you a cryptographically authenticated history of how code landed on master

@liamsi
Copy link
Member

liamsi commented Nov 28, 2019

Thanks @tarcieri. That makes sense. The team seems in favour of squashing though (like in the golang tendermint repo). And I think there is also merit in having a cleaner history on master. The original commit history is still around in the Pull request. Well ... as long as github is around I guess :-P

In any case I'm in favour of consistency. Will stick to squash merging then.

@liamsi liamsi merged commit 90be161 into master Nov 28, 2019
@ebuchman
Copy link
Member Author

cryptographically authenticated

With SHA1. And trusting github. The git model is so broken it hurts my brain: https://ebuchman.github.io/posts/2019-01-26-software-collab-part1/ . So I air on the side of clean commit history - it's especially nice to have every commit correspond to just one PR so you can see how everything happened, and otherwise restrict merging to master so anyone can see that each merge got the approvals if they want to. Would love to see more tooling developed around authenticating that merges happened properly and that squash merges correspond to the same patches as the set of commits, but alas, we're not there yet.

@tarcieri
Copy link
Contributor

With SHA1.

Yup 😜

@xla xla deleted the bucky/lite branch January 18, 2020 15:10
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.

7 participants