2020-07-02 08:22:45 +00:00
|
|
|
<!--
|
|
|
|
order: 1
|
|
|
|
-->
|
|
|
|
|
|
|
|
# Encoding
|
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
Learn about the encoding formats used on Ethermint. {synopsis}
|
2020-07-02 08:22:45 +00:00
|
|
|
|
|
|
|
## Pre-requisite Readings
|
|
|
|
|
2020-07-06 16:56:02 +00:00
|
|
|
- [Cosmos SDK Encoding](https://docs.cosmos.network/master/core/encoding.html) {prereq}
|
2020-11-12 19:42:24 +00:00
|
|
|
- [Ethereum RLP](https://eth.wiki/en/fundamentals/rlp) {prereq}
|
2020-07-02 08:22:45 +00:00
|
|
|
|
|
|
|
## Encoding Formats
|
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
### Protocol Buffers
|
2020-07-02 08:22:45 +00:00
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
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 structs that are used for state and clients
|
|
|
|
(transaction messages, genesis, query services, etc) will be implemented as protocol buffer messages.
|
2020-07-02 08:22:45 +00:00
|
|
|
|
|
|
|
### Amino
|
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
The Cosmos SDK also supports the legacy Amino encoding format for backwards compatibility with
|
|
|
|
previous versions, specially for client encoding. Ethermint will not support Amino in the EVM module
|
|
|
|
once the migration to SDK `v0.40` is finalized.
|
2020-07-02 08:22:45 +00:00
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
### RLP
|
2020-07-02 08:22:45 +00:00
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
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. Ethermint 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.
|
2020-07-02 08:22:45 +00:00
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
Each message type defined on the EVM module define the `EncodeRLP` and `DecodeRLP` methods which
|
|
|
|
implement the `rlp.Encoder` and `rlp.Decoder` interfaces respectively. The RLP encode method is used
|
|
|
|
to sign bytes and transactions in `RLPSignBytes` and `Sign`.
|
2020-07-02 08:22:45 +00:00
|
|
|
|
|
|
|
## Next {hide}
|
|
|
|
|
2020-11-12 19:42:24 +00:00
|
|
|
Learn how [pending state](./pending_state.md) is handled on Ethermint. {hide}
|