Support min fees in a localnet and fix gaiad config (#3172)
This commit is contained in:
parent
abbd2d4dd3
commit
8211c025da
|
@ -50,6 +50,8 @@ IMPROVEMENTS
|
|||
|
||||
* Gaia
|
||||
* [\#3158](https://github.com/cosmos/cosmos-sdk/pull/3158) Validate slashing genesis
|
||||
* [\#3172](https://github.com/cosmos/cosmos-sdk/pull/3172) Support minimum fees
|
||||
in a local testnet.
|
||||
|
||||
* SDK
|
||||
* [\#3137](https://github.com/cosmos/cosmos-sdk/pull/3137) Add tag documentation
|
||||
|
@ -71,8 +73,9 @@ BUG FIXES
|
|||
* Gaia CLI (`gaiacli`)
|
||||
|
||||
* Gaia
|
||||
|
||||
* \#3148 Fix `gaiad export` by adding a boolean to `NewGaiaApp` determining whether or not to load the latest version
|
||||
* [\#3172](https://github.com/cosmos/cosmos-sdk/pull/3172) Fix parsing `gaiad.toml`
|
||||
when it already exists.
|
||||
|
||||
* SDK
|
||||
|
||||
|
|
|
@ -213,8 +213,7 @@ func (app *BaseApp) initFromMainStore(mainKey *sdk.KVStoreKey) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetMinimumFees sets the minimum fees.
|
||||
func (app *BaseApp) SetMinimumFees(fees sdk.Coins) { app.minimumFees = fees }
|
||||
func (app *BaseApp) setMinimumFees(fees sdk.Coins) { app.minimumFees = fees }
|
||||
|
||||
// NewContext returns a new Context with the correct store, the given header, and nil txBytes.
|
||||
func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context {
|
||||
|
|
|
@ -37,7 +37,7 @@ func SetMinimumFees(minFees string) func(*BaseApp) {
|
|||
if err != nil {
|
||||
panic(fmt.Sprintf("invalid minimum fees: %v", err))
|
||||
}
|
||||
return func(bap *BaseApp) { bap.SetMinimumFees(fees) }
|
||||
return func(bap *BaseApp) { bap.setMinimumFees(fees) }
|
||||
}
|
||||
|
||||
func (app *BaseApp) SetName(name string) {
|
||||
|
|
|
@ -10,15 +10,16 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
staketypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
tmconfig "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
@ -34,6 +35,7 @@ var (
|
|||
flagNodeDaemonHome = "node-daemon-home"
|
||||
flagNodeCliHome = "node-cli-home"
|
||||
flagStartingIPAddress = "starting-ip-address"
|
||||
flagMinimumFees = "minimum-fees"
|
||||
)
|
||||
|
||||
const nodeDirPerm = 0755
|
||||
|
@ -76,13 +78,19 @@ Example:
|
|||
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1",
|
||||
"Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)")
|
||||
|
||||
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
|
||||
cmd.Flags().String(
|
||||
client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created",
|
||||
)
|
||||
cmd.Flags().String(
|
||||
flagMinimumFees, fmt.Sprintf("1%s", staketypes.DefaultBondDenom), "Validator minimum fees",
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func initTestnet(config *cfg.Config, cdc *codec.Codec) error {
|
||||
func initTestnet(config *tmconfig.Config, cdc *codec.Codec) error {
|
||||
var chainID string
|
||||
|
||||
outDir := viper.GetString(flagOutputDir)
|
||||
numValidators := viper.GetInt(flagNumValidators)
|
||||
|
||||
|
@ -95,6 +103,9 @@ func initTestnet(config *cfg.Config, cdc *codec.Codec) error {
|
|||
nodeIDs := make([]string, numValidators)
|
||||
valPubKeys := make([]crypto.PubKey, numValidators)
|
||||
|
||||
gaiaConfig := srvconfig.DefaultConfig()
|
||||
gaiaConfig.MinFees = viper.GetString(flagMinimumFees)
|
||||
|
||||
var (
|
||||
accs []app.GenesisAccount
|
||||
genFiles []string
|
||||
|
@ -181,14 +192,14 @@ func initTestnet(config *cfg.Config, cdc *codec.Codec) error {
|
|||
Address: addr,
|
||||
Coins: sdk.Coins{
|
||||
sdk.NewInt64Coin(fmt.Sprintf("%stoken", nodeDirName), 1000),
|
||||
sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 150),
|
||||
sdk.NewInt64Coin(staketypes.DefaultBondDenom, 500),
|
||||
},
|
||||
})
|
||||
|
||||
msg := stake.NewMsgCreateValidator(
|
||||
sdk.ValAddress(addr),
|
||||
valPubKeys[i],
|
||||
sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 100),
|
||||
sdk.NewInt64Coin(staketypes.DefaultBondDenom, 100),
|
||||
stake.NewDescription(nodeDirName, "", "", ""),
|
||||
stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
|
||||
)
|
||||
|
@ -213,6 +224,9 @@ func initTestnet(config *cfg.Config, cdc *codec.Codec) error {
|
|||
_ = os.RemoveAll(outDir)
|
||||
return err
|
||||
}
|
||||
|
||||
gaiaConfigFilePath := filepath.Join(nodeDir, "config/gaiad.toml")
|
||||
srvconfig.WriteConfigFile(gaiaConfigFilePath, gaiaConfig)
|
||||
}
|
||||
|
||||
if err := initGenFiles(cdc, chainID, accs, genFiles, numValidators); err != nil {
|
||||
|
@ -261,7 +275,7 @@ func initGenFiles(
|
|||
}
|
||||
|
||||
func collectGenFiles(
|
||||
cdc *codec.Codec, config *cfg.Config, chainID string,
|
||||
cdc *codec.Codec, config *tmconfig.Config, chainID string,
|
||||
monikers, nodeIDs []string, valPubKeys []crypto.PubKey,
|
||||
numValidators int, outDir, nodeDirPrefix, nodeDaemonHomeName string,
|
||||
) error {
|
||||
|
|
|
@ -21,13 +21,13 @@ var configTemplate *template.Template
|
|||
|
||||
func init() {
|
||||
var err error
|
||||
tmpl := template.New("cosmosConfigFileTemplate")
|
||||
tmpl := template.New("gaiaConfigFileTemplate")
|
||||
if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// ParseConfig retrieves the default environment configuration for Cosmos.
|
||||
// ParseConfig retrieves the default environment configuration for Gaia.
|
||||
func ParseConfig() (*Config, error) {
|
||||
conf := DefaultConfig()
|
||||
err := viper.Unmarshal(conf)
|
||||
|
|
|
@ -103,18 +103,15 @@ func interceptLoadConfig() (conf *cfg.Config, err error) {
|
|||
conf, err = tcmd.ParseConfig() // NOTE: ParseConfig() creates dir/files as necessary.
|
||||
}
|
||||
|
||||
cosmosConfigFilePath := filepath.Join(rootDir, "config/gaiad.toml")
|
||||
viper.SetConfigName("cosmos")
|
||||
_ = viper.MergeInConfig()
|
||||
var cosmosConf *config.Config
|
||||
if _, err := os.Stat(cosmosConfigFilePath); os.IsNotExist(err) {
|
||||
cosmosConf, _ := config.ParseConfig()
|
||||
config.WriteConfigFile(cosmosConfigFilePath, cosmosConf)
|
||||
// create a default gaia config file if it does not exist
|
||||
gaiaConfigFilePath := filepath.Join(rootDir, "config/gaiad.toml")
|
||||
if _, err := os.Stat(gaiaConfigFilePath); os.IsNotExist(err) {
|
||||
gaiaConf, _ := config.ParseConfig()
|
||||
config.WriteConfigFile(gaiaConfigFilePath, gaiaConf)
|
||||
}
|
||||
|
||||
if cosmosConf == nil {
|
||||
_, err = config.ParseConfig()
|
||||
}
|
||||
viper.SetConfigName("gaiad")
|
||||
err = viper.MergeInConfig()
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue