Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testnet: Add flag for time between blocks #134

Merged
merged 2 commits into from
May 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look to be in line with what setting is for when I read https://github.com/tendermint/tendermint/blob/v0.35.9/config/config.go#L1130-L1133

The setting is to allow some extra votes to arrive. You need +2/3 votes for a quorum, but waiting a little longer can gather more votes, which is nice. If you say you want blocks every 5 seconds, then you can't spend the entire 5 seconds waiting for new votes before starting your next round, to collect your votes.

Say it takes 2 seconds for a quorum to form on a proposed block, and you want to wait an extra 1 second before you start making the next block for more votes to arrive. Then you start making the new blocks, but you only have 2 seconds left before your target of 5 seconds is reached. If you waited 5 seconds, then it would be 7 second per block.

I also don't understand why you would want to tweak this setting all of a sudden.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's what I initially understood, but the Tendermint docs say that this configuration should be specified


if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil {
_ = os.RemoveAll(outputDir)
Expand Down