You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***GetMsgs:** unwraps the transaction and returns a list of contained `sdk.Msg`s - one transaction may have one or multiple messages, which are defined by module developers.
34
-
***ValidateBasic:** lightweight, [_stateless_](../beginner/01-tx-lifecycle.md#types-of-checks) checks used by ABCI messages [`CheckTx`](./00-baseapp.md#checktx) and [`DeliverTx`](./00-baseapp.md#delivertx) to make sure transactions are not invalid. For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) module's `ValidateBasic` function checks that its transactions are signed by the correct number of signers and that the fees do not exceed what the user's maximum. When [`runTx`](./00-baseapp.md#runtx) is checking a transaction created from the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/spec) module, it first runs `ValidateBasic` on each message, then runs the `auth` module AnteHandler which calls `ValidateBasic` for the transaction itself.
35
34
36
-
:::note
37
-
This function is different from the deprecated `sdk.Msg`[`ValidateBasic`](../beginner/01-tx-lifecycle.md#ValidateBasic) methods, which was performing basic validity checks on messages only.
38
-
:::
39
-
40
-
As a developer, you should rarely manipulate `Tx` directly, as `Tx` is really an intermediate type used for transaction generation. Instead, developers should prefer the `TxBuilder` interface, which you can learn more about [below](#transaction-generation).
35
+
As a developer, you should rarely manipulate `Tx` directly, as `Tx` is an intermediate type used for transaction generation. Instead, developers should prefer the `TxBuilder` interface, which you can learn more about [below](#transaction-generation).
41
36
42
37
### Signing Transactions
43
38
@@ -133,17 +128,19 @@ While messages contain the information for state transition logic, a transaction
133
128
134
129
### Transaction Generation
135
130
136
-
The `TxBuilder` interface contains data closely related with the generation of transactions, which an end-user can freely set to generate the desired transaction:
131
+
The `TxBuilder` interface contains data closely related with the generation of transactions, which an end-user can set to generate the desired transaction:
*`Msg`s, the array of [messages](#messages) included in the transaction.
143
138
*`GasLimit`, option chosen by the users for how to calculate how much gas they will need to pay.
144
139
*`Memo`, a note or comment to send with the transaction.
145
140
*`FeeAmount`, the maximum amount the user is willing to pay in fees.
146
141
*`TimeoutHeight`, block height until which the transaction is valid.
142
+
*`Unordered`, an option indicating this transaction may be executed in any order (requires TimeoutTimestamp to be set)
143
+
*`TimeoutTimestamp`, the timeout timestamp (unordered nonce) of the transaction (required to be used with Unordered).
147
144
*`Signatures`, the array of signatures from all signers of the transaction.
148
145
149
146
As there are currently two sign modes for signing transactions, there are also two implementations of `TxBuilder`:
@@ -154,7 +151,7 @@ As there are currently two sign modes for signing transactions, there are also t
154
151
However, the two implementations of `TxBuilder` should be hidden away from end-users, as they should prefer using the overarching `TxConfig` interface:
`TxConfig` is an app-wide configuration for managing transactions. Most importantly, it holds the information about whether to sign each transaction with `SIGN_MODE_DIRECT` or `SIGN_MODE_LEGACY_AMINO_JSON`. By calling `txBuilder := txConfig.NewTxBuilder()`, a new `TxBuilder` will be created with the appropriate sign mode.
@@ -204,3 +201,21 @@ An example can be seen [here](../../user/run-node/03-txs.md#using-rest)
204
201
#### CometBFT RPC
205
202
206
203
The three methods presented above are actually higher abstractions over the CometBFT RPC `/broadcast_tx_{async,sync,commit}` endpoints, documented [here](https://docs.cometbft.com/v0.37/core/rpc). This means that you can use the CometBFT RPC endpoints directly to broadcast the transaction, if you wish so.
204
+
205
+
### Unordered Transactions
206
+
207
+
:::tip
208
+
209
+
Looking to enable unordered transactions on your chain?
210
+
Check out the [v0.53.0 Upgrade Guide](https://docs.cosmos.network/v0.53/build/migrations/upgrade-guide#enable-unordered-transactions-optional)
211
+
212
+
:::
213
+
214
+
Beginning with Cosmos SDK v0.53.0, chains may enable unordered transaction support.
215
+
Unordered transactions work by using a timestamp as the transaction's nonce value.
216
+
The timestamp must be greater than the current block time and not exceed the chain's configured max unordered timeout timestamp duration.
217
+
Senders must use a unique timestamp for each distinct transaction. The difference may be as small as a nanosecond, however.
218
+
219
+
These unique timestamps serve as a one-shot nonce, and their lifespan in state is short-lived.
220
+
Upon transaction inclusion, an entry consisting of timeout timestamp and account address will be recorded to state.
221
+
Once the block time is passed the timeout timestamp value, the entry will be removed. This ensures that unordered nonces do not indefinitely fill up the chain's storage.
Unordered transactions from the same account must use a unique timeout timestamp value. The difference between each timeout timestamp value may be as small as a nanosecond, however.
We set encoding config to use Protobuf, which will use `SIGN_MODE_DIRECT` by default. As per [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-020-protobuf-transaction-encoding.md), each signer needs to sign the `SignerInfo`s of all other signers. This means that we need to perform two steps sequentially:
0 commit comments