@lodestar/beacon-node 1.52.0-dev.dad8e3af98 → 1.52.0-dev.deb8a48a68
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/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -4
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +6 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +17 -2
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +21 -5
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -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/gossip/gossipsub.d.ts +1 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +3 -0
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +22 -2
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +11 -2
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/sync/types.d.ts +2 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +123 -22
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +5 -4
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/package.json +26 -26
- package/src/api/impl/validator/index.ts +2 -4
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/validation/executionPayloadBid.ts +20 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +28 -5
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/gossip/gossipsub.ts +4 -0
- package/src/network/network.ts +6 -2
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/sync/types.ts +2 -0
- package/src/sync/unknownBlock.ts +133 -23
- package/src/sync/utils/downloadByRoot.ts +7 -5
package/lib/sync/unknownBlock.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isBlockInputColumns } from "../chain/blocks/blockInput/blockInput.js";
|
|
|
7
7
|
import { BlockInputSource } from "../chain/blocks/blockInput/types.js";
|
|
8
8
|
import { PayloadError, PayloadErrorCode } from "../chain/blocks/importExecutionPayload.js";
|
|
9
9
|
import { PayloadEnvelopeInputSource } from "../chain/blocks/payloadEnvelopeInput/index.js";
|
|
10
|
-
import { BlockError, BlockErrorCode, ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, } from "../chain/errors/index.js";
|
|
10
|
+
import { BlockError, BlockErrorCode, DataColumnSidecarErrorCode, DataColumnSidecarValidationError, ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, } from "../chain/errors/index.js";
|
|
11
11
|
import { ChainEvent } from "../chain/index.js";
|
|
12
12
|
import { validateGloasBlockDataColumnSidecars } from "../chain/validation/dataColumnSidecar.js";
|
|
13
13
|
import { validateGossipExecutionPayloadEnvelope } from "../chain/validation/executionPayloadEnvelope.js";
|
|
@@ -1295,7 +1295,16 @@ export class BlockInputSync {
|
|
|
1295
1295
|
return;
|
|
1296
1296
|
}
|
|
1297
1297
|
if (validationResult.err) {
|
|
1298
|
-
|
|
1298
|
+
const err = validationResult.err;
|
|
1299
|
+
const { envelopePeerId } = pendingPayload;
|
|
1300
|
+
// Same penalties as for an envelope validated right after download in fetchPayloadInput
|
|
1301
|
+
if (envelopePeerId !== undefined &&
|
|
1302
|
+
err instanceof ExecutionPayloadEnvelopeError &&
|
|
1303
|
+
(pendingPayload.envelope.message.payload.slotNumber !== payloadInput.slot ||
|
|
1304
|
+
toRootHex(pendingPayload.envelope.message.payload.blockHash) !== payloadInput.getBlockHashHex())) {
|
|
1305
|
+
this.network.reportPeer(envelopePeerId, PeerAction.LowToleranceError, err.type.code);
|
|
1306
|
+
}
|
|
1307
|
+
this.logger.debug("Pending payload envelope failed validation after block import, refetching by root", { slot: pendingPayload.envelope.message.payload.slotNumber, root: rootHex }, err);
|
|
1299
1308
|
const pendingPayloadByRoot = {
|
|
1300
1309
|
status: PendingPayloadInputStatus.pending,
|
|
1301
1310
|
rootHex,
|
|
@@ -1303,6 +1312,10 @@ export class BlockInputSync {
|
|
|
1303
1312
|
timeAddedSec: pendingPayload.timeAddedSec,
|
|
1304
1313
|
peerIdStrings: new Set(pendingPayload.peerIdStrings),
|
|
1305
1314
|
};
|
|
1315
|
+
// Do not prefer the peer whose envelope just failed validation
|
|
1316
|
+
if (envelopePeerId !== undefined) {
|
|
1317
|
+
pendingPayloadByRoot.peerIdStrings.delete(envelopePeerId);
|
|
1318
|
+
}
|
|
1306
1319
|
this.pendingPayloads.set(rootHex, pendingPayloadByRoot);
|
|
1307
1320
|
if (this.network.getConnectedPeers().length > 0) {
|
|
1308
1321
|
await this.downloadPayload(pendingPayloadByRoot);
|
|
@@ -1477,6 +1490,8 @@ export class BlockInputSync {
|
|
|
1477
1490
|
? cacheItem.payloadInput
|
|
1478
1491
|
: await this.chain.seenPayloadEnvelopeInputCache.getOrReload(rootHex);
|
|
1479
1492
|
let envelope = payloadInput?.hasPayloadEnvelope() ? payloadInput.getPayloadEnvelope() : undefined;
|
|
1493
|
+
// An envelope downloaded in an earlier attempt is validated with the peer of a later one
|
|
1494
|
+
let envelopePeerId;
|
|
1480
1495
|
const fetchStartSec = Date.now() / 1000;
|
|
1481
1496
|
if (typeof slot === "number") {
|
|
1482
1497
|
this.metrics?.blockInputSync.payloadFetchBegin.observe(this.chain.clock.secFromSlot(slot, fetchStartSec));
|
|
@@ -1507,6 +1522,7 @@ export class BlockInputSync {
|
|
|
1507
1522
|
try {
|
|
1508
1523
|
if (!envelope) {
|
|
1509
1524
|
envelope = await this.fetchExecutionPayloadEnvelope(peerId, blockRoot, rootHex);
|
|
1525
|
+
envelopePeerId = peerId;
|
|
1510
1526
|
cacheItem.peerIdStrings.add(peerId);
|
|
1511
1527
|
const slotWasUnknown = typeof slot !== "number";
|
|
1512
1528
|
slot = envelope.message.payload.slotNumber;
|
|
@@ -1526,6 +1542,7 @@ export class BlockInputSync {
|
|
|
1526
1542
|
return {
|
|
1527
1543
|
status: PendingPayloadInputStatus.waitingForBlock,
|
|
1528
1544
|
envelope,
|
|
1545
|
+
envelopePeerId,
|
|
1529
1546
|
timeAddedSec: cacheItem.timeAddedSec,
|
|
1530
1547
|
peerIdStrings: cacheItem.peerIdStrings,
|
|
1531
1548
|
};
|
|
@@ -1601,24 +1618,37 @@ export class BlockInputSync {
|
|
|
1601
1618
|
else {
|
|
1602
1619
|
excludedPeers.add(peerId);
|
|
1603
1620
|
}
|
|
1621
|
+
// Honest peers serve the requested root and columns, and every path that stores payload columns verifies them
|
|
1622
|
+
if (e instanceof DownloadByRootError || e instanceof DataColumnSidecarValidationError) {
|
|
1623
|
+
this.network.reportPeer(peerId, PeerAction.LowToleranceError, e.type.code);
|
|
1624
|
+
}
|
|
1604
1625
|
if (e instanceof ExecutionPayloadEnvelopeError) {
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1626
|
+
// Range sync stores an envelope after checking only its root, slot and block hash, so an honest peer may
|
|
1627
|
+
// serve one that fails the other checks. Compared directly since validation stops at the first failure.
|
|
1628
|
+
if (envelope !== undefined &&
|
|
1629
|
+
payloadInput &&
|
|
1630
|
+
(envelope.message.payload.slotNumber !== payloadInput.slot ||
|
|
1631
|
+
toRootHex(envelope.message.payload.blockHash) !== payloadInput.getBlockHashHex())) {
|
|
1632
|
+
if (envelopePeerId !== undefined) {
|
|
1633
|
+
this.network.reportPeer(envelopePeerId, PeerAction.LowToleranceError, e.type.code);
|
|
1634
|
+
}
|
|
1635
|
+
envelope = payloadInput.hasPayloadEnvelope() ? payloadInput.getPayloadEnvelope() : undefined;
|
|
1636
|
+
}
|
|
1637
|
+
else {
|
|
1638
|
+
switch (e.type.code) {
|
|
1639
|
+
// Caused by local state, the downloaded envelope may still be valid
|
|
1640
|
+
case ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN:
|
|
1641
|
+
case ExecutionPayloadEnvelopeErrorCode.ENVELOPE_ALREADY_KNOWN:
|
|
1642
|
+
case ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING:
|
|
1643
|
+
case ExecutionPayloadEnvelopeErrorCode.UNKNOWN_BLOCK_STATE:
|
|
1644
|
+
// Every copy fails once the block is finalized
|
|
1645
|
+
case ExecutionPayloadEnvelopeErrorCode.BELONG_TO_FINALIZED_BLOCK:
|
|
1646
|
+
break;
|
|
1647
|
+
// The served copy is invalid, take the envelope from payloadInput or another peer on the next attempt
|
|
1648
|
+
default:
|
|
1615
1649
|
envelope = payloadInput?.hasPayloadEnvelope() ? payloadInput.getPayloadEnvelope() : undefined;
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
// The served copy is invalid, take the envelope from payloadInput or another peer on the next attempt
|
|
1619
|
-
default:
|
|
1620
|
-
envelope = payloadInput?.hasPayloadEnvelope() ? payloadInput.getPayloadEnvelope() : undefined;
|
|
1621
|
-
break;
|
|
1650
|
+
break;
|
|
1651
|
+
}
|
|
1622
1652
|
}
|
|
1623
1653
|
}
|
|
1624
1654
|
}
|
|
@@ -1642,7 +1672,12 @@ export class BlockInputSync {
|
|
|
1642
1672
|
}
|
|
1643
1673
|
const receivedRootHex = toRootHex(envelope.message.beaconBlockRoot);
|
|
1644
1674
|
if (receivedRootHex !== rootHex) {
|
|
1645
|
-
throw new
|
|
1675
|
+
throw new DownloadByRootError({
|
|
1676
|
+
code: DownloadByRootErrorCode.MISMATCH_BLOCK_ROOT,
|
|
1677
|
+
peer: prettyPrintPeerIdStr(peerIdStr),
|
|
1678
|
+
requestedBlockRoot: rootHex,
|
|
1679
|
+
receivedBlockRoot: receivedRootHex,
|
|
1680
|
+
});
|
|
1646
1681
|
}
|
|
1647
1682
|
return envelope;
|
|
1648
1683
|
}
|
|
@@ -1662,7 +1697,13 @@ export class BlockInputSync {
|
|
|
1662
1697
|
const requestedColumnsSet = new Set(requestedColumns);
|
|
1663
1698
|
const extraColumns = columnSidecars.filter((columnSidecar) => !requestedColumnsSet.has(columnSidecar.index));
|
|
1664
1699
|
if (extraColumns.length > 0) {
|
|
1665
|
-
throw new
|
|
1700
|
+
throw new DownloadByRootError({
|
|
1701
|
+
code: DownloadByRootErrorCode.EXTRA_SIDECAR_RECEIVED,
|
|
1702
|
+
peer: prettyPrintPeerIdStr(peerIdStr),
|
|
1703
|
+
slot: payloadInput.slot,
|
|
1704
|
+
blockRoot: payloadInput.blockRootHex,
|
|
1705
|
+
invalidIndices: prettyPrintIndices(extraColumns.map((column) => column.index)),
|
|
1706
|
+
});
|
|
1666
1707
|
}
|
|
1667
1708
|
// PayloadEnvelopeInput already carries the block slot, root, and commitments, so reuse the
|
|
1668
1709
|
// block-based Gloas validator rather than maintaining a second payload-specific variant.
|
|
@@ -1689,7 +1730,19 @@ export class BlockInputSync {
|
|
|
1689
1730
|
}
|
|
1690
1731
|
let i = 0;
|
|
1691
1732
|
let deferredByRateLimit = false;
|
|
1733
|
+
let requestedWhenReconstructable = false;
|
|
1692
1734
|
while (i++ < this.getMaxDownloadAttempts()) {
|
|
1735
|
+
const reconstructable = isPendingBlockInput(cacheItem) &&
|
|
1736
|
+
isBlockInputColumns(cacheItem.blockInput) &&
|
|
1737
|
+
cacheItem.blockInput.hasBlockAndAllData();
|
|
1738
|
+
// Reconstruction recovers whole rows however many columns are missing, so only one more request is worth it,
|
|
1739
|
+
// further peers could each hold the import until their response times out
|
|
1740
|
+
if (reconstructable) {
|
|
1741
|
+
if (requestedWhenReconstructable) {
|
|
1742
|
+
break;
|
|
1743
|
+
}
|
|
1744
|
+
requestedWhenReconstructable = true;
|
|
1745
|
+
}
|
|
1693
1746
|
const pendingColumns = isPendingBlockInput(cacheItem) && isBlockInputColumns(cacheItem.blockInput)
|
|
1694
1747
|
? new Set(cacheItem.blockInput.getMissingSampledColumnMeta().missing)
|
|
1695
1748
|
: defaultPendingColumns;
|
|
@@ -1698,6 +1751,9 @@ export class BlockInputSync {
|
|
|
1698
1751
|
// prefer peers that gossiped this block root to us (#9923)
|
|
1699
1752
|
const peerMeta = this.peerBalancer.bestPeerForPendingColumns(pendingColumns, excludedPeers, cacheItem.peerIdStrings, now);
|
|
1700
1753
|
if (peerMeta === null) {
|
|
1754
|
+
if (reconstructable) {
|
|
1755
|
+
break;
|
|
1756
|
+
}
|
|
1701
1757
|
const retryAt = this.peerBalancer.getNextRateLimitRetryAt(pendingColumns, excludedPeers, now);
|
|
1702
1758
|
if (retryAt !== null) {
|
|
1703
1759
|
throw new UnknownBlockRateLimitedError(`Error fetching UnknownBlockRoot slot=${slot} root=${rootHex} after ${i}: peers with needed columns are rate-limited`, retryAt);
|
|
@@ -1733,14 +1789,21 @@ export class BlockInputSync {
|
|
|
1733
1789
|
for (const warning of warnings) {
|
|
1734
1790
|
this.logger.debug("BlockInputSync.fetchBlockInput: downloaded with warning", logCtx, warning);
|
|
1735
1791
|
this.metrics?.blockInputSync.downloadByRoot.warn.inc({ code: warning.type.code, client: peerClient });
|
|
1792
|
+
// A partial response is legal, columns that were not requested are not
|
|
1793
|
+
if (warning.type.code === DownloadByRootErrorCode.EXTRA_SIDECAR_RECEIVED) {
|
|
1794
|
+
this.network.reportPeer(peerId, PeerAction.LowToleranceError, warning.type.code);
|
|
1795
|
+
excludedPeers.add(peerId);
|
|
1796
|
+
}
|
|
1797
|
+
// Not picked again for this block, it would be preferred as a previous source of it
|
|
1798
|
+
if (warning.type.code === DownloadByRootErrorCode.NOT_ENOUGH_SIDECARS_RECEIVED) {
|
|
1799
|
+
excludedPeers.add(peerId);
|
|
1800
|
+
}
|
|
1736
1801
|
}
|
|
1737
|
-
// TODO: penalize peer?
|
|
1738
1802
|
}
|
|
1739
1803
|
}
|
|
1740
1804
|
catch (e) {
|
|
1741
1805
|
this.logger.debug("Error downloading in BlockInputSync.fetchBlockInput", { slot, rootHex, attempt: i, peer: peerId, peerClient }, e);
|
|
1742
1806
|
const downloadByRootMetrics = this.metrics?.blockInputSync.downloadByRoot;
|
|
1743
|
-
// TODO: penalize peer?
|
|
1744
1807
|
if (e instanceof DownloadByRootError) {
|
|
1745
1808
|
const errorCode = e.type.code;
|
|
1746
1809
|
downloadByRootMetrics?.error.inc({ code: errorCode, client: peerClient });
|
|
@@ -1755,6 +1818,23 @@ export class BlockInputSync {
|
|
|
1755
1818
|
}
|
|
1756
1819
|
excludedPeers.add(peerId);
|
|
1757
1820
|
}
|
|
1821
|
+
else if (e instanceof DataColumnSidecarValidationError) {
|
|
1822
|
+
const errorCode = e.type.code;
|
|
1823
|
+
downloadByRootMetrics?.error.inc({ code: errorCode, client: peerClient });
|
|
1824
|
+
// Not PROPOSAL_SIGNATURE_INVALID or INCORRECT_HEADER_ROOT, which compares signatures too: the spec does not
|
|
1825
|
+
// require verifying the header signature of req/resp columns, so honest peers may serve a bad one
|
|
1826
|
+
switch (errorCode) {
|
|
1827
|
+
case DataColumnSidecarErrorCode.INCORRECT_BLOCK:
|
|
1828
|
+
case DataColumnSidecarErrorCode.INVALID_INDEX:
|
|
1829
|
+
case DataColumnSidecarErrorCode.INCORRECT_CELL_COUNT:
|
|
1830
|
+
case DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT:
|
|
1831
|
+
case DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT:
|
|
1832
|
+
case DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID:
|
|
1833
|
+
case DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
|
|
1834
|
+
this.network.reportPeer(peerId, PeerAction.LowToleranceError, errorCode);
|
|
1835
|
+
}
|
|
1836
|
+
excludedPeers.add(peerId);
|
|
1837
|
+
}
|
|
1758
1838
|
else if (e instanceof RequestError) {
|
|
1759
1839
|
// should look into req_resp metrics in this case
|
|
1760
1840
|
downloadByRootMetrics?.error.inc({ code: "req_resp", client: peerClient });
|
|
@@ -1805,6 +1885,27 @@ export class BlockInputSync {
|
|
|
1805
1885
|
}
|
|
1806
1886
|
} // end while loop over peers
|
|
1807
1887
|
const message = `Error fetching BlockInput with slot=${slot} root=${rootHex} after ${i - 1} attempts.`;
|
|
1888
|
+
if (isPendingBlockInput(cacheItem) &&
|
|
1889
|
+
isBlockInputColumns(cacheItem.blockInput) &&
|
|
1890
|
+
cacheItem.blockInput.hasBlockAndAllData()) {
|
|
1891
|
+
// Peers cannot serve the remaining columns now, half of them is enough to reconstruct the rest
|
|
1892
|
+
this.logger.verbose("BlockInputSync.fetchBlockInput: reconstructing columns peers could not serve", {
|
|
1893
|
+
slot,
|
|
1894
|
+
rootHex,
|
|
1895
|
+
missing: cacheItem.blockInput.getMissingSampledColumnMeta().missing.length,
|
|
1896
|
+
});
|
|
1897
|
+
this.chain.columnReconstructionTracker.triggerColumnReconstruction(cacheItem.blockInput);
|
|
1898
|
+
cacheItem = { ...cacheItem, status: PendingBlockInputStatus.downloaded, timeSyncedSec: Date.now() / 1000 };
|
|
1899
|
+
if (this.pendingBlocks.has(rootHex)) {
|
|
1900
|
+
this.pendingBlocks.set(rootHex, cacheItem);
|
|
1901
|
+
}
|
|
1902
|
+
const result = this.chain.forkChoice.hasBlockHex(cacheItem.blockInput.parentRootHex)
|
|
1903
|
+
? FetchResult.SuccessResolved
|
|
1904
|
+
: FetchResult.SuccessMissingParent;
|
|
1905
|
+
this.metrics?.blockInputSync.fetchTime.observe({ result }, Date.now() / 1000 - fetchStartSec);
|
|
1906
|
+
this.metrics?.blockInputSync.fetchPeers.set({ result }, i - 1);
|
|
1907
|
+
return cacheItem;
|
|
1908
|
+
}
|
|
1808
1909
|
const retryAt = deferredByRateLimit ? this.peerBalancer.getNextRateLimitRetryAt() : null;
|
|
1809
1910
|
if (retryAt !== null) {
|
|
1810
1911
|
throw new UnknownBlockRateLimitedError(`${message} Peers are rate-limited.`, retryAt);
|