@lodestar/beacon-node 1.43.0-dev.abc719ddc1 → 1.43.0-dev.ac258a8def
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +17 -9
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +45 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +2 -2
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +0 -1
- package/lib/api/impl/debug/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.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +68 -6
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/interface.d.ts +4 -4
- package/lib/chain/archiveStore/interface.d.ts.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +4 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +16 -28
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +32 -14
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +100 -91
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts +5 -3
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +58 -26
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
- package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +15 -20
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts +21 -2
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +92 -12
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +5 -3
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +50 -7
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +25 -5
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +80 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +8 -6
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +44 -14
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +3 -14
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +0 -4
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +8 -1
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +2 -0
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
- 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 +5 -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/errors/index.d.ts +1 -0
- package/lib/chain/errors/index.d.ts.map +1 -1
- package/lib/chain/errors/index.js +1 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/errors/proposerPreferences.d.ts +40 -0
- package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
- package/lib/chain/errors/proposerPreferences.js +14 -0
- package/lib/chain/errors/proposerPreferences.js.map +1 -0
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +5 -17
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +6 -1
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +7 -5
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +26 -4
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +31 -13
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +11 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +52 -14
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +1 -0
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +1 -0
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +1 -4
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +1 -4
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -0
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +1 -0
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +24 -7
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +69 -17
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
- package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
- package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
- package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +1 -0
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +24 -9
- 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 +19 -9
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts +8 -0
- package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
- package/lib/chain/validation/proposerPreferences.js +91 -0
- package/lib/chain/validation/proposerPreferences.js.map +1 -0
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +21 -14
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -0
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -0
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +20 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +18 -0
- package/lib/execution/engine/types.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 +4 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +7 -1
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/interface.js +1 -0
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
- package/lib/network/gossip/scoringParameters.js +12 -1
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +32 -748
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +6 -0
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/interface.d.ts +2 -0
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +2 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +9 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +41 -19
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +5 -0
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +6 -5
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +5 -0
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/interface.d.ts +1 -1
- package/lib/network/reqresp/interface.js +1 -1
- package/lib/network/reqresp/protocols.d.ts +1 -0
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +5 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
- package/lib/network/reqresp/rateLimit.js +4 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +1 -0
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +3 -0
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +3 -0
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/node/nodejs.js +2 -2
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/constants.d.ts +7 -1
- package/lib/sync/constants.d.ts.map +1 -1
- package/lib/sync/constants.js +7 -4
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/range/batch.d.ts +35 -5
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +240 -59
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +22 -4
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +102 -10
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +71 -11
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/sync.d.ts.map +1 -1
- package/lib/sync/sync.js +13 -0
- package/lib/sync/sync.js.map +1 -1
- package/lib/sync/types.d.ts +34 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +34 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +29 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +727 -61
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +73 -10
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +213 -26
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +16 -2
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.js +0 -9
- package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
- package/lib/sync/utils/rateLimit.d.ts +2 -0
- package/lib/sync/utils/rateLimit.d.ts.map +1 -0
- package/lib/sync/utils/rateLimit.js +15 -0
- package/lib/sync/utils/rateLimit.js.map +1 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +20 -5
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +17 -16
- package/src/api/impl/beacon/blocks/index.ts +22 -9
- package/src/api/impl/beacon/pool/index.ts +83 -1
- package/src/api/impl/beacon/state/utils.ts +2 -2
- package/src/api/impl/debug/index.ts +0 -1
- package/src/api/impl/lodestar/index.ts +1 -1
- package/src/api/impl/validator/index.ts +82 -5
- package/src/chain/archiveStore/archiveStore.ts +5 -5
- package/src/chain/archiveStore/interface.ts +4 -4
- package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
- package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
- package/src/chain/blocks/blockInput/blockInput.ts +4 -1
- package/src/chain/blocks/importBlock.ts +16 -48
- package/src/chain/blocks/importExecutionPayload.ts +126 -110
- package/src/chain/blocks/index.ts +71 -23
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
- package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
- package/src/chain/blocks/types.ts +15 -25
- package/src/chain/blocks/utils/chainSegment.ts +117 -17
- package/src/chain/blocks/verifyBlock.ts +70 -9
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
- package/src/chain/blocks/verifyBlocksSanityChecks.ts +26 -7
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +137 -0
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
- package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
- package/src/chain/chain.ts +65 -26
- package/src/chain/emitter.ts +3 -14
- package/src/chain/errors/blockError.ts +4 -1
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/errors/proposerPreferences.ts +47 -0
- package/src/chain/forkChoice/index.ts +2 -22
- package/src/chain/initState.ts +9 -1
- package/src/chain/interface.ts +11 -3
- package/src/chain/opPools/payloadAttestationPool.ts +29 -8
- package/src/chain/prepareNextSlot.ts +36 -14
- package/src/chain/produceBlock/produceBlockBody.ts +63 -13
- package/src/chain/regen/interface.ts +1 -0
- package/src/chain/regen/queued.ts +2 -7
- package/src/chain/regen/regen.ts +2 -7
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +89 -21
- package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
- package/src/chain/validation/block.ts +1 -0
- package/src/chain/validation/executionPayloadBid.ts +25 -8
- package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
- package/src/chain/validation/proposerPreferences.ts +110 -0
- package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
- package/src/execution/engine/http.ts +21 -14
- package/src/execution/engine/interface.ts +1 -0
- package/src/execution/engine/mock.ts +8 -1
- package/src/execution/engine/types.ts +41 -0
- package/src/metrics/metrics/lodestar.ts +4 -0
- package/src/network/gossip/interface.ts +6 -0
- package/src/network/gossip/scoringParameters.ts +14 -1
- package/src/network/gossip/topic.ts +6 -0
- package/src/network/interface.ts +2 -0
- package/src/network/network.ts +24 -1
- package/src/network/processor/gossipHandlers.ts +56 -20
- package/src/network/processor/gossipQueues/index.ts +5 -0
- package/src/network/processor/index.ts +6 -5
- package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
- package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
- package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
- package/src/network/reqresp/handlers/index.ts +5 -0
- package/src/network/reqresp/interface.ts +1 -1
- package/src/network/reqresp/protocols.ts +6 -0
- package/src/network/reqresp/rateLimit.ts +4 -0
- package/src/network/reqresp/score.ts +1 -0
- package/src/network/reqresp/types.ts +5 -0
- package/src/node/nodejs.ts +2 -2
- package/src/sync/constants.ts +8 -4
- package/src/sync/range/batch.ts +320 -67
- package/src/sync/range/chain.ts +130 -13
- package/src/sync/range/range.ts +86 -11
- package/src/sync/sync.ts +13 -1
- package/src/sync/types.ts +72 -0
- package/src/sync/unknownBlock.ts +915 -65
- package/src/sync/utils/downloadByRange.ts +386 -39
- package/src/sync/utils/downloadByRoot.ts +24 -2
- package/src/sync/utils/pendingBlocksTree.ts +0 -15
- package/src/sync/utils/rateLimit.ts +16 -0
- package/src/util/sszBytes.ts +25 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/sync/constants.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,8FAA8F;AAC9F,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD,2EAA2E;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/sync/constants.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,8FAA8F;AAC9F,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AAElD;;;;;IAKI;AACJ,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,4CAA4C;AAC5C,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAmC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC"}
|
package/lib/sync/constants.js
CHANGED
|
@@ -3,10 +3,13 @@ export const PARALLEL_HEAD_CHAINS = 2;
|
|
|
3
3
|
/** Minimum work we require a finalized chain to do before picking a chain with more peers. */
|
|
4
4
|
export const MIN_FINALIZED_CHAIN_VALIDATED_EPOCHS = 10;
|
|
5
5
|
/** The number of times to retry a batch before it is considered failed. */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export const MAX_BATCH_DOWNLOAD_ATTEMPTS = 5;
|
|
7
|
+
/**
|
|
8
|
+
* Backoff before assigning more range-sync batches to a peer that rate-limited us.
|
|
9
|
+
*
|
|
10
|
+
* Note: this is used when rate limited due to MAX_CONCURRENT_REQUESTS
|
|
11
|
+
*/
|
|
12
|
+
export const RATE_LIMITED_PEER_BACKOFF_MS = 5_000;
|
|
10
13
|
/**
|
|
11
14
|
* Consider batch faulty after downloading and processing this number of times
|
|
12
15
|
* as in https://github.com/ChainSafe/lodestar/issues/8147 we cannot proceed the sync chain if there is unknown parent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/sync/constants.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEvD,2EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/sync/constants.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEvD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAElD;;;;;IAKI;AACJ,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,gBAAgB,CAAC,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
2
|
import { ForkName } from "@lodestar/params";
|
|
3
|
-
import { Epoch, RootHex, Slot } from "@lodestar/types";
|
|
3
|
+
import { Epoch, RootHex, Slot, gloas } from "@lodestar/types";
|
|
4
4
|
import { LodestarError } from "@lodestar/utils";
|
|
5
5
|
import { IBlockInput } from "../../chain/blocks/blockInput/types.js";
|
|
6
|
+
import { PayloadEnvelopeInput } from "../../chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js";
|
|
6
7
|
import { PeerSyncMeta } from "../../network/peers/peersData.js";
|
|
7
8
|
import { IClock } from "../../util/clock.js";
|
|
8
9
|
import { CustodyConfig } from "../../util/dataColumns.js";
|
|
9
10
|
import { PeerIdStr } from "../../util/peerId.js";
|
|
10
|
-
import { DownloadByRangeRequests } from "../utils/downloadByRange.js";
|
|
11
|
+
import { DownloadByRangeRequests, ParentPayloadCommitments } from "../utils/downloadByRange.js";
|
|
11
12
|
/**
|
|
12
13
|
* Current state of a batch
|
|
13
14
|
*/
|
|
@@ -38,27 +39,42 @@ export type Attempt = {
|
|
|
38
39
|
export type AwaitingDownloadState = {
|
|
39
40
|
status: BatchStatus.AwaitingDownload;
|
|
40
41
|
blocks: IBlockInput[];
|
|
42
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
41
43
|
};
|
|
42
44
|
export type DownloadSuccessState = {
|
|
43
45
|
status: BatchStatus.AwaitingProcessing;
|
|
44
46
|
blocks: IBlockInput[];
|
|
47
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
45
48
|
};
|
|
46
49
|
export type BatchState = AwaitingDownloadState | {
|
|
47
50
|
status: BatchStatus.Downloading;
|
|
48
51
|
peer: PeerIdStr;
|
|
49
52
|
blocks: IBlockInput[];
|
|
53
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
50
54
|
} | DownloadSuccessState | {
|
|
51
55
|
status: BatchStatus.Processing;
|
|
52
56
|
blocks: IBlockInput[];
|
|
57
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
53
58
|
attempt: Attempt;
|
|
54
59
|
} | {
|
|
55
60
|
status: BatchStatus.AwaitingValidation;
|
|
56
61
|
blocks: IBlockInput[];
|
|
62
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
57
63
|
attempt: Attempt;
|
|
58
64
|
};
|
|
59
65
|
export type BatchMetadata = {
|
|
60
66
|
startEpoch: Epoch;
|
|
67
|
+
startSlot: Slot;
|
|
68
|
+
count: number;
|
|
61
69
|
status: BatchStatus;
|
|
70
|
+
blocksReq?: string;
|
|
71
|
+
blobsReq?: string;
|
|
72
|
+
columnsReq?: string;
|
|
73
|
+
envelopesReq?: string;
|
|
74
|
+
downloadAttempts: number;
|
|
75
|
+
processingAttempts: number;
|
|
76
|
+
failedDownloadPeers?: string;
|
|
77
|
+
failedProcessingPeers?: string;
|
|
62
78
|
};
|
|
63
79
|
/**
|
|
64
80
|
* Batches are downloaded at the first block of the epoch.
|
|
@@ -91,7 +107,11 @@ export declare class Batch {
|
|
|
91
107
|
private readonly config;
|
|
92
108
|
private readonly clock;
|
|
93
109
|
private readonly custodyConfig;
|
|
94
|
-
|
|
110
|
+
private readonly isFirstBatchInChain;
|
|
111
|
+
private readonly latestBid;
|
|
112
|
+
constructor(startEpoch: Epoch, config: ChainForkConfig, clock: IClock, custodyConfig: CustodyConfig, isFirstBatchInChain: boolean, latestBid: gloas.ExecutionPayloadBid | undefined, targetSlot: Slot);
|
|
113
|
+
private shouldDownloadParentEnvelope;
|
|
114
|
+
getParentPayloadCommitments(parentBlockRoot: Uint8Array): ParentPayloadCommitments;
|
|
95
115
|
/**
|
|
96
116
|
* Builds ByRange requests for block, blobs and columns
|
|
97
117
|
*/
|
|
@@ -106,6 +126,7 @@ export declare class Batch {
|
|
|
106
126
|
getFailedPeers(): PeerIdStr[];
|
|
107
127
|
getMetadata(): BatchMetadata;
|
|
108
128
|
getBlocks(): IBlockInput[];
|
|
129
|
+
getPayloadEnvelopes(): Map<Slot, PayloadEnvelopeInput> | null;
|
|
109
130
|
/**
|
|
110
131
|
* AwaitingDownload -> Downloading
|
|
111
132
|
*/
|
|
@@ -113,15 +134,24 @@ export declare class Batch {
|
|
|
113
134
|
/**
|
|
114
135
|
* Downloading -> AwaitingProcessing
|
|
115
136
|
*/
|
|
116
|
-
downloadingSuccess(peer: PeerIdStr, blocks: IBlockInput[]): DownloadSuccessState;
|
|
137
|
+
downloadingSuccess(peer: PeerIdStr, blocks: IBlockInput[], payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null): DownloadSuccessState;
|
|
117
138
|
/**
|
|
118
139
|
* Downloading -> AwaitingDownload
|
|
119
140
|
*/
|
|
120
141
|
downloadingError(peer: PeerIdStr): void;
|
|
142
|
+
/**
|
|
143
|
+
* Downloading -> AwaitingDownload (without counting as a failed attempt).
|
|
144
|
+
* Used when the peer rate-limited us — the request was never actually served.
|
|
145
|
+
*/
|
|
146
|
+
downloadingRateLimited(): void;
|
|
121
147
|
/**
|
|
122
148
|
* AwaitingProcessing -> Processing
|
|
123
149
|
*/
|
|
124
|
-
startProcessing():
|
|
150
|
+
startProcessing(): {
|
|
151
|
+
blocks: IBlockInput[];
|
|
152
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
153
|
+
peers: PeerIdStr[];
|
|
154
|
+
};
|
|
125
155
|
/**
|
|
126
156
|
* Processing -> AwaitingValidation
|
|
127
157
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/sync/range/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/sync/range/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAmD,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAC,KAAK,EAAE,OAAO,EAAqB,IAAI,EAAE,KAAK,EAAS,MAAM,iBAAiB,CAAC;AACvF,OAA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C,GACrE;IAAC,IAAI,EAAE,cAAc,CAAC,qBAAqB,CAAA;CAAC,GAC5C;IAAC,IAAI,EAAE,cAAc,CAAC,uBAAuB,CAAA;CAAC,GAC9C;IAAC,IAAI,EAAE,cAAc,CAAC,mCAAmC,CAAA;CAAC,CAAC;AAE/D,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,qBAAa,UAAW,SAAQ,aAAa,CAAC,cAAc,GAAG,kBAAkB,CAAC;CAAG"}
|
package/lib/sync/range/batch.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isForkPostDeneb, isForkPostFulu } from "@lodestar/params";
|
|
2
|
-
import { LodestarError } from "@lodestar/utils";
|
|
1
|
+
import { isForkPostDeneb, isForkPostFulu, isForkPostGloas } from "@lodestar/params";
|
|
2
|
+
import { LodestarError, byteArrayEquals, prettyPrintIndices, toRootHex } from "@lodestar/utils";
|
|
3
3
|
import { isBlockInputColumns } from "../../chain/blocks/blockInput/blockInput.js";
|
|
4
4
|
import { isDaOutOfRange } from "../../chain/blocks/blockInput/utils.js";
|
|
5
5
|
import { BlockError, BlockErrorCode } from "../../chain/errors/index.js";
|
|
6
|
+
import { ZERO_HASH } from "../../constants/constants.js";
|
|
6
7
|
import { MAX_BATCH_DOWNLOAD_ATTEMPTS, MAX_BATCH_PROCESSING_ATTEMPTS } from "../constants.js";
|
|
7
8
|
import { getBatchSlotRange, hashBlocks } from "./utils/index.js";
|
|
8
9
|
export { BatchStatus };
|
|
@@ -28,6 +29,12 @@ var BatchStatus;
|
|
|
28
29
|
*/
|
|
29
30
|
BatchStatus["AwaitingValidation"] = "AwaitingValidation";
|
|
30
31
|
})(BatchStatus || (BatchStatus = {}));
|
|
32
|
+
function formatRangeReq(req) {
|
|
33
|
+
return `startSlot=${req.startSlot},count=${req.count}`;
|
|
34
|
+
}
|
|
35
|
+
function formatColumnsReq(req) {
|
|
36
|
+
return `startSlot=${req.startSlot},count=${req.count},cols=${prettyPrintIndices(req.columns)}`;
|
|
37
|
+
}
|
|
31
38
|
/**
|
|
32
39
|
* Batches are downloaded at the first block of the epoch.
|
|
33
40
|
*
|
|
@@ -47,7 +54,7 @@ export class Batch {
|
|
|
47
54
|
/** Block, blob and column requests that are used to determine the best peer and are used in downloadByRange */
|
|
48
55
|
requests;
|
|
49
56
|
/** State of the batch. */
|
|
50
|
-
state = { status: BatchStatus.AwaitingDownload, blocks: [] };
|
|
57
|
+
state = { status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null };
|
|
51
58
|
/** Peers that provided good data */
|
|
52
59
|
goodPeers = [];
|
|
53
60
|
/** The `Attempts` that have been made and failed to send us this batch. */
|
|
@@ -59,7 +66,9 @@ export class Batch {
|
|
|
59
66
|
config;
|
|
60
67
|
clock;
|
|
61
68
|
custodyConfig;
|
|
62
|
-
|
|
69
|
+
isFirstBatchInChain;
|
|
70
|
+
latestBid;
|
|
71
|
+
constructor(startEpoch, config, clock, custodyConfig, isFirstBatchInChain, latestBid, targetSlot) {
|
|
63
72
|
this.config = config;
|
|
64
73
|
this.clock = clock;
|
|
65
74
|
this.custodyConfig = custodyConfig;
|
|
@@ -67,9 +76,36 @@ export class Batch {
|
|
|
67
76
|
this.forkName = this.config.getForkName(startSlot);
|
|
68
77
|
this.startEpoch = startEpoch;
|
|
69
78
|
this.startSlot = startSlot;
|
|
70
|
-
this.count = count;
|
|
79
|
+
this.count = Math.min(count, targetSlot - startSlot + 1);
|
|
80
|
+
this.isFirstBatchInChain = isFirstBatchInChain;
|
|
81
|
+
this.latestBid = latestBid;
|
|
71
82
|
this.requests = this.getRequests([]);
|
|
72
83
|
}
|
|
84
|
+
shouldDownloadParentEnvelope(firstBlock) {
|
|
85
|
+
if (!this.isFirstBatchInChain)
|
|
86
|
+
return false;
|
|
87
|
+
if (this.startSlot === 0 || !isForkPostGloas(this.config.getForkName(this.startSlot - 1))) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
// we only know if we should download parent envelope if firstBlock is downloaded
|
|
91
|
+
if (firstBlock === undefined)
|
|
92
|
+
return false;
|
|
93
|
+
if (this.latestBid === undefined)
|
|
94
|
+
return false;
|
|
95
|
+
const firstBlockBidParentHash = firstBlock.message.body.signedExecutionPayloadBid.message
|
|
96
|
+
.parentBlockHash;
|
|
97
|
+
return byteArrayEquals(firstBlockBidParentHash, this.latestBid.blockHash);
|
|
98
|
+
}
|
|
99
|
+
getParentPayloadCommitments(parentBlockRoot) {
|
|
100
|
+
if (this.latestBid === undefined) {
|
|
101
|
+
throw new Error(`Coding error: getParentPayloadCommitments called without latestBid for parentBlockRoot=${toRootHex(parentBlockRoot)}`);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
blockRoot: parentBlockRoot,
|
|
105
|
+
blockRootHex: toRootHex(parentBlockRoot),
|
|
106
|
+
kzgCommitments: this.latestBid.blobKzgCommitments,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
73
109
|
/**
|
|
74
110
|
* Builds ByRange requests for block, blobs and columns
|
|
75
111
|
*/
|
|
@@ -82,35 +118,32 @@ export class Batch {
|
|
|
82
118
|
count: this.count,
|
|
83
119
|
step: 1,
|
|
84
120
|
};
|
|
121
|
+
const requests = { blocksRequest };
|
|
122
|
+
// Post-Gloas envelopes are required for block processing, independent of DA retention window.
|
|
123
|
+
if (isForkPostGloas(this.forkName)) {
|
|
124
|
+
requests.envelopesRequest = { startSlot: this.startSlot, count: this.count };
|
|
125
|
+
}
|
|
85
126
|
if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
count: this.count,
|
|
91
|
-
columns: this.custodyConfig.sampledColumns,
|
|
92
|
-
},
|
|
127
|
+
requests.columnsRequest = {
|
|
128
|
+
startSlot: this.startSlot,
|
|
129
|
+
count: this.count,
|
|
130
|
+
columns: this.custodyConfig.sampledColumns,
|
|
93
131
|
};
|
|
94
132
|
}
|
|
95
|
-
if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
|
|
96
|
-
|
|
97
|
-
blocksRequest,
|
|
98
|
-
blobsRequest: {
|
|
99
|
-
startSlot: this.startSlot,
|
|
100
|
-
count: this.count,
|
|
101
|
-
},
|
|
102
|
-
};
|
|
133
|
+
else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
|
|
134
|
+
requests.blobsRequest = { startSlot: this.startSlot, count: this.count };
|
|
103
135
|
}
|
|
104
|
-
return
|
|
105
|
-
blocksRequest,
|
|
106
|
-
};
|
|
136
|
+
return requests;
|
|
107
137
|
}
|
|
108
138
|
// subsequent request where part of the epoch has already been downloaded. Need to figure out what is the beginning
|
|
109
139
|
// of the range where download needs to resume
|
|
110
140
|
let blockStartSlot = this.startSlot;
|
|
111
141
|
let dataStartSlot = this.startSlot;
|
|
142
|
+
let envelopeStartSlot = this.startSlot;
|
|
112
143
|
const neededColumns = new Set();
|
|
144
|
+
const envelopesBySlot = this.state.payloadEnvelopes ?? new Map();
|
|
113
145
|
// ensure blocks are in slot-wise order
|
|
146
|
+
const isPostGloas = isForkPostGloas(this.forkName);
|
|
114
147
|
for (const blockInput of blocks) {
|
|
115
148
|
const blockSlot = blockInput.slot;
|
|
116
149
|
// check if block/data is present (hasBlock/hasAllData). If present then check if startSlot is the same as
|
|
@@ -126,15 +159,38 @@ export class Batch {
|
|
|
126
159
|
if (blockInput.hasBlock() && blockStartSlot === blockSlot) {
|
|
127
160
|
blockStartSlot = blockSlot + 1;
|
|
128
161
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
// Range sync uses hasComputedAllData (all sampled columns physically present), not hasAllData
|
|
163
|
+
// which flips at the reconstruction threshold. Sync never triggers reconstruction, so accepting
|
|
164
|
+
// a half-downloaded block here makes writeBlockInputToDb later block on waitForComputedAllData.
|
|
165
|
+
if (isPostGloas) {
|
|
166
|
+
// Post-Gloas: column data lives on PayloadEnvelopeInput, not on BlockInputNoData.
|
|
167
|
+
const payloadInput = envelopesBySlot.get(blockSlot);
|
|
168
|
+
if (blockInput.hasBlock() && envelopeStartSlot === blockSlot && payloadInput?.hasPayloadEnvelope()) {
|
|
169
|
+
envelopeStartSlot = blockSlot + 1;
|
|
170
|
+
}
|
|
171
|
+
if (payloadInput && !payloadInput.hasComputedAllData()) {
|
|
172
|
+
for (const index of payloadInput.getMissingSampledColumnMeta().missing) {
|
|
132
173
|
neededColumns.add(index);
|
|
133
174
|
}
|
|
134
175
|
}
|
|
176
|
+
else if (payloadInput?.hasComputedAllData() && dataStartSlot === blockSlot) {
|
|
177
|
+
// Only advance dataStartSlot when we know columns for this slot are complete. If
|
|
178
|
+
// payloadInput is missing entirely we cannot tell, so stop here so the next round
|
|
179
|
+
// re-requests columns (and envelopes) starting at this slot.
|
|
180
|
+
dataStartSlot = blockSlot + 1;
|
|
181
|
+
}
|
|
135
182
|
}
|
|
136
|
-
else
|
|
137
|
-
|
|
183
|
+
else {
|
|
184
|
+
if (isBlockInputColumns(blockInput) ? !blockInput.hasComputedAllData() : !blockInput.hasAllData()) {
|
|
185
|
+
if (isBlockInputColumns(blockInput)) {
|
|
186
|
+
for (const index of blockInput.getMissingSampledColumnMeta().missing) {
|
|
187
|
+
neededColumns.add(index);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (dataStartSlot === blockSlot) {
|
|
192
|
+
dataStartSlot = blockSlot + 1;
|
|
193
|
+
}
|
|
138
194
|
}
|
|
139
195
|
}
|
|
140
196
|
// if the blockStartSlot or dataStartSlot is after the desired endSlot then no request will be made for the batch
|
|
@@ -153,11 +209,15 @@ export class Batch {
|
|
|
153
209
|
// range of 40 - 63, startSlot will be inclusive but subtraction will exclusive so need to + 1
|
|
154
210
|
const count = endSlot - dataStartSlot + 1;
|
|
155
211
|
if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
212
|
+
// Skip the column re-request when we have no specific column indices outstanding.
|
|
213
|
+
// Peer rejects an empty `columns` list
|
|
214
|
+
if (neededColumns.size > 0) {
|
|
215
|
+
requests.columnsRequest = {
|
|
216
|
+
count,
|
|
217
|
+
startSlot: dataStartSlot,
|
|
218
|
+
columns: Array.from(neededColumns),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
161
221
|
}
|
|
162
222
|
else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
|
|
163
223
|
requests.blobsRequest = {
|
|
@@ -167,6 +227,39 @@ export class Batch {
|
|
|
167
227
|
}
|
|
168
228
|
// dataSlot will still have a value but do not create a request for preDeneb forks
|
|
169
229
|
}
|
|
230
|
+
if (isForkPostGloas(this.forkName) && envelopeStartSlot <= endSlot) {
|
|
231
|
+
requests.envelopesRequest = {
|
|
232
|
+
startSlot: envelopeStartSlot,
|
|
233
|
+
count: endSlot - envelopeStartSlot + 1,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
// Only the first batch of a SyncChain may need the dangling-parent payload by-root.
|
|
237
|
+
if (blocks.length > 0 && this.shouldDownloadParentEnvelope(blocks[0].getBlock())) {
|
|
238
|
+
// shouldDownloadParentEnvelope() = true means there are at least 1 block
|
|
239
|
+
const parentRoot = blocks[0].getBlock().message.parentRoot;
|
|
240
|
+
if (!byteArrayEquals(parentRoot, ZERO_HASH)) {
|
|
241
|
+
const parentRootHex = toRootHex(parentRoot);
|
|
242
|
+
let parentPayloadInput;
|
|
243
|
+
if (this.state.payloadEnvelopes) {
|
|
244
|
+
for (const pi of this.state.payloadEnvelopes.values()) {
|
|
245
|
+
if (pi.blockRootHex === parentRootHex) {
|
|
246
|
+
parentPayloadInput = pi;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const needsEnvelope = !parentPayloadInput?.hasPayloadEnvelope();
|
|
252
|
+
const missingColumns = parentPayloadInput
|
|
253
|
+
? parentPayloadInput.getMissingSampledColumnMeta().missing
|
|
254
|
+
: this.custodyConfig.sampledColumns;
|
|
255
|
+
if (needsEnvelope || missingColumns.length > 0) {
|
|
256
|
+
requests.parentPayloadRequest = {
|
|
257
|
+
...(needsEnvelope ? { envelopeBlockRoot: parentRoot } : {}),
|
|
258
|
+
...(missingColumns.length > 0 ? { blockRoot: parentRoot, columns: missingColumns } : {}),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
170
263
|
return requests;
|
|
171
264
|
}
|
|
172
265
|
/**
|
|
@@ -176,22 +269,22 @@ export class Batch {
|
|
|
176
269
|
if (!isForkPostFulu(this.forkName)) {
|
|
177
270
|
return this.requests;
|
|
178
271
|
}
|
|
179
|
-
// post-fulu we need to ensure that we only request columns that the peer has advertised
|
|
180
|
-
const { columnsRequest } = this.requests;
|
|
181
|
-
if (columnsRequest == null) {
|
|
182
|
-
return this.requests;
|
|
183
|
-
}
|
|
272
|
+
// post-fulu we need to ensure that we only request columns that the peer has advertised.
|
|
273
|
+
const { columnsRequest, parentPayloadRequest } = this.requests;
|
|
184
274
|
const peerColumns = new Set(peer.custodyColumns ?? []);
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
275
|
+
const filteredColumnsRequest = columnsRequest != null ? columnsRequest.columns.filter((c) => peerColumns.has(c)) : null;
|
|
276
|
+
const parentColumns = parentPayloadRequest?.columns;
|
|
277
|
+
const filteredParentColumns = parentColumns != null ? parentColumns.filter((c) => peerColumns.has(c)) : null;
|
|
278
|
+
const updatedColumnRequest = columnsRequest != null && filteredColumnsRequest != null
|
|
279
|
+
? { columnsRequest: { ...columnsRequest, columns: filteredColumnsRequest } }
|
|
280
|
+
: {};
|
|
281
|
+
const updatedParentPayloadRequest = parentPayloadRequest != null && filteredParentColumns != null
|
|
282
|
+
? { parentPayloadRequest: { ...parentPayloadRequest, columns: filteredParentColumns } }
|
|
283
|
+
: {};
|
|
189
284
|
return {
|
|
190
285
|
...this.requests,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
columns: requestedColumns,
|
|
194
|
-
},
|
|
286
|
+
...updatedColumnRequest,
|
|
287
|
+
...updatedParentPayloadRequest,
|
|
195
288
|
};
|
|
196
289
|
}
|
|
197
290
|
/**
|
|
@@ -201,11 +294,33 @@ export class Batch {
|
|
|
201
294
|
return [...this.failedDownloadAttempts, ...this.failedProcessingAttempts.flatMap((a) => a.peers)];
|
|
202
295
|
}
|
|
203
296
|
getMetadata() {
|
|
204
|
-
|
|
297
|
+
const { blocksRequest, blobsRequest, columnsRequest, envelopesRequest } = this.requests;
|
|
298
|
+
const failedProcessingPeerList = this.failedProcessingAttempts.flatMap((a) => a.peers);
|
|
299
|
+
return {
|
|
300
|
+
startEpoch: this.startEpoch,
|
|
301
|
+
startSlot: this.startSlot,
|
|
302
|
+
count: this.count,
|
|
303
|
+
status: this.state.status,
|
|
304
|
+
...(blocksRequest && { blocksReq: formatRangeReq(blocksRequest) }),
|
|
305
|
+
...(blobsRequest && { blobsReq: formatRangeReq(blobsRequest) }),
|
|
306
|
+
...(columnsRequest && { columnsReq: formatColumnsReq(columnsRequest) }),
|
|
307
|
+
...(envelopesRequest && { envelopesReq: formatRangeReq(envelopesRequest) }),
|
|
308
|
+
downloadAttempts: this.failedDownloadAttempts.length,
|
|
309
|
+
processingAttempts: this.failedProcessingAttempts.length,
|
|
310
|
+
...(this.failedDownloadAttempts.length > 0 && {
|
|
311
|
+
failedDownloadPeers: this.failedDownloadAttempts.join(","),
|
|
312
|
+
}),
|
|
313
|
+
...(failedProcessingPeerList.length > 0 && {
|
|
314
|
+
failedProcessingPeers: failedProcessingPeerList.join(","),
|
|
315
|
+
}),
|
|
316
|
+
};
|
|
205
317
|
}
|
|
206
318
|
getBlocks() {
|
|
207
319
|
return this.state.blocks;
|
|
208
320
|
}
|
|
321
|
+
getPayloadEnvelopes() {
|
|
322
|
+
return this.state.payloadEnvelopes;
|
|
323
|
+
}
|
|
209
324
|
/**
|
|
210
325
|
* AwaitingDownload -> Downloading
|
|
211
326
|
*/
|
|
@@ -213,12 +328,17 @@ export class Batch {
|
|
|
213
328
|
if (this.state.status !== BatchStatus.AwaitingDownload) {
|
|
214
329
|
throw new BatchError(this.wrongStatusErrorType(BatchStatus.AwaitingDownload));
|
|
215
330
|
}
|
|
216
|
-
this.state = {
|
|
331
|
+
this.state = {
|
|
332
|
+
status: BatchStatus.Downloading,
|
|
333
|
+
peer,
|
|
334
|
+
blocks: this.state.blocks,
|
|
335
|
+
payloadEnvelopes: this.state.payloadEnvelopes,
|
|
336
|
+
};
|
|
217
337
|
}
|
|
218
338
|
/**
|
|
219
339
|
* Downloading -> AwaitingProcessing
|
|
220
340
|
*/
|
|
221
|
-
downloadingSuccess(peer, blocks) {
|
|
341
|
+
downloadingSuccess(peer, blocks, payloadEnvelopes) {
|
|
222
342
|
if (this.state.status !== BatchStatus.Downloading) {
|
|
223
343
|
throw new BatchError(this.wrongStatusErrorType(BatchStatus.Downloading));
|
|
224
344
|
}
|
|
@@ -229,7 +349,11 @@ export class Batch {
|
|
|
229
349
|
const slots = new Set();
|
|
230
350
|
for (const block of blocks) {
|
|
231
351
|
slots.add(block.slot);
|
|
232
|
-
|
|
352
|
+
const dataComplete = isBlockInputColumns(block)
|
|
353
|
+
? // by_range needs to download all columns
|
|
354
|
+
block.hasBlock() && block.hasComputedAllData()
|
|
355
|
+
: block.hasBlockAndAllData();
|
|
356
|
+
if (!dataComplete) {
|
|
233
357
|
allComplete = false;
|
|
234
358
|
}
|
|
235
359
|
}
|
|
@@ -242,12 +366,45 @@ export class Batch {
|
|
|
242
366
|
status: this.state.status,
|
|
243
367
|
});
|
|
244
368
|
}
|
|
369
|
+
const newPayloadEnvelopes = payloadEnvelopes ?? this.state.payloadEnvelopes;
|
|
370
|
+
if (allComplete && isForkPostGloas(this.forkName)) {
|
|
371
|
+
for (const block of blocks) {
|
|
372
|
+
const payloadInput = newPayloadEnvelopes?.get(block.slot);
|
|
373
|
+
// by_range needs every block's envelope and all sampled columns.
|
|
374
|
+
if (!payloadInput?.hasPayloadEnvelope() || !payloadInput.hasComputedAllData()) {
|
|
375
|
+
allComplete = false;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// First batch of a sync chain must additionally have the dangling-parent payload fully
|
|
381
|
+
// present, otherwise `processBlocks` will throw PARENT_PAYLOAD_UNKNOWN. The parent's
|
|
382
|
+
// `PayloadEnvelopeInput` is identified by `blockRootHex` matching `blocks[0].parentRoot`.
|
|
383
|
+
if (allComplete && blocks.length > 0 && this.shouldDownloadParentEnvelope(blocks[0].getBlock())) {
|
|
384
|
+
const parentRoot = blocks[0].getBlock().message.parentRoot;
|
|
385
|
+
// Genesis has no parent payload — nothing to wait for.
|
|
386
|
+
if (!byteArrayEquals(parentRoot, ZERO_HASH)) {
|
|
387
|
+
const parentRootHex = toRootHex(parentRoot);
|
|
388
|
+
let parentPayloadComplete = false;
|
|
389
|
+
if (newPayloadEnvelopes) {
|
|
390
|
+
for (const payloadInput of newPayloadEnvelopes.values()) {
|
|
391
|
+
if (payloadInput.blockRootHex === parentRootHex) {
|
|
392
|
+
parentPayloadComplete = payloadInput.hasPayloadEnvelope() && payloadInput.hasComputedAllData();
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (!parentPayloadComplete) {
|
|
398
|
+
allComplete = false;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
245
402
|
if (allComplete) {
|
|
246
|
-
this.state = { status: BatchStatus.AwaitingProcessing, blocks };
|
|
403
|
+
this.state = { status: BatchStatus.AwaitingProcessing, blocks, payloadEnvelopes: newPayloadEnvelopes };
|
|
247
404
|
}
|
|
248
405
|
else {
|
|
406
|
+
this.state = { status: BatchStatus.AwaitingDownload, blocks, payloadEnvelopes: newPayloadEnvelopes };
|
|
249
407
|
this.requests = this.getRequests(blocks);
|
|
250
|
-
this.state = { status: BatchStatus.AwaitingDownload, blocks };
|
|
251
408
|
}
|
|
252
409
|
return this.state;
|
|
253
410
|
}
|
|
@@ -262,7 +419,25 @@ export class Batch {
|
|
|
262
419
|
if (this.failedDownloadAttempts.length > MAX_BATCH_DOWNLOAD_ATTEMPTS) {
|
|
263
420
|
throw new BatchError(this.errorType({ code: BatchErrorCode.MAX_DOWNLOAD_ATTEMPTS }));
|
|
264
421
|
}
|
|
265
|
-
this.state = {
|
|
422
|
+
this.state = {
|
|
423
|
+
status: BatchStatus.AwaitingDownload,
|
|
424
|
+
blocks: this.state.blocks,
|
|
425
|
+
payloadEnvelopes: this.state.payloadEnvelopes,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Downloading -> AwaitingDownload (without counting as a failed attempt).
|
|
430
|
+
* Used when the peer rate-limited us — the request was never actually served.
|
|
431
|
+
*/
|
|
432
|
+
downloadingRateLimited() {
|
|
433
|
+
if (this.state.status !== BatchStatus.Downloading) {
|
|
434
|
+
throw new BatchError(this.wrongStatusErrorType(BatchStatus.Downloading));
|
|
435
|
+
}
|
|
436
|
+
this.state = {
|
|
437
|
+
status: BatchStatus.AwaitingDownload,
|
|
438
|
+
blocks: this.state.blocks,
|
|
439
|
+
payloadEnvelopes: this.state.payloadEnvelopes,
|
|
440
|
+
};
|
|
266
441
|
}
|
|
267
442
|
/**
|
|
268
443
|
* AwaitingProcessing -> Processing
|
|
@@ -272,13 +447,14 @@ export class Batch {
|
|
|
272
447
|
throw new BatchError(this.wrongStatusErrorType(BatchStatus.AwaitingProcessing));
|
|
273
448
|
}
|
|
274
449
|
const blocks = this.state.blocks;
|
|
450
|
+
const payloadEnvelopes = this.state.payloadEnvelopes;
|
|
275
451
|
const hash = hashBlocks(blocks, this.config); // tracks blocks to report peer on processing error
|
|
276
452
|
// Reset goodPeers in case another download attempt needs to be made. When Attempt is successful or not the peers
|
|
277
453
|
// that the data came from will be handled by the Attempt that goes for processing
|
|
278
454
|
const peers = this.goodPeers;
|
|
279
455
|
this.goodPeers = [];
|
|
280
|
-
this.state = { status: BatchStatus.Processing, blocks, attempt: { peers, hash } };
|
|
281
|
-
return blocks;
|
|
456
|
+
this.state = { status: BatchStatus.Processing, blocks, payloadEnvelopes, attempt: { peers, hash } };
|
|
457
|
+
return { blocks, payloadEnvelopes, peers };
|
|
282
458
|
}
|
|
283
459
|
/**
|
|
284
460
|
* Processing -> AwaitingValidation
|
|
@@ -287,7 +463,12 @@ export class Batch {
|
|
|
287
463
|
if (this.state.status !== BatchStatus.Processing) {
|
|
288
464
|
throw new BatchError(this.wrongStatusErrorType(BatchStatus.Processing));
|
|
289
465
|
}
|
|
290
|
-
this.state = {
|
|
466
|
+
this.state = {
|
|
467
|
+
status: BatchStatus.AwaitingValidation,
|
|
468
|
+
blocks: this.state.blocks,
|
|
469
|
+
payloadEnvelopes: this.state.payloadEnvelopes,
|
|
470
|
+
attempt: this.state.attempt,
|
|
471
|
+
};
|
|
291
472
|
}
|
|
292
473
|
/**
|
|
293
474
|
* Processing -> AwaitingDownload
|
|
@@ -333,7 +514,7 @@ export class Batch {
|
|
|
333
514
|
}
|
|
334
515
|
// remove any downloaded blocks and re-attempt
|
|
335
516
|
// TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
|
|
336
|
-
this.state = { status: BatchStatus.AwaitingDownload, blocks: [] };
|
|
517
|
+
this.state = { status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null };
|
|
337
518
|
}
|
|
338
519
|
onProcessingError(attempt) {
|
|
339
520
|
this.failedProcessingAttempts.push(attempt);
|
|
@@ -342,11 +523,11 @@ export class Batch {
|
|
|
342
523
|
}
|
|
343
524
|
// remove any downloaded blocks and re-attempt
|
|
344
525
|
// TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
|
|
345
|
-
this.state = { status: BatchStatus.AwaitingDownload, blocks: [] };
|
|
526
|
+
this.state = { status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null };
|
|
346
527
|
}
|
|
347
528
|
/** Helper to construct typed BatchError. Stack traces are correct as the error is thrown above */
|
|
348
529
|
errorType(type) {
|
|
349
|
-
return { ...type,
|
|
530
|
+
return { ...type, startEpoch: this.startEpoch, status: this.state.status };
|
|
350
531
|
}
|
|
351
532
|
wrongStatusErrorType(expectedStatus) {
|
|
352
533
|
return this.errorType({ code: BatchErrorCode.WRONG_STATUS, expectedStatus });
|