Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace phase0 types #2073

Merged
merged 7 commits into from
Feb 19, 2021
Merged

Namespace phase0 types #2073

merged 7 commits into from
Feb 19, 2021

Conversation

wemeetagain
Copy link
Member

This namespaces ssz types under config.types.phase0 or import {phase0} from "@chainsafe/lodestar-types";
This allows us to always refer unambiguously to a specific version of a type.
It also allows us to add types for future HFs without breaking the 'backward compatibility' of the existing types.

This PR creates IPhase0Params and IPhase0SSZTypes and integrates them in the params and types libraries in a standard way.

Future HF params are expected to define new params and never update the value of a pre-existing param. IBeaconParams will be the union of all HF params.
(eg: type IBeaconParams = IPhase0Params & IHFParams ....;)

Future HF ssz types are expected to define new types and possibly update existing types (but only by adding additional fields to those types).
IBeaconSSZTypes will have a separate namespace for each HF that allows for unambiguously selecting a type at a specific version.
(eg: type IBeaconSSZTypes = { phase0: IPhase0SSZTypes; hf: IHFSSZTypes };)
These same namespaces are exported from the root of the @chainsafe/lodestar-types to access the typescript types.
(eg: import {phase0, hf} from "@chainsafe/lodestar-types";)

For improved ergonomics, a few tweaks have been made.
Primitive types are also available directly on IBeaconSSZTypes and are also exported from the roof of @chainsafe/lodestar-types. This list of un-namespaced types may only ever grow to include types that we know will never change, to protect backwards compatibility.

Additionally, phase0 typescript types have been re-exported under phase0 exports in @chainsafe/lodestar-beacon-state-transition. This allows importing a single phase0 object from @chainsafe/lodestar-beacon-state-transition to both access phase0 state transition functions AND phase0 typescript types.

@github-actions github-actions bot added Api scope-networking All issues related to networking, gossip, and libp2p. labels Feb 19, 2021
@codeclimate
Copy link

codeclimate bot commented Feb 19, 2021

Code Climate has analyzed commit 301d609 and detected 36 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 36

View more on Code Climate.

Copy link
Member

@mpetrunic mpetrunic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSo many changed files, even octotree extension has frozen haha

@wemeetagain wemeetagain merged commit 14ae103 into master Feb 19, 2021
@wemeetagain wemeetagain deleted the cayman/phase0-types branch February 19, 2021 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope-networking All issues related to networking, gossip, and libp2p.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants