@lodestar/beacon-node 1.50.0-dev.58d40975f9 → 1.50.0-dev.5a1db4e01c
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/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +6 -4
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +20 -0
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/beaconProposerCache.d.ts +6 -0
- package/lib/chain/beaconProposerCache.d.ts.map +1 -1
- package/lib/chain/beaconProposerCache.js +16 -0
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +1 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/chain.d.ts +1 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +15 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +1 -23
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +4 -0
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +13 -1
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +11 -0
- package/lib/chain/opPools/utils.d.ts.map +1 -1
- package/lib/chain/opPools/utils.js +22 -0
- package/lib/chain/opPools/utils.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +11 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +40 -28
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/db/beacon.d.ts +2 -1
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +3 -1
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +2 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +1 -0
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +2 -1
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/index.d.ts +1 -0
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +1 -0
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/db/repositories/proposerPreferences.d.ts +14 -0
- package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
- package/lib/db/repositories/proposerPreferences.js +21 -0
- package/lib/db/repositories/proposerPreferences.js.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.js +74 -0
- package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
- package/lib/execution/engine/http.d.ts +45 -13
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +236 -198
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/index.d.ts +3 -2
- package/lib/execution/engine/index.d.ts.map +1 -1
- package/lib/execution/engine/index.js +33 -8
- package/lib/execution/engine/index.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -1
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
- package/lib/execution/engine/jsonRpcTransport.js +158 -0
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
- package/lib/execution/engine/restHttpClient.d.ts +71 -0
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
- package/lib/execution/engine/restHttpClient.js +201 -0
- package/lib/execution/engine/restHttpClient.js.map +1 -0
- package/lib/execution/engine/restTransport.d.ts +46 -0
- package/lib/execution/engine/restTransport.d.ts.map +1 -0
- package/lib/execution/engine/restTransport.js +399 -0
- package/lib/execution/engine/restTransport.js.map +1 -0
- package/lib/execution/engine/sszTypes.d.ts +1261 -0
- package/lib/execution/engine/sszTypes.d.ts.map +1 -0
- package/lib/execution/engine/sszTypes.js +216 -0
- package/lib/execution/engine/sszTypes.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +39 -0
- package/lib/execution/engine/transport.d.ts.map +1 -0
- package/lib/execution/engine/transport.js +2 -0
- package/lib/execution/engine/transport.js.map +1 -0
- package/lib/execution/engine/types.d.ts +2 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +24 -57
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/execution/engine/utils.d.ts.map +1 -1
- package/lib/execution/engine/utils.js +9 -2
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +3 -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 +5 -1
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +8 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +1 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/node/options.d.ts +3 -2
- package/lib/node/options.d.ts.map +1 -1
- package/lib/node/options.js +2 -2
- package/lib/node/options.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +10 -2
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +29 -3
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/metadata.d.ts.map +1 -1
- package/lib/util/metadata.js +2 -1
- package/lib/util/metadata.js.map +1 -1
- package/package.json +16 -15
- package/src/api/impl/beacon/state/index.ts +13 -4
- package/src/api/impl/validator/index.ts +23 -0
- package/src/chain/beaconProposerCache.ts +19 -1
- package/src/chain/blocks/importBlock.ts +1 -2
- package/src/chain/chain.ts +17 -0
- package/src/chain/interface.ts +2 -0
- package/src/chain/opPools/opPool.ts +1 -31
- package/src/chain/opPools/proposerPreferencesPool.ts +20 -1
- package/src/chain/opPools/utils.ts +31 -0
- package/src/chain/prepareNextSlot.ts +15 -3
- package/src/chain/produceBlock/produceBlockBody.ts +68 -34
- package/src/db/beacon.ts +3 -0
- package/src/db/buckets.ts +1 -0
- package/src/db/interface.ts +2 -0
- package/src/db/repositories/index.ts +1 -0
- package/src/db/repositories/proposerPreferences.ts +23 -0
- package/src/execution/engine/blobVersionedHashes.ts +72 -0
- package/src/execution/engine/http.ts +304 -271
- package/src/execution/engine/index.ts +41 -7
- package/src/execution/engine/interface.ts +1 -1
- package/src/execution/engine/jsonRpcTransport.ts +247 -0
- package/src/execution/engine/restHttpClient.ts +269 -0
- package/src/execution/engine/restTransport.ts +544 -0
- package/src/execution/engine/sszTypes.ts +354 -0
- package/src/execution/engine/transport.ts +61 -0
- package/src/execution/engine/types.ts +34 -74
- package/src/execution/engine/utils.ts +12 -2
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/events.ts +16 -1
- package/src/network/processor/gossipHandlers.ts +1 -1
- package/src/node/options.ts +10 -1
- package/src/util/asyncIterableToEvents.ts +44 -5
- package/src/util/metadata.ts +2 -1
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import {ResponseIncoming, ResponseOutgoing} from "@lodestar/reqresp";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AsyncIterableEventBus,
|
|
5
|
+
IteratorEvent,
|
|
6
|
+
RequestCancelEvent,
|
|
7
|
+
RequestEvent,
|
|
8
|
+
} from "../../util/asyncIterableToEvents.js";
|
|
4
9
|
import {StrictEventEmitterSingleArg} from "../../util/strictEvents.js";
|
|
5
10
|
import {EventDirection} from "../events.js";
|
|
6
11
|
import {IncomingRequestArgs, OutgoingRequestArgs} from "../reqresp/types.js";
|
|
7
12
|
|
|
8
13
|
export enum ReqRespBridgeEvent {
|
|
9
14
|
outgoingRequest = "reqresp.outgoingRequest",
|
|
15
|
+
outgoingRequestCancel = "reqresp.outgoingRequestCancel",
|
|
10
16
|
outgoingResponse = "reqresp.outgoingResponse",
|
|
11
17
|
incomingRequest = "reqresp.incomingRequest",
|
|
18
|
+
incomingRequestCancel = "reqresp.incomingRequestCancel",
|
|
12
19
|
incomingResponse = "reqresp.incomingResponse",
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
export type ReqRespBridgeEventData = {
|
|
16
23
|
[ReqRespBridgeEvent.outgoingRequest]: RequestEvent<OutgoingRequestArgs>;
|
|
24
|
+
[ReqRespBridgeEvent.outgoingRequestCancel]: RequestCancelEvent;
|
|
17
25
|
[ReqRespBridgeEvent.outgoingResponse]: IteratorEvent<ResponseOutgoing>;
|
|
18
26
|
[ReqRespBridgeEvent.incomingRequest]: RequestEvent<IncomingRequestArgs>;
|
|
27
|
+
[ReqRespBridgeEvent.incomingRequestCancel]: RequestCancelEvent;
|
|
19
28
|
[ReqRespBridgeEvent.incomingResponse]: IteratorEvent<ResponseIncoming>;
|
|
20
29
|
};
|
|
21
30
|
|
|
@@ -26,8 +35,10 @@ export class ReqRespBridgeEventBus extends (EventEmitter as {new (): IReqRespBri
|
|
|
26
35
|
// NOTE: If the same event is on this two arrays it can create an infinite cycle
|
|
27
36
|
export const reqRespBridgeEventDirection: Record<ReqRespBridgeEvent, EventDirection> = {
|
|
28
37
|
[ReqRespBridgeEvent.outgoingRequest]: EventDirection.mainToWorker,
|
|
38
|
+
[ReqRespBridgeEvent.outgoingRequestCancel]: EventDirection.mainToWorker,
|
|
29
39
|
[ReqRespBridgeEvent.outgoingResponse]: EventDirection.mainToWorker,
|
|
30
40
|
[ReqRespBridgeEvent.incomingRequest]: EventDirection.workerToMain,
|
|
41
|
+
[ReqRespBridgeEvent.incomingRequestCancel]: EventDirection.workerToMain,
|
|
31
42
|
[ReqRespBridgeEvent.incomingResponse]: EventDirection.workerToMain,
|
|
32
43
|
};
|
|
33
44
|
|
|
@@ -36,8 +47,10 @@ export function getReqRespBridgeReqEvents(
|
|
|
36
47
|
): AsyncIterableEventBus<OutgoingRequestArgs, ResponseIncoming> {
|
|
37
48
|
return {
|
|
38
49
|
emitRequest: (data) => events.emit(ReqRespBridgeEvent.outgoingRequest, data),
|
|
50
|
+
emitRequestCancel: (data) => events.emit(ReqRespBridgeEvent.outgoingRequestCancel, data),
|
|
39
51
|
emitResponse: (data) => events.emit(ReqRespBridgeEvent.incomingResponse, data),
|
|
40
52
|
onRequest: (cb) => events.on(ReqRespBridgeEvent.outgoingRequest, cb),
|
|
53
|
+
onRequestCancel: (cb) => events.on(ReqRespBridgeEvent.outgoingRequestCancel, cb),
|
|
41
54
|
onResponse: (cb) => events.on(ReqRespBridgeEvent.incomingResponse, cb),
|
|
42
55
|
};
|
|
43
56
|
}
|
|
@@ -47,8 +60,10 @@ export function getReqRespBridgeRespEvents(
|
|
|
47
60
|
): AsyncIterableEventBus<IncomingRequestArgs, ResponseOutgoing> {
|
|
48
61
|
return {
|
|
49
62
|
emitRequest: (data) => events.emit(ReqRespBridgeEvent.incomingRequest, data),
|
|
63
|
+
emitRequestCancel: (data) => events.emit(ReqRespBridgeEvent.incomingRequestCancel, data),
|
|
50
64
|
emitResponse: (data) => events.emit(ReqRespBridgeEvent.outgoingResponse, data),
|
|
51
65
|
onRequest: (cb) => events.on(ReqRespBridgeEvent.incomingRequest, cb),
|
|
66
|
+
onRequestCancel: (cb) => events.on(ReqRespBridgeEvent.incomingRequestCancel, cb),
|
|
52
67
|
onResponse: (cb) => events.on(ReqRespBridgeEvent.outgoingResponse, cb),
|
|
53
68
|
};
|
|
54
69
|
}
|
|
@@ -1395,7 +1395,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1395
1395
|
const delaySec = chain.clock.secFromSlot(payloadAttestationMessage.data.slot, seenTimestampSec);
|
|
1396
1396
|
metrics?.gossipPayloadAttestationMessage.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
1397
1397
|
const nextSlotProposer = chain.getHeadState().getBeaconProposer(payloadAttestationMessage.data.slot + 1);
|
|
1398
|
-
const isNextSlotProposer = chain.beaconProposerCache.
|
|
1398
|
+
const isNextSlotProposer = chain.beaconProposerCache.has(nextSlotProposer);
|
|
1399
1399
|
|
|
1400
1400
|
if (isNextSlotProposer) {
|
|
1401
1401
|
try {
|
package/src/node/options.ts
CHANGED
|
@@ -3,12 +3,14 @@ import {ArchiveMode, DEFAULT_ARCHIVE_MODE, IChainOptions, defaultChainOptions} f
|
|
|
3
3
|
import {ValidatorMonitorOpts, defaultValidatorMonitorOpts} from "../chain/validatorMonitor.js";
|
|
4
4
|
import {DatabaseOptions, defaultDbOptions} from "../db/options.js";
|
|
5
5
|
import {
|
|
6
|
+
EngineApiMode,
|
|
6
7
|
ExecutionBuilderOpts,
|
|
7
8
|
ExecutionEngineOpts,
|
|
8
9
|
defaultExecutionBuilderHttpOpts,
|
|
9
10
|
defaultExecutionBuilderOpts,
|
|
10
11
|
defaultExecutionEngineHttpOpts,
|
|
11
12
|
defaultExecutionEngineOpts,
|
|
13
|
+
engineApiModes,
|
|
12
14
|
} from "../execution/index.js";
|
|
13
15
|
import {MetricsOptions, defaultMetricsOptions} from "../metrics/options.js";
|
|
14
16
|
import {MonitoringOptions, defaultMonitoringOptions} from "../monitoring/options.js";
|
|
@@ -19,7 +21,14 @@ import {SyncOptions, defaultSyncOptions} from "../sync/options.js";
|
|
|
19
21
|
export {allNamespaces} from "../api/rest/index.js";
|
|
20
22
|
|
|
21
23
|
// Re-export to use as default values in CLI args
|
|
22
|
-
export {
|
|
24
|
+
export {
|
|
25
|
+
defaultExecutionEngineHttpOpts,
|
|
26
|
+
defaultExecutionBuilderHttpOpts,
|
|
27
|
+
engineApiModes,
|
|
28
|
+
ArchiveMode,
|
|
29
|
+
DEFAULT_ARCHIVE_MODE,
|
|
30
|
+
};
|
|
31
|
+
export type {EngineApiMode};
|
|
23
32
|
|
|
24
33
|
export interface IBeaconNodeOptions {
|
|
25
34
|
api: ApiOptions;
|
|
@@ -6,6 +6,10 @@ export type RequestEvent<T> = {
|
|
|
6
6
|
id: number;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
export type RequestCancelEvent = {
|
|
10
|
+
id: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
9
13
|
export enum IteratorEventType {
|
|
10
14
|
next = "iterator.next",
|
|
11
15
|
done = "iterator.done",
|
|
@@ -19,8 +23,10 @@ export type IteratorEvent<V> =
|
|
|
19
23
|
|
|
20
24
|
export type AsyncIterableEventBus<Args, Item> = {
|
|
21
25
|
emitRequest(data: RequestEvent<Args>): void;
|
|
26
|
+
emitRequestCancel(data: RequestCancelEvent): void;
|
|
22
27
|
emitResponse(data: IteratorEvent<Item>): void;
|
|
23
28
|
onRequest(handler: (data: RequestEvent<Args>) => void): void;
|
|
29
|
+
onRequestCancel(handler: (data: RequestCancelEvent) => void): void;
|
|
24
30
|
onResponse(handler: (data: IteratorEvent<Item>) => void): void;
|
|
25
31
|
};
|
|
26
32
|
|
|
@@ -37,7 +43,9 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
37
43
|
// TODO: Consider expiring the requests after no reply for long enough, t
|
|
38
44
|
private readonly pending = new Map<number, PendingItem<Item>>();
|
|
39
45
|
|
|
40
|
-
constructor(
|
|
46
|
+
constructor(
|
|
47
|
+
private readonly events: Pick<AsyncIterableEventBus<Args, Item>, "onResponse" | "emitRequest" | "emitRequestCancel">
|
|
48
|
+
) {
|
|
41
49
|
events.onResponse(this.onResponse.bind(this));
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -89,7 +97,10 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
89
97
|
|
|
90
98
|
async return() {
|
|
91
99
|
// This will be reached if the consumer called 'break' or 'return' early in the loop.
|
|
92
|
-
|
|
100
|
+
// Without the cancel the handler keeps producing items that cross the thread boundary just to be dropped
|
|
101
|
+
if (self.pending.delete(id)) {
|
|
102
|
+
self.events.emitRequestCancel({id});
|
|
103
|
+
}
|
|
93
104
|
return {value: undefined, done: true};
|
|
94
105
|
},
|
|
95
106
|
};
|
|
@@ -132,20 +143,35 @@ export class AsyncIterableBridgeCaller<Args, Item> {
|
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
export class AsyncIterableBridgeHandler<Args, Item> {
|
|
146
|
+
private readonly iterators = new Map<number, AsyncIterator<Item>>();
|
|
147
|
+
|
|
135
148
|
constructor(
|
|
136
|
-
private readonly events: Pick<AsyncIterableEventBus<Args, Item>, "onRequest" | "emitResponse">,
|
|
149
|
+
private readonly events: Pick<AsyncIterableEventBus<Args, Item>, "onRequest" | "onRequestCancel" | "emitResponse">,
|
|
137
150
|
private readonly handler: (args: Args) => AsyncIterable<Item>
|
|
138
151
|
) {
|
|
139
152
|
events.onRequest(this.onRequest.bind(this));
|
|
153
|
+
events.onRequestCancel(this.onRequestCancel.bind(this));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get iteratingCount(): number {
|
|
157
|
+
return this.iterators.size;
|
|
140
158
|
}
|
|
141
159
|
|
|
142
160
|
private async onRequest(data: RequestEvent<Args>): Promise<void> {
|
|
143
161
|
try {
|
|
144
|
-
|
|
162
|
+
const iterator = this.handler(data.callArgs)[Symbol.asyncIterator]();
|
|
163
|
+
this.iterators.set(data.id, iterator);
|
|
164
|
+
|
|
165
|
+
while (true) {
|
|
166
|
+
const result = await iterator.next();
|
|
167
|
+
if (result.done) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
145
171
|
this.events.emitResponse({
|
|
146
172
|
type: IteratorEventType.next,
|
|
147
173
|
id: data.id,
|
|
148
|
-
item,
|
|
174
|
+
item: result.value,
|
|
149
175
|
});
|
|
150
176
|
}
|
|
151
177
|
|
|
@@ -159,6 +185,19 @@ export class AsyncIterableBridgeHandler<Args, Item> {
|
|
|
159
185
|
id: data.id,
|
|
160
186
|
error: toThreadBoundaryError(e as Error),
|
|
161
187
|
});
|
|
188
|
+
} finally {
|
|
189
|
+
this.iterators.delete(data.id);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private onRequestCancel(data: RequestCancelEvent): void {
|
|
194
|
+
const iterator = this.iterators.get(data.id);
|
|
195
|
+
if (!iterator?.return) {
|
|
196
|
+
return;
|
|
162
197
|
}
|
|
198
|
+
|
|
199
|
+
// An async generator queues return() behind the next() that is in flight, so at most one more
|
|
200
|
+
// item is produced before its finally blocks run. Any error surfaces through that next() call.
|
|
201
|
+
void iterator.return().catch(() => {});
|
|
163
202
|
}
|
|
164
203
|
}
|
package/src/util/metadata.ts
CHANGED
|
@@ -6,7 +6,8 @@ export function getLodestarClientVersion(info?: {version?: string; commit?: stri
|
|
|
6
6
|
code: ClientCode.LS,
|
|
7
7
|
name: "Lodestar",
|
|
8
8
|
version: info?.version ?? "",
|
|
9
|
-
commit
|
|
9
|
+
// engine_getClientVersionV1 defines commit as 4 bytes, so builds without git data must not send an empty one
|
|
10
|
+
commit: info?.commit ? info.commit.slice(0, 8) : "00000000",
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
|