2021-08-18 23:11:38 +00:00
|
|
|
# Consensus specs config util
|
2020-01-25 00:26:10 +00:00
|
|
|
|
2021-05-19 15:15:34 +00:00
|
|
|
For run-time configuration, see [Configs documentation](../../../../../configs/README.md).
|
2020-01-25 00:26:10 +00:00
|
|
|
|
2021-05-19 15:15:34 +00:00
|
|
|
For compile-time presets, see [Presets documentation](../../../../../presets/README.md)
|
|
|
|
and the `build-targets` flag for the `pyspec` distutils command.
|
|
|
|
|
|
|
|
## Config usage:
|
2020-01-25 00:26:10 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from eth2spec.config import config_util
|
2021-05-18 19:31:27 +00:00
|
|
|
from eth2spec.phase0 import mainnet as spec
|
2021-05-07 12:12:14 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
2021-05-18 10:48:42 +00:00
|
|
|
# To load the default configurations
|
2021-08-18 23:11:38 +00:00
|
|
|
config_util.load_defaults(Path("consensus-specs/configs")) # change path to point to equivalent of specs `configs` dir.
|
2021-05-18 10:48:42 +00:00
|
|
|
# After loading the defaults, a config can be chosen: 'mainnet', 'minimal', or custom network config (by file path)
|
2021-05-18 19:31:27 +00:00
|
|
|
spec.config = spec.Configuration(**config_util.load_config_file(Path('mytestnet.yaml')))
|
2020-01-25 00:26:10 +00:00
|
|
|
```
|
|
|
|
|
2021-05-07 12:12:14 +00:00
|
|
|
Note: previously the testnet config files included both preset and runtime-configuration data.
|
2021-05-18 10:48:42 +00:00
|
|
|
The new config loader is compatible with this: all config vars are loaded from the file,
|
2021-05-19 15:15:34 +00:00
|
|
|
but those that have become presets can be ignored.
|