@lodestar/api 1.44.0-dev.de5436c9ff → 1.44.0-dev.df8a25e36b

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.
@@ -1,12 +1,10 @@
1
1
  import {ContainerType, ListCompositeType, ValueOf} from "@chainsafe/ssz";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {
4
- ForkName,
5
4
  ForkPostDeneb,
6
5
  ForkPostGloas,
7
6
  ForkPreBellatrix,
8
7
  ForkPreDeneb,
9
- ForkPreElectra,
10
8
  isForkPostBellatrix,
11
9
  isForkPostDeneb,
12
10
  isForkPostGloas,
@@ -99,18 +97,6 @@ export type Endpoints = {
99
97
  ExecutionOptimisticFinalizedAndVersionMeta
100
98
  >;
101
99
 
102
- /**
103
- * Get block attestations
104
- * Retrieves attestation included in requested block.
105
- */
106
- getBlockAttestations: Endpoint<
107
- "GET",
108
- BlockArgs,
109
- {params: {block_id: string}},
110
- BeaconBlockBody<ForkPreElectra>["attestations"],
111
- ExecutionOptimisticAndFinalizedMeta
112
- >;
113
-
114
100
  /**
115
101
  * Get block attestations
116
102
  * Retrieves attestation included in requested block.
@@ -170,14 +156,6 @@ export type Endpoints = {
170
156
  *
171
157
  * Returns if the block was validated successfully and has been broadcast. It has also been integrated into the beacon node's database.
172
158
  */
173
- publishBlock: Endpoint<
174
- "POST",
175
- {signedBlockContents: SignedBlockContents},
176
- {body: unknown; headers: {[MetaHeader.Version]: string}},
177
- EmptyResponseData,
178
- EmptyMeta
179
- >;
180
-
181
159
  publishBlockV2: Endpoint<
182
160
  "POST",
183
161
  {
@@ -193,14 +171,6 @@ export type Endpoints = {
193
171
  * Publish a signed blinded block by submitting it to the mev relay and patching in the block
194
172
  * transactions beacon node gets in response.
195
173
  */
196
- publishBlindedBlock: Endpoint<
197
- "POST",
198
- {signedBlindedBlock: SignedBlindedBeaconBlock},
199
- {body: unknown; headers: {[MetaHeader.Version]: string}},
200
- EmptyResponseData,
201
- EmptyMeta
202
- >;
203
-
204
174
  publishBlindedBlockV2: Endpoint<
205
175
  "POST",
206
176
  {
@@ -318,15 +288,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
318
288
  meta: ExecutionOptimisticFinalizedAndVersionCodec,
319
289
  },
320
290
  },
321
- getBlockAttestations: {
322
- url: "/eth/v1/beacon/blocks/{block_id}/attestations",
323
- method: "GET",
324
- req: blockIdOnlyReq,
325
- resp: {
326
- data: ssz.phase0.BeaconBlockBody.fields.attestations,
327
- meta: ExecutionOptimisticAndFinalizedCodec,
328
- },
329
- },
330
291
  getBlockAttestationsV2: {
331
292
  url: "/eth/v2/beacon/blocks/{block_id}/attestations",
332
293
  method: "GET",
@@ -367,80 +328,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
367
328
  meta: ExecutionOptimisticAndFinalizedCodec,
368
329
  },
369
330
  },
370
- publishBlock: {
371
- url: "/eth/v1/beacon/blocks",
372
- method: "POST",
373
- req: {
374
- writeReqJson: ({signedBlockContents}) => {
375
- const slot = signedBlockContents.signedBlock.message.slot;
376
- const fork = config.getForkName(slot);
377
-
378
- return {
379
- body: isForkPostDeneb(fork)
380
- ? sszTypesFor(fork).SignedBlockContents.toJson(signedBlockContents as SignedBlockContents<ForkPostDeneb>)
381
- : sszTypesFor(fork).SignedBeaconBlock.toJson(
382
- signedBlockContents.signedBlock as SignedBeaconBlock<ForkPreDeneb>
383
- ),
384
- headers: {
385
- [MetaHeader.Version]: config.getForkName(slot),
386
- },
387
- };
388
- },
389
- parseReqJson: ({body, headers}) => {
390
- let forkName: ForkName;
391
- // As per spec, version header is optional for JSON requests
392
- const versionHeader = fromHeaders(headers, MetaHeader.Version, false);
393
- if (versionHeader !== undefined) {
394
- forkName = toForkName(versionHeader);
395
- } else {
396
- // Determine fork from slot in JSON payload
397
- forkName = config.getForkName(
398
- (body as {signed_block: unknown}).signed_block !== undefined
399
- ? (body as {signed_block: SignedBeaconBlock}).signed_block.message.slot
400
- : (body as SignedBeaconBlock).message.slot
401
- );
402
- }
403
- return {
404
- signedBlockContents: isForkPostDeneb(forkName)
405
- ? sszTypesFor(forkName).SignedBlockContents.fromJson(body)
406
- : {signedBlock: ssz[forkName].SignedBeaconBlock.fromJson(body)},
407
- };
408
- },
409
- writeReqSsz: ({signedBlockContents}) => {
410
- const slot = signedBlockContents.signedBlock.message.slot;
411
- const fork = config.getForkName(slot);
412
-
413
- return {
414
- body: isForkPostDeneb(fork)
415
- ? sszTypesFor(fork).SignedBlockContents.serialize(
416
- signedBlockContents as SignedBlockContents<ForkPostDeneb>
417
- )
418
- : sszTypesFor(fork).SignedBeaconBlock.serialize(
419
- signedBlockContents.signedBlock as SignedBeaconBlock<ForkPreDeneb>
420
- ),
421
- headers: {
422
- [MetaHeader.Version]: config.getForkName(slot),
423
- },
424
- };
425
- },
426
- parseReqSsz: ({body, headers}) => {
427
- const forkName = toForkName(fromHeaders(headers, MetaHeader.Version));
428
- return {
429
- signedBlockContents: isForkPostDeneb(forkName)
430
- ? sszTypesFor(forkName).SignedBlockContents.deserialize(body)
431
- : {signedBlock: ssz[forkName].SignedBeaconBlock.deserialize(body)},
432
- };
433
- },
434
- schema: {
435
- body: Schema.Object,
436
- headers: {[MetaHeader.Version]: Schema.String},
437
- },
438
- },
439
- resp: EmptyResponseCodec,
440
- init: {
441
- requestWireFormat: WireFormat.ssz,
442
- },
443
- },
444
331
  publishBlockV2: {
445
332
  url: "/eth/v2/beacon/blocks",
446
333
  method: "POST",
@@ -513,59 +400,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
513
400
  requestWireFormat: WireFormat.ssz,
514
401
  },
515
402
  },
516
- publishBlindedBlock: {
517
- url: "/eth/v1/beacon/blinded_blocks",
518
- method: "POST",
519
- req: {
520
- writeReqJson: ({signedBlindedBlock}) => {
521
- const fork = config.getForkName(signedBlindedBlock.message.slot);
522
- return {
523
- body: getPostBellatrixForkTypes(fork).SignedBlindedBeaconBlock.toJson(signedBlindedBlock),
524
- headers: {
525
- [MetaHeader.Version]: fork,
526
- },
527
- };
528
- },
529
- parseReqJson: ({body, headers}) => {
530
- let fork: ForkName;
531
- // As per spec, version header is optional for JSON requests
532
- const versionHeader = fromHeaders(headers, MetaHeader.Version, false);
533
- if (versionHeader !== undefined) {
534
- fork = toForkName(versionHeader);
535
- } else {
536
- // Determine fork from slot in JSON payload
537
- fork = config.getForkName((body as SignedBlindedBeaconBlock).message.slot);
538
- }
539
-
540
- return {
541
- signedBlindedBlock: getPostBellatrixForkTypes(fork).SignedBlindedBeaconBlock.fromJson(body),
542
- };
543
- },
544
- writeReqSsz: ({signedBlindedBlock}) => {
545
- const fork = config.getForkName(signedBlindedBlock.message.slot);
546
- return {
547
- body: getPostBellatrixForkTypes(fork).SignedBlindedBeaconBlock.serialize(signedBlindedBlock),
548
- headers: {
549
- [MetaHeader.Version]: fork,
550
- },
551
- };
552
- },
553
- parseReqSsz: ({body, headers}) => {
554
- const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
555
- return {
556
- signedBlindedBlock: getPostBellatrixForkTypes(fork).SignedBlindedBeaconBlock.deserialize(body),
557
- };
558
- },
559
- schema: {
560
- body: Schema.Object,
561
- headers: {[MetaHeader.Version]: Schema.String},
562
- },
563
- },
564
- resp: EmptyResponseCodec,
565
- init: {
566
- requestWireFormat: WireFormat.ssz,
567
- },
568
- },
569
403
  publishBlindedBlockV2: {
570
404
  url: "/eth/v2/beacon/blinded_blocks",
571
405
  method: "POST",
@@ -71,18 +71,6 @@ type PayloadAttestationMessageList = ValueOf<typeof PayloadAttestationMessageLis
71
71
  type SignedProposerPreferencesList = ValueOf<typeof SignedProposerPreferencesListType>;
72
72
 
73
73
  export type Endpoints = {
74
- /**
75
- * Get Attestations from operations pool
76
- * Retrieves attestations known by the node but not necessarily incorporated into any block
77
- */
78
- getPoolAttestations: Endpoint<
79
- "GET",
80
- {slot?: Slot; committeeIndex?: CommitteeIndex},
81
- {query: {slot?: number; committee_index?: number}},
82
- AttestationListPhase0,
83
- EmptyMeta
84
- >;
85
-
86
74
  /**
87
75
  * Get Attestations from operations pool
88
76
  * Retrieves attestations known by the node but not necessarily incorporated into any block
@@ -119,19 +107,6 @@ export type Endpoints = {
119
107
  VersionMeta
120
108
  >;
121
109
 
122
- /**
123
- * Get AttesterSlashings from operations pool
124
- * Retrieves attester slashings known by the node but not necessarily incorporated into any block
125
- */
126
- getPoolAttesterSlashings: Endpoint<
127
- // ⏎
128
- "GET",
129
- EmptyArgs,
130
- EmptyRequest,
131
- AttesterSlashingListPhase0,
132
- EmptyMeta
133
- >;
134
-
135
110
  /**
136
111
  * Get AttesterSlashings from operations pool
137
112
  * Retrieves attester slashings known by the node but not necessarily incorporated into any block
@@ -184,22 +159,6 @@ export type Endpoints = {
184
159
  EmptyMeta
185
160
  >;
186
161
 
187
- /**
188
- * Submit Attestation objects to node
189
- * Submits Attestation objects to the node. Each attestation in the request body is processed individually.
190
- *
191
- * If an attestation is validated successfully the node MUST publish that attestation on the appropriate subnet.
192
- *
193
- * If one or more attestations fail validation the node MUST return a 400 error with details of which attestations have failed, and why.
194
- */
195
- submitPoolAttestations: Endpoint<
196
- "POST",
197
- {signedAttestations: SingleAttestation<ForkPreElectra>[]},
198
- {body: unknown},
199
- EmptyResponseData,
200
- EmptyMeta
201
- >;
202
-
203
162
  /**
204
163
  * Submit Attestation objects to node
205
164
  * Submits Attestation objects to the node. Each attestation in the request body is processed individually.
@@ -216,18 +175,6 @@ export type Endpoints = {
216
175
  EmptyMeta
217
176
  >;
218
177
 
219
- /**
220
- * Submit AttesterSlashing object to node's pool
221
- * Submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.
222
- */
223
- submitPoolAttesterSlashings: Endpoint<
224
- "POST",
225
- {attesterSlashing: phase0.AttesterSlashing},
226
- {body: unknown},
227
- EmptyResponseData,
228
- EmptyMeta
229
- >;
230
-
231
178
  /**
232
179
  * Submit AttesterSlashing object to node's pool
233
180
  * Submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.
@@ -315,19 +262,6 @@ export type Endpoints = {
315
262
 
316
263
  export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoints> {
317
264
  return {
318
- getPoolAttestations: {
319
- url: "/eth/v1/beacon/pool/attestations",
320
- method: "GET",
321
- req: {
322
- writeReq: ({slot, committeeIndex}) => ({query: {slot, committee_index: committeeIndex}}),
323
- parseReq: ({query}) => ({slot: query.slot, committeeIndex: query.committee_index}),
324
- schema: {query: {slot: Schema.Uint, committee_index: Schema.Uint}},
325
- },
326
- resp: {
327
- data: AttestationListTypePhase0,
328
- meta: EmptyMetaCodec,
329
- },
330
- },
331
265
  getPoolAttestationsV2: {
332
266
  url: "/eth/v2/beacon/pool/attestations",
333
267
  method: "GET",
@@ -367,15 +301,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
367
301
  meta: VersionCodec,
368
302
  },
369
303
  },
370
- getPoolAttesterSlashings: {
371
- url: "/eth/v1/beacon/pool/attester_slashings",
372
- method: "GET",
373
- req: EmptyRequestCodec,
374
- resp: {
375
- data: AttesterSlashingListTypePhase0,
376
- meta: EmptyMetaCodec,
377
- },
378
- },
379
304
  getPoolAttesterSlashingsV2: {
380
305
  url: "/eth/v2/beacon/pool/attester_slashings",
381
306
  method: "GET",
@@ -414,20 +339,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
414
339
  meta: EmptyMetaCodec,
415
340
  },
416
341
  },
417
- submitPoolAttestations: {
418
- url: "/eth/v1/beacon/pool/attestations",
419
- method: "POST",
420
- req: {
421
- writeReqJson: ({signedAttestations}) => ({body: SingleAttestationListTypePhase0.toJson(signedAttestations)}),
422
- parseReqJson: ({body}) => ({signedAttestations: SingleAttestationListTypePhase0.fromJson(body)}),
423
- writeReqSsz: ({signedAttestations}) => ({body: SingleAttestationListTypePhase0.serialize(signedAttestations)}),
424
- parseReqSsz: ({body}) => ({signedAttestations: SingleAttestationListTypePhase0.deserialize(body)}),
425
- schema: {
426
- body: Schema.ObjectArray,
427
- },
428
- },
429
- resp: EmptyResponseCodec,
430
- },
431
342
  submitPoolAttestationsV2: {
432
343
  url: "/eth/v2/beacon/pool/attestations",
433
344
  method: "POST",
@@ -473,20 +384,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
473
384
  },
474
385
  resp: EmptyResponseCodec,
475
386
  },
476
- submitPoolAttesterSlashings: {
477
- url: "/eth/v1/beacon/pool/attester_slashings",
478
- method: "POST",
479
- req: {
480
- writeReqJson: ({attesterSlashing}) => ({body: ssz.phase0.AttesterSlashing.toJson(attesterSlashing)}),
481
- parseReqJson: ({body}) => ({attesterSlashing: ssz.phase0.AttesterSlashing.fromJson(body)}),
482
- writeReqSsz: ({attesterSlashing}) => ({body: ssz.phase0.AttesterSlashing.serialize(attesterSlashing)}),
483
- parseReqSsz: ({body}) => ({attesterSlashing: ssz.phase0.AttesterSlashing.deserialize(body)}),
484
- schema: {
485
- body: Schema.Object,
486
- },
487
- },
488
- resp: EmptyResponseCodec,
489
- },
490
387
  submitPoolAttesterSlashingsV2: {
491
388
  url: "/eth/v2/beacon/pool/attester_slashings",
492
389
  method: "POST",
@@ -110,6 +110,8 @@ export enum EventType {
110
110
  executionPayloadBid = "execution_payload_bid",
111
111
  /** The node has received a `SignedProposerPreferences` (from P2P or API) that passes gossip validation on the `proposer_preferences` topic */
112
112
  proposerPreferences = "proposer_preferences",
113
+ /** The node has executed the Fast Confirmation Rule and produced a confirmed beacon block */
114
+ fastConfirmation = "fast_confirmation",
113
115
  }
114
116
 
115
117
  export const eventTypes: {[K in EventType]: K} = {
@@ -135,6 +137,7 @@ export const eventTypes: {[K in EventType]: K} = {
135
137
  [EventType.executionPayloadAvailable]: EventType.executionPayloadAvailable,
136
138
  [EventType.executionPayloadBid]: EventType.executionPayloadBid,
137
139
  [EventType.proposerPreferences]: EventType.proposerPreferences,
140
+ [EventType.fastConfirmation]: EventType.fastConfirmation,
138
141
  };
139
142
 
140
143
  export type EventData = {
@@ -203,6 +206,11 @@ export type EventData = {
203
206
  };
204
207
  [EventType.executionPayloadBid]: {version: ForkName; data: gloas.SignedExecutionPayloadBid};
205
208
  [EventType.proposerPreferences]: {version: ForkName; data: gloas.SignedProposerPreferences};
209
+ [EventType.fastConfirmation]: {
210
+ block: RootHex;
211
+ slot: Slot;
212
+ currentSlot: Slot;
213
+ };
206
214
  };
207
215
 
208
216
  export type BeaconEvent = {[K in EventType]: {type: K; message: EventData[K]}}[EventType];
@@ -400,6 +408,14 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type
400
408
  ),
401
409
  [EventType.executionPayloadBid]: WithVersion((fork) => getPostGloasForkTypes(fork).SignedExecutionPayloadBid),
402
410
  [EventType.proposerPreferences]: WithVersion((fork) => getPostGloasForkTypes(fork).SignedProposerPreferences),
411
+ [EventType.fastConfirmation]: new ContainerType(
412
+ {
413
+ block: stringType,
414
+ slot: ssz.Slot,
415
+ currentSlot: ssz.Slot,
416
+ },
417
+ {jsonCase: "eth2"}
418
+ ),
403
419
 
404
420
  [EventType.lightClientOptimisticUpdate]: WithVersion(
405
421
  (fork) => getPostAltairForkTypes(fork).LightClientOptimisticUpdate
@@ -600,8 +600,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
600
600
  meta: ExecutionOptimisticFinalizedAndVersionCodec,
601
601
  },
602
602
  },
603
- // TODO GLOAS: this endpoint needs to be updated because post-gloas there could be two variants of the persisted checkpoint state (empty or full).
604
- // Either add a an additional parameter `payloadPresent`, or return one or both variants of state.
605
603
  getPersistedCheckpointState: {
606
604
  url: "/eth/v1/lodestar/persisted_checkpoint_state",
607
605
  method: "GET",
@@ -499,23 +499,6 @@ export type Endpoints = {
499
499
  EmptyMeta
500
500
  >;
501
501
 
502
- /**
503
- * Get aggregated attestation
504
- * Aggregates all attestations matching given attestation data root and slot
505
- * Returns an aggregated `Attestation` object with same `AttestationData` root.
506
- */
507
- getAggregatedAttestation: Endpoint<
508
- "GET",
509
- {
510
- /** HashTreeRoot of AttestationData that validator want's aggregated */
511
- attestationDataRoot: Root;
512
- slot: Slot;
513
- },
514
- {query: {attestation_data_root: string; slot: number}},
515
- phase0.Attestation,
516
- EmptyMeta
517
- >;
518
-
519
502
  /**
520
503
  * Get aggregated attestation
521
504
  * Aggregates all attestations matching given attestation data root, slot and committee index
@@ -534,18 +517,6 @@ export type Endpoints = {
534
517
  VersionMeta
535
518
  >;
536
519
 
537
- /**
538
- * Publish multiple aggregate and proofs
539
- * Verifies given aggregate and proofs and publishes them on appropriate gossipsub topic.
540
- */
541
- publishAggregateAndProofs: Endpoint<
542
- "POST",
543
- {signedAggregateAndProofs: SignedAggregateAndProofListPhase0},
544
- {body: unknown},
545
- EmptyResponseData,
546
- EmptyMeta
547
- >;
548
-
549
520
  /**
550
521
  * Publish multiple aggregate and proofs
551
522
  * Verifies given aggregate and proofs and publishes them on appropriate gossipsub topic.
@@ -1040,29 +1011,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
1040
1011
  meta: EmptyMetaCodec,
1041
1012
  },
1042
1013
  },
1043
- getAggregatedAttestation: {
1044
- url: "/eth/v1/validator/aggregate_attestation",
1045
- method: "GET",
1046
- req: {
1047
- writeReq: ({attestationDataRoot, slot}) => ({
1048
- query: {attestation_data_root: toRootHex(attestationDataRoot), slot},
1049
- }),
1050
- parseReq: ({query}) => ({
1051
- attestationDataRoot: fromHex(query.attestation_data_root),
1052
- slot: query.slot,
1053
- }),
1054
- schema: {
1055
- query: {
1056
- attestation_data_root: Schema.StringRequired,
1057
- slot: Schema.UintRequired,
1058
- },
1059
- },
1060
- },
1061
- resp: {
1062
- data: ssz.phase0.Attestation,
1063
- meta: EmptyMetaCodec,
1064
- },
1065
- },
1066
1014
  getAggregatedAttestationV2: {
1067
1015
  url: "/eth/v2/validator/aggregate_attestation",
1068
1016
  method: "GET",
@@ -1088,28 +1036,6 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
1088
1036
  meta: VersionCodec,
1089
1037
  },
1090
1038
  },
1091
- publishAggregateAndProofs: {
1092
- url: "/eth/v1/validator/aggregate_and_proofs",
1093
- method: "POST",
1094
- req: {
1095
- writeReqJson: ({signedAggregateAndProofs}) => ({
1096
- body: SignedAggregateAndProofListPhase0Type.toJson(signedAggregateAndProofs),
1097
- }),
1098
- parseReqJson: ({body}) => ({
1099
- signedAggregateAndProofs: SignedAggregateAndProofListPhase0Type.fromJson(body),
1100
- }),
1101
- writeReqSsz: ({signedAggregateAndProofs}) => ({
1102
- body: SignedAggregateAndProofListPhase0Type.serialize(signedAggregateAndProofs),
1103
- }),
1104
- parseReqSsz: ({body}) => ({
1105
- signedAggregateAndProofs: SignedAggregateAndProofListPhase0Type.deserialize(body),
1106
- }),
1107
- schema: {
1108
- body: Schema.ObjectArray,
1109
- },
1110
- },
1111
- resp: EmptyResponseCodec,
1112
- },
1113
1039
  publishAggregateAndProofsV2: {
1114
1040
  url: "/eth/v2/validator/aggregate_and_proofs",
1115
1041
  method: "POST",