@lodestar/beacon-node 1.52.0-dev.5745da1108 → 1.52.0-dev.643dd3c5bf
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/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -4
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +9 -5
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +6 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +17 -2
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +21 -5
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +39 -6
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +6 -2
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +9 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +3 -2
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/sync/range/batch.d.ts +4 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +12 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +17 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +52 -19
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +1 -0
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/batches.d.ts +20 -4
- package/lib/sync/range/utils/batches.d.ts.map +1 -1
- package/lib/sync/range/utils/batches.js +31 -13
- package/lib/sync/range/utils/batches.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +5 -2
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/types.d.ts +2 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +60 -19
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +8 -0
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +43 -23
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +20 -3
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +76 -20
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/dataColumns.d.ts +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +4 -1
- package/lib/util/dataColumns.js.map +1 -1
- package/package.json +17 -17
- package/src/api/impl/validator/index.ts +2 -4
- package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
- package/src/chain/chain.ts +9 -5
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/validation/executionPayloadBid.ts +20 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +28 -5
- package/src/chain/validation/voluntaryExit.ts +44 -6
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/events.ts +12 -0
- package/src/network/core/networkCoreWorkerHandler.ts +6 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/sync/range/batch.ts +13 -0
- package/src/sync/range/chain.ts +64 -17
- package/src/sync/range/range.ts +1 -0
- package/src/sync/range/utils/batches.ts +38 -13
- package/src/sync/range/utils/peerBalancer.ts +4 -1
- package/src/sync/types.ts +2 -0
- package/src/sync/unknownBlock.ts +65 -21
- package/src/sync/utils/downloadByRange.ts +60 -26
- package/src/util/asyncIterableToEvents.ts +100 -21
- package/src/util/dataColumns.ts +4 -1
|
@@ -10,6 +10,11 @@ export type RequestCancelEvent = {
|
|
|
10
10
|
id: number;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
export type ResponsePullEvent = {
|
|
14
|
+
id: number;
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
13
18
|
export enum IteratorEventType {
|
|
14
19
|
next = "iterator.next",
|
|
15
20
|
done = "iterator.done",
|
|
@@ -25,11 +30,22 @@ export type AsyncIterableEventBus<Args, Item> = {
|
|
|
25
30
|
emitRequest(data: RequestEvent<Args>): void;
|
|
26
31
|
emitRequestCancel(data: RequestCancelEvent): void;
|
|
27
32
|
emitResponse(data: IteratorEvent<Item>): void;
|
|
33
|
+
emitResponsePull(data: ResponsePullEvent): void;
|
|
28
34
|
onRequest(handler: (data: RequestEvent<Args>) => void): void;
|
|
29
35
|
onRequestCancel(handler: (data: RequestCancelEvent) => void): void;
|
|
30
36
|
onResponse(handler: (data: IteratorEvent<Item>) => void): void;
|
|
37
|
+
onResponsePull(handler: (data: ResponsePullEvent) => void): void;
|
|
31
38
|
};
|
|
32
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Credit window: the consumer grants this many items up front and refunds one per item it pulls, so the
|
|
42
|
+
* producer runs at most `window` (plus one in-flight) items ahead regardless of read speed. Bounds
|
|
43
|
+
* consumer-side buffering on the serving bridge. The requester bridge passes Infinity to stay eager: we
|
|
44
|
+
* buffer our own responses into an array anyway, and pacing the worker there only risks the libp2p read
|
|
45
|
+
* buffer overflowing. Must be >= 1.
|
|
46
|
+
*/
|
|
47
|
+
export const RESP_BRIDGE_WINDOW = 2;
|
|
48
|
+
|
|
33
49
|
type PendingItem<T> = {
|
|
34
50
|
items: LinkedList<T>;
|
|
35
51
|
done: boolean;
|
|
@@ -44,8 +60,15 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
44
60
|
private readonly pending = new Map<number, PendingItem<Item>>();
|
|
45
61
|
|
|
46
62
|
constructor(
|
|
47
|
-
private readonly events: Pick<
|
|
63
|
+
private readonly events: Pick<
|
|
64
|
+
AsyncIterableEventBus<Args, Item>,
|
|
65
|
+
"onResponse" | "emitRequest" | "emitRequestCancel" | "emitResponsePull"
|
|
66
|
+
>,
|
|
67
|
+
private readonly window = RESP_BRIDGE_WINDOW
|
|
48
68
|
) {
|
|
69
|
+
if (window < 1) {
|
|
70
|
+
throw new Error(`AsyncIterableBridgeCaller window must be >= 1, got ${window}`);
|
|
71
|
+
}
|
|
49
72
|
events.onResponse(this.onResponse.bind(this));
|
|
50
73
|
}
|
|
51
74
|
|
|
@@ -71,12 +94,18 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
71
94
|
callArgs,
|
|
72
95
|
id,
|
|
73
96
|
});
|
|
97
|
+
// Grant the initial window; next() refunds one credit per consumed item. An Infinity window
|
|
98
|
+
// grants unbounded credit up front so the producer never waits (requester bridge, see above).
|
|
99
|
+
self.events.emitResponsePull({id, count: self.window});
|
|
74
100
|
|
|
75
101
|
return {
|
|
76
102
|
async next() {
|
|
77
103
|
while (true) {
|
|
78
104
|
const item = req.items.shift();
|
|
79
105
|
if (item !== null) {
|
|
106
|
+
if (self.window !== Infinity) {
|
|
107
|
+
self.events.emitResponsePull({id, count: 1});
|
|
108
|
+
}
|
|
80
109
|
return {value: item, done: false};
|
|
81
110
|
}
|
|
82
111
|
|
|
@@ -142,29 +171,52 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
142
171
|
}
|
|
143
172
|
}
|
|
144
173
|
|
|
174
|
+
type HandlerState<Item> = {
|
|
175
|
+
iterator: AsyncIterator<Item>;
|
|
176
|
+
credit: number;
|
|
177
|
+
cancelled: boolean;
|
|
178
|
+
onCredit: null | (() => void);
|
|
179
|
+
};
|
|
180
|
+
|
|
145
181
|
export class AsyncIterableBridgeHandler<Args, Item> {
|
|
146
|
-
private readonly
|
|
182
|
+
private readonly states = new Map<number, HandlerState<Item>>();
|
|
147
183
|
|
|
148
184
|
constructor(
|
|
149
|
-
private readonly events: Pick<
|
|
185
|
+
private readonly events: Pick<
|
|
186
|
+
AsyncIterableEventBus<Args, Item>,
|
|
187
|
+
"onRequest" | "onRequestCancel" | "emitResponse" | "onResponsePull"
|
|
188
|
+
>,
|
|
150
189
|
private readonly handler: (args: Args) => AsyncIterable<Item>
|
|
151
190
|
) {
|
|
152
191
|
events.onRequest(this.onRequest.bind(this));
|
|
153
192
|
events.onRequestCancel(this.onRequestCancel.bind(this));
|
|
193
|
+
events.onResponsePull(this.onResponsePull.bind(this));
|
|
154
194
|
}
|
|
155
195
|
|
|
156
196
|
get iteratingCount(): number {
|
|
157
|
-
return this.
|
|
197
|
+
return this.states.size;
|
|
158
198
|
}
|
|
159
199
|
|
|
160
200
|
private async onRequest(data: RequestEvent<Args>): Promise<void> {
|
|
201
|
+
let state: HandlerState<Item> | undefined;
|
|
161
202
|
try {
|
|
162
|
-
|
|
163
|
-
|
|
203
|
+
state = {
|
|
204
|
+
iterator: this.handler(data.callArgs)[Symbol.asyncIterator](),
|
|
205
|
+
credit: 0,
|
|
206
|
+
cancelled: false,
|
|
207
|
+
onCredit: null,
|
|
208
|
+
};
|
|
209
|
+
this.states.set(data.id, state);
|
|
164
210
|
|
|
165
211
|
while (true) {
|
|
166
|
-
|
|
167
|
-
if (
|
|
212
|
+
await this.waitForCredit(state);
|
|
213
|
+
if (state.cancelled) {
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
state.credit--;
|
|
217
|
+
|
|
218
|
+
const result = await state.iterator.next();
|
|
219
|
+
if (result.done || state.cancelled) {
|
|
168
220
|
break;
|
|
169
221
|
}
|
|
170
222
|
|
|
@@ -175,29 +227,56 @@ export class AsyncIterableBridgeHandler<Args, Item> {
|
|
|
175
227
|
});
|
|
176
228
|
}
|
|
177
229
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
230
|
+
if (!state.cancelled) {
|
|
231
|
+
this.events.emitResponse({
|
|
232
|
+
type: IteratorEventType.done,
|
|
233
|
+
id: data.id,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
182
236
|
} catch (e) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
237
|
+
if (!state?.cancelled) {
|
|
238
|
+
this.events.emitResponse({
|
|
239
|
+
type: IteratorEventType.error,
|
|
240
|
+
id: data.id,
|
|
241
|
+
error: toThreadBoundaryError(e as Error),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
188
244
|
} finally {
|
|
189
|
-
this.
|
|
245
|
+
this.states.delete(data.id);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private waitForCredit(state: HandlerState<Item>): Promise<void> {
|
|
250
|
+
if (state.credit > 0 || state.cancelled) {
|
|
251
|
+
return Promise.resolve();
|
|
252
|
+
}
|
|
253
|
+
return new Promise<void>((resolve) => {
|
|
254
|
+
state.onCredit = resolve;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private onResponsePull(data: ResponsePullEvent): void {
|
|
259
|
+
const state = this.states.get(data.id);
|
|
260
|
+
if (!state) {
|
|
261
|
+
return;
|
|
190
262
|
}
|
|
263
|
+
state.credit += data.count;
|
|
264
|
+
state.onCredit?.();
|
|
265
|
+
state.onCredit = null;
|
|
191
266
|
}
|
|
192
267
|
|
|
193
268
|
private onRequestCancel(data: RequestCancelEvent): void {
|
|
194
|
-
const
|
|
195
|
-
if (!
|
|
269
|
+
const state = this.states.get(data.id);
|
|
270
|
+
if (!state) {
|
|
196
271
|
return;
|
|
197
272
|
}
|
|
273
|
+
// Unblock the loop if it is parked on credit so it can observe the cancel and stop
|
|
274
|
+
state.cancelled = true;
|
|
275
|
+
state.onCredit?.();
|
|
276
|
+
state.onCredit = null;
|
|
198
277
|
|
|
199
278
|
// An async generator queues return() behind the next() that is in flight, so at most one more
|
|
200
279
|
// item is produced before its finally blocks run. Any error surfaces through that next() call.
|
|
201
|
-
void iterator.return().catch(() => {});
|
|
280
|
+
void state.iterator.return?.().catch(() => {});
|
|
202
281
|
}
|
|
203
282
|
}
|
package/src/util/dataColumns.ts
CHANGED
|
@@ -288,7 +288,7 @@ export function getBlobKzgCommitments(
|
|
|
288
288
|
* each blob in the block, assemble the sidecars which can be distributed to peers.
|
|
289
289
|
*
|
|
290
290
|
* SPEC FUNCTION
|
|
291
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.
|
|
291
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.5/specs/fulu/validator.md#get_data_column_sidecars
|
|
292
292
|
*/
|
|
293
293
|
export function getFuluDataColumnSidecars(
|
|
294
294
|
signedBlockHeader: SignedBeaconBlockHeader,
|
|
@@ -299,6 +299,9 @@ export function getFuluDataColumnSidecars(
|
|
|
299
299
|
if (cellsAndKzgProofs.length !== kzgCommitments.length) {
|
|
300
300
|
throw Error("Invalid cellsAndKzgProofs length for getDataColumnSidecars");
|
|
301
301
|
}
|
|
302
|
+
if (kzgCommitments.length === 0) {
|
|
303
|
+
return [];
|
|
304
|
+
}
|
|
302
305
|
|
|
303
306
|
const sidecars: fulu.DataColumnSidecar[] = [];
|
|
304
307
|
for (let columnIndex = 0; columnIndex < NUMBER_OF_COLUMNS; columnIndex++) {
|