@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,24 @@
1
+ import {ValueOf} from "@chainsafe/ssz";
2
+ import * as ssz from "./sszTypes.js";
3
+
4
+ export type SyncSubnets = ValueOf<typeof ssz.SyncSubnets>;
5
+ export type Metadata = ValueOf<typeof ssz.Metadata>;
6
+ export type SyncCommittee = ValueOf<typeof ssz.SyncCommittee>;
7
+ export type SyncCommitteeMessage = ValueOf<typeof ssz.SyncCommitteeMessage>;
8
+ export type SyncCommitteeContribution = ValueOf<typeof ssz.SyncCommitteeContribution>;
9
+ export type ContributionAndProof = ValueOf<typeof ssz.ContributionAndProof>;
10
+ export type SignedContributionAndProof = ValueOf<typeof ssz.SignedContributionAndProof>;
11
+ export type SyncAggregatorSelectionData = ValueOf<typeof ssz.SyncAggregatorSelectionData>;
12
+ export type SyncAggregate = ValueOf<typeof ssz.SyncAggregate>;
13
+ export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>;
14
+ export type BeaconBlock = ValueOf<typeof ssz.BeaconBlock>;
15
+ export type SignedBeaconBlock = ValueOf<typeof ssz.SignedBeaconBlock>;
16
+ export type BeaconState = ValueOf<typeof ssz.BeaconState>;
17
+
18
+ export type LightClientHeader = ValueOf<typeof ssz.LightClientHeader>;
19
+ export type LightClientBootstrap = ValueOf<typeof ssz.LightClientBootstrap>;
20
+ export type LightClientUpdate = ValueOf<typeof ssz.LightClientUpdate>;
21
+ export type LightClientFinalityUpdate = ValueOf<typeof ssz.LightClientFinalityUpdate>;
22
+ export type LightClientOptimisticUpdate = ValueOf<typeof ssz.LightClientOptimisticUpdate>;
23
+ export type LightClientStore = ValueOf<typeof ssz.LightClientStore>;
24
+ export type LightClientUpdatesByRange = ValueOf<typeof ssz.LightClientUpdatesByRange>;
@@ -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};
@@ -0,0 +1,238 @@
1
+ import {ByteListType, ByteVectorType, ContainerType, ListCompositeType} from "@chainsafe/ssz";
2
+ import {
3
+ BYTES_PER_LOGS_BLOOM,
4
+ HISTORICAL_ROOTS_LIMIT,
5
+ MAX_BYTES_PER_TRANSACTION,
6
+ MAX_EXTRA_DATA_BYTES,
7
+ MAX_TRANSACTIONS_PER_PAYLOAD,
8
+ } from "@lodestar/params";
9
+ import {ssz as altairSsz} from "../altair/index.js";
10
+ import {ssz as phase0Ssz} from "../phase0/index.js";
11
+ import {ssz as primitiveSsz} from "../primitive/index.js";
12
+ import {stringType} from "../utils/stringType.js";
13
+
14
+ const {
15
+ Bytes32,
16
+ UintNum64,
17
+ Slot,
18
+ ValidatorIndex,
19
+ Root,
20
+ BLSSignature,
21
+ UintBn256: Uint256,
22
+ BLSPubkey,
23
+ ExecutionAddress,
24
+ } = primitiveSsz;
25
+
26
+ /**
27
+ * ByteList[MAX_BYTES_PER_TRANSACTION]
28
+ *
29
+ * Spec v1.0.1
30
+ */
31
+ export const Transaction = new ByteListType(MAX_BYTES_PER_TRANSACTION);
32
+
33
+ /**
34
+ * Union[OpaqueTransaction]
35
+ *
36
+ * Spec v1.0.1
37
+ */
38
+ export const Transactions = new ListCompositeType(Transaction, MAX_TRANSACTIONS_PER_PAYLOAD);
39
+
40
+ export const CommonExecutionPayloadType = new ContainerType({
41
+ parentHash: Root,
42
+ feeRecipient: ExecutionAddress,
43
+ stateRoot: Bytes32,
44
+ receiptsRoot: Bytes32,
45
+ logsBloom: new ByteVectorType(BYTES_PER_LOGS_BLOOM),
46
+ prevRandao: Bytes32,
47
+ blockNumber: UintNum64,
48
+ gasLimit: UintNum64,
49
+ gasUsed: UintNum64,
50
+ timestamp: UintNum64,
51
+ // TODO: if there is perf issue, consider making ByteListType
52
+ extraData: new ByteListType(MAX_EXTRA_DATA_BYTES),
53
+ baseFeePerGas: Uint256,
54
+ blockHash: Root,
55
+ });
56
+
57
+ export const ExecutionPayload = new ContainerType(
58
+ {
59
+ ...CommonExecutionPayloadType.fields,
60
+ transactions: Transactions,
61
+ },
62
+ {typeName: "ExecutionPayload", jsonCase: "eth2"}
63
+ );
64
+
65
+ export const ExecutionPayloadHeader = new ContainerType(
66
+ {
67
+ ...CommonExecutionPayloadType.fields,
68
+ transactionsRoot: Root,
69
+ },
70
+ {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"}
71
+ );
72
+
73
+ export const BeaconBlockBody = new ContainerType(
74
+ {
75
+ ...altairSsz.BeaconBlockBody.fields,
76
+ executionPayload: ExecutionPayload,
77
+ },
78
+ {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
79
+ );
80
+
81
+ export const BeaconBlock = new ContainerType(
82
+ {
83
+ slot: Slot,
84
+ proposerIndex: ValidatorIndex,
85
+ // Reclare expandedType() with altair block and altair state
86
+ parentRoot: Root,
87
+ stateRoot: Root,
88
+ body: BeaconBlockBody,
89
+ },
90
+ {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
91
+ );
92
+
93
+ export const SignedBeaconBlock = new ContainerType(
94
+ {
95
+ message: BeaconBlock,
96
+ signature: BLSSignature,
97
+ },
98
+ {typeName: "SignedBeaconBlock", jsonCase: "eth2"}
99
+ );
100
+
101
+ export const PowBlock = new ContainerType(
102
+ {
103
+ blockHash: Root,
104
+ parentHash: Root,
105
+ totalDifficulty: Uint256,
106
+ },
107
+ {typeName: "PowBlock", jsonCase: "eth2"}
108
+ );
109
+
110
+ // we don't reuse phase0.BeaconState fields since we need to replace some keys
111
+ // and we cannot keep order doing that
112
+ export const BeaconState = new ContainerType(
113
+ {
114
+ genesisTime: UintNum64,
115
+ genesisValidatorsRoot: Root,
116
+ slot: primitiveSsz.Slot,
117
+ fork: phase0Ssz.Fork,
118
+ // History
119
+ latestBlockHeader: phase0Ssz.BeaconBlockHeader,
120
+ blockRoots: phase0Ssz.HistoricalBlockRoots,
121
+ stateRoots: phase0Ssz.HistoricalStateRoots,
122
+ historicalRoots: new ListCompositeType(Root, HISTORICAL_ROOTS_LIMIT),
123
+ // Eth1
124
+ eth1Data: phase0Ssz.Eth1Data,
125
+ eth1DataVotes: phase0Ssz.Eth1DataVotes,
126
+ eth1DepositIndex: UintNum64,
127
+ // Registry
128
+ validators: phase0Ssz.Validators,
129
+ balances: phase0Ssz.Balances,
130
+ randaoMixes: phase0Ssz.RandaoMixes,
131
+ // Slashings
132
+ slashings: phase0Ssz.Slashings,
133
+ // Participation
134
+ previousEpochParticipation: altairSsz.EpochParticipation,
135
+ currentEpochParticipation: altairSsz.EpochParticipation,
136
+ // Finality
137
+ justificationBits: phase0Ssz.JustificationBits,
138
+ previousJustifiedCheckpoint: phase0Ssz.Checkpoint,
139
+ currentJustifiedCheckpoint: phase0Ssz.Checkpoint,
140
+ finalizedCheckpoint: phase0Ssz.Checkpoint,
141
+ // Inactivity
142
+ inactivityScores: altairSsz.InactivityScores,
143
+ // Sync
144
+ currentSyncCommittee: altairSsz.SyncCommittee,
145
+ nextSyncCommittee: altairSsz.SyncCommittee,
146
+ // Execution
147
+ latestExecutionPayloadHeader: ExecutionPayloadHeader, // [New in Merge]
148
+ },
149
+ {typeName: "BeaconState", jsonCase: "eth2"}
150
+ );
151
+
152
+ export const BlindedBeaconBlockBody = new ContainerType(
153
+ {
154
+ ...altairSsz.BeaconBlockBody.fields,
155
+ executionPayloadHeader: ExecutionPayloadHeader,
156
+ },
157
+ {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
158
+ );
159
+
160
+ export const BlindedBeaconBlock = new ContainerType(
161
+ {
162
+ slot: Slot,
163
+ proposerIndex: ValidatorIndex,
164
+ // Reclare expandedType() with altair block and altair state
165
+ parentRoot: Root,
166
+ stateRoot: Root,
167
+ body: BlindedBeaconBlockBody,
168
+ },
169
+ {typeName: "BlindedBeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
170
+ );
171
+
172
+ export const SignedBlindedBeaconBlock = new ContainerType(
173
+ {
174
+ message: BlindedBeaconBlock,
175
+ signature: BLSSignature,
176
+ },
177
+ {typeName: "SignedBlindedBeaconBlock", jsonCase: "eth2"}
178
+ );
179
+
180
+ export const ValidatorRegistrationV1 = new ContainerType(
181
+ {
182
+ feeRecipient: ExecutionAddress,
183
+ gasLimit: UintNum64,
184
+ timestamp: UintNum64,
185
+ pubkey: BLSPubkey,
186
+ },
187
+ {typeName: "ValidatorRegistrationV1", jsonCase: "eth2"}
188
+ );
189
+
190
+ export const SignedValidatorRegistrationV1 = new ContainerType(
191
+ {
192
+ message: ValidatorRegistrationV1,
193
+ signature: BLSSignature,
194
+ },
195
+ {typeName: "SignedValidatorRegistrationV1", jsonCase: "eth2"}
196
+ );
197
+
198
+ export const BuilderBid = new ContainerType(
199
+ {
200
+ header: ExecutionPayloadHeader,
201
+ value: Uint256,
202
+ pubkey: BLSPubkey,
203
+ },
204
+ {typeName: "BuilderBid", jsonCase: "eth2"}
205
+ );
206
+
207
+ export const SignedBuilderBid = new ContainerType(
208
+ {
209
+ message: BuilderBid,
210
+ signature: BLSSignature,
211
+ },
212
+ {typeName: "SignedBuilderBid", jsonCase: "eth2"}
213
+ );
214
+
215
+ // PayloadAttributes primarily for SSE event
216
+ export const PayloadAttributes = new ContainerType(
217
+ {timestamp: UintNum64, prevRandao: Bytes32, suggestedFeeRecipient: stringType},
218
+ {typeName: "PayloadAttributes", jsonCase: "eth2"}
219
+ );
220
+
221
+ export const SSEPayloadAttributesCommon = new ContainerType(
222
+ {
223
+ proposerIndex: UintNum64,
224
+ proposalSlot: Slot,
225
+ parentBlockNumber: UintNum64,
226
+ parentBlockRoot: Root,
227
+ parentBlockHash: Root,
228
+ },
229
+ {typeName: "SSEPayloadAttributesCommon", jsonCase: "eth2"}
230
+ );
231
+
232
+ export const SSEPayloadAttributes = new ContainerType(
233
+ {
234
+ ...SSEPayloadAttributesCommon.fields,
235
+ payloadAttributes: PayloadAttributes,
236
+ },
237
+ {typeName: "SSEPayloadAttributes", jsonCase: "eth2"}
238
+ );
@@ -0,0 +1,24 @@
1
+ import {ValueOf} from "@chainsafe/ssz";
2
+ import * as ssz from "./sszTypes.js";
3
+
4
+ export type Transaction = ValueOf<typeof ssz.Transaction>;
5
+ export type Transactions = ValueOf<typeof ssz.Transactions>;
6
+ export type ExecutionPayload = ValueOf<typeof ssz.ExecutionPayload>;
7
+ export type ExecutionPayloadHeader = ValueOf<typeof ssz.ExecutionPayloadHeader>;
8
+ export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>;
9
+ export type BeaconBlock = ValueOf<typeof ssz.BeaconBlock>;
10
+ export type SignedBeaconBlock = ValueOf<typeof ssz.SignedBeaconBlock>;
11
+ export type BeaconState = ValueOf<typeof ssz.BeaconState>;
12
+ export type PowBlock = ValueOf<typeof ssz.PowBlock>;
13
+
14
+ export type BlindedBeaconBlockBody = ValueOf<typeof ssz.BlindedBeaconBlockBody>;
15
+ export type BlindedBeaconBlock = ValueOf<typeof ssz.BlindedBeaconBlock>;
16
+ export type SignedBlindedBeaconBlock = ValueOf<typeof ssz.SignedBlindedBeaconBlock>;
17
+
18
+ export type ValidatorRegistrationV1 = ValueOf<typeof ssz.ValidatorRegistrationV1>;
19
+ export type SignedValidatorRegistrationV1 = ValueOf<typeof ssz.SignedValidatorRegistrationV1>;
20
+ export type BuilderBid = ValueOf<typeof ssz.BuilderBid>;
21
+ export type SignedBuilderBid = ValueOf<typeof ssz.SignedBuilderBid>;
22
+ export type SSEPayloadAttributes = ValueOf<typeof ssz.SSEPayloadAttributes>;
23
+
24
+ export type FullOrBlindedExecutionPayload = ExecutionPayload | ExecutionPayloadHeader;
@@ -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};
@@ -0,0 +1,281 @@
1
+ import {ContainerType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz";
2
+ import {
3
+ EPOCHS_PER_SYNC_COMMITTEE_PERIOD,
4
+ BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH,
5
+ HISTORICAL_ROOTS_LIMIT,
6
+ MAX_BLS_TO_EXECUTION_CHANGES,
7
+ MAX_WITHDRAWALS_PER_PAYLOAD,
8
+ SLOTS_PER_EPOCH,
9
+ } from "@lodestar/params";
10
+ import {ssz as altairSsz} from "../altair/index.js";
11
+ import {ssz as bellatrixSsz} from "../bellatrix/index.js";
12
+ import {ssz as phase0Ssz} from "../phase0/index.js";
13
+ import {ssz as primitiveSsz} from "../primitive/index.js";
14
+
15
+ const {
16
+ UintNum64,
17
+ Slot,
18
+ ValidatorIndex,
19
+ WithdrawalIndex,
20
+ Root,
21
+ BLSSignature,
22
+ BLSPubkey,
23
+ ExecutionAddress,
24
+ Gwei,
25
+ UintBn256,
26
+ Bytes32,
27
+ } = primitiveSsz;
28
+
29
+ export const ExecutionBranch = new VectorCompositeType(Bytes32, EXECUTION_PAYLOAD_DEPTH);
30
+
31
+ export const Withdrawal = new ContainerType(
32
+ {
33
+ index: WithdrawalIndex,
34
+ validatorIndex: ValidatorIndex,
35
+ address: ExecutionAddress,
36
+ amount: Gwei,
37
+ },
38
+ {typeName: "Withdrawal", jsonCase: "eth2"}
39
+ );
40
+
41
+ export const BLSToExecutionChange = new ContainerType(
42
+ {
43
+ validatorIndex: ValidatorIndex,
44
+ fromBlsPubkey: BLSPubkey,
45
+ toExecutionAddress: ExecutionAddress,
46
+ },
47
+ {typeName: "BLSToExecutionChange", jsonCase: "eth2"}
48
+ );
49
+
50
+ export const SignedBLSToExecutionChange = new ContainerType(
51
+ {
52
+ message: BLSToExecutionChange,
53
+ signature: BLSSignature,
54
+ },
55
+ {typeName: "SignedBLSToExecutionChange", jsonCase: "eth2"}
56
+ );
57
+
58
+ export const Withdrawals = new ListCompositeType(Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD);
59
+ export const ExecutionPayload = new ContainerType(
60
+ {
61
+ ...bellatrixSsz.ExecutionPayload.fields,
62
+ withdrawals: Withdrawals, // New in capella
63
+ },
64
+ {typeName: "ExecutionPayload", jsonCase: "eth2"}
65
+ );
66
+
67
+ export const ExecutionPayloadHeader = new ContainerType(
68
+ {
69
+ ...bellatrixSsz.ExecutionPayloadHeader.fields,
70
+ withdrawalsRoot: Root, // New in capella
71
+ },
72
+ {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"}
73
+ );
74
+
75
+ export const BLSToExecutionChanges = new ListCompositeType(SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES);
76
+ export const BeaconBlockBody = new ContainerType(
77
+ {
78
+ ...altairSsz.BeaconBlockBody.fields,
79
+ executionPayload: ExecutionPayload, // Modified in capella
80
+ blsToExecutionChanges: BLSToExecutionChanges,
81
+ },
82
+ {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
83
+ );
84
+
85
+ export const BeaconBlock = new ContainerType(
86
+ {
87
+ slot: Slot,
88
+ proposerIndex: ValidatorIndex,
89
+ // Reclare expandedType() with altair block and altair state
90
+ parentRoot: Root,
91
+ stateRoot: Root,
92
+ body: BeaconBlockBody, // Modified in Capella
93
+ },
94
+ {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
95
+ );
96
+
97
+ export const SignedBeaconBlock = new ContainerType(
98
+ {
99
+ message: BeaconBlock, // Modified in capella
100
+ signature: BLSSignature,
101
+ },
102
+ {typeName: "SignedBeaconBlock", jsonCase: "eth2"}
103
+ );
104
+
105
+ export const BuilderBid = new ContainerType(
106
+ {
107
+ header: ExecutionPayloadHeader,
108
+ value: UintBn256,
109
+ pubkey: BLSPubkey,
110
+ },
111
+ {typeName: "BuilderBid", jsonCase: "eth2"}
112
+ );
113
+
114
+ export const SignedBuilderBid = new ContainerType(
115
+ {
116
+ message: BuilderBid,
117
+ signature: BLSSignature,
118
+ },
119
+ {typeName: "SignedBuilderBid", jsonCase: "eth2"}
120
+ );
121
+
122
+ export const HistoricalSummary = new ContainerType(
123
+ {
124
+ blockSummaryRoot: Root,
125
+ stateSummaryRoot: Root,
126
+ },
127
+ {typeName: "HistoricalSummary", jsonCase: "eth2"}
128
+ );
129
+
130
+ export const HistoricalSummaries = new ListCompositeType(HistoricalSummary, HISTORICAL_ROOTS_LIMIT, {
131
+ typeName: "HistoricalSummaries",
132
+ });
133
+
134
+ // we don't reuse bellatrix.BeaconState fields since we need to replace some keys
135
+ // and we cannot keep order doing that
136
+ export const BeaconState = new ContainerType(
137
+ {
138
+ genesisTime: UintNum64,
139
+ genesisValidatorsRoot: Root,
140
+ slot: primitiveSsz.Slot,
141
+ fork: phase0Ssz.Fork,
142
+ // History
143
+ latestBlockHeader: phase0Ssz.BeaconBlockHeader,
144
+ blockRoots: phase0Ssz.HistoricalBlockRoots,
145
+ stateRoots: phase0Ssz.HistoricalStateRoots,
146
+ // historical_roots Frozen in Capella, replaced by historical_summaries
147
+ historicalRoots: new ListCompositeType(Root, HISTORICAL_ROOTS_LIMIT),
148
+ // Eth1
149
+ eth1Data: phase0Ssz.Eth1Data,
150
+ eth1DataVotes: phase0Ssz.Eth1DataVotes,
151
+ eth1DepositIndex: UintNum64,
152
+ // Registry
153
+ validators: phase0Ssz.Validators,
154
+ balances: phase0Ssz.Balances,
155
+ randaoMixes: phase0Ssz.RandaoMixes,
156
+ // Slashings
157
+ slashings: phase0Ssz.Slashings,
158
+ // Participation
159
+ previousEpochParticipation: altairSsz.EpochParticipation,
160
+ currentEpochParticipation: altairSsz.EpochParticipation,
161
+ // Finality
162
+ justificationBits: phase0Ssz.JustificationBits,
163
+ previousJustifiedCheckpoint: phase0Ssz.Checkpoint,
164
+ currentJustifiedCheckpoint: phase0Ssz.Checkpoint,
165
+ finalizedCheckpoint: phase0Ssz.Checkpoint,
166
+ // Inactivity
167
+ inactivityScores: altairSsz.InactivityScores,
168
+ // Sync
169
+ currentSyncCommittee: altairSsz.SyncCommittee,
170
+ nextSyncCommittee: altairSsz.SyncCommittee,
171
+ // Execution
172
+ latestExecutionPayloadHeader: ExecutionPayloadHeader, // [Modified in Capella]
173
+ // Withdrawals
174
+ nextWithdrawalIndex: WithdrawalIndex, // [New in Capella]
175
+ nextWithdrawalValidatorIndex: ValidatorIndex, // [New in Capella]
176
+ // Deep history valid from Capella onwards
177
+ historicalSummaries: HistoricalSummaries, // [New in Capella]
178
+ },
179
+ {typeName: "BeaconState", jsonCase: "eth2"}
180
+ );
181
+
182
+ export const BlindedBeaconBlockBody = new ContainerType(
183
+ {
184
+ ...altairSsz.BeaconBlockBody.fields,
185
+ executionPayloadHeader: ExecutionPayloadHeader, // Modified in capella
186
+ blsToExecutionChanges: BLSToExecutionChanges, // New in capella
187
+ },
188
+ {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
189
+ );
190
+
191
+ export const BlindedBeaconBlock = new ContainerType(
192
+ {
193
+ ...bellatrixSsz.BlindedBeaconBlock.fields,
194
+ body: BlindedBeaconBlockBody, // Modified in capella
195
+ },
196
+ {typeName: "BlindedBeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true}
197
+ );
198
+
199
+ export const SignedBlindedBeaconBlock = new ContainerType(
200
+ {
201
+ message: BlindedBeaconBlock, // Modified in capella
202
+ signature: BLSSignature,
203
+ },
204
+ {typeName: "SignedBlindedBeaconBlock", jsonCase: "eth2"}
205
+ );
206
+
207
+ export const LightClientHeader = new ContainerType(
208
+ {
209
+ beacon: phase0Ssz.BeaconBlockHeader,
210
+ execution: ExecutionPayloadHeader,
211
+ executionBranch: ExecutionBranch,
212
+ },
213
+ {typeName: "LightClientHeader", jsonCase: "eth2"}
214
+ );
215
+
216
+ export const LightClientBootstrap = new ContainerType(
217
+ {
218
+ header: LightClientHeader,
219
+ currentSyncCommittee: altairSsz.SyncCommittee,
220
+ currentSyncCommitteeBranch: altairSsz.LightClientBootstrap.fields.currentSyncCommitteeBranch,
221
+ },
222
+ {typeName: "LightClientBootstrap", jsonCase: "eth2"}
223
+ );
224
+
225
+ export const LightClientUpdate = new ContainerType(
226
+ {
227
+ attestedHeader: LightClientHeader,
228
+ nextSyncCommittee: altairSsz.SyncCommittee,
229
+ nextSyncCommitteeBranch: altairSsz.LightClientUpdate.fields.nextSyncCommitteeBranch,
230
+ finalizedHeader: LightClientHeader,
231
+ finalityBranch: altairSsz.LightClientUpdate.fields.finalityBranch,
232
+ syncAggregate: altairSsz.SyncAggregate,
233
+ signatureSlot: Slot,
234
+ },
235
+ {typeName: "LightClientUpdate", jsonCase: "eth2"}
236
+ );
237
+
238
+ export const LightClientFinalityUpdate = new ContainerType(
239
+ {
240
+ attestedHeader: LightClientHeader,
241
+ finalizedHeader: LightClientHeader,
242
+ finalityBranch: altairSsz.LightClientFinalityUpdate.fields.finalityBranch,
243
+ syncAggregate: altairSsz.SyncAggregate,
244
+ signatureSlot: Slot,
245
+ },
246
+ {typeName: "LightClientFinalityUpdate", jsonCase: "eth2"}
247
+ );
248
+
249
+ export const LightClientOptimisticUpdate = new ContainerType(
250
+ {
251
+ attestedHeader: LightClientHeader,
252
+ syncAggregate: altairSsz.SyncAggregate,
253
+ signatureSlot: Slot,
254
+ },
255
+ {typeName: "LightClientOptimisticUpdate", jsonCase: "eth2"}
256
+ );
257
+
258
+ export const LightClientStore = new ContainerType(
259
+ {
260
+ snapshot: LightClientBootstrap,
261
+ validUpdates: new ListCompositeType(LightClientUpdate, EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH),
262
+ },
263
+ {typeName: "LightClientStore", jsonCase: "eth2"}
264
+ );
265
+
266
+ // PayloadAttributes primarily for SSE event
267
+ export const PayloadAttributes = new ContainerType(
268
+ {
269
+ ...bellatrixSsz.PayloadAttributes.fields,
270
+ withdrawals: Withdrawals,
271
+ },
272
+ {typeName: "PayloadAttributes", jsonCase: "eth2"}
273
+ );
274
+
275
+ export const SSEPayloadAttributes = new ContainerType(
276
+ {
277
+ ...bellatrixSsz.SSEPayloadAttributesCommon.fields,
278
+ payloadAttributes: PayloadAttributes,
279
+ },
280
+ {typeName: "SSEPayloadAttributes", jsonCase: "eth2"}
281
+ );
@@ -0,0 +1,33 @@
1
+ import {ValueOf} from "@chainsafe/ssz";
2
+ import * as ssz from "./sszTypes.js";
3
+
4
+ export type Withdrawal = ValueOf<typeof ssz.Withdrawal>;
5
+ export type Withdrawals = ValueOf<typeof ssz.Withdrawals>;
6
+ export type BLSToExecutionChange = ValueOf<typeof ssz.BLSToExecutionChange>;
7
+ export type BLSToExecutionChanges = ValueOf<typeof ssz.BLSToExecutionChanges>;
8
+ export type SignedBLSToExecutionChange = ValueOf<typeof ssz.SignedBLSToExecutionChange>;
9
+
10
+ export type ExecutionPayload = ValueOf<typeof ssz.ExecutionPayload>;
11
+ export type ExecutionPayloadHeader = ValueOf<typeof ssz.ExecutionPayloadHeader>;
12
+
13
+ export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>;
14
+ export type BeaconBlock = ValueOf<typeof ssz.BeaconBlock>;
15
+ export type SignedBeaconBlock = ValueOf<typeof ssz.SignedBeaconBlock>;
16
+ export type BeaconState = ValueOf<typeof ssz.BeaconState>;
17
+
18
+ export type BlindedBeaconBlockBody = ValueOf<typeof ssz.BlindedBeaconBlockBody>;
19
+ export type BlindedBeaconBlock = ValueOf<typeof ssz.BlindedBeaconBlock>;
20
+ export type SignedBlindedBeaconBlock = ValueOf<typeof ssz.SignedBlindedBeaconBlock>;
21
+
22
+ export type FullOrBlindedExecutionPayload = ExecutionPayload | ExecutionPayloadHeader;
23
+
24
+ export type BuilderBid = ValueOf<typeof ssz.BuilderBid>;
25
+ export type SignedBuilderBid = ValueOf<typeof ssz.SignedBuilderBid>;
26
+ export type SSEPayloadAttributes = ValueOf<typeof ssz.SSEPayloadAttributes>;
27
+
28
+ export type LightClientHeader = ValueOf<typeof ssz.LightClientHeader>;
29
+ export type LightClientBootstrap = ValueOf<typeof ssz.LightClientBootstrap>;
30
+ export type LightClientUpdate = ValueOf<typeof ssz.LightClientUpdate>;
31
+ export type LightClientFinalityUpdate = ValueOf<typeof ssz.LightClientFinalityUpdate>;
32
+ export type LightClientOptimisticUpdate = ValueOf<typeof ssz.LightClientOptimisticUpdate>;
33
+ export type LightClientStore = ValueOf<typeof ssz.LightClientStore>;
@@ -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};