@lodestar/beacon-node 1.34.1 → 1.35.0-dev.092cc3954a
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.js +71 -53
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +3 -3
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/debug/index.js +20 -9
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/errors.js +2 -0
- package/lib/api/impl/errors.js.map +1 -1
- package/lib/api/impl/index.d.ts +3 -3
- package/lib/api/impl/index.js +3 -3
- package/lib/api/impl/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.js +1 -1
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.js +2 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/rest/activeSockets.js +3 -2
- package/lib/api/rest/activeSockets.js.map +1 -1
- package/lib/api/rest/base.d.ts +1 -1
- package/lib/api/rest/base.js +6 -2
- package/lib/api/rest/base.js.map +1 -1
- package/lib/api/rest/index.js +2 -0
- package/lib/api/rest/index.js.map +1 -1
- package/lib/api/rest/swaggerUI.js +4 -2
- package/lib/api/rest/swaggerUI.js.map +1 -1
- package/lib/bun-wrappers/prometheus-gc-stats.d.ts +2 -0
- package/lib/bun-wrappers/prometheus-gc-stats.js +8 -0
- package/lib/bun-wrappers/prometheus-gc-stats.js.map +1 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts +32 -0
- package/lib/chain/ColumnReconstructionTracker.js +71 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -0
- package/lib/chain/GetBlobsTracker.d.ts +31 -0
- package/lib/chain/GetBlobsTracker.js +82 -0
- package/lib/chain/GetBlobsTracker.js.map +1 -0
- package/lib/chain/archiveStore/archiveStore.js +49 -38
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +2 -0
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/archiveStore/index.d.ts +1 -1
- package/lib/chain/archiveStore/index.js +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +5 -0
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +14 -7
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/balancesCache.js +1 -3
- package/lib/chain/balancesCache.js.map +1 -1
- package/lib/chain/beaconProposerCache.js +1 -0
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +19 -7
- package/lib/chain/blocks/blockInput/blockInput.js +132 -88
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/blockInput/index.d.ts +1 -1
- package/lib/chain/blocks/blockInput/index.js +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +19 -10
- package/lib/chain/blocks/blockInput/types.js +1 -0
- package/lib/chain/blocks/blockInput/types.js.map +1 -1
- package/lib/chain/blocks/blockInput/utils.d.ts +0 -4
- package/lib/chain/blocks/blockInput/utils.js +6 -29
- package/lib/chain/blocks/blockInput/utils.js.map +1 -1
- package/lib/chain/blocks/importBlock.js +36 -32
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/index.d.ts +6 -5
- package/lib/chain/blocks/index.js +5 -4
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +3 -108
- package/lib/chain/blocks/types.js +0 -119
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts +2 -2
- package/lib/chain/blocks/utils/chainSegment.js +2 -2
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +3 -3
- package/lib/chain/blocks/verifyBlock.js +15 -14
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +7 -22
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +18 -110
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -3
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +24 -22
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +4 -3
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +2 -2
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -2
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +2 -2
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.d.ts +3 -3
- package/lib/chain/blocks/writeBlockInputToDb.js +61 -63
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/bls/multithread/index.js +167 -163
- package/lib/chain/bls/multithread/index.js.map +1 -1
- package/lib/chain/bls/singleThread.js +1 -0
- package/lib/chain/bls/singleThread.js.map +1 -1
- package/lib/chain/chain.d.ts +13 -11
- package/lib/chain/chain.js +79 -20
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +43 -2
- package/lib/chain/emitter.js +18 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/blobSidecarError.d.ts +24 -0
- package/lib/chain/errors/blobSidecarError.js +10 -0
- package/lib/chain/errors/blobSidecarError.js.map +1 -1
- package/lib/chain/errors/blockError.js +1 -0
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +42 -0
- package/lib/chain/errors/dataColumnSidecarError.js +14 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/errors/gossipValidation.js +1 -0
- package/lib/chain/errors/gossipValidation.js.map +1 -1
- package/lib/chain/errors/index.d.ts +2 -2
- package/lib/chain/errors/index.js +2 -2
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/genesis/genesis.js +16 -5
- package/lib/chain/genesis/genesis.js.map +1 -1
- package/lib/chain/index.d.ts +2 -2
- package/lib/chain/index.js +2 -2
- package/lib/chain/index.js.map +1 -1
- package/lib/chain/interface.d.ts +13 -9
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/lightClient/index.js +16 -9
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/lightClient/proofs.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +14 -9
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/attestationPool.js +8 -3
- package/lib/chain/opPools/attestationPool.js.map +1 -1
- package/lib/chain/opPools/index.d.ts +1 -1
- package/lib/chain/opPools/index.js +1 -1
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/opPools/opPool.js +10 -12
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/syncCommitteeMessagePool.js +9 -6
- package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.js +5 -2
- package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
- package/lib/chain/options.js +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.js +141 -134
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +3 -10
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/errors.js +1 -0
- package/lib/chain/regen/errors.js.map +1 -1
- package/lib/chain/regen/index.d.ts +1 -1
- package/lib/chain/regen/index.js +1 -1
- package/lib/chain/regen/index.js.map +1 -1
- package/lib/chain/regen/queued.js +35 -28
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.js +1 -0
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/reprocess.js +3 -1
- package/lib/chain/reprocess.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -1
- package/lib/chain/seenCache/index.js +1 -1
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenAggregateAndProof.js +7 -6
- package/lib/chain/seenCache/seenAggregateAndProof.js.map +1 -1
- package/lib/chain/seenCache/seenAttestationData.js +5 -2
- package/lib/chain/seenCache/seenAttestationData.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +2 -4
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +2 -4
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/seenCache/seenCommittee.js +1 -3
- package/lib/chain/seenCache/seenCommittee.js.map +1 -1
- package/lib/chain/seenCache/seenCommitteeContribution.js +3 -2
- package/lib/chain/seenCache/seenCommitteeContribution.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +74 -78
- package/lib/chain/seenCache/seenGossipBlockInput.js +235 -369
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/shufflingCache.js +5 -2
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/stateCache/blockStateCacheImpl.js +13 -7
- package/lib/chain/stateCache/blockStateCacheImpl.js.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +1 -0
- package/lib/chain/stateCache/datastore/db.js.map +1 -1
- package/lib/chain/stateCache/datastore/file.js +1 -0
- package/lib/chain/stateCache/datastore/file.js.map +1 -1
- package/lib/chain/stateCache/datastore/index.d.ts +1 -1
- package/lib/chain/stateCache/datastore/index.js +1 -1
- package/lib/chain/stateCache/datastore/index.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +10 -0
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js +10 -4
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/index.d.ts +1 -1
- package/lib/chain/stateCache/index.js +1 -1
- package/lib/chain/stateCache/index.js.map +1 -1
- package/lib/chain/stateCache/mapMetrics.js +4 -4
- package/lib/chain/stateCache/mapMetrics.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +14 -6
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/validation/blobSidecar.d.ts +8 -3
- package/lib/chain/validation/blobSidecar.js +73 -31
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +7 -9
- package/lib/chain/validation/dataColumnSidecar.js +95 -57
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/index.d.ts +1 -1
- package/lib/chain/validation/index.js +1 -1
- package/lib/chain/validation/index.js.map +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +1 -2
- package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +1 -3
- package/lib/chain/validatorMonitor.js +2 -1
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/db/beacon.js +24 -0
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/index.d.ts +1 -1
- package/lib/db/index.js.map +1 -1
- package/lib/db/repositories/blobSidecars.js.map +1 -1
- package/lib/db/repositories/blockArchive.js +4 -5
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +4 -0
- package/lib/db/repositories/blockArchiveIndex.js +13 -5
- package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.js +8 -7
- package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.js +17 -7
- package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
- package/lib/db/repositories/depositDataRoot.js +1 -0
- package/lib/db/repositories/depositDataRoot.js.map +1 -1
- package/lib/db/repositories/index.d.ts +10 -10
- package/lib/db/repositories/index.js +9 -9
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/db/repositories/stateArchive.js +3 -2
- package/lib/db/repositories/stateArchive.js.map +1 -1
- package/lib/db/repositories/stateArchiveIndex.d.ts +1 -0
- package/lib/db/repositories/stateArchiveIndex.js +6 -2
- package/lib/db/repositories/stateArchiveIndex.js.map +1 -1
- package/lib/db/single/preGenesisState.d.ts +1 -0
- package/lib/db/single/preGenesisState.js +11 -4
- package/lib/db/single/preGenesisState.js.map +1 -1
- package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts +1 -0
- package/lib/db/single/preGenesisStateLastProcessedBlock.js +10 -4
- package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +1 -1
- package/lib/eth1/eth1DataCache.js +2 -0
- package/lib/eth1/eth1DataCache.js.map +1 -1
- package/lib/eth1/eth1DepositDataTracker.js +18 -5
- package/lib/eth1/eth1DepositDataTracker.js.map +1 -1
- package/lib/eth1/eth1DepositsCache.js +3 -0
- package/lib/eth1/eth1DepositsCache.js.map +1 -1
- package/lib/eth1/eth1MergeBlockTracker.js +10 -4
- package/lib/eth1/eth1MergeBlockTracker.js.map +1 -1
- package/lib/eth1/index.js +2 -0
- package/lib/eth1/index.js.map +1 -1
- package/lib/eth1/provider/eth1Provider.d.ts +1 -2
- package/lib/eth1/provider/eth1Provider.js +6 -2
- package/lib/eth1/provider/eth1Provider.js.map +1 -1
- package/lib/eth1/provider/jsonRpcHttpClient.d.ts +1 -1
- package/lib/eth1/provider/jsonRpcHttpClient.js +16 -2
- package/lib/eth1/provider/jsonRpcHttpClient.js.map +1 -1
- package/lib/eth1/provider/jwt.js.map +1 -1
- package/lib/eth1/provider/utils.d.ts +5 -0
- package/lib/eth1/provider/utils.js +9 -1
- package/lib/eth1/provider/utils.js.map +1 -1
- package/lib/eth1/utils/deposits.js.map +1 -1
- package/lib/execution/builder/cache.js +6 -0
- package/lib/execution/builder/cache.js.map +1 -1
- package/lib/execution/builder/http.js +14 -8
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/execution/builder/index.js.map +1 -1
- package/lib/execution/engine/disabled.js +2 -4
- package/lib/execution/engine/disabled.js.map +1 -1
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.js +43 -11
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +2 -2
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/mock.d.ts +1 -0
- package/lib/execution/engine/mock.js +16 -12
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +1 -3
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/types.d.ts +5 -1
- package/lib/execution/engine/types.js +37 -8
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/execution/engine/utils.js +3 -3
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/execution/index.d.ts +2 -2
- package/lib/execution/index.js +2 -2
- package/lib/execution/index.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/metrics/index.d.ts +1 -1
- package/lib/metrics/index.js +1 -1
- package/lib/metrics/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +11 -5
- package/lib/metrics/metrics/beacon.js +40 -20
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +55 -13
- package/lib/metrics/metrics/lodestar.js +85 -8
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/metrics/metrics.d.ts +1 -1
- package/lib/metrics/metrics.js.map +1 -1
- package/lib/metrics/nodeJsMetrics.js +1 -1
- package/lib/metrics/nodeJsMetrics.js.map +1 -1
- package/lib/metrics/server/http.d.ts +1 -1
- package/lib/metrics/utils/avgMinMax.d.ts +1 -1
- package/lib/metrics/utils/avgMinMax.js +10 -6
- package/lib/metrics/utils/avgMinMax.js.map +1 -1
- package/lib/metrics/utils/gauge.d.ts +1 -1
- package/lib/metrics/utils/gauge.js +1 -4
- package/lib/metrics/utils/gauge.js.map +1 -1
- package/lib/metrics/utils/registryMetricCreator.d.ts +1 -1
- package/lib/metrics/utils/registryMetricCreator.js.map +1 -1
- package/lib/monitoring/properties.js +4 -0
- package/lib/monitoring/properties.js.map +1 -1
- package/lib/monitoring/service.js +13 -1
- package/lib/monitoring/service.js.map +1 -1
- package/lib/monitoring/system.js +25 -27
- package/lib/monitoring/system.js.map +1 -1
- package/lib/network/core/networkCore.d.ts +2 -2
- package/lib/network/core/networkCore.js +67 -50
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +1 -1
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts +2 -2
- package/lib/network/core/networkCoreWorkerHandler.js +5 -2
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/discv5/index.d.ts +2 -2
- package/lib/network/discv5/index.js +5 -2
- package/lib/network/discv5/index.js.map +1 -1
- package/lib/network/discv5/worker.js +3 -3
- package/lib/network/discv5/worker.js.map +1 -1
- package/lib/network/events.d.ts +2 -18
- package/lib/network/events.js +0 -7
- package/lib/network/events.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts +1 -1
- package/lib/network/gossip/encoding.js +4 -2
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/errors.js +1 -0
- package/lib/network/gossip/errors.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +1 -1
- package/lib/network/gossip/gossipsub.js +8 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/index.d.ts +2 -2
- package/lib/network/gossip/index.js +2 -2
- package/lib/network/gossip/index.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +2 -2
- package/lib/network/gossip/topic.d.ts +125 -105
- package/lib/network/gossip/topic.js +2 -1
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/index.d.ts +3 -3
- package/lib/network/index.js +3 -3
- package/lib/network/index.js.map +1 -1
- package/lib/network/interface.d.ts +3 -2
- package/lib/network/libp2p/index.js +2 -2
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/metadata.js +4 -0
- package/lib/network/metadata.js.map +1 -1
- package/lib/network/network.d.ts +4 -2
- package/lib/network/network.js +89 -71
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.js +1 -1
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/datastore.js +8 -2
- package/lib/network/peers/datastore.js.map +1 -1
- package/lib/network/peers/discover.js +75 -66
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/peers/peerManager.js +154 -130
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/peersData.d.ts +1 -1
- package/lib/network/peers/peersData.js +1 -3
- package/lib/network/peers/peersData.js.map +1 -1
- package/lib/network/peers/score/index.d.ts +1 -1
- package/lib/network/peers/score/index.js +1 -1
- package/lib/network/peers/score/index.js.map +1 -1
- package/lib/network/peers/score/score.js +6 -0
- package/lib/network/peers/score/score.js.map +1 -1
- package/lib/network/peers/score/store.js +3 -0
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/peers/utils/subnetMap.js +2 -4
- package/lib/network/peers/utils/subnetMap.js.map +1 -1
- package/lib/network/processor/aggregatorTracker.js +1 -3
- package/lib/network/processor/aggregatorTracker.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +145 -165
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/indexed.js +11 -9
- package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
- package/lib/network/processor/gossipQueues/linear.js +9 -8
- package/lib/network/processor/gossipQueues/linear.js.map +1 -1
- package/lib/network/processor/index.d.ts +2 -1
- package/lib/network/processor/index.js +22 -8
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +11 -2
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +1 -2
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/index.d.ts +1 -3
- package/lib/network/reqresp/index.js +1 -3
- package/lib/network/reqresp/index.js.map +1 -1
- package/lib/network/reqresp/rateLimit.js +11 -5
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js +8 -4
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
- package/lib/network/statusCache.js +1 -0
- package/lib/network/statusCache.js.map +1 -1
- package/lib/network/subnets/attnetsService.js +73 -65
- package/lib/network/subnets/attnetsService.js.map +1 -1
- package/lib/network/subnets/interface.js +1 -1
- package/lib/network/subnets/interface.js.map +1 -1
- package/lib/network/subnets/syncnetsService.js +29 -22
- package/lib/network/subnets/syncnetsService.js.map +1 -1
- package/lib/network/subnets/util.js +1 -2
- package/lib/network/subnets/util.js.map +1 -1
- package/lib/node/nodejs.d.ts +1 -1
- package/lib/node/nodejs.js +15 -0
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.js +1 -2
- package/lib/node/notifier.js.map +1 -1
- package/lib/node/options.js.map +1 -1
- package/lib/node/utils/interop/state.js +1 -2
- package/lib/node/utils/interop/state.js.map +1 -1
- package/lib/sync/backfill/backfill.d.ts +1 -1
- package/lib/sync/backfill/backfill.js +58 -16
- package/lib/sync/backfill/backfill.js.map +1 -1
- package/lib/sync/constants.d.ts +2 -1
- package/lib/sync/constants.js +2 -1
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/interface.d.ts +1 -59
- package/lib/sync/interface.js +0 -20
- package/lib/sync/interface.js.map +1 -1
- package/lib/sync/options.d.ts +1 -1
- package/lib/sync/range/batch.d.ts +48 -32
- package/lib/sync/range/batch.js +201 -55
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +15 -10
- package/lib/sync/range/chain.js +141 -70
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts +3 -3
- package/lib/sync/range/range.js +86 -54
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/hashBlocks.d.ts +2 -2
- package/lib/sync/range/utils/hashBlocks.js +6 -4
- package/lib/sync/range/utils/hashBlocks.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +18 -13
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/sync.d.ts +1 -2
- package/lib/sync/sync.js +95 -87
- package/lib/sync/sync.js.map +1 -1
- package/lib/sync/types.d.ts +44 -0
- package/lib/sync/types.js +34 -0
- package/lib/sync/types.js.map +1 -0
- package/lib/sync/unknownBlock.d.ts +42 -28
- package/lib/sync/unknownBlock.js +404 -458
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +186 -0
- package/lib/sync/utils/downloadByRange.js +457 -0
- package/lib/sync/utils/downloadByRange.js.map +1 -0
- package/lib/sync/utils/downloadByRoot.d.ts +119 -0
- package/lib/sync/utils/downloadByRoot.js +319 -0
- package/lib/sync/utils/downloadByRoot.js.map +1 -0
- package/lib/sync/utils/pendingBlocksTree.d.ts +14 -6
- package/lib/sync/utils/pendingBlocksTree.js +24 -18
- package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
- package/lib/util/array.js +7 -3
- package/lib/util/array.js.map +1 -1
- package/lib/util/asyncIterableToEvents.js +6 -3
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/binarySearch.js +2 -0
- package/lib/util/binarySearch.js.map +1 -1
- package/lib/util/blobs.d.ts +2 -2
- package/lib/util/blobs.js +4 -4
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/bufferPool.js +7 -2
- package/lib/util/bufferPool.js.map +1 -1
- package/lib/util/clock.d.ts +1 -1
- package/lib/util/clock.js +23 -18
- package/lib/util/clock.js.map +1 -1
- package/lib/util/dataColumns.d.ts +13 -10
- package/lib/util/dataColumns.js +92 -134
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +20 -0
- package/lib/util/execution.js +148 -0
- package/lib/util/execution.js.map +1 -0
- package/lib/util/itTrigger.js +4 -4
- package/lib/util/itTrigger.js.map +1 -1
- package/lib/util/map.js +2 -0
- package/lib/util/map.js.map +1 -1
- package/lib/util/queue/index.d.ts +1 -1
- package/lib/util/queue/index.js +1 -1
- package/lib/util/queue/index.js.map +1 -1
- package/lib/util/queue/itemQueue.js +52 -49
- package/lib/util/queue/itemQueue.js.map +1 -1
- package/lib/util/serializedCache.js +1 -3
- package/lib/util/serializedCache.js.map +1 -1
- package/lib/util/set.js +2 -0
- package/lib/util/set.js.map +1 -1
- package/lib/util/sszBytes.d.ts +1 -0
- package/lib/util/sszBytes.js +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/timeSeries.js +3 -1
- package/lib/util/timeSeries.js.map +1 -1
- package/lib/util/types.d.ts +1 -1
- package/lib/util/types.js +2 -2
- package/lib/util/types.js.map +1 -1
- package/lib/util/wrapError.d.ts +7 -0
- package/package.json +22 -16
- package/lib/chain/seenCache/seenBlockInput.d.ts +0 -84
- package/lib/chain/seenCache/seenBlockInput.js +0 -225
- package/lib/chain/seenCache/seenBlockInput.js.map +0 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.d.ts +0 -28
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js +0 -328
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js.map +0 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.d.ts +0 -49
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js +0 -499
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js.map +0 -1
package/lib/sync/unknownBlock.js
CHANGED
|
@@ -1,21 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { sleep } from "@lodestar/utils";
|
|
4
|
-
import {
|
|
1
|
+
import { ForkSeq, INTERVALS_PER_SLOT } from "@lodestar/params";
|
|
2
|
+
import { RequestError, RequestErrorCode } from "@lodestar/reqresp";
|
|
3
|
+
import { prettyBytes, prettyPrintIndices, pruneSetToMax, sleep } from "@lodestar/utils";
|
|
4
|
+
import { isBlockInputBlobs, isBlockInputColumns } from "../chain/blocks/blockInput/blockInput.js";
|
|
5
|
+
import { BlockInputSource } from "../chain/blocks/blockInput/types.js";
|
|
5
6
|
import { BlockError, BlockErrorCode } from "../chain/errors/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { byteArrayEquals } from "../util/bytes.js";
|
|
7
|
+
import { ChainEvent } from "../chain/index.js";
|
|
8
|
+
import { NetworkEvent, prettyPrintPeerIdStr } from "../network/index.js";
|
|
9
9
|
import { shuffle } from "../util/shuffle.js";
|
|
10
10
|
import { sortBy } from "../util/sortBy.js";
|
|
11
11
|
import { wrapError } from "../util/wrapError.js";
|
|
12
12
|
import { MAX_CONCURRENT_REQUESTS } from "./constants.js";
|
|
13
|
-
import {
|
|
13
|
+
import { PendingBlockInputStatus, PendingBlockType, getBlockInputSyncCacheItemRootHex, getBlockInputSyncCacheItemSlot, isPendingBlockInput, } from "./types.js";
|
|
14
|
+
import { DownloadByRootError, downloadByRoot } from "./utils/downloadByRoot.js";
|
|
14
15
|
import { getAllDescendantBlocks, getDescendantBlocks, getUnknownAndAncestorBlocks } from "./utils/pendingBlocksTree.js";
|
|
15
16
|
const MAX_ATTEMPTS_PER_BLOCK = 5;
|
|
16
17
|
const MAX_KNOWN_BAD_BLOCKS = 500;
|
|
17
18
|
const MAX_PENDING_BLOCKS = 100;
|
|
18
|
-
|
|
19
|
+
var FetchResult;
|
|
20
|
+
(function (FetchResult) {
|
|
21
|
+
FetchResult["SuccessResolved"] = "success_resolved";
|
|
22
|
+
FetchResult["SuccessMissingParent"] = "success_missing_parent";
|
|
23
|
+
FetchResult["SuccessLate"] = "success_late";
|
|
24
|
+
FetchResult["FailureTriedAllPeers"] = "failure_tried_all_peers";
|
|
25
|
+
FetchResult["FailureMaxAttempts"] = "failure_max_attempts";
|
|
26
|
+
})(FetchResult || (FetchResult = {}));
|
|
27
|
+
/**
|
|
28
|
+
* BlockInputSync is a class that handles ReqResp to find blocks and data related to a specific blockRoot. The
|
|
29
|
+
* blockRoot may have been found via object gossip, or the API. Gossip objects that can trigger a search are block,
|
|
30
|
+
* blobs, columns, attestations, etc. In the case of blocks and data this is generally during the current slot but
|
|
31
|
+
* can also be for items that are received late but are not fully verified and thus not in fork-choice (old blocks on
|
|
32
|
+
* an unknown fork). It can also be triggered via an attestation (or sync committee message or any other item that
|
|
33
|
+
* gets gossiped) that references a blockRoot that is not in fork-choice. In rare (and realistically should not happen)
|
|
34
|
+
* situations it can get triggered via the API when the validator attempts to publish a block, attestation, aggregate
|
|
35
|
+
* and proof or a sync committee contribution that has unknown information included (parentRoot for instance).
|
|
36
|
+
*
|
|
37
|
+
* The goal of the class is to make sure that all information that is necessary for import into fork-choice is pulled
|
|
38
|
+
* from peers so that the block and data can be processed, and thus the object that triggered the search can be
|
|
39
|
+
* referenced and validated.
|
|
40
|
+
*
|
|
41
|
+
* The most common case for this search is a set of block/data that comes across gossip for the current slot, during
|
|
42
|
+
* normal chain operation, but not everything was received before the gossip cutoff window happens so it is necessary
|
|
43
|
+
* to pull remaining data via req/resp so that fork-choice can be updated prior to making an attestation for the
|
|
44
|
+
* current slot.
|
|
45
|
+
*
|
|
46
|
+
* Event sources for old UnknownBlock
|
|
47
|
+
*
|
|
48
|
+
* - publishBlock
|
|
49
|
+
* - gossipHandlers
|
|
50
|
+
* - searchUnknownSlotRoot
|
|
51
|
+
* = produceSyncCommitteeContribution
|
|
52
|
+
* = validateGossipFnRetryUnknownRoot
|
|
53
|
+
* * submitPoolAttestationsV2
|
|
54
|
+
* * publishAggregateAndProofsV2
|
|
55
|
+
* = onPendingGossipsubMessage
|
|
56
|
+
* * NetworkEvent.pendingGossipsubMessage
|
|
57
|
+
* - onGossipsubMessage
|
|
58
|
+
*/
|
|
59
|
+
export class BlockInputSync {
|
|
60
|
+
config;
|
|
61
|
+
network;
|
|
62
|
+
chain;
|
|
63
|
+
logger;
|
|
64
|
+
metrics;
|
|
65
|
+
opts;
|
|
66
|
+
/**
|
|
67
|
+
* block RootHex -> PendingBlock. To avoid finding same root at the same time
|
|
68
|
+
*/
|
|
69
|
+
pendingBlocks = new Map();
|
|
70
|
+
knownBadBlocks = new Set();
|
|
71
|
+
proposerBoostSecWindow;
|
|
72
|
+
maxPendingBlocks;
|
|
73
|
+
subscribedToNetworkEvents = false;
|
|
74
|
+
peerBalancer;
|
|
19
75
|
constructor(config, network, chain, logger, metrics, opts) {
|
|
20
76
|
this.config = config;
|
|
21
77
|
this.network = network;
|
|
@@ -23,306 +79,231 @@ export class UnknownBlockSync {
|
|
|
23
79
|
this.logger = logger;
|
|
24
80
|
this.metrics = metrics;
|
|
25
81
|
this.opts = opts;
|
|
26
|
-
/**
|
|
27
|
-
* block RootHex -> PendingBlock. To avoid finding same root at the same time
|
|
28
|
-
*/
|
|
29
|
-
this.pendingBlocks = new Map();
|
|
30
|
-
this.knownBadBlocks = new Set();
|
|
31
|
-
this.subscribedToNetworkEvents = false;
|
|
32
|
-
this.engineGetBlobsCache = new Map();
|
|
33
|
-
this.blockInputsRetryTrackerCache = new Set();
|
|
34
|
-
/**
|
|
35
|
-
* Process an unknownBlock event and register the block in `pendingBlocks` Map.
|
|
36
|
-
*/
|
|
37
|
-
this.onUnknownBlock = (data) => {
|
|
38
|
-
try {
|
|
39
|
-
const unknownBlockType = this.addUnknownBlock(data.rootHex, data.peer);
|
|
40
|
-
this.triggerUnknownBlockSearch();
|
|
41
|
-
this.metrics?.syncUnknownBlock.requests.inc({ type: unknownBlockType });
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
this.logger.debug("Error handling unknownBlock event", {}, e);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Process an unknownBlockInput event and register the block in `pendingBlocks` Map.
|
|
49
|
-
*/
|
|
50
|
-
this.onUnknownBlockInput = (data) => {
|
|
51
|
-
try {
|
|
52
|
-
const unknownBlockType = this.addUnknownBlock(data.blockInput, data.peer);
|
|
53
|
-
this.triggerUnknownBlockSearch();
|
|
54
|
-
this.metrics?.syncUnknownBlock.requests.inc({ type: unknownBlockType });
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
this.logger.debug("Error handling unknownBlockInput event", {}, e);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Process an unknownBlockParent event and register the block in `pendingBlocks` Map.
|
|
62
|
-
*/
|
|
63
|
-
this.onUnknownParent = (data) => {
|
|
64
|
-
try {
|
|
65
|
-
this.addUnknownParent(data.blockInput, data.peer);
|
|
66
|
-
this.triggerUnknownBlockSearch();
|
|
67
|
-
this.metrics?.syncUnknownBlock.requests.inc({ type: PendingBlockType.UNKNOWN_PARENT });
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
this.logger.debug("Error handling unknownBlockParent event", {}, e);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
this.onPeerConnected = (data) => {
|
|
74
|
-
try {
|
|
75
|
-
const peerId = data.peer;
|
|
76
|
-
const peerSyncMeta = this.network.getConnectedPeerSyncMeta(peerId);
|
|
77
|
-
this.peerBalancer.onPeerConnected(data.peer, peerSyncMeta);
|
|
78
|
-
this.triggerUnknownBlockSearch();
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
this.logger.debug("Error handling peerConnected event", {}, e);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
this.onPeerDisconnected = (data) => {
|
|
85
|
-
const peerId = data.peer;
|
|
86
|
-
this.peerBalancer.onPeerDisconnected(peerId);
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Gather tip parent blocks with unknown parent and do a search for all of them
|
|
90
|
-
*/
|
|
91
|
-
this.triggerUnknownBlockSearch = () => {
|
|
92
|
-
// Cheap early stop to prevent calling the network.getConnectedPeers()
|
|
93
|
-
if (this.pendingBlocks.size === 0) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// If the node loses all peers with pending unknown blocks, the sync will stall
|
|
97
|
-
const connectedPeers = this.network.getConnectedPeers();
|
|
98
|
-
if (connectedPeers.length === 0) {
|
|
99
|
-
this.logger.debug("No connected peers, skipping unknown block search.");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const { unknowns, ancestors } = getUnknownAndAncestorBlocks(this.pendingBlocks);
|
|
103
|
-
// it's rare when there is no unknown block
|
|
104
|
-
// see https://github.com/ChainSafe/lodestar/issues/5649#issuecomment-1594213550
|
|
105
|
-
if (unknowns.length === 0) {
|
|
106
|
-
let processedBlocks = 0;
|
|
107
|
-
for (const block of ancestors) {
|
|
108
|
-
// when this happens, it's likely the block and parent block are processed by head sync
|
|
109
|
-
if (this.chain.forkChoice.hasBlockHex(block.parentBlockRootHex)) {
|
|
110
|
-
processedBlocks++;
|
|
111
|
-
this.processBlock(block).catch((e) => {
|
|
112
|
-
this.logger.debug("Unexpected error - process old downloaded block", {}, e);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
this.logger.verbose("No unknown block, process ancestor downloaded blocks", {
|
|
117
|
-
pendingBlocks: this.pendingBlocks.size,
|
|
118
|
-
ancestorBlocks: ancestors.length,
|
|
119
|
-
processedBlocks,
|
|
120
|
-
});
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
// most of the time there is exactly 1 unknown block
|
|
124
|
-
for (const block of unknowns) {
|
|
125
|
-
this.downloadBlock(block).catch((e) => {
|
|
126
|
-
this.logger.debug("Unexpected error - downloadBlock", { root: block.blockRootHex }, e);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
82
|
this.maxPendingBlocks = opts?.maxPendingBlocks ?? MAX_PENDING_BLOCKS;
|
|
131
83
|
this.proposerBoostSecWindow = this.config.SECONDS_PER_SLOT / INTERVALS_PER_SLOT;
|
|
132
|
-
this.peerBalancer = new UnknownBlockPeerBalancer(
|
|
84
|
+
this.peerBalancer = new UnknownBlockPeerBalancer();
|
|
133
85
|
if (metrics) {
|
|
134
|
-
metrics.
|
|
135
|
-
|
|
136
|
-
metrics.syncUnknownBlock.knownBadBlocks.set(this.knownBadBlocks.size);
|
|
137
|
-
metrics.syncUnknownBlock.peerBalancer.peersMetaCount.set(this.peerBalancer.peersMeta.size);
|
|
138
|
-
metrics.syncUnknownBlock.peerBalancer.peersActiveRequestCount.set(this.peerBalancer.activeRequests.size);
|
|
139
|
-
metrics.syncUnknownBlock.peerBalancer.totalActiveRequests.set(this.peerBalancer.getTotalActiveRequests());
|
|
140
|
-
});
|
|
86
|
+
metrics.blockInputSync.pendingBlocks.addCollect(() => metrics.blockInputSync.pendingBlocks.set(this.pendingBlocks.size));
|
|
87
|
+
metrics.blockInputSync.knownBadBlocks.addCollect(() => metrics.blockInputSync.knownBadBlocks.set(this.knownBadBlocks.size));
|
|
141
88
|
}
|
|
142
89
|
}
|
|
143
90
|
subscribeToNetwork() {
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.logger.verbose("UnknownBlockSync enabled.");
|
|
148
|
-
this.network.events.on(NetworkEvent.unknownBlock, this.onUnknownBlock);
|
|
149
|
-
this.network.events.on(NetworkEvent.unknownBlockInput, this.onUnknownBlockInput);
|
|
150
|
-
this.network.events.on(NetworkEvent.unknownBlockParent, this.onUnknownParent);
|
|
151
|
-
this.network.events.on(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
152
|
-
this.network.events.on(NetworkEvent.peerDisconnected, this.onPeerDisconnected);
|
|
153
|
-
this.subscribedToNetworkEvents = true;
|
|
154
|
-
}
|
|
91
|
+
if (this.opts?.disableBlockInputSync) {
|
|
92
|
+
this.logger.verbose("BlockInputSync disabled by disableBlockInputSync option.");
|
|
93
|
+
return;
|
|
155
94
|
}
|
|
156
|
-
|
|
157
|
-
|
|
95
|
+
// cannot chain to the above if or the log will be incorrect
|
|
96
|
+
if (!this.subscribedToNetworkEvents) {
|
|
97
|
+
this.logger.verbose("BlockInputSync enabled.");
|
|
98
|
+
this.chain.emitter.on(ChainEvent.unknownBlockRoot, this.onUnknownBlockRoot);
|
|
99
|
+
this.chain.emitter.on(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
100
|
+
this.chain.emitter.on(ChainEvent.unknownParent, this.onUnknownParent);
|
|
101
|
+
this.network.events.on(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
102
|
+
this.network.events.on(NetworkEvent.peerDisconnected, this.onPeerDisconnected);
|
|
103
|
+
this.subscribedToNetworkEvents = true;
|
|
158
104
|
}
|
|
159
105
|
}
|
|
160
106
|
unsubscribeFromNetwork() {
|
|
161
|
-
this.logger.verbose("
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
164
|
-
this.
|
|
107
|
+
this.logger.verbose("BlockInputSync disabled.");
|
|
108
|
+
this.chain.emitter.off(ChainEvent.unknownBlockRoot, this.onUnknownBlockRoot);
|
|
109
|
+
this.chain.emitter.off(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
110
|
+
this.chain.emitter.off(ChainEvent.unknownParent, this.onUnknownParent);
|
|
165
111
|
this.network.events.off(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
166
112
|
this.network.events.off(NetworkEvent.peerDisconnected, this.onPeerDisconnected);
|
|
167
113
|
this.subscribedToNetworkEvents = false;
|
|
168
114
|
}
|
|
169
115
|
close() {
|
|
170
116
|
this.unsubscribeFromNetwork();
|
|
171
|
-
// add more in the future if needed
|
|
172
117
|
}
|
|
173
118
|
isSubscribedToNetwork() {
|
|
174
119
|
return this.subscribedToNetworkEvents;
|
|
175
120
|
}
|
|
176
121
|
/**
|
|
177
|
-
*
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
122
|
+
* Process an unknownBlock event and register the block in `pendingBlocks` Map.
|
|
123
|
+
*/
|
|
124
|
+
onUnknownBlockRoot = (data) => {
|
|
125
|
+
try {
|
|
126
|
+
const { root, slot } = data.rootSlot;
|
|
127
|
+
this.addByRootHex(root, slot, data.peer);
|
|
128
|
+
this.triggerUnknownBlockSearch();
|
|
129
|
+
this.metrics?.blockInputSync.requests.inc({ type: PendingBlockType.UNKNOWN_BLOCK_ROOT });
|
|
130
|
+
this.metrics?.blockInputSync.source.inc({ source: data.source });
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
this.logger.debug("Error handling unknownBlockRoot event", {}, e);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Process an unknownBlockInput event and register the block in `pendingBlocks` Map.
|
|
182
138
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
139
|
+
onIncompleteBlockInput = (data) => {
|
|
140
|
+
try {
|
|
141
|
+
this.addByBlockInput(data.blockInput, data.peer);
|
|
142
|
+
this.triggerUnknownBlockSearch();
|
|
143
|
+
this.metrics?.blockInputSync.requests.inc({ type: PendingBlockType.INCOMPLETE_BLOCK_INPUT });
|
|
144
|
+
this.metrics?.blockInputSync.source.inc({ source: data.source });
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
this.logger.debug("Error handling incompleteBlockInput event", {}, e);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Process an unknownBlockParent event and register the block in `pendingBlocks` Map.
|
|
152
|
+
*/
|
|
153
|
+
onUnknownParent = (data) => {
|
|
154
|
+
try {
|
|
155
|
+
// we don't know the slot of parent, hence make it undefined
|
|
156
|
+
this.addByRootHex(data.blockInput.parentRootHex, undefined, data.peer);
|
|
157
|
+
this.addByBlockInput(data.blockInput, data.peer);
|
|
158
|
+
this.triggerUnknownBlockSearch();
|
|
159
|
+
this.metrics?.blockInputSync.requests.inc({ type: PendingBlockType.UNKNOWN_PARENT });
|
|
160
|
+
this.metrics?.blockInputSync.source.inc({ source: data.source });
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
this.logger.debug("Error handling unknownParent event", {}, e);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
addByRootHex = (rootHex, slot, peerIdStr) => {
|
|
167
|
+
let pendingBlock = this.pendingBlocks.get(rootHex);
|
|
190
168
|
if (!pendingBlock) {
|
|
191
|
-
pendingBlock =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
: {
|
|
204
|
-
blockRootHex,
|
|
205
|
-
parentBlockRootHex,
|
|
206
|
-
blockInput,
|
|
207
|
-
peerIdStrs: new Set(),
|
|
208
|
-
status: PendingBlockStatus.downloaded,
|
|
209
|
-
downloadAttempts: 0,
|
|
210
|
-
};
|
|
211
|
-
this.pendingBlocks.set(blockRootHex, pendingBlock);
|
|
212
|
-
this.logger.verbose("Added unknown block parent to pendingBlocks", {
|
|
213
|
-
root: blockRootHex,
|
|
214
|
-
parent: parentBlockRootHex,
|
|
169
|
+
pendingBlock = {
|
|
170
|
+
status: PendingBlockInputStatus.pending,
|
|
171
|
+
slot,
|
|
172
|
+
rootHex: rootHex,
|
|
173
|
+
peerIdStrings: new Set(),
|
|
174
|
+
timeAddedSec: Date.now() / 1000,
|
|
175
|
+
};
|
|
176
|
+
this.pendingBlocks.set(rootHex, pendingBlock);
|
|
177
|
+
this.logger.verbose("Added new rootHex to BlockInputSync.pendingBlocks", {
|
|
178
|
+
rootHex: prettyBytes(pendingBlock.rootHex),
|
|
179
|
+
peerIdStr: peerIdStr ?? "unknown peer",
|
|
215
180
|
});
|
|
216
181
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
this.addUnknownBlock(parentBlockRootHex, peerIdStr);
|
|
220
|
-
}
|
|
221
|
-
addUnknownBlock(blockInputOrRootHex, peerIdStr) {
|
|
222
|
-
let blockRootHex;
|
|
223
|
-
let blockInput;
|
|
224
|
-
let unknownBlockType;
|
|
225
|
-
if (typeof blockInputOrRootHex === "string") {
|
|
226
|
-
blockRootHex = blockInputOrRootHex;
|
|
227
|
-
blockInput = null;
|
|
228
|
-
unknownBlockType = PendingBlockType.UNKNOWN_BLOCK;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
if (blockInputOrRootHex.block !== null) {
|
|
232
|
-
const { block } = blockInputOrRootHex;
|
|
233
|
-
blockRootHex = toRootHex(this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message));
|
|
234
|
-
unknownBlockType = PendingBlockType.UNKNOWN_DATA;
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
unknownBlockType = PendingBlockType.UNKNOWN_BLOCKINPUT;
|
|
238
|
-
blockRootHex = blockInputOrRootHex.blockRootHex;
|
|
239
|
-
}
|
|
240
|
-
blockInput = blockInputOrRootHex;
|
|
182
|
+
if (peerIdStr) {
|
|
183
|
+
pendingBlock.peerIdStrings.add(peerIdStr);
|
|
241
184
|
}
|
|
242
|
-
|
|
243
|
-
|
|
185
|
+
// TODO: check this prune methodology
|
|
186
|
+
// Limit pending blocks to prevent DOS attacks that cause OOM
|
|
187
|
+
const prunedItemCount = pruneSetToMax(this.pendingBlocks, this.maxPendingBlocks);
|
|
188
|
+
if (prunedItemCount > 0) {
|
|
189
|
+
this.logger.verbose(`Pruned ${prunedItemCount} items from BlockInputSync.pendingBlocks`);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
addByBlockInput = (blockInput, peerIdStr) => {
|
|
193
|
+
let pendingBlock = this.pendingBlocks.get(blockInput.blockRootHex);
|
|
194
|
+
// if entry is missing or was added via rootHex and now we have more complete information overwrite
|
|
195
|
+
// the existing information with the more complete cache entry
|
|
196
|
+
if (!pendingBlock || !isPendingBlockInput(pendingBlock)) {
|
|
244
197
|
pendingBlock = {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
parentBlockRootHex: null,
|
|
198
|
+
// can be added via unknown parent and we may already have full block input. need to check and set correctly
|
|
199
|
+
// so we pull the data if its missing or handle the block correctly in getIncompleteAndAncestorBlocks
|
|
200
|
+
status: blockInput.hasBlockAndAllData() ? PendingBlockInputStatus.downloaded : PendingBlockInputStatus.pending,
|
|
249
201
|
blockInput,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
downloadAttempts: 0,
|
|
202
|
+
peerIdStrings: new Set(),
|
|
203
|
+
timeAddedSec: Date.now() / 1000,
|
|
253
204
|
};
|
|
254
|
-
this.pendingBlocks.set(blockRootHex, pendingBlock);
|
|
255
|
-
this.logger.verbose("Added
|
|
256
|
-
unknownBlockType,
|
|
257
|
-
root: blockRootHex,
|
|
258
|
-
slot: blockInput?.block?.message.slot ?? "unknown",
|
|
259
|
-
});
|
|
205
|
+
this.pendingBlocks.set(blockInput.blockRootHex, pendingBlock);
|
|
206
|
+
this.logger.verbose("Added blockInput to BlockInputSync.pendingBlocks", pendingBlock.blockInput.getLogMeta());
|
|
260
207
|
}
|
|
261
208
|
if (peerIdStr) {
|
|
262
|
-
pendingBlock.
|
|
209
|
+
pendingBlock.peerIdStrings.add(peerIdStr);
|
|
263
210
|
}
|
|
211
|
+
// TODO: check this prune methodology
|
|
264
212
|
// Limit pending blocks to prevent DOS attacks that cause OOM
|
|
265
213
|
const prunedItemCount = pruneSetToMax(this.pendingBlocks, this.maxPendingBlocks);
|
|
266
214
|
if (prunedItemCount > 0) {
|
|
267
|
-
this.logger.
|
|
215
|
+
this.logger.verbose(`Pruned ${prunedItemCount} items from BlockInputSync.pendingBlocks`);
|
|
268
216
|
}
|
|
269
|
-
|
|
270
|
-
|
|
217
|
+
};
|
|
218
|
+
onPeerConnected = (data) => {
|
|
219
|
+
try {
|
|
220
|
+
const peerId = data.peer;
|
|
221
|
+
const peerSyncMeta = this.network.getConnectedPeerSyncMeta(peerId);
|
|
222
|
+
this.peerBalancer.onPeerConnected(data.peer, peerSyncMeta);
|
|
223
|
+
this.triggerUnknownBlockSearch();
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
this.logger.debug("Error handling peerConnected event", {}, e);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
onPeerDisconnected = (data) => {
|
|
230
|
+
const peerId = data.peer;
|
|
231
|
+
this.peerBalancer.onPeerDisconnected(peerId);
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Gather tip parent blocks with unknown parent and do a search for all of them
|
|
235
|
+
*/
|
|
236
|
+
triggerUnknownBlockSearch = () => {
|
|
237
|
+
// Cheap early stop to prevent calling the network.getConnectedPeers()
|
|
238
|
+
if (this.pendingBlocks.size === 0) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// If the node loses all peers with pending unknown blocks, the sync will stall
|
|
242
|
+
const connectedPeers = this.network.getConnectedPeers();
|
|
243
|
+
if (connectedPeers.length === 0) {
|
|
244
|
+
this.logger.debug("No connected peers, skipping unknown block search.");
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const { unknowns, ancestors } = getUnknownAndAncestorBlocks(this.pendingBlocks);
|
|
248
|
+
// it's rare when there is no unknown block
|
|
249
|
+
// see https://github.com/ChainSafe/lodestar/issues/5649#issuecomment-1594213550
|
|
250
|
+
if (unknowns.length === 0) {
|
|
251
|
+
let processedBlocks = 0;
|
|
252
|
+
for (const block of ancestors) {
|
|
253
|
+
// when this happens, it's likely the block and parent block are processed by head sync
|
|
254
|
+
if (this.chain.forkChoice.hasBlockHex(block.blockInput.parentRootHex)) {
|
|
255
|
+
processedBlocks++;
|
|
256
|
+
this.processBlock(block).catch((e) => {
|
|
257
|
+
this.logger.debug("Unexpected error - process old downloaded block", {}, e);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
this.logger.verbose("No unknown block, process ancestor downloaded blocks", {
|
|
262
|
+
pendingBlocks: this.pendingBlocks.size,
|
|
263
|
+
ancestorBlocks: ancestors.length,
|
|
264
|
+
processedBlocks,
|
|
265
|
+
});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
// most of the time there is exactly 1 unknown block
|
|
269
|
+
for (const block of unknowns) {
|
|
270
|
+
this.downloadBlock(block).catch((e) => {
|
|
271
|
+
this.logger.debug("Unexpected error - downloadBlock", { root: getBlockInputSyncCacheItemRootHex(block) }, e);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
271
275
|
async downloadBlock(block) {
|
|
272
|
-
if (block.status !==
|
|
276
|
+
if (block.status !== PendingBlockInputStatus.pending) {
|
|
273
277
|
return;
|
|
274
278
|
}
|
|
275
|
-
const
|
|
279
|
+
const rootHex = getBlockInputSyncCacheItemRootHex(block);
|
|
276
280
|
const logCtx = {
|
|
277
|
-
|
|
281
|
+
slot: getBlockInputSyncCacheItemSlot(block),
|
|
282
|
+
blockRoot: prettyBytes(rootHex),
|
|
278
283
|
pendingBlocks: this.pendingBlocks.size,
|
|
279
|
-
slot: block.blockInput?.block?.message.slot ?? "unknown",
|
|
280
|
-
unknownBlockType,
|
|
281
284
|
};
|
|
282
|
-
this.logger.verbose("
|
|
283
|
-
block.status =
|
|
284
|
-
|
|
285
|
-
if (block.blockInput === null) {
|
|
286
|
-
// we only have block root, and nothing else
|
|
287
|
-
res = await wrapError(this.fetchUnknownBlockRoot(fromHex(block.blockRootHex)));
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
res = await wrapError(this.fetchUnavailableBlockInput(block.blockInput));
|
|
291
|
-
}
|
|
292
|
-
if (res.err)
|
|
293
|
-
this.metrics?.syncUnknownBlock.downloadedBlocksError.inc();
|
|
294
|
-
else
|
|
295
|
-
this.metrics?.syncUnknownBlock.downloadedBlocksSuccess.inc();
|
|
285
|
+
this.logger.verbose("BlockInputSync.downloadBlock()", logCtx);
|
|
286
|
+
block.status = PendingBlockInputStatus.fetching;
|
|
287
|
+
const res = await wrapError(this.fetchBlockInput(block));
|
|
296
288
|
if (!res.err) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
throw Error(`Expected BlockInput to be available, got dataPromise for ${block.blockRootHex}`);
|
|
302
|
-
}
|
|
303
|
-
block = {
|
|
304
|
-
...block,
|
|
305
|
-
status: PendingBlockStatus.downloaded,
|
|
306
|
-
blockInput,
|
|
307
|
-
parentBlockRootHex: toRootHex(blockInput.block.message.parentRoot),
|
|
308
|
-
};
|
|
309
|
-
this.pendingBlocks.set(block.blockRootHex, block);
|
|
310
|
-
const blockSlot = blockInput.block.message.slot;
|
|
289
|
+
this.metrics?.blockInputSync.downloadedBlocksSuccess.inc();
|
|
290
|
+
const pending = res.result;
|
|
291
|
+
this.pendingBlocks.set(pending.blockInput.blockRootHex, pending);
|
|
292
|
+
const blockSlot = pending.blockInput.slot;
|
|
311
293
|
const finalizedSlot = this.chain.forkChoice.getFinalizedBlock().slot;
|
|
312
294
|
const delaySec = Date.now() / 1000 - (this.chain.genesisTime + blockSlot * this.config.SECONDS_PER_SLOT);
|
|
313
|
-
this.metrics?.
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (parentInForkchoice) {
|
|
295
|
+
this.metrics?.blockInputSync.elapsedTimeTillReceived.observe(delaySec);
|
|
296
|
+
const parentInForkChoice = this.chain.forkChoice.hasBlockHex(pending.blockInput.parentRootHex);
|
|
297
|
+
const logCtx2 = {
|
|
298
|
+
...logCtx,
|
|
299
|
+
slot: blockSlot,
|
|
300
|
+
parentInForkChoice,
|
|
301
|
+
};
|
|
302
|
+
this.logger.verbose("Downloaded unknown block", logCtx2);
|
|
303
|
+
if (parentInForkChoice) {
|
|
323
304
|
// Bingo! Process block. Add to pending blocks anyway for recycle the cache that prevents duplicate processing
|
|
324
|
-
this.processBlock(
|
|
325
|
-
this.logger.debug("Unexpected error - process newly downloaded block",
|
|
305
|
+
this.processBlock(pending).catch((e) => {
|
|
306
|
+
this.logger.debug("Unexpected error - process newly downloaded block", logCtx2, e);
|
|
326
307
|
});
|
|
327
308
|
}
|
|
328
309
|
else if (blockSlot <= finalizedSlot) {
|
|
@@ -331,34 +312,20 @@ export class UnknownBlockSync {
|
|
|
331
312
|
// 0 - 1 - ... - n - finalizedSlot
|
|
332
313
|
// \
|
|
333
314
|
// parent 1 - parent 2 - ... - unknownParent block
|
|
334
|
-
const blockRoot = this.config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(blockInput.block.message);
|
|
335
315
|
this.logger.debug("Downloaded block is before finalized slot", {
|
|
316
|
+
...logCtx2,
|
|
336
317
|
finalizedSlot,
|
|
337
|
-
blockSlot,
|
|
338
|
-
parentRoot: toRootHex(blockRoot),
|
|
339
|
-
unknownBlockType,
|
|
340
318
|
});
|
|
341
|
-
this.
|
|
319
|
+
this.removeAndDownScoreAllDescendants(block);
|
|
342
320
|
}
|
|
343
321
|
else {
|
|
344
|
-
this.
|
|
322
|
+
this.onUnknownBlockRoot({ rootSlot: { root: pending.blockInput.parentRootHex }, source: BlockInputSource.byRoot });
|
|
345
323
|
}
|
|
346
324
|
}
|
|
347
325
|
else {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
block.downloadAttempts++;
|
|
352
|
-
const errorData = { root: block.blockRootHex, attempts: block.downloadAttempts, unknownBlockType };
|
|
353
|
-
if (block.downloadAttempts > MAX_ATTEMPTS_PER_BLOCK) {
|
|
354
|
-
// Give up on this block and assume it does not exist, penalizing all peers as if it was a bad block
|
|
355
|
-
this.logger.debug("Ignoring unknown block root after many failed downloads", errorData, res.err);
|
|
356
|
-
this.removeAndDownscoreAllDescendants(block);
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
// Try again when a new peer connects, its status changes, or a new unknownBlockParent event happens
|
|
360
|
-
this.logger.debug("Error downloading unknown block root", errorData, res.err);
|
|
361
|
-
}
|
|
326
|
+
this.metrics?.blockInputSync.downloadedBlocksError.inc();
|
|
327
|
+
this.logger.debug("Ignoring unknown block root after many failed downloads", logCtx, res.err);
|
|
328
|
+
this.removeAndDownScoreAllDescendants(block);
|
|
362
329
|
}
|
|
363
330
|
}
|
|
364
331
|
/**
|
|
@@ -369,11 +336,14 @@ export class UnknownBlockSync {
|
|
|
369
336
|
async processBlock(pendingBlock) {
|
|
370
337
|
// pending block status is `downloaded` right after `downloadBlock`
|
|
371
338
|
// but could be `pending` if added by `onUnknownBlockParent` event and this function is called recursively
|
|
372
|
-
if (pendingBlock.status !==
|
|
373
|
-
if (pendingBlock.status ===
|
|
339
|
+
if (pendingBlock.status !== PendingBlockInputStatus.downloaded) {
|
|
340
|
+
if (pendingBlock.status === PendingBlockInputStatus.pending) {
|
|
374
341
|
const connectedPeers = this.network.getConnectedPeers();
|
|
375
342
|
if (connectedPeers.length === 0) {
|
|
376
|
-
this.logger.debug("No connected peers, skipping download block", {
|
|
343
|
+
this.logger.debug("No connected peers, skipping download block", {
|
|
344
|
+
slot: pendingBlock.blockInput.slot,
|
|
345
|
+
blockRoot: pendingBlock.blockInput.blockRootHex,
|
|
346
|
+
});
|
|
377
347
|
return;
|
|
378
348
|
}
|
|
379
349
|
// if the download is a success we'll call `processBlock()` for this block
|
|
@@ -381,20 +351,17 @@ export class UnknownBlockSync {
|
|
|
381
351
|
}
|
|
382
352
|
return;
|
|
383
353
|
}
|
|
384
|
-
pendingBlock.status =
|
|
354
|
+
pendingBlock.status = PendingBlockInputStatus.processing;
|
|
385
355
|
// this prevents unbundling attack
|
|
386
356
|
// see https://lighthouse-blog.sigmaprime.io/mev-unbundling-rpc.html
|
|
387
|
-
const { slot: blockSlot, proposerIndex } = pendingBlock.blockInput.
|
|
357
|
+
const { slot: blockSlot, proposerIndex } = pendingBlock.blockInput.getBlock().message;
|
|
388
358
|
if (this.chain.clock.secFromSlot(blockSlot) < this.proposerBoostSecWindow &&
|
|
389
359
|
this.chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
390
360
|
// proposer is known by a gossip block already, wait a bit to make sure this block is not
|
|
391
361
|
// eligible for proposer boost to prevent unbundling attack
|
|
392
|
-
const blockRoot = this.config
|
|
393
|
-
.getForkTypes(blockSlot)
|
|
394
|
-
.BeaconBlock.hashTreeRoot(pendingBlock.blockInput.block.message);
|
|
395
362
|
this.logger.verbose("Avoid proposer boost for this block of known proposer", {
|
|
396
|
-
blockSlot,
|
|
397
|
-
blockRoot:
|
|
363
|
+
slot: blockSlot,
|
|
364
|
+
blockRoot: prettyBytes(pendingBlock.blockInput.blockRootHex),
|
|
398
365
|
proposerIndex,
|
|
399
366
|
});
|
|
400
367
|
await sleep(this.proposerBoostSecWindow * 1000);
|
|
@@ -415,21 +382,24 @@ export class UnknownBlockSync {
|
|
|
415
382
|
eagerPersistBlock: true,
|
|
416
383
|
}));
|
|
417
384
|
if (res.err)
|
|
418
|
-
this.metrics?.
|
|
385
|
+
this.metrics?.blockInputSync.processedBlocksError.inc();
|
|
419
386
|
else
|
|
420
|
-
this.metrics?.
|
|
387
|
+
this.metrics?.blockInputSync.processedBlocksSuccess.inc();
|
|
421
388
|
if (!res.err) {
|
|
422
389
|
// no need to update status to "processed", delete anyway
|
|
423
|
-
this.pendingBlocks.delete(pendingBlock.blockRootHex);
|
|
390
|
+
this.pendingBlocks.delete(pendingBlock.blockInput.blockRootHex);
|
|
391
|
+
this.chain.seenBlockInputCache.prune(pendingBlock.blockInput.blockRootHex);
|
|
424
392
|
// Send child blocks to the processor
|
|
425
|
-
for (const descendantBlock of getDescendantBlocks(pendingBlock.blockRootHex, this.pendingBlocks)) {
|
|
426
|
-
|
|
427
|
-
this.
|
|
428
|
-
|
|
393
|
+
for (const descendantBlock of getDescendantBlocks(pendingBlock.blockInput.blockRootHex, this.pendingBlocks)) {
|
|
394
|
+
if (isPendingBlockInput(descendantBlock)) {
|
|
395
|
+
this.processBlock(descendantBlock).catch((e) => {
|
|
396
|
+
this.logger.debug("Unexpected error - process descendant block", {}, e);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
429
399
|
}
|
|
430
400
|
}
|
|
431
401
|
else {
|
|
432
|
-
const errorData = {
|
|
402
|
+
const errorData = { slot: pendingBlock.blockInput.slot, root: pendingBlock.blockInput.blockRootHex };
|
|
433
403
|
if (res.err instanceof BlockError) {
|
|
434
404
|
switch (res.err.type.code) {
|
|
435
405
|
// This cases are already handled with `{ignoreIfKnown: true}`
|
|
@@ -439,7 +409,7 @@ export class UnknownBlockSync {
|
|
|
439
409
|
case BlockErrorCode.PRESTATE_MISSING:
|
|
440
410
|
// Should not happen, mark as downloaded to try again latter
|
|
441
411
|
this.logger.debug("Attempted to process block but its parent was still unknown", errorData, res.err);
|
|
442
|
-
pendingBlock.status =
|
|
412
|
+
pendingBlock.status = PendingBlockInputStatus.downloaded;
|
|
443
413
|
break;
|
|
444
414
|
case BlockErrorCode.EXECUTION_ENGINE_ERROR:
|
|
445
415
|
// Removing the block(s) without penalizing the peers, hoping for EL to
|
|
@@ -449,13 +419,13 @@ export class UnknownBlockSync {
|
|
|
449
419
|
default:
|
|
450
420
|
// Block is not correct with respect to our chain. Log error loudly
|
|
451
421
|
this.logger.debug("Error processing block from unknown parent sync", errorData, res.err);
|
|
452
|
-
this.
|
|
422
|
+
this.removeAndDownScoreAllDescendants(pendingBlock);
|
|
453
423
|
}
|
|
454
424
|
}
|
|
455
425
|
// Probably a queue error or something unwanted happened, mark as pending to try again latter
|
|
456
426
|
else {
|
|
457
427
|
this.logger.debug("Unknown error processing block from unknown block sync", errorData, res.err);
|
|
458
|
-
pendingBlock.status =
|
|
428
|
+
pendingBlock.status = PendingBlockInputStatus.downloaded;
|
|
459
429
|
}
|
|
460
430
|
}
|
|
461
431
|
}
|
|
@@ -468,144 +438,128 @@ export class UnknownBlockSync {
|
|
|
468
438
|
* prefulu, will attempt a max of `MAX_ATTEMPTS_PER_BLOCK` on different peers, postfulu we may attempt more as defined in `getMaxDownloadAttempts()` function
|
|
469
439
|
* Also verifies the received block root + returns the peer that provided the block for future downscoring.
|
|
470
440
|
*/
|
|
471
|
-
async
|
|
472
|
-
const
|
|
441
|
+
async fetchBlockInput(cacheItem) {
|
|
442
|
+
const rootHex = getBlockInputSyncCacheItemRootHex(cacheItem);
|
|
473
443
|
const excludedPeers = new Set();
|
|
474
|
-
let partialDownload = null;
|
|
475
444
|
const defaultPendingColumns = this.config.getForkSeq(this.chain.clock.currentSlot) >= ForkSeq.fulu
|
|
476
|
-
? new Set(this.network.custodyConfig.
|
|
445
|
+
? new Set(this.network.custodyConfig.sampledColumns)
|
|
477
446
|
: null;
|
|
478
|
-
|
|
447
|
+
const fetchStartSec = Date.now() / 1000;
|
|
448
|
+
let slot = isPendingBlockInput(cacheItem) ? cacheItem.blockInput.slot : cacheItem.slot;
|
|
449
|
+
if (slot !== undefined) {
|
|
450
|
+
this.metrics?.blockInputSync.fetchBegin.observe(this.chain.clock.secFromSlot(slot, fetchStartSec));
|
|
451
|
+
}
|
|
479
452
|
let i = 0;
|
|
480
453
|
while (i++ < this.getMaxDownloadAttempts()) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
454
|
+
const pendingColumns = isPendingBlockInput(cacheItem) && isBlockInputColumns(cacheItem.blockInput)
|
|
455
|
+
? new Set(cacheItem.blockInput.getMissingSampledColumnMeta().missing)
|
|
456
|
+
: defaultPendingColumns;
|
|
457
|
+
// pendingDataColumns is null pre-fulu
|
|
458
|
+
const peerMeta = this.peerBalancer.bestPeerForPendingColumns(pendingColumns, excludedPeers);
|
|
459
|
+
if (peerMeta === null) {
|
|
484
460
|
// no more peer with needed columns to try, throw error
|
|
485
|
-
|
|
461
|
+
let message = `Error fetching UnknownBlockRoot slot=${slot} blockRoot=${prettyBytes(rootHex)} after ${i}: cannot find peer`;
|
|
462
|
+
if (pendingColumns) {
|
|
463
|
+
message += ` with needed columns=${prettyPrintIndices(Array.from(pendingColumns))}`;
|
|
464
|
+
}
|
|
465
|
+
this.metrics?.blockInputSync.fetchTimeSec.observe({ result: FetchResult.FailureTriedAllPeers }, Date.now() / 1000 - fetchStartSec);
|
|
466
|
+
this.metrics?.blockInputSync.fetchPeers.set({ result: FetchResult.FailureTriedAllPeers }, i);
|
|
467
|
+
throw Error(message);
|
|
486
468
|
}
|
|
487
|
-
const { peerId, client: peerClient } =
|
|
488
|
-
|
|
469
|
+
const { peerId, client: peerClient } = peerMeta;
|
|
470
|
+
cacheItem.peerIdStrings.add(peerId);
|
|
489
471
|
try {
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
472
|
+
const downloadResult = await downloadByRoot({
|
|
473
|
+
config: this.config,
|
|
474
|
+
network: this.network,
|
|
475
|
+
seenCache: this.chain.seenBlockInputCache,
|
|
476
|
+
peerMeta,
|
|
477
|
+
cacheItem,
|
|
478
|
+
});
|
|
479
|
+
cacheItem = downloadResult.result;
|
|
480
|
+
if (slot === undefined) {
|
|
481
|
+
slot = cacheItem.blockInput.slot;
|
|
482
|
+
// we were not able to observe the time into slot when starting the fetch, do it now
|
|
483
|
+
this.metrics?.blockInputSync.fetchBegin.observe(this.chain.clock.secFromSlot(slot, fetchStartSec));
|
|
498
484
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
485
|
+
const logCtx = { slot, rootHex, peerId, peerClient };
|
|
486
|
+
this.logger.verbose("BlockInputSync.fetchBlockInput: successful download", logCtx);
|
|
487
|
+
this.metrics?.blockInputSync.downloadByRoot.success.inc();
|
|
488
|
+
const warnings = downloadResult.warnings;
|
|
489
|
+
if (warnings) {
|
|
490
|
+
for (const warning of warnings) {
|
|
491
|
+
this.logger.debug("BlockInputSync.fetchBlockInput: downloaded with warning", logCtx, warning);
|
|
492
|
+
this.metrics?.blockInputSync.downloadByRoot.warn.inc({ code: warning.type.code, client: peerClient });
|
|
493
|
+
}
|
|
494
|
+
// TODO: penalize peer?
|
|
504
495
|
}
|
|
505
|
-
return { blockInput, peerIdStr: peerId };
|
|
506
496
|
}
|
|
507
497
|
catch (e) {
|
|
508
|
-
this.logger.debug("Error
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
if (lastError) {
|
|
516
|
-
lastError.message = `Error fetching UnknownBlockRoot after ${i} attempts: ${lastError.message}`;
|
|
517
|
-
throw lastError;
|
|
518
|
-
}
|
|
519
|
-
throw Error(`Error fetching UnknownBlockRoot after ${i}: cannot download all blobs or data columns for block ${blockRootHex}`);
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* We have partial block input:
|
|
523
|
-
* - we have block but not have all blobs (deneb) or needed columns (fulu)
|
|
524
|
-
* - we don't have block and have some blobs (deneb) or some columns (fulu)
|
|
525
|
-
* Fetches missing block/data columns/block for the blockinput. This function returns either preData or availableData BlockInput.
|
|
526
|
-
*/
|
|
527
|
-
async fetchUnavailableBlockInput(unavailableBlockInput) {
|
|
528
|
-
if (unavailableBlockInput.block !== null && unavailableBlockInput.type !== BlockInputType.dataPromise) {
|
|
529
|
-
return { blockInput: unavailableBlockInput, peerIdStr: "" };
|
|
530
|
-
}
|
|
531
|
-
let blockRootHex;
|
|
532
|
-
let blobKzgCommitmentsLen;
|
|
533
|
-
let blockRoot;
|
|
534
|
-
const dataMeta = {};
|
|
535
|
-
let sampledColumns = [];
|
|
536
|
-
if (unavailableBlockInput.block === null) {
|
|
537
|
-
blockRootHex = unavailableBlockInput.blockRootHex;
|
|
538
|
-
blockRoot = fromHex(blockRootHex);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
const { cachedData, block: unavailableBlock } = unavailableBlockInput;
|
|
542
|
-
blockRoot = this.config
|
|
543
|
-
.getForkTypes(unavailableBlock.message.slot)
|
|
544
|
-
.BeaconBlock.hashTreeRoot(unavailableBlock.message);
|
|
545
|
-
blockRootHex = toRootHex(blockRoot);
|
|
546
|
-
blobKzgCommitmentsLen = unavailableBlock.message.body.blobKzgCommitments.length;
|
|
547
|
-
if (cachedData.fork === ForkName.deneb || cachedData.fork === ForkName.electra) {
|
|
548
|
-
const pendingBlobs = blobKzgCommitmentsLen - cachedData.blobsCache.size;
|
|
549
|
-
Object.assign(dataMeta, { pendingBlobs });
|
|
550
|
-
}
|
|
551
|
-
else if (cachedData.fork === ForkName.fulu) {
|
|
552
|
-
sampledColumns = this.network.custodyConfig.sampledColumns;
|
|
553
|
-
const pendingColumns = sampledColumns.length - cachedData.dataColumnsCache.size;
|
|
554
|
-
Object.assign(dataMeta, { pendingColumns });
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
let lastError = null;
|
|
558
|
-
let i = 0;
|
|
559
|
-
const excludedPeers = new Set();
|
|
560
|
-
while (i++ < this.getMaxDownloadAttempts()) {
|
|
561
|
-
const bestPeer = this.peerBalancer.bestPeerForBlockInput(unavailableBlockInput, excludedPeers);
|
|
562
|
-
if (bestPeer === null) {
|
|
563
|
-
// no more peer to try, throw error
|
|
564
|
-
throw Error(`Error fetching UnavailableBlockInput after ${i}: cannot find peer with needed columns ${sampledColumns.join(", ")}`);
|
|
565
|
-
}
|
|
566
|
-
const { peerId, client: peerClient } = bestPeer;
|
|
567
|
-
excludedPeers.add(peerId);
|
|
568
|
-
try {
|
|
569
|
-
const blockInput = await unavailableBeaconBlobsByRoot(this.config, this.network, peerId, peerClient, unavailableBlockInput, {
|
|
570
|
-
metrics: this.metrics,
|
|
571
|
-
logger: this.logger,
|
|
572
|
-
executionEngine: this.chain.executionEngine,
|
|
573
|
-
emitter: this.chain.emitter,
|
|
574
|
-
blockInputsRetryTrackerCache: this.blockInputsRetryTrackerCache,
|
|
575
|
-
engineGetBlobsCache: this.engineGetBlobsCache,
|
|
576
|
-
});
|
|
577
|
-
if (unavailableBlockInput.block !== null && blockInput.type === BlockInputType.dataPromise) {
|
|
578
|
-
// all datacolumns were not downloaded we can continue with other peers
|
|
579
|
-
// as unavailableBlockInput.block's dataColumnsCache would be updated
|
|
580
|
-
continue;
|
|
581
|
-
}
|
|
582
|
-
// data is available, verify block root is correct
|
|
583
|
-
const block = blockInput.block.message;
|
|
584
|
-
const receivedBlockRoot = this.config.getForkTypes(block.slot).BeaconBlock.hashTreeRoot(block);
|
|
585
|
-
if (!byteArrayEquals(receivedBlockRoot, blockRoot)) {
|
|
586
|
-
throw Error(`Wrong block received by peer, got ${toRootHex(receivedBlockRoot)} expected ${blockRootHex}`);
|
|
498
|
+
this.logger.debug("Error downloading in BlockInputSync.fetchBlockInput", { slot, rootHex, attempt: i, peer: peerId, peerClient }, e);
|
|
499
|
+
const downloadByRootMetrics = this.metrics?.blockInputSync.downloadByRoot;
|
|
500
|
+
// TODO: penalize peer?
|
|
501
|
+
if (e instanceof DownloadByRootError) {
|
|
502
|
+
const errorCode = e.type.code;
|
|
503
|
+
downloadByRootMetrics?.error.inc({ code: errorCode, client: peerClient });
|
|
504
|
+
excludedPeers.add(peerId);
|
|
587
505
|
}
|
|
588
|
-
if (
|
|
589
|
-
|
|
506
|
+
else if (e instanceof RequestError) {
|
|
507
|
+
// should look into req_resp metrics in this case
|
|
508
|
+
downloadByRootMetrics?.error.inc({ code: "req_resp", client: peerClient });
|
|
509
|
+
switch (e.type.code) {
|
|
510
|
+
case RequestErrorCode.REQUEST_RATE_LIMITED:
|
|
511
|
+
case RequestErrorCode.REQUEST_TIMEOUT:
|
|
512
|
+
// do not exclude peer for these errors
|
|
513
|
+
break;
|
|
514
|
+
default:
|
|
515
|
+
excludedPeers.add(peerId);
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
590
518
|
}
|
|
591
519
|
else {
|
|
592
|
-
|
|
520
|
+
// investigate if this happens
|
|
521
|
+
downloadByRootMetrics?.error.inc({ code: "unknown", client: peerClient });
|
|
522
|
+
excludedPeers.add(peerId);
|
|
593
523
|
}
|
|
594
|
-
return { blockInput, peerIdStr: peerId };
|
|
595
|
-
}
|
|
596
|
-
catch (e) {
|
|
597
|
-
this.logger.debug("Error fetching UnavailableBlockInput", { attempt: i, blockRootHex, peer: peerId }, e);
|
|
598
|
-
lastError = e;
|
|
599
524
|
}
|
|
600
525
|
finally {
|
|
601
526
|
this.peerBalancer.onRequestCompleted(peerId);
|
|
602
527
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
528
|
+
this.pendingBlocks.set(getBlockInputSyncCacheItemRootHex(cacheItem), cacheItem);
|
|
529
|
+
if (cacheItem.status === PendingBlockInputStatus.downloaded) {
|
|
530
|
+
// download was successful, no need to go with another peer, return
|
|
531
|
+
const result = this.chain.forkChoice.hasBlockHex(cacheItem.blockInput.blockRootHex)
|
|
532
|
+
? FetchResult.SuccessLate
|
|
533
|
+
: this.chain.forkChoice.hasBlockHex(cacheItem.blockInput.parentRootHex)
|
|
534
|
+
? FetchResult.SuccessResolved
|
|
535
|
+
: FetchResult.SuccessMissingParent;
|
|
536
|
+
this.metrics?.blockInputSync.fetchTimeSec.observe({ result }, Date.now() / 1000 - fetchStartSec);
|
|
537
|
+
this.metrics?.blockInputSync.fetchPeers.set({ result }, i);
|
|
538
|
+
return cacheItem;
|
|
539
|
+
}
|
|
540
|
+
} // end while loop over peers
|
|
541
|
+
const message = `Error fetching BlockInput with slot=${slot} blockRoot=${prettyBytes(rootHex)} after ${i - 1} attempts.`;
|
|
542
|
+
if (!isPendingBlockInput(cacheItem)) {
|
|
543
|
+
throw Error(`${message} No block and no data was found.`);
|
|
544
|
+
}
|
|
545
|
+
if (!cacheItem.blockInput.hasBlock()) {
|
|
546
|
+
throw new Error(`${message} Block was not found.`);
|
|
547
|
+
}
|
|
548
|
+
if (isBlockInputBlobs(cacheItem.blockInput)) {
|
|
549
|
+
const missing = cacheItem.blockInput.getMissingBlobMeta().map((b) => b.index);
|
|
550
|
+
if (missing.length) {
|
|
551
|
+
throw new Error(`${message} Missing blob indices=${prettyPrintIndices(missing)}.`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (isBlockInputColumns(cacheItem.blockInput)) {
|
|
555
|
+
const missing = cacheItem.blockInput.getMissingSampledColumnMeta().missing;
|
|
556
|
+
if (missing.length) {
|
|
557
|
+
throw new Error(`${message} Missing column indices=${prettyPrintIndices(missing)}.`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
this.metrics?.blockInputSync.fetchTimeSec.observe({ result: FetchResult.FailureMaxAttempts }, Date.now() / 1000 - fetchStartSec);
|
|
561
|
+
this.metrics?.blockInputSync.fetchPeers.set({ result: FetchResult.FailureMaxAttempts }, i - 1);
|
|
562
|
+
throw Error(message);
|
|
609
563
|
}
|
|
610
564
|
/**
|
|
611
565
|
* Gets all descendant blocks of `block` recursively from `pendingBlocks`.
|
|
@@ -613,33 +567,44 @@ export class UnknownBlockSync {
|
|
|
613
567
|
* Downscore all peers that have referenced any of this bad blocks. May report peers multiple times if they have
|
|
614
568
|
* referenced more than one bad block.
|
|
615
569
|
*/
|
|
616
|
-
|
|
570
|
+
removeAndDownScoreAllDescendants(block) {
|
|
617
571
|
// Get all blocks that are a descendant of this one
|
|
618
572
|
const badPendingBlocks = this.removeAllDescendants(block);
|
|
619
573
|
// just console log and do not penalize on pending/bad blocks for debugging
|
|
620
574
|
// console.log("removeAndDownscoreAllDescendants", {block});
|
|
621
575
|
for (const block of badPendingBlocks) {
|
|
576
|
+
//
|
|
577
|
+
// TODO(fulu): why is this commented out here?
|
|
578
|
+
//
|
|
622
579
|
// this.knownBadBlocks.add(block.blockRootHex);
|
|
623
580
|
// for (const peerIdStr of block.peerIdStrs) {
|
|
624
581
|
// // TODO: Refactor peerRpcScores to work with peerIdStr only
|
|
625
582
|
// this.network.reportPeer(peerIdStr, PeerAction.LowToleranceError, "BadBlockByRoot");
|
|
626
583
|
// }
|
|
627
584
|
this.logger.debug("ignored Banning unknown block", {
|
|
628
|
-
|
|
629
|
-
|
|
585
|
+
slot: getBlockInputSyncCacheItemSlot(block),
|
|
586
|
+
root: getBlockInputSyncCacheItemRootHex(block),
|
|
587
|
+
peerIdStrings: Array.from(block.peerIdStrings)
|
|
588
|
+
.map((id) => prettyPrintPeerIdStr(id))
|
|
589
|
+
.join(","),
|
|
630
590
|
});
|
|
631
591
|
}
|
|
632
592
|
// Prune knownBadBlocks
|
|
633
593
|
pruneSetToMax(this.knownBadBlocks, MAX_KNOWN_BAD_BLOCKS);
|
|
634
594
|
}
|
|
635
595
|
removeAllDescendants(block) {
|
|
596
|
+
const rootHex = getBlockInputSyncCacheItemRootHex(block);
|
|
597
|
+
const slot = getBlockInputSyncCacheItemSlot(block);
|
|
636
598
|
// Get all blocks that are a descendant of this one
|
|
637
|
-
const badPendingBlocks = [block, ...getAllDescendantBlocks(
|
|
638
|
-
this.metrics?.
|
|
599
|
+
const badPendingBlocks = [block, ...getAllDescendantBlocks(rootHex, this.pendingBlocks)];
|
|
600
|
+
this.metrics?.blockInputSync.removedBlocks.inc(badPendingBlocks.length);
|
|
639
601
|
for (const block of badPendingBlocks) {
|
|
640
|
-
|
|
641
|
-
this.
|
|
642
|
-
|
|
602
|
+
const rootHex = getBlockInputSyncCacheItemRootHex(block);
|
|
603
|
+
this.pendingBlocks.delete(rootHex);
|
|
604
|
+
this.chain.seenBlockInputCache.prune(rootHex);
|
|
605
|
+
this.logger.debug("Removing bad/unknown/incomplete BlockInputSyncCacheItem", {
|
|
606
|
+
slot,
|
|
607
|
+
blockRoot: rootHex,
|
|
643
608
|
});
|
|
644
609
|
}
|
|
645
610
|
return badPendingBlocks;
|
|
@@ -657,10 +622,11 @@ export class UnknownBlockSync {
|
|
|
657
622
|
* Class to track active byRoots requests and balance them across eligible peers.
|
|
658
623
|
*/
|
|
659
624
|
export class UnknownBlockPeerBalancer {
|
|
660
|
-
|
|
625
|
+
peersMeta;
|
|
626
|
+
activeRequests;
|
|
627
|
+
constructor() {
|
|
661
628
|
this.peersMeta = new Map();
|
|
662
629
|
this.activeRequests = new Map();
|
|
663
|
-
this.custodyConfig = custodyConfig;
|
|
664
630
|
}
|
|
665
631
|
/** Trigger on each peer re-status */
|
|
666
632
|
onPeerConnected(peerId, syncMeta) {
|
|
@@ -694,36 +660,16 @@ export class UnknownBlockPeerBalancer {
|
|
|
694
660
|
* called from fetchUnavailableBlockInput() where we have either BlockInput or NullBlockInput
|
|
695
661
|
* excludedPeers are the peers that we requested already so we don't want to try again
|
|
696
662
|
*/
|
|
697
|
-
bestPeerForBlockInput(
|
|
698
|
-
let cachedData = undefined;
|
|
699
|
-
if (unavailableBlockInput.block === null) {
|
|
700
|
-
// NullBlockInput
|
|
701
|
-
cachedData = unavailableBlockInput.cachedData;
|
|
702
|
-
}
|
|
703
|
-
else {
|
|
704
|
-
// BlockInput
|
|
705
|
-
if (unavailableBlockInput.type !== BlockInputType.dataPromise) {
|
|
706
|
-
throw Error(`bestPeerForBlockInput called with BlockInput type ${unavailableBlockInput.type}, expected dataPromise`);
|
|
707
|
-
}
|
|
708
|
-
cachedData = unavailableBlockInput.cachedData;
|
|
709
|
-
}
|
|
663
|
+
bestPeerForBlockInput(blockInput, excludedPeers) {
|
|
710
664
|
const eligiblePeers = [];
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const pendingDataColumns = new Set();
|
|
715
|
-
for (const column of this.custodyConfig.sampledColumns) {
|
|
716
|
-
if (!dataColumnsCache.has(column)) {
|
|
717
|
-
pendingDataColumns.add(column);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
// there could be no pending column in case of NullBlockInput
|
|
665
|
+
if (isBlockInputColumns(blockInput)) {
|
|
666
|
+
const pendingDataColumns = new Set(blockInput.getMissingSampledColumnMeta().missing);
|
|
667
|
+
// there could be no pending column in case when block is still missing
|
|
721
668
|
eligiblePeers.push(...this.filterPeers(pendingDataColumns, excludedPeers));
|
|
722
669
|
}
|
|
723
670
|
else {
|
|
724
671
|
// prefulu
|
|
725
|
-
|
|
726
|
-
eligiblePeers.push(...this.filterPeers(pendingDataColumns, excludedPeers));
|
|
672
|
+
eligiblePeers.push(...this.filterPeers(null, excludedPeers));
|
|
727
673
|
}
|
|
728
674
|
if (eligiblePeers.length === 0) {
|
|
729
675
|
return null;
|
|
@@ -775,7 +721,7 @@ export class UnknownBlockPeerBalancer {
|
|
|
775
721
|
continue;
|
|
776
722
|
}
|
|
777
723
|
// postfulu, find peers that have custody columns that we need
|
|
778
|
-
const {
|
|
724
|
+
const { custodyColumns: peerColumns } = syncMeta;
|
|
779
725
|
// check if the peer has all needed columns
|
|
780
726
|
// get match
|
|
781
727
|
const columns = peerColumns.reduce((acc, elem) => {
|