@lodestar/beacon-node 1.41.0-dev.3b98c59c64 → 1.41.0-dev.45864cc073
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/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +3 -2
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +1 -0
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/node/utils.d.ts +1 -1
- package/lib/api/impl/node/utils.d.ts.map +1 -1
- package/lib/api/impl/node/utils.js.map +1 -1
- package/lib/api/impl/validator/index.js +2 -2
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/utils/updateBackfillRange.js +1 -1
- package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +20 -2
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +47 -0
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +2 -1
- package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/types.js +1 -0
- package/lib/chain/blocks/blockInput/types.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +26 -3
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -0
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -0
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/chain.js +6 -6
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +3 -3
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +30 -24
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +1 -2
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +4 -1
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +5 -1
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +15 -7
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +1 -1
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.js +3 -3
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +8 -1
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/blobSidecar.js +2 -2
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +6 -3
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +1 -2
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +4 -4
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +1 -2
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/db/repositories/blockArchive.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.js +1 -2
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/execution/engine/http.d.ts +1 -0
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +3 -0
- package/lib/execution/engine/http.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/networkCore.d.ts +3 -3
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -3
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/types.d.ts +2 -2
- package/lib/network/core/types.d.ts.map +1 -1
- package/lib/network/events.d.ts +2 -1
- package/lib/network/events.d.ts.map +1 -1
- package/lib/network/events.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts +3 -3
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +13 -4
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +47 -20
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +3 -3
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/scoringParameters.d.ts +1 -1
- package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
- package/lib/network/gossip/scoringParameters.js +1 -1
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/interface.d.ts +3 -3
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/libp2p/index.d.ts +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +7 -2
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/network.d.ts +2 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js +3 -0
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/datastore.d.ts +7 -5
- package/lib/network/peers/datastore.d.ts.map +1 -1
- package/lib/network/peers/datastore.js +10 -10
- package/lib/network/peers/datastore.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts +1 -0
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +51 -29
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +3 -3
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +4 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +1 -1
- package/lib/network/processor/types.d.ts +1 -1
- package/lib/network/processor/types.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.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/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +0 -1
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/util.js +2 -2
- package/lib/network/util.js.map +1 -1
- package/lib/util/clock.d.ts +6 -0
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +9 -3
- package/lib/util/clock.js.map +1 -1
- package/package.json +38 -41
- package/src/api/impl/beacon/blocks/index.ts +3 -2
- package/src/api/impl/debug/index.ts +1 -0
- package/src/api/impl/node/utils.ts +3 -3
- package/src/api/impl/validator/index.ts +2 -2
- package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
- package/src/chain/blocks/blockInput/blockInput.ts +68 -3
- package/src/chain/blocks/blockInput/types.ts +1 -0
- package/src/chain/blocks/importBlock.ts +34 -3
- package/src/chain/blocks/verifyBlocksDataAvailability.ts +3 -0
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
- package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
- package/src/chain/chain.ts +6 -6
- package/src/chain/emitter.ts +3 -3
- package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
- package/src/chain/forkChoice/index.ts +39 -21
- package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
- package/src/chain/produceBlock/produceBlockBody.ts +1 -2
- package/src/chain/regen/queued.ts +7 -2
- package/src/chain/regen/regen.ts +8 -2
- package/src/chain/seenCache/seenGossipBlockInput.ts +16 -7
- package/src/chain/validation/aggregateAndProof.ts +1 -1
- package/src/chain/validation/attestation.ts +3 -3
- package/src/chain/validation/attesterSlashing.ts +9 -0
- package/src/chain/validation/blobSidecar.ts +2 -2
- package/src/chain/validation/block.ts +9 -4
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/chain/validation/executionPayloadBid.ts +1 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +4 -4
- package/src/chain/validation/payloadAttestationMessage.ts +1 -2
- package/src/db/repositories/blockArchive.ts +1 -2
- package/src/execution/engine/http.ts +3 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/networkCore.ts +3 -3
- package/src/network/core/networkCoreWorkerHandler.ts +3 -3
- package/src/network/core/types.ts +2 -2
- package/src/network/events.ts +2 -1
- package/src/network/gossip/encoding.ts +3 -3
- package/src/network/gossip/gossipsub.ts +86 -25
- package/src/network/gossip/interface.ts +3 -3
- package/src/network/gossip/scoringParameters.ts +4 -4
- package/src/network/interface.ts +3 -3
- package/src/network/libp2p/index.ts +8 -3
- package/src/network/network.ts +3 -3
- package/src/network/options.ts +3 -0
- package/src/network/peers/datastore.ts +13 -10
- package/src/network/peers/peerManager.ts +56 -30
- package/src/network/peers/utils/prioritizePeers.ts +3 -3
- package/src/network/processor/gossipHandlers.ts +12 -3
- package/src/network/processor/gossipValidatorFn.ts +1 -1
- package/src/network/processor/types.ts +1 -1
- package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/network/reqresp/score.ts +0 -1
- package/src/network/util.ts +2 -2
- package/src/util/clock.ts +9 -4
- package/src/util/workerEvents.ts +1 -1
|
@@ -162,7 +162,6 @@ export class PeerManager {
|
|
|
162
162
|
|
|
163
163
|
// A single map of connected peers with all necessary data to handle PINGs, STATUS, and metrics
|
|
164
164
|
private connectedPeers: Map<PeerIdStr, PeerData>;
|
|
165
|
-
|
|
166
165
|
private opts: PeerManagerOpts;
|
|
167
166
|
private intervals: NodeJS.Timeout[] = [];
|
|
168
167
|
|
|
@@ -480,6 +479,14 @@ export class PeerManager {
|
|
|
480
479
|
clientAgent,
|
|
481
480
|
custodyColumns,
|
|
482
481
|
});
|
|
482
|
+
|
|
483
|
+
// Identify peer after status proves the connection is usable.
|
|
484
|
+
// This is the only place we trigger identify — avoids wasted streams on
|
|
485
|
+
// peers that close identify right after connection open or turn out to be
|
|
486
|
+
// irrelevant.
|
|
487
|
+
if (peerData?.agentVersion === null) {
|
|
488
|
+
void this.identifyPeer(peer.toString(), prettyPrintPeerId(peer), getConnection(this.libp2p, peer.toString()));
|
|
489
|
+
}
|
|
483
490
|
}
|
|
484
491
|
}
|
|
485
492
|
|
|
@@ -753,21 +760,26 @@ export class PeerManager {
|
|
|
753
760
|
// NOTE: libp2p may emit two "peer:connect" events: One for inbound, one for outbound
|
|
754
761
|
// If that happens, it's okay. Only the "outbound" connection triggers immediate action
|
|
755
762
|
const now = Date.now();
|
|
763
|
+
const existingPeerData = this.connectedPeers.get(remotePeerStr);
|
|
756
764
|
const nodeId = computeNodeId(remotePeer);
|
|
757
765
|
const peerData: PeerData = {
|
|
758
|
-
|
|
766
|
+
// Keep existing timestamps if this peer already had another open connection.
|
|
767
|
+
// libp2p may emit multiple connection:open events per peer.
|
|
768
|
+
lastReceivedMsgUnixTsMs: existingPeerData?.lastReceivedMsgUnixTsMs ?? (direction === "outbound" ? 0 : now),
|
|
759
769
|
// If inbound, request after STATUS_INBOUND_GRACE_PERIOD
|
|
760
|
-
lastStatusUnixTsMs:
|
|
761
|
-
|
|
762
|
-
|
|
770
|
+
lastStatusUnixTsMs:
|
|
771
|
+
existingPeerData?.lastStatusUnixTsMs ??
|
|
772
|
+
(direction === "outbound" ? 0 : now - STATUS_INTERVAL_MS + STATUS_INBOUND_GRACE_PERIOD),
|
|
773
|
+
connectedUnixTsMs: existingPeerData?.connectedUnixTsMs ?? now,
|
|
774
|
+
relevantStatus: existingPeerData?.relevantStatus ?? RelevantPeerStatus.Unknown,
|
|
763
775
|
direction,
|
|
764
776
|
nodeId,
|
|
765
777
|
peerId: remotePeer,
|
|
766
|
-
status: null,
|
|
767
|
-
metadata: null,
|
|
768
|
-
agentVersion: null,
|
|
769
|
-
agentClient: null,
|
|
770
|
-
encodingPreference: null,
|
|
778
|
+
status: existingPeerData?.status ?? null,
|
|
779
|
+
metadata: existingPeerData?.metadata ?? null,
|
|
780
|
+
agentVersion: existingPeerData?.agentVersion ?? null,
|
|
781
|
+
agentClient: existingPeerData?.agentClient ?? null,
|
|
782
|
+
encodingPreference: existingPeerData?.encodingPreference ?? null,
|
|
771
783
|
};
|
|
772
784
|
this.connectedPeers.set(remotePeerStr, peerData);
|
|
773
785
|
|
|
@@ -776,26 +788,6 @@ export class PeerManager {
|
|
|
776
788
|
void this.requestStatus(remotePeer, this.statusCache.get());
|
|
777
789
|
}
|
|
778
790
|
|
|
779
|
-
this.libp2p.services.identify
|
|
780
|
-
.identify(connection)
|
|
781
|
-
.then((result) => {
|
|
782
|
-
const agentVersion = result.agentVersion;
|
|
783
|
-
if (agentVersion) {
|
|
784
|
-
peerData.agentVersion = agentVersion;
|
|
785
|
-
peerData.agentClient = getKnownClientFromAgentVersion(agentVersion);
|
|
786
|
-
}
|
|
787
|
-
})
|
|
788
|
-
.catch((err) => {
|
|
789
|
-
if (connection.status !== "open") {
|
|
790
|
-
this.logger.debug("Peer disconnected during identify protocol", {
|
|
791
|
-
peerId: remotePeerPrettyStr,
|
|
792
|
-
error: (err as Error).message,
|
|
793
|
-
});
|
|
794
|
-
} else {
|
|
795
|
-
this.logger.debug("Error setting agentVersion for the peer", {peerId: remotePeerPrettyStr}, err);
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
|
|
799
791
|
return true;
|
|
800
792
|
}
|
|
801
793
|
|
|
@@ -822,6 +814,19 @@ export class PeerManager {
|
|
|
822
814
|
const {direction, status, remotePeer} = evt.detail;
|
|
823
815
|
const peerIdStr = remotePeer.toString();
|
|
824
816
|
|
|
817
|
+
const openConnections =
|
|
818
|
+
getConnectionsMap(this.libp2p)
|
|
819
|
+
.get(peerIdStr)
|
|
820
|
+
?.value.filter((connection) => connection.status === "open") ?? [];
|
|
821
|
+
if (openConnections.length > 0) {
|
|
822
|
+
this.logger.debug("Ignoring peer disconnect event while another connection is still open", {
|
|
823
|
+
peerId: prettyPrintPeerIdStr(peerIdStr),
|
|
824
|
+
direction,
|
|
825
|
+
status,
|
|
826
|
+
});
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
|
|
825
830
|
let logMessage = "onLibp2pPeerDisconnect";
|
|
826
831
|
const logContext: Record<string, string | number> = {
|
|
827
832
|
peerId: prettyPrintPeerIdStr(peerIdStr),
|
|
@@ -856,6 +861,27 @@ export class PeerManager {
|
|
|
856
861
|
}
|
|
857
862
|
}
|
|
858
863
|
|
|
864
|
+
private async identifyPeer(peerIdStr: string, peerIdPretty: string, connection?: Connection): Promise<void> {
|
|
865
|
+
if (!connection || connection.status !== "open") {
|
|
866
|
+
this.logger.debug("Peer has no open connection for identify", {peerId: peerIdPretty});
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
try {
|
|
871
|
+
const result = await this.libp2p.services.identify.identify(connection);
|
|
872
|
+
const agentVersion = result.agentVersion;
|
|
873
|
+
if (agentVersion) {
|
|
874
|
+
const connectedPeerData = this.connectedPeers.get(peerIdStr);
|
|
875
|
+
if (connectedPeerData) {
|
|
876
|
+
connectedPeerData.agentVersion = agentVersion;
|
|
877
|
+
connectedPeerData.agentClient = getKnownClientFromAgentVersion(agentVersion);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
} catch (e) {
|
|
881
|
+
this.logger.debug("Error setting agentVersion for the peer", {peerId: peerIdPretty}, e as Error);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
859
885
|
private async goodbyeAndDisconnect(peer: PeerId, goodbye: GoodByeReasonCode): Promise<void> {
|
|
860
886
|
const reason = GOODBYE_KNOWN_CODES[goodbye.toString()] || "";
|
|
861
887
|
const peerIdStr = peer.toString();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {MessageStreamDirection, PeerId} from "@libp2p/interface";
|
|
2
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
3
3
|
import {ChainConfig} from "@lodestar/config";
|
|
4
4
|
import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
|
|
@@ -95,7 +95,7 @@ function computeStatusScore(ours: Status, theirs: Status | null, opts: Prioritiz
|
|
|
95
95
|
|
|
96
96
|
type PeerInfo = {
|
|
97
97
|
id: PeerId;
|
|
98
|
-
direction:
|
|
98
|
+
direction: MessageStreamDirection | null;
|
|
99
99
|
statusScore: StatusScore;
|
|
100
100
|
attnets: phase0.AttestationSubnets;
|
|
101
101
|
syncnets: altair.SyncSubnets;
|
|
@@ -137,7 +137,7 @@ export enum ExcessPeerDisconnectReason {
|
|
|
137
137
|
export function prioritizePeers(
|
|
138
138
|
connectedPeersInfo: {
|
|
139
139
|
id: PeerId;
|
|
140
|
-
direction:
|
|
140
|
+
direction: MessageStreamDirection | null;
|
|
141
141
|
status: Status | null;
|
|
142
142
|
attnets: phase0.AttestationSubnets | null;
|
|
143
143
|
syncnets: altair.SyncSubnets | null;
|
|
@@ -2,6 +2,7 @@ import {routes} from "@lodestar/api";
|
|
|
2
2
|
import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {
|
|
4
4
|
ForkName,
|
|
5
|
+
ForkPostDeneb,
|
|
5
6
|
ForkPostElectra,
|
|
6
7
|
ForkPreElectra,
|
|
7
8
|
ForkSeq,
|
|
@@ -70,6 +71,7 @@ import {validateGossipPayloadAttestationMessage} from "../../chain/validation/pa
|
|
|
70
71
|
import {OpSource} from "../../chain/validatorMonitor.js";
|
|
71
72
|
import {Metrics} from "../../metrics/index.js";
|
|
72
73
|
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
|
|
74
|
+
import {getBlobKzgCommitments} from "../../util/dataColumns.ts";
|
|
73
75
|
import {INetworkCore} from "../core/index.js";
|
|
74
76
|
import {NetworkEventBus} from "../events.js";
|
|
75
77
|
import {
|
|
@@ -417,9 +419,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
417
419
|
chain.getBlobsTracker.triggerGetBlobs(blockInput);
|
|
418
420
|
} else {
|
|
419
421
|
metrics?.blockInputFetchStats.totalDataAvailableBlockInputs.inc();
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
422
|
+
const blobCount = getBlobKzgCommitments(
|
|
423
|
+
blockInput.forkName,
|
|
424
|
+
signedBlock as SignedBeaconBlock<ForkPostDeneb>
|
|
425
|
+
).length;
|
|
426
|
+
metrics?.blockInputFetchStats.totalDataAvailableBlockInputBlobs.inc(blobCount);
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
chain
|
|
@@ -852,6 +856,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
852
856
|
} catch (e) {
|
|
853
857
|
logger.error("Error adding to payloadAttestation pool", {}, e as Error);
|
|
854
858
|
}
|
|
859
|
+
chain.forkChoice.notifyPtcMessages(
|
|
860
|
+
toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
|
|
861
|
+
[validationResult.validatorCommitteeIndex],
|
|
862
|
+
payloadAttestationMessage.data.payloadPresent
|
|
863
|
+
);
|
|
855
864
|
},
|
|
856
865
|
[GossipType.execution_payload_bid]: async ({
|
|
857
866
|
gossipData,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {TopicValidatorResult} from "@libp2p/
|
|
1
|
+
import {TopicValidatorResult} from "@libp2p/gossipsub";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {Logger} from "@lodestar/utils";
|
|
4
4
|
import {AttestationError, GossipAction, GossipActionError} from "../../chain/errors/index.js";
|
|
@@ -20,7 +20,7 @@ export async function* onBlobSidecarsByRoot(
|
|
|
20
20
|
for (const blobIdentifier of requestBody) {
|
|
21
21
|
const {blockRoot, index} = blobIdentifier;
|
|
22
22
|
const blockRootHex = toRootHex(blockRoot);
|
|
23
|
-
const block = chain.forkChoice.
|
|
23
|
+
const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
|
|
24
24
|
|
|
25
25
|
// NOTE: Only support non-finalized blocks.
|
|
26
26
|
// SPEC: Clients MUST support requesting blocks and sidecars since the latest finalized epoch.
|
|
@@ -34,7 +34,7 @@ export async function* onDataColumnSidecarsByRoot(
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const blockRootHex = toRootHex(blockRoot);
|
|
37
|
-
const block = chain.forkChoice.
|
|
37
|
+
const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
|
|
38
38
|
// If the block is not in fork choice, it may be finalized. Attempt to find its slot in block archive
|
|
39
39
|
const slot = block ? block.slot : await db.blockArchive.getSlotByRoot(blockRoot);
|
|
40
40
|
|
|
@@ -38,7 +38,6 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
|
|
|
38
38
|
: PeerAction.LowToleranceError;
|
|
39
39
|
// TODO: Detect SSZDecodeError and return PeerAction.Fatal
|
|
40
40
|
|
|
41
|
-
case RequestErrorCode.TTFB_TIMEOUT:
|
|
42
41
|
case RequestErrorCode.RESP_TIMEOUT:
|
|
43
42
|
switch (method) {
|
|
44
43
|
case ReqRespMethod.Ping:
|
package/src/network/util.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function getConnection(libp2p: Libp2p, peerIdStr: string): Connection | u
|
|
|
23
23
|
return getConnectionsMap(libp2p).get(peerIdStr)?.value[0] ?? undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// https://github.com/
|
|
26
|
+
// https://github.com/libp2p/js-libp2p/blob/f87cba928991736d9646b3e054c367f55cab315c/packages/gossipsub/src/gossipsub.ts#L2076
|
|
27
27
|
export function isPublishToZeroPeersError(e: Error): boolean {
|
|
28
|
-
return e.message.includes("PublishError.
|
|
28
|
+
return e.message.includes("PublishError.NoPeersSubscribedToTopic");
|
|
29
29
|
}
|
package/src/util/clock.ts
CHANGED
|
@@ -92,15 +92,17 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
92
92
|
}
|
|
93
93
|
return slot;
|
|
94
94
|
}
|
|
95
|
-
|
|
96
95
|
/**
|
|
97
96
|
* If it's too close to next slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY, return currentSlot + 1.
|
|
98
97
|
* Otherwise return currentSlot
|
|
98
|
+
*
|
|
99
|
+
* Spec: phase0/p2p-interface.md - gossip validation uses `current_time + MAXIMUM_GOSSIP_CLOCK_DISPARITY < message_time`
|
|
100
|
+
* to reject future messages (strict `<`), so the boundary (exactly equal) is accepted, hence `<=` here.
|
|
99
101
|
*/
|
|
100
102
|
get currentSlotWithGossipDisparity(): Slot {
|
|
101
103
|
const currentSlot = this.currentSlot;
|
|
102
104
|
const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
|
|
103
|
-
return nextSlotTime - Date.now()
|
|
105
|
+
return nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
get currentEpoch(): Epoch {
|
|
@@ -121,6 +123,9 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* Check if a slot is current slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY.
|
|
126
|
+
*
|
|
127
|
+
* Uses `<=` for disparity checks because the spec rejects with strict `<`
|
|
128
|
+
* (phase0/p2p-interface.md), meaning the boundary (exactly equal) is accepted.
|
|
124
129
|
*/
|
|
125
130
|
isCurrentSlotGivenGossipDisparity(slot: Slot): boolean {
|
|
126
131
|
const currentSlot = this.currentSlot;
|
|
@@ -129,12 +134,12 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
129
134
|
}
|
|
130
135
|
const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
|
|
131
136
|
// we're too close to next slot, accept next slot
|
|
132
|
-
if (nextSlotTime - Date.now()
|
|
137
|
+
if (nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
|
|
133
138
|
return slot === currentSlot + 1;
|
|
134
139
|
}
|
|
135
140
|
const currentSlotTime = computeTimeAtSlot(this.config, currentSlot, this.genesisTime) * 1000;
|
|
136
141
|
// we've just passed the current slot, accept previous slot
|
|
137
|
-
if (Date.now() - currentSlotTime
|
|
142
|
+
if (Date.now() - currentSlotTime <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
|
|
138
143
|
return slot === currentSlot - 1;
|
|
139
144
|
}
|
|
140
145
|
return false;
|
package/src/util/workerEvents.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {MessagePort, Worker} from "node:worker_threads";
|
|
2
|
-
import {Message} from "@libp2p/
|
|
2
|
+
import type {Message} from "@libp2p/gossipsub";
|
|
3
3
|
import {Thread} from "@chainsafe/threads";
|
|
4
4
|
import {Logger} from "@lodestar/logger";
|
|
5
5
|
import {sleep} from "@lodestar/utils";
|