@lodestar/api 1.43.0 → 1.44.0-dev.00facd40a8

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,4 +1,4 @@
1
- import {ContainerType, Type, ValueOf} from "@chainsafe/ssz";
1
+ import {ContainerType, OptionalType, Type, ValueOf} from "@chainsafe/ssz";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {isForkPostFulu} from "@lodestar/params";
4
4
  import {ArrayOf, BeaconState, DataColumnSidecars, StringType, ssz, sszTypesFor} from "@lodestar/types";
@@ -78,12 +78,62 @@ const ForkChoiceResponseType = new ContainerType(
78
78
  {jsonCase: "eth2"}
79
79
  );
80
80
 
81
+ const ForkChoiceNodeV2ExtraDataType = new ContainerType(
82
+ {
83
+ executionOptimistic: ssz.Boolean,
84
+ timestamp: ssz.UintNum64,
85
+ target: stringType,
86
+ justifiedEpoch: ssz.Epoch,
87
+ finalizedEpoch: ssz.Epoch,
88
+ unrealizedJustifiedEpoch: ssz.Epoch,
89
+ unrealizedFinalizedEpoch: ssz.Epoch,
90
+ payloadAttesterCount: new OptionalType(ssz.UintNum64),
91
+ payloadAvailabilityYesCount: new OptionalType(ssz.UintNum64),
92
+ payloadDataAvailabilityYesCount: new OptionalType(ssz.UintNum64),
93
+ gasLimit: new OptionalType(ssz.UintNum64),
94
+ },
95
+ {jsonCase: "eth2"}
96
+ );
97
+ const ForkChoiceNodeV2Type = new ContainerType(
98
+ {
99
+ payloadStatus: new StringType<"pending" | "empty" | "full">(),
100
+ slot: ssz.Slot,
101
+ blockRoot: stringType,
102
+ parentRoot: stringType,
103
+ weight: ssz.UintNum64,
104
+ validity: new StringType<"valid" | "invalid" | "optimistic">(),
105
+ executionBlockHash: stringType,
106
+ extraData: ForkChoiceNodeV2ExtraDataType,
107
+ },
108
+ {jsonCase: "eth2"}
109
+ );
110
+ const ForkChoiceExtraDataType = new ContainerType(
111
+ {
112
+ unrealizedJustifiedCheckpoint: ssz.phase0.Checkpoint,
113
+ unrealizedFinalizedCheckpoint: ssz.phase0.Checkpoint,
114
+ proposerBoostRoot: stringType,
115
+ previousProposerBoostRoot: stringType,
116
+ headRoot: stringType,
117
+ },
118
+ {jsonCase: "eth2"}
119
+ );
120
+ const ForkChoiceResponseV2Type = new ContainerType(
121
+ {
122
+ justifiedCheckpoint: ssz.phase0.Checkpoint,
123
+ finalizedCheckpoint: ssz.phase0.Checkpoint,
124
+ forkChoiceNodes: ArrayOf(ForkChoiceNodeV2Type),
125
+ extraData: ForkChoiceExtraDataType,
126
+ },
127
+ {jsonCase: "eth2"}
128
+ );
129
+
81
130
  const ProtoNodeListType = ArrayOf(ProtoNodeType);
82
131
  const DebugChainHeadListType = ArrayOf(DebugChainHeadType);
83
132
 
84
133
  type ProtoNodeList = ValueOf<typeof ProtoNodeListType>;
85
134
  type DebugChainHeadList = ValueOf<typeof DebugChainHeadListType>;
86
135
  type ForkChoiceResponse = ValueOf<typeof ForkChoiceResponseType>;
136
+ type ForkChoiceResponseV2 = ValueOf<typeof ForkChoiceResponseV2Type>;
87
137
 
88
138
  export type Endpoints = {
89
139
  /**
@@ -110,6 +160,18 @@ export type Endpoints = {
110
160
  EmptyMeta
111
161
  >;
112
162
 
163
+ /**
164
+ * Retrieves all current fork choice context (v2: per (root, payload_status) with PTC vote tallies)
165
+ */
166
+ getDebugForkChoiceV2: Endpoint<
167
+ // ⏎
168
+ "GET",
169
+ EmptyArgs,
170
+ EmptyRequest,
171
+ ForkChoiceResponseV2,
172
+ EmptyMeta
173
+ >;
174
+
113
175
  /**
114
176
  * Dump all ProtoArray's nodes to debug
115
177
  */
@@ -185,6 +247,24 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
185
247
  },
186
248
  },
187
249
  },
250
+ getDebugForkChoiceV2: {
251
+ url: "/eth/v2/debug/fork_choice",
252
+ method: "GET",
253
+ req: EmptyRequestCodec,
254
+ resp: {
255
+ data: ForkChoiceResponseV2Type,
256
+ meta: EmptyMetaCodec,
257
+ onlySupport: WireFormat.json,
258
+ transform: {
259
+ toResponse: (data) => ({
260
+ ...(data as ForkChoiceResponseV2),
261
+ }),
262
+ fromResponse: (resp) => ({
263
+ data: resp as ForkChoiceResponseV2,
264
+ }),
265
+ },
266
+ },
267
+ },
188
268
  getProtoArrayNodes: {
189
269
  url: "/eth/v0/debug/forkchoice",
190
270
  method: "GET",
@@ -108,6 +108,8 @@ export enum EventType {
108
108
  executionPayloadAvailable = "execution_payload_available",
109
109
  /** The node has received a `SignedExecutionPayloadBid` (from P2P or API) that passes gossip validation on the `execution_payload_bid` topic */
110
110
  executionPayloadBid = "execution_payload_bid",
111
+ /** The node has received a `SignedProposerPreferences` (from P2P or API) that passes gossip validation on the `proposer_preferences` topic */
112
+ proposerPreferences = "proposer_preferences",
111
113
  }
112
114
 
113
115
  export const eventTypes: {[K in EventType]: K} = {
@@ -132,6 +134,7 @@ export const eventTypes: {[K in EventType]: K} = {
132
134
  [EventType.executionPayloadGossip]: EventType.executionPayloadGossip,
133
135
  [EventType.executionPayloadAvailable]: EventType.executionPayloadAvailable,
134
136
  [EventType.executionPayloadBid]: EventType.executionPayloadBid,
137
+ [EventType.proposerPreferences]: EventType.proposerPreferences,
135
138
  };
136
139
 
137
140
  export type EventData = {
@@ -199,6 +202,7 @@ export type EventData = {
199
202
  blockRoot: RootHex;
200
203
  };
201
204
  [EventType.executionPayloadBid]: {version: ForkName; data: gloas.SignedExecutionPayloadBid};
205
+ [EventType.proposerPreferences]: {version: ForkName; data: gloas.SignedProposerPreferences};
202
206
  };
203
207
 
204
208
  export type BeaconEvent = {[K in EventType]: {type: K; message: EventData[K]}}[EventType];
@@ -395,6 +399,7 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type
395
399
  {jsonCase: "eth2"}
396
400
  ),
397
401
  [EventType.executionPayloadBid]: WithVersion((fork) => getPostGloasForkTypes(fork).SignedExecutionPayloadBid),
402
+ [EventType.proposerPreferences]: WithVersion((fork) => getPostGloasForkTypes(fork).SignedProposerPreferences),
398
403
 
399
404
  [EventType.lightClientOptimisticUpdate]: WithVersion(
400
405
  (fork) => getPostAltairForkTypes(fork).LightClientOptimisticUpdate
@@ -108,6 +108,7 @@ export enum ClientCode {
108
108
  BU = "BU", // besu
109
109
  EJ = "EJ", // ethereumJS
110
110
  EG = "EG", // erigon
111
+ EX = "EX", // ethrex
111
112
  GE = "GE", // go-ethereum
112
113
  GR = "GR", // grandine
113
114
  LH = "LH", // lighthouse
@@ -960,7 +960,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
960
960
  },
961
961
  },
962
962
  getExecutionPayloadEnvelope: {
963
- url: "/eth/v1/validator/execution_payload_envelope/{slot}/{beacon_block_root}",
963
+ url: "/eth/v1/validator/execution_payload_envelopes/{slot}/{beacon_block_root}",
964
964
  method: "GET",
965
965
  req: {
966
966
  writeReq: ({slot, beaconBlockRoot}) => ({