cosmos / gaia

Cosmos Hub
https://hub.cosmos.network
Apache License 2.0
476 stars 693 forks source link

genesis incompatibility between versions #1950

Closed greg-szabo closed 1 year ago

greg-szabo commented 1 year ago

Summary of Bug

The Cosmos Hub (cosmoshub-4) genesis file does not pass the validate-genesis test with gaiad v7.1.0. Notably:

$ gaiad-v7.1.0-darwin-amd64 validate-genesis
Error: error validating genesis file config/genesis.json: failed to unmarshal authz genesis state: EOF
Usage:
  gaiad validate-genesis [file] [flags]

Flags:
  -h, --help   help for validate-genesis

Global Flags:
      --home string         directory for config and data (default "/Users/greg/.gaia")
      --log_format string   The logging format (json|plain) (default "plain")
      --log_level string    The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
      --trace               print out full stack trace on errors

Version

v7.1.0, v7.0.1, possibly others The binary is the MacOS release from this repo.

Steps to Reproduce

# gaiad init something
$ wget -O $HOME/.gaia/config/genesis.json.gz https://github.com/cosmos/mainnet/raw/master/genesis/genesis.cosmoshub-4.json.gz
$ gunzip $HOME/.gaia/config/genesis.json.gz
$ gaiad validate-genesis

Expected resolution

I understand that newer versions of gaiad will introduce new features but we should have a way to still validate the genesis of yesteryear so a new node can start up, for example, using statesync.


For Admin Use

okwme commented 1 year ago

thanks for the issue @greg-szabo ! we ran into something similar earlier this year with the content of the bank module (https://github.com/cosmos/gaia/issues/1384). It was fixed here but I believe it came about from a bad migration of the bank module initially. This issue could come from the same thing but with the authz module based on the error.

This should be fixed but just an additional point: you don't need to have the correct genesis for statesync. In fact you can have a completely blank genesis as long as the chain-id is correct.

okwme commented 1 year ago

Actually can you confirm @greg-szabo , are you requesting the ability to validate a previous version of gaia's genesis with a more recent version? For instance gaia v6.0.0 exported genesis (cosmoshub-4) being bale to be validated by v7.1.0 gaia?

mpoke commented 1 year ago

@glnro @yaruwangway will this issue be fixed by the migration code in v8?

glnro commented 1 year ago

We fixed export on a clean genesis, I can double check on stateful genesis.

yaruwangway commented 1 year ago

Hi, I think this is still not working .failed to unmarshal authz genesis state: EOF with v8

glnro commented 1 year ago

Exported a genesis from a localnet with v8.0.0-rc3 successfully and confirmed it was a valid genesis.

yaruwangway commented 1 year ago

the genesis is from here, this is testing backward compatibility? @glnro

glnro commented 1 year ago

This isn't a bug, rather it might be a feature we may want to support in the future.

glnro commented 1 year ago

@julienrbrt is validating previous versions of genesis files something the sdk could support in the future? At present, my understanding is there's no way for the sdk to be able to know which version to validate against (except the current), so the expected behavior in this case would be that this fails validation.

julienrbrt commented 1 year ago

@julienrbrt is validating previous versions of genesis files something the sdk could support in the future? At present, my understanding is there's no way for the sdk to be able to know which version to validate against (except the current), so the expected behavior in this case would be that this fails validation.

I don't think validating a previous genesis with a new binary should be supported. IMHO if there is a breaking change in the genesis that makes it invalid with a new version, the genesis should be migrated to a valid genesis for that version.

Currently, the SDK supports genesis migration, but only for different SDK versions (simd genesis migrate 0.xx). We will eventually support the addition of genesis migration set by an app: https://github.com/cosmos/cosmos-sdk/issues/5041.

glnro commented 1 year ago

Closing this as the fix for this issue is forthcoming once the Hub updates the SDK to v0.47. #2402 acceptance criteria includes migrating and uploading a valid genesis.json that can be validated.