Skip to content

Commit

Permalink
feat: Add SIGN_MODE_DIRECT_AUX and tx Tip proto definitions (cosmos#9405
Browse files Browse the repository at this point in the history
)

closes: cosmos#9406 

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes
  • Loading branch information
aaronc authored Aug 11, 2021
1 parent c14b101 commit 69b4935
Show file tree
Hide file tree
Showing 5 changed files with 926 additions and 108 deletions.
43 changes: 42 additions & 1 deletion docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,10 @@
- [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi)
- [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single)
- [SignDoc](#cosmos.tx.v1beta1.SignDoc)
- [SignDocDirectAux](#cosmos.tx.v1beta1.SignDocDirectAux)
- [SignDocJSON](#cosmos.tx.v1beta1.SignDocJSON)
- [SignerInfo](#cosmos.tx.v1beta1.SignerInfo)
- [Tip](#cosmos.tx.v1beta1.Tip)
- [Tx](#cosmos.tx.v1beta1.Tx)
- [TxBody](#cosmos.tx.v1beta1.TxBody)
- [TxRaw](#cosmos.tx.v1beta1.TxRaw)
Expand Down Expand Up @@ -8623,7 +8625,8 @@ SignMode represents a signing mode with its own security guarantees.
| SIGN_MODE_UNSPECIFIED | 0 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected. |
| 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_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. |
| 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_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 Expand Up @@ -8653,6 +8656,7 @@ transaction.
| ----- | ---- | ----- | ----------- |
| `signer_infos` | [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) | repeated | signer_infos defines the signing modes for the required signers. The number and order of elements must match the required signers from TxBody's messages. The first element is the primary signer and the one which pays the fee. |
| `fee` | [Fee](#cosmos.tx.v1beta1.Fee) | | Fee is the fee and gas limit for the transaction. The first signer is the primary signer and the one which pays the fee. The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation. |
| `tip` | [Tip](#cosmos.tx.v1beta1.Tip) | | Tip is the optional tip used for meta-transactions. |



Expand Down Expand Up @@ -8746,6 +8750,27 @@ SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT.



<a name="cosmos.tx.v1beta1.SignDocDirectAux"></a>

### SignDocDirectAux
SignDocDirectAux is the type used for generating sign bytes for
SIGN_MODE_DIRECT_AUX.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `body_bytes` | [bytes](#bytes) | | body_bytes is protobuf serialization of a TxBody that matches the representation in TxRaw. |
| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public_key is the public key of the signing account. |
| `chain_id` | [string](#string) | | chain_id is the identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker. |
| `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. |
| `tip` | [Tip](#cosmos.tx.v1beta1.Tip) | | Tip is the optional tip used for meta-transactions. It should be left empty if the signer is not the tipper for this transaction. |






<a name="cosmos.tx.v1beta1.SignDocJSON"></a>

### SignDocJSON
Expand Down Expand Up @@ -8786,6 +8811,22 @@ signer.



<a name="cosmos.tx.v1beta1.Tip"></a>

### Tip
Tip is the tip used for meta-transactions.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | amount is the amount of the tip |
| `tipper` | [string](#string) | | tipper is the address of the account paying for the tip |






<a name="cosmos.tx.v1beta1.Tx"></a>

### Tx
Expand Down
8 changes: 7 additions & 1 deletion proto/cosmos/tx/signing/v1beta1/signing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ enum SignMode {

// 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.
// SIGN_MODE_DIRECT. It is currently not supported.
SIGN_MODE_DIRECT_JSON = 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_DIRECT_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
37 changes: 37 additions & 0 deletions proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ message SignDocJSON {
bytes sign_doc_sha256_hash = 5;
}

// SignDocDirectAux is the type used for generating sign bytes for
// SIGN_MODE_DIRECT_AUX.
message SignDocDirectAux {
// body_bytes is protobuf serialization of a TxBody that matches the
// representation in TxRaw.
bytes body_bytes = 1;

// public_key is the public key of the signing account.
google.protobuf.Any public_key = 2;

// chain_id is the identifier of the chain this transaction targets.
// It prevents signed transactions from being used on another chain by an
// attacker.
string chain_id = 3;

// account_number is the account number of the account in state.
uint64 account_number = 4;

// sequence is the sequence number of the signing account.
uint64 sequence = 5;

// Tip is the optional tip used for meta-transactions. It should be left
// empty if the signer is not the tipper for this transaction.
Tip tip = 6;
}

// TxBody is the body of a transaction that all signers sign over.
message TxBody {
// messages is a list of messages to be executed. The required signers of
Expand Down Expand Up @@ -141,6 +167,9 @@ message AuthInfo {
// based on the cost of evaluating the body and doing signature verification
// of the signers. This can be estimated via simulation.
Fee fee = 2;

// Tip is the optional tip used for meta-transactions.
Tip tip = 3;
}

// SignerInfo describes the public key and signing mode of a single top-level
Expand Down Expand Up @@ -214,3 +243,11 @@ message Fee {
// not support fee grants, this will fail
string granter = 4;
}

// Tip is the tip used for meta-transactions.
message Tip {
// amount is the amount of the tip
repeated cosmos.base.v1beta1.Coin amount = 1;
// tipper is the address of the account paying for the tip
string tipper = 2;
}
82 changes: 45 additions & 37 deletions types/tx/signing/signing.pb.go

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

Loading

0 comments on commit 69b4935

Please sign in to comment.