From 8756a0d184c8782558cec49d96fbb7d684c33bbd Mon Sep 17 00:00:00 2001 From: Vitalis Salis Date: Tue, 31 Jan 2023 17:43:20 +0300 Subject: [PATCH 1/2] feat: Add testnet CLI arg for specifying the time between blocks --- cmd/babylond/cmd/testnet.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index 683499ae9..642eaa68c 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -10,6 +10,7 @@ import ( "net" "os" "path/filepath" + "time" appparams "github.com/babylonchain/babylon/app/params" bbn "github.com/babylonchain/babylon/types" @@ -53,6 +54,7 @@ var ( flagStartingIPAddress = "starting-ip-address" flagBtcNetwork = "btc-network" flagAdditionalSenderAccount = "additional-sender-account" + flagTimeBetweenBlocks = "time-between-blocks-seconds" ) // TestnetCmd initializes all files for tendermint testnet and application @@ -88,6 +90,7 @@ Example: algo, _ := cmd.Flags().GetString(flags.FlagKeyType) btcNetwork, _ := cmd.Flags().GetString(flagBtcNetwork) additionalAccount, _ := cmd.Flags().GetBool(flagAdditionalSenderAccount) + timeBetweenBlocks, _ := cmd.Flags().GetUint64(flagTimeBetweenBlocks) if err != nil { return errors.New("base Bitcoin header height should be a uint64") } @@ -102,7 +105,7 @@ Example: return InitTestnet( clientCtx, cmd, config, mbm, genBalIterator, outputDir, genesisCliArgs.ChainID, minGasPrices, nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators, - btcNetwork, additionalAccount, genesisParams, + btcNetwork, additionalAccount, timeBetweenBlocks, genesisParams, ) }, } @@ -117,6 +120,7 @@ Example: cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") cmd.Flags().String(flagBtcNetwork, string(bbn.BtcSimnet), "Bitcoin network to use. Available networks: simnet, testnet, regtest, mainnet") cmd.Flags().Bool(flagAdditionalSenderAccount, false, "If there should be additional pre funded account per validator") + cmd.Flags().Uint64(flagTimeBetweenBlocks, 10, "Time between blocks in seconds") addGenesisFlags(cmd) return cmd @@ -142,6 +146,7 @@ func InitTestnet( numValidators int, btcNetwork string, additionalAccount bool, + timeBetweenBlocks uint64, genesisParams GenesisParams, ) error { @@ -162,6 +167,8 @@ func InitTestnet( babylonConfig.API.EnableUnsafeCORS = true babylonConfig.GRPC.Address = "0.0.0.0:9090" babylonConfig.GRPCWeb.Address = "0.0.0.0:9091" + // Time between blocks + babylonConfig.Consensus.TimeoutCommit = time.Second * time.Duration(timeBetweenBlocks) var ( genAccounts []authtypes.GenesisAccount From ef1453046b41e3b61f5fa42086a9af6ab343f145 Mon Sep 17 00:00:00 2001 From: Vitalis Salis Date: Fri, 28 Apr 2023 14:46:17 +0300 Subject: [PATCH 2/2] fix --- cmd/babylond/cmd/testnet.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index 642eaa68c..6f3ac6cc1 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -120,7 +120,7 @@ Example: cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") cmd.Flags().String(flagBtcNetwork, string(bbn.BtcSimnet), "Bitcoin network to use. Available networks: simnet, testnet, regtest, mainnet") cmd.Flags().Bool(flagAdditionalSenderAccount, false, "If there should be additional pre funded account per validator") - cmd.Flags().Uint64(flagTimeBetweenBlocks, 10, "Time between blocks in seconds") + cmd.Flags().Uint64(flagTimeBetweenBlocks, 5, "Time between blocks in seconds") addGenesisFlags(cmd) return cmd @@ -167,8 +167,6 @@ func InitTestnet( babylonConfig.API.EnableUnsafeCORS = true babylonConfig.GRPC.Address = "0.0.0.0:9090" babylonConfig.GRPCWeb.Address = "0.0.0.0:9091" - // Time between blocks - babylonConfig.Consensus.TimeoutCommit = time.Second * time.Duration(timeBetweenBlocks) var ( genAccounts []authtypes.GenesisAccount @@ -194,6 +192,8 @@ func InitTestnet( nodeConfig.Instrumentation.Prometheus = true // Set the number of simultaneous connections to unlimited nodeConfig.Instrumentation.MaxOpenConnections = 0 + // Time between blocks + nodeConfig.Consensus.TimeoutCommit = time.Second * time.Duration(timeBetweenBlocks) if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil { _ = os.RemoveAll(outputDir)