Revert change of StdSignature PubKey to []byte (#6885)
* Revert change of StdSignature.PubKey to []byte * Fixes
This commit is contained in:
parent
72ebafeeca
commit
ef6dc2f180
|
@ -193,7 +193,7 @@ func TestMultiSigMigration(t *testing.T) {
|
|||
err := multisig.AddSignatureFromPubKey(multisignature, sigs[0], pkSet[0], pkSet)
|
||||
|
||||
// create a StdSignature for msg, and convert it to sigV2
|
||||
sig := authtypes.StdSignature{PubKey: pkSet[1].Bytes(), Signature: msg}
|
||||
sig := authtypes.StdSignature{PubKey: pkSet[1], Signature: msg}
|
||||
sigV2, err := authtypes.StdSignatureToSignatureV2(cdc, sig)
|
||||
require.NoError(t, multisig.AddSignatureV2(multisignature, sigV2, pkSet))
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
|
|||
// use stdsignature to mock the size of a full signature
|
||||
simSig := types.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready
|
||||
Signature: simSecp256k1Sig[:],
|
||||
PubKey: pubkey.Bytes(),
|
||||
PubKey: pubkey,
|
||||
}
|
||||
|
||||
sigBz := legacy.Cdc.MustMarshalBinaryBare(simSig)
|
||||
|
|
|
@ -74,7 +74,7 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() {
|
|||
multisignature1 := multisig.NewMultisig(len(pkSet1))
|
||||
expectedCost1 := expectedGasCostByKeys(pkSet1)
|
||||
for i := 0; i < len(pkSet1); i++ {
|
||||
stdSig := types.StdSignature{PubKey: pkSet1[i].Bytes(), Signature: sigSet1[i]}
|
||||
stdSig := types.StdSignature{PubKey: pkSet1[i], Signature: sigSet1[i]}
|
||||
sigV2, err := types.StdSignatureToSignatureV2(cdc, stdSig)
|
||||
suite.Require().NoError(err)
|
||||
err = multisig.AddSignatureV2(multisignature1, sigV2, pkSet1)
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestVerifySignature(t *testing.T) {
|
|||
signature, err := priv.Sign(signBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
stdSig := types.StdSignature{PubKey: pubKey.Bytes(), Signature: signature}
|
||||
stdSig := types.StdSignature{PubKey: pubKey, Signature: signature}
|
||||
sigV2, err := types.StdSignatureToSignatureV2(cdc, stdSig)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -73,13 +73,13 @@ func TestVerifySignature(t *testing.T) {
|
|||
|
||||
sig1, err := priv.Sign(multiSignBytes)
|
||||
require.NoError(t, err)
|
||||
stdSig1 := types.StdSignature{PubKey: pubKey.Bytes(), Signature: sig1}
|
||||
stdSig1 := types.StdSignature{PubKey: pubKey, Signature: sig1}
|
||||
sig1V2, err := types.StdSignatureToSignatureV2(cdc, stdSig1)
|
||||
require.NoError(t, err)
|
||||
|
||||
sig2, err := priv1.Sign(multiSignBytes)
|
||||
require.NoError(t, err)
|
||||
stdSig2 := types.StdSignature{PubKey: pubKey.Bytes(), Signature: sig2}
|
||||
stdSig2 := types.StdSignature{PubKey: pubKey, Signature: sig2}
|
||||
sig2V2, err := types.StdSignatureToSignatureV2(cdc, stdSig2)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package types_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
|
@ -17,6 +19,7 @@ import (
|
|||
func testCodec() *codec.Codec {
|
||||
cdc := codec.New()
|
||||
sdk.RegisterCodec(cdc)
|
||||
cryptoAmino.RegisterCrypto(cdc)
|
||||
cdc.RegisterConcrete(&testdata.TestMsg{}, "cosmos-sdk/Test", nil)
|
||||
return cdc
|
||||
}
|
||||
|
|
|
@ -71,12 +71,7 @@ func (fee StdFee) GasPrices() sdk.DecCoins {
|
|||
|
||||
// Deprecated
|
||||
func NewStdSignature(pk crypto.PubKey, sig []byte) StdSignature {
|
||||
var pkBz []byte
|
||||
if pk != nil {
|
||||
pkBz = pk.Bytes()
|
||||
}
|
||||
|
||||
return StdSignature{PubKey: pkBz, Signature: sig}
|
||||
return StdSignature{PubKey: pk, Signature: sig}
|
||||
}
|
||||
|
||||
// GetSignature returns the raw signature bytes.
|
||||
|
@ -86,13 +81,8 @@ func (ss StdSignature) GetSignature() []byte {
|
|||
|
||||
// GetPubKey returns the public key of a signature as a crypto.PubKey using the
|
||||
// Amino codec.
|
||||
func (ss StdSignature) GetPubKey() (pk crypto.PubKey) {
|
||||
if len(ss.PubKey) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
amino.MustUnmarshalBinaryBare(ss.PubKey, &pk)
|
||||
return pk
|
||||
func (ss StdSignature) GetPubKey() crypto.PubKey {
|
||||
return ss.PubKey
|
||||
}
|
||||
|
||||
// MarshalYAML returns the YAML representation of the signature.
|
||||
|
@ -319,7 +309,7 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms
|
|||
|
||||
// Deprecated: StdSignature represents a sig
|
||||
type StdSignature struct {
|
||||
PubKey []byte `json:"pub_key" yaml:"pub_key"` // optional
|
||||
crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional
|
||||
Signature []byte `json:"signature" yaml:"signature"`
|
||||
}
|
||||
|
||||
|
@ -397,13 +387,6 @@ func StdSignatureToSignatureV2(cdc *codec.Codec, sig StdSignature) (signing.Sign
|
|||
|
||||
// SignatureV2ToStdSignature converts a SignatureV2 to a StdSignature
|
||||
func SignatureV2ToStdSignature(cdc *codec.Codec, sig signing.SignatureV2) (StdSignature, error) {
|
||||
var pubKeyBz []byte
|
||||
|
||||
pubKey := sig.PubKey
|
||||
if pubKey != nil {
|
||||
pubKeyBz = pubKey.Bytes()
|
||||
}
|
||||
|
||||
var (
|
||||
sigBz []byte
|
||||
err error
|
||||
|
@ -417,7 +400,7 @@ func SignatureV2ToStdSignature(cdc *codec.Codec, sig signing.SignatureV2) (StdSi
|
|||
}
|
||||
|
||||
return StdSignature{
|
||||
PubKey: pubKeyBz,
|
||||
PubKey: sig.PubKey,
|
||||
Signature: sigBz,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums
|
|||
panic(err)
|
||||
}
|
||||
|
||||
sigs[i] = StdSignature{PubKey: priv.PubKey().Bytes(), Signature: sig}
|
||||
sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig}
|
||||
}
|
||||
|
||||
tx := NewStdTx(msgs, fee, sigs, "")
|
||||
|
@ -184,11 +184,11 @@ func TestStdSignatureMarshalYAML(t *testing.T) {
|
|||
"|\n pubkey: \"\"\n signature: \"\"\n",
|
||||
},
|
||||
{
|
||||
StdSignature{PubKey: pubKey.Bytes(), Signature: []byte("dummySig")},
|
||||
StdSignature{PubKey: pubKey, Signature: []byte("dummySig")},
|
||||
fmt.Sprintf("|\n pubkey: %s\n signature: 64756D6D79536967\n", sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, pubKey)),
|
||||
},
|
||||
{
|
||||
StdSignature{PubKey: pubKey.Bytes(), Signature: nil},
|
||||
StdSignature{PubKey: pubKey, Signature: nil},
|
||||
fmt.Sprintf("|\n pubkey: %s\n signature: \"\"\n", sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, pubKey)),
|
||||
},
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func TestSignatureV2Conversions(t *testing.T) {
|
|||
sdk.RegisterCodec(cdc)
|
||||
RegisterCodec(cdc)
|
||||
dummy := []byte("dummySig")
|
||||
sig := StdSignature{PubKey: pubKey.Bytes(), Signature: dummy}
|
||||
sig := StdSignature{PubKey: pubKey, Signature: dummy}
|
||||
|
||||
sigV2, err := StdSignatureToSignatureV2(cdc, sig)
|
||||
require.NoError(t, err)
|
||||
|
@ -247,7 +247,7 @@ func TestSignatureV2Conversions(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
sigV2, err = StdSignatureToSignatureV2(cdc, StdSignature{
|
||||
PubKey: multiPK.Bytes(),
|
||||
PubKey: multiPK,
|
||||
Signature: msig,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
@ -264,7 +264,7 @@ func TestGetSignaturesV2(t *testing.T) {
|
|||
RegisterCodec(cdc)
|
||||
|
||||
fee := NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)})
|
||||
sig := StdSignature{PubKey: pubKey.Bytes(), Signature: dummy}
|
||||
sig := StdSignature{PubKey: pubKey, Signature: dummy}
|
||||
stdTx := NewStdTx([]sdk.Msg{testdata.NewTestMsg()}, fee, []StdSignature{sig}, "testsigs")
|
||||
|
||||
sigs, err := stdTx.GetSignaturesV2()
|
||||
|
|
|
@ -300,7 +300,7 @@ func MakeSignature(kr keyring.Keyring, name string, msg StdSignMsg) (sig StdSign
|
|||
}
|
||||
|
||||
return StdSignature{
|
||||
PubKey: pubkey.Bytes(),
|
||||
PubKey: pubkey,
|
||||
Signature: sigBytes,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue