From 83fb0e789f8ab18e3a4be17d0f363c3068ecf391 Mon Sep 17 00:00:00 2001 From: Rafael Tenfen Date: Thu, 26 Sep 2024 10:40:55 -0300 Subject: [PATCH] fix: testnet command minor issues (#91) - Add default gen state to `ibc` module - Add `jq` to dockerfile, needed to local deployments - Specify min gas prices as default `1ubbn` in a single place --- cmd/babylond/cmd/custom_babylon_config.go | 22 ++++++++++++++++++++-- cmd/babylond/cmd/genesis.go | 4 ++++ cmd/babylond/cmd/root.go | 16 +--------------- cmd/babylond/cmd/testnet.go | 2 +- contrib/images/babylond/Dockerfile | 2 +- test/e2e/initialization/node.go | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cmd/babylond/cmd/custom_babylon_config.go b/cmd/babylond/cmd/custom_babylon_config.go index 055f6069f..6b4e6c9f9 100644 --- a/cmd/babylond/cmd/custom_babylon_config.go +++ b/cmd/babylond/cmd/custom_babylon_config.go @@ -2,8 +2,12 @@ package cmd import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + sdkmath "cosmossdk.io/math" serverconfig "github.com/cosmos/cosmos-sdk/server/config" + sdk "github.com/cosmos/cosmos-sdk/types" + appparams "github.com/babylonlabs-io/babylon/app/params" bbn "github.com/babylonlabs-io/babylon/types" ) @@ -25,9 +29,23 @@ type BabylonAppConfig struct { BtcConfig BtcConfig `mapstructure:"btc-config"` } -func DefaultBabylonConfig() *BabylonAppConfig { +func DefaultBabylonAppConfig() *BabylonAppConfig { + baseConfig := *serverconfig.DefaultConfig() + // The SDK's default minimum gas price is set to "" (empty value) inside + // app.toml. If left empty by validators, the node will halt on startup. + // However, the chain developer can set a default app.toml value for their + // validators here. + // + // In summary: + // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their + // own app.toml config, + // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their + // own app.toml to override, or use this default value. + // + // In app, we set the min gas prices to 0. + baseConfig.MinGasPrices = sdk.NewCoin(appparams.BaseCoinUnit, sdkmath.NewInt(1)).String() return &BabylonAppConfig{ - Config: *serverconfig.DefaultConfig(), + Config: baseConfig, Wasm: wasmtypes.DefaultWasmConfig(), BtcConfig: defaultBabylonBtcConfig(), } diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index 1a5acab27..1bd94e11e 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -28,6 +28,8 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctypes "github.com/cosmos/ibc-go/v8/modules/core/types" "github.com/spf13/cobra" appparams "github.com/babylonlabs-io/babylon/app/params" @@ -224,6 +226,8 @@ func PrepareGenesis( } genesisState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankGenState) + genesisState[ibcexported.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibctypes.DefaultGenesisState()) + appGenStateJSON, err := json.MarshalIndent(genesisState, "", " ") if err != nil { diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index efc9304c1..e5979db3a 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -153,22 +153,8 @@ func initAppConfig() (string, interface{}) { // Optionally allow the chain developer to overwrite the SDK's default // server config. - babylonConfig := DefaultBabylonConfig() + babylonConfig := DefaultBabylonAppConfig() babylonTemplate := DefaultBabylonTemplate() - // The SDK's default minimum gas price is set to "" (empty value) inside - // app.toml. If left empty by validators, the node will halt on startup. - // However, the chain developer can set a default app.toml value for their - // validators here. - // - // In summary: - // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their - // own app.toml config, - // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their - // own app.toml to override, or use this default value. - // - // In app, we set the min gas prices to 0. - babylonConfig.MinGasPrices = "0ubbn" - return babylonTemplate, babylonConfig } diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index e0c0d918d..2e26b57b6 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -177,7 +177,7 @@ func InitTestnet( nodeIDs := make([]string, numValidators) valKeys := make([]*privval.ValidatorKeys, numValidators) - babylonConfig := DefaultBabylonConfig() + babylonConfig := DefaultBabylonAppConfig() babylonConfig.MinGasPrices = minGasPrices babylonConfig.API.Enable = true babylonConfig.API.Address = "tcp://0.0.0.0:1317" diff --git a/contrib/images/babylond/Dockerfile b/contrib/images/babylond/Dockerfile index ce6a6564a..7aa4602a0 100644 --- a/contrib/images/babylond/Dockerfile +++ b/contrib/images/babylond/Dockerfile @@ -26,7 +26,7 @@ RUN LEDGER_ENABLED=$LEDGER_ENABLED \ FROM debian:bookworm-slim AS wasm-link -RUN apt-get update && apt-get install -y wget bash +RUN apt-get update && apt-get install -y wget bash jq # Label should match your github repo LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylond:${VERSION}" diff --git a/test/e2e/initialization/node.go b/test/e2e/initialization/node.go index 17eddb24d..b43ba62b0 100644 --- a/test/e2e/initialization/node.go +++ b/test/e2e/initialization/node.go @@ -120,7 +120,7 @@ func (n *internalNode) createAppConfig(nodeConfig *NodeConfig) { // set application configuration appCfgPath := filepath.Join(n.configDir(), "config", "app.toml") - appConfig := cmd.DefaultBabylonConfig() + appConfig := cmd.DefaultBabylonAppConfig() appConfig.BaseConfig.Pruning = nodeConfig.Pruning appConfig.BaseConfig.PruningKeepRecent = nodeConfig.PruningKeepRecent