Testing on 0.28.1 candidate on develop...
I noticed that running collect-gen-txs will strip out some of the parameters, like the slashing parameters. This happens during cdc.UnmarshalJSON() call in GaiaAppGenState(), which doesn't return an error, yet the slashing parameters are stripped.
This may be a bug in go-amino JSON, not sure.
Also, I noticed discrepancies in the following fields, before and after collecting gentxs...
< "genesis_time": "2018-12-11T22:04:09.804347Z",
---
> "genesis_time": "2018-12-17T10:51:00.47518914Z",
6,7c6,7
< "max_bytes": "50000",
< "max_gas": "1500000"
---
> "max_bytes": "22020096",
> "max_gas": "-1"
3867c3867
< "loose_tokens": "2550000.0000000000",
---
> "loose_tokens": "5200000.0000000000",
This looks like some larger issue with failing the parse... investigating...
never mind, this is because we changed the json field names to include underscores (_) instead of dashes (-)
Reopening as I'm still seeing this behavior.
Also another issue: the way not_bonded_tokens gets set, it doesn't add from 0 but it adds from the last value.
Also another issue: the way not_bonded_tokens gets set, it doesn't add from 0 but it adds from the last value.
Could this possibly be causing this?
for readers convenience:
for _, acc := range genesisState.Accounts {
for _, coin := range acc.Coins {
if coin.Denom == genesisState.StakingData.Params.BondDenom {
stakingData.Pool.NotBondedTokens = stakingData.Pool.NotBondedTokens.
Add(coin.Amount) // increase the supply
}
}
}
Trying to reproduce (unsuccessfully):
alessio@bangalter:~/.../cosmos/cosmos-sdk$ gaiad init alessio 2>/dev/null && echo OK
OK
alessio@bangalter:~/.../cosmos/cosmos-sdk$ gaiad add-genesis-account foo 2000000000000000stake && echo OK
OK
alessio@bangalter:~/.../cosmos/cosmos-sdk$ gaiad gentx --name foo 2>/dev/null && echo OK
OK
alessio@bangalter:~/.../cosmos/cosmos-sdk$ cp ~/.gaiad/config/genesis.json genesis-pre-collect.json
alessio@bangalter:~/.../cosmos/cosmos-sdk$ gaiad collect-gentxs 2>/dev/null && echo OK
OK
alessio@bangalter:~/.../cosmos/cosmos-sdk$ cp ~/.gaiad/config/genesis.json genesis-post-collect.json
alessio@bangalter:~/.../cosmos/cosmos-sdk$ diff -u genesis-pre-collect.json genesis-post-collect.json
--- genesis-pre-collect.json 2019-04-02 01:34:24.656237002 +0100
+++ genesis-post-collect.json 2019-04-02 01:34:43.652338467 +0100
@@ -1,5 +1,5 @@
{
- "genesis_time": "2019-04-02T00:33:34.881218732Z",
+ "genesis_time": "2019-04-02T00:34:34.135270762Z",
"chain_id": "test-chain-KGILpJ",
"consensus_params": {
"block": {
@@ -51,7 +51,7 @@
},
"staking": {
"pool": {
- "not_bonded_tokens": "0",
+ "not_bonded_tokens": "2000000000000000",
"bonded_tokens": "0"
},
"params": {
@@ -140,6 +140,52 @@
"signing_infos": {},
"missed_blocks": {}
},
- "gentxs": null
+ "gentxs": [
+ {
+ "type": "auth/StdTx",
+ "value": {
+ "msg": [
+ {
+ "type": "cosmos-sdk/MsgCreateValidator",
+ "value": {
+ "description": {
+ "moniker": "alessio",
+ "identity": "",
+ "website": "",
+ "details": ""
+ },
+ "commission": {
+ "rate": "0.100000000000000000",
+ "max_rate": "0.200000000000000000",
+ "max_change_rate": "0.010000000000000000"
+ },
+ "min_self_delegation": "1",
+ "delegator_address": "cosmos1dj4ghqevu9y788gkc6gafdpgx6umh8qplffye4",
+ "validator_address": "cosmosvaloper1dj4ghqevu9y788gkc6gafdpgx6umh8qp6aa34x",
+ "pubkey": "cosmosvalconspub1zcjduepqvasvgnhpjj484qtdkdyvk40tpc236phv45k8zfmd770u3jemrd2q283jrt",
+ "value": {
+ "denom": "stake",
+ "amount": "100000000"
+ }
+ }
+ }
+ ],
+ "fee": {
+ "amount": null,
+ "gas": "200000"
+ },
+ "signatures": [
+ {
+ "pub_key": {
+ "type": "tendermint/PubKeySecp256k1",
+ "value": "AiIF6j9Ri0GMrE2gCgmnkwVaeFMZDtgBOF0Wa7xXT4w/"
+ },
+ "signature": "HAEgjCpZnOkP2UUpwsSiwEy0qaj2xGiw08JzaejwdiwW+l7mDuoFYxepNbPow8Av61K+4yHq1/2DIS/poTvkGg=="
+ }
+ ],
+ "memo": "[email protected]:26656"
+ }
+ }
+ ]
}
}
\ No newline at end of file
@alessio
Could this possibly be causing this?
Yes I believe that's it, it should be initialized to zero before adding.
Also, did you try updating the max_bytes/max_gas to a custom value before collect-gentxs? If you try that and it still doesn't cause an issue, I think we can close this. But the loose_tokens i believe is still an issue.
alessio@bangalter:~/work/cosmos-sdk$ rm -rf ~/.gaiad/
alessio@bangalter:~/work/cosmos-sdk$ gaiad init alessio 2>/dev/null && echo OK
OK
alessio@bangalter:~/work/cosmos-sdk$ gaiad add-genesis-account foo 2000000000000000stake && echo OK
alessio@bangalter:~/work/cosmos-sdk$ jq .consensus_params.block ~/.gaiad/config/genesis.json
{
"max_bytes": "22020096",
"max_gas": "-1",
"time_iota_ms": "1000"
}
Then I modified max_gas and max_bytes:
alessio@bangalter:~/work/cosmos-sdk$ jq .consensus_params.block ~/.gaiad/config/genesis.json
{
"max_bytes": "92020096",
"max_gas": "1234567",
"time_iota_ms": "1000"
}
I carried on:
alessio@bangalter:~/work/cosmos-sdk$ gaiad gentx --name foo 2>/dev/null && echo OK
OK
alessio@bangalter:~/work/cosmos-sdk$ cp ~/.gaiad/config/genesis.json genesis-pre-collect.json
alessio@bangalter:~/work/cosmos-sdk$ gaiad collect-gentxs 2>/dev/null && echo OK
OK
alessio@bangalter:~/work/cosmos-sdk$ cp ~/.gaiad/config/genesis.json genesis-post-collect.json
alessio@bangalter:~/work/cosmos-sdk$ diff -u genesis-pre-collect.json genesis-post-collect.json
--- genesis-pre-collect.json 2019-04-05 19:00:24.197349192 +0100
+++ genesis-post-collect.json 2019-04-05 19:00:42.009468134 +0100
@@ -1,10 +1,10 @@
{
- "genesis_time": "2019-04-05T17:57:00.68329048Z",
+ "genesis_time": "2019-04-05T18:00:33.100507555Z",
"chain_id": "test-chain-wyAXQS",
"consensus_params": {
"block": {
- "max_bytes": "92020096",
- "max_gas": "1234567",
+ "max_bytes": "22020096",
+ "max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {
@@ -51,7 +51,7 @@
},
"staking": {
"pool": {
- "not_bonded_tokens": "0",
+ "not_bonded_tokens": "2000000000000000",
"bonded_tokens": "0"
},
"params": {
@@ -140,6 +140,52 @@
"signing_infos": {},
"missed_blocks": {}
},
- "gentxs": null
+ "gentxs": [
+ {
+ "type": "auth/StdTx",
+ "value": {
+ "msg": [
+ {
+ "type": "cosmos-sdk/MsgCreateValidator",
+ "value": {
+ "description": {
+ "moniker": "alessio",
+ "identity": "",
+ "website": "",
+ "details": ""
+ },
+ "commission": {
+ "rate": "0.100000000000000000",
+ "max_rate": "0.200000000000000000",
+ "max_change_rate": "0.010000000000000000"
+ },
+ "min_self_delegation": "1",
+ "delegator_address": "cosmos1dj4ghqevu9y788gkc6gafdpgx6umh8qplffye4",
+ "validator_address": "cosmosvaloper1dj4ghqevu9y788gkc6gafdpgx6umh8qp6aa34x",
+ "pubkey": "cosmosvalconspub1zcjduepqz2mrzuy6uct3cvv5fd9km3nwkx75rjzr2lx82x89x596hujrktjqu9jphw",
+ "value": {
+ "denom": "stake",
+ "amount": "100000000"
+ }
+ }
+ }
+ ],
+ "fee": {
+ "amount": null,
+ "gas": "200000"
+ },
+ "signatures": [
+ {
+ "pub_key": {
+ "type": "tendermint/PubKeySecp256k1",
+ "value": "AiIF6j9Ri0GMrE2gCgmnkwVaeFMZDtgBOF0Wa7xXT4w/"
+ },
+ "signature": "6PHDBM2JI+N89Pv3Ty96AAjd3GdmDHOcFJFuXu3BVOQE1YktNYSfICRrGYTyUcylGQ43xsryynbRMxpdZ0IsZA=="
+ }
+ ],
+ "memo": "[email protected]:26656"
+ }
+ }
+ ]
}
-}
+}
\ No newline at end of file
Hence on:
Also, did you try updating the max_bytes/max_gas to a custom value before collect-gentxs?
You're right, that's a bug.
I think I got it:
In cmd/gaia/init/utils.go:
// ExportGenesisFile creates and writes the genesis configuration to disk. An
// error is returned if building or writing the configuration to file fails.
func ExportGenesisFile(
genFile, chainID string, validators []types.GenesisValidator, appState json.RawMessage,
) error {
genDoc := types.GenesisDoc{
ChainID: chainID,
Validators: validators,
AppState: appState,
}
if err := genDoc.ValidateAndComplete(); err != nil {
return err
}
return genDoc.SaveAs(genFile)
}
Such function, which is called by genAppStateFromConfig() at the very end of the new genDoc generation, ignores pre-existing values in genesis.json.
This is now partially fixed. The only question that remains is re: not bonded tokens @jaekwon
@alexanderbez hold on, there is a bit which I am unclear about. Can you reopen and remove this from the milestone please?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.