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
Copy file name to clipboardExpand all lines: docs/documentation/concepts/accounts.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,6 @@ You can query an account address using CLI, gRPC, REST, or JSON-RPC:
232
232
</Tabs>
233
233
234
234
<Note>
235
-
For JSON-RPC methods, see [`eth_accounts`](/api-reference/ethereum-json-rpc/methods#eth-accounts) and [`personal_listAccounts`](/api-reference/ethereum-json-rpc/methods#personal-listAccounts) documentation.
235
+
For JSON-RPC methods, see [`eth_accounts`](/docs/api-reference/ethereum-json-rpc/methods#eth-accounts) and [`personal_listAccounts`](/docs/api-reference/ethereum-json-rpc/methods#personal-listAccounts) documentation.
Copy file name to clipboardExpand all lines: docs/documentation/concepts/encoding.mdx
+89-15Lines changed: 89 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,28 +9,102 @@ In Ethereum, integers must be represented in big-endian binary form with no lead
9
9
10
10
The Cosmos Stargate release introduces protobuf as the main encoding format for both client and state serialization. All the EVM module types that are used for state and clients, such as transaction messages, genesis, query services, etc., will be implemented as protocol buffer messages. The Cosmos SDK also supports the legacy Amino encoding. Protocol Buffers (protobuf) is a language-agnostic binary serialization format that is smaller and faster than JSON. It is used to serialize structured data, such as messages, and is designed to be highly efficient and extensible. The encoding format is defined in a language-agnostic language called Protocol Buffers Language (proto3), and the encoded messages can be used to generate code for a variety of programming languages. The main advantage of protobuf is its efficiency, which results in smaller message sizes and faster serialization and deserialization times. The RLP decoding process is as follows: according to the first byte (i.e., prefix) of input data and decoding the data type, the length of the actual data and offset; according to the type and offset of data, decode the data correspondingly.
11
11
12
-
## Prerequisite Readings[](#prerequisite-readings"Direct link to Prerequisite Readings")
## Encoding Formats[](#encoding-formats"Direct link to Encoding Formats")
23
+
## Encoding Formats
18
24
19
-
### Protocol Buffers[](#protocol-buffers"Direct link to Protocol Buffers")
25
+
<Tabs>
26
+
<Tabtitle="Protocol Buffers">
27
+
**Primary encoding for Cosmos EVM**
28
+
29
+
The Cosmos [Stargate](https://stargate.cosmos.network/) release introduces [protobuf](https://developers.google.com/protocol-buffers) as the main encoding format for both client and state serialization.
30
+
31
+
<Info>
32
+
All EVM module types (transaction messages, genesis, query services) are implemented as protocol buffer messages.
33
+
</Info>
34
+
35
+
**Advantages:**
36
+
- Language-agnostic binary serialization
37
+
- Smaller message sizes than JSON
38
+
- Faster serialization/deserialization
39
+
- Strongly typed with schema validation
40
+
</Tab>
41
+
42
+
<Tabtitle="RLP">
43
+
**Ethereum compatibility encoding**
44
+
45
+
Recursive Length Prefix ([RLP](https://eth.wiki/en/fundamentals/rlp)) is an encoding/decoding algorithm that serializes messages for Ethereum compatibility.
46
+
47
+
<Note>
48
+
Cosmos EVM uses RLP specifically for Ethereum transaction encoding to ensure JSON-RPC compatibility.
49
+
</Note>
50
+
51
+
**Usage in Cosmos EVM:**
52
+
- Encoding `MsgEthereumTx` for JSON-RPC
53
+
- Transaction signing and verification
54
+
- Block hash computation
55
+
- Merkle tree data structures
56
+
</Tab>
57
+
58
+
<Tabtitle="Amino (Legacy)">
59
+
**Backwards compatibility only**
60
+
61
+
The Cosmos SDK supports legacy Amino encoding for backwards compatibility with older versions.
62
+
63
+
<Warning>
64
+
Cosmos EVM does not support Amino in the EVM module. It's only available for other Cosmos SDK modules that enable it.
65
+
</Warning>
66
+
67
+
**Limited use cases:**
68
+
- Client encoding for legacy wallets
69
+
- Signing with Ledger devices
70
+
- Not used for EVM transactions
71
+
</Tab>
72
+
</Tabs>
20
73
21
-
The Cosmos [Stargate](https://stargate.cosmos.network/) release introduces [protobuf](https://developers.google.com/protocol-buffers) as the main encoding format for both client and state serialization. All the EVM module types that are used for state and clients (transaction messages, genesis, query services, etc) will be implemented as protocol buffer messages.
74
+
### Transaction Encoding Implementation
22
75
23
-
### Amino[](#amino"Direct link to Amino")
76
+
The `x/vm` module handles `MsgEthereumTx` encoding by converting to go-ethereum's `Transaction` format and using RLP:
24
77
25
-
The Cosmos SDK also supports the legacy Amino encoding format for backwards compatibility with previous versions, specially for client encoding and signing with Ledger devices. Cosmos EVM does not support Amino in the EVM module, but it is supported for all other Cosmos SDK modules that enable it.
26
-
27
-
### RLP[](#rlp"Direct link to RLP")
28
-
29
-
Recursive Length Prefix ([RLP](https://eth.wiki/en/fundamentals/rlp)), is an encoding/decoding algorithm that serializes a message and allows for quick reconstruction of encoded data. Cosmos EVM uses RLP to encode/decode Ethereum messages for JSON-RPC handling to conform messages to the proper Ethereum format. This allows messages to be encoded and decoded in the exact format as Ethereum's.
30
-
31
-
The `x/vm` transactions (`MsgEthereumTx`) encoding is performed by casting the message to a go-ethereum's `Transaction` and then marshaling the transaction data using RLP:
78
+
<CodeGroup>
32
79
80
+
```go TxEncoder
81
+
// TxEncoder overwrites sdk.TxEncoder to support MsgEthereumTx
82
+
func(gtxConfig) TxEncoder() sdk.TxEncoder {
83
+
returnfunc(tx sdk.Tx) ([]byte, error) {
84
+
msg, ok:= tx.(*evmtypes.MsgEthereumTx)
85
+
if ok {
86
+
return msg.AsTransaction().MarshalBinary()
87
+
}
88
+
return g.TxConfig.TxEncoder()(tx)
89
+
}
90
+
}
33
91
```
34
-
// TxEncoder overwrites sdk.TxEncoder to support MsgEthereumTxfunc (g txConfig) TxEncoder() sdk.TxEncoder {return func(tx sdk.Tx) ([]byte, error) { msg, ok := tx.(*evmtypes.MsgEthereumTx) if ok { return msg.AsTransaction().MarshalBinary() } return g.TxConfig.TxEncoder()(tx)}}// TxDecoder overwrites sdk.TxDecoder to support MsgEthereumTxfunc (g txConfig) TxDecoder() sdk.TxDecoder {return func(txBytes []byte) (sdk.Tx, error) { tx := ðtypes.Transaction{} err := tx.UnmarshalBinary(txBytes) if err == nil { msg := &evmtypes.MsgEthereumTx{} msg.FromEthereumTx(tx) return msg, nil } return g.TxConfig.TxDecoder()(txBytes)}}
92
+
93
+
```go TxDecoder
94
+
// TxDecoder overwrites sdk.TxDecoder to support MsgEthereumTx
Copy file name to clipboardExpand all lines: docs/documentation/concepts/mempool.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,7 +204,7 @@ You can also explore these methods interactively using the [RPC Explorer](/docs/
204
204
## Integration
205
205
206
206
<Note>
207
-
For chain developers looking to integrate the mempool into their Cosmos SDK chain, see the [EVM Mempool Integration Guide](/documentation/integration/mempool-integration) for complete setup instructions.
207
+
For chain developers looking to integrate the mempool into their Cosmos SDK chain, see the [EVM Mempool Integration Guide](/docs/documentation/integration/mempool-integration) for complete setup instructions.
Copy file name to clipboardExpand all lines: docs/documentation/concepts/transactions.mdx
+35-29Lines changed: 35 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,22 +10,22 @@ Additionally, a transaction needs to be signed using the sender's private key. T
10
10
In a nutshell, the transaction lifecycle once a signed transaction is submitted to the network is the following:
11
11
12
12
* A transaction hash is cryptographically generated.
13
-
* The transaction is validated through CheckTx and added to the mempool:
14
-
***For Ethereum transactions**: If the nonce is correct, it enters the public mempool immediately. If there's a nonce gap, it's queued locally until the gap is filled (see [Mempool](/docs/documentation/concepts/mempool) for details).
15
-
***For Cosmos transactions**: Standard sequential nonce validation applies.
13
+
* The transaction is validated through CheckTx and added to the mempool (see [Transaction Ordering](#transaction-ordering-and-prioritization) below).
16
14
* The transaction is broadcasted to the network peers (only if immediately executable).
17
15
* A validator selects your transaction for inclusion in a block based on fee prioritization.
18
16
* The transaction is executed and the state change is committed.
19
17
20
-
For a more detailed explanation of the transaction lifecycle, see [the corresponding section](https://docs.cosmos.network/main/basics/tx-lifecycle) and the [Mempool documentation](/docs/documentation/concepts/mempool#transaction-flow).
18
+
<Note>
19
+
For detailed transaction flow and mempool behavior, see the [Mempool documentation](/docs/documentation/concepts/mempool#transaction-flow) and [Cosmos SDK lifecycle](https://docs.cosmos.network/main/basics/tx-lifecycle).
20
+
</Note>
21
21
22
22
The transaction hash is a unique identifier and can be used to check transaction information, for example, the events emitted, if was successful or not.
23
23
24
24
Transactions can fail for various reasons. For example, the provided gas or fees may be insufficient. Also, the transaction validation may fail. Each transaction has specific conditions that must fullfil to be considered valid. A widespread validation is that the sender is the transaction signer. In such a case, if you send a transaction where the sender address is different than the signer's address, the transation will fail, even if the fees are sufficient.
25
25
26
26
Nowadays, transactions can not only perform state transitions on the chain in which are submitted, but also can execute transactions on another blockchains. Interchain transactions are possible through the [Inter-Blockchain Communication protocol (IBC)](https://ibcprotocol.org/). Find a more detailed explanation on the section below.
27
27
28
-
## Transaction Types[](#transaction-types"Direct link to Transaction Types")
28
+
## Transaction Types
29
29
30
30
Cosmos EVM supports two transaction types:
31
31
@@ -38,7 +38,7 @@ Although most of the information included on both of these transaction types is
38
38
39
39
Find more information about these two types on the following sections.
40
40
41
-
### Cosmos Transactions[](#cosmos-transactions"Direct link to Cosmos Transactions")
41
+
### Cosmos Transactions
42
42
43
43
On Cosmos chains, transactions are comprised of metadata held in contexts and `sdk.Msg`s that trigger state changes within a module through the module's Protobuf [Msg service](https://docs.cosmos.network/main/building-modules/msg-services).
44
44
@@ -55,13 +55,12 @@ A Cosmos transaction includes the following information:
55
55
56
56
To submit a Cosmos transaction, users must use one of the provided clients.
57
57
58
-
### Ethereum Transactions[](#ethereum-transactions"Direct link to Ethereum Transactions")
58
+
### Ethereum Transactions
59
59
60
60
Ethereum transactions refer to actions initiated by EOAs (externally-owned accounts, managed by humans), rather than internal smart contract calls. Ethereum transactions transform the state of the EVM and therefore must be broadcasted to the entire network.
61
61
62
62
Ethereum transactions also require a fee, known as `gas`. ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)) introduced the idea of a base fee, along with a priority fee which serves as an incentive for validators to include specific transactions in blocks.
63
63
64
-
**Nonce Management**: Unlike traditional Cosmos transactions, Ethereum transactions can be submitted with nonce gaps. The EVM mempool will queue these transactions locally until the gaps are filled, enabling compatibility with Ethereum tooling that sends batch transactions. See the [Mempool documentation](/docs/documentation/concepts/mempool) for details on nonce gap handling.
65
64
66
65
There are several categories of Ethereum transactions:
67
66
@@ -73,7 +72,7 @@ An Ethereum transaction includes the following information:
73
72
74
73
*`recipient`: receiving address
75
74
*`signature`: sender's signature
76
-
*`nonce`: counter of tx number from account (supports out-of-order submission with queuing)
75
+
*`nonce`: counter of tx number from account
77
76
*`value`: amount of ETH to transfer (in wei)
78
77
*`data`: include arbitrary data. Used when deploying a smart contract or making a smart contract method call
79
78
*`gasLimit`: max amount of gas to be consumed
@@ -96,13 +95,8 @@ Cosmos EVM is capable of processing Ethereum transactions by wrapping them on a
96
95
97
96
One remark about the `MsgEthereumTx` is that it implements both the `sdk.Msg` and `sdk.Tx` interfaces (generally SDK messages only implement the former, while the latter is a group of messages bundled together). The reason for this is that the `MsgEthereumTx` must not be included in a `auth.StdTx` (SDK's standard transaction type) as it performs gas and fee checks using the Ethereum logic from Geth instead of the Cosmos SDK checks done on the auth module `AnteHandler`.
98
97
99
-
**Mempool Handling**: `MsgEthereumTx` transactions receive special treatment in the mempool:
100
-
- Transactions with correct nonces are immediately added to the public mempool and broadcast
101
-
- Transactions with nonce gaps are intercepted and queued locally without broadcasting
102
-
- When gaps are filled, queued transactions are automatically promoted and broadcast
103
-
- This enables compatibility with Ethereum tooling that sends batched transactions
104
98
105
-
#### Ethereum Tx Type[](#ethereum-tx-type"Direct link to Ethereum Tx Type")
99
+
#### Ethereum Tx Type
106
100
107
101
There are three types of transaction types used in Cosmos EVM's [Go Ethereum](https://github.com/ethereum/go-ethereum/blob/b946b7a13b749c99979e312c83dce34cac8dd7b1/core/types/transaction.go#L43-L48) implementation that came from Ethereum Improvement Proposals(EIPs):
108
102
@@ -114,7 +108,7 @@ There are three types of transaction types used in Cosmos EVM's [Go Ethereum](ht
114
108
115
109
These transaction types represent Ethereum's continuous evolution and improvements to its network, helping address challenges related to scalability, security, and user experience.
116
110
117
-
### Interchain Transactions[](#interchain-transactions"Direct link to Interchain Transactions")
111
+
### Interchain Transactions
118
112
119
113
Interchain transactions refer to the transfer of digital assets or data between two or more different blockchain networks.
120
114
@@ -133,19 +127,31 @@ Interchain transactions are becoming increasingly important as the number of dif
133
127
134
128
## Transaction Ordering and Prioritization
135
129
136
-
In Cosmos EVM, both Ethereum and Cosmos transactions compete fairly for block inclusion based on their effective tips:
137
-
138
-
### Fee-Based Priority
139
-
-**Ethereum transactions**: Priority determined by `gas_tip_cap` or `min(gas_tip_cap, gas_fee_cap - base_fee)`
140
-
-**Cosmos transactions**: Priority calculated as `(fee_amount / gas_limit) - base_fee`
141
-
- Transactions with higher effective tips are selected first, regardless of type
142
-
143
-
### Nonce Sequencing
144
-
- Within each account, transactions must be executed in nonce order
145
-
- The mempool automatically handles nonce gaps for Ethereum transactions
146
-
- See the [Mempool Architecture](/docs/documentation/concepts/mempool#architecture) for detailed flow diagrams
147
-
148
-
## Transaction Receipts[](#transaction-receipts"Direct link to Transaction Receipts")
130
+
In Cosmos EVM, both Ethereum and Cosmos transactions compete fairly for block inclusion:
131
+
132
+
<Tabs>
133
+
<Tabtitle="Fee Priority">
134
+
Transactions are ordered by their effective tips:
135
+
- **Ethereum**: `gas_tip_cap` or `min(gas_tip_cap, gas_fee_cap - base_fee)`
For detailed mempool behavior and flow diagrams, see [Mempool Architecture](/docs/documentation/concepts/mempool#architecture).
152
+
</Info>
153
+
154
+
## Transaction Receipts
149
155
150
156
A transaction receipt shows data returned by an Ethereum client to represent the result of a particular transaction, including a hash of the transaction, its block number, the amount of gas used, and, in case of deployment of a smart contract, the address of the contract. Additionally, it includes custom information from the events emitted in the smart contract.
0 commit comments