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

Fix: Defaults for onChain Parameters to Prevent Halt on Not Set Values Expected to Exist #1866

Closed
gzukel opened this issue Mar 8, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@gzukel
Copy link
Contributor

gzukel commented Mar 8, 2024

Describe the Bug
A recent system upgrade encountered an issue where an emissions parameter was not set, leading to a halt of the binary. To prevent such occurrences, it is proposed that all parameters expected by the Chain should have default values unless explicitly set or overridden. This approach would ensure that the addition of new parameters does not cause a system panic due to missing state information, by instantiating a default value when the parameter is not present in the state. However, if the parameter is explicitly set, the system should utilize the specified value.

To Reproduce

  • Conduct a system upgrade without setting a new emissions parameter that is expected to have a value. Thus, when the binary starts and tries to load the parameter from state it errors on json parsing because it expected a json key to exist where it didn't.
  • Observe the resulting binary halt due to the absence of this parameter.

Expected Behavior
The system should automatically assign a default value to any new parameter that is not explicitly set in the state during an upgrade. This action would prevent the system from halting and ensure smooth operation, even when new parameters are introduced.

Screenshots/Logs

panic: UnmarshalJSON cannot decode empty bytes

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.Get({{0x3dbd230, 0xc0014561d0}, 0xc000b81390, {0x3d8a470, 0xc001e42340}, {0x3d8a4c0, 0xc001e423f0}, {0xc00055c5a0, 0x9, 0x24}, ...}, ...)
	/root/go/pkg/mod/github.com/cosmos/[email protected]/x/params/types/subspace.go:110 +0x2c7
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.GetParamSet({{0x3dbd230, 0xc0014561d0}, 0xc000b81390, {0x3d8a470, 0xc001e42340}, {0x3d8a4c0, 0xc001e423f0}, {0xc00055c5a0, 0x9, 0x24}, ...}, ...)
	/root/go/pkg/mod/github.com/cosmos/[email protected]/x/params/types/subspace.go:239 +0x106
github.com/zeta-chain/zetacore/x/emissions/keeper.Keeper.GetParams(...)
	/go/src/github.com/zeta-chain/node/x/emissions/keeper/params.go:10
github.com/zeta-chain/zetacore/x/emissions.BeginBlocker({{0x3da86b8, 0xc0000560b0}, {0x3dbdcb0, 0xc00364df00}, {{0xb, 0x0}, {0xc010d25e20, 0x10}, 0x1fa86a, {0x2b019d02, ...}, ...}, ...}, ...)
	/go/src/github.com/zeta-chain/node/x/emissions/abci.go:22 +0x2e8
github.com/zeta-chain/zetacore/x/emissions.AppModule.BeginBlock(...)
	/go/src/github.com/zeta-chain/node/x/emissions/module.go:172
github.com/cosmos/cosmos-sdk/types/module.(*Manager).BeginBlock(_, {{0x3da86b8, 0xc0000560b0}, {0x3dbdcb0, 0xc00364df00}, {{0xb, 0x0}, {0xc010d25e20, 0x10}, 0x1fa86a, ...}, ...}, ...)
	/root/go/pkg/mod/github.com/cosmos/[email protected]/types/module/module.go:484 +0x1bb
github.com/zeta-chain/zetacore/app.(*App).BeginBlocker(...)
	/go/src/github.com/zeta-chain/node/app/app.go:618
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).BeginBlock(_, {{0xc001e32fa0, 0x20, 0x20}, {{0xb, 0x0}, {0xc010d25e20, 0x10}, 0x1fa86a, {0x2b019d02, ...}, ...}, ...})
	/root/go/pkg/mod/github.com/cosmos/[email protected]/baseapp/abci.go:183 +0x843
github.com/tendermint/tendermint/abci/client.(*localClient).BeginBlockSync(_, {{0xc001e32fa0, 0x20, 0x20}, {{0xb, 0x0}, {0xc010d25e20, 0x10}, 0x1fa86a, {0x2b019d02, ...}, ...}, ...})
	/root/go/pkg/mod/github.com/cometbft/[email protected]/abci/client/local_client.go:280 +0x118
github.com/tendermint/tendermint/proxy.(*appConnConsensus).BeginBlockSync(_, {{0xc001e32fa0, 0x20, 0x20}, {{0xb, 0x0}, {0xc010d25e20, 0x10}, 0x1fa86a, {0x2b019d02, ...}, ...}, ...})
	/root/go/pkg/mod/github.com/cometbft/[email protected]/proxy/app_conn.go:81 +0x55
github.com/tendermint/tendermint/state.execBlockOnProxyApp({0x3daa130?, 0xc0058c0180}, {0x3db44c0, 0xc0018d4460}, 0xc001792000, {0x3dbf248, 0xc082724018}, 0x1fa869?)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/state/execution.go:307 +0x51d
github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(_, {{{0xb, 0x0}, {0xc0018d06b8, 0x7}}, {0xc0018d06f0, 0x10}, 0x1, 0x1fa869, {{0xc0446a20a0, ...}, ...}, ...}, ...)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/state/execution.go:140 +0x171
github.com/tendermint/tendermint/consensus.(*Handshaker).replayBlock(_, {{{0xb, 0x0}, {0xc0018d06b8, 0x7}}, {0xc0018d06f0, 0x10}, 0x1, 0x1fa869, {{0xc0446a20a0, ...}, ...}, ...}, ...)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/consensus/replay.go:503 +0x23c
github.com/tendermint/tendermint/consensus.(*Handshaker).ReplayBlocks(_, {{{0xb, 0x0}, {0xc0018d06b8, 0x7}}, {0xc0018d06f0, 0x10}, 0x1, 0x1fa869, {{0xc0446a20a0, ...}, ...}, ...}, ...)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/consensus/replay.go:416 +0x7ae
github.com/tendermint/tendermint/consensus.(*Handshaker).Handshake(0xc01139cf90, {0x3dc1610, 0xc001b72ea0})
	/root/go/pkg/mod/github.com/cometbft/[email protected]/consensus/replay.go:268 +0x3d4
github.com/tendermint/tendermint/node.doHandshake({_, _}, {{{0xb, 0x0}, {0xc0018d06b8, 0x7}}, {0xc0018d06f0, 0x10}, 0x1, 0x1fa869, ...}, ...)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/node/node.go:329 +0x1b8
github.com/tendermint/tendermint/node.NewNode(0xc000da32c0, {0x3da0600, 0xc001b63860}, 0xc001c68230, {0x3d80880, 0xc04296a480}, 0x1?, 0x5736700?, 0xc001c68470, {0x3daa130, ...}, ...)
	/root/go/pkg/mod/github.com/cometbft/[email protected]/node/node.go:779 +0x597
github.com/zeta-chain/zetacore/server.startInProcess(_, {{0x0, 0x0, 0x0}, {0x3dd4ac0, 0xc001b39b60}, 0x0, {0xc001b702c0, 0x10}, {0x3dc6458, ...}, ...}, ...)
	/go/src/github.com/zeta-chain/node/server/start.go:380 +0xf47
github.com/zeta-chain/zetacore/server.StartCmd.func2(0xc001a42f00?, {0xc001b394a0?, 0x0?, 0x3?})
	/go/src/github.com/zeta-chain/node/server/start.go:164 +0x2a5
github.com/spf13/cobra.(*Command).execute(0xc001a42f00, {0xc001b39410, 0x3, 0x3})
	/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc001782c00)
	/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:985
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x26bd600?, {0x0, 0x0}, {0xc001485460, 0x1a})
	/root/go/pkg/mod/github.com/cosmos/[email protected]/server/cmd/execute.go:36 +0x20f
main.main()
	/go/src/github.com/zeta-chain/node/cmd/zetacored/main.go:19 +0x35

Environment (please complete the following information):
ALL

@gzukel gzukel added the bug Something isn't working label Mar 8, 2024
@gzukel gzukel changed the title Fix: Defaults for onChain Parameters to prevent halt on not set. Fix: Defaults for onChain Parameters to Prevent Halt on Not Set Values Expected to Exist Mar 8, 2024
@lumtis
Copy link
Member

lumtis commented Mar 11, 2024

FYI We already defined default parameters. The issue is the param module that panic when reading a key for a value that has not been previously set. Preventing the panic prevents the chain halt: #1864

@lumtis lumtis closed this as completed Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants