@lodestar/api 1.45.0-rc.0 → 1.46.0-dev.82546f11da

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.
@@ -38,6 +38,7 @@ import {
38
38
  EmptyResponseCodec,
39
39
  EmptyResponseData,
40
40
  JsonOnlyReq,
41
+ WithMeta,
41
42
  WithVersion,
42
43
  } from "../../utils/codecs.js";
43
44
  import {getPostBellatrixForkTypes, getPostGloasForkTypes, toForkName} from "../../utils/fork.js";
@@ -98,6 +99,10 @@ export const ProduceBlockV4MetaType = new ContainerType(
98
99
  ...VersionType.fields,
99
100
  /** Consensus rewards paid to the proposer for this block, in Wei */
100
101
  consensusBlockValue: ssz.UintBn64,
102
+ /** Local execution payload value when self-building, or builder bid value when committing to a bid, in Wei */
103
+ executionPayloadValue: ssz.UintBn64,
104
+ /** Specifies whether the response contains full block contents or only the beacon block */
105
+ executionPayloadIncluded: ssz.Boolean,
101
106
  },
102
107
  {jsonCase: "eth2"}
103
108
  );
@@ -421,6 +426,12 @@ export type Endpoints = {
421
426
  * Post-Gloas, proposers submit execution payload bids rather than full execution payloads,
422
427
  * so there is no longer a concept of blinded or unblinded blocks. Builders release the payload later.
423
428
  * This endpoint is specific to the post-Gloas forks and is not backwards compatible with previous forks.
429
+ *
430
+ * When self-building and `includePayload` is true, the response contains the full `BlockContents`
431
+ * (block, execution payload envelope, KZG proofs and blobs) which enables stateless envelope
432
+ * publishing via any beacon node. When `includePayload` is false, only the `BeaconBlock` is
433
+ * returned and the beacon node caches the envelope and blobs internally.
434
+ * When committing to a builder bid, only the `BeaconBlock` is returned in either case.
424
435
  */
425
436
  produceBlockV4: Endpoint<
426
437
  "GET",
@@ -433,6 +444,8 @@ export type Endpoints = {
433
444
  graffiti?: string;
434
445
  skipRandaoVerification?: boolean;
435
446
  builderBoostFactor?: UintBn64;
447
+ /** Include execution payload envelope and blobs in the response when self-building */
448
+ includePayload: boolean;
436
449
  } & Omit<ExtraProduceBlockOpts, "blindedLocal">,
437
450
  {
438
451
  params: {slot: number};
@@ -444,16 +457,18 @@ export type Endpoints = {
444
457
  builder_selection?: string;
445
458
  builder_boost_factor?: string;
446
459
  strict_fee_recipient_check?: boolean;
460
+ include_payload: boolean;
447
461
  };
448
462
  },
449
- BeaconBlock<ForkPostGloas>,
463
+ BeaconBlock<ForkPostGloas> | BlockContents<ForkPostGloas>,
450
464
  ProduceBlockV4Meta
451
465
  >;
452
466
 
453
467
  /**
454
468
  * Get execution payload envelope.
455
- * Retrieves execution payload envelope for a given slot and beacon block root.
456
- * The envelope contains the full execution payload along with associated metadata.
469
+ * Retrieves the cached execution payload envelope for a given slot and beacon block root,
470
+ * to be signed and published via `publishExecutionPayloadEnvelope`.
471
+ * Used in the stateful (`includePayload=false`) local build flow.
457
472
  */
458
473
  getExecutionPayloadEnvelope: Endpoint<
459
474
  "GET",
@@ -906,6 +921,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
906
921
  builderSelection,
907
922
  builderBoostFactor,
908
923
  strictFeeRecipientCheck,
924
+ includePayload,
909
925
  }) => ({
910
926
  params: {slot},
911
927
  query: {
@@ -916,6 +932,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
916
932
  builder_selection: builderSelection,
917
933
  builder_boost_factor: builderBoostFactor?.toString(),
918
934
  strict_fee_recipient_check: strictFeeRecipientCheck,
935
+ include_payload: includePayload,
919
936
  },
920
937
  }),
921
938
  parseReq: ({params, query}) => ({
@@ -927,6 +944,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
927
944
  builderSelection: query.builder_selection as BuilderSelection,
928
945
  builderBoostFactor: parseBuilderBoostFactor(query.builder_boost_factor),
929
946
  strictFeeRecipientCheck: query.strict_fee_recipient_check,
947
+ includePayload: query.include_payload,
930
948
  }),
931
949
  schema: {
932
950
  params: {slot: Schema.UintRequired},
@@ -938,21 +956,33 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
938
956
  builder_selection: Schema.String,
939
957
  builder_boost_factor: Schema.String,
940
958
  strict_fee_recipient_check: Schema.Boolean,
959
+ include_payload: Schema.BooleanRequired,
941
960
  },
942
961
  },
943
962
  },
944
963
  resp: {
945
- data: WithVersion((fork) => getPostGloasForkTypes(fork).BeaconBlock),
964
+ data: WithMeta(
965
+ ({version, executionPayloadIncluded}) =>
966
+ (executionPayloadIncluded
967
+ ? getPostGloasForkTypes(version).BlockContents
968
+ : getPostGloasForkTypes(version).BeaconBlock) as Type<
969
+ BeaconBlock<ForkPostGloas> | BlockContents<ForkPostGloas>
970
+ >
971
+ ),
946
972
  meta: {
947
973
  toJson: (meta) => ProduceBlockV4MetaType.toJson(meta),
948
974
  fromJson: (val) => ProduceBlockV4MetaType.fromJson(val),
949
975
  toHeadersObject: (meta) => ({
950
976
  [MetaHeader.Version]: meta.version,
951
977
  [MetaHeader.ConsensusBlockValue]: meta.consensusBlockValue.toString(),
978
+ [MetaHeader.ExecutionPayloadValue]: meta.executionPayloadValue.toString(),
979
+ [MetaHeader.ExecutionPayloadIncluded]: meta.executionPayloadIncluded.toString(),
952
980
  }),
953
981
  fromHeaders: (headers) => ({
954
982
  version: toForkName(headers.getRequired(MetaHeader.Version)),
955
983
  consensusBlockValue: BigInt(headers.getRequired(MetaHeader.ConsensusBlockValue)),
984
+ executionPayloadValue: BigInt(headers.getRequired(MetaHeader.ExecutionPayloadValue)),
985
+ executionPayloadIncluded: toBoolean(headers.getRequired(MetaHeader.ExecutionPayloadIncluded)),
956
986
  }),
957
987
  },
958
988
  },
@@ -74,8 +74,10 @@ export type ExecutionOptimisticAndDependentRootMeta = ValueOf<typeof ExecutionOp
74
74
 
75
75
  export enum MetaHeader {
76
76
  Version = "Eth-Consensus-Version",
77
+ BlobDataIncluded = "Eth-Blob-Data-Included",
77
78
  ConsensusBlockValue = "Eth-Consensus-Block-Value",
78
79
  ExecutionPayloadBlinded = "Eth-Execution-Payload-Blinded",
80
+ ExecutionPayloadIncluded = "Eth-Execution-Payload-Included",
79
81
  ExecutionPayloadValue = "Eth-Execution-Payload-Value",
80
82
 
81
83
  /* Lodestar-specific (non-standardized) headers */
@@ -34,6 +34,7 @@ export enum Schema {
34
34
  ObjectArray,
35
35
  AnyArray,
36
36
  Boolean,
37
+ BooleanRequired,
37
38
  }
38
39
 
39
40
  /**
@@ -71,6 +72,7 @@ function getJsonSchemaItem(schema: Schema): JsonSchema {
71
72
  return {type: "array"};
72
73
 
73
74
  case Schema.Boolean:
75
+ case Schema.BooleanRequired:
74
76
  return {type: "boolean"};
75
77
  }
76
78
  }
@@ -81,6 +83,7 @@ function isRequired(schema: Schema): boolean {
81
83
  case Schema.StringRequired:
82
84
  case Schema.UintOrStringRequired:
83
85
  case Schema.StringArrayRequired:
86
+ case Schema.BooleanRequired:
84
87
  return true;
85
88
 
86
89
  default: