# Building Gaia-7002 genesis.json

**URL:** <https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589>\
**Category:** Validation\
**Created:** [July 25, 2018, 1:06am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589 "2018-07-25T01:06:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandrews](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlandrews](https://forum.cosmos.network/u/jlandrews)\
**Post date:** [July 25, 2018, 1:06am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/1 "2018-07-25T01:06:04Z")

</div>

To generate the genesis file for Gaia-7002, we exported the state from Gaia-7001, at height 24570 where it halted. The current version of gaiad has a [bug](https://github.com/cosmos/cosmos-sdk/issues/1799) in gaiad export, but we were able to use a [workaround](https://github.com/cosmos/cosmos-sdk/pull/1800) to successfully export the state. ([state.json](https://gist.github.com/jlandrews/8326a496fe3eb49527d88965d9cda850))

Due to bugs in gaiad v0.22.0, there were some inconsistencies in the state which we corrected.

[Builder script](https://gist.github.com/jlandrews/bd688892b369ef77edb3ad7255bb22d8)  
First we load the exported state.

```auto
import json
from hashlib import sha256
from base64 import b64decode

j = json.loads(open("7001state.json","r").read())

```

Then we removed validators who never signed blocks on Gaia-7001. This should help with time to startup of the chain and speed of consensus.

```auto
#validator addresses which hubble lists as being bonded validators but never signed a block
pks = ['28d64d33cd086452e491becfc15f3d31054db144', '26cf59b48aa6ff3a5126330782090b19bd3b0e87', '1e1a2486dce3b96e08f41d313908088ad33ed491', '1866433301a542afd800b971d6390551088a0903', '10ddf9c6aaf8e6f91f33a4fae3ebeab3c98136d2', '00122e5e691286ac03220fcee3ebec038067dded', '60229e2e273297fe00219e46dffb8f76844cdef9', 'd9e215abd1d680db4d60f3b347a07f949ea5242a', 'e33184c1eab6fb7c6ccb893963e8534c277fa842', 'd9bb73add5962326c5b8c36494dac1c3d7425db5', 'cc4c1d46ddba0912e9d6e4dd1f4a0897a945c68c', 'b3cec3cbafba428bf33fd2204e11ca2232426593', '9a03741063366e11ec0347f6c80a2891c799003f', '5a6b67f68591404c5079bebd7a6b7e046779d3b6', '4b75e0191ab777afb6787b94e256388e78d6a910', '3e504d10079dc278960c0f214235b840e23392b2', '52b590a0de161917dfa8215f990506c4df7a9d0d', '09f1395bfcdb45aa6f09cde85aa8b69246131962', 'ebcaa6886da3c8ac73cfdf8fea26e8d9b14b4e4e']

#remove validators who never came online according to hubble
j['app_state']['stake']['validators'] = [vi for vi in j['app_state']['stake']['validators'] if sha256(b64decode(vi['pub_key']['value'])).digest().hex()[:40] not in pks]
#filter out bonds to no longer existing validators
j['app_state']['stake']['bonds'] = [b for b in j['app_state']['stake']['bonds'] if b['validator_addr'] in [v['owner'] for v in j['app_state']['stake']['validators']]]

```

Due to a [bug](https://github.com/cosmos/cosmos-sdk/issues/1666), validators in Gaia-7001 were being listed as unbonded in the state, even though they had voting power. Also fixed the “do-not-modify” setting.

```auto
#set bonded status and fix do-not-modify flag on validators
for v in j['app_state']['stake']['validators']:
    desc = v["description"]
    for k,dv in desc.items():
        if dv == "[do-not-modify]":
            dv = ""
        desc[k] = dv
    v.update(status=2, description=desc)

```

We also added a validator entry for Shapeshift.

```auto
#adding a validator for shapeshift
j['app_state']['stake']['validators'].append({
  "owner": "cosmosaccaddr1ztc70khr9aghgwmuxap5y9ufavpxutjtkvhpe7",
  "pub_key": {
    "type": "tendermint/PubKeyEd25519",
    "value": "7vURd1EqPVfI/1viF/+LNm9lwaBAN/tSuoJ+Od972z0="
  },
  "revoked": False,
  "status": 2,
  "tokens": "100",
  "delegator_shares": "100",
  "description": {
    "moniker": "Project Bohr",
    "identity": "",
    "website": "",
    "details": ""
  },
  "bond_height": "0",
  "bond_intra_tx_counter": 0,
  "proposer_reward_pool": None,
  "commission": "0",
  "commission_max": "0",
  "commission_change_rate": "0",
  "commission_change_today": "0",
  "prev_bonded_tokens": "0"
})
j['app_state']['stake']['bonds'].append({
  'height': '0', 'validator_addr': 'cosmosaccaddr1ztc70khr9aghgwmuxap5y9ufavpxutjtkvhpe7', 'delegator_addr': 'cosmosaccaddr1ztc70khr9aghgwmuxap5y9ufavpxutjtkvhpe7', 'shares': '100'
})

```

Now that the data in `app_state` has been updated, we need to write the set of validators back to the object that gets passed to tendermint to start the chain.

```auto
#update main validator section to match validators from state machine
j["validators"] = [{"pub_key":v["pub_key"], "power":v["tokens"], "name":v["description"]["moniker"]} for v in j["app_state"]["stake"]["validators"]]

```

We also recalculated the totals for bonded/loose tokens, which were not properly updated to reflect the steak given to the faucet in Gaia-7001.

```auto
coinsToMap = lambda x: type(x)==list and {c["denom"]:c["amount"] for c in x} or {}

#update pool total values to be accurate
j["app_state"]["stake"]["pool"]["loose_tokens"] = str(sum([int(coinsToMap(a["coins"]).get("steak",0)) for a in j["app_state"]["accounts"]]))
j["app_state"]["stake"]["pool"]["bonded_tokens"] = str(sum([int(v["power"]) for v in j["validators"]]))

```

Finally we set misc parameters and wrote the json back to a file.

```auto
#set chain id and timestamp
j["chain_id"] = "gaia-7002"             
j["genesis_time"] = "2018-07-24T08:00:00.123456789Z"

open("7002-genesis.json","w").write(json.dumps(j, indent=2, sort_keys=True))

```

[Genesis file](https://gist.github.com/jlandrews/e7f109227ceadbc54d4dbfaf1637ccdb)

While the genesis file has been created, we’re still waiting on a final release of the software before we officially start Gaia-7002. So please stay tuned.

---

<div class="post-metadata">

**Author:** ![chris-chainflow](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/chris-chainflow/32/1530_2.png) [@chris-chainflow](https://forum.cosmos.network/u/chris-chainflow)\
**Post date:** [July 25, 2018, 1:21am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/2 "2018-07-25T01:21:30Z")

</div>

Can we assume we’re in the genesis file if we were bonded at block 24570?

---

<div class="post-metadata">

**Author:** ![jlandrews](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlandrews](https://forum.cosmos.network/u/jlandrews)\
**Post date:** [July 25, 2018, 1:38am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/3 "2018-07-25T01:38:00Z")

</div>

Yes, assuming your validator was live at some point.

---

<div class="post-metadata">

**Author:** ![jlandrews](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlandrews](https://forum.cosmos.network/u/jlandrews)\
**Post date:** [July 25, 2018, 1:39am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/4 "2018-07-25T01:39:36Z")

</div>

Heads up to anyone who downloaded the genesis file already, there was a minor error. There was a typo of “chain-id” that should have been “chain\_id”. It has been fixed now, in both the script and the resulting json file.

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/adrian/32/285_2.png) [@adrian](https://forum.cosmos.network/u/adrian)\
**Post date:** [July 25, 2018, 9:41am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/5 "2018-07-25T09:41:26Z")

</div>

Awesome job. Could you also remove all instances of “[do-not-modify]” in the validator descriptions. It seems that in case it says “[do-not-modify]” their the owner is not able to update the values.

---

<div class="post-metadata">

**Author:** ![wimel](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/wimel/32/752_2.png) [@wimel](https://forum.cosmos.network/u/wimel)\
**Post date:** [July 25, 2018, 10:01am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/6 "2018-07-25T10:01:31Z")

</div>

perfect! go to gaia-7002! 🛰

---

<div class="post-metadata">

**Author:** ![chris-chainflow](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/chris-chainflow/32/1530_2.png) [@chris-chainflow](https://forum.cosmos.network/u/chris-chainflow)\
**Post date:** [July 25, 2018, 10:10am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/7 "2018-07-25T10:10:17Z")

</div>

@jlandrews Where’s the file to  
download?

---

<div class="post-metadata">

**Author:** ![bharvest](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/bharvest/32/1042_2.png) [@bharvest](https://forum.cosmos.network/u/bharvest)\
**Post date:** [July 25, 2018, 10:24am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/8 "2018-07-25T10:24:04Z")

</div>

could you remove “cosmosaccaddr1arlpxs2ftf5hgetqxxkvd7mqdc28mmaqclyv4y” from the genesis? this is mine and i lost my private key of this.

---

<div class="post-metadata">

**Author:** ![slamper](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/slamper/32/132_2.png) [@slamper](https://forum.cosmos.network/u/slamper)\
**Post date:** [July 25, 2018, 10:40am UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/9 "2018-07-25T10:40:44Z")

</div>

Nice work.

Could you please remove this Certus.One validator: VBVHOLnWGptY26J0wqXoZI2Dnu96pccMb08zlsaxPCQ=  
and assign the 100 power to our new: 0vUHZTzJhnVDh7KJfuGt9g1uDsy0DK3BCQurhngwVos=

That would go with transferring the tokens of cosmosaccaddr1gq0qecxs8xdaarrqxxazwavwxm7qz5jzs5anvt to cosmosaccaddr1yqq6up8zyakmf6t7gg5txnyatqakj7ckkt8jfu

That’d be awesome.

---

<div class="post-metadata">

**Author:** ![chris-chainflow](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.cosmos.network/chris-chainflow/32/1530_2.png) [@chris-chainflow](https://forum.cosmos.network/u/chris-chainflow)\
**Post date:** [July 25, 2018, 1:22pm UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/10 "2018-07-25T13:22:11Z")

</div>

chainflow08’s looking good 👍

---

<div class="post-metadata">

**Author:** ![kochacolaj](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@kochacolaj](https://forum.cosmos.network/u/kochacolaj)\
**Post date:** [July 25, 2018, 2:23pm UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/11 "2018-07-25T14:23:56Z")

</div>

can u please increase steak for kochacolaj to 100? i unbonded 50 but couldnt claim then rebond them due to a bug. suyuuu had the same problem - i dont know his amount. you see [https://figment.network/cosmos/hubble/gaia-7001/validators/1E9CE94FD0BA5CFEB901F90BC658D64D85B134D2](https://figment.network/cosmos/hubble/gaia-7001/validators/1E9CE94FD0BA5CFEB901F90BC658D64D85B134D2) that i unbonded and had maturity while 7001 was healthy. thx

---

<div class="post-metadata">

**Author:** ![jlandrews](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlandrews](https://forum.cosmos.network/u/jlandrews)\
**Post date:** [July 25, 2018, 8:43pm UTC](https://forum.cosmos.network/t/building-gaia-7002-genesis-json/589/12 "2018-07-25T20:43:39Z")

</div>

Updated main post after changing script again. Previously forgot to track bond values to match updated validator state. We will be releasing the final / official genesis file through the SDK repo as usual I believe, so please don’t try to use the one posted here, it’s just for demonstration / transparency purposes.
