docs: first update (#188)

* docs: update

* update +

* txs

* update docs

* more docs

* spec update

* doc fixes
This commit is contained in:
Federico Kunze Küllmer
2021-08-03 17:35:31 +00:00
committed by GitHub
parent 2bd107ee79
commit f7bcc8d12e
28 changed files with 402 additions and 631 deletions
+1
View File
@@ -10,5 +10,6 @@ This repository contains reference documentation on the core concepts of Ethermi
1. [Encoding](./encoding.md)
2. [Pending State](./pending_state.md)
3. [Protobuf Docs](./proto-docs.md)
After reading the core concepts, head on to the [guides](../guides/README.md) to learn how to use Ethereum tooling with Ethermint.
+33 -6
View File
@@ -17,14 +17,14 @@ Learn about the encoding formats used on Ethermint. {synopsis}
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
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.
### Amino
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.
previous versions, specially for client encoding and signing with Ledger devices. Ethermint does not
support Amino in the EVM module, but it is supported for all other Cosmos SDK modules that enable it.
### RLP
@@ -33,9 +33,36 @@ allows for quick reconstruction of encoded data. Ethermint uses RLP to encode/de
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.
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`.
The `x/evm` transactions (`MsgEthereumTx`) encoding is performed by casting the message to a go-ethereum's `Transaction` and then marshaling the transaction data using RLP:
```go
// TxEncoder overwrites sdk.TxEncoder to support MsgEthereumTx
func (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 MsgEthereumTx
func (g txConfig) TxDecoder() sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, error) {
tx := &ethtypes.Transaction{}
err := tx.UnmarshalBinary(txBytes)
if err == nil {
msg := &evmtypes.MsgEthereumTx{}
msg.FromEthereumTx(tx)
return msg, nil
}
return g.TxConfig.TxDecoder()(txBytes)
}
}
```
## Next {hide}