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

light: implement validate basic #4916

Merged
merged 10 commits into from
Jun 4, 2020
Merged

Conversation

cmwaters
Copy link
Contributor

Description

Added validate basic to the light client and wrote tests accordingly

I also tried to improve the error messages as when the providers have all been replaced the user doesn't know what the existing error that caused them to be replaced is

Addresses: #4913

@cmwaters cmwaters requested review from melekes and tessr as code owners May 29, 2020 09:58
@auto-comment
Copy link

auto-comment bot commented May 29, 2020

👋 Thanks for creating a PR!

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer
  • Applied Appropriate Labels

Thank you for your contribution to Tendermint! 🚀

Sorry, something went wrong.

@cmwaters cmwaters added the C:light Component: Light label May 29, 2020
@codecov-commenter
Copy link

codecov-commenter commented May 29, 2020

Codecov Report

Merging #4916 into master will increase coverage by 0.12%.
The diff coverage is 80.55%.

@@            Coverage Diff             @@
##           master    #4916      +/-   ##
==========================================
+ Coverage   63.23%   63.36%   +0.12%     
==========================================
  Files         188      188              
  Lines       19566    19587      +21     
==========================================
+ Hits        12373    12411      +38     
+ Misses       6203     6191      -12     
+ Partials      990      985       -5     
Impacted Files Coverage Δ
light/client.go 74.68% <80.55%> (+1.18%) ⬆️
blockchain/v2/routine.go 77.61% <0.00%> (-2.99%) ⬇️
p2p/pex/pex_reactor.go 81.56% <0.00%> (-0.56%) ⬇️
consensus/reactor.go 72.99% <0.00%> (ø)
consensus/state.go 72.11% <0.00%> (+0.55%) ⬆️
blockchain/v0/pool.go 78.98% <0.00%> (+0.95%) ⬆️
statesync/snapshots.go 94.07% <0.00%> (+1.48%) ⬆️
libs/events/events.go 98.05% <0.00%> (+4.85%) ⬆️
crypto/sr25519/pubkey.go 39.28% <0.00%> (+7.14%) ⬆️
... and 1 more

@cmwaters cmwaters changed the title Callum/light client validate basic light: implement validate basic May 29, 2020
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

good work! 🔨

lite2/client.go Outdated
@@ -1052,10 +1053,32 @@ func (c *Client) signedHeaderFromPrimary(height int64) (*types.SignedHeader, err
h, err := c.primary.SignedHeader(height)
c.providerMutex.Unlock()
if err == nil {
if h == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we extract this and the next conditions into a function?

func validateHeader(h *Header, expectedHeight int64) error {
  if h == nil { return errors.New("nil header")}
  if (expectedHeight > 0 && h.Height != expectedHeight) { return errors.New("height mismatch") 
  return h.ValidateBasic(c.chainID)
}

lite2/client.go Outdated
@@ -1082,17 +1104,35 @@ func (c *Client) validatorSetFromPrimary(height int64) (*types.ValidatorSet, err
c.providerMutex.Lock()
vals, err := c.primary.ValidatorSet(height)
c.providerMutex.Unlock()
if err == nil || err == provider.ErrValidatorSetNotFound {
if err == nil {
if vals == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@cmwaters cmwaters requested a review from melekes June 3, 2020 11:48
@cmwaters cmwaters merged commit d53a8d0 into master Jun 4, 2020
@cmwaters cmwaters deleted the callum/light-client-validate-basic branch June 4, 2020 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:light Component: Light
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants