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

Problem with null genutil when exporting state #5765

Closed
4 tasks
toml01 opened this issue Mar 8, 2020 · 11 comments · Fixed by #5775
Closed
4 tasks

Problem with null genutil when exporting state #5765

toml01 opened this issue Mar 8, 2020 · 11 comments · Fixed by #5775
Labels

Comments

@toml01
Copy link

toml01 commented Mar 8, 2020

Summary of Bug

Exporting state:

enigmad export --for-zero-height --height=40000 > a.json

Then when validating, I'm getting the following error:

$ enigmad validate-genesis a.json 
validating genesis file at a.json
ERROR: error validating genesis file a.json: failed to unmarshal genutil genesis state: UnmarshalJSON cannot decode empty bytes

Then looked in a.json (the file exported), and noticed:

"genutil":null

If I'm not mistaken, it should be "genutil": {} right?

The full exported state:
https://gist.github.com/toml01/3711dfa85b26d37916080040b67ef827

This bug looks similar to #5086 , should've been fixed in 0.38 I believe?

Version

v0.38.1

Steps to Reproduce

Run a chain for some time, then just export the state with --for-zero-height and --height and check for genutil


For Admin Use

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

Indeed, it should be [], but this has already been fixed. What version are you using?

@assafmo
Copy link
Contributor

assafmo commented Mar 9, 2020

v0.38.1

@alexanderbez
Copy link
Contributor

Interesting. The DefaultGenesisState for x/genutil should populate with [].

@toml01
Copy link
Author

toml01 commented Mar 9, 2020

If I manually replace the null with [] I get:

➜  ~ enigmad validate-genesis a.json 
validating genesis file at a.json
ERROR: error validating genesis file a.json: failed to unmarshal genutil genesis state: json: cannot unmarshal array into Go value of type map[string]json.RawMessage

However, when I put {} it works.

➜  ~ enigmad validate-genesis a.json 
validating genesis file at a.json
File at genesis-enigma-testnet-1-3.json is a valid genesis file

@alexanderbez
Copy link
Contributor

Sorry, I should've clarified. This is what I'd expect for default/empty state:

"genutil": {
  "gentxs": []
}

Does that not work?

@alexanderbez
Copy link
Contributor

alexanderbez commented Mar 9, 2020

However, upon export, it's still null so this is indeed a bug:

// ExportGenesis returns the exported genesis state as raw bytes for the genutil
// module.
func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONMarshaler) json.RawMessage {
	return nil
}

This needs to return the state.

@toml01
Copy link
Author

toml01 commented Mar 9, 2020

Yes what you suggested:

"genutil": {
  "gentxs": []
}

works too.

@alexanderbez
Copy link
Contributor

Thanks for the report @toml01. Easy fix, sorry for this.

@toml01
Copy link
Author

toml01 commented Mar 9, 2020

Cool, I can open a quick PR for this

@alexanderbez
Copy link
Contributor

Yes, please!

@toml01
Copy link
Author

toml01 commented Mar 10, 2020

Thanks @alexanderbez ! Didn't have a chance to look at it yet, sorry.

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

Successfully merging a pull request may close this issue.

3 participants