How to Customize Testnet Configuration
Learn how to use the --config-changes flag with marood testnet to dynamically modify node configurations for advanced testing scenarios.
Prerequisites
- Familiarity with the `marood testnet` command.
- Basic understanding of CometBFT's `config.toml` file.
1. The `--config-changes` Flag
This flag accepts a single string containing one or more key-value pairs. The format is
"key1=value1,key2=value2".- For nested keys in
config.toml, use dot notation. For example, thetimeout_commitinside the[consensus]block is referenced asconsensus.timeout_commit. - For top-level keys like
log_level, just use the key name.
2. Example: Creating a Fast-Block Testnet
A common use case is to reduce block times for faster feedback during development. The default
timeout_commit is several seconds. Let's create a 2-node testnet where blocks are committed every 500 milliseconds.marood testnet -v 2 -o ./fast-testnet --config-changes "consensus.timeout_commit=500ms" Note: After running this, you can inspect `./fast-testnet/node0/config/config.toml` and you will see `timeout_commit = "500ms"` has been set.
3. Example: Combining Multiple Changes
You can apply multiple changes by separating them with a comma. Let's create a testnet with fast blocks and verbose debug logging.
marood testnet -v 2 -o ./debug-testnet --config-changes "consensus.timeout_commit=500ms,log_level=debug" 4. Supported Types
The configuration parser is smart enough to handle different data types based on the target field in the configuration struct:
- Durations: Use strings like
"500ms","1s","2m". - Integers: Use plain numbers like
100. - Booleans: Use
trueorfalse. - Strings: Enclose in quotes if they contain special characters, e.g.,
"info".