# Improve config file for cdk-node
**IMPORTANT** : This is a draft version, some ideas are contradictory and another part is not clear how to implements. Is just a starting point
The proposal is to have a more friendly config file.
Currently the config file have next issue:
- Duplicated keys
- Some keys are copied on runtime and another not
- Exposure external config struct directly
Objectives:
- Keep simple for users
- Keep flexible (so you can modify anything)
## Avoid duplicated vars
The idea is that the values of keys can use another defined key.
Pro:
- Avoid duplication values
- You can override concrete values to avoid using common value
Cons:
- Cycles: The problem is that is a var have an indirection to another var that have an indirection to first var it would create a cycle, for example:
```
VAR1={{VAR2}}
VAR2={{VAR1}}
```
- kurtosis templating
- More complexity
Example:
```
[Common]
DataPath= "/tmp/"
L1URL= "http://127.0.0.1:8123"
[LastGERSync]
URL= "{{.Common.L1URL}}"
DBPath = "{{.Common.dataPath}}/lastgersync"
```
So, if you need you can override specific value but, by default, use the common value
## Versioning of config-file
The first line of config file must be the version. This allow us:
Pro:
- Do code for support previous config files
- Allow to deprecate it
Cons:
- More complexity
- If try to support multiples version can be a bit a mess
```
VersionFile = 0.0.1
```
## Validate that config file doesnt have unknown keys
- Add all values on `default.go`
- If it detect any value that are not contained on default values means that is a unknown value and maybe it's a mistake
## Stop setting default values on concrete config files
The idea is that on Kurtosis or IP don't set all possible variable, just the ones that we need to override for this concrete instalation.
This allow us to modify runtime parameters in a more easy way for all IP
## Command to generate a full config-file
- To check values is a good idea to be able to generate a fullconfig file (the one in `default.go`)
## Remove unused config structs
- For example: file: `config/network.go` struct: `NetworkConfig.Genesis`
## Don't publish directly config files of libraries
Currently we have 2 external libraries with his own configuration structs. It make sense that cdk-node define the corresponding structs and copy to the external structs.
Pro:
- High control on contents
- Coherence on config file
Cons:
- Extra complexity on copy values
Current configs:
- `EthTxManager ethtxmanager.Config`
- `Aggregator.Synchronizer syncronizerConfig.Config`
## Allow to override values from environment vars
- This is possible right now and we have to keep this behaviour
## Force values to be defined
- Some values need to be defined and can't use default ones.
- Example:
- URL for L1
- Contracts addressess
## Example of config file
This is not a full config file, just an example
### External config file
```
VersionFile = 0.0.1
[Common]
IsValidiumMode = true
ContractVersions = "banana"
ForkID = 12
DataWritePath = "/tmp/"
DataReadPath = "/etc/cdk/"
[NetworkConfig.L1]
L1URL = "http://el-1-geth-lighthouse:8545"
L1ChainID = "271828"
GenesisLxLyBlock = "61"
GenesisBlock = "78"
PolAddr = "0xEdE9cf798E0fE25D35469493f43E88FeA4a5da0E"
ZkEVMAddr = "0x1Fe038B54aeBf558638CA51C91bC8cCa06609e91"
RollupManagerAddr = "0x2F50ef6b8e8Ee4E579B17619A92dE3E2ffbD8AD2"
GlobalExitRootManagerAddr = "0x1f7ad7caA53e35b4f0D138dC5CBF91aC108a2674"
[NetworkConfig.L2]
L2URL = "http://cdk-erigon-node-001:8123"
[Log]
Level = "debug"
[SequenceSender]
L2Coinbase = "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed"
[SequenceSender.EthTxManager]
PrivateKeys = [
{Path = "{{.common.DataReadPath}}/sequencer.keystore", Password = "pSnv6Dh5s9ahuzGzH9RoCDrKAMddaX3m"},
]
```
### Internal default.go
The mandatory fields to be defined have been set to `!!Mandatody`
We have to think about how to implement this
```
VersionFile = !!Mandatody
ForkUpgradeBatchNumber = 0
ForkUpgradeNewForkId = 0
[Common]
IsValidiumMode = !!Mandatody
ContractVersions = !!Mandatody
ForkID = !!Mandatody
DataWritePath = "/tmp/"
DataReadPath = "/etc/cdk/"
[NetworkConfig.L1]
L1URL = !!Mandatody
L1ChainID = "0"
GenesisLxLyBlock = !!Mandatody
GenesisBlock = !!Mandatody
PolAddr = !!Mandatody
ZkEVMAddr = !!Mandatody
RollupManagerAddr = !!Mandatody
GlobalExitRootManagerAddr = !!Mandatody
[Log]
Environment = "development" # "production" or "development"
Level = "info"
Outputs = ["stderr"]
[Etherman]
URL = "{{.NetworkConfig.L1.L1URL}}"
[SequenceSender]
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
MaxTxSizeForL1 = 131072
L2Coinbase = !!Mandatody
PrivateKey = {Path = "{{.common.DataReadPath}}sequencer.keystore", Password = "pSnv6Dh5s9ahuzGzH9RoCDrKAMddaX3m"}
SequencesTxFileName = "{{.common.DataWritePath}}/sequencesender.json"
GasOffset = 80000
WaitPeriodPurgeTxFile = "15m"
MaxPendingTx = 1
MaxBatchesForL1 = 300
BlockFinality="FinalizedBlock"
RPCURL = "{{.NetworkConfig.L2.L2URL}}"
GetBatchWaitInterval = "10s"
(....)
```