@lodestar/types 1.35.0-dev.83de5b8dea → 1.35.0-dev.8689cc3545

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/altair/index.d.ts.map +1 -0
  2. package/lib/altair/sszTypes.d.ts.map +1 -0
  3. package/lib/altair/types.d.ts.map +1 -0
  4. package/lib/bellatrix/index.d.ts.map +1 -0
  5. package/lib/bellatrix/sszTypes.d.ts.map +1 -0
  6. package/lib/bellatrix/types.d.ts.map +1 -0
  7. package/lib/capella/index.d.ts.map +1 -0
  8. package/lib/capella/sszTypes.d.ts.map +1 -0
  9. package/lib/capella/types.d.ts.map +1 -0
  10. package/lib/deneb/index.d.ts.map +1 -0
  11. package/lib/deneb/sszTypes.d.ts.map +1 -0
  12. package/lib/deneb/types.d.ts.map +1 -0
  13. package/lib/electra/index.d.ts.map +1 -0
  14. package/lib/electra/sszTypes.d.ts.map +1 -0
  15. package/lib/electra/types.d.ts.map +1 -0
  16. package/lib/fulu/index.d.ts.map +1 -0
  17. package/lib/fulu/sszTypes.d.ts.map +1 -0
  18. package/lib/fulu/types.d.ts.map +1 -0
  19. package/lib/gloas/index.d.ts.map +1 -0
  20. package/lib/gloas/sszTypes.d.ts.map +1 -0
  21. package/lib/gloas/types.d.ts.map +1 -0
  22. package/lib/index.d.ts.map +1 -0
  23. package/lib/phase0/index.d.ts.map +1 -0
  24. package/lib/phase0/sszTypes.d.ts.map +1 -0
  25. package/lib/phase0/types.d.ts.map +1 -0
  26. package/lib/phase0/validator.d.ts.map +1 -0
  27. package/lib/primitive/index.d.ts.map +1 -0
  28. package/lib/primitive/sszTypes.d.ts.map +1 -0
  29. package/lib/primitive/types.d.ts.map +1 -0
  30. package/lib/sszTypes.d.ts.map +1 -0
  31. package/lib/types.d.ts.map +1 -0
  32. package/lib/utils/container.d.ts.map +1 -0
  33. package/lib/utils/executionAddress.d.ts.map +1 -0
  34. package/lib/utils/stringType.d.ts.map +1 -0
  35. package/lib/utils/typeguards.d.ts.map +1 -0
  36. package/lib/utils/validatorStatus.d.ts.map +1 -0
  37. package/package.json +6 -8
  38. package/src/altair/index.ts +5 -0
  39. package/src/altair/sszTypes.ts +243 -0
  40. package/src/altair/types.ts +24 -0
  41. package/src/bellatrix/index.ts +5 -0
  42. package/src/bellatrix/sszTypes.ts +238 -0
  43. package/src/bellatrix/types.ts +24 -0
  44. package/src/capella/index.ts +5 -0
  45. package/src/capella/sszTypes.ts +281 -0
  46. package/src/capella/types.ts +33 -0
  47. package/src/deneb/index.ts +5 -0
  48. package/src/deneb/sszTypes.ts +329 -0
  49. package/src/deneb/types.ts +55 -0
  50. package/src/electra/index.ts +5 -0
  51. package/src/electra/sszTypes.ts +451 -0
  52. package/src/electra/types.ts +54 -0
  53. package/src/fulu/index.ts +5 -0
  54. package/src/fulu/sszTypes.ts +138 -0
  55. package/src/fulu/types.ts +31 -0
  56. package/src/gloas/index.ts +5 -0
  57. package/src/gloas/sszTypes.ts +5 -0
  58. package/src/gloas/types.ts +6 -0
  59. package/src/index.ts +15 -0
  60. package/src/phase0/index.ts +6 -0
  61. package/src/phase0/sszTypes.ts +514 -0
  62. package/src/phase0/types.ts +46 -0
  63. package/src/phase0/validator.ts +78 -0
  64. package/src/primitive/index.ts +3 -0
  65. package/src/primitive/sszTypes.ts +70 -0
  66. package/src/primitive/types.ts +53 -0
  67. package/src/sszTypes.ts +86 -0
  68. package/src/types.ts +375 -0
  69. package/src/utils/container.ts +38 -0
  70. package/src/utils/executionAddress.ts +48 -0
  71. package/src/utils/stringType.ts +58 -0
  72. package/src/utils/typeguards.ts +98 -0
  73. package/src/utils/validatorStatus.ts +52 -0
@@ -0,0 +1,329 @@
1
+ import {ByteVectorType, ContainerType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz";
2
+ import {
3
+ BYTES_PER_FIELD_ELEMENT,
4
+ EPOCHS_PER_SYNC_COMMITTEE_PERIOD,
5
+ FIELD_ELEMENTS_PER_BLOB,
6
+ HISTORICAL_ROOTS_LIMIT,
7
+ KZG_COMMITMENT_INCLUSION_PROOF_DEPTH,
8
+ MAX_BLOB_COMMITMENTS_PER_BLOCK,
9
+ SLOTS_PER_EPOCH,
10
+ } from "@lodestar/params";
11
+ import {ssz as altairSsz} from "../altair/index.js";
12
+ import {ssz as bellatrixSsz} from "../bellatrix/index.js";
13
+ import {ssz as capellaSsz} from "../capella/index.js";
14
+ import {ssz as phase0Ssz} from "../phase0/index.js";
15
+ import {ssz as primitiveSsz} from "../primitive/index.js";
16
+
17
+ const {UintNum64, Slot, Root, BLSSignature, UintBn64, UintBn256, Bytes32, Bytes48, Bytes96, BLSPubkey, BlobIndex} =
18
+ primitiveSsz;
19
+
20
+ // Polynomial commitments
21
+ // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md
22
+
23
+ // Custom types
24
+ // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#custom-types
25
+ export const G1Point = Bytes48;
26
+ export const G2Point = Bytes96;
27
+ export const BLSFieldElement = Bytes32;
28
+ export const KZGCommitment = Bytes48;
29
+ export const KZGProof = Bytes48;
30
+
31
+ // Beacon chain
32
+
33
+ // Custom types
34
+ // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/beacon-chain.md#custom-types
35
+
36
+ export const Blob = new ByteVectorType(BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB);
37
+ export const Blobs = new ListCompositeType(Blob, MAX_BLOB_COMMITMENTS_PER_BLOCK);
38
+ export const BlindedBlob = Bytes32;
39
+ export const BlindedBlobs = new ListCompositeType(BlindedBlob, MAX_BLOB_COMMITMENTS_PER_BLOCK);
40
+
41
+ export const VersionedHash = Bytes32;
42
+ export const BlobKzgCommitments = new ListCompositeType(KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK);
43
+ export const KZGProofs = new ListCompositeType(KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK);
44
+
45
+ // ReqResp types
46
+ // =============
47
+
48
+ export const BlobSidecarsByRangeRequest = new ContainerType(
49
+ {
50
+ startSlot: Slot,
51
+ count: UintNum64,
52
+ },
53
+ {typeName: "BlobSidecarsByRangeRequest", jsonCase: "eth2"}
54
+ );
55
+
56
+ export const BlobIdentifier = new ContainerType(
57
+ {
58
+ blockRoot: Root,
59
+ index: BlobIndex,
60
+ },
61
+ {typeName: "BlobIdentifier", jsonCase: "eth2"}
62
+ );
63
+
64
+ // Beacon Chain types
65
+ // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/beacon-chain.md#containers
66
+
67
+ export const ExecutionPayload = new ContainerType(
68
+ {
69
+ ...capellaSsz.ExecutionPayload.fields,
70
+ blobGasUsed: UintBn64, // New in DENEB
71
+ excessBlobGas: UintBn64, // New in DENEB
72
+ },
73
+ {typeName: "ExecutionPayload", jsonCase: "eth2"}
74
+ );
75
+
76
+ export const ExecutionPayloadHeader = new ContainerType(
77
+ {
78
+ ...capellaSsz.ExecutionPayloadHeader.fields,
79
+ blobGasUsed: UintBn64, // New in DENEB
80
+ excessBlobGas: UintBn64, // New in DENEB
81
+ },
82
+ {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"}
83
+ );
84
+
85
+ // We have to preserve Fields ordering while changing the type of ExecutionPayload
86
+ export const BeaconBlockBody = new ContainerType(
87
+ {
88
+ ...altairSsz.BeaconBlockBody.fields,
89
+ executionPayload: ExecutionPayload, // Modified in DENEB
90
+ blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges,
91
+ blobKzgCommitments: BlobKzgCommitments, // New in DENEB
92
+ },
93
+ {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
94
+ );
95
+
96
+ export const BeaconBlock = new ContainerType(
97
+ {
98
+ ...capellaSsz.BeaconBlock.fields,
99
+ body: BeaconBlockBody, // Modified in DENEB
100
+ },
101
+ {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
102
+ );
103
+
104
+ export const SignedBeaconBlock = new ContainerType(
105
+ {
106
+ message: BeaconBlock, // Modified in DENEB
107
+ signature: BLSSignature,
108
+ },
109
+ {typeName: "SignedBeaconBlock", jsonCase: "eth2"}
110
+ );
111
+
112
+ export const KzgCommitmentInclusionProof = new VectorCompositeType(Bytes32, KZG_COMMITMENT_INCLUSION_PROOF_DEPTH);
113
+
114
+ export const BlobSidecar = new ContainerType(
115
+ {
116
+ index: BlobIndex,
117
+ blob: Blob,
118
+ kzgCommitment: KZGCommitment,
119
+ kzgProof: KZGProof,
120
+ signedBlockHeader: phase0Ssz.SignedBeaconBlockHeader,
121
+ kzgCommitmentInclusionProof: KzgCommitmentInclusionProof,
122
+ },
123
+ {typeName: "BlobSidecar", jsonCase: "eth2"}
124
+ );
125
+
126
+ export const BlobSidecars = new ListCompositeType(BlobSidecar, MAX_BLOB_COMMITMENTS_PER_BLOCK);
127
+
128
+ export const BlobsBundle = new ContainerType(
129
+ {
130
+ commitments: BlobKzgCommitments,
131
+ proofs: KZGProofs,
132
+ blobs: Blobs,
133
+ },
134
+ {typeName: "BlobsBundle", jsonCase: "eth2"}
135
+ );
136
+
137
+ export const BlindedBeaconBlockBody = new ContainerType(
138
+ {
139
+ ...altairSsz.BeaconBlockBody.fields,
140
+ executionPayloadHeader: ExecutionPayloadHeader, // Modified in DENEB
141
+ blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges,
142
+ blobKzgCommitments: BlobKzgCommitments, // New in DENEB
143
+ },
144
+ {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
145
+ );
146
+
147
+ export const BlindedBeaconBlock = new ContainerType(
148
+ {
149
+ ...capellaSsz.BlindedBeaconBlock.fields,
150
+ body: BlindedBeaconBlockBody, // Modified in DENEB
151
+ },
152
+ {typeName: "BlindedBeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
153
+ );
154
+
155
+ export const SignedBlindedBeaconBlock = new ContainerType(
156
+ {
157
+ message: BlindedBeaconBlock, // Modified in DENEB
158
+ signature: BLSSignature,
159
+ },
160
+ {typeName: "SignedBlindedBeaconBlock", jsonCase: "eth2"}
161
+ );
162
+
163
+ export const BuilderBid = new ContainerType(
164
+ {
165
+ header: ExecutionPayloadHeader,
166
+ blobKzgCommitments: BlobKzgCommitments,
167
+ value: UintBn256,
168
+ pubkey: BLSPubkey,
169
+ },
170
+ {typeName: "BuilderBid", jsonCase: "eth2"}
171
+ );
172
+
173
+ export const SignedBuilderBid = new ContainerType(
174
+ {
175
+ message: BuilderBid,
176
+ signature: BLSSignature,
177
+ },
178
+ {typeName: "SignedBuilderBid", jsonCase: "eth2"}
179
+ );
180
+
181
+ export const ExecutionPayloadAndBlobsBundle = new ContainerType(
182
+ {
183
+ executionPayload: ExecutionPayload,
184
+ blobsBundle: BlobsBundle,
185
+ },
186
+ {typeName: "ExecutionPayloadAndBlobsBundle", jsonCase: "eth2"}
187
+ );
188
+
189
+ // We don't spread capella.BeaconState fields since we need to replace
190
+ // latestExecutionPayloadHeader and we cannot keep order doing that
191
+ export const BeaconState = new ContainerType(
192
+ {
193
+ genesisTime: UintNum64,
194
+ genesisValidatorsRoot: Root,
195
+ slot: primitiveSsz.Slot,
196
+ fork: phase0Ssz.Fork,
197
+ // History
198
+ latestBlockHeader: phase0Ssz.BeaconBlockHeader,
199
+ blockRoots: phase0Ssz.HistoricalBlockRoots,
200
+ stateRoots: phase0Ssz.HistoricalStateRoots,
201
+ // historical_roots Frozen in Capella, replaced by historical_summaries
202
+ historicalRoots: new ListCompositeType(Root, HISTORICAL_ROOTS_LIMIT),
203
+ // Eth1
204
+ eth1Data: phase0Ssz.Eth1Data,
205
+ eth1DataVotes: phase0Ssz.Eth1DataVotes,
206
+ eth1DepositIndex: UintNum64,
207
+ // Registry
208
+ validators: phase0Ssz.Validators,
209
+ balances: phase0Ssz.Balances,
210
+ randaoMixes: phase0Ssz.RandaoMixes,
211
+ // Slashings
212
+ slashings: phase0Ssz.Slashings,
213
+ // Participation
214
+ previousEpochParticipation: altairSsz.EpochParticipation,
215
+ currentEpochParticipation: altairSsz.EpochParticipation,
216
+ // Finality
217
+ justificationBits: phase0Ssz.JustificationBits,
218
+ previousJustifiedCheckpoint: phase0Ssz.Checkpoint,
219
+ currentJustifiedCheckpoint: phase0Ssz.Checkpoint,
220
+ finalizedCheckpoint: phase0Ssz.Checkpoint,
221
+ // Inactivity
222
+ inactivityScores: altairSsz.InactivityScores,
223
+ // Sync
224
+ currentSyncCommittee: altairSsz.SyncCommittee,
225
+ nextSyncCommittee: altairSsz.SyncCommittee,
226
+ // Execution
227
+ latestExecutionPayloadHeader: ExecutionPayloadHeader, // Modified in DENEB
228
+ // Withdrawals
229
+ nextWithdrawalIndex: capellaSsz.BeaconState.fields.nextWithdrawalIndex,
230
+ nextWithdrawalValidatorIndex: capellaSsz.BeaconState.fields.nextWithdrawalValidatorIndex,
231
+ // Deep history valid from Capella onwards
232
+ historicalSummaries: capellaSsz.BeaconState.fields.historicalSummaries,
233
+ },
234
+ {typeName: "BeaconState", jsonCase: "eth2"}
235
+ );
236
+
237
+ export const LightClientHeader = new ContainerType(
238
+ {
239
+ beacon: phase0Ssz.BeaconBlockHeader,
240
+ execution: ExecutionPayloadHeader,
241
+ executionBranch: capellaSsz.LightClientHeader.fields.executionBranch,
242
+ },
243
+ {typeName: "LightClientHeader", jsonCase: "eth2"}
244
+ );
245
+
246
+ export const LightClientBootstrap = new ContainerType(
247
+ {
248
+ header: LightClientHeader,
249
+ currentSyncCommittee: altairSsz.SyncCommittee,
250
+ currentSyncCommitteeBranch: altairSsz.LightClientBootstrap.fields.currentSyncCommitteeBranch,
251
+ },
252
+ {typeName: "LightClientBootstrap", jsonCase: "eth2"}
253
+ );
254
+
255
+ export const LightClientUpdate = new ContainerType(
256
+ {
257
+ attestedHeader: LightClientHeader,
258
+ nextSyncCommittee: altairSsz.SyncCommittee,
259
+ nextSyncCommitteeBranch: altairSsz.LightClientUpdate.fields.nextSyncCommitteeBranch,
260
+ finalizedHeader: LightClientHeader,
261
+ finalityBranch: altairSsz.LightClientUpdate.fields.finalityBranch,
262
+ syncAggregate: altairSsz.SyncAggregate,
263
+ signatureSlot: Slot,
264
+ },
265
+ {typeName: "LightClientUpdate", jsonCase: "eth2"}
266
+ );
267
+
268
+ export const LightClientFinalityUpdate = new ContainerType(
269
+ {
270
+ attestedHeader: LightClientHeader,
271
+ finalizedHeader: LightClientHeader,
272
+ finalityBranch: altairSsz.LightClientFinalityUpdate.fields.finalityBranch,
273
+ syncAggregate: altairSsz.SyncAggregate,
274
+ signatureSlot: Slot,
275
+ },
276
+ {typeName: "LightClientFinalityUpdate", jsonCase: "eth2"}
277
+ );
278
+
279
+ export const LightClientOptimisticUpdate = new ContainerType(
280
+ {
281
+ attestedHeader: LightClientHeader,
282
+ syncAggregate: altairSsz.SyncAggregate,
283
+ signatureSlot: Slot,
284
+ },
285
+ {typeName: "LightClientOptimisticUpdate", jsonCase: "eth2"}
286
+ );
287
+
288
+ export const LightClientStore = new ContainerType(
289
+ {
290
+ snapshot: LightClientBootstrap,
291
+ validUpdates: new ListCompositeType(LightClientUpdate, EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH),
292
+ },
293
+ {typeName: "LightClientStore", jsonCase: "eth2"}
294
+ );
295
+
296
+ // PayloadAttributes primarily for SSE event
297
+ export const PayloadAttributes = new ContainerType(
298
+ {
299
+ ...capellaSsz.PayloadAttributes.fields,
300
+ parentBeaconBlockRoot: Root,
301
+ },
302
+ {typeName: "PayloadAttributes", jsonCase: "eth2"}
303
+ );
304
+
305
+ export const SSEPayloadAttributes = new ContainerType(
306
+ {
307
+ ...bellatrixSsz.SSEPayloadAttributesCommon.fields,
308
+ payloadAttributes: PayloadAttributes,
309
+ },
310
+ {typeName: "SSEPayloadAttributes", jsonCase: "eth2"}
311
+ );
312
+
313
+ export const BlockContents = new ContainerType(
314
+ {
315
+ block: BeaconBlock,
316
+ kzgProofs: KZGProofs,
317
+ blobs: Blobs,
318
+ },
319
+ {typeName: "BlockContents", jsonCase: "eth2"}
320
+ );
321
+
322
+ export const SignedBlockContents = new ContainerType(
323
+ {
324
+ signedBlock: SignedBeaconBlock,
325
+ kzgProofs: KZGProofs,
326
+ blobs: Blobs,
327
+ },
328
+ {typeName: "SignedBlockContents", jsonCase: "eth2"}
329
+ );
@@ -0,0 +1,55 @@
1
+ import {ValueOf} from "@chainsafe/ssz";
2
+ import * as ssz from "./sszTypes.js";
3
+
4
+ export type KZGProof = ValueOf<typeof ssz.KZGProof>;
5
+ export type KZGCommitment = ValueOf<typeof ssz.KZGCommitment>;
6
+
7
+ export type Blob = ValueOf<typeof ssz.Blob>;
8
+ export type Blobs = ValueOf<typeof ssz.Blobs>;
9
+ export type BlobSidecar = ValueOf<typeof ssz.BlobSidecar>;
10
+ export type BlobSidecars = ValueOf<typeof ssz.BlobSidecars>;
11
+ export type ExecutionPayloadAndBlobsBundle = ValueOf<typeof ssz.ExecutionPayloadAndBlobsBundle>;
12
+ export type BlobsBundle = ValueOf<typeof ssz.BlobsBundle>;
13
+
14
+ export type KzgCommitmentInclusionProof = ValueOf<typeof ssz.KzgCommitmentInclusionProof>;
15
+ export type BlobKzgCommitments = ValueOf<typeof ssz.BlobKzgCommitments>;
16
+ export type KZGProofs = ValueOf<typeof ssz.KZGProofs>;
17
+ export type BLSFieldElement = ValueOf<typeof ssz.BLSFieldElement>;
18
+
19
+ export type BlobIdentifier = ValueOf<typeof ssz.BlobIdentifier>;
20
+ export type BlobSidecarsByRangeRequest = ValueOf<typeof ssz.BlobSidecarsByRangeRequest>;
21
+
22
+ export type ExecutionPayload = ValueOf<typeof ssz.ExecutionPayload>;
23
+ export type ExecutionPayloadHeader = ValueOf<typeof ssz.ExecutionPayloadHeader>;
24
+
25
+ export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>;
26
+ export type BeaconBlock = ValueOf<typeof ssz.BeaconBlock>;
27
+ export type SignedBeaconBlock = ValueOf<typeof ssz.SignedBeaconBlock>;
28
+
29
+ export type BeaconState = ValueOf<typeof ssz.BeaconState>;
30
+
31
+ export type BlindedBeaconBlockBody = ValueOf<typeof ssz.BlindedBeaconBlockBody>;
32
+ export type BlindedBeaconBlock = ValueOf<typeof ssz.BlindedBeaconBlock>;
33
+ export type SignedBlindedBeaconBlock = ValueOf<typeof ssz.SignedBlindedBeaconBlock>;
34
+
35
+ export type FullOrBlindedExecutionPayload = ExecutionPayload | ExecutionPayloadHeader;
36
+
37
+ export type BuilderBid = ValueOf<typeof ssz.BuilderBid>;
38
+ export type SignedBuilderBid = ValueOf<typeof ssz.SignedBuilderBid>;
39
+ export type SSEPayloadAttributes = ValueOf<typeof ssz.SSEPayloadAttributes>;
40
+
41
+ export type LightClientHeader = ValueOf<typeof ssz.LightClientHeader>;
42
+ export type LightClientBootstrap = ValueOf<typeof ssz.LightClientBootstrap>;
43
+ export type LightClientUpdate = ValueOf<typeof ssz.LightClientUpdate>;
44
+ export type LightClientFinalityUpdate = ValueOf<typeof ssz.LightClientFinalityUpdate>;
45
+ export type LightClientOptimisticUpdate = ValueOf<typeof ssz.LightClientOptimisticUpdate>;
46
+ export type LightClientStore = ValueOf<typeof ssz.LightClientStore>;
47
+
48
+ export type ProducedBlobSidecars = Omit<BlobSidecars, "signedBlockHeader" | "kzgCommitmentInclusionProof">;
49
+
50
+ export type BlockContents = ValueOf<typeof ssz.BlockContents>;
51
+ export type SignedBlockContents = ValueOf<typeof ssz.SignedBlockContents>;
52
+ export type BlobAndProof = {
53
+ blob: Blob;
54
+ proof: KZGProof;
55
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./types.js";
2
+
3
+ import * as ssz from "./sszTypes.js";
4
+ import * as ts from "./types.js";
5
+ export {ts, ssz};