diff --git a/lerna.json b/lerna.json index 6904ec0a004c..a9c5000b24f5 100644 --- a/lerna.json +++ b/lerna.json @@ -5,7 +5,7 @@ "npmClient": "yarn", "useWorkspaces": true, "useNx": true, - "version": "1.9.0", + "version": "1.9.1", "stream": "true", "command": { "version": { diff --git a/packages/api/package.json b/packages/api/package.json index 131283eb77e7..a1d215983693 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.0", + "version": "1.9.1", "type": "module", "exports": { ".": { @@ -71,10 +71,10 @@ "dependencies": { "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/ssz": "^0.10.2", - "@lodestar/config": "^1.9.0", - "@lodestar/params": "^1.9.0", - "@lodestar/types": "^1.9.0", - "@lodestar/utils": "^1.9.0", + "@lodestar/config": "^1.9.1", + "@lodestar/params": "^1.9.1", + "@lodestar/types": "^1.9.1", + "@lodestar/utils": "^1.9.1", "cross-fetch": "^3.1.4", "eventsource": "^2.0.2", "qs": "^6.11.1" diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index 2957675c6f84..16e2f67ed117 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.0", + "version": "1.9.1", "type": "module", "exports": { ".": { @@ -118,18 +118,18 @@ "@libp2p/peer-id-factory": "^2.0.1", "@libp2p/prometheus-metrics": "^1.1.3", "@libp2p/tcp": "6.1.0", - "@lodestar/api": "^1.9.0", - "@lodestar/config": "^1.9.0", - "@lodestar/db": "^1.9.0", - "@lodestar/fork-choice": "^1.9.0", - "@lodestar/light-client": "^1.9.0", - "@lodestar/logger": "^1.9.0", - "@lodestar/params": "^1.9.0", - "@lodestar/reqresp": "^1.9.0", - "@lodestar/state-transition": "^1.9.0", - "@lodestar/types": "^1.9.0", - "@lodestar/utils": "^1.9.0", - "@lodestar/validator": "^1.9.0", + "@lodestar/api": "^1.9.1", + "@lodestar/config": "^1.9.1", + "@lodestar/db": "^1.9.1", + "@lodestar/fork-choice": "^1.9.1", + "@lodestar/light-client": "^1.9.1", + "@lodestar/logger": "^1.9.1", + "@lodestar/params": "^1.9.1", + "@lodestar/reqresp": "^1.9.1", + "@lodestar/state-transition": "^1.9.1", + "@lodestar/types": "^1.9.1", + "@lodestar/utils": "^1.9.1", + "@lodestar/validator": "^1.9.1", "@multiformats/multiaddr": "^11.0.0", "@types/datastore-level": "^3.0.0", "buffer-xor": "^2.0.2", diff --git a/packages/beacon-node/src/network/gossip/gossipsub.ts b/packages/beacon-node/src/network/gossip/gossipsub.ts index fbafabcf1a44..ef159e019077 100644 --- a/packages/beacon-node/src/network/gossip/gossipsub.ts +++ b/packages/beacon-node/src/network/gossip/gossipsub.ts @@ -279,21 +279,30 @@ export class Eth2Gossipsub extends GossipSub { // Get seenTimestamp before adding the message to the queue or add async delays const seenTimestampSec = Date.now() / 1000; - // Emit message to network processor - this.events.emit(NetworkEvent.pendingGossipsubMessage, { - topic, - msg, - msgId, - // Hot path, use cached .toString() version - propagationSource: propagationSource.toString(), - seenTimestampSec, - startProcessUnixSec: null, - }); + // Use setTimeout to yield to the macro queue + // Without this we'll have huge event loop lag + // See https://github.com/ChainSafe/lodestar/issues/5604 + setTimeout(() => { + this.events.emit(NetworkEvent.pendingGossipsubMessage, { + topic, + msg, + msgId, + // Hot path, use cached .toString() version + propagationSource: propagationSource.toString(), + seenTimestampSec, + startProcessUnixSec: null, + }); + }, 0); } private onValidationResult(data: NetworkEventData[NetworkEvent.gossipMessageValidationResult]): void { - // TODO: reportMessageValidationResult should take PeerIdStr since it only uses string version - this.reportMessageValidationResult(data.msgId, peerIdFromString(data.propagationSource), data.acceptance); + // Use setTimeout to yield to the macro queue + // Without this we'll have huge event loop lag + // See https://github.com/ChainSafe/lodestar/issues/5604 + setTimeout(() => { + // TODO: reportMessageValidationResult should take PeerIdStr since it only uses string version + this.reportMessageValidationResult(data.msgId, peerIdFromString(data.propagationSource), data.acceptance); + }, 0); } } diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index e4cfbee6f149..0864e792b56c 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -263,7 +263,8 @@ export class Network implements INetwork { // Drop all the gossip validation queues this.networkProcessor.dropAllJobs(); - return this.core.unsubscribeGossipCoreTopics(); + await this.core.unsubscribeGossipCoreTopics(); + this.subscribedToCoreTopics = false; } isSubscribedToGossipCoreTopics(): boolean { diff --git a/packages/beacon-node/src/network/processor/gossipHandlers.ts b/packages/beacon-node/src/network/processor/gossipHandlers.ts index 5804eceb6144..ca4320609e0b 100644 --- a/packages/beacon-node/src/network/processor/gossipHandlers.ts +++ b/packages/beacon-node/src/network/processor/gossipHandlers.ts @@ -138,6 +138,8 @@ export function getGossipHandlers(modules: ValidatorFnsModules, options: GossipH chain .processBlock(blockInput, { + // block may be downloaded and processed by UnknownBlockSync + ignoreIfKnown: true, // proposer signature already checked in validateBeaconBlock() validProposerSignature: true, // blobsSidecar already checked in validateGossipBlobsSidecar() @@ -162,6 +164,8 @@ export function getGossipHandlers(modules: ValidatorFnsModules, options: GossipH .catch((e) => { if (e instanceof BlockError) { switch (e.type.code) { + // ALREADY_KNOWN should not happen with ignoreIfKnown=true above + // PARENT_UNKNOWN should not happen, we handled this in validateBeaconBlock() function above case BlockErrorCode.ALREADY_KNOWN: case BlockErrorCode.PARENT_UNKNOWN: case BlockErrorCode.PRESTATE_MISSING: diff --git a/packages/beacon-node/src/sync/sync.ts b/packages/beacon-node/src/sync/sync.ts index 7d56c1a27883..914d511eb8e0 100644 --- a/packages/beacon-node/src/sync/sync.ts +++ b/packages/beacon-node/src/sync/sync.ts @@ -223,8 +223,8 @@ export class BeaconSync implements IBeaconSync { else if (state !== SyncState.Synced) { const syncDiff = this.chain.clock.currentSlot - this.chain.forkChoice.getHead().slot; if (syncDiff > this.slotImportTolerance * 2) { - this.logger.warn(`Node sync has fallen behind by ${syncDiff} slots`); if (this.network.isSubscribedToGossipCoreTopics()) { + this.logger.warn(`Node sync has fallen behind by ${syncDiff} slots`); this.network .unsubscribeGossipCoreTopics() .then(() => { diff --git a/packages/cli/package.json b/packages/cli/package.json index f9312e740954..1d4d29d5ee9b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@chainsafe/lodestar", - "version": "1.9.0", + "version": "1.9.1", "description": "Command line interface for lodestar", "author": "ChainSafe Systems", "license": "LGPL-3.0", @@ -60,17 +60,17 @@ "@chainsafe/discv5": "^3.0.0", "@chainsafe/ssz": "^0.10.2", "@libp2p/peer-id-factory": "^2.0.3", - "@lodestar/api": "^1.9.0", - "@lodestar/beacon-node": "^1.9.0", - "@lodestar/config": "^1.9.0", - "@lodestar/db": "^1.9.0", - "@lodestar/light-client": "^1.9.0", - "@lodestar/logger": "^1.9.0", - "@lodestar/params": "^1.9.0", - "@lodestar/state-transition": "^1.9.0", - "@lodestar/types": "^1.9.0", - "@lodestar/utils": "^1.9.0", - "@lodestar/validator": "^1.9.0", + "@lodestar/api": "^1.9.1", + "@lodestar/beacon-node": "^1.9.1", + "@lodestar/config": "^1.9.1", + "@lodestar/db": "^1.9.1", + "@lodestar/light-client": "^1.9.1", + "@lodestar/logger": "^1.9.1", + "@lodestar/params": "^1.9.1", + "@lodestar/state-transition": "^1.9.1", + "@lodestar/types": "^1.9.1", + "@lodestar/utils": "^1.9.1", + "@lodestar/validator": "^1.9.1", "@multiformats/multiaddr": "^11.0.0", "@types/lockfile": "^1.0.2", "bip39": "^3.1.0", diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index af34cf861697..4c71e4714dd2 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -130,6 +130,9 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise