cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.07k stars 3.49k forks source link

[Bug]: Unable to start a new network with v0.47.1 #15915

Closed george-aj closed 1 year ago

george-aj commented 1 year ago

Summary of Bug

Unable to start a new v0.47.1 network with these commands: https://docs.cosmos.network/v0.47/run-node/run-node (Note: Had to remove "genesis" from all relevant commands.)

Error gotten:

panic: invalid chain-id on InitChain; expected: , got: localtemp

goroutine 13 [running]:
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).InitChain(0x40?, {{0x673c4c3, 0xedbd532e1, 0x0}, {0xc002166640, 0x9}, 0xc0021749e0, {0x47f5a18, 0x0, 0x0}, ...})
        /home/geo/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.1/baseapp/abci.go:38 +0xab4
github.com/cometbft/cometbft/abci/client.(*localClient).InitChainSync(0xc00219f1a0, {{0x673c4c3, 0xedbd532e1, 0x0}, {0xc002166640, 0x9}, 0xc0021749e0, {0x47f5a18, 0x0, 0x0}, ...})
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/abci/client/local_client.go:275 +0x118
github.com/cometbft/cometbft/proxy.(*appConnConsensus).InitChainSync(0xc002160ba0, {{0x673c4c3, 0xedbd532e1, 0x0}, {0xc002166640, 0x9}, 0xc0021749e0, {0x47f5a18, 0x0, 0x0}, ...})
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/proxy/app_conn.go:85 +0x137
github.com/cometbft/cometbft/consensus.(*Handshaker).ReplayBlocks(_, {{{0xb, 0x0}, {0x273b1f9, 0x6}}, {0xc002166640, 0x9}, 0x1, 0x0, {{0x0, ...}, ...}, ...}, ...)
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/consensus/replay.go:319 +0xf18
github.com/cometbft/cometbft/consensus.(*Handshaker).Handshake(0xc0010d9b98, {0x32b3e20, 0xc000c7aa80})
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/consensus/replay.go:268 +0x3ca
github.com/cometbft/cometbft/node.doHandshake({_, _}, {{{0xb, 0x0}, {0x273b1f9, 0x6}}, {0xc002166640, 0x9}, 0x1, 0x0, ...}, ...)
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/node/node.go:328 +0x198
github.com/cometbft/cometbft/node.NewNode(0xc000db3080, {0x32864a0, 0xc002172d20}, 0xc00213d480, {0x32768a0, 0xc002161710}, 0x1?, 0x47f5a18?, 0xc00213d650, {0x329d448, ...}, ...)
        /home/geo/go/pkg/mod/github.com/cometbft/cometbft@v0.37.0/node/node.go:778 +0x56d
github.com/cosmos/cosmos-sdk/server.startInProcess(_, {{0x0, 0x0, 0x0}, {0x32b2960, 0xc000f223c0}, 0x0, {0x0, 0x0}, {0x32bce40, ...}, ...}, ...)
        /home/geo/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.1/server/start.go:315 +0x7af
github.com/cosmos/cosmos-sdk/server.StartCmd.func2.2()
        /home/geo/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.1/server/start.go:151 +0x58
github.com/cosmos/cosmos-sdk/server.wrapCPUProfile.func2()
        /home/geo/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.1/server/start.go:551 +0x29
created by github.com/cosmos/cosmos-sdk/server.wrapCPUProfile
        /home/geo/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.1/server/start.go:550 +0x24a

In genesis.json I do have "localtemp" as the chain-id.

Am able to start a new v0.47.0 network with the above link and with the same genesis.

Version

v0.47.1 I think it might be related to this check: https://github.com/cosmos/cosmos-sdk/blob/f0018246f1071350be2a7e6c6eaab490f113e4b5/baseapp/abci.go#L41

from this change: https://github.com/cosmos/cosmos-sdk/commit/6a0358607411cd83d22c6f1deea69f399f803007

Steps to Reproduce

Follow these steps, but omit "genesis" when doing an add-genesis-account, gentx or collect-gentxs: https://docs.cosmos.network/v0.47/run-node/run-node

julienrbrt commented 1 year ago

Could you please post the version of simapp or the app (simd version --long) you are using?

but omit "genesis" when doing an add-genesis-account, gentx or collect-gentxs

This sounds weird to me because these command are now under the genesis sub-command, so they do not work without genesis on v0.47.x+

george-aj commented 1 year ago

Could you please post the version of simapp or the app (simd version --long) you are using?

but omit "genesis" when doing an add-genesis-account, gentx or collect-gentxs

This sounds weird to me because these command are now under the genesis sub-command, so they do not work without genesis on v0.47.x+

Here you go:

build_deps:
- cloud.google.com/go@v0.110.0
- cloud.google.com/go/compute/metadata@v0.2.3
- cloud.google.com/go/iam@v0.12.0
- cloud.google.com/go/storage@v1.29.0
- cosmossdk.io/api@v0.3.1
- cosmossdk.io/core@v0.5.1
- cosmossdk.io/depinject@v1.0.0-alpha.3
- cosmossdk.io/errors@v1.0.0-beta.7
- cosmossdk.io/math@v1.0.0
- cosmossdk.io/tools/rosetta@v0.2.1
- filippo.io/edwards25519@v1.0.0
- github.com/99designs/keyring@v1.2.1 => github.com/cosmos/keyring@v1.2.0
- github.com/ChainSafe/go-schnorrkel@v0.0.0-20200405005733-88cbf1b4c40d
- github.com/CosmWasm/wasmd@v0.40.0-tf.rc2 => github.com/notional-labs/wasmd@v0.40.0-tf.rc2
- github.com/CosmWasm/wasmvm@v1.2.1
- github.com/armon/go-metrics@v0.4.1
- github.com/aws/aws-sdk-go@v1.44.203
- github.com/beorn7/perks@v1.0.1
- github.com/bgentry/go-netrc@v0.0.0-20140422174119-9fd32a8b3d3d
- github.com/bgentry/speakeasy@v0.1.1-0.20220910012023-760eaf8b6816
- github.com/btcsuite/btcd/btcec/v2@v2.3.2
- github.com/cenkalti/backoff/v4@v4.1.3
- github.com/cespare/xxhash/v2@v2.2.0
- github.com/chzyer/readline@v1.5.1
- github.com/cockroachdb/apd/v2@v2.0.2
- github.com/coinbase/rosetta-sdk-go/types@v1.0.0
- github.com/cometbft/cometbft@v0.37.0
- github.com/cometbft/cometbft-db@v0.7.0
- github.com/confio/ics23/go@v0.9.0
- github.com/cosmos/btcutil@v1.0.5
- github.com/cosmos/cosmos-proto@v1.0.0-beta.2
- github.com/cosmos/cosmos-sdk@v0.47.1
- github.com/cosmos/go-bip39@v1.0.0
- github.com/cosmos/gogogateway@v1.2.0
- github.com/cosmos/gogoproto@v1.4.7
- github.com/cosmos/iavl@v0.20.0
- github.com/cosmos/ibc-go/v7@v7.0.0
- github.com/cosmos/ics23/go@v0.9.1-0.20221207100636-b1abd8678aab
- github.com/cosmos/interchain-accounts@v0.5.1
- github.com/cosmos/ledger-cosmos-go@v0.12.2
- github.com/cosmos/rosetta-sdk-go@v0.10.0
- github.com/creachadair/taskgroup@v0.4.2
- github.com/davecgh/go-spew@v1.1.1
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.1.0
- github.com/desertbit/timer@v0.0.0-20180107155436-c41aec40b27f
- github.com/docker/distribution@v2.8.1+incompatible
- github.com/dvsekhvalnov/jose2go@v1.5.0
- github.com/felixge/httpsnoop@v1.0.2
- github.com/fsnotify/fsnotify@v1.6.0
- github.com/go-kit/kit@v0.12.0
- github.com/go-kit/log@v0.2.1
- github.com/go-logfmt/logfmt@v0.6.0
- github.com/godbus/dbus@v0.0.0-20190726142602-4481cbc300e2
- github.com/gogo/googleapis@v1.4.1
- github.com/gogo/protobuf@v1.3.2
- github.com/golang/groupcache@v0.0.0-20210331224755-41bb18bfe9da
- github.com/golang/mock@v1.6.0
- github.com/golang/protobuf@v1.5.3
- github.com/golang/snappy@v0.0.4
- github.com/google/btree@v1.1.2
- github.com/google/go-cmp@v0.5.9
- github.com/google/gofuzz@v1.2.0
- github.com/google/orderedcode@v0.0.1
- github.com/google/uuid@v1.3.0
- github.com/googleapis/enterprise-certificate-proxy@v0.2.3
- github.com/googleapis/gax-go/v2@v2.7.0
- github.com/gorilla/handlers@v1.5.1
- github.com/gorilla/mux@v1.8.0
- github.com/gorilla/websocket@v1.5.0
- github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0
- github.com/grpc-ecosystem/grpc-gateway@v1.16.0
- github.com/gsterjov/go-libsecret@v0.0.0-20161001094733-a6f4afe4910c
- github.com/gtank/merlin@v0.1.1
- github.com/gtank/ristretto255@v0.1.2
- github.com/hashicorp/go-cleanhttp@v0.5.2
- github.com/hashicorp/go-getter@v1.7.0
- github.com/hashicorp/go-immutable-radix@v1.3.1
- github.com/hashicorp/go-safetemp@v1.0.0
- github.com/hashicorp/go-version@v1.6.0
- github.com/hashicorp/golang-lru@v0.5.5-0.20210104140557-80c98217689d
- github.com/hashicorp/hcl@v1.0.0
- github.com/hdevalence/ed25519consensus@v0.1.0
- github.com/huandu/skiplist@v1.2.0
- github.com/iancoleman/orderedmap@v0.2.0
- github.com/improbable-eng/grpc-web@v0.15.0
- github.com/jmespath/go-jmespath@v0.4.0
- github.com/json-iterator/go@v1.1.12
- github.com/klauspost/compress@v1.16.3
- github.com/lib/pq@v1.10.7
- github.com/libp2p/go-buffer-pool@v0.1.0
- github.com/magiconair/properties@v1.8.7
- github.com/manifoldco/promptui@v0.9.0
- github.com/mattn/go-isatty@v0.0.17
- github.com/matttproud/golang_protobuf_extensions@v1.0.4
- github.com/mimoo/StrobeGo@v0.0.0-20210601165009-122bf33a46e0
- github.com/minio/highwayhash@v1.0.2
- github.com/mitchellh/go-homedir@v1.1.0
- github.com/mitchellh/go-testing-interface@v1.14.1
- github.com/mitchellh/mapstructure@v1.5.0
- github.com/modern-go/concurrent@v0.0.0-20180306012644-bacd9c7ef1dd
- github.com/modern-go/reflect2@v1.0.2
- github.com/mtibben/percent@v0.2.1
- github.com/opencontainers/go-digest@v1.0.0
- github.com/pelletier/go-toml/v2@v2.0.6
- github.com/pkg/errors@v0.9.1
- github.com/pmezard/go-difflib@v1.0.0
- github.com/prometheus/client_golang@v1.14.0
- github.com/prometheus/client_model@v0.3.0
- github.com/prometheus/common@v0.40.0
- github.com/prometheus/procfs@v0.9.0
- github.com/rakyll/statik@v0.1.7
- github.com/rcrowley/go-metrics@v0.0.0-20201227073835-cf1acfcdf475
- github.com/rs/cors@v1.8.3
- github.com/spf13/afero@v1.9.3
- github.com/spf13/cast@v1.5.0
- github.com/spf13/cobra@v1.6.1
- github.com/spf13/jwalterweatherman@v1.1.0
- github.com/spf13/pflag@v1.0.5
- github.com/spf13/viper@v1.15.0
- github.com/strangelove-ventures/async-icq/v7@v7.0.0-20230317170414-3c3da64f93d4
- github.com/strangelove-ventures/packet-forward-middleware/v7@v7.0.0-20230321175727-de5b28b4b6ca
- github.com/stretchr/testify@v1.8.2
- github.com/subosito/gotenv@v1.4.2
- github.com/syndtr/goleveldb@v1.0.1-0.20220721030215-126854af5e6d
- github.com/tendermint/go-amino@v0.16.0
- github.com/tidwall/btree@v1.6.0
- github.com/ulikunitz/xz@v0.5.11
- github.com/zondax/hid@v0.9.1
- github.com/zondax/ledger-go@v0.14.1
- go.opencensus.io@v0.24.0
- golang.org/x/crypto@v0.7.0
- golang.org/x/exp@v0.0.0-20230321023759-10a507213a29
- golang.org/x/net@v0.8.0
- golang.org/x/oauth2@v0.5.0
- golang.org/x/sys@v0.6.0
- golang.org/x/term@v0.6.0
- golang.org/x/text@v0.8.0
- golang.org/x/xerrors@v0.0.0-20220907171357-04be3eba64a2
- google.golang.org/api@v0.110.0
- google.golang.org/genproto@v0.0.0-20230216225411-c8e22ba71e44
- google.golang.org/grpc@v1.53.0
- google.golang.org/protobuf@v1.29.1
- gopkg.in/ini.v1@v1.67.0
- gopkg.in/yaml.v2@v2.4.0
- gopkg.in/yaml.v3@v3.0.1
- nhooyr.io/websocket@v1.8.6
- pgregory.net/rapid@v0.5.5
- sigs.k8s.io/yaml@v1.3.0
build_tags: netgo,ledger
commit: 5ef26d6e0b769cc0afdf20bdf929114f5d42a165
cosmos_sdk_version: v0.47.1
go: go version go1.20.3 linux/amd64
name: temporal
server_name: temporald
version: ""
george-aj commented 1 year ago

Could you please post the version of simapp or the app (simd version --long) you are using?

but omit "genesis" when doing an add-genesis-account, gentx or collect-gentxs

This sounds weird to me because these command are now under the genesis sub-command, so they do not work without genesis on v0.47.x+

In addition the genesis sub command is missing:

temporald --help
Wasm Daemon (server)

Usage:
  temporald [command]

Available Commands:
  add-genesis-account Add a genesis account to genesis.json
  collect-gentxs      Collect genesis txs and output a genesis.json file
  config              Create or query an application CLI configuration file
  debug               Tool for helping with debugging your application
  export              Export state to JSON
  gentx               Generate a genesis tx carrying a self delegation
  help                Help about any command
  init                Initialize private validator, p2p, genesis, and application configuration files
  keys                Manage your application's keys
  migrate             Migrate genesis to a specified target version
  prune               Prune app history states by keeping the recent heights and deleting old heights
  query               Querying subcommands
  rollback            rollback cosmos-sdk and tendermint state by one height
  rosetta             spin up a rosetta server
  start               Run the full node
  status              Query remote node for status
  tendermint          Tendermint subcommands
  testnet             subcommands for starting or configuring local testnets
  tx                  Transactions subcommands
  validate-genesis    validates the genesis file at the default location or at the location passed as an arg
  version             Print the application binary version information

