lite2: fix tendermint lite sub command (#4505)

* lite2: fix tendermint lite sub command

- better logging
- chainID as an argument
- more examples

* one more log msg

* lite2: fire update right away after start

* turn off auto update in verification tests

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Anton Kaliaev
2020-03-02 06:51:36 +00:00
committed by GitHub
co-authored by mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent c33576e72a
commit 9bf8f41ac9
4 changed files with 94 additions and 35 deletions
+10 -1
View File
@@ -166,12 +166,14 @@ func NewClient(
}
if c.latestTrustedHeader != nil {
c.logger.Info("Checking trusted header using options")
if err := c.checkTrustedHeaderUsingOptions(trustOptions); err != nil {
return nil, err
}
}
if c.latestTrustedHeader == nil || c.latestTrustedHeader.Height < trustOptions.Height {
c.logger.Info("Downloading trusted header using options")
if err := c.initializeWithTrustOptions(trustOptions); err != nil {
return nil, err
}
@@ -258,7 +260,7 @@ func (c *Client) restoreTrustedHeaderAndVals() error {
c.latestTrustedHeader = trustedHeader
c.latestTrustedVals = trustedVals
c.logger.Debug("Restored trusted header and vals", "height", lastHeight)
c.logger.Info("Restored trusted header and vals", "height", lastHeight)
}
return nil
@@ -930,6 +932,11 @@ func (c *Client) removeWitness(idx int) {
func (c *Client) autoUpdateRoutine() {
defer c.routinesWaitGroup.Done()
err := c.Update(time.Now())
if err != nil {
c.logger.Error("Error during auto update", "err", err)
}
ticker := time.NewTicker(c.updatePeriod)
defer ticker.Stop()
@@ -1013,6 +1020,7 @@ func (c *Client) signedHeaderFromPrimary(height int64) (*types.SignedHeader, err
if err == provider.ErrSignedHeaderNotFound {
return nil, err
}
c.logger.Error("Failed to get signed header from primary", "attempt", attempt, "err", err)
time.Sleep(backoffTimeout(attempt))
}
@@ -1036,6 +1044,7 @@ func (c *Client) validatorSetFromPrimary(height int64) (*types.ValidatorSet, err
if err == nil || err == provider.ErrValidatorSetNotFound {
return vals, err
}
c.logger.Error("Failed to get validator set from primary", "attempt", attempt, "err", err)
time.Sleep(backoffTimeout(attempt))
}
+2
View File
@@ -154,6 +154,7 @@ func TestClient_SequentialVerification(t *testing.T) {
)},
dbs.New(dbm.NewMemDB(), chainID),
SequentialVerification(),
UpdatePeriod(0),
)
if tc.initErr {
@@ -280,6 +281,7 @@ func TestClient_SkippingVerification(t *testing.T) {
)},
dbs.New(dbm.NewMemDB(), chainID),
SkippingVerification(DefaultTrustLevel),
UpdatePeriod(0),
)
if tc.initErr {
require.Error(t, err)