cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.24k stars 3.61k forks source link

Update genesis.json to be embeddable in TM genesis file #32

Closed ebuchman closed 7 years ago

ebuchman commented 7 years ago
  1. Let's change from array to object. This:
[
  "base/chainID", "test_chain_1",
  "base/account", {
    "pub_key": [1, "B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"],
    "coins": [
        {   
          "denom": "mycoin",
          "amount": 9007199254740992
        }   
    ]   
  }
]

becomes

{
  "base/chainID": "test_chain_1",
  "base/account": {
    "pub_key": [1, "B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"],
    "coins": [
        {   
          "denom": "mycoin",
          "amount": 9007199254740992
        }   
    ]   
  }
}
  1. Let's give it app/tendermint structure:
{
  "app": { ... },
  "tendermint": { ... }
}

so we can embed the tendermint genesis in the app genesis and only have one.

  1. We need to do something about chain_id. They are specified separately in tendermint and app genesis objects. Do we let one overwrite the other? Remove one? Not sure what's right here yet.
ethanfrey commented 7 years ago

Problem with object instead of array is duplicate keys and order. We may have many "base/account" entries. How to represent in a map? Also what if there is a dependency between two setoptions

ethanfrey commented 7 years ago

I think it is cleaner. And those two chain IDs caused lots of headache today, no idea the best change, but a change is welcome

rigelrozanski commented 7 years ago

on (3.) it seems silly to have them overwrite each other, is there any good argument to be made for specifying the chainid within basecoin as opposed to tendermint? currently tendermint only supports attaching to one abci correct? I guess under a situation where tendermint supports connecting to multiple apps then it would make sense to include the chainid in basecoin, but maybe we build that in whenever this feature goes online, if ever. As such probably makes sense to remove chainid from basecoin

melekes commented 7 years ago

(2) but what if I am not running TM in-proc, but rather on a separate machine? In this case, the suggested structure will be confusing for people, won't it? I would expect TM looking for genesis.json at /etc/tendermint/genesis.json or on path, specified at config.toml.

(3) state in the docs that they must be equal?

ethanfrey commented 7 years ago

Was there any decision on this @ebuchman ?

I remember the discussion, but I think you decided something on it, can you add that info here and I'll make sure it is done as it should be.

ethanfrey commented 7 years ago

This is how it looks now by default. I think this is a good solution. Please re-open this issue if I am wrong.

{
  "app_hash": "",
  "chain_id": "test_chain_id",
  "genesis_time": "0001-01-01T00:00:00.000Z",
  "validators": [
    {
      "amount": 10,
      "name": "",
      "pub_key": {
        "type": "ed25519",
        "data": "7B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30"
      }
    }
  ],
  "app_options": {
    "accounts": [{
      "pub_key": {
        "type": "ed25519",
        "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
      },
      "coins": [
        {
          "denom": "mycoin",
          "amount": 9007199254740992
        }
      ]
    }]
  }
}