@lodestar/beacon-node 1.52.0-dev.0f379f3b22 → 1.52.0-dev.119f1f9fe6
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 +18 -5
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +2 -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 +6 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +15 -8
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +4 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +9 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -17
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +6 -5
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +71 -25
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +15 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +6 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +1 -1
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
- package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
- package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +24 -7
- 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 +32 -16
- 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 +9 -1
- 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 +18 -31
- 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 +100 -9
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +9 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +39 -6
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +1 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +5 -2
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +22 -2
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +11 -2
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +15 -5
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/sync/range/batch.d.ts +10 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +29 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +17 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +60 -20
- 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 +44 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/batches.d.ts +20 -4
- package/lib/sync/range/utils/batches.d.ts.map +1 -1
- package/lib/sync/range/utils/batches.js +31 -13
- package/lib/sync/range/utils/batches.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +5 -2
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/types.d.ts +14 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +2 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +28 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +338 -26
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +22 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +55 -25
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +24 -2
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +48 -5
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/dataColumns.d.ts +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +4 -1
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/eventLoop.d.ts +3 -3
- package/lib/util/eventLoop.d.ts.map +1 -1
- package/lib/util/eventLoop.js +3 -3
- package/lib/util/eventLoop.js.map +1 -1
- package/package.json +27 -27
- package/src/api/impl/beacon/blocks/index.ts +20 -5
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/debug/index.ts +6 -2
- package/src/api/impl/validator/index.ts +17 -9
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/blocks/importExecutionPayload.ts +9 -2
- package/src/chain/blocks/index.ts +3 -31
- package/src/chain/chain.ts +104 -42
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
- package/src/chain/interface.ts +1 -1
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/validation/aggregateAndProof.ts +24 -9
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +21 -33
- package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validation/voluntaryExit.ts +44 -6
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/gossip/gossipsub.ts +6 -2
- package/src/network/network.ts +6 -2
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/network/processor/gossipHandlers.ts +15 -6
- package/src/network/processor/index.ts +7 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/sync/range/batch.ts +33 -0
- package/src/sync/range/chain.ts +72 -17
- package/src/sync/range/range.ts +57 -3
- package/src/sync/range/utils/batches.ts +38 -13
- package/src/sync/range/utils/peerBalancer.ts +4 -1
- package/src/sync/types.ts +13 -0
- package/src/sync/unknownBlock.ts +387 -28
- package/src/sync/utils/downloadByRange.ts +89 -29
- package/src/sync/utils/downloadByRoot.ts +75 -7
- package/src/util/dataColumns.ts +4 -1
- package/src/util/eventLoop.ts +3 -3
|
@@ -658,11 +658,15 @@ export function getBeaconBlockApi(
|
|
|
658
658
|
: parseInt(blockId, 10);
|
|
659
659
|
if (!Number.isNaN(slot)) {
|
|
660
660
|
const head = chain.forkChoice.getHead();
|
|
661
|
+
// The head can be the FULL variant, a block reports the status of the payload it builds on
|
|
662
|
+
const executionOptimistic = isOptimisticBlock(
|
|
663
|
+
chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head
|
|
664
|
+
);
|
|
661
665
|
|
|
662
666
|
if (slot === head.slot) {
|
|
663
667
|
return {
|
|
664
668
|
data: {root: fromHex(head.blockRoot)},
|
|
665
|
-
meta: {executionOptimistic
|
|
669
|
+
meta: {executionOptimistic, finalized: false},
|
|
666
670
|
};
|
|
667
671
|
}
|
|
668
672
|
|
|
@@ -671,7 +675,7 @@ export function getBeaconBlockApi(
|
|
|
671
675
|
return {
|
|
672
676
|
data: {root: state.getBlockRootAtSlot(slot)},
|
|
673
677
|
meta: {
|
|
674
|
-
executionOptimistic
|
|
678
|
+
executionOptimistic,
|
|
675
679
|
finalized: computeEpochAtSlot(slot) <= chain.forkChoice.getFinalizedCheckpoint().epoch,
|
|
676
680
|
},
|
|
677
681
|
};
|
|
@@ -680,7 +684,10 @@ export function getBeaconBlockApi(
|
|
|
680
684
|
const head = chain.forkChoice.getHead();
|
|
681
685
|
return {
|
|
682
686
|
data: {root: fromHex(head.blockRoot)},
|
|
683
|
-
meta: {
|
|
687
|
+
meta: {
|
|
688
|
+
executionOptimistic: isOptimisticBlock(chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head),
|
|
689
|
+
finalized: false,
|
|
690
|
+
},
|
|
684
691
|
};
|
|
685
692
|
}
|
|
686
693
|
|
|
@@ -1195,10 +1202,14 @@ export function getBeaconBlockApi(
|
|
|
1195
1202
|
data = [];
|
|
1196
1203
|
}
|
|
1197
1204
|
|
|
1205
|
+
// Post-gloas sidecars belong to the block's own payload, its FULL variant only exists once imported
|
|
1206
|
+
const payload = finalized ? null : chain.forkChoice.getBlockHex(blockRootHex, PayloadStatus.FULL);
|
|
1198
1207
|
return {
|
|
1199
1208
|
data,
|
|
1200
1209
|
meta: {
|
|
1201
|
-
executionOptimistic
|
|
1210
|
+
executionOptimistic: isForkPostGloas(fork)
|
|
1211
|
+
? !finalized && (payload === null || isOptimisticBlock(payload))
|
|
1212
|
+
: executionOptimistic,
|
|
1202
1213
|
finalized,
|
|
1203
1214
|
version: config.getForkName(block.message.slot),
|
|
1204
1215
|
},
|
|
@@ -1296,10 +1307,14 @@ export function getBeaconBlockApi(
|
|
|
1296
1307
|
blobs = [];
|
|
1297
1308
|
}
|
|
1298
1309
|
|
|
1310
|
+
// Post-gloas blobs belong to the block's own payload, its FULL variant only exists once imported
|
|
1311
|
+
const payload = finalized ? null : chain.forkChoice.getBlockHex(blockRootHex, PayloadStatus.FULL);
|
|
1299
1312
|
return {
|
|
1300
1313
|
data: blobs,
|
|
1301
1314
|
meta: {
|
|
1302
|
-
executionOptimistic
|
|
1315
|
+
executionOptimistic: isForkPostGloas(fork)
|
|
1316
|
+
? !finalized && (payload === null || isOptimisticBlock(payload))
|
|
1317
|
+
: executionOptimistic,
|
|
1303
1318
|
finalized,
|
|
1304
1319
|
},
|
|
1305
1320
|
};
|
|
@@ -75,7 +75,8 @@ export async function getStateResponseWithRegen(
|
|
|
75
75
|
const finalizedEpoch = chain.forkChoice.getFinalizedCheckpoint().epoch;
|
|
76
76
|
return {
|
|
77
77
|
state,
|
|
78
|
-
|
|
78
|
+
// The head can be the FULL variant, a state reports the status of the payload its block builds on
|
|
79
|
+
executionOptimistic: isOptimisticBlock(chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head),
|
|
79
80
|
finalized: state.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
3
|
import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
|
|
4
|
-
import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
|
4
|
+
import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
|
|
5
5
|
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
6
6
|
import {BeaconState, DataColumnSidecar, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
|
|
7
7
|
import {fromHex, toRootHex} from "@lodestar/utils";
|
|
@@ -190,12 +190,16 @@ export function getDebugApi({
|
|
|
190
190
|
dataColumnSidecars = [];
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
// Post-gloas sidecars belong to the block's own payload, its FULL variant only exists once imported
|
|
194
|
+
const payload = finalized ? null : chain.forkChoice.getBlockHex(toRootHex(blockRoot), PayloadStatus.FULL);
|
|
193
195
|
return {
|
|
194
196
|
data: (indices
|
|
195
197
|
? dataColumnSidecars.filter(({index}) => indices.includes(index))
|
|
196
198
|
: dataColumnSidecars) as DataColumnSidecars,
|
|
197
199
|
meta: {
|
|
198
|
-
executionOptimistic
|
|
200
|
+
executionOptimistic: isForkPostGloas(fork)
|
|
201
|
+
? !finalized && (payload === null || isOptimisticBlock(payload))
|
|
202
|
+
: executionOptimistic,
|
|
199
203
|
finalized,
|
|
200
204
|
version: fork,
|
|
201
205
|
},
|
|
@@ -132,8 +132,6 @@ const BLOCK_PRODUCTION_RACE_CUTOFF_BPS = 1667;
|
|
|
132
132
|
* TODO GLOAS: revisit, the block propagates faster as it only commits to a bid and the attestation deadline changed
|
|
133
133
|
*/
|
|
134
134
|
export const BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS = 1667;
|
|
135
|
-
/** Rejection message of the bid block branch when there is no viable bid to commit to */
|
|
136
|
-
const NO_BID_AVAILABLE = "No builder bid available";
|
|
137
135
|
|
|
138
136
|
type BidCandidate = {
|
|
139
137
|
signedBid: gloas.SignedExecutionPayloadBid;
|
|
@@ -409,7 +407,7 @@ export function getValidatorApi(
|
|
|
409
407
|
* Both the above scenarios could be problematic and hence validator shouldn't participate
|
|
410
408
|
* or weigh its vote on a head till it resolves to a Valid execution status.
|
|
411
409
|
* Following activities should be skipped on an Optimistic head (with Syncing status):
|
|
412
|
-
* 1. Attestation if targetRoot is optimistic
|
|
410
|
+
* 1. Attestation if the head block voted for (post-gloas the variant voted for) or the targetRoot is optimistic
|
|
413
411
|
* 2. SyncCommitteeContribution if if the root for which to produce contribution is Optimistic.
|
|
414
412
|
* 3. ProduceBlock if the parentRoot (chain's current head) is optimistic. Must be checked
|
|
415
413
|
* explicitly as only local payload production consults the EL, blinded blocks from an
|
|
@@ -1156,7 +1154,7 @@ export function getValidatorApi(
|
|
|
1156
1154
|
});
|
|
1157
1155
|
const bidBlockPromise: ReturnType<typeof chain.produceBlock> = bestBidPromise.then((candidate) => {
|
|
1158
1156
|
if (candidate === null) {
|
|
1159
|
-
throw new
|
|
1157
|
+
throw new NoBidReceived();
|
|
1160
1158
|
}
|
|
1161
1159
|
metrics?.blockProductionRequests.inc({source: ProducedBlockSource.builder});
|
|
1162
1160
|
return timed(ProducedBlockSource.builder, () =>
|
|
@@ -1270,7 +1268,7 @@ export function getValidatorApi(
|
|
|
1270
1268
|
source = ProducedBlockSource.engine;
|
|
1271
1269
|
bestResult = engineResult;
|
|
1272
1270
|
const reason =
|
|
1273
|
-
bidBlockResult.status === "rejected" &&
|
|
1271
|
+
bidBlockResult.status === "rejected" && bidBlockResult.reason instanceof NoBidReceived
|
|
1274
1272
|
? EngineBlockSelectionReason.BuilderNoBid
|
|
1275
1273
|
: bidBlockResult.status === "pending"
|
|
1276
1274
|
? EngineBlockSelectionReason.BuilderPending
|
|
@@ -1397,10 +1395,18 @@ export function getValidatorApi(
|
|
|
1397
1395
|
// After Gloas, attestation.data.index signals payload status in fork-choice:
|
|
1398
1396
|
// - 0 = EMPTY / not present, 1 = FULL / present
|
|
1399
1397
|
// - same-slot attestations must always use index = 0
|
|
1398
|
+
// Validator shouldn't vote on an optimistic head, post-gloas that is the variant voted for
|
|
1400
1399
|
if (canonicalBlock.slot !== slot) {
|
|
1401
1400
|
index = canonicalBlock.payloadStatus === PayloadStatus.FULL ? 1 : 0;
|
|
1401
|
+
if (isOptimisticBlock(canonicalBlock)) {
|
|
1402
|
+
throw new NodeIsSyncing(
|
|
1403
|
+
`Head block's execution payload not yet validated, executionPayloadBlockHash=${canonicalBlock.executionPayloadBlockHash}`
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1402
1406
|
} else {
|
|
1403
1407
|
index = 0;
|
|
1408
|
+
// Same-slot votes support the PENDING variant, which does not depend on the block's own payload
|
|
1409
|
+
notOnOptimisticBlockRoot(beaconBlockRoot);
|
|
1404
1410
|
}
|
|
1405
1411
|
} else if (isForkPostElectra(fork)) {
|
|
1406
1412
|
index = 0;
|
|
@@ -1418,8 +1424,11 @@ export function getValidatorApi(
|
|
|
1418
1424
|
headBlockRoot
|
|
1419
1425
|
: headState.getBlockRootAtSlot(targetSlot);
|
|
1420
1426
|
|
|
1421
|
-
// Check the execution status as validator shouldn't vote on an optimistic head
|
|
1422
|
-
//
|
|
1427
|
+
// Check the execution status as validator shouldn't vote on an optimistic head, post-gloas the
|
|
1428
|
+
// variant voted for is checked above. Check on target is sufficient for a valid source
|
|
1429
|
+
if (!isForkPostGloas(fork)) {
|
|
1430
|
+
notOnOptimisticBlockRoot(beaconBlockRoot);
|
|
1431
|
+
}
|
|
1423
1432
|
notOnOptimisticBlockRoot(targetRoot);
|
|
1424
1433
|
notOnOutOfRangeData(targetRoot);
|
|
1425
1434
|
|
|
@@ -2326,8 +2335,7 @@ export function getValidatorApi(
|
|
|
2326
2335
|
metrics?.inclusionListsValid.inc({source: InclusionListSource.api});
|
|
2327
2336
|
metrics?.inclusionListsValidSize.inc(totalBytes);
|
|
2328
2337
|
|
|
2329
|
-
const isTimely =
|
|
2330
|
-
secFromSlot >= 0 && secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
|
|
2338
|
+
const isTimely = secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
|
|
2331
2339
|
chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
|
|
2332
2340
|
|
|
2333
2341
|
chain.emitter.emit(routes.events.EventType.inclusionList, {
|
|
@@ -19,6 +19,11 @@ const RECONSTRUCTION_DELAY_MIN_BPS = 667;
|
|
|
19
19
|
*/
|
|
20
20
|
const RECONSTRUCTION_DELAY_MAX_BPS = 1000;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Maximum time a column request waits for a pending reconstruction, covers the delay and the recovery itself
|
|
24
|
+
*/
|
|
25
|
+
export const RECONSTRUCTED_COLUMNS_WAIT_BPS = 2500;
|
|
26
|
+
|
|
22
27
|
const QUEUE_MAX_LENGTH = 16;
|
|
23
28
|
|
|
24
29
|
export type ColumnReconstructionInput = BlockInputColumns | PayloadEnvelopeInput;
|
|
@@ -50,6 +50,15 @@ export async function getHistoricalState(
|
|
|
50
50
|
const transitionTimer = metrics?.stateTransitionTime.startTimer();
|
|
51
51
|
let blockCount = 0;
|
|
52
52
|
for await (const block of db.blockArchive.valuesStream({gt: state.slot, lte: slot})) {
|
|
53
|
+
// Pruned history keeps the genesis state but not the blocks after it, without this check the
|
|
54
|
+
// first block would only be rejected after processing every slot in between
|
|
55
|
+
if (
|
|
56
|
+
blockCount === 0 &&
|
|
57
|
+
!byteArrayEquals(block.message.parentRoot, state.computeAnchorCheckpoint().checkpoint.root)
|
|
58
|
+
) {
|
|
59
|
+
metrics?.regenErrorCount.inc({reason: RegenErrorType.blockProcessing});
|
|
60
|
+
throw Error(`Archived blocks do not extend nearest state slot=${state.slot} blockSlot=${block.message.slot}`);
|
|
61
|
+
}
|
|
53
62
|
try {
|
|
54
63
|
state = state.stateTransition(
|
|
55
64
|
{block},
|
|
@@ -284,7 +284,7 @@ export async function archiveBlocks(
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
// Delete expired data column sidecars
|
|
287
|
-
// Keep only `[
|
|
287
|
+
// Keep only `[current_epoch - max(MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, archiveDataEpochs)]`
|
|
288
288
|
if (finalizedPostFulu) {
|
|
289
289
|
if (archiveDataEpochs !== Infinity) {
|
|
290
290
|
const dataColumnSidecarsMinEpoch = getDataColumnSidecarsMinEpoch(config, currentEpoch, archiveDataEpochs);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {GENESIS_SLOT} from "@lodestar/params";
|
|
2
3
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
4
|
import {Epoch, Slot} from "@lodestar/types";
|
|
4
5
|
import {Logger, prettyPrintIndices} from "@lodestar/utils";
|
|
@@ -13,6 +14,9 @@ import {Metrics} from "../../../metrics/index.js";
|
|
|
13
14
|
*/
|
|
14
15
|
export const MAX_PRUNE_BLOCK_SLOTS_PER_RUN = 4096;
|
|
15
16
|
|
|
17
|
+
// Genesis is kept so the block and state stay available via the API, e.g. for checkpoint providers
|
|
18
|
+
const FIRST_PRUNABLE_SLOT = GENESIS_SLOT + 1;
|
|
19
|
+
|
|
16
20
|
export async function pruneHistory(
|
|
17
21
|
config: ChainForkConfig,
|
|
18
22
|
db: IBeaconDb,
|
|
@@ -30,11 +34,12 @@ export async function pruneHistory(
|
|
|
30
34
|
// ensure that during (extremely lol) long periods of non-finality we don't delete unfinalized epoch data
|
|
31
35
|
finalizedEpoch
|
|
32
36
|
);
|
|
33
|
-
const firstBlockSlot =
|
|
37
|
+
const [firstBlockSlot = FIRST_PRUNABLE_SLOT] = await db.blockArchive.keys({gte: FIRST_PRUNABLE_SLOT, limit: 1});
|
|
34
38
|
const blockCutoffSlot = Math.min(computeStartSlotAtEpoch(blockCutoffEpoch), firstBlockSlot + maxBlockSlots);
|
|
35
39
|
// The latest archived state is the anchor on restart and can trail finalization by a few epochs
|
|
36
40
|
const lastArchivedStateSlot = (await db.stateArchive.lastKey()) ?? 0;
|
|
37
41
|
const stateCutoffSlot = Math.min(computeStartSlotAtEpoch(finalizedEpoch), lastArchivedStateSlot);
|
|
42
|
+
const stateStartSlot = Math.max(statePruneFromSlot, FIRST_PRUNABLE_SLOT);
|
|
38
43
|
|
|
39
44
|
logger.debug("Preparing to prune history", {
|
|
40
45
|
currentEpoch,
|
|
@@ -46,9 +51,9 @@ export async function pruneHistory(
|
|
|
46
51
|
|
|
47
52
|
const step0 = metrics?.pruneHistory.fetchKeys.startTimer();
|
|
48
53
|
const [blocks, envelopes, states] = await Promise.all([
|
|
49
|
-
db.blockArchive.keys({gte:
|
|
50
|
-
db.executionPayloadEnvelopeArchive.keys({gte:
|
|
51
|
-
stateCutoffSlot >
|
|
54
|
+
db.blockArchive.keys({gte: FIRST_PRUNABLE_SLOT, lt: blockCutoffSlot}),
|
|
55
|
+
db.executionPayloadEnvelopeArchive.keys({gte: FIRST_PRUNABLE_SLOT, lt: blockCutoffSlot}),
|
|
56
|
+
stateCutoffSlot > stateStartSlot ? db.stateArchive.keys({gte: stateStartSlot, lt: stateCutoffSlot}) : [],
|
|
52
57
|
]);
|
|
53
58
|
step0?.();
|
|
54
59
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
InvalidBlockCode,
|
|
8
8
|
LVHInvalidJudged,
|
|
9
9
|
PayloadExecutionStatus,
|
|
10
|
+
PayloadStatus,
|
|
10
11
|
getFinalizedExecutionBlockHash,
|
|
11
12
|
getSafeExecutionBlockHash,
|
|
12
13
|
} from "@lodestar/fork-choice";
|
|
@@ -117,7 +118,7 @@ function toForkChoiceExecutionStatus(status: ExecutionPayloadStatus): PayloadExe
|
|
|
117
118
|
* 3. Regenerate state for envelope verification
|
|
118
119
|
* 4. Verify envelope (fields against state, signature, and EL in parallel where possible)
|
|
119
120
|
* 5. Persist verified payload envelope to hot DB (waits for write-queue space for backpressure)
|
|
120
|
-
* 6. Update fork choice (transitions the block's PENDING variant to FULL)
|
|
121
|
+
* 6. Update fork choice (transitions the block's PENDING variant to FULL) and emit head events if the head changed
|
|
121
122
|
* 7. Queue notifyForkchoiceUpdate to engine api
|
|
122
123
|
* 8. Record metrics for payload envelope and column sources
|
|
123
124
|
* 9. Emit `execution_payload` event
|
|
@@ -356,6 +357,7 @@ export async function importExecutionPayload(
|
|
|
356
357
|
|
|
357
358
|
// 6. Update fork choice, transitions the block's PENDING variant to FULL
|
|
358
359
|
const execStatus = toForkChoiceExecutionStatus(execResult.status);
|
|
360
|
+
const prevHead = this.forkChoice.getHead();
|
|
359
361
|
try {
|
|
360
362
|
this.forkChoice.onExecutionPayload(
|
|
361
363
|
blockRootHex,
|
|
@@ -376,12 +378,17 @@ export async function importExecutionPayload(
|
|
|
376
378
|
}
|
|
377
379
|
throw e;
|
|
378
380
|
}
|
|
381
|
+
const head = this.forkChoice.getHead();
|
|
382
|
+
this.emitHeadEvents(prevHead, head);
|
|
383
|
+
if (head.blockRoot !== prevHead.blockRoot) {
|
|
384
|
+
this.onHeadChanged(prevHead, head);
|
|
385
|
+
}
|
|
379
386
|
|
|
380
387
|
// 7. Queue notifyForkchoiceUpdate to engine api
|
|
381
|
-
const head = this.forkChoice.getHead();
|
|
382
388
|
if (
|
|
383
389
|
!this.opts.disableImportExecutionFcU &&
|
|
384
390
|
blockRootHex === head.blockRoot &&
|
|
391
|
+
head.payloadStatus === PayloadStatus.FULL &&
|
|
385
392
|
// Skip a payload that does not satisfy the inclusion list constraints, fork choice keeps the EMPTY
|
|
386
393
|
// variant as head and the next prepare fcU keeps the engine on the parent payload
|
|
387
394
|
this.forkChoice.isPayloadInclusionListSatisfied(blockRootHex)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {PayloadStatus} from "@lodestar/fork-choice";
|
|
2
2
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
3
3
|
import {SignedBeaconBlock, Slot} from "@lodestar/types";
|
|
4
|
-
import {isErrorAborted
|
|
4
|
+
import {isErrorAborted} from "@lodestar/utils";
|
|
5
5
|
import {Metrics} from "../../metrics/metrics.js";
|
|
6
6
|
import {nextEventLoop} from "../../util/eventLoop.js";
|
|
7
7
|
import {JobItemQueue, isQueueErrorAborted} from "../../util/queue/index.js";
|
|
@@ -208,36 +208,9 @@ export async function processBlocks(
|
|
|
208
208
|
this.logger.debug("Block error", {slot: err.signedBlock.message.slot}, err);
|
|
209
209
|
|
|
210
210
|
if (err.type.code === BlockErrorCode.INVALID_SIGNATURE) {
|
|
211
|
-
|
|
212
|
-
const blockSlot = signedBlock.message.slot;
|
|
213
|
-
const {state} = err.type;
|
|
214
|
-
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
215
|
-
const blockRootHex = toRootHex(forkTypes.BeaconBlock.hashTreeRoot(signedBlock.message));
|
|
216
|
-
this.persistInvalidSszValue(
|
|
217
|
-
forkTypes.SignedBeaconBlock,
|
|
218
|
-
signedBlock,
|
|
219
|
-
`${blockSlot}_invalid_signature`,
|
|
220
|
-
blockRootHex
|
|
221
|
-
);
|
|
222
|
-
this.persistInvalidSszBytes(
|
|
223
|
-
"BeaconState",
|
|
224
|
-
state.serialize(),
|
|
225
|
-
toRootHex(state.hashTreeRoot()),
|
|
226
|
-
`${state.slot}_invalid_signature`
|
|
227
|
-
);
|
|
211
|
+
void this.persistInvalidSignature(err.type.state, err.signedBlock);
|
|
228
212
|
} else if (err.type.code === BlockErrorCode.INVALID_STATE_ROOT) {
|
|
229
|
-
|
|
230
|
-
const blockSlot = signedBlock.message.slot;
|
|
231
|
-
const {preState, postState} = err.type;
|
|
232
|
-
const preRoot = preState.hashTreeRoot();
|
|
233
|
-
const postRoot = postState.hashTreeRoot();
|
|
234
|
-
this.persistInvalidStateRoot(preState, postState, signedBlock).catch((e) => {
|
|
235
|
-
this.logger.error(
|
|
236
|
-
"Error persisting invalid state root objects",
|
|
237
|
-
{slot: blockSlot, preStateRoot: toRootHex(preRoot), postStateRoot: toRootHex(postRoot)},
|
|
238
|
-
e
|
|
239
|
-
);
|
|
240
|
-
});
|
|
213
|
+
void this.persistInvalidStateRoot(err.type.preState, err.type.postState, err.signedBlock);
|
|
241
214
|
}
|
|
242
215
|
}
|
|
243
216
|
|
|
@@ -307,7 +280,6 @@ async function importPayloadEnvelopesOfKnownBlocks(
|
|
|
307
280
|
});
|
|
308
281
|
await importExecutionPayload.call(this, payloadInputs[i], dataAvailabilityStatuses[i], {validSignature: false});
|
|
309
282
|
}
|
|
310
|
-
// the new FULL variants are not seen by the head cached from the last block import
|
|
311
283
|
this.recomputeForkChoiceHead(ForkchoiceCaller.importBlock);
|
|
312
284
|
|
|
313
285
|
return result;
|
package/src/chain/chain.ts
CHANGED
|
@@ -93,7 +93,7 @@ import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
|
|
|
93
93
|
import {persistPayloadEnvelopeInput} from "./blocks/writePayloadEnvelopeInputToDb.js";
|
|
94
94
|
import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier, IBlsVerifier} from "./bls/index.js";
|
|
95
95
|
import {BuilderCircuitBreaker} from "./builderCircuitBreaker.js";
|
|
96
|
-
import {ColumnReconstructionTracker} from "./ColumnReconstructionTracker.js";
|
|
96
|
+
import {ColumnReconstructionTracker, RECONSTRUCTED_COLUMNS_WAIT_BPS} from "./ColumnReconstructionTracker.js";
|
|
97
97
|
import {ChainEvent, ChainEventEmitter, ReorgEventData} from "./emitter.js";
|
|
98
98
|
import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js";
|
|
99
99
|
import {ForkChoiceExecutionEngine} from "./forkChoiceExecutionEngine.js";
|
|
@@ -701,7 +701,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
701
701
|
const state = await this.regen.getBlockSlotState(block, slot, {dontTransferCache: true}, RegenCaller.restApi);
|
|
702
702
|
return {
|
|
703
703
|
state,
|
|
704
|
-
|
|
704
|
+
// The canonical variant can be FULL, a state reports the status of the payload its block builds on
|
|
705
|
+
executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
|
|
705
706
|
finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
|
|
706
707
|
};
|
|
707
708
|
}
|
|
@@ -717,7 +718,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
717
718
|
return (
|
|
718
719
|
state && {
|
|
719
720
|
state,
|
|
720
|
-
executionOptimistic: isOptimisticBlock(block),
|
|
721
|
+
executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
|
|
721
722
|
finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
|
|
722
723
|
}
|
|
723
724
|
);
|
|
@@ -865,7 +866,9 @@ export class BeaconChain implements IBeaconChain {
|
|
|
865
866
|
const finalizedBlock = this.forkChoice.getFinalizedBlock();
|
|
866
867
|
if (slot > finalizedBlock.slot) {
|
|
867
868
|
// Unfinalized slot, attempt to find in fork-choice
|
|
868
|
-
const
|
|
869
|
+
const canonicalBlock = this.forkChoice.getCanonicalBlockAtSlot(slot);
|
|
870
|
+
// The canonical variant can be FULL, a block reports the status of the payload it builds on
|
|
871
|
+
const block = canonicalBlock && this.forkChoice.getBlockHexDefaultStatus(canonicalBlock.blockRoot);
|
|
869
872
|
if (block) {
|
|
870
873
|
// Block found in fork-choice.
|
|
871
874
|
// It may be in the block input cache, awaiting full DA reconstruction, check there first
|
|
@@ -893,16 +896,18 @@ export class BeaconChain implements IBeaconChain {
|
|
|
893
896
|
): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null> {
|
|
894
897
|
const block = this.forkChoice.getBlockHexDefaultStatus(root);
|
|
895
898
|
if (block) {
|
|
899
|
+
// The finalized block stays in fork-choice and the hot db until the archiver has migrated it
|
|
900
|
+
const finalized = block.slot <= this.forkChoice.getFinalizedBlock().slot;
|
|
896
901
|
// Block found in fork-choice.
|
|
897
902
|
// It may be in the block input cache, awaiting full DA reconstruction, check there first
|
|
898
903
|
// Otherwise (most likely), check the hot db
|
|
899
904
|
const blockInput = this.seenBlockInputCache.get(block.blockRoot);
|
|
900
905
|
if (blockInput?.hasBlock()) {
|
|
901
|
-
return {block: blockInput.getBlock(), executionOptimistic: isOptimisticBlock(block), finalized
|
|
906
|
+
return {block: blockInput.getBlock(), executionOptimistic: isOptimisticBlock(block), finalized};
|
|
902
907
|
}
|
|
903
908
|
const data = await this.db.block.get(fromHex(root));
|
|
904
909
|
if (data) {
|
|
905
|
-
return {block: data, executionOptimistic: isOptimisticBlock(block), finalized
|
|
910
|
+
return {block: data, executionOptimistic: isOptimisticBlock(block), finalized};
|
|
906
911
|
}
|
|
907
912
|
// If block is not found in hot db, try cold db since there could be an archive cycle happening
|
|
908
913
|
// TODO: Add a lock to the archiver to have deterministic behavior on where are blocks
|
|
@@ -917,6 +922,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
917
922
|
): Promise<{block: Uint8Array; executionOptimistic: boolean; finalized: boolean; slot: Slot} | null> {
|
|
918
923
|
const block = this.forkChoice.getBlockHexDefaultStatus(root);
|
|
919
924
|
if (block) {
|
|
925
|
+
// The finalized block stays in fork-choice and the hot db until the archiver has migrated it
|
|
926
|
+
const finalized = block.slot <= this.forkChoice.getFinalizedBlock().slot;
|
|
920
927
|
// Block found in fork-choice.
|
|
921
928
|
// It may be in the block input cache, awaiting full DA reconstruction, check there first
|
|
922
929
|
// Otherwise (most likely), check the hot db
|
|
@@ -928,14 +935,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
928
935
|
return {
|
|
929
936
|
block: serialized,
|
|
930
937
|
executionOptimistic: isOptimisticBlock(block),
|
|
931
|
-
finalized
|
|
938
|
+
finalized,
|
|
932
939
|
slot: blockInput.slot,
|
|
933
940
|
};
|
|
934
941
|
}
|
|
935
942
|
return {
|
|
936
943
|
block: sszTypesFor(blockInput.forkName).SignedBeaconBlock.serialize(signedBlock),
|
|
937
944
|
executionOptimistic: isOptimisticBlock(block),
|
|
938
|
-
finalized
|
|
945
|
+
finalized,
|
|
939
946
|
slot: blockInput.slot,
|
|
940
947
|
};
|
|
941
948
|
}
|
|
@@ -943,7 +950,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
943
950
|
if (data) {
|
|
944
951
|
const slot = getSlotFromSignedBeaconBlockSerialized(data);
|
|
945
952
|
if (slot === null) throw new Error(`Invalid block data stored in DB for root: ${root}`);
|
|
946
|
-
return {block: data, executionOptimistic: isOptimisticBlock(block), finalized
|
|
953
|
+
return {block: data, executionOptimistic: isOptimisticBlock(block), finalized, slot};
|
|
947
954
|
}
|
|
948
955
|
// If block is not found in hot db, try cold db since there could be an archive cycle happening
|
|
949
956
|
// TODO: Add a lock to the archiver to have deterministic behavior on where are blocks
|
|
@@ -1126,6 +1133,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1126
1133
|
// After gloas, columns are tracked in PayloadEnvelopeInput
|
|
1127
1134
|
const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
1128
1135
|
if (payloadInput) {
|
|
1136
|
+
// Available with half the columns, peers that saw it attested expect the reconstructed rest
|
|
1137
|
+
if (
|
|
1138
|
+
!payloadInput.hasComputedAllData() &&
|
|
1139
|
+
payloadInput.hasAllData() &&
|
|
1140
|
+
indices.some((index) => !payloadInput.hasColumn(index))
|
|
1141
|
+
) {
|
|
1142
|
+
this.columnReconstructionTracker.triggerColumnReconstruction(payloadInput);
|
|
1143
|
+
await payloadInput
|
|
1144
|
+
.waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
|
|
1145
|
+
.catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
|
|
1146
|
+
}
|
|
1129
1147
|
for (let i = 0; i < indices.length; i++) {
|
|
1130
1148
|
const index = indices[i];
|
|
1131
1149
|
const sidecar = payloadInput.getColumn(index);
|
|
@@ -1147,6 +1165,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1147
1165
|
if (!isBlockInputColumns(blockInput)) {
|
|
1148
1166
|
throw new Error(`Expected block input to have columns: slot=${blockSlot} root=${blockRootHex}`);
|
|
1149
1167
|
}
|
|
1168
|
+
// Available with half the columns, peers that saw it attested expect the reconstructed rest
|
|
1169
|
+
if (
|
|
1170
|
+
!blockInput.hasComputedAllData() &&
|
|
1171
|
+
blockInput.hasAllData() &&
|
|
1172
|
+
indices.some((index) => !blockInput.hasColumn(index))
|
|
1173
|
+
) {
|
|
1174
|
+
this.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
|
|
1175
|
+
await blockInput
|
|
1176
|
+
.waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
|
|
1177
|
+
.catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
|
|
1178
|
+
}
|
|
1150
1179
|
for (let i = 0; i < indices.length; i++) {
|
|
1151
1180
|
const index = indices[i];
|
|
1152
1181
|
const sidecar = blockInput.getColumn(index);
|
|
@@ -1473,9 +1502,10 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1473
1502
|
|
|
1474
1503
|
/**
|
|
1475
1504
|
* Emit `head` and `head_v2` when the fork choice head differs between two observations. Every caller that
|
|
1476
|
-
* can move the head, `updateAndGetHead()` and `
|
|
1505
|
+
* can move the head, `updateAndGetHead()`, `updateTime()` and `onExecutionPayload()`, must capture the head before
|
|
1506
|
+
* and pass both.
|
|
1477
1507
|
*/
|
|
1478
|
-
|
|
1508
|
+
emitHeadEvents(prevHead: ProtoBlock, head: ProtoBlock): void {
|
|
1479
1509
|
const headRootChanged = head.blockRoot !== prevHead.blockRoot;
|
|
1480
1510
|
|
|
1481
1511
|
if (!headRootChanged && prevHead.payloadStatus === head.payloadStatus) {
|
|
@@ -1606,38 +1636,76 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1606
1636
|
}
|
|
1607
1637
|
|
|
1608
1638
|
/**
|
|
1609
|
-
* Invalid state root error is critical and it causes the node to stale most of the time so we want to
|
|
1610
|
-
*
|
|
1639
|
+
* Invalid state root error is critical and it causes the node to stale most of the time so we want to persist
|
|
1640
|
+
* preState, postState and block for further investigation.
|
|
1611
1641
|
*/
|
|
1612
1642
|
async persistInvalidStateRoot(
|
|
1613
1643
|
preState: IBeaconStateView,
|
|
1614
1644
|
postState: IBeaconStateView,
|
|
1615
1645
|
block: SignedBeaconBlock
|
|
1616
1646
|
): Promise<void> {
|
|
1647
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1617
1650
|
const blockSlot = block.message.slot;
|
|
1618
|
-
const
|
|
1619
|
-
const
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1651
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1652
|
+
const preStateRoot = toRootHex(preState.hashTreeRoot());
|
|
1653
|
+
const postStateRoot = toRootHex(postState.hashTreeRoot());
|
|
1654
|
+
const logStr = `slot_${blockSlot}_invalid_state_root_${postStateRoot}`;
|
|
1655
|
+
try {
|
|
1656
|
+
await Promise.all([
|
|
1657
|
+
this.persistSszObject(
|
|
1658
|
+
`SignedBeaconBlock_slot_${blockSlot}`,
|
|
1659
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1660
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1661
|
+
`${logStr}_block`
|
|
1662
|
+
),
|
|
1663
|
+
this.persistSszObject(
|
|
1664
|
+
`preState_slot_${preState.slot}_BeaconState`,
|
|
1665
|
+
preState.serialize(),
|
|
1666
|
+
preStateRoot,
|
|
1667
|
+
`${logStr}_pre_state`
|
|
1668
|
+
),
|
|
1669
|
+
this.persistSszObject(
|
|
1670
|
+
`postState_slot_${postState.slot}_BeaconState`,
|
|
1671
|
+
postState.serialize(),
|
|
1672
|
+
postStateRoot,
|
|
1673
|
+
`${logStr}_post_state`
|
|
1674
|
+
),
|
|
1675
|
+
]);
|
|
1676
|
+
} catch (e) {
|
|
1677
|
+
this.logger.error(
|
|
1678
|
+
"Error persisting invalid state root objects",
|
|
1679
|
+
{slot: blockSlot, preStateRoot, postStateRoot},
|
|
1680
|
+
e as Error
|
|
1681
|
+
);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
async persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void> {
|
|
1686
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
const blockSlot = block.message.slot;
|
|
1690
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1691
|
+
try {
|
|
1692
|
+
await Promise.all([
|
|
1693
|
+
this.persistSszObject(
|
|
1694
|
+
forkTypes.SignedBeaconBlock.typeName,
|
|
1695
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1696
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1697
|
+
`${blockSlot}_invalid_signature`
|
|
1698
|
+
),
|
|
1699
|
+
this.persistSszObject(
|
|
1700
|
+
"BeaconState",
|
|
1701
|
+
state.serialize(),
|
|
1702
|
+
toRootHex(state.hashTreeRoot()),
|
|
1703
|
+
`${state.slot}_invalid_signature`
|
|
1704
|
+
),
|
|
1705
|
+
]);
|
|
1706
|
+
} catch (e) {
|
|
1707
|
+
this.logger.error("Error persisting invalid signature objects", {slot: blockSlot}, e as Error);
|
|
1708
|
+
}
|
|
1641
1709
|
}
|
|
1642
1710
|
|
|
1643
1711
|
persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void {
|
|
@@ -1652,12 +1720,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1652
1720
|
}
|
|
1653
1721
|
}
|
|
1654
1722
|
|
|
1655
|
-
persistInvalidSszBytes(typeName: string, sszBytes: Uint8Array, rootHex: RootHex, suffix?: string): void {
|
|
1656
|
-
if (this.opts.persistInvalidSszObjects) {
|
|
1657
|
-
void this.persistSszObject(typeName, sszBytes, rootHex, suffix);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
1723
|
/**
|
|
1662
1724
|
* Regenerate state for attestation verification, this does not happen with default chain option of maxSkipSlots = 32 .
|
|
1663
1725
|
* However, need to handle just in case. Lodestar doesn't support multiple regen state requests for attestation verification
|
|
@@ -151,6 +151,14 @@ export enum AttestationErrorCode {
|
|
|
151
151
|
* Gloas: index-1 attestation but the execution payload has not been seen yet
|
|
152
152
|
*/
|
|
153
153
|
EXECUTION_PAYLOAD_NOT_SEEN = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_NOT_SEEN",
|
|
154
|
+
/**
|
|
155
|
+
* Gloas: index-1 attestation to a block whose execution payload is not yet validated by the execution engine
|
|
156
|
+
*/
|
|
157
|
+
EXECUTION_PAYLOAD_OPTIMISTIC = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_OPTIMISTIC",
|
|
158
|
+
/**
|
|
159
|
+
* Gloas: index-1 attestation to a block whose execution payload was invalidated
|
|
160
|
+
*/
|
|
161
|
+
EXECUTION_PAYLOAD_INVALID = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_INVALID",
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
export type AttestationErrorType =
|
|
@@ -190,7 +198,9 @@ export type AttestationErrorType =
|
|
|
190
198
|
| {code: AttestationErrorCode.ATTESTER_NOT_IN_COMMITTEE}
|
|
191
199
|
| {code: AttestationErrorCode.INVALID_PAYLOAD_STATUS_VALUE; attDataIndex: number}
|
|
192
200
|
| {code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT}
|
|
193
|
-
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
201
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
202
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC; beaconBlockRoot: RootHex}
|
|
203
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID; beaconBlockRoot: RootHex};
|
|
194
204
|
|
|
195
205
|
export class AttestationError extends GossipActionError<AttestationErrorType> {
|
|
196
206
|
getMetadata(): Record<string, string | number | null> {
|