-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
👋 Thanks for creating a PR! Before we can merge this PR, please make sure that all the following items have been
Thank you for your contribution to Tendermint! 🚀 |
Codecov Report
@@ 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
|
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
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