-
-
Notifications
You must be signed in to change notification settings - Fork 434
feat: fulu types #7774
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
Merged
Merged
feat: fulu types #7774
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
117fdf7
feat: fulu types
wemeetagain 918fd17
chore: apply suggestions from code review
wemeetagain cd424d8
feat: add params and config
wemeetagain aba16e9
chore: add validator params update
wemeetagain c2d6010
chore: remove duplicate types
wemeetagain 40e3958
chore: more duplicate types
wemeetagain 841b391
chore: update packages/params/test/unit/forkName.test.ts
wemeetagain f12f410
chore: fix types
wemeetagain 2895969
chore: standardize added primitives
wemeetagain 4e948f3
chore: apply suggestions from code review
wemeetagain ece7403
chore: remove "forkblobs"
wemeetagain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export * from "./types.js"; | ||
| import * as ssz from "./sszTypes.js"; | ||
| import * as ts from "./types.js"; | ||
| export {ts, ssz}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,258 @@ | ||
| import {ByteVectorType, ContainerType, ListBasicType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz"; | ||
| import { | ||
| BYTES_PER_FIELD_ELEMENT, | ||
| FIELD_ELEMENTS_PER_CELL, | ||
| FIELD_ELEMENTS_PER_EXT_BLOB, | ||
| KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH, | ||
| MAX_BLOB_COMMITMENTS_PER_BLOCK, | ||
| MAX_REQUEST_DATA_COLUMN_SIDECARS, | ||
| NUMBER_OF_COLUMNS, | ||
| } from "@lodestar/params"; | ||
|
|
||
| import {ssz as altairSsz} from "../altair/index.js"; | ||
| import {ssz as denebSsz} from "../deneb/index.js"; | ||
| import {ssz as electraSsz} from "../electra/index.js"; | ||
| import {ssz as phase0Ssz} from "../phase0/index.js"; | ||
| import {ssz as primitiveSsz} from "../primitive/index.js"; | ||
|
|
||
| const {BLSSignature, Root, ColumnIndex, RowIndex, Bytes32, Slot, UintNum64} = primitiveSsz; | ||
|
|
||
| export const KZGProof = denebSsz.KZGProof; | ||
| export const Blob = denebSsz.Blob; | ||
|
|
||
| export const Metadata = new ContainerType( | ||
| { | ||
| ...altairSsz.Metadata.fields, | ||
| custodyGroupCount: UintNum64, | ||
| }, | ||
| {typeName: "Metadata", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const Cell = new ByteVectorType(BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_CELL); | ||
| export const DataColumn = new ListCompositeType(Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK); | ||
| export const ExtendedMatrix = new ListCompositeType(Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK * NUMBER_OF_COLUMNS); | ||
| export const KzgCommitmentsInclusionProof = new VectorCompositeType(Bytes32, KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH); | ||
| export const KZGProofs = new ListCompositeType( | ||
| denebSsz.KZGProof, | ||
| FIELD_ELEMENTS_PER_EXT_BLOB * MAX_BLOB_COMMITMENTS_PER_BLOCK | ||
| ); | ||
|
|
||
| export const DataColumnSidecar = new ContainerType( | ||
| { | ||
| index: ColumnIndex, | ||
| column: DataColumn, | ||
| kzgCommitments: denebSsz.BlobKzgCommitments, | ||
| kzgProofs: denebSsz.KZGProofs, | ||
| signedBlockHeader: phase0Ssz.SignedBeaconBlockHeader, | ||
| kzgCommitmentsInclusionProof: KzgCommitmentsInclusionProof, | ||
| }, | ||
| {typeName: "DataColumnSidecar", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const DataColumnSidecars = new ListCompositeType(DataColumnSidecar, NUMBER_OF_COLUMNS); | ||
|
|
||
| export const MatrixEntry = new ContainerType( | ||
| { | ||
| cell: Cell, | ||
| kzgProof: denebSsz.KZGProof, | ||
| columnIndex: ColumnIndex, | ||
| rowIndex: RowIndex, | ||
| }, | ||
| {typeName: "MatrixEntry", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| // ReqResp types | ||
| // ============= | ||
|
|
||
| export const DataColumnIdentifier = new ContainerType( | ||
| { | ||
| blockRoot: Root, | ||
| index: ColumnIndex, | ||
| }, | ||
| {typeName: "DataColumnIdentifier", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const DataColumnSidecarsByRootRequest = new ListCompositeType( | ||
| DataColumnIdentifier, | ||
| MAX_REQUEST_DATA_COLUMN_SIDECARS | ||
| ); | ||
|
|
||
| export const DataColumnSidecarsByRangeRequest = new ContainerType( | ||
| { | ||
| startSlot: Slot, | ||
| count: UintNum64, | ||
| columns: new ListBasicType(ColumnIndex, NUMBER_OF_COLUMNS), | ||
| }, | ||
| {typeName: "DataColumnSidecarsByRangeRequest", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const ExecutionPayload = new ContainerType( | ||
| { | ||
| ...electraSsz.ExecutionPayload.fields, | ||
| }, | ||
| {typeName: "ExecutionPayload", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const ExecutionPayloadHeader = new ContainerType( | ||
| { | ||
| ...electraSsz.ExecutionPayloadHeader.fields, | ||
| }, | ||
| {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BeaconBlockBody = new ContainerType( | ||
| { | ||
| ...electraSsz.BeaconBlockBody.fields, | ||
| }, | ||
| {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} | ||
| ); | ||
|
|
||
| export const BeaconBlock = new ContainerType( | ||
| { | ||
| ...electraSsz.BeaconBlock.fields, | ||
| }, | ||
| {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true} | ||
| ); | ||
|
|
||
| export const SignedBeaconBlock = new ContainerType( | ||
| { | ||
| message: BeaconBlock, | ||
| signature: BLSSignature, | ||
| }, | ||
| {typeName: "SignedBeaconBlock", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BlobSidecar = new ContainerType( | ||
| { | ||
| ...denebSsz.BlobSidecar.fields, | ||
| }, | ||
| {typeName: "BlobSidecar", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BlobsBundle = new ContainerType( | ||
| { | ||
| commitments: denebSsz.BlobKzgCommitments, | ||
| proofs: KZGProofs, | ||
| blobs: denebSsz.Blobs, | ||
| }, | ||
| {typeName: "BlobsBundle", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BlindedBeaconBlockBody = new ContainerType( | ||
| { | ||
| ...electraSsz.BlindedBeaconBlockBody.fields, | ||
| }, | ||
| {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} | ||
| ); | ||
|
|
||
| export const BlindedBeaconBlock = new ContainerType( | ||
| { | ||
| ...electraSsz.BlindedBeaconBlock.fields, | ||
| }, | ||
| {typeName: "BlindedBeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true} | ||
| ); | ||
|
|
||
| export const SignedBlindedBeaconBlock = new ContainerType( | ||
| { | ||
| message: BlindedBeaconBlock, | ||
| signature: BLSSignature, | ||
| }, | ||
| {typeName: "SignedBlindedBeaconBlock", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BuilderBid = new ContainerType( | ||
| { | ||
| ...electraSsz.BuilderBid.fields, | ||
| }, | ||
| {typeName: "BuilderBid", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const SignedBuilderBid = new ContainerType( | ||
| { | ||
| message: BuilderBid, | ||
| signature: BLSSignature, | ||
| }, | ||
| {typeName: "SignedBuilderBid", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const ExecutionPayloadAndBlobsBundle = new ContainerType( | ||
| { | ||
| executionPayload: ExecutionPayload, | ||
| blobsBundle: BlobsBundle, | ||
| }, | ||
| {typeName: "ExecutionPayloadAndBlobsBundle", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BeaconState = new ContainerType( | ||
wemeetagain marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| ...electraSsz.BeaconState.fields, | ||
| }, | ||
| {typeName: "BeaconState", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientHeader = new ContainerType( | ||
| { | ||
| ...denebSsz.LightClientHeader.fields, | ||
| }, | ||
| {typeName: "LightClientHeader", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientBootstrap = new ContainerType( | ||
| { | ||
| ...electraSsz.LightClientBootstrap.fields, | ||
| }, | ||
| {typeName: "LightClientBootstrap", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientUpdate = new ContainerType( | ||
| { | ||
| ...electraSsz.LightClientUpdate.fields, | ||
| }, | ||
| {typeName: "LightClientUpdate", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientFinalityUpdate = new ContainerType( | ||
| { | ||
| ...electraSsz.LightClientFinalityUpdate.fields, | ||
| }, | ||
| {typeName: "LightClientFinalityUpdate", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientOptimisticUpdate = new ContainerType( | ||
| { | ||
| ...electraSsz.LightClientOptimisticUpdate.fields, | ||
| }, | ||
| {typeName: "LightClientOptimisticUpdate", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const LightClientStore = new ContainerType( | ||
| { | ||
| ...electraSsz.LightClientStore.fields, | ||
| }, | ||
| {typeName: "LightClientStore", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const SSEPayloadAttributes = new ContainerType( | ||
| { | ||
| ...electraSsz.SSEPayloadAttributes.fields, | ||
| }, | ||
| {typeName: "SSEPayloadAttributes", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const BlockContents = new ContainerType( | ||
| { | ||
| block: BeaconBlock, | ||
| kzgProofs: KZGProofs, | ||
| blobs: denebSsz.Blobs, | ||
| }, | ||
| {typeName: "BlockContents", jsonCase: "eth2"} | ||
| ); | ||
|
|
||
| export const SignedBlockContents = new ContainerType( | ||
| { | ||
| signedBlock: SignedBeaconBlock, | ||
| kzgProofs: KZGProofs, | ||
| blobs: denebSsz.Blobs, | ||
| }, | ||
| {typeName: "SignedBlockContents", jsonCase: "eth2"} | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import {ValueOf} from "@chainsafe/ssz"; | ||
| import * as ssz from "./sszTypes.js"; | ||
|
|
||
| export type KZGProof = ValueOf<typeof ssz.KZGProof>; | ||
| export type Blob = ValueOf<typeof ssz.Blob>; | ||
|
|
||
| export type Metadata = ValueOf<typeof ssz.Metadata>; | ||
|
|
||
| export type Cell = ValueOf<typeof ssz.Cell>; | ||
| export type DataColumn = ValueOf<typeof ssz.DataColumn>; | ||
| export type ExtendedMatrix = ValueOf<typeof ssz.ExtendedMatrix>; | ||
| export type KzgCommitmentsInclusionProof = ValueOf<typeof ssz.KzgCommitmentsInclusionProof>; | ||
| export type DataColumnSidecar = ValueOf<typeof ssz.DataColumnSidecar>; | ||
| export type DataColumnSidecars = ValueOf<typeof ssz.DataColumnSidecars>; | ||
| export type MatrixEntry = ValueOf<typeof ssz.MatrixEntry>; | ||
|
|
||
| export type DataColumnIdentifier = ValueOf<typeof ssz.DataColumnIdentifier>; | ||
| export type DataColumnSidecarsByRootRequest = ValueOf<typeof ssz.DataColumnSidecarsByRootRequest>; | ||
| export type DataColumnSidecarsByRangeRequest = ValueOf<typeof ssz.DataColumnSidecarsByRangeRequest>; | ||
|
|
||
| export type ExecutionPayloadAndBlobsBundle = ValueOf<typeof ssz.ExecutionPayloadAndBlobsBundle>; | ||
|
|
||
| export type ExecutionPayload = ValueOf<typeof ssz.ExecutionPayload>; | ||
| export type ExecutionPayloadHeader = ValueOf<typeof ssz.ExecutionPayloadHeader>; | ||
|
|
||
| export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>; | ||
| export type BeaconBlock = ValueOf<typeof ssz.BeaconBlock>; | ||
| export type SignedBeaconBlock = ValueOf<typeof ssz.SignedBeaconBlock>; | ||
|
|
||
| export type BeaconState = ValueOf<typeof ssz.BeaconState>; | ||
|
|
||
| export type BlindedBeaconBlockBody = ValueOf<typeof ssz.BlindedBeaconBlockBody>; | ||
| export type BlindedBeaconBlock = ValueOf<typeof ssz.BlindedBeaconBlock>; | ||
| export type SignedBlindedBeaconBlock = ValueOf<typeof ssz.SignedBlindedBeaconBlock>; | ||
|
|
||
| export type BuilderBid = ValueOf<typeof ssz.BuilderBid>; | ||
| export type SignedBuilderBid = ValueOf<typeof ssz.SignedBuilderBid>; | ||
| export type SSEPayloadAttributes = ValueOf<typeof ssz.SSEPayloadAttributes>; | ||
|
|
||
| export type LightClientHeader = ValueOf<typeof ssz.LightClientHeader>; | ||
| export type LightClientBootstrap = ValueOf<typeof ssz.LightClientBootstrap>; | ||
| export type LightClientUpdate = ValueOf<typeof ssz.LightClientUpdate>; | ||
| export type LightClientFinalityUpdate = ValueOf<typeof ssz.LightClientFinalityUpdate>; | ||
| export type LightClientOptimisticUpdate = ValueOf<typeof ssz.LightClientOptimisticUpdate>; | ||
| export type LightClientStore = ValueOf<typeof ssz.LightClientStore>; | ||
|
|
||
| export type BlockContents = ValueOf<typeof ssz.BlockContents>; | ||
| export type SignedBlockContents = ValueOf<typeof ssz.SignedBlockContents>; | ||
| export type Contents = Omit<BlockContents, "block">; | ||
| export type BlobAndProofV2 = { | ||
| blob: Blob; | ||
| proofs: KZGProof[]; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.