How to add a new feature proposal in consensus-specs¶
Table of Contents¶
- A. Make it executable for linter checks
- 1. Create a folder under
./specs/_features
- 2. Choose the "previous fork" to extend: usually, use the scheduled or the latest mainnet fork version.
- 3. Write down your proposed
beacon-chain.md
change - 4. Add
fork.md
- 5. Make it executable
- B: Make it executable for pytest and test generator
- 1. [Optional] Add
light-client/*
docs if you updated the content ofBeaconBlock
- 2. Add the mainnet and minimal presets and update the configs
- 3. Update
context.py
- 4. Update
constants.py
- 5. Update
genesis.py
: - 6. Update CI configurations
- Others
- Bonus
- Need help?
A. Make it executable for linter checks¶
1. Create a folder under ./specs/_features
¶
For example, if it's an EIP-9999
CL spec, you can create a ./specs/_features/eip9999
folder.
2. Choose the "previous fork" to extend: usually, use the scheduled or the latest mainnet fork version.¶
For example, if the latest fork is Capella, use ./specs/capella
content as your "previous fork".
3. Write down your proposed beacon-chain.md
change¶
- You can either use Beacon Chain Spec Template, or make a copy of the latest fork content and then edit it.
- Tips:
- We use
doctoc
tool to generate the table of content. - The differences between "Constants", "Configurations", and "Presets":
- Constants: The constant that should never be changed.
- Configurations: The settings that we may change for different networks.
- Presets: The settings that we may change for testing.
- Readability and simplicity are more important than efficiency and optimization.
- Use simple Python rather than the fancy Python dark magic.
- We use
4. Add fork.md
¶
You can refer to the previous fork's fork.md
file.
5. Make it executable¶
- Update Pyspec
constants.py
with the new feature name. - Update helpers for
setup.py
for building the spec:- Update
pysetup/constants.py
with the new feature name as Pyspecconstants.py
defined. - Update
pysetup/spec_builders/__init__.py
. Implement a new<FEATURE_NAME>SpecBuilder
inpysetup/spec_builders/<FEATURE_NAME>.py
with the new feature name. e.g.,EIP9999SpecBuilder
. Append it to thespec_builders
list. - Update
pysetup/md_doc_paths.py
: add the path of the new markdown files inget_md_doc_paths
function if needed.
- Update
- Update
PREVIOUS_FORK_OF
setting in bothtest/helpers/constants.py
andpysetup/md_doc_paths.py
.- NOTE: since these two modules (the pyspec itself and the spec builder tool) must be separate, the fork sequence setting has to be defined again.
B: Make it executable for pytest and test generator¶
1. [Optional] Add light-client/*
docs if you updated the content of BeaconBlock
¶
- You can refer to the previous fork's
light-client/*
file. - Add the path of the new markdown files in
pysetup/md_doc_paths.py
'sget_md_doc_paths
function.
2. Add the mainnet and minimal presets and update the configs¶
- Add presets:
presets/mainnet/<new-feature-name>.yaml
andpresets/minimal/<new-feature-name>.yaml
- Update configs:
configs/mainnet.yaml
andconfigs/minimal.yaml
3. Update context.py
¶
- [Optional] Add
with_<new-feature-name>_and_later
decorator for writing pytest cases. e.g.,with_capella_and_later
.
4. Update constants.py
¶
- Add
<NEW_FEATURE>
toALL_PHASES
andTESTGEN_FORKS
5. Update genesis.py
:¶
We use create_genesis_state
to create the default state
in tests.
- If the given feature changes
BeaconState
fields, you have to set the initial values by adding:
- If the given feature changes
ExecutionPayload
fields, you have to set the initial values by updatingget_sample_genesis_execution_payload_header
helper.
6. Update CI configurations¶
- Update GitHub Actions config
- Update
pyspec-tests.strategy.matrix.version
list by adding new feature to it
- Update
- Update CircleCI config
- Add new job to the
workflows.test_spec.jobs
- Add new job to the
Others¶
Bonus¶
- Add
validator.md
if honest validator behavior changes with the new feature.
Need help?¶
You can tag spec elves for cleaning up your PR. 🧚