Skip to content

Commit

Permalink
temp fix for error checking over rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Nov 17, 2023
1 parent de54dfd commit 2a5d6f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
8 changes: 2 additions & 6 deletions signer/sign_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,7 @@ func newStepRegressionError(height, round int64, regressed, last int8) *StepRegr
}
}

type EmptySignBytesError struct{}

func (e *EmptySignBytesError) Error() string {
return "no SignBytes found"
}
var EmptySignBytesError = errors.New("no SignBytes found")

Check warning on line 351 in signer/sign_state.go

View workflow job for this annotation

GitHub Actions / lint

error-naming: error var EmptySignBytesError should have name of the form ErrFoo (revive)

// CheckHRS checks the given height, round, step (HRS) against that of the
// SignState. It returns an error if the arguments constitute a regression,
Expand Down Expand Up @@ -380,7 +376,7 @@ func (signState *SignState) CheckHRS(hrst HRSTKey) (bool, error) {
}
return true, nil
}
return false, new(EmptySignBytesError)
return false, EmptySignBytesError
}
}
}
Expand Down
25 changes: 8 additions & 17 deletions signer/threshold_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -732,23 +733,13 @@ func (pv *ThresholdValidator) Sign(ctx context.Context, chainID string, block Bl
return err
}

hre := new(HeightRegressionError)
rre := new(RoundRegressionError)
sre := new(StepRegressionError)
ese := new(EmptySignBytesError)
ase := new(AlreadySignedVoteError)
dbe := new(DiffBlockIDsError)
cde := new(ConflictingDataError)
ue := new(UnmarshalError)

if !errors.As(err, &hre) &&
!errors.As(err, &rre) &&
!errors.As(err, &sre) &&
!errors.As(err, &ese) &&
!errors.As(err, &ue) &&
!errors.As(err, &ase) &&
!errors.As(err, &dbe) &&
!errors.As(err, &cde) {
// TODO how can we determine error type when it's wrapped in an RPCError?
if !strings.Contains(err.Error(), "regression") &&
!strings.Contains(err.Error(), EmptySignBytesError.Error()) &&
!strings.Contains(err.Error(), "refusing to sign") &&
!strings.Contains(err.Error(), "differing block IDs") &&
!strings.Contains(err.Error(), "conflicting data") &&
!strings.Contains(err.Error(), "cannot be unmarshalled into") {
pv.cosignerHealth.MarkUnhealthy(cosigner)
pv.nonceCache.ClearNonces(cosigner)
}
Expand Down

0 comments on commit 2a5d6f7

Please sign in to comment.