@lodestar/api 1.45.0 → 1.46.0-dev.4191d8e353
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/routes/beacon/block.d.ts +10 -1
- package/lib/beacon/routes/beacon/block.d.ts.map +1 -1
- package/lib/beacon/routes/beacon/block.js +34 -12
- package/lib/beacon/routes/beacon/block.js.map +1 -1
- package/lib/beacon/routes/beacon/pool.d.ts +1 -1
- package/lib/beacon/routes/events.d.ts +137 -2
- package/lib/beacon/routes/events.d.ts.map +1 -1
- package/lib/beacon/routes/events.js +22 -0
- package/lib/beacon/routes/events.js.map +1 -1
- package/lib/beacon/routes/validator.d.ts +17 -3
- package/lib/beacon/routes/validator.d.ts.map +1 -1
- package/lib/beacon/routes/validator.js +16 -3
- package/lib/beacon/routes/validator.js.map +1 -1
- package/lib/utils/metadata.d.ts +2 -0
- package/lib/utils/metadata.d.ts.map +1 -1
- package/lib/utils/metadata.js +2 -0
- package/lib/utils/metadata.js.map +1 -1
- package/lib/utils/schema.d.ts +2 -1
- package/lib/utils/schema.d.ts.map +1 -1
- package/lib/utils/schema.js +3 -0
- package/lib/utils/schema.js.map +1 -1
- package/package.json +15 -15
- package/src/beacon/routes/beacon/block.ts +51 -14
- package/src/beacon/routes/events.ts +30 -0
- package/src/beacon/routes/validator.ts +34 -4
- package/src/utils/metadata.ts +2 -0
- package/src/utils/schema.ts +3 -0
|
@@ -56,9 +56,23 @@ const gloasDataColumnSidecarSSE = new ContainerType(
|
|
|
56
56
|
},
|
|
57
57
|
{typeName: "DataColumnSidecarSSE", jsonCase: "eth2"}
|
|
58
58
|
);
|
|
59
|
+
const headV2 = new ContainerType(
|
|
60
|
+
{
|
|
61
|
+
slot: ssz.Slot,
|
|
62
|
+
block: stringType,
|
|
63
|
+
state: stringType,
|
|
64
|
+
payloadStatus: new StringType<"empty" | "full">(),
|
|
65
|
+
epochTransition: ssz.Boolean,
|
|
66
|
+
currentEpochDependentRoot: stringType,
|
|
67
|
+
nextEpochDependentRoot: stringType,
|
|
68
|
+
executionOptimistic: ssz.Boolean,
|
|
69
|
+
},
|
|
70
|
+
{typeName: "HeadV2", jsonCase: "eth2"}
|
|
71
|
+
);
|
|
59
72
|
type FuluDataColumnSidecarSSE = ValueOf<typeof fuluDataColumnSidecarSSE>;
|
|
60
73
|
type GloasDataColumnSidecarSSE = ValueOf<typeof gloasDataColumnSidecarSSE>;
|
|
61
74
|
type DataColumnSidecarSSE = FuluDataColumnSidecarSSE | GloasDataColumnSidecarSSE;
|
|
75
|
+
type HeadV2 = ValueOf<typeof headV2>;
|
|
62
76
|
|
|
63
77
|
export enum EventType {
|
|
64
78
|
/**
|
|
@@ -68,6 +82,16 @@ export enum EventType {
|
|
|
68
82
|
* Both dependent roots use the genesis block root in the case of underflow.
|
|
69
83
|
*/
|
|
70
84
|
head = "head",
|
|
85
|
+
/**
|
|
86
|
+
* The node's fork choice has selected a new head consisting of a beacon block and its `payload_status`.
|
|
87
|
+
* The node should emit a second head event for the same beacon block and slot when there is an update
|
|
88
|
+
* in the `payload_status` from empty to full. Emission on other payload_status transitions (e.g. full to empty)
|
|
89
|
+
* is optional and implementation-defined. `slot` is the slot of the head block. `current_epoch_dependent_root`
|
|
90
|
+
* is `get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch - 1) - 1)` and `next_epoch_dependent_root`
|
|
91
|
+
* is `get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch) - 1)`, where `epoch` is obtained by
|
|
92
|
+
* `compute_epoch_at_slot(slot)`. All dependent roots use the genesis block root in the case of underflow.
|
|
93
|
+
*/
|
|
94
|
+
headV2 = "head_v2",
|
|
71
95
|
/** The node has received a block (from P2P or API) that is successfully imported on the fork-choice `on_block` handler */
|
|
72
96
|
block = "block",
|
|
73
97
|
/** The node has received a block (from P2P or API) that passes validation rules of the `beacon_block` topic */
|
|
@@ -118,6 +142,7 @@ export enum EventType {
|
|
|
118
142
|
|
|
119
143
|
export const eventTypes: {[K in EventType]: K} = {
|
|
120
144
|
[EventType.head]: EventType.head,
|
|
145
|
+
[EventType.headV2]: EventType.headV2,
|
|
121
146
|
[EventType.block]: EventType.block,
|
|
122
147
|
[EventType.blockGossip]: EventType.blockGossip,
|
|
123
148
|
[EventType.attestation]: EventType.attestation,
|
|
@@ -153,6 +178,10 @@ export type EventData = {
|
|
|
153
178
|
currentDutyDependentRoot: RootHex;
|
|
154
179
|
executionOptimistic: boolean;
|
|
155
180
|
};
|
|
181
|
+
[EventType.headV2]: {
|
|
182
|
+
version: ForkName;
|
|
183
|
+
data: HeadV2;
|
|
184
|
+
};
|
|
156
185
|
[EventType.block]: {
|
|
157
186
|
slot: Slot;
|
|
158
187
|
block: RootHex;
|
|
@@ -299,6 +328,7 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type
|
|
|
299
328
|
},
|
|
300
329
|
{jsonCase: "eth2"}
|
|
301
330
|
),
|
|
331
|
+
[EventType.headV2]: WithVersion(() => headV2),
|
|
302
332
|
|
|
303
333
|
[EventType.block]: new ContainerType(
|
|
304
334
|
{
|
|
@@ -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
|
-
*
|
|
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:
|
|
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
|
},
|
package/src/utils/metadata.ts
CHANGED
|
@@ -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 */
|
package/src/utils/schema.ts
CHANGED
|
@@ -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:
|