@lodestar/beacon-node 1.43.0-dev.aef3645690 → 1.43.0-dev.b05ea98d04
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 -5
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +1 -1
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +1 -2
- package/lib/chain/GetBlobsTracker.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 +2 -4
- 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 +38 -58
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +28 -14
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +89 -89
- 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 +59 -26
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +7 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +29 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.js +7 -5
- package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +16 -21
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts +23 -2
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +89 -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 +79 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +30 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
- 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 +46 -50
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +16 -15
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +5 -4
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +8 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +4 -0
- package/lib/chain/errors/attestationError.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 +11 -15
- 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 +47 -23
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -9
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +5 -32
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +13 -8
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +68 -25
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/errors.d.ts +1 -11
- package/lib/chain/regen/errors.d.ts.map +1 -1
- package/lib/chain/regen/errors.js +0 -2
- package/lib/chain/regen/errors.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +7 -12
- 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 +6 -11
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +9 -44
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +0 -5
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +8 -38
- 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 +22 -6
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +53 -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/stateCache/datastore/db.d.ts +5 -4
- package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +10 -32
- package/lib/chain/stateCache/datastore/db.js.map +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/file.js +5 -5
- package/lib/chain/stateCache/datastore/file.js.map +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +8 -15
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +12 -0
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +12 -0
- package/lib/chain/validation/attestation.js.map +1 -1
- 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 +21 -11
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +4 -3
- package/lib/chain/validation/payloadAttestationMessage.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 +1 -0
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +60 -22
- 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/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/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +6 -4
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/constants.d.ts +3 -1
- package/lib/sync/constants.d.ts.map +1 -1
- package/lib/sync/constants.js +3 -4
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/range/batch.d.ts +28 -2
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +146 -44
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +12 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +53 -9
- 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 +17 -6
- package/lib/sync/range/range.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 +22 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +604 -53
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +46 -10
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +162 -24
- 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/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 +84 -6
- package/src/chain/GetBlobsTracker.ts +1 -2
- package/src/chain/archiveStore/archiveStore.ts +5 -5
- package/src/chain/archiveStore/interface.ts +4 -4
- package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +6 -8
- package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
- package/src/chain/blocks/blockInput/blockInput.ts +4 -1
- package/src/chain/blocks/importBlock.ts +38 -83
- package/src/chain/blocks/importExecutionPayload.ts +110 -102
- package/src/chain/blocks/index.ts +74 -24
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
- package/src/chain/blocks/payloadEnvelopeProcessor.ts +7 -6
- package/src/chain/blocks/types.ts +16 -26
- package/src/chain/blocks/utils/chainSegment.ts +114 -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 +134 -0
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +41 -0
- package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
- package/src/chain/chain.ts +63 -72
- package/src/chain/emitter.ts +15 -14
- package/src/chain/errors/attestationError.ts +6 -1
- 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 +8 -20
- 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 +55 -24
- package/src/chain/produceBlock/computeNewStateRoot.ts +6 -43
- package/src/chain/produceBlock/produceBlockBody.ts +91 -27
- package/src/chain/regen/errors.ts +1 -6
- package/src/chain/regen/interface.ts +7 -12
- package/src/chain/regen/queued.ts +14 -55
- package/src/chain/regen/regen.ts +10 -43
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +71 -20
- package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
- package/src/chain/stateCache/datastore/db.ts +10 -33
- package/src/chain/stateCache/datastore/file.ts +5 -6
- package/src/chain/stateCache/datastore/types.ts +2 -3
- package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
- package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
- package/src/chain/stateCache/types.ts +8 -14
- package/src/chain/validation/aggregateAndProof.ts +13 -0
- package/src/chain/validation/attestation.ts +13 -0
- package/src/chain/validation/block.ts +1 -0
- package/src/chain/validation/executionPayloadBid.ts +25 -8
- package/src/chain/validation/executionPayloadEnvelope.ts +22 -12
- package/src/chain/validation/payloadAttestationMessage.ts +5 -3
- 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 +1 -0
- package/src/network/network.ts +12 -1
- package/src/network/processor/gossipHandlers.ts +79 -27
- package/src/network/processor/gossipQueues/index.ts +5 -0
- package/src/network/processor/index.ts +6 -5
- 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/node/nodejs.ts +6 -4
- package/src/sync/constants.ts +4 -4
- package/src/sync/range/batch.ts +204 -49
- package/src/sync/range/chain.ts +69 -11
- package/src/sync/range/range.ts +18 -6
- package/src/sync/types.ts +72 -0
- package/src/sync/unknownBlock.ts +762 -57
- package/src/sync/utils/downloadByRange.ts +272 -39
- package/src/sync/utils/downloadByRoot.ts +24 -2
- package/src/sync/utils/pendingBlocksTree.ts +0 -15
- package/src/util/sszBytes.ts +25 -5
|
@@ -2,7 +2,7 @@ import {routes} from "@lodestar/api";
|
|
|
2
2
|
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
3
|
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
4
4
|
import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
|
|
5
|
-
import {
|
|
5
|
+
import {CheckpointHex} from "../stateCache/types.js";
|
|
6
6
|
|
|
7
7
|
export enum RegenCaller {
|
|
8
8
|
getDuties = "getDuties",
|
|
@@ -21,6 +21,7 @@ export enum RegenCaller {
|
|
|
21
21
|
validateGossipAttestation = "validateGossipAttestation",
|
|
22
22
|
validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
|
|
23
23
|
validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
|
|
24
|
+
validateGossipProposerPreferences = "validateGossipProposerPreferences",
|
|
24
25
|
onForkChoiceFinalized = "onForkChoiceFinalized",
|
|
25
26
|
restApi = "restApi",
|
|
26
27
|
}
|
|
@@ -40,21 +41,15 @@ export interface IStateRegenerator extends IStateRegeneratorInternal {
|
|
|
40
41
|
dumpCacheSummary(): routes.lodestar.StateCacheItem[];
|
|
41
42
|
getStateSync(stateRoot: RootHex): IBeaconStateView | null;
|
|
42
43
|
getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
|
|
43
|
-
getCheckpointStateOrBytes(cp:
|
|
44
|
-
getCheckpointStateSync(cp:
|
|
44
|
+
getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>;
|
|
45
|
+
getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
|
|
45
46
|
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
|
|
46
47
|
pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
|
|
47
48
|
pruneOnFinalized(finalizedEpoch: Epoch): void;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* payloadPresent is true if this is payload state, false if block state.
|
|
52
|
-
* payloadPresent is always true for pre-gloas.
|
|
53
|
-
*/
|
|
54
|
-
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void;
|
|
49
|
+
processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
|
|
50
|
+
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
|
|
55
51
|
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
|
|
56
|
-
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch
|
|
57
|
-
upgradeForGloas(epoch: Epoch): void;
|
|
52
|
+
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null;
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
-
import {IForkChoice,
|
|
2
|
+
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
3
|
import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
|
-
import {BeaconBlock, Epoch, RootHex, Slot,
|
|
5
|
-
import {Logger,
|
|
4
|
+
import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
|
|
5
|
+
import {Logger, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {Metrics} from "../../metrics/index.js";
|
|
7
7
|
import {JobItemQueue} from "../../util/queue/index.js";
|
|
8
|
-
import {BlockStateCache,
|
|
8
|
+
import {BlockStateCache, CheckpointHex, CheckpointStateCache} from "../stateCache/types.js";
|
|
9
9
|
import {RegenError, RegenErrorCode} from "./errors.js";
|
|
10
10
|
import {
|
|
11
11
|
IStateRegenerator,
|
|
@@ -88,12 +88,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
88
88
|
*/
|
|
89
89
|
getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
|
|
90
90
|
const parentRoot = toRootHex(block.parentRoot);
|
|
91
|
-
const parentBlock =
|
|
92
|
-
? this.forkChoice.getBlockHexAndBlockHash(
|
|
93
|
-
parentRoot,
|
|
94
|
-
toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
|
|
95
|
-
)
|
|
96
|
-
: this.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
91
|
+
const parentBlock = this.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
97
92
|
if (!parentBlock) {
|
|
98
93
|
throw new RegenError({
|
|
99
94
|
code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
|
|
@@ -104,19 +99,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
104
99
|
const parentEpoch = computeEpochAtSlot(parentBlock.slot);
|
|
105
100
|
const blockEpoch = computeEpochAtSlot(block.slot);
|
|
106
101
|
|
|
107
|
-
// Convert PayloadStatus to payloadPresent boolean
|
|
108
|
-
if (parentBlock.payloadStatus === PayloadStatus.PENDING) {
|
|
109
|
-
throw new RegenError({
|
|
110
|
-
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
111
|
-
blockRoot: block.parentRoot,
|
|
112
|
-
payloadStatus: parentBlock.payloadStatus,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
const payloadPresent = parentBlock.payloadStatus === PayloadStatus.FULL;
|
|
116
|
-
|
|
117
102
|
// Check the checkpoint cache (if the pre-state is a checkpoint state)
|
|
118
103
|
if (parentEpoch < blockEpoch) {
|
|
119
|
-
const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch
|
|
104
|
+
const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch);
|
|
120
105
|
if (checkpointState && computeEpochAtSlot(checkpointState.slot) === blockEpoch) {
|
|
121
106
|
return checkpointState;
|
|
122
107
|
}
|
|
@@ -135,14 +120,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
135
120
|
return null;
|
|
136
121
|
}
|
|
137
122
|
|
|
138
|
-
async getCheckpointStateOrBytes(cp:
|
|
123
|
+
async getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null> {
|
|
139
124
|
return this.checkpointStateCache.getStateOrBytes(cp);
|
|
140
125
|
}
|
|
141
126
|
|
|
142
127
|
/**
|
|
143
128
|
* Get checkpoint state from cache
|
|
144
129
|
*/
|
|
145
|
-
getCheckpointStateSync(cp:
|
|
130
|
+
getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null {
|
|
146
131
|
return this.checkpointStateCache.get(cp);
|
|
147
132
|
}
|
|
148
133
|
|
|
@@ -150,19 +135,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
150
135
|
* Get state closest to head
|
|
151
136
|
*/
|
|
152
137
|
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
|
|
153
|
-
|
|
154
|
-
if (head.payloadStatus === PayloadStatus.PENDING) {
|
|
155
|
-
throw new RegenError({
|
|
156
|
-
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
157
|
-
blockRoot: fromHex(head.blockRoot),
|
|
158
|
-
payloadStatus: head.payloadStatus,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
const payloadPresent = head.payloadStatus === PayloadStatus.FULL;
|
|
162
|
-
return (
|
|
163
|
-
this.checkpointStateCache.getLatest(head.blockRoot, Infinity, payloadPresent) ||
|
|
164
|
-
this.blockStateCache.get(head.stateRoot)
|
|
165
|
-
);
|
|
138
|
+
return this.checkpointStateCache.getLatest(head.blockRoot, Infinity) || this.blockStateCache.get(head.stateRoot);
|
|
166
139
|
}
|
|
167
140
|
|
|
168
141
|
pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
|
|
@@ -175,24 +148,15 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
175
148
|
this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
|
|
176
149
|
}
|
|
177
150
|
|
|
178
|
-
|
|
151
|
+
processState(blockRootHex: RootHex, postState: IBeaconStateView): void {
|
|
179
152
|
this.blockStateCache.add(postState);
|
|
180
153
|
this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
|
|
181
154
|
this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
|
|
182
155
|
});
|
|
183
156
|
}
|
|
184
157
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*/
|
|
188
|
-
processPayloadState(payloadState: IBeaconStateView): void {
|
|
189
|
-
// Add payload state to block state cache (keyed by payload state root)
|
|
190
|
-
this.blockStateCache.add(payloadState);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// TODO GLOAS: This should also be called when importing execution payload after we implement it
|
|
194
|
-
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
|
|
195
|
-
this.checkpointStateCache.add(cp, item, payloadPresent);
|
|
158
|
+
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void {
|
|
159
|
+
this.checkpointStateCache.add(cp, item);
|
|
196
160
|
}
|
|
197
161
|
|
|
198
162
|
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
|
|
@@ -228,13 +192,8 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
228
192
|
}
|
|
229
193
|
}
|
|
230
194
|
|
|
231
|
-
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch
|
|
232
|
-
return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
upgradeForGloas(epoch: Epoch): void {
|
|
236
|
-
this.logger.verbose("Upgrading block state cache for Gloas fork", {epoch});
|
|
237
|
-
this.blockStateCache.upgradeToGloas();
|
|
195
|
+
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null {
|
|
196
|
+
return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
|
|
238
197
|
}
|
|
239
198
|
|
|
240
199
|
/**
|
package/src/chain/regen/regen.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {IForkChoice,
|
|
3
|
-
import {
|
|
2
|
+
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
4
|
import {
|
|
5
5
|
DataAvailabilityStatus,
|
|
6
6
|
ExecutionPayloadStatus,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
computeEpochAtSlot,
|
|
10
10
|
computeStartSlotAtEpoch,
|
|
11
11
|
} from "@lodestar/state-transition";
|
|
12
|
-
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot
|
|
12
|
+
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
|
|
13
13
|
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
14
14
|
import {IBeaconDb} from "../../db/index.js";
|
|
15
15
|
import {Metrics} from "../../metrics/index.js";
|
|
@@ -57,12 +57,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
57
57
|
regenCaller: RegenCaller
|
|
58
58
|
): Promise<IBeaconStateView> {
|
|
59
59
|
const parentRoot = toRootHex(block.parentRoot);
|
|
60
|
-
const parentBlock =
|
|
61
|
-
? this.modules.forkChoice.getBlockHexAndBlockHash(
|
|
62
|
-
parentRoot,
|
|
63
|
-
toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
|
|
64
|
-
)
|
|
65
|
-
: this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
60
|
+
const parentBlock = this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
66
61
|
if (!parentBlock) {
|
|
67
62
|
throw new RegenError({
|
|
68
63
|
code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
|
|
@@ -110,19 +105,9 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
110
105
|
const {checkpointStateCache} = this.modules;
|
|
111
106
|
const epoch = computeEpochAtSlot(slot);
|
|
112
107
|
|
|
113
|
-
// Convert PayloadStatus to payloadPresent boolean
|
|
114
|
-
if (block.payloadStatus === PayloadStatus.PENDING) {
|
|
115
|
-
throw new RegenError({
|
|
116
|
-
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
117
|
-
blockRoot: fromHex(blockRoot),
|
|
118
|
-
payloadStatus: block.payloadStatus,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const payloadPresent = block.payloadStatus === PayloadStatus.FULL;
|
|
122
|
-
|
|
123
108
|
const latestCheckpointStateCtx = allowDiskReload
|
|
124
|
-
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch
|
|
125
|
-
: checkpointStateCache.getLatest(blockRoot, epoch
|
|
109
|
+
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch)
|
|
110
|
+
: checkpointStateCache.getLatest(blockRoot, epoch);
|
|
126
111
|
|
|
127
112
|
// If a checkpoint state exists with the given checkpoint root, it either is in requested epoch
|
|
128
113
|
// or needs to have empty slots processed until the requested epoch
|
|
@@ -176,18 +161,9 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
176
161
|
if (!lastBlockToReplay) continue;
|
|
177
162
|
const epoch = computeEpochAtSlot(lastBlockToReplay.slot - 1);
|
|
178
163
|
|
|
179
|
-
// Convert PayloadStatus to payloadPresent boolean
|
|
180
|
-
if (b.payloadStatus === PayloadStatus.PENDING) {
|
|
181
|
-
throw new RegenError({
|
|
182
|
-
code: RegenErrorCode.INTERNAL_ERROR,
|
|
183
|
-
message: `Unexpected PENDING payloadStatus for ancestor block ${b.blockRoot} at slot ${b.slot}`,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
const payloadPresent = b.payloadStatus === PayloadStatus.FULL;
|
|
187
|
-
|
|
188
164
|
state = allowDiskReload
|
|
189
|
-
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch
|
|
190
|
-
: checkpointStateCache.getLatest(b.blockRoot, epoch
|
|
165
|
+
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch)
|
|
166
|
+
: checkpointStateCache.getLatest(b.blockRoot, epoch);
|
|
191
167
|
if (state) {
|
|
192
168
|
break;
|
|
193
169
|
}
|
|
@@ -351,11 +327,6 @@ async function processSlotsByCheckpoint(
|
|
|
351
327
|
* emitting "checkpoint" events after every epoch processed.
|
|
352
328
|
*
|
|
353
329
|
* Stops processing after no more full epochs can be processed.
|
|
354
|
-
*
|
|
355
|
-
* Output state variant:
|
|
356
|
-
* - Post-Gloas: If slots are processed, returns block state (payloadPresent=false).
|
|
357
|
-
* If no slots processed, returns preState as-is (preserves variant).
|
|
358
|
-
* - Pre-Gloas: Always payloadPresent=true (no block/payload distinction).
|
|
359
330
|
*/
|
|
360
331
|
export async function processSlotsToNearestCheckpoint(
|
|
361
332
|
modules: {
|
|
@@ -375,7 +346,7 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
375
346
|
const postSlot = slot;
|
|
376
347
|
const preEpoch = computeEpochAtSlot(preSlot);
|
|
377
348
|
let postState = preState;
|
|
378
|
-
const {
|
|
349
|
+
const {checkpointStateCache, emitter, metrics, logger} = modules;
|
|
379
350
|
let count = 0;
|
|
380
351
|
|
|
381
352
|
for (
|
|
@@ -399,11 +370,7 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
399
370
|
// This may becomes the "official" checkpoint state if the 1st block of epoch is skipped
|
|
400
371
|
const checkpointState = postState;
|
|
401
372
|
const cp = getCheckpointFromState(checkpointState);
|
|
402
|
-
|
|
403
|
-
// Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
|
|
404
|
-
// Post-Gloas: result is a block state (payloadPresent=false)
|
|
405
|
-
const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
|
|
406
|
-
checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
|
|
373
|
+
checkpointStateCache.add(cp, checkpointState);
|
|
407
374
|
// consumers should not mutate state ever
|
|
408
375
|
emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
|
|
409
376
|
|
|
@@ -5,3 +5,4 @@ export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
|
5
5
|
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
6
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
7
7
|
export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
|
|
8
|
+
export {SeenProposerPreferences} from "./seenProposerPreferences.js";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
2
3
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
4
|
import {RootHex} from "@lodestar/types";
|
|
4
5
|
import {Logger} from "@lodestar/utils";
|
|
5
6
|
import {Metrics} from "../../metrics/metrics.js";
|
|
7
|
+
import {IClock} from "../../util/clock.js";
|
|
6
8
|
import {SerializedCache} from "../../util/serializedCache.js";
|
|
9
|
+
import {isDaOutOfRange} from "../blocks/blockInput/index.js";
|
|
7
10
|
import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
8
11
|
import {ChainEvent, ChainEventEmitter} from "../emitter.js";
|
|
9
12
|
|
|
@@ -11,6 +14,9 @@ export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/ind
|
|
|
11
14
|
export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
12
15
|
|
|
13
16
|
export type SeenPayloadEnvelopeInputModules = {
|
|
17
|
+
config: ChainForkConfig;
|
|
18
|
+
clock: IClock;
|
|
19
|
+
forkChoice: IForkChoice;
|
|
14
20
|
chainEvents: ChainEventEmitter;
|
|
15
21
|
signal: AbortSignal;
|
|
16
22
|
serializedCache: SerializedCache;
|
|
@@ -21,10 +27,20 @@ export type SeenPayloadEnvelopeInputModules = {
|
|
|
21
27
|
/**
|
|
22
28
|
* Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
|
|
23
29
|
*
|
|
24
|
-
* Created during block import when a block is processed.
|
|
25
|
-
*
|
|
30
|
+
* Created during block import when a block is processed. Two pruning paths:
|
|
31
|
+
* - `prepareNextSlot` calls `pruneBelow(headParentSlot)` every slot once the head we'll build
|
|
32
|
+
* on is known.
|
|
33
|
+
* - `onFinalized` calls `pruneBelow(finalizedSlot)` on every finalization for bulk cleanup.
|
|
34
|
+
*
|
|
35
|
+
* Steady state (linear chain, healthy progression): the cache holds ~2 entries — the head
|
|
36
|
+
* (parent for next-slot production) and its parent (proposer-boost-reorg fallback). It can
|
|
37
|
+
* transiently hold more during forks, range-sync bursts, or when `prepareNextSlot` skips
|
|
38
|
+
* ticks; subsequent ticks settle it back.
|
|
26
39
|
*/
|
|
27
40
|
export class SeenPayloadEnvelopeInput {
|
|
41
|
+
private readonly config: ChainForkConfig;
|
|
42
|
+
private readonly clock: IClock;
|
|
43
|
+
private readonly forkChoice: IForkChoice;
|
|
28
44
|
private readonly chainEvents: ChainEventEmitter;
|
|
29
45
|
private readonly signal: AbortSignal;
|
|
30
46
|
private readonly serializedCache: SerializedCache;
|
|
@@ -32,7 +48,19 @@ export class SeenPayloadEnvelopeInput {
|
|
|
32
48
|
private readonly logger?: Logger;
|
|
33
49
|
private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
|
|
34
50
|
|
|
35
|
-
constructor({
|
|
51
|
+
constructor({
|
|
52
|
+
config,
|
|
53
|
+
clock,
|
|
54
|
+
forkChoice,
|
|
55
|
+
chainEvents,
|
|
56
|
+
signal,
|
|
57
|
+
serializedCache,
|
|
58
|
+
metrics,
|
|
59
|
+
logger,
|
|
60
|
+
}: SeenPayloadEnvelopeInputModules) {
|
|
61
|
+
this.config = config;
|
|
62
|
+
this.clock = clock;
|
|
63
|
+
this.forkChoice = forkChoice;
|
|
36
64
|
this.chainEvents = chainEvents;
|
|
37
65
|
this.signal = signal;
|
|
38
66
|
this.serializedCache = serializedCache;
|
|
@@ -51,14 +79,13 @@ export class SeenPayloadEnvelopeInput {
|
|
|
51
79
|
});
|
|
52
80
|
}
|
|
53
81
|
|
|
54
|
-
this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.
|
|
82
|
+
this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
|
|
55
83
|
this.signal.addEventListener("abort", () => {
|
|
56
|
-
this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.
|
|
84
|
+
this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
|
|
57
85
|
});
|
|
58
86
|
}
|
|
59
87
|
|
|
60
|
-
private
|
|
61
|
-
// Prune all entries with slot < finalized slot
|
|
88
|
+
private pruneFinalized = (checkpoint: CheckpointWithHex): void => {
|
|
62
89
|
const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
|
|
63
90
|
let deletedCount = 0;
|
|
64
91
|
for (const [, input] of this.payloadInputs) {
|
|
@@ -67,16 +94,32 @@ export class SeenPayloadEnvelopeInput {
|
|
|
67
94
|
deletedCount++;
|
|
68
95
|
}
|
|
69
96
|
}
|
|
70
|
-
|
|
97
|
+
|
|
98
|
+
this.logger?.debug("SeenPayloadEnvelopeInput.pruneFinalized deleted entries", {
|
|
99
|
+
finalizedSlot,
|
|
100
|
+
finalizedRoot: checkpoint.rootHex,
|
|
101
|
+
deletedCount,
|
|
102
|
+
});
|
|
71
103
|
};
|
|
72
104
|
|
|
73
|
-
add(props: CreateFromBlockProps): PayloadEnvelopeInput {
|
|
74
|
-
|
|
75
|
-
|
|
105
|
+
add(props: Omit<CreateFromBlockProps, "daOutOfRange">): PayloadEnvelopeInput {
|
|
106
|
+
const existing = this.payloadInputs.get(props.blockRootHex);
|
|
107
|
+
if (existing !== undefined) {
|
|
108
|
+
this.logger?.verbose("SeenPayloadEnvelopeInput.add reused existing entry", {
|
|
109
|
+
slot: existing.slot,
|
|
110
|
+
root: props.blockRootHex,
|
|
111
|
+
});
|
|
112
|
+
return existing;
|
|
76
113
|
}
|
|
77
|
-
const
|
|
114
|
+
const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.block.message.slot, this.clock.currentEpoch);
|
|
115
|
+
const input = PayloadEnvelopeInput.createFromBlock({...props, daOutOfRange});
|
|
78
116
|
this.payloadInputs.set(props.blockRootHex, input);
|
|
79
117
|
this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
|
|
118
|
+
this.logger?.verbose("SeenPayloadEnvelopeInput.add created new entry", {
|
|
119
|
+
slot: input.slot,
|
|
120
|
+
root: props.blockRootHex,
|
|
121
|
+
daOutOfRange,
|
|
122
|
+
});
|
|
80
123
|
return input;
|
|
81
124
|
}
|
|
82
125
|
|
|
@@ -88,17 +131,25 @@ export class SeenPayloadEnvelopeInput {
|
|
|
88
131
|
return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
|
|
89
132
|
}
|
|
90
133
|
|
|
91
|
-
prune(blockRootHex: RootHex): void {
|
|
92
|
-
const payloadInput = this.payloadInputs.get(blockRootHex);
|
|
93
|
-
if (payloadInput) {
|
|
94
|
-
this.evictPayloadInput(payloadInput);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
134
|
size(): number {
|
|
99
135
|
return this.payloadInputs.size;
|
|
100
136
|
}
|
|
101
137
|
|
|
138
|
+
pruneBelowParent(parentBlock: ProtoBlock): void {
|
|
139
|
+
for (const block of this.forkChoice.getAllAncestorBlocks(parentBlock.blockRoot, parentBlock.payloadStatus)) {
|
|
140
|
+
if (block.slot < parentBlock.slot) {
|
|
141
|
+
const input = this.payloadInputs.get(block.blockRoot);
|
|
142
|
+
if (input) {
|
|
143
|
+
this.evictPayloadInput(input);
|
|
144
|
+
this.logger?.verbose("SeenPayloadEnvelopeInput.pruneBelowParent deleted", {
|
|
145
|
+
slot: block.slot,
|
|
146
|
+
root: block.blockRoot,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
102
153
|
private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
|
|
103
154
|
this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
|
|
104
155
|
this.payloadInputs.delete(payloadInput.blockRootHex);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
|
|
6
|
+
*/
|
|
7
|
+
export class SeenProposerPreferences {
|
|
8
|
+
private readonly validatorByDependentRootBySlot = new MapDef<Slot, Map<RootHex, ValidatorIndex>>(
|
|
9
|
+
() => new Map<RootHex, ValidatorIndex>()
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
isKnown(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
|
|
13
|
+
return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
add(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
|
|
17
|
+
this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
|
|
22
|
+
* passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
|
|
23
|
+
* on each slot tick.
|
|
24
|
+
*/
|
|
25
|
+
prune(currentSlot: Slot): void {
|
|
26
|
+
for (const slot of this.validatorByDependentRootBySlot.keys()) {
|
|
27
|
+
if (slot < currentSlot) {
|
|
28
|
+
this.validatorByDependentRootBySlot.delete(slot);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
2
|
import {Epoch, phase0, ssz} from "@lodestar/types";
|
|
3
|
-
import {MapDef
|
|
3
|
+
import {MapDef} from "@lodestar/utils";
|
|
4
4
|
import {IBeaconDb} from "../../../db/interface.js";
|
|
5
5
|
import {
|
|
6
6
|
getLastProcessedSlotFromBeaconStateSerialized,
|
|
@@ -14,8 +14,8 @@ import {CPStateDatastore, DatastoreKey} from "./types.js";
|
|
|
14
14
|
export class DbCPStateDatastore implements CPStateDatastore {
|
|
15
15
|
constructor(private readonly db: IBeaconDb) {}
|
|
16
16
|
|
|
17
|
-
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array
|
|
18
|
-
const serializedCheckpoint = checkpointToDatastoreKey(cpKey
|
|
17
|
+
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
|
|
18
|
+
const serializedCheckpoint = checkpointToDatastoreKey(cpKey);
|
|
19
19
|
await this.db.checkpointState.putBinary(serializedCheckpoint, stateBytes);
|
|
20
20
|
return serializedCheckpoint;
|
|
21
21
|
}
|
|
@@ -40,30 +40,18 @@ export class DbCPStateDatastore implements CPStateDatastore {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function extractCheckpointBytes(key: DatastoreKey): Uint8Array {
|
|
44
|
-
const fixedSize = ssz.phase0.Checkpoint.minSize;
|
|
45
|
-
return key.subarray(0, fixedSize);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
43
|
export function datastoreKeyToCheckpoint(key: DatastoreKey): phase0.Checkpoint {
|
|
49
|
-
return ssz.phase0.Checkpoint.deserialize(
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function checkpointToDatastoreKey(cp: phase0.Checkpoint, payloadPresent: boolean): DatastoreKey {
|
|
53
|
-
const cpBytes = ssz.phase0.Checkpoint.serialize(cp);
|
|
54
|
-
const key = new Uint8Array(cpBytes.length + 1);
|
|
55
|
-
key.set(cpBytes);
|
|
56
|
-
key[cpBytes.length] = payloadPresent ? 1 : 0;
|
|
57
|
-
return key;
|
|
44
|
+
return ssz.phase0.Checkpoint.deserialize(key);
|
|
58
45
|
}
|
|
59
46
|
|
|
60
|
-
function
|
|
61
|
-
return
|
|
47
|
+
export function checkpointToDatastoreKey(cp: phase0.Checkpoint): DatastoreKey {
|
|
48
|
+
return ssz.phase0.Checkpoint.serialize(cp);
|
|
62
49
|
}
|
|
63
50
|
|
|
64
51
|
/**
|
|
65
|
-
* Get the latest
|
|
66
|
-
* -
|
|
52
|
+
* Get the latest safe checkpoint state the node can use to boot from
|
|
53
|
+
* - it should be the checkpoint state that's unique in its epoch
|
|
54
|
+
* - its last processed block slot should be at epoch boundary or last slot of previous epoch
|
|
67
55
|
* - state slot should be at epoch boundary
|
|
68
56
|
* - state slot should be equal to epoch * SLOTS_PER_EPOCH
|
|
69
57
|
*
|
|
@@ -82,20 +70,9 @@ export async function getLatestSafeDatastoreKey(
|
|
|
82
70
|
|
|
83
71
|
const dataStoreKeyByEpoch: Map<Epoch, DatastoreKey> = new Map();
|
|
84
72
|
for (const [epoch, keys] of checkpointsByEpoch.entries()) {
|
|
73
|
+
// only consider epochs with a single checkpoint to avoid ambiguity from forks
|
|
85
74
|
if (keys.length === 1) {
|
|
86
|
-
// PRCS (skipped slot) or CRCS and no payloadPresent
|
|
87
|
-
// Pre-gloas always fall into this case
|
|
88
75
|
dataStoreKeyByEpoch.set(epoch, keys[0]);
|
|
89
|
-
} else if (keys.length === 2) {
|
|
90
|
-
// CRCS without payload and CRCS with payload
|
|
91
|
-
// ie Two keys for the same checkpoint with different payloadPresent suffix (FULL/EMPTY)
|
|
92
|
-
// TODO GLOAS: Here we pick FULL key, there is a chance that payload is orphaned hence we not be able to sync
|
|
93
|
-
const cp0 = extractCheckpointBytes(keys[0]);
|
|
94
|
-
const cp1 = extractCheckpointBytes(keys[1]);
|
|
95
|
-
if (byteArrayEquals(cp0, cp1)) {
|
|
96
|
-
const fullKey = isPayloadCheckpointState(keys[0]) ? keys[0] : keys[1];
|
|
97
|
-
dataStoreKeyByEpoch.set(epoch, fullKey);
|
|
98
|
-
}
|
|
99
76
|
}
|
|
100
77
|
}
|
|
101
78
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {phase0} from "@lodestar/types";
|
|
2
|
+
import {phase0, ssz} from "@lodestar/types";
|
|
3
3
|
import {fromHex, toHex} from "@lodestar/utils";
|
|
4
4
|
import {ensureDir, readFile, readFileNames, removeFile, writeIfNotExist} from "../../../util/file.js";
|
|
5
|
-
import {
|
|
5
|
+
import {getLatestSafeDatastoreKey} from "./db.js";
|
|
6
6
|
import {CPStateDatastore, DatastoreKey} from "./types.js";
|
|
7
7
|
|
|
8
8
|
const CHECKPOINT_STATES_FOLDER = "checkpoint_states";
|
|
9
|
-
|
|
10
|
-
const CHECKPOINT_FILE_NAME_LENGTH = 84;
|
|
9
|
+
const CHECKPOINT_FILE_NAME_LENGTH = 82;
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Implementation of CPStateDatastore using file system, this is beneficial for debugging.
|
|
@@ -29,8 +28,8 @@ export class FileCPStateDatastore implements CPStateDatastore {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array
|
|
33
|
-
const serializedCheckpoint =
|
|
31
|
+
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
|
|
32
|
+
const serializedCheckpoint = ssz.phase0.Checkpoint.serialize(cpKey);
|
|
34
33
|
const filePath = path.join(this.folderPath, toHex(serializedCheckpoint));
|
|
35
34
|
await writeIfNotExist(filePath, stateBytes);
|
|
36
35
|
return serializedCheckpoint;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {phase0} from "@lodestar/types";
|
|
2
2
|
|
|
3
|
-
// With db implementation, persistedKey is serialized data of a checkpoint
|
|
4
|
-
// ie a fixed size of `ssz.phase0.Checkpoint.minSize + 1`
|
|
3
|
+
// With db implementation, persistedKey is serialized data of a checkpoint
|
|
5
4
|
export type DatastoreKey = Uint8Array;
|
|
6
5
|
|
|
7
6
|
// Make this generic to support testing
|
|
8
7
|
export interface CPStateDatastore {
|
|
9
|
-
write: (cpKey: phase0.Checkpoint, stateBytes: Uint8Array
|
|
8
|
+
write: (cpKey: phase0.Checkpoint, stateBytes: Uint8Array) => Promise<DatastoreKey>;
|
|
10
9
|
remove: (key: DatastoreKey) => Promise<void>;
|
|
11
10
|
read: (key: DatastoreKey) => Promise<Uint8Array | null>;
|
|
12
11
|
readLatestSafe: () => Promise<Uint8Array | null>;
|
|
@@ -20,11 +20,6 @@ export type FIFOBlockStateCacheOpts = {
|
|
|
20
20
|
* clock slot
|
|
21
21
|
*/
|
|
22
22
|
export const DEFAULT_MAX_BLOCK_STATES = 64;
|
|
23
|
-
/**
|
|
24
|
-
* For Gloas (ePBS), each block can have two states: block state and payload state.
|
|
25
|
-
* Double the cache size to maintain the same effective block depth.
|
|
26
|
-
*/
|
|
27
|
-
export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* New implementation of BlockStateCache that keeps the most recent n states consistently
|
|
@@ -46,7 +41,7 @@ export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
|
|
|
46
41
|
* The maintained key order would be: 11 -> 13 -> 12 -> 10, and state 10 will be pruned first.
|
|
47
42
|
*/
|
|
48
43
|
export class FIFOBlockStateCache implements BlockStateCache {
|
|
49
|
-
|
|
44
|
+
readonly maxStates: number;
|
|
50
45
|
|
|
51
46
|
private readonly cache: MapTracker<string, IBeaconStateView>;
|
|
52
47
|
/**
|
|
@@ -172,10 +167,6 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
169
|
|
|
175
|
-
upgradeToGloas(): void {
|
|
176
|
-
this.maxStates = DEFAULT_MAX_BLOCK_STATES_GLOAS;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
170
|
/**
|
|
180
171
|
* No need for this implementation
|
|
181
172
|
* This is only to conform to the old api
|