Skip to content

Commit

Permalink
mempool: add a slightly more helpful error message on signature verif…
Browse files Browse the repository at this point in the history
…ication failure

This is very helpful when debugging signing code on clients

Co-authored-by: @sampocs <[email protected]>
  • Loading branch information
assafmo and sampocs committed Jun 27, 2024
1 parent afddef3 commit ed14878
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/auth/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (svd SigVerificationDecorator) verifySig(ctx sdk.Context, tx sdk.Tx, acc sd
if OnlyLegacyAminoSigners(sig.Data) {
// If all signers are using SIGN_MODE_LEGACY_AMINO, we rely on VerifySignature to check account sequence number,
// and therefore communicate sequence number as a potential cause of error.
errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d), sequence (%d) and chain-id (%s)", accNum, acc.GetSequence(), chainID)
errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d), sequence (%d) and chain-id (%s): (%s)", accNum, acc.GetSequence(), chainID, err.Error())
} else {
errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s): (%s)", accNum, chainID, err.Error())
}
Expand Down
3 changes: 2 additions & 1 deletion x/auth/signing/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package signing

import (
"context"
"encoding/hex"
"fmt"

signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
Expand Down Expand Up @@ -78,7 +79,7 @@ func VerifySignature(
return err
}
if !pubKey.VerifySignature(signBytes, data.Signature) {
return fmt.Errorf("unable to verify single signer signature")
return fmt.Errorf("unable to verify single signer signature '%s' for signBytes '%s'", hex.EncodeToString(data.Signature), hex.EncodeToString(signBytes))
}
return nil

Expand Down

0 comments on commit ed14878

Please sign in to comment.