Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: Remove SIGN_MODE_AMINO_AUX #10322

Merged
merged 21 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig boo
AccountNumber: txf.accountNumber,
Sequence: txf.sequence,
SignerIndex: signerIndex,
Address: sdk.AccAddress(pubKey.Address()).String(),
}

// For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on
Expand Down
3 changes: 1 addition & 2 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ GrantAuthorization defines the GenesisState/GrantAuthorization type.
<a name="cosmos.authz.v1beta1.QueryGranterGrantsRequest"></a>

### QueryGranterGrantsRequest
QueryGranterGrantsRequest is the request type for the Query/Grants RPC method.
QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method.


| Field | Type | Label | Description |
Expand Down Expand Up @@ -9400,7 +9400,6 @@ SignMode represents a signing mode with its own security guarantees.
| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx. |
| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT. It is currently not supported. |
| SIGN_MODE_DIRECT_AUX | 3 | SIGN_MODE_DIRECT_AUX specifies a signing mode which uses SignDocDirectAux. As opposed to SIGN_MODE_DIRECT, this sign mode does not require signers signing over other signers' `signer_info`. It also allows for adding Tips in transactions. |
| SIGN_MODE_AMINO_AUX | 4 | SIGN_MODE_AMINO_AUX specifies a signing mode which uses SignDocAminoAux. |
| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future. |


Expand Down
4 changes: 0 additions & 4 deletions proto/cosmos/tx/signing/v1beta1/signing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ enum SignMode {
// for adding Tips in transactions.
SIGN_MODE_DIRECT_AUX = 3;

// SIGN_MODE_AMINO_AUX specifies a signing mode which uses
// SignDocAminoAux.
SIGN_MODE_AMINO_AUX = 4;

// SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// Amino JSON and will be removed in the future.
SIGN_MODE_LEGACY_AMINO_JSON = 127;
Expand Down
2 changes: 2 additions & 0 deletions server/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,11 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe

// set the signer data
signerData := authsigning.SignerData{
Address: signer.String(),
ChainID: metadata.ChainID,
AccountNumber: metadata.SignersData[i].AccountNumber,
Sequence: metadata.SignersData[i].Sequence,
SignerIndex: i,
}

// get signature bytes
Expand Down
2 changes: 2 additions & 0 deletions simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch
// 2nd round: once all signer infos are set, every signer can sign.
for i, p := range priv {
signerData := authsign.SignerData{
Address: sdk.AccAddress(p.PubKey().Address()).String(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was removed before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signerData.Address field was actually never present before, and newly added in this PR

ChainID: chainID,
AccountNumber: accNums[i],
Sequence: accSeqs[i],
SignerIndex: i,
}
signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
if err != nil {
Expand Down
78 changes: 36 additions & 42 deletions types/tx/signing/signing.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
return fmt.Errorf("set the chain id with either the --chain-id flag or config file")
}

signingData := signing.SignerData{
ChainID: txFactory.ChainID(),
AccountNumber: txFactory.AccountNumber(),
Sequence: txFactory.Sequence(),
}
for j, sig := range sigs {
signingData := signing.SignerData{
Address: sdk.AccAddress(sig.PubKey.Address()).String(),
ChainID: txFactory.ChainID(),
AccountNumber: txFactory.AccountNumber(),
Sequence: txFactory.Sequence(),
SignerIndex: j,
}

for _, sig := range sigs {
err = signing.VerifySignature(sig.PubKey, signingData, sig.Data, txCfg.SignModeHandler(), txBuilder.GetTx())
if err != nil {
addr, _ := sdk.AccAddressFromHex(sig.PubKey.Address().String())
Expand Down Expand Up @@ -322,9 +324,11 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error {
multisigPub := pubKey.(*kmultisig.LegacyAminoPubKey)
multisigSig := multisig.NewMultisig(len(multisigPub.PubKeys))
signingData := signing.SignerData{
Address: sdk.AccAddress(pubKey.Address()).String(),
ChainID: txFactory.ChainID(),
AccountNumber: txFactory.AccountNumber(),
Sequence: txFactory.Sequence(),
SignerIndex: i,
}

for _, sig := range signatureBatch {
Expand Down
2 changes: 2 additions & 0 deletions x/auth/client/cli/validate_sigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ func printAndValidateSigs(
}

signingData := authsigning.SignerData{
Address: sigAddr.String(),
ChainID: chainID,
AccountNumber: accNum,
Sequence: accSeq,
SignerIndex: i,
}
err = authsigning.VerifySignature(pubKey, signingData, sig.Data, signModeHandler, sigTx)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/auth/middleware/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins,
// 2nd round: once all signer infos are set, every signer can sign.
for i, p := range priv {
signerData := authsign.SignerData{
Address: sdk.AccAddress(p.PubKey().Address()).String(),
ChainID: chainID,
AccountNumber: accNums[i],
Sequence: accSeqs[i],
SignerIndex: i,
}
signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions x/auth/middleware/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,13 @@ func (svm sigVerificationTxHandler) sigVerify(ctx context.Context, tx sdk.Tx, is
if !genesis {
accNum = acc.GetAccountNumber()
}

signerData := authsigning.SignerData{
Address: signerAddrs[i].String(),
ChainID: chainID,
AccountNumber: accNum,
Sequence: acc.GetSequence(),
SignerIndex: i,
}

if !simulate {
Expand Down
2 changes: 2 additions & 0 deletions x/auth/middleware/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ func (s *MWTestSuite) createTestTx(txBuilder client.TxBuilder, privs []cryptotyp
sigsV2 = []signing.SignatureV2{}
for i, priv := range privs {
signerData := xauthsigning.SignerData{
Address: sdk.AccAddress(priv.PubKey().Address()).String(),
ChainID: chainID,
AccountNumber: accNums[i],
Sequence: accSeqs[i],
SignerIndex: i,
}
sigV2, err := tx.SignWithPrivKey(
s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData,
Expand Down
2 changes: 2 additions & 0 deletions x/auth/migrations/legacytx/amino_signing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {

handler := stdTxSignModeHandler{}
signingData := signing.SignerData{
Address: addr1.String(),
ChainID: chainId,
AccountNumber: accNum,
Sequence: seqNum,
SignerIndex: 0,
}
signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.NoError(t, err)
Expand Down
47 changes: 0 additions & 47 deletions x/auth/migrations/legacytx/stdsign_aux.go

This file was deleted.

2 changes: 2 additions & 0 deletions x/auth/signing/handler_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ func TestHandlerMap_GetSignBytes(t *testing.T) {
aminoJSONHandler := legacytx.NewStdTxSignModeHandler()

signingData := signing.SignerData{
Address: addr1.String(),
ChainID: chainId,
AccountNumber: accNum,
Sequence: seqNum,
SignerIndex: 0,
}
signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.NoError(t, err)
Expand Down
5 changes: 4 additions & 1 deletion x/auth/signing/sign_mode_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type SignModeHandler interface {
// SignerData is the specific information needed to sign a transaction that generally
// isn't included in the transaction body itself
type SignerData struct {
// The address of the signer.
Address string

// ChainID is the chain that this transaction is targeted
ChainID string

Expand All @@ -35,6 +38,6 @@ type SignerData struct {
// info.
Sequence uint64

// SignerIndex index of signer in the signer_infos array
// SignerIndex index of signer in the signer_infos array.
SignerIndex int
}
2 changes: 2 additions & 0 deletions x/auth/signing/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func TestVerifySignature(t *testing.T) {
msgs := []sdk.Msg{testdata.NewTestMsg(addr)}
fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)})
signerData := signing.SignerData{
Address: addr.String(),
ChainID: chainId,
AccountNumber: acc.GetAccountNumber(),
Sequence: acc.GetSequence(),
SignerIndex: 0,
}
signBytes := legacytx.StdSignBytes(signerData.ChainID, signerData.AccountNumber, signerData.Sequence, 10, fee, msgs, memo)
signature, err := priv.Sign(signBytes)
Expand Down
4 changes: 4 additions & 0 deletions x/auth/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,23 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() {

// sign transaction
signerData := signing.SignerData{
Address: addr.String(),
ChainID: "test",
AccountNumber: 1,
Sequence: seq1,
SignerIndex: 0,
}
signBytes, err := signModeHandler.GetSignBytes(signModeHandler.DefaultMode(), signerData, sigTx)
s.Require().NoError(err)
sigBz, err := privKey.Sign(signBytes)
s.Require().NoError(err)

signerData = signing.SignerData{
Address: msigAddr.String(),
ChainID: "test",
AccountNumber: 3,
Sequence: mseq,
SignerIndex: 0,
}
mSignBytes, err := signModeHandler.GetSignBytes(signModeHandler.DefaultMode(), signerData, sigTx)
s.Require().NoError(err)
Expand Down
Loading