Skip to content

[Bug]: v0.50 init cmd uses wrong json marshaller #18477

@nhannamsiu

Description

@nhannamsiu

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

This is how init cmd saves genesis file on v0.47. It uses correct cometbft json pkg to marshal.

func (genDoc *GenesisDoc) SaveAs(file string) error {
	genDocBytes, err := cmtjson.MarshalIndent(genDoc, "", "  ")
	if err != nil {
		return err
	}
	return cmtos.WriteFile(file, genDocBytes, 0644)
}

This is for v0.50.1. It uses default golang json pkg to marshal in x/genutil/types/genesis.go

func (ag *AppGenesis) SaveAs(file string) error {
	appGenesisBytes, err := json.MarshalIndent(ag, "", "  ")
	if err != nil {
		return err
	}

	return os.WriteFile(file, appGenesisBytes, 0o600)
}

This led to confusing error when we tried to run the node, especially after upgrading to v0.50.1, which breaks many stuff.

Cosmos SDK Version

v0.50.1

How to reproduce?

  1. Run init command on both v0.47.x and v0.50.x to generate genesis files.
  2. Compare 2 files and see that on v0.47.x it's "initial_height": **"1"** while on v0.50.x it's "initial_height": **1**

Metadata

Metadata

Assignees

Labels

S:needs more infoThis bug can't be addressed until more information is provided by the reporter.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions