Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator set addresses need to be exported #6528

Closed
4 tasks
michaelfig opened this issue Jun 28, 2020 · 2 comments · Fixed by #6529
Closed
4 tasks

Validator set addresses need to be exported #6528

michaelfig opened this issue Jun 28, 2020 · 2 comments · Fixed by #6529

Comments

@michaelfig
Copy link
Contributor

Summary of Bug

I'm using daemon export --for-zero-height > export.json and it creates a file with a validator set with the following excerpt:

{
  "validators": [
    {
      "address": "",
      "name": "local-chain",
      "power": "50",
      "pub_key": {
        "type": "tendermint/PubKeyEd25519",
        "value": "vrT5BFcl5qnykM/v6dqZ+ZHD+0SMdZL67BHrsO1R+qs="
      }
    }
  ]
}

Note the empty "address": "" entry. When I start the new chain, the RPC for the genesis (curl http://localhost:26657/genesis) contains "address": "4688325E1761CAC253216A789DC895947C08F8EE".

This discrepancy causes my clients to fail, since they don't calculate the same GCI hash as for the exported genesis.json.

Version

current master - 43837b1

Steps to Reproduce

  1. Let a chain run for a little, then stop it.
  2. daemon export --for-zero-height > export.json
  3. jq .validators[].address egenesis.json

Note that the addresses are all empty strings.

I found a fix for this, but don't have the bandwidth to walk it through the cosmos-sdk PR process:

diff --git a/x/staking/genesis.go b/x/staking/genesis.go
index 8bd5ef6d6..4cb8dd95b 100644
--- a/x/staking/genesis.go
+++ b/x/staking/genesis.go
@@ -185,9 +185,10 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
 func WriteValidators(ctx sdk.Context, keeper keeper.Keeper) (vals []tmtypes.GenesisValidator) {
        keeper.IterateLastValidators(ctx, func(_ int64, validator exported.ValidatorI) (stop bool) {
                vals = append(vals, tmtypes.GenesisValidator{
-                       PubKey: validator.GetConsPubKey(),
-                       Power:  validator.GetConsensusPower(),
-                       Name:   validator.GetMoniker(),
+                       Address: validator.GetConsAddr().Bytes(),
+                       PubKey:  validator.GetConsPubKey(),
+                       Power:   validator.GetConsensusPower(),
+                       Name:    validator.GetMoniker(),
                })
 
                return false

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

Thanks @michaelfig, feel free to open a PR if you have the ability since you already posted the diff.

@michaelfig
Copy link
Contributor Author

Thanks @michaelfig, feel free to open a PR if you have the ability since you already posted the diff.

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants