@lodestar/api 1.51.0-dev.c99cf49add → 1.51.0-dev.cda05d18f1
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.
- package/lib/beacon/index.d.ts +1 -1
- package/lib/beacon/index.d.ts.map +1 -1
- package/lib/beacon/index.js +1 -1
- package/lib/beacon/index.js.map +1 -1
- package/lib/beacon/routes/beacon/block.d.ts +4 -10
- package/lib/beacon/routes/beacon/block.d.ts.map +1 -1
- package/lib/beacon/routes/beacon/block.js +0 -8
- package/lib/beacon/routes/beacon/block.js.map +1 -1
- package/lib/beacon/routes/beacon/index.d.ts +1 -1
- package/lib/beacon/routes/beacon/index.d.ts.map +1 -1
- package/lib/beacon/routes/beacon/index.js +2 -2
- package/lib/beacon/routes/beacon/index.js.map +1 -1
- package/lib/beacon/routes/events.d.ts +7 -1
- package/lib/beacon/routes/events.d.ts.map +1 -1
- package/lib/beacon/routes/events.js +4 -0
- package/lib/beacon/routes/events.js.map +1 -1
- package/lib/beacon/routes/lodestar.js +1 -1
- package/lib/beacon/routes/lodestar.js.map +1 -1
- package/lib/beacon/routes/validator.d.ts +62 -1
- package/lib/beacon/routes/validator.d.ts.map +1 -1
- package/lib/beacon/routes/validator.js +65 -0
- package/lib/beacon/routes/validator.js.map +1 -1
- package/lib/keymanager/index.d.ts.map +1 -1
- package/lib/keymanager/index.js.map +1 -1
- package/lib/utils/client/httpClient.d.ts.map +1 -1
- package/lib/utils/client/httpClient.js +5 -2
- package/lib/utils/client/httpClient.js.map +1 -1
- package/lib/utils/server/method.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/beacon/index.ts +1 -1
- package/src/beacon/routes/beacon/block.ts +4 -10
- package/src/beacon/routes/beacon/index.ts +3 -4
- package/src/beacon/routes/events.ts +6 -0
- package/src/beacon/routes/lodestar.ts +1 -1
- package/src/beacon/routes/validator.ts +116 -0
- package/src/keymanager/index.ts +0 -1
- package/src/utils/client/httpClient.ts +5 -2
- package/src/utils/server/method.ts +4 -3
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
UintBn64,
|
|
29
29
|
ValidatorIndex,
|
|
30
30
|
altair,
|
|
31
|
+
bellatrix,
|
|
31
32
|
gloas,
|
|
33
|
+
heze,
|
|
32
34
|
phase0,
|
|
33
35
|
ssz,
|
|
34
36
|
sszTypesFor,
|
|
@@ -269,6 +271,20 @@ export const SignedProposerPreferencesListType = ArrayOf(
|
|
|
269
271
|
ssz.gloas.SignedProposerPreferences,
|
|
270
272
|
(MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
|
|
271
273
|
);
|
|
274
|
+
export const InclusionListDutyType = new ContainerType(
|
|
275
|
+
{
|
|
276
|
+
/** The validator's public key, uniquely identifying them */
|
|
277
|
+
pubkey: ssz.BLSPubkey,
|
|
278
|
+
/** Index of validator in validator registry */
|
|
279
|
+
validatorIndex: ssz.ValidatorIndex,
|
|
280
|
+
/** The slot at which the validator must produce the inclusion list */
|
|
281
|
+
slot: ssz.Slot,
|
|
282
|
+
/** Shuffling dependent root of the duty's epoch, to set as `dependent_root` on the inclusion list */
|
|
283
|
+
dependentRoot: ssz.Root,
|
|
284
|
+
},
|
|
285
|
+
{jsonCase: "eth2"}
|
|
286
|
+
);
|
|
287
|
+
export const InclusionListDutyListType = ArrayOf(InclusionListDutyType);
|
|
272
288
|
|
|
273
289
|
// The url is UTF-8 bytes on the SSZ wire but a plain string in JSON
|
|
274
290
|
class BuilderUrlType extends ByteListType {
|
|
@@ -323,6 +339,8 @@ export const BuilderPreferencesEntryListType = ArrayOf(
|
|
|
323
339
|
MAX_BUILDER_ENTRIES * (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
|
|
324
340
|
);
|
|
325
341
|
|
|
342
|
+
export type InclusionListDuty = ValueOf<typeof InclusionListDutyType>;
|
|
343
|
+
export type InclusionListDutyList = ValueOf<typeof InclusionListDutyListType>;
|
|
326
344
|
export type ValidatorIndices = ValueOf<typeof ValidatorIndicesType>;
|
|
327
345
|
export type AttesterDuty = ValueOf<typeof AttesterDutyType>;
|
|
328
346
|
export type AttesterDutyList = ValueOf<typeof AttesterDutyListType>;
|
|
@@ -773,6 +791,50 @@ export type Endpoints = {
|
|
|
773
791
|
EmptyResponseData,
|
|
774
792
|
EmptyMeta
|
|
775
793
|
>;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Get inclusion list committee duties
|
|
797
|
+
* Requests the beacon node to provide a set of inclusion list committee duties for a particular epoch.
|
|
798
|
+
*/
|
|
799
|
+
getInclusionListCommitteeDuties: Endpoint<
|
|
800
|
+
"POST",
|
|
801
|
+
{
|
|
802
|
+
/** Should only be allowed 1 epoch ahead */
|
|
803
|
+
epoch: Epoch;
|
|
804
|
+
/** An array of the validator indices for which to obtain the duties */
|
|
805
|
+
indices: ValidatorIndices;
|
|
806
|
+
},
|
|
807
|
+
{params: {epoch: Epoch}; body: unknown},
|
|
808
|
+
InclusionListDutyList,
|
|
809
|
+
ExecutionOptimisticAndDependentRootMeta
|
|
810
|
+
>;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Produce an inclusion list
|
|
814
|
+
* Requests the beacon node to produce the transactions for an inclusion list at the given slot.
|
|
815
|
+
*/
|
|
816
|
+
produceInclusionList: Endpoint<
|
|
817
|
+
"GET",
|
|
818
|
+
{
|
|
819
|
+
/** The slot for which an inclusion list should be created */
|
|
820
|
+
slot: Slot;
|
|
821
|
+
},
|
|
822
|
+
{query: {slot: number}},
|
|
823
|
+
bellatrix.Transactions,
|
|
824
|
+
VersionMeta
|
|
825
|
+
>;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Publish inclusion list
|
|
829
|
+
* Verifies the given inclusion list and publishes it on the `inclusion_list` gossipsub topic.
|
|
830
|
+
*/
|
|
831
|
+
publishInclusionList: Endpoint<
|
|
832
|
+
"POST",
|
|
833
|
+
{signedInclusionList: heze.SignedInclusionList},
|
|
834
|
+
{body: unknown; headers: {[MetaHeader.Version]: string}},
|
|
835
|
+
EmptyResponseData,
|
|
836
|
+
EmptyMeta
|
|
837
|
+
>;
|
|
776
838
|
};
|
|
777
839
|
|
|
778
840
|
export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoints> {
|
|
@@ -1453,6 +1515,60 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
|
|
|
1453
1515
|
requestWireFormat: WireFormat.ssz,
|
|
1454
1516
|
},
|
|
1455
1517
|
},
|
|
1518
|
+
getInclusionListCommitteeDuties: {
|
|
1519
|
+
url: "/eth/v1/validator/duties/inclusion_list/{epoch}",
|
|
1520
|
+
method: "POST",
|
|
1521
|
+
req: {
|
|
1522
|
+
writeReqJson: ({epoch, indices}) => ({params: {epoch}, body: ValidatorIndicesType.toJson(indices)}),
|
|
1523
|
+
parseReqJson: ({params, body}) => ({epoch: params.epoch, indices: ValidatorIndicesType.fromJson(body)}),
|
|
1524
|
+
writeReqSsz: ({epoch, indices}) => ({params: {epoch}, body: ValidatorIndicesType.serialize(indices)}),
|
|
1525
|
+
parseReqSsz: ({params, body}) => ({epoch: params.epoch, indices: ValidatorIndicesType.deserialize(body)}),
|
|
1526
|
+
schema: {
|
|
1527
|
+
params: {epoch: Schema.UintRequired},
|
|
1528
|
+
body: Schema.StringArray,
|
|
1529
|
+
},
|
|
1530
|
+
},
|
|
1531
|
+
resp: {
|
|
1532
|
+
data: InclusionListDutyListType,
|
|
1533
|
+
meta: ExecutionOptimisticAndDependentRootCodec,
|
|
1534
|
+
},
|
|
1535
|
+
},
|
|
1536
|
+
produceInclusionList: {
|
|
1537
|
+
url: "/eth/v1/validator/inclusion_list",
|
|
1538
|
+
method: "GET",
|
|
1539
|
+
req: {
|
|
1540
|
+
writeReq: ({slot}) => ({query: {slot}}),
|
|
1541
|
+
parseReq: ({query}) => ({slot: query.slot}),
|
|
1542
|
+
schema: {
|
|
1543
|
+
query: {slot: Schema.UintRequired},
|
|
1544
|
+
},
|
|
1545
|
+
},
|
|
1546
|
+
resp: {
|
|
1547
|
+
data: ssz.bellatrix.Transactions,
|
|
1548
|
+
meta: VersionCodec,
|
|
1549
|
+
},
|
|
1550
|
+
},
|
|
1551
|
+
publishInclusionList: {
|
|
1552
|
+
url: "/eth/v1/validator/inclusion_list",
|
|
1553
|
+
method: "POST",
|
|
1554
|
+
req: {
|
|
1555
|
+
writeReqJson: ({signedInclusionList}) => ({
|
|
1556
|
+
body: ssz.heze.SignedInclusionList.toJson(signedInclusionList),
|
|
1557
|
+
headers: {[MetaHeader.Version]: config.getForkName(signedInclusionList.message.slot)},
|
|
1558
|
+
}),
|
|
1559
|
+
parseReqJson: ({body}) => ({signedInclusionList: ssz.heze.SignedInclusionList.fromJson(body)}),
|
|
1560
|
+
writeReqSsz: ({signedInclusionList}) => ({
|
|
1561
|
+
body: ssz.heze.SignedInclusionList.serialize(signedInclusionList),
|
|
1562
|
+
headers: {[MetaHeader.Version]: config.getForkName(signedInclusionList.message.slot)},
|
|
1563
|
+
}),
|
|
1564
|
+
parseReqSsz: ({body}) => ({signedInclusionList: ssz.heze.SignedInclusionList.deserialize(body)}),
|
|
1565
|
+
schema: {
|
|
1566
|
+
body: Schema.Object,
|
|
1567
|
+
headers: {[MetaHeader.Version]: Schema.String},
|
|
1568
|
+
},
|
|
1569
|
+
},
|
|
1570
|
+
resp: EmptyResponseCodec,
|
|
1571
|
+
},
|
|
1456
1572
|
};
|
|
1457
1573
|
}
|
|
1458
1574
|
|
package/src/keymanager/index.ts
CHANGED
|
@@ -353,12 +353,15 @@ export class HttpClient implements IHttpClient {
|
|
|
353
353
|
// Implement fetch timeout
|
|
354
354
|
const controller = new AbortController();
|
|
355
355
|
const timeout = setTimeout(() => controller.abort(), init.timeoutMs);
|
|
356
|
-
init.signal = controller.signal;
|
|
357
356
|
|
|
358
357
|
// Attach global/local signal to this request's controller
|
|
358
|
+
// Check already-aborted after subscribe to avoid a race where abort fires between the check and addEventListener
|
|
359
359
|
const onSignalAbort = (): void => controller.abort();
|
|
360
360
|
for (const s of abortSignals) {
|
|
361
361
|
s?.addEventListener("abort", onSignalAbort);
|
|
362
|
+
if (s?.aborted) {
|
|
363
|
+
controller.abort();
|
|
364
|
+
}
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
const routeId = definition.operationId;
|
|
@@ -367,7 +370,7 @@ export class HttpClient implements IHttpClient {
|
|
|
367
370
|
|
|
368
371
|
try {
|
|
369
372
|
this.logger?.debug("API request", {routeId, requestWireFormat, responseWireFormat});
|
|
370
|
-
const {url, requestInit} = createApiRequest(definition, args, init);
|
|
373
|
+
const {url, requestInit} = createApiRequest(definition, args, {...init, signal: controller.signal});
|
|
371
374
|
const response = await this.fetch(url, requestInit);
|
|
372
375
|
const apiResponse = new ApiResponse(definition, response.body, response);
|
|
373
376
|
|
|
@@ -12,9 +12,10 @@ type ApplicationResponseObject<E extends Endpoint> = {
|
|
|
12
12
|
: {data: E["return"] | (E["return"] extends undefined ? undefined : Uint8Array)}) &
|
|
13
13
|
(E["meta"] extends EmptyMeta ? {meta?: never} : {meta: E["meta"]});
|
|
14
14
|
|
|
15
|
-
export type ApplicationResponse<E extends Endpoint> =
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export type ApplicationResponse<E extends Endpoint> =
|
|
16
|
+
HasOnlyOptionalProps<ApplicationResponseObject<E>> extends true
|
|
17
|
+
? ApplicationResponseObject<E> | void
|
|
18
|
+
: ApplicationResponseObject<E>;
|
|
18
19
|
|
|
19
20
|
export type ApiContext = {
|
|
20
21
|
/**
|