refactor(x/auth): add a slightly more helpful error message on signature verification failure (#20802)

Co-authored-by: @sampocs <sam@stridelabs.co>
This commit is contained in:
Assaf Morami 2024-06-28 11:51:24 +03:00 committed by GitHub
parent ce461a509e
commit 5d54274775
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -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())
}

View File

@ -2,6 +2,7 @@ package signing
import (
"context"
"encoding/hex"
"fmt"
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
@ -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