From def66ae378a63cf6ceafd91465672db20457f4e3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 30 Sep 2021 11:47:34 +0530 Subject: [PATCH 1/7] WIP: add `SIGN_MODE_AMINO_AUX` --- docs/core/proto-docs.md | 55 +- proto/cosmos/tx/signing/v1beta1/signing.proto | 4 + proto/cosmos/tx/v1beta1/tx.proto | 32 + types/tx/signing/signing.pb.go | 79 +-- types/tx/tx.pb.go | 583 ++++++++++++++++-- x/auth/tx/amino_aux.go | 53 ++ 6 files changed, 689 insertions(+), 117 deletions(-) create mode 100644 x/auth/tx/amino_aux.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index dc097938e00..5fa4d528416 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -667,6 +667,7 @@ - [SignDocDirectAux](#cosmos.tx.v1beta1.SignDocDirectAux) - [SignDocJSON](#cosmos.tx.v1beta1.SignDocJSON) - [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) + - [StdSignDocAux](#cosmos.tx.v1beta1.StdSignDocAux) - [Tip](#cosmos.tx.v1beta1.Tip) - [Tx](#cosmos.tx.v1beta1.Tx) - [TxBody](#cosmos.tx.v1beta1.TxBody) @@ -2469,7 +2470,7 @@ ReflectionService defines a service for interface reflection. ### AppDescriptor -AppDescriptor describes a Cosmos SDK based application +AppDescriptor describes a cosmos-sdk based application | Field | Type | Label | Description | @@ -2750,7 +2751,7 @@ InterfaceImplementerDescriptor describes an interface implementer ### MsgDescriptor -MsgDescriptor describes a Cosmos SDK message that can be delivered with a transaction +MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction | Field | Type | Label | Description | @@ -2783,7 +2784,7 @@ because it would be redundant with the grpc reflection service ### QueryServiceDescriptor -QueryServiceDescriptor describes a Cosmos SDK queryable service +QueryServiceDescriptor describes a cosmos-sdk queryable service | Field | Type | Label | Description | @@ -2800,12 +2801,12 @@ QueryServiceDescriptor describes a Cosmos SDK queryable service ### QueryServicesDescriptor -QueryServicesDescriptor contains the list of Cosmos SDK queriable services +QueryServicesDescriptor contains the list of cosmos-sdk queriable services | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `query_services` | [QueryServiceDescriptor](#cosmos.base.reflection.v2alpha1.QueryServiceDescriptor) | repeated | query_services is a list of Cosmos SDK QueryServiceDescriptor | +| `query_services` | [QueryServiceDescriptor](#cosmos.base.reflection.v2alpha1.QueryServiceDescriptor) | repeated | query_services is a list of cosmos-sdk QueryServiceDescriptor | @@ -2861,7 +2862,7 @@ ReflectionService defines a service for application reflection. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `GetAuthnDescriptor` | [GetAuthnDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest) | [GetAuthnDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse) | GetAuthnDescriptor returns information on how to authenticate transactions in the application NOTE: this RPC is still experimental and might be subject to breaking changes or removal in future releases of the Cosmos SDK. | GET|/cosmos/base/reflection/v1beta1/app_descriptor/authn| +| `GetAuthnDescriptor` | [GetAuthnDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest) | [GetAuthnDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse) | GetAuthnDescriptor returns information on how to authenticate transactions in the application NOTE: this RPC is still experimental and might be subject to breaking changes or removal in future releases of the cosmos-sdk. | GET|/cosmos/base/reflection/v1beta1/app_descriptor/authn| | `GetChainDescriptor` | [GetChainDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest) | [GetChainDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse) | GetChainDescriptor returns the description of the chain | GET|/cosmos/base/reflection/v1beta1/app_descriptor/chain| | `GetCodecDescriptor` | [GetCodecDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest) | [GetCodecDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse) | GetCodecDescriptor returns the descriptor of the codec of the application | GET|/cosmos/base/reflection/v1beta1/app_descriptor/codec| | `GetConfigurationDescriptor` | [GetConfigurationDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest) | [GetConfigurationDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse) | GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application | GET|/cosmos/base/reflection/v1beta1/app_descriptor/configuration| @@ -2882,7 +2883,7 @@ ReflectionService defines a service for application reflection. ### Metadata -Metadata contains Cosmos SDK-specific snapshot metadata. +Metadata contains SDK-specific snapshot metadata. | Field | Type | Label | Description | @@ -3559,7 +3560,7 @@ Msg defines the bank Msg service. ### PrivKey Deprecated: PrivKey defines a ed25519 private key. -NOTE: ed25519 keys must not be used in Cosmos SDK apps except in a tendermint validator context. +NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. | Field | Type | Label | Description | @@ -3574,8 +3575,8 @@ NOTE: ed25519 keys must not be used in Cosmos SDK apps except in a tendermint va ### PubKey -PubKey is an ed25519 public key for handling Tendermint keys in the Cosmos SDK. -It's needed for Any serialization and Cosmos SDK compatibility. +PubKey is an ed25519 public key for handling Tendermint keys in SDK. +It's needed for Any serialization and SDK compatibility. It must not be used in a non Tendermint key context because it doesn't implement ADR-28. Nevertheless, you will like to use ed25519 in app user level then you must create a new proto message and follow ADR-28 for Address construction. @@ -9089,7 +9090,7 @@ Query defines the gRPC querier service. ### MsgBeginRedelegate -MsgBeginRedelegate defines a Cosmos SDK message for performing a redelegation +MsgBeginRedelegate defines a SDK message for performing a redelegation of coins from a delegator and source validator to a destination validator. @@ -9123,7 +9124,7 @@ MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. ### MsgCreateValidator -MsgCreateValidator defines a Cosmos SDK message for creating a new validator. +MsgCreateValidator defines a SDK message for creating a new validator. | Field | Type | Label | Description | @@ -9154,7 +9155,7 @@ MsgCreateValidatorResponse defines the Msg/CreateValidator response type. ### MsgDelegate -MsgDelegate defines a Cosmos SDK message for performing a delegation of coins +MsgDelegate defines a SDK message for performing a delegation of coins from a delegator to a validator. @@ -9182,7 +9183,7 @@ MsgDelegateResponse defines the Msg/Delegate response type. ### MsgEditValidator -MsgEditValidator defines a Cosmos SDK message for editing an existing validator. +MsgEditValidator defines a SDK message for editing an existing validator. | Field | Type | Label | Description | @@ -9210,7 +9211,7 @@ MsgEditValidatorResponse defines the Msg/EditValidator response type. ### MsgUndelegate -MsgUndelegate defines a Cosmos SDK message for performing an undelegation from a +MsgUndelegate defines a SDK message for performing an undelegation from a delegate and a validator. @@ -9367,6 +9368,7 @@ SignMode represents a signing mode with its own security guarantees. | 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_JSON | 3 | SIGN_MODE_DIRECT_JSON specifies a signing mode which uses SignDocJSON. It is verified using a canonical JSON representation of the bytes used in SIGN_MODE_DIRECT. It is currently not supported. | | SIGN_MODE_DIRECT_AUX | 4 | 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 | 5 | 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. | @@ -9551,6 +9553,27 @@ signer. + + +### StdSignDocAux + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `account_number` | [uint64](#uint64) | | account_number is the account number of the account in state. | +| `sequence` | [uint64](#uint64) | | sequence is the sequence number of the signing account. | +| `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain | +| `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | +| `memo` | [string](#string) | | memo is any arbitrary note/comment to be added to the transaction. WARNING: in clients, any publicly exposed text should not be called memo, but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). | +| `msgs` | [bytes](#bytes) | repeated | msgs | +| `tip` | [bytes](#bytes) | repeated | Tip is the optional tip used for meta-transactions. | + + + + + + ### Tip @@ -9873,7 +9896,7 @@ Plan specifies information about a planned upgrade and when it should occur. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `name` | [string](#string) | | Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height is reached and the software will exit. | -| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | **Deprecated.** Deprecated: Time based upgrades have been deprecated. Time based upgrade logic has been removed from the Cosmos SDK. If this field is not empty, an error will be thrown. | +| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | **Deprecated.** Deprecated: Time based upgrades have been deprecated. Time based upgrade logic has been removed from the SDK. If this field is not empty, an error will be thrown. | | `height` | [int64](#int64) | | The height at which the upgrade must be performed. Only used if Time is not set. | | `info` | [string](#string) | | Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to | | `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | **Deprecated.** Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been moved to the IBC module in the sub module 02-client. If this field is not empty, an error will be thrown. | diff --git a/proto/cosmos/tx/signing/v1beta1/signing.proto b/proto/cosmos/tx/signing/v1beta1/signing.proto index 6a49860c2d5..fd494dfffeb 100644 --- a/proto/cosmos/tx/signing/v1beta1/signing.proto +++ b/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -32,6 +32,10 @@ enum SignMode { // for adding Tips in transactions. SIGN_MODE_DIRECT_AUX = 4; + // SIGN_MODE_AMINO_AUX specifies a signing mode which uses + // SignDocAminoAux. + SIGN_MODE_AMINO_AUX = 5; + // 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; diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index dd281a8e526..16e5d72f8b6 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -252,3 +252,35 @@ message Tip { // tipper is the address of the account paying for the tip string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } + +message StdSignDocAux { + // account_number is the account number of the account in state. + uint64 account_number = 1; + + // sequence is the sequence number of the signing account. + uint64 sequence = 2; + + // timeout is the block height after which this transaction will not + // be processed by the chain + uint64 timeout_height = 3; + + // chain_id is the unique identifier of the chain this transaction targets. + // It prevents signed transactions from being used on another chain by an + // attacker + string chain_id = 4; + + // memo is any arbitrary note/comment to be added to the transaction. + // WARNING: in clients, any publicly exposed text should not be called memo, + // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). + string memo = 5; + + // msgs + repeated bytes msgs = 6 [ + (gogoproto.casttype) = "encoding/json.RawMessage" + ]; + + // Tip is the optional tip used for meta-transactions. + repeated bytes tip = 7 [ + (gogoproto.casttype) = "encoding/json.RawMessage" + ]; +} diff --git a/types/tx/signing/signing.pb.go b/types/tx/signing/signing.pb.go index d59381440f0..7ef0489bf02 100644 --- a/types/tx/signing/signing.pb.go +++ b/types/tx/signing/signing.pb.go @@ -47,6 +47,9 @@ const ( // require signers signing over other signers' `signer_info`. It also allows // for adding Tips in transactions. SignMode_SIGN_MODE_DIRECT_AUX SignMode = 4 + // SIGN_MODE_AMINO_AUX specifies a signing mode which uses + // SignDocAminoAux. + SignMode_SIGN_MODE_AMINO_AUX SignMode = 5 // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses // Amino JSON and will be removed in the future. SignMode_SIGN_MODE_LEGACY_AMINO_JSON SignMode = 127 @@ -58,6 +61,7 @@ var SignMode_name = map[int32]string{ 2: "SIGN_MODE_TEXTUAL", 3: "SIGN_MODE_DIRECT_JSON", 4: "SIGN_MODE_DIRECT_AUX", + 5: "SIGN_MODE_AMINO_AUX", 127: "SIGN_MODE_LEGACY_AMINO_JSON", } @@ -67,6 +71,7 @@ var SignMode_value = map[string]int32{ "SIGN_MODE_TEXTUAL": 2, "SIGN_MODE_DIRECT_JSON": 3, "SIGN_MODE_DIRECT_AUX": 4, + "SIGN_MODE_AMINO_AUX": 5, "SIGN_MODE_LEGACY_AMINO_JSON": 127, } @@ -404,43 +409,43 @@ func init() { } var fileDescriptor_9a54958ff3d0b1b9 = []byte{ - // 562 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xed, 0xc6, 0xad, 0xda, 0x29, 0x42, 0x66, 0x49, 0xa5, 0xd4, 0x20, 0x53, 0x95, 0x03, - 0x15, 0x52, 0xd7, 0x6a, 0x7b, 0x40, 0x70, 0x73, 0x13, 0x93, 0x86, 0x36, 0x09, 0xd8, 0x89, 0x54, - 0xb8, 0x58, 0xb6, 0xb3, 0x35, 0x56, 0x63, 0xaf, 0xf1, 0xae, 0x51, 0x7d, 0xe2, 0x15, 0x78, 0x0c, - 0x78, 0x0e, 0x2e, 0x1c, 0x7b, 0xe4, 0x88, 0x92, 0x67, 0xe0, 0x8e, 0x62, 0xc7, 0x49, 0x2a, 0x8a, - 0x10, 0x39, 0x59, 0x3b, 0xf3, 0xcf, 0x37, 0xff, 0x6a, 0x66, 0x0d, 0x4f, 0x3c, 0xca, 0x42, 0xca, - 0x34, 0x7e, 0xa5, 0xb1, 0xc0, 0x8f, 0x82, 0xc8, 0xd7, 0x3e, 0x1e, 0xb8, 0x84, 0x3b, 0x07, 0xe5, - 0x19, 0xc7, 0x09, 0xe5, 0x14, 0x6d, 0x17, 0x42, 0xcc, 0xaf, 0x70, 0x99, 0x98, 0x0a, 0x95, 0xfd, - 0x29, 0xc3, 0x4b, 0xb2, 0x98, 0x53, 0x2d, 0x4c, 0x87, 0x3c, 0x60, 0xc1, 0x1c, 0x54, 0x06, 0x0a, - 0x92, 0xb2, 0xed, 0x53, 0xea, 0x0f, 0x89, 0x96, 0x9f, 0xdc, 0xf4, 0x42, 0x73, 0xa2, 0xac, 0x48, - 0xed, 0x5e, 0x40, 0xd5, 0x0a, 0xfc, 0xc8, 0xe1, 0x69, 0x42, 0x1a, 0x84, 0x79, 0x49, 0x10, 0x73, - 0x9a, 0x30, 0xd4, 0x01, 0x60, 0x65, 0x9c, 0xd5, 0xc4, 0x9d, 0xca, 0xde, 0xe6, 0x21, 0xc6, 0x7f, - 0x75, 0x84, 0x6f, 0x81, 0x98, 0x0b, 0x84, 0xdd, 0x5f, 0x12, 0xdc, 0xbf, 0x45, 0x83, 0x8e, 0x00, - 0xe2, 0xd4, 0x1d, 0x06, 0x9e, 0x7d, 0x49, 0xb2, 0x9a, 0xb8, 0x23, 0xee, 0x6d, 0x1e, 0x56, 0x71, - 0xe1, 0x17, 0x97, 0x7e, 0xb1, 0x1e, 0x65, 0xe6, 0x46, 0xa1, 0x3b, 0x25, 0x19, 0x6a, 0x82, 0x34, - 0x70, 0xb8, 0x53, 0x5b, 0xc9, 0xe5, 0x47, 0xff, 0x67, 0x0b, 0x37, 0x1c, 0xee, 0x98, 0x39, 0x00, - 0x29, 0xb0, 0xce, 0xc8, 0x87, 0x94, 0x44, 0x1e, 0xa9, 0x55, 0x76, 0xc4, 0x3d, 0xc9, 0x9c, 0x9d, - 0x95, 0x6f, 0x15, 0x90, 0x26, 0x52, 0xd4, 0x83, 0x35, 0x16, 0x44, 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 0x59, 0xdd, 0x8e, 0x5c, 0x41, 0x35, 0xa8, 0xfe, 0x91, 0xd2, 0xfb, 0xe7, 0xb2, 0x84, 0x1e, 0xc1, - 0x83, 0x79, 0xe6, 0xcc, 0x68, 0xea, 0xf5, 0xb7, 0xb6, 0xde, 0x6e, 0x75, 0xba, 0x45, 0xe9, 0xa7, - 0xe3, 0xe6, 0xf7, 0x91, 0x2a, 0x5e, 0x8f, 0x54, 0xf1, 0xe7, 0x48, 0x15, 0x3f, 0x8f, 0x55, 0xe1, - 0x7a, 0xac, 0x0a, 0x3f, 0xc6, 0xaa, 0xf0, 0x6e, 0xdf, 0x0f, 0xf8, 0xfb, 0xd4, 0xc5, 0x1e, 0x0d, - 0xb5, 0xf2, 0xe5, 0xe7, 0x9f, 0x7d, 0x36, 0xb8, 0xd4, 0x78, 0x16, 0x93, 0xc5, 0xdf, 0x89, 0xbb, - 0x96, 0xbf, 0x9b, 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x94, 0x26, 0xd7, 0x6a, 0x04, - 0x00, 0x00, + // 571 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x41, 0x4f, 0xd4, 0x40, + 0x14, 0xc7, 0xb7, 0x6c, 0x97, 0xc0, 0xc3, 0x98, 0x3a, 0x2c, 0x71, 0xa9, 0xa6, 0x12, 0x3c, 0x48, + 0x4c, 0x98, 0x06, 0x38, 0x18, 0xbd, 0x95, 0xdd, 0xba, 0xac, 0xb0, 0x8b, 0xb6, 0x4b, 0x82, 0x5e, + 0x36, 0x6d, 0x77, 0xa8, 0x0d, 0xdb, 0x4e, 0xed, 0x4c, 0x0d, 0x3d, 0xf9, 0x15, 0xfc, 0x1a, 0x7e, + 0x0c, 0xe3, 0xc5, 0x23, 0x47, 0x8f, 0x06, 0x3e, 0x83, 0x77, 0xc3, 0xb4, 0xdd, 0x42, 0xc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1e, 0x2a, 0x12, 0x5a, 0x81, + 0x7b, 0x55, 0x75, 0x68, 0x1e, 0x0f, 0x8f, 0x8c, 0x03, 0x65, 0xee, 0x26, 0x27, 0x37, 0x8f, 0x5e, + 0xd9, 0x87, 0x03, 0xa5, 0x8e, 0x5a, 0xd0, 0xfc, 0x43, 0x32, 0x8e, 0x8e, 0x15, 0x19, 0xdd, 0x87, + 0xe5, 0x4a, 0x31, 0xfa, 0xbd, 0xc1, 0xa1, 0x10, 0x1a, 0xe8, 0x11, 0x3c, 0xa8, 0x84, 0x03, 0xb3, + 0x6b, 0xb4, 0xdf, 0x16, 0xba, 0x60, 0x7e, 0xda, 0xed, 0x7e, 0xbf, 0xd0, 0xa4, 0xf3, 0x0b, 0x4d, + 0xfa, 0x79, 0xa1, 0x49, 0x9f, 0x2f, 0xb5, 0xda, 0xf9, 0xa5, 0x56, 0xfb, 0x71, 0xa9, 0xd5, 0xde, + 0x6d, 0xfa, 0x01, 0x7f, 0x9f, 0xba, 0xd8, 0xa3, 0xa1, 0x5e, 0x3e, 0x09, 0xe2, 0x67, 0x93, 0x8d, + 0x4f, 0x75, 0x9e, 0xc5, 0xe4, 0xfa, 0x3b, 0xe3, 0xce, 0x8b, 0x3f, 0xd4, 0xce, 0xef, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x67, 0xe0, 0x5a, 0xe2, 0x83, 0x04, 0x00, 0x00, } func (m *SignatureDescriptors) Marshal() (dAtA []byte, err error) { diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 881a0f938e9..0df2e02ace2 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -4,6 +4,7 @@ package tx import ( + encoding_json "encoding/json" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -1002,6 +1003,110 @@ func (m *Tip) GetTipper() string { return "" } +type StdSignDocAux struct { + // account_number is the account number of the account in state. + AccountNumber uint64 `protobuf:"varint,1,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` + // sequence is the sequence number of the signing account. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // timeout is the block height after which this transaction will not + // be processed by the chain + TimeoutHeight uint64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` + // chain_id is the unique identifier of the chain this transaction targets. + // It prevents signed transactions from being used on another chain by an + // attacker + ChainId string `protobuf:"bytes,4,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // memo is any arbitrary note/comment to be added to the transaction. + // WARNING: in clients, any publicly exposed text should not be called memo, + // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). + Memo string `protobuf:"bytes,5,opt,name=memo,proto3" json:"memo,omitempty"` + // msgs + Msgs []encoding_json.RawMessage `protobuf:"bytes,6,rep,name=msgs,proto3,casttype=encoding/json.RawMessage" json:"msgs,omitempty"` + // Tip is the optional tip used for meta-transactions. + Tip []encoding_json.RawMessage `protobuf:"bytes,7,rep,name=tip,proto3,casttype=encoding/json.RawMessage" json:"tip,omitempty"` +} + +func (m *StdSignDocAux) Reset() { *m = StdSignDocAux{} } +func (m *StdSignDocAux) String() string { return proto.CompactTextString(m) } +func (*StdSignDocAux) ProtoMessage() {} +func (*StdSignDocAux) Descriptor() ([]byte, []int) { + return fileDescriptor_96d1575ffde80842, []int{11} +} +func (m *StdSignDocAux) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StdSignDocAux) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StdSignDocAux.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StdSignDocAux) XXX_Merge(src proto.Message) { + xxx_messageInfo_StdSignDocAux.Merge(m, src) +} +func (m *StdSignDocAux) XXX_Size() int { + return m.Size() +} +func (m *StdSignDocAux) XXX_DiscardUnknown() { + xxx_messageInfo_StdSignDocAux.DiscardUnknown(m) +} + +var xxx_messageInfo_StdSignDocAux proto.InternalMessageInfo + +func (m *StdSignDocAux) GetAccountNumber() uint64 { + if m != nil { + return m.AccountNumber + } + return 0 +} + +func (m *StdSignDocAux) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *StdSignDocAux) GetTimeoutHeight() uint64 { + if m != nil { + return m.TimeoutHeight + } + return 0 +} + +func (m *StdSignDocAux) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *StdSignDocAux) GetMemo() string { + if m != nil { + return m.Memo + } + return "" +} + +func (m *StdSignDocAux) GetMsgs() []encoding_json.RawMessage { + if m != nil { + return m.Msgs + } + return nil +} + +func (m *StdSignDocAux) GetTip() []encoding_json.RawMessage { + if m != nil { + return m.Tip + } + return nil +} + func init() { proto.RegisterType((*Tx)(nil), "cosmos.tx.v1beta1.Tx") proto.RegisterType((*TxRaw)(nil), "cosmos.tx.v1beta1.TxRaw") @@ -1016,75 +1121,82 @@ func init() { proto.RegisterType((*ModeInfo_Multi)(nil), "cosmos.tx.v1beta1.ModeInfo.Multi") proto.RegisterType((*Fee)(nil), "cosmos.tx.v1beta1.Fee") proto.RegisterType((*Tip)(nil), "cosmos.tx.v1beta1.Tip") + proto.RegisterType((*StdSignDocAux)(nil), "cosmos.tx.v1beta1.StdSignDocAux") } func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1004 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0x66, 0x6d, 0xc7, 0x7e, 0x49, 0xda, 0x66, 0x14, 0x21, 0xc7, 0x51, 0xdd, 0x60, 0x54, - 0xf0, 0x25,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f, 0xa4, 0x16, 0x04, 0x33, 0xb8, 0xc1, 0xc7, 0x4f, 0x4f, 0x3b, 0xd6, 0xb3, - 0xd3, 0x8e, 0xf5, 0xfc, 0xb4, 0x63, 0x3d, 0x39, 0xeb, 0x54, 0x9e, 0x9d, 0x75, 0x2a, 0xbf, 0x9c, - 0x75, 0x2a, 0x8f, 0xae, 0x2f, 0x2f, 0x9c, 0xab, 0x66, 0xa3, 0xba, 0xfe, 0xd8, 0x6e, 0xfc, 0x1d, - 0x00, 0x00, 0xff, 0xff, 0x2e, 0xeb, 0x69, 0xc0, 0xc0, 0x09, 0x00, 0x00, + // 1089 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xf6, 0xfa, 0x5f, 0xec, 0xb7, 0x4d, 0xff, 0x8c, 0xa2, 0x9f, 0x5c, 0xf7, 0x57, 0x37, 0x18, + 0x15, 0x7c, 0xc9, 0x6e, 0x92, 0x0a, 0x28, 0x08, 0x09, 0xec, 0x96, 0x2a, 0xa5, 0xa4, 0x95, 0xd6, + 0x39, 0xf5, 0xb2, 0x1a, 0xef, 0x4e, 0xd6, 0xd3, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0x6a, 0x7f, 0x05, + 0x24, 0xa4, 0x0a, 0x09, 0x71, 0xe5, 0xcc, 0x99, 0x0f, 0xd1, 0x63, 0xc5, 0x89, 0x53, 0xa9, 0x92, + 0x13, 0x42, 0xe2, 0x03, 0x70, 0x01, 0xcd, 0xec, 0xec, 0xc6, 0x49, 0x83, 0x1d, 0x89, 0x8a, 0x93, + 0xe7, 0xcf, 0xf3, 0x3e, 0xf3, 0xbc, 0xf3, 0xbe, 0x7e, 0x66, 0xa1, 0xed, 0x73, 0x11, 0x71, 0xe1, + 0xc8, 0xa9, 0xf3, 0xd5, 0xd6, 0x88, 0x48, 0xbc, 0xe5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0xd7, 0x7b, 0x21, 0x95, 0xe3, 0x74, 0x64, 0xfb, 0x3c, 0x72, 0xf2, 0xaf, 0x03, 0xfd, 0xb3, + 0x21, 0x82, 0x27, 0x8e, 0x9c, 0xc5, 0x44, 0xe8, 0x00, 0xe1, 0x1a, 0x6a, 0x74, 0x15, 0x9a, 0x21, + 0x16, 0xde, 0x84, 0x46, 0x54, 0xea, 0x42, 0x54, 0xdd, 0x46, 0x88, 0xc5, 0x17, 0x6a, 0x8e, 0x6c, + 0xa8, 0xc5, 0x78, 0x46, 0x92, 0xcc, 0xc6, 0x06, 0xad, 0x9f, 0x7f, 0xda, 0x58, 0x33, 0x1a, 0xfa, + 0x41, 0x90, 0x10, 0x21, 0x86, 0x32, 0xa1, 0x2c, 0x74, 0x33, 0x18, 0xda, 0x86, 0x95, 0x30, 0xc1, + 0x4c, 0x1a, 0x5f, 0x5b, 0x14, 0x91, 0x03, 0xbb, 0x8f, 0xa1, 0xb2, 0x47, 0x63, 0xb4, 0x75, 0xe6, + 0x64, 0x0b, 0xe9, 0x9b, 0x50, 0x97, 0x34, 0x8e, 0x49, 0x92, 0x99, 0xd4, 0x82, 0xc3, 0x0c, 0xae, + 0xfb, 0x75, 0x19, 0x56, 0x87, 0x32, 0x30, 0xaf, 0x80, 0xf2, 0xff, 0xd7, 0x0d, 0xd9, 0x5a, 0x66, + 0xc8, 0xe5, 0x13, 0x86, 0x7c, 0x46, 0x57, 0x9c, 0x7f, 0x15, 0xaa, 0xc7, 0x5f, 0x85, 0xdc, 0x6b, + 0x6b, 0x73, 0x5e, 0xbb, 0x09, 0xd5, 0x48, 0x84, 0xa2, 0x55, 0x57, 0x1f, 0x12, 0x83, 0xff, 0xff, + 0xf9, 0xf2, 0x7a, 0x8b, 0x30, 0x9f, 0x07, 0xea, 0xb3, 0xec, 0xb1, 0xe0, 0xcc, 0x76, 0xf1, 0xd3, + 0xdd, 0xcc, 0xac, 0x5d, 0x8d, 0x44, 0x76, 0xe6, 0x2e, 0x2b, 0x67, 0x08, 0x50, 0xc0, 0xc1, 0x27, + 0xcf, 0x0f, 0x3a, 0xd6, 0x8b, 0x83, 0x8e, 0xf5, 0xea, 0xa0, 0x63, 0x3d, 0x3b, 0xec, 0x94, 0x5e, + 0x1c, 0x76, 0x4a, 0xbf, 0x1c, 0x76, 0x4a, 0x8f, 0x6e, 0x2c, 0xef, 0x22, 0x47, 0x4e, 0x47, 0x75, + 0xed, 0x3c, 0x37, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x75, 0x57, 0x2f, 0xcd, 0x0a, 0x00, + 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1820,6 +1932,76 @@ func (m *Tip) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StdSignDocAux) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StdSignDocAux) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StdSignDocAux) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Tip) > 0 { + for iNdEx := len(m.Tip) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Tip[iNdEx]) + copy(dAtA[i:], m.Tip[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Tip[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Msgs[iNdEx]) + copy(dAtA[i:], m.Msgs[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Msgs[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Memo) > 0 { + i -= len(m.Memo) + copy(dAtA[i:], m.Memo) + i = encodeVarintTx(dAtA, i, uint64(len(m.Memo))) + i-- + dAtA[i] = 0x2a + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x22 + } + if m.TimeoutHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutHeight)) + i-- + dAtA[i] = 0x18 + } + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if m.AccountNumber != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AccountNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -2149,6 +2331,44 @@ func (m *Tip) Size() (n int) { return n } +func (m *StdSignDocAux) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AccountNumber != 0 { + n += 1 + sovTx(uint64(m.AccountNumber)) + } + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) + } + if m.TimeoutHeight != 0 { + n += 1 + sovTx(uint64(m.TimeoutHeight)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Memo) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Msgs) > 0 { + for _, b := range m.Msgs { + l = len(b) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.Tip) > 0 { + for _, b := range m.Tip { + l = len(b) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4153,6 +4373,241 @@ func (m *Tip) Unmarshal(dAtA []byte) error { } return nil } +func (m *StdSignDocAux) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StdSignDocAux: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StdSignDocAux: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) + } + m.AccountNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) + } + m.TimeoutHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Memo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, make([]byte, postIndex-iNdEx)) + copy(m.Msgs[len(m.Msgs)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tip", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tip = append(m.Tip, make([]byte, postIndex-iNdEx)) + copy(m.Tip[len(m.Tip)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/auth/tx/amino_aux.go b/x/auth/tx/amino_aux.go new file mode 100644 index 00000000000..21d6083b88d --- /dev/null +++ b/x/auth/tx/amino_aux.go @@ -0,0 +1,53 @@ +package tx + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types/tx" + signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + + "github.com/cosmos/cosmos-sdk/x/auth/signing" +) + +var _ signing.SignModeHandler = signModeAminoAuxHandler{} + +// signModeAminoAuxHandler defines the SIGN_MODE_AMINO_AUX SignModeHandler +type signModeAminoAuxHandler struct{} + +// DefaultMode implements SignModeHandler.DefaultMode +func (signModeAminoAuxHandler) DefaultMode() signingtypes.SignMode { + return signingtypes.SignMode_SIGN_MODE_AMINO_AUX +} + +// Modes implements SignModeHandler.Modes +func (signModeAminoAuxHandler) Modes() []signingtypes.SignMode { + return []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_AMINO_AUX} +} + +// GetSignBytes implements SignModeHandler.GetSignBytes +func (signModeAminoAuxHandler) GetSignBytes( + mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx, +) ([]byte, error) { + + if mode != signingtypes.SignMode_SIGN_MODE_AMINO_AUX { + return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_AMINO_AUX, mode) + } + + protoTx, ok := tx.(*wrapper) + if !ok { + return nil, fmt.Errorf("can only handle a protobuf Tx, got %T", tx) + } + + signDocDirectAux := types.StdSignDocAux{ + AccountNumber: data.AccountNumber, + Sequence: data.Sequence, + TimeoutHeight: protoTx.GetTimeoutHeight(), + ChainId: data.ChainID, + Memo: protoTx.tx.Body.Memo, + Msgs: protoTx.GetMsgs(), + Tip: protoTx.tx.AuthInfo.Tip, + } + + return signDocDirectAux.Marshal() +} From 7f9ad401d9787167a836b04fb225f45871a4da26 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 30 Sep 2021 11:52:06 +0530 Subject: [PATCH 2/7] WIp --- x/auth/tx/amino_aux.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/auth/tx/amino_aux.go b/x/auth/tx/amino_aux.go index 21d6083b88d..859ec5bde49 100644 --- a/x/auth/tx/amino_aux.go +++ b/x/auth/tx/amino_aux.go @@ -45,8 +45,9 @@ func (signModeAminoAuxHandler) GetSignBytes( TimeoutHeight: protoTx.GetTimeoutHeight(), ChainId: data.ChainID, Memo: protoTx.tx.Body.Memo, - Msgs: protoTx.GetMsgs(), - Tip: protoTx.tx.AuthInfo.Tip, + // TODO + // Msgs: protoTx.GetMsgs(), + // Tip: protoTx.tx.AuthInfo.Tip, } return signDocDirectAux.Marshal() From 9c308cdc7454cb1d150bd79a386af1dc39b1eb2e Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 30 Sep 2021 17:27:50 +0530 Subject: [PATCH 3/7] add tests --- docs/core/proto-docs.md | 2 +- proto/cosmos/tx/v1beta1/tx.proto | 4 +- types/tx/tx.pb.go | 172 ++++++++++++++++--------------- x/auth/tx/amino_aux.go | 18 +++- x/auth/tx/amino_aux_test.go | 148 ++++++++++++++++++++++++++ x/auth/tx/mode_handler.go | 2 + 6 files changed, 256 insertions(+), 90 deletions(-) create mode 100644 x/auth/tx/amino_aux_test.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 5fa4d528416..ffab5703f4a 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -9567,7 +9567,7 @@ signer. | `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | | `memo` | [string](#string) | | memo is any arbitrary note/comment to be added to the transaction. WARNING: in clients, any publicly exposed text should not be called memo, but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). | | `msgs` | [bytes](#bytes) | repeated | msgs | -| `tip` | [bytes](#bytes) | repeated | Tip is the optional tip used for meta-transactions. | +| `tip` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Tip is the optional tip used for meta-transactions. | diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index 16e5d72f8b6..b9cbfb65abb 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -280,7 +280,5 @@ message StdSignDocAux { ]; // Tip is the optional tip used for meta-transactions. - repeated bytes tip = 7 [ - (gogoproto.casttype) = "encoding/json.RawMessage" - ]; + repeated cosmos.base.v1beta1.Coin tip = 7; } diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 0df2e02ace2..0189b82852c 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -1022,7 +1022,7 @@ type StdSignDocAux struct { // msgs Msgs []encoding_json.RawMessage `protobuf:"bytes,6,rep,name=msgs,proto3,casttype=encoding/json.RawMessage" json:"msgs,omitempty"` // Tip is the optional tip used for meta-transactions. - Tip []encoding_json.RawMessage `protobuf:"bytes,7,rep,name=tip,proto3,casttype=encoding/json.RawMessage" json:"tip,omitempty"` + Tip []*types2.Coin `protobuf:"bytes,7,rep,name=tip,proto3" json:"tip,omitempty"` } func (m *StdSignDocAux) Reset() { *m = StdSignDocAux{} } @@ -1100,7 +1100,7 @@ func (m *StdSignDocAux) GetMsgs() []encoding_json.RawMessage { return nil } -func (m *StdSignDocAux) GetTip() []encoding_json.RawMessage { +func (m *StdSignDocAux) GetTip() []*types2.Coin { if m != nil { return m.Tip } @@ -1127,76 +1127,75 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1089 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xf6, 0xfa, 0x5f, 0xec, 0xb7, 0x4d, 0xff, 0x8c, 0xa2, 0x9f, 0x5c, 0xf7, 0x57, 0x37, 0x18, - 0x15, 0x7c, 0xc9, 0x6e, 0x92, 0x0a, 0x28, 0x08, 0x09, 0xec, 0x96, 0x2a, 0xa5, 0xa4, 0x95, 0xd6, - 0x39, 0xf5, 0xb2, 0x1a, 0xef, 0x4e, 0xd6, 0xd3, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0x6a, 0x7f, 0x05, - 0x24, 0xa4, 0x0a, 0x09, 0x71, 0xe5, 0xcc, 0x99, 0x0f, 0xd1, 0x63, 0xc5, 0x89, 0x53, 0xa9, 0x92, - 0x13, 0x42, 0xe2, 0x03, 0x70, 0x01, 0xcd, 0xec, 0xec, 0xc6, 0x49, 0x83, 0x1d, 0x89, 0x8a, 0x93, - 0xe7, 0xcf, 0xf3, 0x3e, 0xf3, 0xbc, 0xf3, 0xbe, 0x7e, 0x66, 0xa1, 0xed, 0x73, 0x11, 0x71, 0xe1, - 0xc8, 0xa9, 0xf3, 0xd5, 0xd6, 0x88, 0x48, 0xbc, 0xe5, 0xc8, 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7b, 0x21, 0x95, 0xe3, 0x74, 0x64, 0xfb, 0x3c, 0x72, 0xf2, 0xaf, 0x03, 0xfd, 0xb3, - 0x21, 0x82, 0x27, 0x8e, 0x9c, 0xc5, 0x44, 0xe8, 0x00, 0xe1, 0x1a, 0x6a, 0x74, 0x15, 0x9a, 0x21, - 0x16, 0xde, 0x84, 0x46, 0x54, 0xea, 0x42, 0x54, 0xdd, 0x46, 0x88, 0xc5, 0x17, 0x6a, 0x8e, 0x6c, - 0xa8, 0xc5, 0x78, 0x46, 0x92, 0xcc, 0xc6, 0x06, 0xad, 0x9f, 0x7f, 0xda, 0x58, 0x33, 0x1a, 0xfa, - 0x41, 0x90, 0x10, 0x21, 0x86, 0x32, 0xa1, 0x2c, 0x74, 0x33, 0x18, 0xda, 0x86, 0x95, 0x30, 0xc1, - 0x4c, 0x1a, 0x5f, 0x5b, 0x14, 0x91, 0x03, 0xbb, 0x8f, 0xa1, 0xb2, 0x47, 0x63, 0xb4, 0x75, 0xe6, - 0x64, 0x0b, 0xe9, 0x9b, 0x50, 0x97, 0x34, 0x8e, 0x49, 0x92, 0x99, 0xd4, 0x82, 0xc3, 0x0c, 0xae, - 0xfb, 0x75, 0x19, 0x56, 0x87, 0x32, 0x30, 0xaf, 0x80, 0xf2, 0xff, 0xd7, 0x0d, 0xd9, 0x5a, 0x66, - 0xc8, 0xe5, 0x13, 0x86, 0x7c, 0x46, 0x57, 0x9c, 0x7f, 0x15, 0xaa, 0xc7, 0x5f, 0x85, 0xdc, 0x6b, - 0x6b, 0x73, 0x5e, 0xbb, 0x09, 0xd5, 0x48, 0x84, 0xa2, 0x55, 0x57, 0x1f, 0x12, 0x83, 0xff, 0xff, - 0xf9, 0xf2, 0x7a, 0x8b, 0x30, 0x9f, 0x07, 0xea, 0xb3, 0xec, 0xb1, 0xe0, 0xcc, 0x76, 0xf1, 0xd3, - 0xdd, 0xcc, 0xac, 0x5d, 0x8d, 0x44, 0x76, 0xe6, 0x2e, 0x2b, 0x67, 0x08, 0x50, 0xc0, 0xc1, 0x27, - 0xcf, 0x0f, 0x3a, 0xd6, 0x8b, 0x83, 0x8e, 0xf5, 0xea, 0xa0, 0x63, 0x3d, 0x3b, 0xec, 0x94, 0x5e, - 0x1c, 0x76, 0x4a, 0xbf, 0x1c, 0x76, 0x4a, 0x8f, 0x6e, 0x2c, 0xef, 0x22, 0x47, 0x4e, 0x47, 0x75, - 0xed, 0x3c, 0x37, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x75, 0x57, 0x2f, 0xcd, 0x0a, 0x00, - 0x00, + // 1088 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xfa, 0x2b, 0xf6, 0xdb, 0xa6, 0x1f, 0xa3, 0x08, 0xb9, 0x2e, 0x75, 0x83, 0x51, 0xc1, + 0x12, 0xca, 0x6e, 0x9a, 0x0a, 0x28, 0x08, 0x09, 0xec, 0x96, 0x2a, 0xa5, 0xa4, 0x95, 0xd6, 0x39, + 0xf5, 0xb2, 0x1a, 0xef, 0x4e, 0xd6, 0xd3, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0x6a, 0xff, 0x02, 0x4e, + 0x48, 0x15, 0x12, 0xe2, 0xca, 0x99, 0x33, 0x3f, 0xa2, 0xc7, 0x8a, 0x13, 0xa7, 0x52, 0x25, 0x27, + 0x84, 0xc4, 0x0f, 0xe0, 0x02, 0x9a, 0xd9, 0xd9, 0x8d, 0x93, 0x06, 0x3b, 0x12, 0x15, 0x27, 0xcf, + 0xc7, 0xf3, 0xbe, 0xf3, 0xbc, 0x1f, 0x7e, 0xde, 0x85, 0xb6, 0xcf, 0x45, 0xc4, 0x85, 0x23, 0xa7, + 0xce, 0xd7, 0xd7, 0x47, 0x44, 0xe2, 0xeb, 0x8e, 0x9c, 0xda, 0x71, 0xc2, 0x25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 0x07, 0x15, 0x49, 0xe3, 0x56, 0x5d, 0x73, 0x79, + 0xe3, 0xa4, 0x0a, 0xd1, 0xd8, 0x55, 0x90, 0xee, 0xf7, 0x65, 0xa8, 0x67, 0xe5, 0x42, 0x9b, 0xd0, + 0x88, 0x88, 0x10, 0x38, 0xd4, 0x41, 0x56, 0xfe, 0x35, 0x8a, 0x02, 0x85, 0x10, 0x54, 0x23, 0x12, + 0x65, 0x55, 0x6d, 0xba, 0x7a, 0xad, 0xd8, 0x4b, 0x1a, 0x11, 0x9e, 0x4a, 0x6f, 0x4c, 0x68, 0x38, + 0x96, 0x3a, 0xbc, 0xaa, 0xbb, 0x6a, 0x4e, 0xb7, 0xf5, 0x21, 0x1a, 0xc0, 0x45, 0x32, 0x95, 0x84, + 0x09, 0xca, 0x99, 0xc7, 0x63, 0x49, 0x39, 0x13, 0xad, 0xbf, 0x57, 0x16, 0x3c, 0x7b, 0xa1, 0xc0, + 0x3f, 0xc8, 0xe0, 0xe8, 0x21, 0x74, 0x18, 0x67, 0x9e, 0x9f, 0x50, 0x49, 0x7d, 0x3c, 0xf1, 0x4e, + 0x70, 0x78, 0x7e, 0x81, 0xc3, 0xcb, 0x8c, 0xb3, 0x5b, 0xc6, 0xf6, 0xf3, 0x63, 0xbe, 0xbb, 0x3f, + 0x5a, 0xd0, 0xc8, 0x5b, 0x12, 0x7d, 0x06, 0x67, 0x55, 0xab, 0x90, 0x44, 0x37, 0x71, 0x9e, 0x9d, + 0x2b, 0x27, 0xe4, 0x75, 0xa8, 0x61, 0xba, 0x8f, 0xcf, 0x88, 0x62, 0x2d, 0x54, 0x41, 0xf6, 0x08, + 0x31, 0xcd, 0x71, 0x52, 0x41, 0xee, 0x10, 0xe2, 0x2a, 0x48, 0x5e, 0xba, 0xca, 0xf2, 0xd2, 0xfd, + 0x60, 0x01, 0x1c, 0xbe, 0x77, 0xac, 0x0d, 0xad, 0xd3, 0xb5, 0xe1, 0x4d, 0x68, 0x46, 0x3c, 0x20, + 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0x8e, 0x6c, 0x9f, 0x47, 0x4e, 0xfe, 0x75, 0xa0, 0x7f, 0x36, 0x44, + 0xf0, 0xd8, 0x91, 0xb3, 0x98, 0x08, 0x6d, 0x20, 0x5c, 0xe3, 0x1a, 0x5d, 0x86, 0x66, 0x88, 0x85, + 0x37, 0xa1, 0x11, 0x95, 0xba, 0x10, 0x55, 0xb7, 0x11, 0x62, 0xf1, 0xa5, 0xda, 0x23, 0x1b, 0x6a, + 0x31, 0x9e, 0x91, 0x24, 0x93, 0xb1, 0x41, 0xeb, 0x97, 0x9f, 0x37, 0xd6, 0x0c, 0x87, 0x7e, 0x10, + 0x24, 0x44, 0x88, 0xa1, 0x4c, 0x28, 0x0b, 0xdd, 0x0c, 0x86, 0xb6, 0x60, 0x25, 0x4c, 0x30, 0x93, + 0x46, 0xd7, 0x16, 0x59, 0xe4, 0xc0, 0xee, 0x23, 0xa8, 0xec, 0xd2, 0x18, 0x5d, 0x3f, 0x75, 0xb0, + 0x05, 0xf5, 0x4d, 0xa8, 0x4b, 0x1a, 0xc7, 0x24, 0xc9, 0x44, 0x6a, 0xc1, 0x63, 0x06, 0xd7, 0xfd, + 0xa6, 0x0c, 0xab, 0x43, 0x19, 0x98, 0x29, 0xa0, 0xf4, 0xff, 0x55, 0x41, 0xb6, 0x96, 0x09, 0x72, + 0xf9, 0x98, 0x20, 0x9f, 0x52, 0x15, 0xe7, 0xa7, 0x42, 0xf5, 0xe8, 0x54, 0xc8, 0xb5, 0xb6, 0x36, + 0xa7, 0xb5, 0x9b, 0x50, 0x8d, 0x44, 0x28, 0x5a, 0x75, 0xf5, 0x21, 0x31, 0x78, 0xf3, 0xaf, 0x17, + 0x57, 0x5b, 0x84, 0xf9, 0x3c, 0x50, 0x9f, 0x65, 0x8f, 0x04, 0x67, 0xb6, 0x8b, 0x9f, 0xec, 0x64, + 0x62, 0xed, 0x6a, 0x24, 0x7a, 0x2f, 0x53, 0x97, 0x95, 0x65, 0xe9, 0x53, 0xa8, 0xc1, 0xa7, 0xcf, + 0xf6, 0x3b, 0xd6, 0xf3, 0xfd, 0x8e, 0xf5, 0x72, 0xbf, 0x63, 0x3d, 0x3d, 0xe8, 0x94, 0x9e, 0x1f, + 0x74, 0x4a, 0xbf, 0x1e, 0x74, 0x4a, 0x0f, 0xaf, 0x2d, 0x6f, 0x21, 0x47, 0x4e, 0x47, 0x75, 0x2d, + 0x3b, 0x37, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xea, 0xa3, 0xa4, 0x3b, 0xca, 0x0a, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1954,9 +1953,14 @@ func (m *StdSignDocAux) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = l if len(m.Tip) > 0 { for iNdEx := len(m.Tip) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Tip[iNdEx]) - copy(dAtA[i:], m.Tip[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Tip[iNdEx]))) + { + size, err := m.Tip[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x3a } @@ -2361,8 +2365,8 @@ func (m *StdSignDocAux) Size() (n int) { } } if len(m.Tip) > 0 { - for _, b := range m.Tip { - l = len(b) + for _, e := range m.Tip { + l = e.Size() n += 1 + l + sovTx(uint64(l)) } } @@ -4559,7 +4563,7 @@ func (m *StdSignDocAux) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Tip", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4569,23 +4573,25 @@ func (m *StdSignDocAux) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Tip = append(m.Tip, make([]byte, postIndex-iNdEx)) - copy(m.Tip[len(m.Tip)-1], dAtA[iNdEx:postIndex]) + m.Tip = append(m.Tip, &types2.Coin{}) + if err := m.Tip[len(m.Tip)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/auth/tx/amino_aux.go b/x/auth/tx/amino_aux.go index 859ec5bde49..a1988b6fbb7 100644 --- a/x/auth/tx/amino_aux.go +++ b/x/auth/tx/amino_aux.go @@ -1,12 +1,14 @@ package tx import ( + "encoding/json" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types/tx" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -39,15 +41,25 @@ func (signModeAminoAuxHandler) GetSignBytes( return nil, fmt.Errorf("can only handle a protobuf Tx, got %T", tx) } + msgs := protoTx.GetMsgs() + msgsBytes := make([]json.RawMessage, 0, len(msgs)) + for _, msg := range msgs { + legacyMsg, ok := msg.(legacytx.LegacyMsg) + if !ok { + panic(fmt.Errorf("expected %T when using amino JSON", (*legacytx.LegacyMsg)(nil))) + } + + msgsBytes = append(msgsBytes, json.RawMessage(legacyMsg.GetSignBytes())) + } + signDocDirectAux := types.StdSignDocAux{ AccountNumber: data.AccountNumber, Sequence: data.Sequence, TimeoutHeight: protoTx.GetTimeoutHeight(), ChainId: data.ChainID, Memo: protoTx.tx.Body.Memo, - // TODO - // Msgs: protoTx.GetMsgs(), - // Tip: protoTx.tx.AuthInfo.Tip, + Tip: protoTx.tx.AuthInfo.Tip.Amount, + Msgs: msgsBytes, } return signDocDirectAux.Marshal() diff --git a/x/auth/tx/amino_aux_test.go b/x/auth/tx/amino_aux_test.go new file mode 100644 index 00000000000..8daa6dafcd8 --- /dev/null +++ b/x/auth/tx/amino_aux_test.go @@ -0,0 +1,148 @@ +package tx + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" + signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/stretchr/testify/require" +) + +func TestAminoAuxHandler(t *testing.T) { + privKey, pubkey, addr := testdata.KeyTestPubAddr() + interfaceRegistry := codectypes.NewInterfaceRegistry() + interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{}) + marshaler := codec.NewProtoCodec(interfaceRegistry) + + txConfig := NewTxConfig(marshaler, []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_AMINO_AUX}) + txBuilder := txConfig.NewTxBuilder() + + memo := "sometestmemo" + msgs := []sdk.Msg{testdata.NewTestMsg(addr)} + accSeq := uint64(2) // Arbitrary account sequence + + // any, err := codectypes.NewAnyWithValue(pubkey) + // require.NoError(t, err) + + sigData := &signingtypes.SingleSignatureData{ + SignMode: signingtypes.SignMode_SIGN_MODE_AMINO_AUX, + } + + sig := signingtypes.SignatureV2{ + PubKey: pubkey, + Data: sigData, + Sequence: accSeq, + } + + fee := txtypes.Fee{Amount: sdk.NewCoins(sdk.NewInt64Coin("atom", 150)), GasLimit: 20000} + + err := txBuilder.SetMsgs(msgs...) + require.NoError(t, err) + txBuilder.SetMemo(memo) + txBuilder.SetFeeAmount(fee.Amount) + txBuilder.SetGasLimit(fee.GasLimit) + + err = txBuilder.SetSignatures(sig) + require.NoError(t, err) + + signingData := signing.SignerData{ + ChainID: "test-chain", + AccountNumber: 1, + } + + modeHandler := signModeAminoAuxHandler{} + signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, txBuilder.GetTx()) + + require.NoError(t, err) + require.NotNil(t, signBytes) + + anys := make([]*codectypes.Any, len(msgs)) + for i, msg := range msgs { + var err error + anys[i], err = codectypes.NewAnyWithValue(msg) + if err != nil { + panic(err) + } + } + + // txBody := &txtypes.TxBody{ + // Memo: memo, + // Messages: anys, + // } + // bodyBytes := marshaler.MustMarshal(txBody) + txBytes, err := txConfig.TxJSONEncoder()(txBuilder.GetTx()) + raw := make([]json.RawMessage, 1) + raw = append(raw, txBytes) + require.NoError(t, err) + + t.Log("verify GetSignBytes with generating sign bytes by marshaling signDocDirectAux") + signDocDirectAux := txtypes.StdSignDocAux{ + AccountNumber: 1, + ChainId: "test-chain", + TimeoutHeight: uint64(10), + Memo: memo, + Msgs: raw, + } + + expectedSignBytes, err := signDocDirectAux.Marshal() + require.NoError(t, err) + require.Equal(t, expectedSignBytes, signBytes) + + t.Log("verify that setting signature doesn't change sign bytes") + sigData.Signature, err = privKey.Sign(signBytes) + require.NoError(t, err) + err = txBuilder.SetSignatures(sig) + require.NoError(t, err) + signBytes, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx()) + require.NoError(t, err) + require.Equal(t, expectedSignBytes, signBytes) + + // t.Log("verify GetSignBytes with false txBody data") + // signDocDirectAux.BodyBytes = []byte("dfafdasfds") + // expectedSignBytes, err = signDocDirectAux.Marshal() + // require.NoError(t, err) + // require.NotEqual(t, expectedSignBytes, signBytes) +} + +func TestAminoAuxHandler_DefaultMode(t *testing.T) { + handler := signModeAminoAuxHandler{} + require.Equal(t, signingtypes.SignMode_SIGN_MODE_AMINO_AUX, handler.DefaultMode()) +} + +func TestAminoAuxModeHandler_nonDIRECT_MODE(t *testing.T) { + invalidModes := []signingtypes.SignMode{ + signingtypes.SignMode_SIGN_MODE_DIRECT, + signingtypes.SignMode_SIGN_MODE_DIRECT_JSON, + signingtypes.SignMode_SIGN_MODE_TEXTUAL, + signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, + signingtypes.SignMode_SIGN_MODE_UNSPECIFIED, + signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, + } + for _, invalidMode := range invalidModes { + t.Run(invalidMode.String(), func(t *testing.T) { + var dh signModeAminoAuxHandler + var signingData signing.SignerData + _, err := dh.GetSignBytes(invalidMode, signingData, nil) + require.Error(t, err) + wantErr := fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_AMINO_AUX, invalidMode) + require.Equal(t, err, wantErr) + }) + } +} + +func TestAminoAuxModeHandler_nonProtoTx(t *testing.T) { + var ah signModeAminoAuxHandler + var signingData signing.SignerData + tx := new(nonProtoTx) + _, err := ah.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, tx) + require.Error(t, err) + wantErr := fmt.Errorf("can only handle a protobuf Tx, got %T", tx) + require.Equal(t, err, wantErr) +} diff --git a/x/auth/tx/mode_handler.go b/x/auth/tx/mode_handler.go index 3a9b17df8f4..5ebd0a6c547 100644 --- a/x/auth/tx/mode_handler.go +++ b/x/auth/tx/mode_handler.go @@ -30,6 +30,8 @@ func makeSignModeHandler(modes []signingtypes.SignMode) signing.SignModeHandler handlers[i] = signModeLegacyAminoJSONHandler{} case signingtypes.SignMode_SIGN_MODE_DIRECT_AUX: handlers[i] = signModeDirectAuxHandler{} + case signingtypes.SignMode_SIGN_MODE_AMINO_AUX: + handlers[i] = signModeAminoAuxHandler{} default: panic(fmt.Errorf("unsupported sign mode %+v", mode)) } From f9e403ec22612f00dab3d1a4ff715cd57959f4e1 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 30 Sep 2021 18:14:58 +0530 Subject: [PATCH 4/7] revert tx.proto --- docs/core/proto-docs.md | 22 - proto/cosmos/tx/v1beta1/tx.proto | 30 -- types/tx/tx.pb.go | 589 +++------------------- x/auth/migrations/legacytx/stdsign_aux.go | 47 ++ x/auth/tx/amino_aux.go | 34 +- 5 files changed, 126 insertions(+), 596 deletions(-) create mode 100644 x/auth/migrations/legacytx/stdsign_aux.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index ffab5703f4a..00aad2bd00b 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -667,7 +667,6 @@ - [SignDocDirectAux](#cosmos.tx.v1beta1.SignDocDirectAux) - [SignDocJSON](#cosmos.tx.v1beta1.SignDocJSON) - [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) - - [StdSignDocAux](#cosmos.tx.v1beta1.StdSignDocAux) - [Tip](#cosmos.tx.v1beta1.Tip) - [Tx](#cosmos.tx.v1beta1.Tx) - [TxBody](#cosmos.tx.v1beta1.TxBody) @@ -9553,27 +9552,6 @@ signer. - - -### StdSignDocAux - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `account_number` | [uint64](#uint64) | | account_number is the account number of the account in state. | -| `sequence` | [uint64](#uint64) | | sequence is the sequence number of the signing account. | -| `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain | -| `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | -| `memo` | [string](#string) | | memo is any arbitrary note/comment to be added to the transaction. WARNING: in clients, any publicly exposed text should not be called memo, but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). | -| `msgs` | [bytes](#bytes) | repeated | msgs | -| `tip` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Tip is the optional tip used for meta-transactions. | - - - - - - ### Tip diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index b9cbfb65abb..dd281a8e526 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -252,33 +252,3 @@ message Tip { // tipper is the address of the account paying for the tip string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } - -message StdSignDocAux { - // account_number is the account number of the account in state. - uint64 account_number = 1; - - // sequence is the sequence number of the signing account. - uint64 sequence = 2; - - // timeout is the block height after which this transaction will not - // be processed by the chain - uint64 timeout_height = 3; - - // chain_id is the unique identifier of the chain this transaction targets. - // It prevents signed transactions from being used on another chain by an - // attacker - string chain_id = 4; - - // memo is any arbitrary note/comment to be added to the transaction. - // WARNING: in clients, any publicly exposed text should not be called memo, - // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). - string memo = 5; - - // msgs - repeated bytes msgs = 6 [ - (gogoproto.casttype) = "encoding/json.RawMessage" - ]; - - // Tip is the optional tip used for meta-transactions. - repeated cosmos.base.v1beta1.Coin tip = 7; -} diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 0189b82852c..881a0f938e9 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -4,7 +4,6 @@ package tx import ( - encoding_json "encoding/json" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -1003,110 +1002,6 @@ func (m *Tip) GetTipper() string { return "" } -type StdSignDocAux struct { - // account_number is the account number of the account in state. - AccountNumber uint64 `protobuf:"varint,1,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` - // sequence is the sequence number of the signing account. - Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` - // timeout is the block height after which this transaction will not - // be processed by the chain - TimeoutHeight uint64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` - // chain_id is the unique identifier of the chain this transaction targets. - // It prevents signed transactions from being used on another chain by an - // attacker - ChainId string `protobuf:"bytes,4,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // memo is any arbitrary note/comment to be added to the transaction. - // WARNING: in clients, any publicly exposed text should not be called memo, - // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). - Memo string `protobuf:"bytes,5,opt,name=memo,proto3" json:"memo,omitempty"` - // msgs - Msgs []encoding_json.RawMessage `protobuf:"bytes,6,rep,name=msgs,proto3,casttype=encoding/json.RawMessage" json:"msgs,omitempty"` - // Tip is the optional tip used for meta-transactions. - Tip []*types2.Coin `protobuf:"bytes,7,rep,name=tip,proto3" json:"tip,omitempty"` -} - -func (m *StdSignDocAux) Reset() { *m = StdSignDocAux{} } -func (m *StdSignDocAux) String() string { return proto.CompactTextString(m) } -func (*StdSignDocAux) ProtoMessage() {} -func (*StdSignDocAux) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{11} -} -func (m *StdSignDocAux) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StdSignDocAux) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StdSignDocAux.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StdSignDocAux) XXX_Merge(src proto.Message) { - xxx_messageInfo_StdSignDocAux.Merge(m, src) -} -func (m *StdSignDocAux) XXX_Size() int { - return m.Size() -} -func (m *StdSignDocAux) XXX_DiscardUnknown() { - xxx_messageInfo_StdSignDocAux.DiscardUnknown(m) -} - -var xxx_messageInfo_StdSignDocAux proto.InternalMessageInfo - -func (m *StdSignDocAux) GetAccountNumber() uint64 { - if m != nil { - return m.AccountNumber - } - return 0 -} - -func (m *StdSignDocAux) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - -func (m *StdSignDocAux) GetTimeoutHeight() uint64 { - if m != nil { - return m.TimeoutHeight - } - return 0 -} - -func (m *StdSignDocAux) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -func (m *StdSignDocAux) GetMemo() string { - if m != nil { - return m.Memo - } - return "" -} - -func (m *StdSignDocAux) GetMsgs() []encoding_json.RawMessage { - if m != nil { - return m.Msgs - } - return nil -} - -func (m *StdSignDocAux) GetTip() []*types2.Coin { - if m != nil { - return m.Tip - } - return nil -} - func init() { proto.RegisterType((*Tx)(nil), "cosmos.tx.v1beta1.Tx") proto.RegisterType((*TxRaw)(nil), "cosmos.tx.v1beta1.TxRaw") @@ -1121,81 +1016,75 @@ func init() { proto.RegisterType((*ModeInfo_Multi)(nil), "cosmos.tx.v1beta1.ModeInfo.Multi") proto.RegisterType((*Fee)(nil), "cosmos.tx.v1beta1.Fee") proto.RegisterType((*Tip)(nil), "cosmos.tx.v1beta1.Tip") - proto.RegisterType((*StdSignDocAux)(nil), "cosmos.tx.v1beta1.StdSignDocAux") } func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1088 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xfa, 0x2b, 0xf6, 0xdb, 0xa6, 0x1f, 0xa3, 0x08, 0xb9, 0x2e, 0x75, 0x83, 0x51, 0xc1, - 0x12, 0xca, 0x6e, 0x9a, 0x0a, 0x28, 0x08, 0x09, 0xec, 0x96, 0x2a, 0xa5, 0xa4, 0x95, 0xd6, 0x39, - 0xf5, 0xb2, 0x1a, 0xef, 0x4e, 0xd6, 0xd3, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0x6a, 0xff, 0x02, 0x4e, - 0x48, 0x15, 0x12, 0xe2, 0xca, 0x99, 0x33, 0x3f, 0xa2, 0xc7, 0x8a, 0x13, 0xa7, 0x52, 0x25, 0x27, - 0x84, 0xc4, 0x0f, 0xe0, 0x02, 0x9a, 0xd9, 0xd9, 0x8d, 0x93, 0x06, 0x3b, 0x12, 0x15, 0x27, 0xcf, - 0xc7, 0xf3, 0xbe, 0xf3, 0xb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0xa6, 0x29, 0x0b, - 0x39, 0x56, 0x13, 0x7c, 0x8e, 0x0a, 0x65, 0x83, 0xcd, 0x67, 0x2f, 0xae, 0x96, 0x7e, 0xfa, 0xed, - 0x6a, 0x2f, 0xa4, 0x72, 0x9c, 0x8e, 0x6c, 0x9f, 0x47, 0x4e, 0xfe, 0x75, 0xa0, 0x7f, 0x36, 0x44, - 0xf0, 0xd8, 0x91, 0xb3, 0x98, 0x08, 0x6d, 0x20, 0x5c, 0xe3, 0x1a, 0x5d, 0x86, 0x66, 0x88, 0x85, - 0x37, 0xa1, 0x11, 0x95, 0xba, 0x10, 0x55, 0xb7, 0x11, 0x62, 0xf1, 0xa5, 0xda, 0x23, 0x1b, 0x6a, - 0x31, 0x9e, 0x91, 0x24, 0x93, 0xb1, 0x41, 0xeb, 0x97, 0x9f, 0x37, 0xd6, 0x0c, 0x87, 0x7e, 0x10, - 0x24, 0x44, 0x88, 0xa1, 0x4c, 0x28, 0x0b, 0xdd, 0x0c, 0x86, 0xb6, 0x60, 0x25, 0x4c, 0x30, 0x93, - 0x46, 0xd7, 0x16, 0x59, 0xe4, 0xc0, 0xee, 0x23, 0xa8, 0xec, 0xd2, 0x18, 0x5d, 0x3f, 0x75, 0xb0, - 0x05, 0xf5, 0x4d, 0xa8, 0x4b, 0x1a, 0xc7, 0x24, 0xc9, 0x44, 0x6a, 0xc1, 0x63, 0x06, 0xd7, 0xfd, - 0xa6, 0x0c, 0xab, 0x43, 0x19, 0x98, 0x29, 0xa0, 0xf4, 0xff, 0x55, 0x41, 0xb6, 0x96, 0x09, 0x72, - 0xf9, 0x98, 0x20, 0x9f, 0x52, 0x15, 0xe7, 0xa7, 0x42, 0xf5, 0xe8, 0x54, 0xc8, 0xb5, 0xb6, 0x36, - 0xa7, 0xb5, 0x9b, 0x50, 0x8d, 0x44, 0x28, 0x5a, 0x75, 0xf5, 0x21, 0x31, 0x78, 0xf3, 0xaf, 0x17, - 0x57, 0x5b, 0x84, 0xf9, 0x3c, 0x50, 0x9f, 0x65, 0x8f, 0x04, 0x67, 0xb6, 0x8b, 0x9f, 0xec, 0x64, - 0x62, 0xed, 0x6a, 0x24, 0x7a, 0x2f, 0x53, 0x97, 0x95, 0x65, 0xe9, 0x53, 0xa8, 0xc1, 0xa7, 0xcf, - 0xf6, 0x3b, 0xd6, 0xf3, 0xfd, 0x8e, 0xf5, 0x72, 0xbf, 0x63, 0x3d, 0x3d, 0xe8, 0x94, 0x9e, 0x1f, - 0x74, 0x4a, 0xbf, 0x1e, 0x74, 0x4a, 0x0f, 0xaf, 0x2d, 0x6f, 0x21, 0x47, 0x4e, 0x47, 0x75, 0x2d, - 0x3b, 0x37, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xea, 0xa3, 0xa4, 0x3b, 0xca, 0x0a, 0x00, 0x00, + // 1004 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0x66, 0x6d, 0xc7, 0x7e, 0x49, 0xda, 0x66, 0x14, 0x21, 0xc7, 0x51, 0xdd, 0x60, 0x54, + 0xf0, 0x25, 0xbb, 0x49, 0x2a, 0xa0, 0x20, 0x24, 0xb0, 0x5b, 0xaa, 0x94, 0xd2, 0x56, 0x1a, 0xe7, + 0xd4, 0xcb, 0x6a, 0xbc, 0x9e, 0xac, 0x87, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0xf0, 0x7e, 0x08, 0xa4, + 0x0a, 0x09, 0x71, 0xe5, 0xcc, 0x99, 0x0f, 0xd1, 0x63, 0xc5, 0x89, 0x13, 0x54, 0xc9, 0x09, 0x21, + 0xf1, 0x15, 0x40, 0x3b, 0x3b, 0xbb, 0x49, 0x8b, 0xb1, 0x2b, 0x51, 0x71, 0xf2, 0xcc, 0x9b, 0xdf, + 0xfb, 0xbd, 0xdf, 0xfb, 0xb3, 0x33, 0x86, 0xb6, 0x2f, 0x64, 0x28, 0xa4, 0xab, 0x66, 0xee, 0x57, + 0x07, 0x23, 0xaa, 0xc8, 0x81, 0xab, 0x66, 0x4e, 0x14, 0x0b, 0x25, 0xd0, 0x66, 0x7e, 0xe6, 0xa8, + 0x99, 0x63, 0xce, 0xda, 0x5b, 0x81, 0x08, 0x84, 0x3e, 0x75, 0xb3, 0x55, 0x0e, 0x6c, 0xef, 0x19, + 0x12, 0x3f, 0x4e, 0x23, 0x25, 0xdc, 0x30, 0x99, 0x2a, 0x26, 0x59, 0x50, 0x32, 0x16, 0x06, 0x03, + 0xef, 0x18, 0xf8, 0x88, 0x48, 0x5a, 0x62, 0x7c, 0xc1, 0xb8, 0x39, 0x7f, 0xe7, 0x5c, 0x93, 0x64, + 0x01, 0x67, 0xfc, 0x9c, 0xc9, 0xec, 0x0d, 0x70, 0x3b, 0x10, 0x22, 0x98, 0x52, 0x57, 0xef, 0x46, + 0xc9, 0x89, 0x4b, 0x78, 0x5a, 0x1c, 0xe5, 0x1c, 0x5e, 0xae, 0xd5, 0x24, 0xa2, 0x37, 0xdd, 0x6f, + 0x2c, 0x58, 0x39, 0x9e, 0xa1, 0x3d, 0xa8, 0x8e, 0xc4, 0x38, 0x6d, 0x59, 0xbb, 0x56, 0x6f, 0xed, + 0x70, 0xdb, 0xf9, 0x47, 0xb2, 0xce, 0xf1, 0x6c, 0x20, 0xc6, 0x29, 0xd6, 0x30, 0x74, 0x13, 0x9a, + 0x24, 0x51, 0x13, 0x8f, 0xf1, 0x13, 0xd1, 0x5a, 0xd1, 0x3e, 0x3b, 0x73, 0x7c, 0xfa, 0x89, 0x9a, + 0xdc, 0xe5, 0x27, 0x02, 0x37, 0x88, 0x59, 0xa1, 0x0e, 0x40, 0x26, 0x9b, 0xa8, 0x24, 0xa6, 0xb2, + 0x65, 0xef, 0xda, 0xbd, 0x75, 0x7c, 0xc1, 0xd2, 0xe5, 0x50, 0x3b, 0x9e, 0x61, 0xf2, 0x35, 0xba, + 0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 0xd3, 0x5f, 0xaf, 0x55, 0x7e, 0xfc, 0xed, 0x5a, 0x2f, 0x60, 0x6a, 0x92, 0x8c, + 0x1c, 0x5f, 0x84, 0x6e, 0xf1, 0xef, 0x40, 0xff, 0xec, 0xc9, 0xf1, 0x63, 0x57, 0xa5, 0x11, 0x95, + 0xda, 0x41, 0x62, 0x43, 0x8d, 0x76, 0xa0, 0x19, 0x10, 0xe9, 0x4d, 0x59, 0xc8, 0x94, 0x6e, 0x44, + 0x15, 0x37, 0x02, 0x22, 0x3f, 0xcf, 0xf6, 0xc8, 0x81, 0x5a, 0x44, 0x52, 0x1a, 0xe7, 0xd7, 0xd8, + 0xa0, 0xf5, 0xf3, 0x4f, 0x7b, 0x5b, 0x46, 0x43, 0x7f, 0x3c, 0x8e, 0xa9, 0x94, 0x43, 0x15, 0x33, + 0x1e, 0xe0, 0x1c, 0x86, 0x0e, 0x61, 0x35, 0x88, 0x09, 0x57, 0xe6, 0x5e, 0x5b, 0xe4, 0x51, 0x00, + 0xbb, 0x5f, 0x80, 0x7d, 0xcc, 0x22, 0x74, 0xf0, 0xca, 0xc9, 0x96, 0xd2, 0xf7, 0xa1, 0xae, 0x58, + 0x14, 0xd1, 0x38, 0xbf, 0xa4, 0x16, 0x04, 0x33, 0xb8, 0xc1, 0xc7, 0x4f, 0x4f, 0x3b, 0xd6, 0xb3, + 0xd3, 0x8e, 0xf5, 0xfc, 0xb4, 0x63, 0x3d, 0x39, 0xeb, 0x54, 0x9e, 0x9d, 0x75, 0x2a, 0xbf, 0x9c, + 0x75, 0x2a, 0x8f, 0xae, 0x2f, 0x2f, 0x9c, 0xab, 0x66, 0xa3, 0xba, 0xfe, 0xd8, 0x6e, 0xfc, 0x1d, + 0x00, 0x00, 0xff, 0xff, 0x2e, 0xeb, 0x69, 0xc0, 0xc0, 0x09, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1931,81 +1820,6 @@ func (m *Tip) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StdSignDocAux) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StdSignDocAux) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdSignDocAux) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Tip) > 0 { - for iNdEx := len(m.Tip) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Tip[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if len(m.Msgs) > 0 { - for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Msgs[iNdEx]) - copy(dAtA[i:], m.Msgs[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Msgs[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.Memo) > 0 { - i -= len(m.Memo) - copy(dAtA[i:], m.Memo) - i = encodeVarintTx(dAtA, i, uint64(len(m.Memo))) - i-- - dAtA[i] = 0x2a - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0x22 - } - if m.TimeoutHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TimeoutHeight)) - i-- - dAtA[i] = 0x18 - } - if m.Sequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x10 - } - if m.AccountNumber != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.AccountNumber)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -2335,44 +2149,6 @@ func (m *Tip) Size() (n int) { return n } -func (m *StdSignDocAux) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AccountNumber != 0 { - n += 1 + sovTx(uint64(m.AccountNumber)) - } - if m.Sequence != 0 { - n += 1 + sovTx(uint64(m.Sequence)) - } - if m.TimeoutHeight != 0 { - n += 1 + sovTx(uint64(m.TimeoutHeight)) - } - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Memo) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Msgs) > 0 { - for _, b := range m.Msgs { - l = len(b) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.Tip) > 0 { - for _, e := range m.Tip { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4377,243 +4153,6 @@ func (m *Tip) Unmarshal(dAtA []byte) error { } return nil } -func (m *StdSignDocAux) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StdSignDocAux: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StdSignDocAux: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) - } - m.AccountNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AccountNumber |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) - } - m.Sequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) - } - m.TimeoutHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeoutHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Memo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Msgs = append(m.Msgs, make([]byte, postIndex-iNdEx)) - copy(m.Msgs[len(m.Msgs)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tip", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Tip = append(m.Tip, &types2.Coin{}) - if err := m.Tip[len(m.Tip)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/auth/migrations/legacytx/stdsign_aux.go b/x/auth/migrations/legacytx/stdsign_aux.go new file mode 100644 index 00000000000..a6aea988576 --- /dev/null +++ b/x/auth/migrations/legacytx/stdsign_aux.go @@ -0,0 +1,47 @@ +package legacytx + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec/legacy" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type StdSignDocAux struct { + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + TimeoutHeight uint64 `json:"timeout_height,omitempty" yaml:"timeout_height"` + ChainID string `json:"chain_id" yaml:"chain_id"` + Memo string `json:"memo" yaml:"memo"` + Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` + Tip sdk.Coins `json:"tip" yaml:"tip"` +} + +// StdSignBytes returns the bytes to sign for a transaction. +func StdSignAuxBytes(chainID string, accnum, sequence, timeout uint64, tip sdk.Coins, msgs []sdk.Msg, memo string) []byte { + msgsBytes := make([]json.RawMessage, 0, len(msgs)) + for _, msg := range msgs { + legacyMsg, ok := msg.(LegacyMsg) + if !ok { + panic(fmt.Errorf("expected %T when using amino JSON", (*LegacyMsg)(nil))) + } + + msgsBytes = append(msgsBytes, json.RawMessage(legacyMsg.GetSignBytes())) + } + + bz, err := legacy.Cdc.MarshalJSON(StdSignDocAux{ + AccountNumber: accnum, + ChainID: chainID, + Memo: memo, + Msgs: msgsBytes, + Sequence: sequence, + TimeoutHeight: timeout, + Tip: tip, + }) + if err != nil { + panic(err) + } + + return sdk.MustSortJSON(bz) +} diff --git a/x/auth/tx/amino_aux.go b/x/auth/tx/amino_aux.go index a1988b6fbb7..b1e88d701dc 100644 --- a/x/auth/tx/amino_aux.go +++ b/x/auth/tx/amino_aux.go @@ -1,11 +1,10 @@ package tx import ( - "encoding/json" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types/tx" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" @@ -41,26 +40,23 @@ func (signModeAminoAuxHandler) GetSignBytes( return nil, fmt.Errorf("can only handle a protobuf Tx, got %T", tx) } - msgs := protoTx.GetMsgs() - msgsBytes := make([]json.RawMessage, 0, len(msgs)) - for _, msg := range msgs { - legacyMsg, ok := msg.(legacytx.LegacyMsg) - if !ok { - panic(fmt.Errorf("expected %T when using amino JSON", (*legacytx.LegacyMsg)(nil))) - } + if protoTx.txBodyHasUnknownNonCriticals { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, aminoNonCriticalFieldsError) + } + + body := protoTx.tx.Body - msgsBytes = append(msgsBytes, json.RawMessage(legacyMsg.GetSignBytes())) + if len(body.ExtensionOptions) != 0 || len(body.NonCriticalExtensionOptions) != 0 { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "SIGN_MODE_AMINO_AUX does not support protobuf extension options.") } - signDocDirectAux := types.StdSignDocAux{ - AccountNumber: data.AccountNumber, - Sequence: data.Sequence, - TimeoutHeight: protoTx.GetTimeoutHeight(), - ChainId: data.ChainID, - Memo: protoTx.tx.Body.Memo, - Tip: protoTx.tx.AuthInfo.Tip.Amount, - Msgs: msgsBytes, + var tip sdk.Coins + for _, v := range protoTx.tx.AuthInfo.Tip.Amount { + tip.Add(*v) } - return signDocDirectAux.Marshal() + return legacytx.StdSignAuxBytes( + data.ChainID, data.AccountNumber, data.Sequence, protoTx.GetTimeoutHeight(), + tip, tx.GetMsgs(), protoTx.GetMemo(), + ), nil } From 59a2c371d74180cf9e9f26052b55aa49e8b6e459 Mon Sep 17 00:00:00 2001 From: Amaury M <1293565+amaurym@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:27:31 +0200 Subject: [PATCH 5/7] add SetTip --- client/tx_config.go | 2 ++ x/auth/migrations/legacytx/stdtx_builder.go | 5 +++++ x/auth/tx/builder.go | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/client/tx_config.go b/client/tx_config.go index 8220e917b2b..c9db30ff0d7 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -2,6 +2,7 @@ package client import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -41,6 +42,7 @@ type ( SetMemo(memo string) SetFeeAmount(amount sdk.Coins) SetGasLimit(limit uint64) + SetTip(tip *tx.Tip) SetTimeoutHeight(height uint64) SetFeeGranter(feeGranter sdk.AccAddress) } diff --git a/x/auth/migrations/legacytx/stdtx_builder.go b/x/auth/migrations/legacytx/stdtx_builder.go index 7e2e1c60443..af848d13eb8 100644 --- a/x/auth/migrations/legacytx/stdtx_builder.go +++ b/x/auth/migrations/legacytx/stdtx_builder.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -56,6 +57,10 @@ func (s *StdTxBuilder) SetGasLimit(limit uint64) { s.StdTx.Fee.Gas = limit } +func (s *StdTxBuilder) SetTip(tip *tx.Tip) { + panic("StdTxBuilder does not support tips") +} + // SetMemo implements TxBuilder.SetMemo func (s *StdTxBuilder) SetMemo(memo string) { s.Memo = memo diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 359c646087a..f71cc8d20ba 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -250,6 +250,13 @@ func (w *wrapper) SetFeeAmount(coins sdk.Coins) { w.authInfoBz = nil } +func (w *wrapper) SetTip(tip *tx.Tip) { + w.tx.AuthInfo.Tip = tip + + // set authInfoBz to nil because the cached authInfoBz no longer matches tx.AuthInfo + w.authInfoBz = nil +} + func (w *wrapper) SetFeePayer(feePayer sdk.AccAddress) { if w.tx.AuthInfo.Fee == nil { w.tx.AuthInfo.Fee = &tx.Fee{} From 971ae43d35184ddfc88f3ed1fd1e510a387cd31c Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 1 Oct 2021 11:40:58 +0530 Subject: [PATCH 6/7] fix tests --- proto/cosmos/tx/v1beta1/tx.proto | 2 +- types/tx/tx.pb.go | 132 +++++++++++++++---------------- x/auth/tx/amino_aux.go | 7 +- x/auth/tx/amino_aux_test.go | 71 +++++++++-------- 4 files changed, 107 insertions(+), 105 deletions(-) diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index dd281a8e526..d2588c62467 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -248,7 +248,7 @@ message Fee { // Tip is the tip used for meta-transactions. message Tip { // amount is the amount of the tip - repeated cosmos.base.v1beta1.Coin amount = 1; + repeated cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false]; // tipper is the address of the account paying for the tip string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 881a0f938e9..83b8d5840aa 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -950,7 +950,7 @@ func (m *Fee) GetGranter() string { // Tip is the tip used for meta-transactions. type Tip struct { // amount is the amount of the tip - Amount []*types2.Coin `protobuf:"bytes,1,rep,name=amount,proto3" json:"amount,omitempty"` + Amount []types2.Coin `protobuf:"bytes,1,rep,name=amount,proto3" json:"amount"` // tipper is the address of the account paying for the tip Tipper string `protobuf:"bytes,2,opt,name=tipper,proto3" json:"tipper,omitempty"` } @@ -988,7 +988,7 @@ func (m *Tip) XXX_DiscardUnknown() { var xxx_messageInfo_Tip proto.InternalMessageInfo -func (m *Tip) GetAmount() []*types2.Coin { +func (m *Tip) GetAmount() []types2.Coin { if m != nil { return m.Amount } @@ -1021,70 +1021,70 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1004 bytes of a gzipped FileDescriptorProto + // 1007 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0x66, 0x6d, 0xc7, 0x7e, 0x49, 0xda, 0x66, 0x14, 0x21, 0xc7, 0x51, 0xdd, 0x60, 0x54, - 0xf0, 0x25, 0xbb, 0x49, 0x2a, 0xa0, 0x20, 0x24, 0xb0, 0x5b, 0xaa, 0x94, 0xd2, 0x56, 0x1a, 0xe7, - 0xd4, 0xcb, 0x6a, 0xbc, 0x9e, 0xac, 0x87, 0x7a, 0x67, 0x96, 0x9d, 0x59, 0xf0, 0x7e, 0x08, 0xa4, - 0x0a, 0x09, 0x71, 0xe5, 0xcc, 0x99, 0x0f, 0xd1, 0x63, 0xc5, 0x89, 0x13, 0x54, 0xc9, 0x09, 0x21, - 0xf1, 0x15, 0x40, 0x3b, 0x3b, 0xbb, 0x49, 0x8b, 0xb1, 0x2b, 0x51, 0x71, 0xf2, 0xcc, 0x9b, 0xdf, - 0xfb, 0xbd, 0xdf, 0xfb, 0xb3, 0x33, 0x86, 0xb6, 0x2f, 0x64, 0x28, 0xa4, 0xab, 0x66, 0xee, 0x57, - 0x07, 0x23, 0xaa, 0xc8, 0x81, 0xab, 0x66, 0x4e, 0x14, 0x0b, 0x25, 0xd0, 0x66, 0x7e, 0xe6, 0xa8, - 0x99, 0x63, 0xce, 0xda, 0x5b,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 0xca, 0xf3, 0x93, 0x4e, + 0xe5, 0x97, 0x93, 0x4e, 0xe5, 0xf1, 0xb5, 0xe5, 0xe5, 0xf3, 0xd5, 0x6c, 0x54, 0x37, 0x9f, 0xdc, + 0x8d, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x17, 0x43, 0x65, 0x00, 0xc6, 0x09, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -4095,7 +4095,7 @@ func (m *Tip) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Amount = append(m.Amount, &types2.Coin{}) + m.Amount = append(m.Amount, types2.Coin{}) if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/auth/tx/amino_aux.go b/x/auth/tx/amino_aux.go index b1e88d701dc..aa388a42a55 100644 --- a/x/auth/tx/amino_aux.go +++ b/x/auth/tx/amino_aux.go @@ -50,13 +50,8 @@ func (signModeAminoAuxHandler) GetSignBytes( return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "SIGN_MODE_AMINO_AUX does not support protobuf extension options.") } - var tip sdk.Coins - for _, v := range protoTx.tx.AuthInfo.Tip.Amount { - tip.Add(*v) - } - return legacytx.StdSignAuxBytes( data.ChainID, data.AccountNumber, data.Sequence, protoTx.GetTimeoutHeight(), - tip, tx.GetMsgs(), protoTx.GetMemo(), + protoTx.tx.AuthInfo.Tip.Amount, tx.GetMsgs(), protoTx.GetMemo(), ), nil } diff --git a/x/auth/tx/amino_aux_test.go b/x/auth/tx/amino_aux_test.go index 8daa6dafcd8..071727bb7b7 100644 --- a/x/auth/tx/amino_aux_test.go +++ b/x/auth/tx/amino_aux_test.go @@ -1,18 +1,19 @@ package tx import ( - "encoding/json" "fmt" "testing" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/stretchr/testify/require" ) func TestAminoAuxHandler(t *testing.T) { @@ -24,9 +25,12 @@ func TestAminoAuxHandler(t *testing.T) { txConfig := NewTxConfig(marshaler, []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_AMINO_AUX}) txBuilder := txConfig.NewTxBuilder() + accountNumber := uint64(1) + chainId := "test-chain" memo := "sometestmemo" msgs := []sdk.Msg{testdata.NewTestMsg(addr)} accSeq := uint64(2) // Arbitrary account sequence + timeout := uint64(10) // any, err := codectypes.NewAnyWithValue(pubkey) // require.NoError(t, err) @@ -43,22 +47,28 @@ func TestAminoAuxHandler(t *testing.T) { fee := txtypes.Fee{Amount: sdk.NewCoins(sdk.NewInt64Coin("atom", 150)), GasLimit: 20000} + tip := sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(1000))) err := txBuilder.SetMsgs(msgs...) require.NoError(t, err) txBuilder.SetMemo(memo) txBuilder.SetFeeAmount(fee.Amount) txBuilder.SetGasLimit(fee.GasLimit) + txBuilder.SetTimeoutHeight(timeout) + txBuilder.SetTip(&txtypes.Tip{ + Amount: tip, + }) err = txBuilder.SetSignatures(sig) require.NoError(t, err) signingData := signing.SignerData{ - ChainID: "test-chain", - AccountNumber: 1, + ChainID: chainId, + AccountNumber: accountNumber, + Sequence: accSeq, } - modeHandler := signModeAminoAuxHandler{} - signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, txBuilder.GetTx()) + handler := signModeAminoAuxHandler{} + signBytes, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, txBuilder.GetTx()) require.NoError(t, err) require.NotNil(t, signBytes) @@ -72,26 +82,7 @@ func TestAminoAuxHandler(t *testing.T) { } } - // txBody := &txtypes.TxBody{ - // Memo: memo, - // Messages: anys, - // } - // bodyBytes := marshaler.MustMarshal(txBody) - txBytes, err := txConfig.TxJSONEncoder()(txBuilder.GetTx()) - raw := make([]json.RawMessage, 1) - raw = append(raw, txBytes) - require.NoError(t, err) - - t.Log("verify GetSignBytes with generating sign bytes by marshaling signDocDirectAux") - signDocDirectAux := txtypes.StdSignDocAux{ - AccountNumber: 1, - ChainId: "test-chain", - TimeoutHeight: uint64(10), - Memo: memo, - Msgs: raw, - } - - expectedSignBytes, err := signDocDirectAux.Marshal() + expectedSignBytes := legacytx.StdSignAuxBytes(chainId, accountNumber, accSeq, timeout, tip, msgs, memo) require.NoError(t, err) require.Equal(t, expectedSignBytes, signBytes) @@ -100,15 +91,31 @@ func TestAminoAuxHandler(t *testing.T) { require.NoError(t, err) err = txBuilder.SetSignatures(sig) require.NoError(t, err) - signBytes, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx()) + signBytes, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, txBuilder.GetTx()) require.NoError(t, err) require.Equal(t, expectedSignBytes, signBytes) - // t.Log("verify GetSignBytes with false txBody data") - // signDocDirectAux.BodyBytes = []byte("dfafdasfds") - // expectedSignBytes, err = signDocDirectAux.Marshal() - // require.NoError(t, err) - // require.NotEqual(t, expectedSignBytes, signBytes) + // expect error with wrong sign mode + _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx()) + require.Error(t, err) + + // expect error with extension options + bldr := newBuilder() + buildTx(t, bldr) + any, err := codectypes.NewAnyWithValue(testdata.NewTestMsg()) + require.NoError(t, err) + bldr.tx.Body.ExtensionOptions = []*codectypes.Any{any} + tx := bldr.GetTx() + _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, tx) + require.Error(t, err) + + // expect error with non-critical extension options + bldr = newBuilder() + buildTx(t, bldr) + bldr.tx.Body.NonCriticalExtensionOptions = []*codectypes.Any{any} + tx = bldr.GetTx() + _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, tx) + require.Error(t, err) } func TestAminoAuxHandler_DefaultMode(t *testing.T) { From 55c66e89427687e68964d3a3b12d91dab2a6f20c Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 1 Oct 2021 20:18:45 +0530 Subject: [PATCH 7/7] address review changes --- x/auth/migrations/legacytx/stdsign_aux.go | 2 +- x/auth/tx/amino_aux_test.go | 37 ++++++++--------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/x/auth/migrations/legacytx/stdsign_aux.go b/x/auth/migrations/legacytx/stdsign_aux.go index a6aea988576..5ba8539e747 100644 --- a/x/auth/migrations/legacytx/stdsign_aux.go +++ b/x/auth/migrations/legacytx/stdsign_aux.go @@ -24,7 +24,7 @@ func StdSignAuxBytes(chainID string, accnum, sequence, timeout uint64, tip sdk.C for _, msg := range msgs { legacyMsg, ok := msg.(LegacyMsg) if !ok { - panic(fmt.Errorf("expected %T when using amino JSON", (*LegacyMsg)(nil))) + panic(fmt.Errorf("expected %T when using AMINO_AUX", (*LegacyMsg)(nil))) } msgsBytes = append(msgsBytes, json.RawMessage(legacyMsg.GetSignBytes())) diff --git a/x/auth/tx/amino_aux_test.go b/x/auth/tx/amino_aux_test.go index 071727bb7b7..d7fced93870 100644 --- a/x/auth/tx/amino_aux_test.go +++ b/x/auth/tx/amino_aux_test.go @@ -31,23 +31,9 @@ func TestAminoAuxHandler(t *testing.T) { msgs := []sdk.Msg{testdata.NewTestMsg(addr)} accSeq := uint64(2) // Arbitrary account sequence timeout := uint64(10) - - // any, err := codectypes.NewAnyWithValue(pubkey) - // require.NoError(t, err) - - sigData := &signingtypes.SingleSignatureData{ - SignMode: signingtypes.SignMode_SIGN_MODE_AMINO_AUX, - } - - sig := signingtypes.SignatureV2{ - PubKey: pubkey, - Data: sigData, - Sequence: accSeq, - } - fee := txtypes.Fee{Amount: sdk.NewCoins(sdk.NewInt64Coin("atom", 150)), GasLimit: 20000} - tip := sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(1000))) + err := txBuilder.SetMsgs(msgs...) require.NoError(t, err) txBuilder.SetMemo(memo) @@ -56,8 +42,18 @@ func TestAminoAuxHandler(t *testing.T) { txBuilder.SetTimeoutHeight(timeout) txBuilder.SetTip(&txtypes.Tip{ Amount: tip, + Tipper: addr.String(), // Not needed when signing using AMINO_AUX, but putting here for clarity. }) + sigData := &signingtypes.SingleSignatureData{ + SignMode: signingtypes.SignMode_SIGN_MODE_AMINO_AUX, + } + + sig := signingtypes.SignatureV2{ + PubKey: pubkey, + Data: sigData, + Sequence: accSeq, + } err = txBuilder.SetSignatures(sig) require.NoError(t, err) @@ -65,23 +61,14 @@ func TestAminoAuxHandler(t *testing.T) { ChainID: chainId, AccountNumber: accountNumber, Sequence: accSeq, + SignerIndex: 0, } handler := signModeAminoAuxHandler{} signBytes, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_AMINO_AUX, signingData, txBuilder.GetTx()) - require.NoError(t, err) require.NotNil(t, signBytes) - anys := make([]*codectypes.Any, len(msgs)) - for i, msg := range msgs { - var err error - anys[i], err = codectypes.NewAnyWithValue(msg) - if err != nil { - panic(err) - } - } - expectedSignBytes := legacytx.StdSignAuxBytes(chainId, accountNumber, accSeq, timeout, tip, msgs, memo) require.NoError(t, err) require.Equal(t, expectedSignBytes, signBytes)