Flags:
  -h, --help                help for temporald
      --home string         directory for config and data (default "/home/geo/.temporald")
      --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

Use "temporald [command] --help" for more information about a command.

temporald genesis --help
Error: unknown command "genesis" for "temporald"
Run 'temporald --help' for usage.
julienrbrt commented 1 year ago

Ok, given that you do not use simapp, the “missing” genesis command is simply due to your app having a different configuration in its root.go. You should check your root.go and compare it with simapp: https://github.com/cosmos/cosmos-sdk/blob/v0.47.1/simapp/simd/cmd/root.go#L177-L184. That being said, would you mind verifying the baseapp options you are using and ensure that baseapp.SetChainID is set? You can always use the SDK helpers (https://github.com/cosmos/cosmos-sdk/blob/v0.47.1/simapp/simd/cmd/root.go#L261) that contains all the necessary options.

george-aj commented 1 year ago

The chain_id is not being set and when I do baseapp.SetChainID("localtemp") all is well, but how do I get the chain-id from the genesis.json file?

julienrbrt commented 1 year ago

If you use our helpers, then it will do that automatically; otherwise, you can replicate the logic: https://github.com/cosmos/cosmos-sdk/blob/828794e85cb6b337dd43a084323ae41277d942a7/server/util.go#L440-L449 https://github.com/cosmos/cosmos-sdk/blob/828794e85cb6b337dd43a084323ae41277d942a7/server/util.go#L488 It reads a flag or the genesis.

george-aj commented 1 year ago

Thank you @julienrbrt, that did it.