Skip to content

Commit

Permalink
revert: Remove SIGN_MODE_AMINO_AUX (cosmos#10322)
Browse files Browse the repository at this point in the history
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

Revert cosmos#10268 

As part of the TX working group, we decided not to introduce a new sign mode for tipper signing. The tipper will use amino-json to sign via ledger (see cosmos#10346).

Also, add `signing.SignerData#Address` (will be used in subsequent PR cosmos#10346)

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
amaury1093 authored Oct 18, 2021
1 parent a95d659 commit 99e2e0f
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 306 deletions.
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(),
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

0 comments on commit 99e2e0f

Please sign in to comment.