@lodestar/api 1.41.0-dev.702f7932c2 → 1.41.0-dev.8578102bd2

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 (107) hide show
  1. package/lib/beacon/client/beacon.js.map +1 -1
  2. package/lib/beacon/client/config.js.map +1 -1
  3. package/lib/beacon/client/debug.js.map +1 -1
  4. package/lib/beacon/client/events.js.map +1 -1
  5. package/lib/beacon/client/index.js.map +1 -1
  6. package/lib/beacon/client/lightclient.js.map +1 -1
  7. package/lib/beacon/client/lodestar.js.map +1 -1
  8. package/lib/beacon/client/node.js.map +1 -1
  9. package/lib/beacon/client/proof.js.map +1 -1
  10. package/lib/beacon/client/validator.js.map +1 -1
  11. package/lib/beacon/index.d.ts +1 -1
  12. package/lib/beacon/index.d.ts.map +1 -1
  13. package/lib/beacon/routes/beacon/block.d.ts +15 -1
  14. package/lib/beacon/routes/beacon/block.d.ts.map +1 -1
  15. package/lib/beacon/routes/beacon/block.js +52 -7
  16. package/lib/beacon/routes/beacon/block.js.map +1 -1
  17. package/lib/beacon/routes/beacon/index.js.map +1 -1
  18. package/lib/beacon/routes/beacon/pool.js.map +1 -1
  19. package/lib/beacon/routes/beacon/rewards.js.map +1 -1
  20. package/lib/beacon/routes/beacon/state.js.map +1 -1
  21. package/lib/beacon/routes/config.js.map +1 -1
  22. package/lib/beacon/routes/debug.d.ts +3 -3
  23. package/lib/beacon/routes/debug.d.ts.map +1 -1
  24. package/lib/beacon/routes/debug.js +3 -2
  25. package/lib/beacon/routes/debug.js.map +1 -1
  26. package/lib/beacon/routes/events.d.ts +615 -1
  27. package/lib/beacon/routes/events.d.ts.map +1 -1
  28. package/lib/beacon/routes/events.js +2 -1
  29. package/lib/beacon/routes/events.js.map +1 -1
  30. package/lib/beacon/routes/lightclient.js.map +1 -1
  31. package/lib/beacon/routes/lodestar.js.map +1 -1
  32. package/lib/beacon/routes/node.d.ts +13 -13
  33. package/lib/beacon/routes/node.d.ts.map +1 -1
  34. package/lib/beacon/routes/node.js +14 -5
  35. package/lib/beacon/routes/node.js.map +1 -1
  36. package/lib/beacon/routes/proof.js.map +1 -1
  37. package/lib/beacon/routes/validator.d.ts +55 -2
  38. package/lib/beacon/routes/validator.d.ts.map +1 -1
  39. package/lib/beacon/routes/validator.js +89 -2
  40. package/lib/beacon/routes/validator.js.map +1 -1
  41. package/lib/beacon/server/beacon.js.map +1 -1
  42. package/lib/beacon/server/config.js.map +1 -1
  43. package/lib/beacon/server/debug.js.map +1 -1
  44. package/lib/beacon/server/events.js.map +1 -1
  45. package/lib/beacon/server/index.js.map +1 -1
  46. package/lib/beacon/server/lightclient.js.map +1 -1
  47. package/lib/beacon/server/lodestar.js.map +1 -1
  48. package/lib/beacon/server/node.js.map +1 -1
  49. package/lib/beacon/server/proof.js.map +1 -1
  50. package/lib/beacon/server/validator.js.map +1 -1
  51. package/lib/builder/client.js.map +1 -1
  52. package/lib/builder/index.js.map +1 -1
  53. package/lib/builder/routes.js.map +1 -1
  54. package/lib/builder/server/index.js.map +1 -1
  55. package/lib/keymanager/client.js.map +1 -1
  56. package/lib/keymanager/index.js.map +1 -1
  57. package/lib/keymanager/routes.js +8 -4
  58. package/lib/keymanager/routes.js.map +1 -1
  59. package/lib/keymanager/server/index.js.map +1 -1
  60. package/lib/utils/client/error.d.ts.map +1 -1
  61. package/lib/utils/client/error.js.map +1 -1
  62. package/lib/utils/client/eventSource.js.map +1 -1
  63. package/lib/utils/client/format.js.map +1 -1
  64. package/lib/utils/client/httpClient.d.ts +0 -14
  65. package/lib/utils/client/httpClient.d.ts.map +1 -1
  66. package/lib/utils/client/httpClient.js +3 -0
  67. package/lib/utils/client/httpClient.js.map +1 -1
  68. package/lib/utils/client/method.js.map +1 -1
  69. package/lib/utils/client/request.js.map +1 -1
  70. package/lib/utils/client/response.d.ts.map +1 -1
  71. package/lib/utils/client/response.js +3 -0
  72. package/lib/utils/client/response.js.map +1 -1
  73. package/lib/utils/codecs.js.map +1 -1
  74. package/lib/utils/fork.d.ts +2 -1
  75. package/lib/utils/fork.d.ts.map +1 -1
  76. package/lib/utils/fork.js +7 -1
  77. package/lib/utils/fork.js.map +1 -1
  78. package/lib/utils/headers.d.ts.map +1 -1
  79. package/lib/utils/headers.js +4 -2
  80. package/lib/utils/headers.js.map +1 -1
  81. package/lib/utils/httpStatusCode.js +2 -1
  82. package/lib/utils/httpStatusCode.js.map +1 -1
  83. package/lib/utils/metadata.d.ts +11 -11
  84. package/lib/utils/metadata.d.ts.map +1 -1
  85. package/lib/utils/metadata.js +2 -1
  86. package/lib/utils/metadata.js.map +1 -1
  87. package/lib/utils/schema.js +2 -1
  88. package/lib/utils/schema.js.map +1 -1
  89. package/lib/utils/serdes.js.map +1 -1
  90. package/lib/utils/server/error.d.ts.map +1 -1
  91. package/lib/utils/server/error.js.map +1 -1
  92. package/lib/utils/server/handler.js.map +1 -1
  93. package/lib/utils/server/parser.js.map +1 -1
  94. package/lib/utils/server/route.js.map +1 -1
  95. package/lib/utils/types.js.map +1 -1
  96. package/lib/utils/urlFormat.js +2 -1
  97. package/lib/utils/urlFormat.js.map +1 -1
  98. package/lib/utils/wireFormat.js +2 -1
  99. package/lib/utils/wireFormat.js.map +1 -1
  100. package/package.json +9 -9
  101. package/src/beacon/routes/beacon/block.ts +87 -19
  102. package/src/beacon/routes/debug.ts +6 -3
  103. package/src/beacon/routes/node.ts +4 -0
  104. package/src/beacon/routes/validator.ts +157 -1
  105. package/src/utils/client/httpClient.ts +4 -0
  106. package/src/utils/client/response.ts +4 -0
  107. package/src/utils/fork.ts +10 -0
@@ -1,6 +1,7 @@
1
1
  import {ContainerType, Type, ValueOf} from "@chainsafe/ssz";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
- import {ArrayOf, BeaconState, StringType, fulu, ssz} from "@lodestar/types";
3
+ import {isForkPostFulu} from "@lodestar/params";
4
+ import {ArrayOf, BeaconState, DataColumnSidecars, StringType, ssz, sszTypesFor} from "@lodestar/types";
4
5
  import {
5
6
  EmptyArgs,
6
7
  EmptyMeta,
@@ -149,7 +150,7 @@ export type Endpoints = {
149
150
  indices?: number[];
150
151
  },
151
152
  {params: {block_id: string}; query: {indices?: number[]}},
152
- fulu.DataColumnSidecars,
153
+ DataColumnSidecars,
153
154
  ExecutionOptimisticFinalizedAndVersionMeta
154
155
  >;
155
156
  };
@@ -222,7 +223,9 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
222
223
  schema: {params: {block_id: Schema.StringRequired}, query: {indices: Schema.UintArray}},
223
224
  },
224
225
  resp: {
225
- data: ssz.fulu.DataColumnSidecars,
226
+ data: WithVersion((fork) =>
227
+ isForkPostFulu(fork) ? sszTypesFor(fork).DataColumnSidecars : ssz.fulu.DataColumnSidecars
228
+ ),
226
229
  meta: ExecutionOptimisticFinalizedAndVersionCodec,
227
230
  },
228
231
  },
@@ -15,6 +15,10 @@ import {HttpStatusCode} from "../../utils/httpStatusCode.js";
15
15
  import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
16
16
  import {WireFormat} from "../../utils/wireFormat.js";
17
17
 
18
+ // TODO: Workaround for tsgo import-elision bug: ensure this is treated as a runtime value.
19
+ // https://github.com/microsoft/typescript-go/issues/2212
20
+ void HttpStatusCode;
21
+
18
22
  export const NetworkIdentityType = new ContainerType(
19
23
  {
20
24
  /** Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) */
@@ -2,6 +2,7 @@ import {ContainerType, Type, ValueOf} from "@chainsafe/ssz";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {
4
4
  ForkPostDeneb,
5
+ ForkPostGloas,
5
6
  ForkPreDeneb,
6
7
  VALIDATOR_REGISTRY_LIMIT,
7
8
  isForkPostDeneb,
@@ -22,6 +23,7 @@ import {
22
23
  UintBn64,
23
24
  ValidatorIndex,
24
25
  altair,
26
+ gloas,
25
27
  phase0,
26
28
  ssz,
27
29
  sszTypesFor,
@@ -36,7 +38,7 @@ import {
36
38
  JsonOnlyReq,
37
39
  WithVersion,
38
40
  } from "../../utils/codecs.js";
39
- import {getPostBellatrixForkTypes, toForkName} from "../../utils/fork.js";
41
+ import {getPostBellatrixForkTypes, getPostGloasForkTypes, toForkName} from "../../utils/fork.js";
40
42
  import {fromHeaders} from "../../utils/headers.js";
41
43
  import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
42
44
  import {
@@ -89,6 +91,17 @@ export type ProduceBlockV3Meta = ValueOf<typeof ProduceBlockV3MetaType> & {
89
91
  executionPayloadSource: ProducedBlockSource;
90
92
  };
91
93
 
94
+ export const ProduceBlockV4MetaType = new ContainerType(
95
+ {
96
+ ...VersionType.fields,
97
+ /** Consensus rewards paid to the proposer for this block, in Wei */
98
+ consensusBlockValue: ssz.UintBn64,
99
+ },
100
+ {jsonCase: "eth2"}
101
+ );
102
+
103
+ export type ProduceBlockV4Meta = ValueOf<typeof ProduceBlockV4MetaType>;
104
+
92
105
  export const AttesterDutyType = new ContainerType(
93
106
  {
94
107
  /** The validator's public key, uniquely identifying them */
@@ -357,6 +370,59 @@ export type Endpoints = {
357
370
  ProduceBlockV3Meta
358
371
  >;
359
372
 
373
+ /**
374
+ * Requests a beacon node to produce a valid block, which can then be signed by a validator.
375
+ *
376
+ * Post-Gloas, proposers submit execution payload bids rather than full execution payloads,
377
+ * so there is no longer a concept of blinded or unblinded blocks. Builders release the payload later.
378
+ * This endpoint is specific to the post-Gloas forks and is not backwards compatible with previous forks.
379
+ */
380
+ produceBlockV4: Endpoint<
381
+ "GET",
382
+ {
383
+ /** The slot for which the block should be proposed */
384
+ slot: Slot;
385
+ /** The validator's randao reveal value */
386
+ randaoReveal: BLSSignature;
387
+ /** Arbitrary data validator wants to include in block */
388
+ graffiti?: string;
389
+ skipRandaoVerification?: boolean;
390
+ builderBoostFactor?: UintBn64;
391
+ } & Omit<ExtraProduceBlockOpts, "blindedLocal">,
392
+ {
393
+ params: {slot: number};
394
+ query: {
395
+ randao_reveal: string;
396
+ graffiti?: string;
397
+ skip_randao_verification?: string;
398
+ fee_recipient?: string;
399
+ builder_selection?: string;
400
+ builder_boost_factor?: string;
401
+ strict_fee_recipient_check?: boolean;
402
+ };
403
+ },
404
+ BeaconBlock<ForkPostGloas>,
405
+ ProduceBlockV4Meta
406
+ >;
407
+
408
+ /**
409
+ * Get execution payload envelope.
410
+ * Retrieves execution payload envelope for a given slot and beacon block root.
411
+ * The envelope contains the full execution payload along with associated metadata.
412
+ */
413
+ getExecutionPayloadEnvelope: Endpoint<
414
+ "GET",
415
+ {
416
+ /** Slot for which the execution payload envelope is requested */
417
+ slot: Slot;
418
+ /** Root of the beacon block that this envelope is for */
419
+ beaconBlockRoot: Root;
420
+ },
421
+ {params: {slot: Slot; beacon_block_root: string}},
422
+ gloas.ExecutionPayloadEnvelope,
423
+ VersionMeta
424
+ >;
425
+
360
426
  /**
361
427
  * Produce an attestation data
362
428
  * Requests that the beacon node produce an AttestationData.
@@ -763,6 +829,96 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
763
829
  },
764
830
  },
765
831
  },
832
+ produceBlockV4: {
833
+ url: "/eth/v4/validator/blocks/{slot}",
834
+ method: "GET",
835
+ req: {
836
+ writeReq: ({
837
+ slot,
838
+ randaoReveal,
839
+ graffiti,
840
+ skipRandaoVerification,
841
+ feeRecipient,
842
+ builderSelection,
843
+ builderBoostFactor,
844
+ strictFeeRecipientCheck,
845
+ }) => ({
846
+ params: {slot},
847
+ query: {
848
+ randao_reveal: toHex(randaoReveal),
849
+ graffiti: toGraffitiHex(graffiti),
850
+ skip_randao_verification: writeSkipRandaoVerification(skipRandaoVerification),
851
+ fee_recipient: feeRecipient,
852
+ builder_selection: builderSelection,
853
+ builder_boost_factor: builderBoostFactor?.toString(),
854
+ strict_fee_recipient_check: strictFeeRecipientCheck,
855
+ },
856
+ }),
857
+ parseReq: ({params, query}) => ({
858
+ slot: params.slot,
859
+ randaoReveal: fromHex(query.randao_reveal),
860
+ graffiti: fromGraffitiHex(query.graffiti),
861
+ skipRandaoVerification: parseSkipRandaoVerification(query.skip_randao_verification),
862
+ feeRecipient: query.fee_recipient,
863
+ builderSelection: query.builder_selection as BuilderSelection,
864
+ builderBoostFactor: parseBuilderBoostFactor(query.builder_boost_factor),
865
+ strictFeeRecipientCheck: query.strict_fee_recipient_check,
866
+ }),
867
+ schema: {
868
+ params: {slot: Schema.UintRequired},
869
+ query: {
870
+ randao_reveal: Schema.StringRequired,
871
+ graffiti: Schema.String,
872
+ skip_randao_verification: Schema.String,
873
+ fee_recipient: Schema.String,
874
+ builder_selection: Schema.String,
875
+ builder_boost_factor: Schema.String,
876
+ strict_fee_recipient_check: Schema.Boolean,
877
+ },
878
+ },
879
+ },
880
+ resp: {
881
+ data: WithVersion((fork) => getPostGloasForkTypes(fork).BeaconBlock),
882
+ meta: {
883
+ toJson: (meta) => ProduceBlockV4MetaType.toJson(meta),
884
+ fromJson: (val) => ProduceBlockV4MetaType.fromJson(val),
885
+ toHeadersObject: (meta) => ({
886
+ [MetaHeader.Version]: meta.version,
887
+ [MetaHeader.ConsensusBlockValue]: meta.consensusBlockValue.toString(),
888
+ }),
889
+ fromHeaders: (headers) => ({
890
+ version: toForkName(headers.getRequired(MetaHeader.Version)),
891
+ consensusBlockValue: BigInt(headers.getRequired(MetaHeader.ConsensusBlockValue)),
892
+ }),
893
+ },
894
+ },
895
+ },
896
+ getExecutionPayloadEnvelope: {
897
+ url: "/eth/v1/validator/execution_payload_envelope/{slot}/{beacon_block_root}",
898
+ method: "GET",
899
+ req: {
900
+ writeReq: ({slot, beaconBlockRoot}) => ({
901
+ params: {
902
+ slot,
903
+ beacon_block_root: toRootHex(beaconBlockRoot),
904
+ },
905
+ }),
906
+ parseReq: ({params}) => ({
907
+ slot: params.slot,
908
+ beaconBlockRoot: fromHex(params.beacon_block_root),
909
+ }),
910
+ schema: {
911
+ params: {
912
+ slot: Schema.UintRequired,
913
+ beacon_block_root: Schema.StringRequired,
914
+ },
915
+ },
916
+ },
917
+ resp: {
918
+ data: ssz.gloas.ExecutionPayloadEnvelope,
919
+ meta: VersionCodec,
920
+ },
921
+ },
766
922
  produceAttestationData: {
767
923
  url: "/eth/v1/validator/attestation_data",
768
924
  method: "GET",
@@ -25,6 +25,10 @@ import {
25
25
  } from "./request.js";
26
26
  import {ApiResponse} from "./response.js";
27
27
 
28
+ // TODO: Workaround for tsgo import-elision bug: ensure this is treated as a runtime value.
29
+ // https://github.com/microsoft/typescript-go/issues/2212
30
+ void HttpStatusCode;
31
+
28
32
  /** A higher default timeout, validator will set its own shorter timeoutMs */
29
33
  const DEFAULT_TIMEOUT_MS = 60_000;
30
34
  const DEFAULT_RETRIES = 0;
@@ -5,6 +5,10 @@ import {WireFormat, getWireFormat} from "../wireFormat.js";
5
5
  import {ApiError} from "./error.js";
6
6
  import {RouteDefinitionExtra} from "./request.js";
7
7
 
8
+ // TODO: Workaround for tsgo import-elision bug: ensure this is treated as a runtime value.
9
+ // https://github.com/microsoft/typescript-go/issues/2212
10
+ void HttpStatusCode;
11
+
8
12
  export type RawBody =
9
13
  | {type: WireFormat.json; value: unknown}
10
14
  | {type: WireFormat.ssz; value: Uint8Array}
package/src/utils/fork.ts CHANGED
@@ -3,9 +3,11 @@ import {
3
3
  ForkPostAltair,
4
4
  ForkPostBellatrix,
5
5
  ForkPostDeneb,
6
+ ForkPostGloas,
6
7
  isForkPostAltair,
7
8
  isForkPostBellatrix,
8
9
  isForkPostDeneb,
10
+ isForkPostGloas,
9
11
  } from "@lodestar/params";
10
12
  import {SSZTypesFor, sszTypesFor} from "@lodestar/types";
11
13
 
@@ -42,3 +44,11 @@ export function getPostDenebForkTypes(fork: ForkName): SSZTypesFor<ForkPostDeneb
42
44
 
43
45
  return sszTypesFor(fork);
44
46
  }
47
+
48
+ export function getPostGloasForkTypes(fork: ForkName): SSZTypesFor<ForkPostGloas> {
49
+ if (!isForkPostGloas(fork)) {
50
+ throw Error(`Invalid fork=${fork} for post-gloas fork types`);
51
+ }
52
+
53
+ return sszTypesFor(fork);
54
+ }