feat: update chain-id format (#447)

* feat: update chain-id format

* c++

* docs

* additional context'
This commit is contained in:
Federico Kunze Küllmer
2021-08-17 14:11:26 +00:00
committed by GitHub
parent d93205b711
commit aa1b728d34
29 changed files with 119 additions and 66 deletions
+4 -3
View File
@@ -8,9 +8,10 @@ parent:
This repository contains reference documentation on the basic concepts of Ethermint.
1. [Chain ID](./chain_id)
1. [Accounts](./accounts)
2. [Gas and Fees](./gas)
3. [Lifecycle of a transaction](./transactions)
4. [Tokens](./tokens)
1. [Gas and Fees](./gas)
1. [Lifecycle of a transaction](./transactions)
1. [Tokens](./tokens)
After reading the basics, head on to the [Core Reference](../core/README) for more advanced material.
+1 -1
View File
@@ -1,5 +1,5 @@
<!--
order: 1
order: 2
-->
# Accounts
+36
View File
@@ -0,0 +1,36 @@
<!--
order: 1
-->
# Chain ID
Learn about the Ethermint chain-id format {synopsis}
## The Chain Identifier
Every chain must have a unique identifier or `chain-id`. Tendermint requires each application to
define its own `chain-id` in the [genesis.json fields](https://docs.tendermint.com/master/spec/core/genesis.html#genesis-fields). However, in order to comply with both EIP155 and Cosmos standard for chain upgrades, Ethermint-compatible chains must implement a special structure for their chain identifiers.
## Structure
The Ethermint Chain ID contains 3 main components
- **Identifier**: Unstructured string that defines the name of the application.
- **EIP155 Number**: Immutable [EIP155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) `CHAIN_ID` that defines the replay attack protection number.
- **Version Number**: Is the version number (always positive) that the chain is currently running.
This number **MUST** be incremented every time the chain is upgraded or forked in order to avoid network or consensus errors.
### Format
The format for specifying and Ethermint compatible chain-id in genesis is the following:
```bash
{identifier}_{EIP155}-{version}
```
The following table provides an example where the second row corresponds to an upgrade from the first one:
| ChainID | Identifier | EIP155 Number | Version Number |
|--------------------|------------|---------------|----------------|
| `ethermint_9000-1` | ethermint | 9000 | 1 |
| `ethermint_9000-2` | ethermint | 9000 | 2 |
+1 -1
View File
@@ -1,5 +1,5 @@
<!--
order: 3
order: 4
-->
# Gas and Fees
+1 -1
View File
@@ -1,5 +1,5 @@
<!--
order: 4
order: 5
-->
# Tokens
+1 -1
View File
@@ -1,5 +1,5 @@
<!--
order: 2
order: 3
-->
# Transactions
+2 -2
View File
@@ -15,8 +15,8 @@ are not already. Then click the top right circle and go to `Settings` > `Network
Network` button and fill the form as shown below with your application `ChainID`.
::: tip
To find your full `ChainID`, got your genesis.json file. To get the Ethereum chain ID from the Cosmos chain ID, you need to consider only the last digit in the string value. For example
if your chain id on ethermint is `"chain_id": "ethermint-1337"`, then you will have to use the value `1337` on Metamask.
To find your full `ChainID`, got your genesis.json file. To get the [EIP155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) chain ID from the Cosmos chain ID, you need to consider only the second number in the string value. For example
if your chain id on ethermint is `"chain_id": "ethermint_9000-1"`, then you will have to use the value `9000` on Metamask.
:::
![metamask networks settings](./../img/metamask_network_settings.png)
+1 -1
View File
@@ -24,7 +24,7 @@ This guide helps you create a single validator node that runs a network locally
```bash
$MONIKER=testing
$KEY=mykey
$CHAINID="ethermint-777"
$CHAINID="ethermint_9000-1"
ethermintd init $MONIKER --chain-id=$CHAINID
```
+17 -17
View File
@@ -63,13 +63,13 @@ ethermintd config
We can make changes to the default settings upon our choices, so it allows users to set the configuration beforehand all at once, so it would be ready with the same config afterward.
For example, the chain identifier can be changed to `ethermint-777` from a blank name by using:
For example, the chain identifier can be changed to `ethermint_9000-1` from a blank name by using:
```bash
ethermintd config "chain-id" ethermint-777
ethermintd config "chain-id" ethermint_9000-1
ethermintd config
{
"chain-id": "ethermint-777",
"chain-id": "ethermint_9000-1",
"keyring-backend": "os",
"output": "text",
"node": "tcp://localhost:26657",
@@ -89,7 +89,7 @@ Alternatively, we can directly make the changes to the config values in one plac
# The network chain ID
chain-id = "ethermint-777"
chain-id = "ethermint_9000-1"
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory)
@@ -108,12 +108,12 @@ node = "tcp://localhost:26657"
broadcast-mode = "sync"
```
After the necessary changes are made in the `client.toml`, then save. For example, if we directly change the chain-id from `ethermint-0` to `etherminttest-1`, and output to number, it would change instantly as shown below.
After the necessary changes are made in the `client.toml`, then save. For example, if we directly change the chain-id from `ethermint_9000-1` to `etherminttest_9000-1`, and output to number, it would change instantly as shown below.
```bash
ethermintd config
{
"chain-id": "etherminttest-1",
"chain-id": "etherminttest_9000-1",
"keyring-backend": "os",
"output": "number",
"node": "tcp://localhost:26657",
@@ -126,7 +126,7 @@ ethermintd config
A list of commonly used flags of `ethermintd` is listed below:
| Option | Description | Type | Default Value |
| ------------------- | ----------------------------- | ------------ | --------------- |
|---------------------|-------------------------------|--------------|-----------------|
| `--chain-id` | Full Chain ID | String | --- |
| `--home` | Directory for config and data | string | `~/.ethermintd` |
| `--keyring-backend` | Select keyring's backend | os/file/test | os |
@@ -136,13 +136,13 @@ A list of commonly used flags of `ethermintd` is listed below:
A list of commonly used `ethermintd` commands. You can obtain the full list by using the `ethermintd -h` command.
| Command | Description | Subcommands (example) |
| --------------- | ------------------------ | ------------------------------------------------------------ |
| `keys` | Keys management | `list`, `show`, `add`, `add --recover`, `delete` |
| `tx` | Transactions subcommands | `bank send`, `ibc-transfer transfer`, `distribution withdraw-all-rewards` |
| `query` | Query subcommands | `bank balance`, `staking validators`, `gov proposals` |
| `tendermint` | Tendermint subcommands | `show-address`, `show-node-id`, `version` |
| `config` | Client configuration | |
| `init` | Initialize full node | |
| `start` | Run full node | |
| `version` | Ethermint version | |
| Command | Description | Subcommands (example) |
|--------------|--------------------------|---------------------------------------------------------------------------|
| `keys` | Keys management | `list`, `show`, `add`, `add --recover`, `delete` |
| `tx` | Transactions subcommands | `bank send`, `ibc-transfer transfer`, `distribution withdraw-all-rewards` |
| `query` | Query subcommands | `bank balance`, `staking validators`, `gov proposals` |
| `tendermint` | Tendermint subcommands | `show-address`, `show-node-id`, `version` |
| `config` | Client configuration | |
| `init` | Initialize full node | |
| `start` | Run full node | |
| `version` | Ethermint version | |