Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump libp2p deps #6015

Merged
merged 37 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
356e555
chore: bump libp2p deps
wemeetagain Oct 2, 2023
db5928b
Add resource leak detection in mocha for e2e
nazarhussain Oct 4, 2023
36bee08
Remove all retries from network tests
nazarhussain Oct 4, 2023
ce0b8f1
Remove the timeout from workflow actions
nazarhussain Oct 4, 2023
2550eb7
Uncomment a test
nazarhussain Oct 4, 2023
1df7905
Update hooks to show time in the log
nazarhussain Oct 4, 2023
b52e7e0
Add a custom mocha wrapper to detected leaked resources
nazarhussain Oct 4, 2023
5c5d51e
Use mocha wrapper for beacon-node e2e tests
nazarhussain Oct 4, 2023
a495e37
Add multiple exit to mocha run
nazarhussain Oct 4, 2023
d7b654b
Add mocha exit with failure count
nazarhussain Oct 4, 2023
a784688
Update the process exit strategy
nazarhussain Oct 4, 2023
af4c603
Exit the process with signal
nazarhussain Oct 4, 2023
652294c
Exit the process with signal
nazarhussain Oct 4, 2023
b3406a3
Stop the beacon node once
nazarhussain Oct 4, 2023
b471c54
Abort the process
nazarhussain Oct 4, 2023
04e34d6
Enable debug logging for e2e tests
nazarhussain Oct 4, 2023
96fdaa8
Add unique name to each node for identification
nazarhussain Oct 5, 2023
7d2256e
Add unique name to each node for identification
nazarhussain Oct 5, 2023
ca2a6d3
Fix gossip test close
nazarhussain Oct 5, 2023
1aeee1a
Fixing peer manager close handler
nazarhussain Oct 5, 2023
cdb9771
Update the process of finding active resources
nazarhussain Oct 5, 2023
a5c6929
Add log prefix to validators to debug
nazarhussain Oct 5, 2023
519f626
Add log prefix to validators to debug
nazarhussain Oct 5, 2023
c8c4f28
Add try/catch for network core close
nazarhussain Oct 5, 2023
1c1168a
Wait for peer disconnect
nazarhussain Oct 6, 2023
efbd4fb
Updat the exit strategy to ignore default resources
nazarhussain Oct 6, 2023
88a6acf
Add more logs to investigate
nazarhussain Oct 6, 2023
b421786
Await for disconnect
nazarhussain Oct 6, 2023
f8e2025
Add debug level logs threads
nazarhussain Oct 6, 2023
1d6fcf5
Remove exit option for the mocha
nazarhussain Oct 6, 2023
5c85157
Cleanup extra code
nazarhussain Oct 10, 2023
274cc19
Cleanup the PR
nazarhussain Oct 10, 2023
abe067f
Cleanup a duplicate variable
nazarhussain Oct 10, 2023
4c42132
Fix the unused tests
nazarhussain Oct 10, 2023
ddcc243
Merge branch 'unstable' into cayman/bump-libp2p
nazarhussain Oct 13, 2023
9144fdc
Revert some code change
nazarhussain Oct 13, 2023
47df439
Remove unrelated diff
nflaig Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"karma-spec-reporter": "^0.0.36",
"karma-webpack": "^5.0.0",
"lerna": "^7.3.0",
"libp2p": "0.46.3",
"libp2p": "0.46.12",
"mocha": "^10.2.0",
"node-gyp": "^9.4.0",
"npm-run-all": "^4.1.5",
Expand Down
20 changes: 10 additions & 10 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@chainsafe/blst": "^0.2.9",
"@chainsafe/discv5": "^5.1.0",
"@chainsafe/libp2p-gossipsub": "^10.1.0",
"@chainsafe/libp2p-noise": "^13.0.0",
"@chainsafe/libp2p-noise": "^13.0.1",
"@chainsafe/persistent-merkle-tree": "^0.5.0",
"@chainsafe/prometheus-gc-stats": "^1.0.0",
"@chainsafe/ssz": "^0.13.0",
Expand All @@ -111,14 +111,14 @@
"@fastify/cors": "^8.2.1",
"@fastify/swagger": "^8.10.0",
"@fastify/swagger-ui": "^1.9.3",
"@libp2p/bootstrap": "^9.0.2",
"@libp2p/interface": "^0.1.1",
"@libp2p/mdns": "^9.0.2",
"@libp2p/mplex": "^9.0.2",
"@libp2p/peer-id": "^3.0.1",
"@libp2p/peer-id-factory": "^3.0.2",
"@libp2p/prometheus-metrics": "^2.0.2",
"@libp2p/tcp": "8.0.2",
"@libp2p/bootstrap": "^9.0.7",
"@libp2p/interface": "^0.1.2",
"@libp2p/mdns": "^9.0.9",
"@libp2p/mplex": "^9.0.7",
"@libp2p/peer-id": "^3.0.2",
"@libp2p/peer-id-factory": "^3.0.4",
"@libp2p/prometheus-metrics": "^2.0.7",
"@libp2p/tcp": "8.0.8",
"@lodestar/api": "^1.11.3",
"@lodestar/config": "^1.11.3",
"@lodestar/db": "^1.11.3",
Expand All @@ -143,7 +143,7 @@
"it-all": "^3.0.2",
"it-pipe": "^3.0.1",
"jwt-simple": "0.5.6",
"libp2p": "0.46.3",
"libp2p": "0.46.12",
"multiformats": "^11.0.1",
"prom-client": "^14.2.0",
"qs": "^6.11.1",
Expand Down
41 changes: 22 additions & 19 deletions packages/beacon-node/src/network/core/networkCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,28 @@ export class NetworkCore implements INetworkCore {
/** Destroy this instance. Can only be called once. */
async close(): Promise<void> {
if (this.closed) return;

nflaig marked this conversation as resolved.
Show resolved Hide resolved
this.clock.off(ClockEvent.epoch, this.onEpoch);

// Must goodbye and disconnect before stopping libp2p
await this.peerManager.goodbyeAndDisconnectAllPeers();
this.logger.debug("network sent goodbye to all peers");
await this.peerManager.close();
this.logger.debug("network peerManager closed");
await this.gossip.stop();
this.logger.debug("network gossip closed");
await this.reqResp.stop();
await this.reqResp.unregisterAllProtocols();
this.logger.debug("network reqResp closed");
this.attnetsService.close();
this.syncnetsService.close();
await this.libp2p.stop();
this.logger.debug("network lib2p closed");

this.closed = true;
try {
this.clock.off(ClockEvent.epoch, this.onEpoch);

// Must goodbye and disconnect before stopping libp2p
await this.peerManager.goodbyeAndDisconnectAllPeers();
this.logger.debug("network sent goodbye to all peers");
await this.peerManager.close();
this.logger.debug("network peerManager closed");
await this.gossip.stop();
this.logger.debug("network gossip closed");
await this.reqResp.stop();
await this.reqResp.unregisterAllProtocols();
this.logger.debug("network reqResp closed");
this.attnetsService.close();
this.syncnetsService.close();
await this.libp2p.stop();
this.logger.debug("network lib2p closed");

this.closed = true;
} catch (err) {
this.logger.error("Error on NetworkCore.close()", {}, err as Error);
}
nazarhussain marked this conversation as resolved.
Show resolved Hide resolved
}

async scrapeMetrics(): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class WorkerNetworkCore implements INetworkCore {
}

async close(): Promise<void> {
this.modules.logger.debug("closing network core running in network worker");
await this.getApi().close();
this.modules.logger.debug("terminating network worker");
await terminateWorkerThread({
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/network/peers/peerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ export class PeerManager {
} catch (e) {
this.logger.verbose("Failed to send goodbye", {peer: prettyPrintPeerId(peer)}, e as Error);
} finally {
void this.disconnect(peer);
await this.disconnect(peer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe("beacon node api", function () {

// To make BN communicate with EL, it needs to produce some blocks and for that need validators
const {validators} = await getAndInitDevValidators({
logPrefix: "Offline-BN",
node: bnElOffline,
validatorClientCount: 1,
validatorsPerClient: validatorCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("lightclient api", function () {
const genesisValidatorsRoot = Buffer.alloc(32, 0xaa);
const config = createBeaconConfig(chainConfig, genesisValidatorsRoot);
const testLoggerOpts: TestLoggerOpts = {level: LogLevel.info};
const loggerNodeA = testLogger("Node-A", testLoggerOpts);
const loggerNodeA = testLogger("lightclient-api", testLoggerOpts);
const validatorCount = 2;

let bn: BeaconNode;
Expand Down Expand Up @@ -54,6 +54,7 @@ describe("lightclient api", function () {
validators = (
await getAndInitDevValidators({
node: bn,
logPrefix: "lightclient-api",
validatorsPerClient: validatorCount,
validatorClientCount: 1,
startIndex: 0,
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/test/e2e/chain/lightclient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("chain / lightclient", function () {
},
};

const loggerNodeA = testLogger("Node", testLoggerOpts);
const loggerNodeA = testLogger("lightclientNode", testLoggerOpts);
const loggerLC = testLogger("LC", {...testLoggerOpts, level: LogLevel.debug});

const bn = await getDevBeaconNode({
Expand All @@ -89,6 +89,7 @@ describe("chain / lightclient", function () {

const {validators} = await getAndInitDevValidators({
node: bn,
logPrefix: "lightclientNode",
validatorsPerClient: validatorCount,
validatorClientCount,
startIndex: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe.skip("doppelganger / doppelganger test", function () {

async function createBNAndVC(config?: TestConfig): Promise<{beaconNode: BeaconNode; validators: Validator[]}> {
const testLoggerOpts: TestLoggerOpts = {level: LogLevel.info};
const loggerNodeA = testLogger("Node-A", testLoggerOpts);
const loggerNodeA = testLogger("doppelganger", testLoggerOpts);

const bn = await getDevBeaconNode({
params: beaconParams,
Expand All @@ -65,6 +65,7 @@ describe.skip("doppelganger / doppelganger test", function () {

const {validators: validatorsWithDoppelganger} = await getAndInitDevValidators({
node: bn,
logPrefix: "doppelganger",
validatorsPerClient: validatorCount,
validatorClientCount: 1,
startIndex: 0,
Expand Down Expand Up @@ -161,6 +162,7 @@ describe.skip("doppelganger / doppelganger test", function () {
});

const {validators: validator0WithoutDoppelganger} = await getAndInitDevValidators({
logPrefix: "doppelganger2",
node: bn,
validatorsPerClient: validatorCount,
validatorClientCount: 1,
Expand Down
11 changes: 8 additions & 3 deletions packages/beacon-node/test/e2e/network/gossipsub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe("gossipsub / worker", function () {

function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {
if (this.timeout() < 20 * 1000) this.timeout(150 * 1000);
this.retries(2); // This test fail sometimes, with a 5% rate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can this be removed now? Was this just related to libp2p issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because tests are performing more stable now, so we don't need to have retries here.


const afterEachCallbacks: (() => Promise<void> | void)[] = [];
afterEach(async () => {
Expand All @@ -41,8 +40,14 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function mockModules(gossipHandlersPartial?: Partial<GossipHandlers>) {
const [netA, closeA] = await getNetworkForTest("A", config, {opts: {useWorker}, gossipHandlersPartial});
const [netB, closeB] = await getNetworkForTest("B", config, {opts: {useWorker}, gossipHandlersPartial});
const [netA, closeA] = await getNetworkForTest(`gossipsub-${useWorker ? "worker" : "main"}-A`, config, {
opts: {useWorker},
gossipHandlersPartial,
});
const [netB, closeB] = await getNetworkForTest(`gossipsub-${useWorker ? "worker" : "main"}-B`, config, {
opts: {useWorker},
gossipHandlersPartial,
});

afterEachCallbacks.push(async () => {
await closeA();
Expand Down
3 changes: 1 addition & 2 deletions packages/beacon-node/test/e2e/network/mdns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const mu = "/ip4/127.0.0.1/tcp/0";
// eslint-disable-next-line mocha/no-skipped-tests
describe.skip("mdns", function () {
this.timeout(50000);
this.retries(2); // This test fail sometimes, with a 5% rate.

const afterEachCallbacks: (() => Promise<void> | void)[] = [];
afterEach(async () => {
Expand Down Expand Up @@ -121,7 +120,7 @@ describe.skip("mdns", function () {

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function createTestNodesAB() {
return Promise.all([createTestNode("A"), createTestNode("B")]);
return Promise.all([createTestNode("mdns-A"), createTestNode("mdns-B")]);
}

it("should connect two peers on a LAN", async function () {
Expand Down
27 changes: 16 additions & 11 deletions packages/beacon-node/test/e2e/network/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,47 @@ describe("network / worker", function () {

function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {
this.timeout(50000);
this.retries(2); // This test fail sometimes, with a 5% rate.

const afterEachCallbacks: (() => Promise<void> | void)[] = [];
afterEach(async () => {
await Promise.all(afterEachCallbacks.map((cb) => cb()));
afterEachCallbacks.splice(0, afterEachCallbacks.length);
while (afterEachCallbacks.length > 0) {
const callback = afterEachCallbacks.pop();
if (callback) await callback();
}
});

let controller: AbortController;
beforeEach(() => (controller = new AbortController()));
afterEach(() => controller.abort());
afterEach(() => {
controller.abort();
sinon.restore();
});

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function createTestNode(nodeName: string) {
const [network, closeAll] = await getNetworkForTest(nodeName, config, {opts: {useWorker}});

afterEachCallbacks.push(async () => {
await closeAll();
sinon.restore();
});

return network;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function createTestNodesAB() {
return Promise.all([createTestNode("A"), createTestNode("B")]);
async function createTestNodesAB(): Promise<[Network, Network]> {
return Promise.all([
createTestNode(`network-${useWorker ? "worker" : "main"}-A`),
createTestNode(`network-${useWorker ? "worker" : "main"}-A`),
]);
}

it("Disconnect peer", async () => {
const network = await createTestNode("A");
const network = await createTestNode(`network-${useWorker ? "worker" : "main"}-DP`);
await network.disconnectPeer(getValidPeerId().toString());
});

it("return getNetworkIdentity", async () => {
const network = await createTestNode("A");
const network = await createTestNode(`network-${useWorker ? "worker" : "main"}-NI`);
const networkIdentity = await network.getNetworkIdentity();
expect(networkIdentity.peerId).equals(network.peerId.toString());
});
Expand Down Expand Up @@ -125,7 +130,7 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {
});

it("Should subscribe to gossip core topics on demand", async () => {
const netA = await createTestNode("A");
const netA = await createTestNode(`network-${useWorker ? "worker" : "main"}-CT`);

expect(await getTopics(netA)).deep.equals([]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {IAttnetsService} from "../../../../src/network/subnets/index.js";
import {Clock} from "../../../../src/util/clock.js";
import {LocalStatusCache} from "../../../../src/network/statusCache.js";

const logger = testLogger();
const logger = testLogger("peerManager");

describe("network / peers / PeerManager", function () {
const peerId1 = getValidPeerId();
Expand Down Expand Up @@ -93,6 +93,10 @@ describe("network / peers / PeerManager", function () {
null
);

afterEachCallbacks.push(async () => {
await peerManager.close();
});

return {statusCache, clock, libp2p, reqResp, peerManager, networkEventBus};
}

Expand Down
11 changes: 8 additions & 3 deletions packages/beacon-node/test/e2e/network/reqresp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe("network / reqresp / worker", function () {

function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {
if (this.timeout() < 60_000) this.timeout(60_000);
this.retries(2); // This test fail sometimes, with a 5% rate.

// Schedule ALTAIR_FORK_EPOCH to trigger registering lightclient ReqResp protocols immediately
const config = createChainForkConfig({
Expand All @@ -56,8 +55,14 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void {
getReqRespHandler?: GetReqRespHandlerFn,
opts?: ReqRespBeaconNodeOpts
): Promise<[Network, Network, PeerIdStr, PeerIdStr]> {
const [netA, closeA] = await getNetworkForTest("A", config, {getReqRespHandler, opts: {...opts, useWorker}});
const [netB, closeB] = await getNetworkForTest("B", config, {getReqRespHandler, opts: {...opts, useWorker}});
const [netA, closeA] = await getNetworkForTest(`reqresp-${useWorker ? "worker" : "main"}-A`, config, {
getReqRespHandler,
opts: {...opts, useWorker},
});
const [netB, closeB] = await getNetworkForTest(`reqresp-${useWorker ? "worker" : "main"}-B`, config, {
getReqRespHandler,
opts: {...opts, useWorker},
});

afterEachCallbacks.push(async () => {
await closeA();
Expand Down
7 changes: 3 additions & 4 deletions packages/beacon-node/test/e2e/sync/unknownBlockSync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describe("sync / unknown block sync", function () {
},
};

const loggerNodeA = testLogger("Node-A", testLoggerOpts);
const loggerNodeB = testLogger("Node-B", testLoggerOpts);
const loggerNodeA = testLogger("UnknownSync-Node-A", testLoggerOpts);
const loggerNodeB = testLogger("UnknownSync-Node-B", testLoggerOpts);

const bn = await getDevBeaconNode({
params: testParams,
Expand All @@ -73,10 +73,9 @@ describe("sync / unknown block sync", function () {
logger: loggerNodeA,
});

afterEachCallbacks.push(() => bn.close());

const {validators} = await getAndInitDevValidators({
node: bn,
logPrefix: "UnknownSync",
validatorsPerClient: validatorCount,
validatorClientCount: 1,
startIndex: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/test/sim/4844-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
const {data: bnIdentity} = await bn.api.node.getNetworkIdentity();

const {validators} = await getAndInitDevValidators({
logPrefix: "Node-A",
node: bn,
validatorsPerClient,
validatorClientCount,
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/test/sim/merge-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
} as ValidatorProposerConfig;

const {validators} = await getAndInitDevValidators({
logPrefix: "Node-A",
node: bn,
validatorsPerClient,
validatorClientCount,
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/test/sim/mergemock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
} as ValidatorProposerConfig;

const {validators} = await getAndInitDevValidators({
logPrefix: "mergemock",
node: bn,
validatorsPerClient,
validatorClientCount,
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/test/sim/withdrawal-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
} as ValidatorProposerConfig;

const {validators} = await getAndInitDevValidators({
logPrefix: "withdrawal-interop",
node: bn,
validatorsPerClient,
validatorClientCount,
Expand Down
Loading
Loading