@lodestar/beacon-node 1.46.0-dev.d0262e8610 → 1.46.0-dev.e00bf67333
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/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +2 -3
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/bls/multithread/index.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.js +0 -1
- package/lib/chain/bls/multithread/index.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +26 -44
- package/lib/chain/chain.js.map +1 -1
- package/lib/metrics/nodeJsMetrics.js +1 -1
- package/lib/metrics/nodeJsMetrics.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +2 -7
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/discv5/index.d.ts.map +1 -1
- package/lib/network/discv5/index.js +1 -4
- package/lib/network/discv5/index.js.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +2 -9
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/peers/datastore.d.ts +1 -1
- package/lib/network/peers/datastore.d.ts.map +1 -1
- package/lib/network/peers/datastore.js +1 -1
- package/lib/network/peers/datastore.js.map +1 -1
- package/lib/util/profile.d.ts +3 -0
- package/lib/util/profile.d.ts.map +1 -1
- package/lib/util/profile.js +1 -27
- package/lib/util/profile.js.map +1 -1
- package/package.json +25 -36
- package/src/api/impl/lodestar/index.ts +2 -3
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
- package/src/chain/bls/multithread/index.ts +0 -1
- package/src/chain/chain.ts +33 -49
- package/src/metrics/nodeJsMetrics.ts +1 -1
- package/src/network/core/networkCoreWorkerHandler.ts +2 -6
- package/src/network/discv5/index.ts +1 -4
- package/src/network/libp2p/index.ts +2 -10
- package/src/network/peers/datastore.ts +1 -1
- package/src/util/profile.ts +1 -31
- package/lib/bun-wrappers/prometheus-gc-stats.d.ts +0 -2
- package/lib/bun-wrappers/prometheus-gc-stats.d.ts.map +0 -1
- package/lib/bun-wrappers/prometheus-gc-stats.js +0 -8
- package/lib/bun-wrappers/prometheus-gc-stats.js.map +0 -1
- package/lib/network/peers/datastore_bun.d.ts +0 -3
- package/lib/network/peers/datastore_bun.d.ts.map +0 -1
- package/lib/network/peers/datastore_bun.js +0 -3
- package/lib/network/peers/datastore_bun.js.map +0 -1
- package/src/bun-wrappers/prometheus-gc-stats.ts +0 -7
- package/src/network/peers/datastore_bun.ts +0 -3
|
@@ -51,10 +51,7 @@ export class Discv5Worker extends (EventEmitter as {new (): StrictEventEmitter<E
|
|
|
51
51
|
loggerOpts: opts.logger.toOpts(),
|
|
52
52
|
genesisTime: opts.genesisTime,
|
|
53
53
|
};
|
|
54
|
-
const worker = new Worker("./worker.js", {
|
|
55
|
-
suppressTranspileTS: Boolean(globalThis.Bun),
|
|
56
|
-
workerData,
|
|
57
|
-
} as ConstructorParameters<typeof Worker>[1]);
|
|
54
|
+
const worker = new Worker("./worker.js", {workerData} as ConstructorParameters<typeof Worker>[1]);
|
|
58
55
|
|
|
59
56
|
const workerApi = await spawn<Discv5WorkerApi>(worker, {
|
|
60
57
|
// A Lodestar Node may do very expensive task at start blocking the event loop and causing
|
|
@@ -9,7 +9,7 @@ import {Libp2pInit, createLibp2p} from "libp2p";
|
|
|
9
9
|
import {Registry} from "prom-client";
|
|
10
10
|
import {ENR} from "@chainsafe/enr";
|
|
11
11
|
import {noise} from "@chainsafe/libp2p-noise";
|
|
12
|
-
import {
|
|
12
|
+
import {defaultCrypto} from "@chainsafe/libp2p-noise/crypto";
|
|
13
13
|
import {quic} from "@chainsafe/libp2p-quic";
|
|
14
14
|
import {Libp2p, LodestarComponents} from "../interface.js";
|
|
15
15
|
import {NetworkOptions, defaultNetworkOptions} from "../options.js";
|
|
@@ -111,14 +111,6 @@ export async function createNodeJsLibp2p(
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const noiseCrypto = {
|
|
115
|
-
...defaultCrypto,
|
|
116
|
-
};
|
|
117
|
-
if (globalThis.Bun) {
|
|
118
|
-
noiseCrypto.chaCha20Poly1305Decrypt = asCrypto.chaCha20Poly1305Decrypt;
|
|
119
|
-
noiseCrypto.chaCha20Poly1305Encrypt = asCrypto.chaCha20Poly1305Encrypt;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
114
|
return createLibp2p({
|
|
123
115
|
privateKey,
|
|
124
116
|
nodeInfo: {
|
|
@@ -130,7 +122,7 @@ export async function createNodeJsLibp2p(
|
|
|
130
122
|
listen: localMultiaddrs,
|
|
131
123
|
announce: [],
|
|
132
124
|
},
|
|
133
|
-
connectionEncrypters: [noise({crypto:
|
|
125
|
+
connectionEncrypters: [noise({crypto: defaultCrypto})],
|
|
134
126
|
transports,
|
|
135
127
|
streamMuxers: [mplex({disconnectThreshold})],
|
|
136
128
|
peerDiscovery,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {AbortOptions} from "@libp2p/interface";
|
|
2
2
|
import {BaseDatastore} from "datastore-core";
|
|
3
|
+
import {LevelDatastore} from "datastore-level";
|
|
3
4
|
import {Key, KeyQuery, Pair, Query} from "interface-datastore";
|
|
4
|
-
import {LevelDatastore} from "#datastore-wrapper";
|
|
5
5
|
|
|
6
6
|
type MemoryItem = {
|
|
7
7
|
lastAccessedMs: number;
|
package/src/util/profile.ts
CHANGED
|
@@ -8,21 +8,10 @@ export enum ProfileThread {
|
|
|
8
8
|
DISC5 = "discv5",
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* The time to take a Bun profile.
|
|
13
|
-
* If we increase this time it'll potentiall cause the app to crash.
|
|
14
|
-
* If we decrease this time, profile recorded will be fragmented and hard to analyze.
|
|
15
|
-
*/
|
|
16
|
-
const BUN_PROFILE_MS = 3 * 1000;
|
|
17
|
-
|
|
18
|
-
export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
|
|
19
|
-
return globalThis.Bun ? profileBun(thread, durationMs) : profileNodeJS(thread, durationMs, dirpath);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
11
|
/**
|
|
23
12
|
* Take `durationMs` profile of the current thread and return the persisted file path.
|
|
24
13
|
*/
|
|
25
|
-
async function
|
|
14
|
+
export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
|
|
26
15
|
const inspector = await import("node:inspector");
|
|
27
16
|
|
|
28
17
|
// due to some typing issues, not able to use promisify here
|
|
@@ -54,25 +43,6 @@ async function profileNodeJS(thread: ProfileThread, durationMs: number, dirpath:
|
|
|
54
43
|
return filePath;
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
/**
|
|
58
|
-
* Unlike NodeJS, Bun console.profile() api flush data to the inspector,
|
|
59
|
-
* so this api returns ms taken of this profile instead of file path.
|
|
60
|
-
*/
|
|
61
|
-
async function profileBun(thread: ProfileThread, durationMs: number): Promise<string> {
|
|
62
|
-
const start = Date.now();
|
|
63
|
-
let now = Date.now();
|
|
64
|
-
while (now - start < durationMs) {
|
|
65
|
-
// biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
|
|
66
|
-
console.profile(String(now));
|
|
67
|
-
await sleep(BUN_PROFILE_MS);
|
|
68
|
-
// biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
|
|
69
|
-
console.profileEnd(String(now));
|
|
70
|
-
now = Date.now();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return `Successfully take Bun ${thread} thread profile in ${now - start}ms. Check your inspector to see the profile.`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
46
|
/**
|
|
77
47
|
* Write heap snapshot of the current thread to the specified file.
|
|
78
48
|
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-gc-stats.d.ts","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,eAEtB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Bun does not support `GCProfiler` from `node:v8`a
|
|
2
|
-
// Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
|
|
3
|
-
// So we expose a dummy function for Bun runtime which do nothing for now
|
|
4
|
-
// TODO: May look get some useful data from `bun:jsc`
|
|
5
|
-
export function gcStats() {
|
|
6
|
-
return () => { };
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=prometheus-gc-stats.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-gc-stats.js","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,yHAAyH;AACzH,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,UAAU,OAAO,GAAG;IACxB,OAAO,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;AAAA,CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datastore_bun.d.ts","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,cAAc,oBAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datastore_bun.js","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Bun does not support `GCProfiler` from `node:v8`a
|
|
2
|
-
// Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
|
|
3
|
-
// So we expose a dummy function for Bun runtime which do nothing for now
|
|
4
|
-
// TODO: May look get some useful data from `bun:jsc`
|
|
5
|
-
export function gcStats() {
|
|
6
|
-
return () => {};
|
|
7
|
-
}
|