Skip to content

Commit

Permalink
fix: testnet command minor issues (#91)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
RafilxTenfen authored Sep 26, 2024
1 parent 0aa58d7 commit 83fb0e7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
22 changes: 20 additions & 2 deletions cmd/babylond/cmd/custom_babylon_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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(),
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/babylond/cmd/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 1 addition & 15 deletions cmd/babylond/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/babylond/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion contrib/images/babylond/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/amd64, ubuntu-24.04)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/amd64, ubuntu-24.04)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/arm64, ubuntu-24.04-arm64)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/arm64, ubuntu-24.04-arm64)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/amd64, ubuntu-24.04)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/amd64, ubuntu-24.04)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/arm64, ubuntu-24.04-arm64)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 32 in contrib/images/babylond/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build (linux/arm64, ubuntu-24.04-arm64)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/initialization/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83fb0e7

Please sign in to comment.