Add spec references, a mapping of spec to implementation#15592
Add spec references, a mapping of spec to implementation#15592prestonvanloon merged 4 commits intoOffchainLabs:developfrom
Conversation
|
Thanks for the PR. I am wondering how we maintain this? Will it be difficult to update in the future? Perhaps you could share a blurb about how you created this PR so we can refer to it in the future when it is time to update it with new spec changes. |
I don't believe it will be difficult to maintain. Creating this was pretty manual & not a good representation of future efforts. When adding support for a new specification (eg from
$ ethspecify check --path=specrefs
MISSING: functions.is_data_available#fulu
- name: is_data_available#fulu
sources: []
spec: |
<spec fn="is_data_available" fork="fulu" />
- name: is_data_available#fulu
sources:
- file: beacon-chain/blockchain/process_block.go
search: func (s *Service) isDataAvailable(
- file: beacon-chain/blockchain/process_block.go
search: func (s *Service) areDataColumnsAvailable(
spec: |
<spec fn="is_data_available" fork="fulu" />
- name: is_data_available#fulu
sources:
- file: beacon-chain/blockchain/process_block.go
search: func (s *Service) isDataAvailable(
- file: beacon-chain/blockchain/process_block.go
search: func (s *Service) areDataColumnsAvailable(
spec: |
<spec fn="is_data_available" fork="fulu" hash="2062e9c6">
def is_data_available(beacon_block_root: Root) -> bool:
# `retrieve_column_sidecars` is implementation and context dependent, replacing
# `retrieve_blobs_and_proofs`. For the given block root, it returns all column
# sidecars to sample, or raises an exception if they are not available.
# The p2p network does not guarantee sidecar retrieval outside of
# `MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS` epochs.
column_sidecars = retrieve_column_sidecars(beacon_block_root)
return all(
verify_data_column_sidecar(column_sidecar)
and verify_data_column_sidecar_kzg_proofs(column_sidecar)
for column_sidecar in column_sidecars
)
</spec>
|
|
One more example, see the changes made here & the files below: |
prestonvanloon
left a comment
There was a problem hiding this comment.
Great, thanks for this!
…s#15592) * Add spec references, a mapping of spec to implementation * Add changelog fragment --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
…s#15592) * Add spec references, a mapping of spec to implementation * Add changelog fragment --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
…s#15592) * Add spec references, a mapping of spec to implementation * Add changelog fragment --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
…s#15592) * Add spec references, a mapping of spec to implementation * Add changelog fragment --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
**Motivation** This PR adds a directory with specification references. These are used to map specification items (configs, presets, functions, etc) to client implementations (code in Lodestar). These specification references are meant to (1) help developers keep track of specification changes and (2) make it easier for third-parties (eg EF Protocol Security) to verify clients adhere to the specifications. Our team is working to do this for all clients. * Consensys/teku#9731 * OffchainLabs/prysm#15592 * sigp/lighthouse#8549 *Note*: The function mappings are the only weak-spot. It's quite difficult to map some of these because of implementation differences & the fact that not everything is implemented (eg Gloas functions). The specref functions will most likely require some additional work, but this PR does identify most functions. **AI Assistance Disclosure** - [x] External Contributors: I have read the [contributor guidelines](https://github.com/ChainSafe/lodestar/blob/unstable/CONTRIBUTING.md#ai-assistance-notice) and disclosed my usage of AI below. Yes, I used Claude Code to identify/map most of these. Fixes: #7477 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Nico Flaig <nflaig@protonmail.com>
What type of PR is this?
Documentation
What does this PR do? Why is it needed?
This PR adds a directory with specification references. These are used to map specification items (configs, presets, functions, etc) to client implementations (code in Prysm). This is much less invasive than my original idea of adding spec tags all across the codebase. These specification references are meant to (1) help developers keep track of specification changes and (2) make it easier for third-parties (eg EF Protocol Security) to verify clients adhere to the specifications.
Note, we recently did the same thing for Teku. View that PR for more details.
Other notes for review
If we decide to merge this PR, we can remove the existing
spec-checkertool.Depends on #15590.
Acknowledgements