Skip to content

Commit

Permalink
testnet: Add flag for time between blocks (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitsalis authored May 1, 2023
1 parent f7c9e04 commit 3a88d87
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/babylond/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net"
"os"
"path/filepath"
"time"

appparams "github.com/babylonchain/babylon/app/params"
bbn "github.com/babylonchain/babylon/types"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand All @@ -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,
)
},
}
Expand All @@ -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, 5, "Time between blocks in seconds")
addGenesisFlags(cmd)

return cmd
Expand All @@ -142,6 +146,7 @@ func InitTestnet(
numValidators int,
btcNetwork string,
additionalAccount bool,
timeBetweenBlocks uint64,
genesisParams GenesisParams,
) error {

Expand Down Expand Up @@ -187,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)
Expand Down

0 comments on commit 3a88d87

Please sign in to comment.