From d4d2b66067cf5291f7ecf6622d70b74acaa94a13 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 13 Apr 2021 14:21:00 +0200 Subject: [PATCH] light: handle too high errors correctly (#6346) --- CHANGELOG_PENDING.md | 1 + light/client.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 308197613..11d246889 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -87,3 +87,4 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi - [privval] \#5638 Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash) - [blockchain/v1] [\#5701](https://github.com/tendermint/tendermint/pull/5701) Handle peers without blocks (@melekes) - [blockchain/v1] \#5711 Fix deadlock (@melekes) +- [light] \#6346 Correctly handle too high errors to improve client robustness (@cmwaters) diff --git a/light/client.go b/light/client.go index 459d406bd..1b7bbe70f 100644 --- a/light/client.go +++ b/light/client.go @@ -731,7 +731,7 @@ func (c *Client) verifySkipping( blockCache = append(blockCache, interimBlock) // if the error is benign, the client does not need to replace the primary - case provider.ErrLightBlockNotFound, provider.ErrNoResponse: + case provider.ErrLightBlockNotFound, provider.ErrNoResponse, provider.ErrHeightTooHigh: return nil, err // all other errors such as ErrBadLightBlock or ErrUnreliableProvider are seen as malevolent and the @@ -969,7 +969,7 @@ func (c *Client) lightBlockFromPrimary(ctx context.Context, height int64) (*type // Everything went smoothly. We reset the lightBlockRequests and return the light block return l, nil - case provider.ErrNoResponse, provider.ErrLightBlockNotFound: + case provider.ErrNoResponse, provider.ErrLightBlockNotFound, provider.ErrHeightTooHigh: // we find a new witness to replace the primary c.logger.Debug("error from light block request from primary, replacing...", "error", err, "height", height, "primary", c.primary) @@ -1072,7 +1072,7 @@ func (c *Client) findNewPrimary(ctx context.Context, height int64, remove bool) return response.lb, nil // process benign errors by logging them only - case provider.ErrNoResponse, provider.ErrLightBlockNotFound: + case provider.ErrNoResponse, provider.ErrLightBlockNotFound, provider.ErrHeightTooHigh: lastError = response.err c.logger.Debug("error on light block request from witness", "error", response.err, "primary", c.witnesses[response.witnessIndex])