update docs with config usage

This commit is contained in:
protolambda 2021-05-18 21:31:27 +02:00
parent 90c4a7599b
commit 48e1ef193a
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
2 changed files with 8 additions and 15 deletions

View File

@ -6,13 +6,13 @@ For configuration, see [Configs documentation](../../../../../configs/README.md)
```python
from eth2spec.config import config_util
from eth2spec.phase0.mainnet import as spec
from eth2spec.phase0 import mainnet as spec
from pathlib import Path
# To load the default configurations
config_util.load_defaults(Path("eth2.0-specs/configs")) # change path to point to equivalent of specs `configs` dir.
# After loading the defaults, a config can be chosen: 'mainnet', 'minimal', or custom network config (by file path)
spec.config = spec.Configuration(**config_util.load_config_file('mytestnet.yaml'))
spec.config = spec.Configuration(**config_util.load_config_file(Path('mytestnet.yaml')))
```
Note: previously the testnet config files included both preset and runtime-configuration data.

View File

@ -176,21 +176,14 @@ reveal_deadlines_setting: -- optional, can have 2 different values:
1: `process_reveal_deadlines` is OFF.
```
##### `config.yaml`
## Config
The runtime-configurables may be different for specific tests.
When present, this replaces the default runtime-config that comes with the otherwise compile-time preset settings.
A configuration is a separate YAML file.
Separation of configuration and tests aims to:
- Prevent duplication of configuration
- Make all tests easy to upgrade (e.g. when a new config constant is introduced)
- Clearly define which constants to use
- Be easily shareable between clients, for cross-client short- or long-lived testnets
- Minimize the amount of different constants permutations to compile as a client.
*Note*: Some clients prefer compile-time constants and optimizations.
They should compile for each configuration once, and run the corresponding tests per build target.
- Include constants to coordinate forking with
The format is described in [`/configs`](../../configs/README.md#format).
The format matches that of the `mainnet_config.yaml` and `minimal_config.yaml`,
see the [`/configs`](../../configs/README.md#format) documentation.
Config values that are introduced at a later fork may be omitted from tests of previous forks.
## Config sourcing