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

Simplify some light client types and testing #132

Merged
merged 33 commits into from
Feb 2, 2020
Merged

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented Jan 26, 2020

Main change: make TrustedState and SignedHeader structs (instead of traits with assoc. types):

  • as a result of parametrarizing TrustedState<C, H> and SignedHeader<C, H>
    (instead of trait with assoc. types) a few things have to be (re)parametrarized and
    others can be deleted as they are redundant and consumers can use the
    param. structs instead of the trait impls (which duplicated code):

    • parametrarize Store<C, H> too
    • delete mocks: MockSignedHeader, MockState
    • delete impl for block::signed_header::SignedHeader
    • delete impl for lite::TrustedState in JSON tests
    • remove State and state.rs module from implementation completely
    • adapt params in verifier to match generic params of TrustedState & SignedHeader
  • More (minor) changes / improvements:

    • remove dependency on block::Height by making lite::Height a u64 type alias
    • differentiate error from verify_commit_(trusting vs full)
    • increase test coverage (slightly only, compare codecovs total below with codecov)
    • simplify test further by removing votes_len from Commit
    • use verify_update_single instead of verify_single in tests (unexport the latter) (f2fd6fe)
  • rename:

    • verify_and_update_single -> verify_single
    • verify_and_update_bisection -> verify_bisection
  • remove store from public facing functions

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGES.md

}
}

// TODO: should this go in the central place all impls live instead? (currently lite_impl)
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we want to keep types.rs purely abstract / generic only? If so this should go into a different file/module.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it should go with the impls since it's a pretty generic thing, but maybe in its own module file in lite

@liamsi liamsi requested review from ebuchman and xla January 28, 2020 08:13
@liamsi liamsi marked this pull request as ready for review January 28, 2020 08:13
@codecov-io
Copy link

codecov-io commented Jan 29, 2020

Codecov Report

Merging #132 into master will increase coverage by 3.93%.
The diff coverage is 67.67%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #132      +/-   ##
=========================================
+ Coverage   32.96%   36.9%   +3.93%     
=========================================
  Files          92      90       -2     
  Lines        3009    3127     +118     
  Branches      430     463      +33     
=========================================
+ Hits          992    1154     +162     
+ Misses       1816    1718      -98     
- Partials      201     255      +54
Impacted Files Coverage Δ
tendermint/src/lite_impl/validator_set.rs 100% <ø> (+18.75%) ⬆️
tendermint-lite/src/main.rs 0% <0%> (ø) ⬆️
tendermint-lite/src/requester.rs 0% <0%> (ø) ⬆️
tendermint/src/lite_impl/header.rs 89.79% <100%> (+6.12%) ⬆️
tendermint/src/lite/types.rs 58.12% <57.96%> (-16.88%) ⬇️
tendermint-lite/src/store.rs 70% <75%> (+70%) ⬆️
tendermint/src/lite_impl/signed_header.rs 82.22% <80%> (-3.83%) ⬇️
tendermint/src/lite/verifier.rs 79.66% <85.1%> (+21.27%) ⬆️
tendermint/src/serializers.rs 0% <0%> (ø) ⬆️
tendermint/src/vote.rs 31.48% <0%> (ø) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a02ffa5...b7282b8. Read the comment docs.

…dHeader

- as a result of parametrarizing `TrustedState<C, H>` and `SignedHeader<C, H>`
(instead of trait with assoc. types) a few things have to be (re)parametrarized and
other can be completely deleted as they are redundant and consumers can use the
param structs instead of the trait impls:
 - parametrarize Store<C, H> too
 - delete mocks: MockSignedHeader, MockState
 - delete impl for block::signed_header::SignedHeader
 - delete impl for lite::TrustedState in JSON tests
 - remove `State` and state.rs module from implementation completely
 - adapt params in verifier to match generic params of TrustedState & SignedHeader

- remove dep on block::Height by making lite::Height a u64 alias
 - remove `DefaultTrustLevel` from tests
 - remove TrustThresholdOneThird and TrustThresholdTwoThirds from tendermint-lite
 (the latter was not used and the first duplicates the default impl)
 - use TrustThresholdFraction::default() instead
- rename `validate_untrusted` -> `validate` which calls the new method on Commit
- simplify tests (`Option`s are not longer needed)
- move length matches check to impl of `validate`
…instead

- use MemStore of light crate in tests as a Mock
…le in the super module)

 - mocks can be used in both types.rs and verifier.rs without decreasing codecov
 - rename _verify_and_update_bisection -> verify_and_update_bisection_inner
@liamsi liamsi mentioned this pull request Jan 30, 2020
22 tasks
…e spec

- verify_and_update_single -> verify_single
- verify_and_update_bisection -> verify_bisection
- remove store from public facing functions
@liamsi liamsi changed the title Simplify some light client related types Simplify some light client types and testing Jan 31, 2020
Copy link
Member

@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.

Wonderful work! Left a bunch of questions and minor nits but they can be followed up on.

tendermint/src/lite/types.rs Show resolved Hide resolved
}
}

// TODO: should this go in the central place all impls live instead? (currently lite_impl)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it should go with the impls since it's a pretty generic thing, but maybe in its own module file in lite

tendermint/src/lite/types.rs Show resolved Hide resolved
tendermint/src/lite/types.rs Show resolved Hide resolved
tendermint/src/lite/verifier.rs Show resolved Hide resolved
tendermint/src/lite/verifier.rs Show resolved Hide resolved
tendermint/Cargo.toml Show resolved Hide resolved
tendermint/src/lite/types.rs Show resolved Hide resolved
tendermint/src/lite_impl/signed_header.rs Show resolved Hide resolved
tendermint/tests/lite.rs Show resolved Hide resolved
@ebuchman ebuchman merged commit d0e99f9 into master Feb 2, 2020
@ebuchman ebuchman deleted the ismail/light_cleanup branch February 2, 2020 03:32
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.

None yet

4 participants