@lodestar/beacon-node 2.1.0-dev.c63474c8f3 → 2.1.0-dev.d00daf7fb4
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/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +8 -0
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +3 -2
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +1 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/validator/index.js +1 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +1 -1
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +14 -5
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +4 -2
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +17 -3
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +11 -2
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +181 -13
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts +9 -3
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +22 -16
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/options.js +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +8 -5
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +5 -1
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +24 -14
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +5 -1
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +5 -1
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +14 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +1 -7
- 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 +1 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.js +6 -1
- package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +6 -4
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +17 -17
- package/src/api/impl/beacon/pool/index.ts +11 -0
- package/src/api/impl/beacon/state/index.ts +3 -7
- package/src/api/impl/beacon/state/utils.ts +1 -1
- package/src/api/impl/validator/index.ts +1 -1
- package/src/api/rest/base.ts +5 -1
- package/src/chain/blocks/importBlock.ts +14 -7
- package/src/chain/blocks/importExecutionPayload.ts +4 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +8 -1
- package/src/chain/chain.ts +17 -3
- package/src/chain/forkChoice/index.ts +235 -13
- package/src/chain/opPools/opPool.ts +27 -16
- package/src/chain/options.ts +1 -1
- package/src/chain/seenCache/seenGossipBlockInput.ts +1 -1
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
- package/src/chain/validation/block.ts +8 -5
- package/src/chain/validation/proposerSlashing.ts +5 -1
- package/src/network/processor/gossipHandlers.ts +40 -22
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -1
- package/src/sync/range/batch.ts +5 -1
- package/src/sync/range/range.ts +7 -1
- package/src/sync/unknownBlock.ts +20 -1
- package/src/sync/utils/downloadByRange.ts +1 -6
- package/src/sync/utils/downloadByRoot.ts +12 -9
- package/src/sync/utils/pendingBlocksTree.ts +6 -1
- package/src/util/sszBytes.ts +7 -8
|
@@ -183,7 +183,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
183
183
|
blockRootHex: RootHex,
|
|
184
184
|
fork: ForkName,
|
|
185
185
|
peerIdStr: string,
|
|
186
|
-
seenTimestampSec: number
|
|
186
|
+
seenTimestampSec: number,
|
|
187
|
+
opts?: {unvalidated?: boolean}
|
|
187
188
|
): BlockInput {
|
|
188
189
|
const blockInput = chain.seenBlockInputCache.getByBlock({
|
|
189
190
|
block: signedBlock,
|
|
@@ -196,15 +197,18 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
196
197
|
// Also seed the payload-envelope cache, so we have PayloadEnvelopeInput even through "PARENT_BLOCK_UNKNOWN" error
|
|
197
198
|
// see https://github.com/ChainSafe/lodestar/issues/9475
|
|
198
199
|
if (isForkPostGloas(fork)) {
|
|
199
|
-
chain.seenPayloadEnvelopeInputCache.add(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
200
|
+
chain.seenPayloadEnvelopeInputCache.add(
|
|
201
|
+
{
|
|
202
|
+
blockRootHex,
|
|
203
|
+
block: signedBlock as SignedBeaconBlock<ForkPostGloas>,
|
|
204
|
+
forkName: fork,
|
|
205
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
206
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
207
|
+
seenTimestampSec,
|
|
208
|
+
source: PayloadEnvelopeInputSource.gossip,
|
|
209
|
+
},
|
|
210
|
+
opts
|
|
211
|
+
);
|
|
208
212
|
}
|
|
209
213
|
|
|
210
214
|
return blockInput;
|
|
@@ -300,7 +304,9 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
300
304
|
}
|
|
301
305
|
chain.seenBlockProposers.add(slot, proposerIndex, blockRootHex);
|
|
302
306
|
|
|
303
|
-
const blockInput = cacheSignatureVerifiedBlock(signedBlock, blockRootHex, fork, peerIdStr, seenTimestampSec
|
|
307
|
+
const blockInput = cacheSignatureVerifiedBlock(signedBlock, blockRootHex, fork, peerIdStr, seenTimestampSec, {
|
|
308
|
+
unvalidated: true,
|
|
309
|
+
});
|
|
304
310
|
chain.emitter.emit(ChainEvent.blockUnknownParent, {
|
|
305
311
|
blockInput,
|
|
306
312
|
peer: peerIdStr,
|
|
@@ -575,7 +581,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
575
581
|
const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
|
|
576
582
|
metrics?.gossipBlock.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
577
583
|
chain.validatorMonitor?.registerBeaconBlock(OpSource.gossip, delaySec, signedBlock.message);
|
|
578
|
-
|
|
584
|
+
const missingData = !blockInput.hasBlockAndAllData();
|
|
585
|
+
if (missingData) {
|
|
579
586
|
chain.logger.debug("Received gossip block, attempting fetch of unavailable data", blockInput.getLogMeta());
|
|
580
587
|
// The data is not yet fully available, immediately trigger an aggressive pull via unknown block sync
|
|
581
588
|
chain.emitter.emit(ChainEvent.incompleteBlockInput, {
|
|
@@ -668,8 +675,13 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
668
675
|
}
|
|
669
676
|
metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"});
|
|
670
677
|
logger[logLevel]("Error processing block", {slot, root: blockInput.blockRootHex, peer: peerIdStr}, e as Error);
|
|
671
|
-
//
|
|
672
|
-
|
|
678
|
+
// BlockInputSync retries the import of a block with missing data from this same BlockInput, pruning it here
|
|
679
|
+
// would put later gossip columns into a new BlockInput that is never imported. The entry is released once the
|
|
680
|
+
// block is persisted, BlockInputSync removes it, on finalization or by the cache size limit
|
|
681
|
+
if (!missingData) {
|
|
682
|
+
// TODO(fulu): Revisit when we prune block inputs
|
|
683
|
+
chain.seenBlockInputCache.prune(blockInput.blockRootHex);
|
|
684
|
+
}
|
|
673
685
|
});
|
|
674
686
|
}
|
|
675
687
|
|
|
@@ -721,7 +733,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
721
733
|
e.type.root,
|
|
722
734
|
topic.boundary.fork,
|
|
723
735
|
peerIdStr,
|
|
724
|
-
seenTimestampSec
|
|
736
|
+
seenTimestampSec,
|
|
737
|
+
{unvalidated: false}
|
|
725
738
|
);
|
|
726
739
|
// We're returning IGNORE (thrown below), so this block is not forwarded to peers. Unlike the
|
|
727
740
|
// happy path there is no rush to forward, so we don't need to wrap in callInNextEventLoop.
|
|
@@ -1295,20 +1308,25 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1295
1308
|
try {
|
|
1296
1309
|
const delaySec = chain.clock.secFromSlot(payloadAttestationMessage.data.slot, seenTimestampSec);
|
|
1297
1310
|
metrics?.gossipPayloadAttestationMessage.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
if (isNextSlotProposer) {
|
|
1302
|
-
try {
|
|
1311
|
+
try {
|
|
1312
|
+
const nextSlotProposer = chain.getHeadState().getBeaconProposer(payloadAttestationMessage.data.slot + 1);
|
|
1313
|
+
if (chain.beaconProposerCache.has(nextSlotProposer)) {
|
|
1303
1314
|
const insertOutcome = chain.payloadAttestationPool.add(
|
|
1304
1315
|
payloadAttestationMessage,
|
|
1305
1316
|
validationResult.attDataRootHex,
|
|
1306
1317
|
validationResult.validatorCommitteeIndices
|
|
1307
1318
|
);
|
|
1308
1319
|
metrics?.opPool.payloadAttestationPool.gossipInsertOutcome.inc({insertOutcome});
|
|
1309
|
-
} catch (e) {
|
|
1310
|
-
logger.debug("Error adding to payloadAttestation pool", {}, e as Error);
|
|
1311
1320
|
}
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
logger.debug(
|
|
1323
|
+
"Error adding to payloadAttestation pool",
|
|
1324
|
+
{
|
|
1325
|
+
slot: payloadAttestationMessage.data.slot,
|
|
1326
|
+
root: toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
|
|
1327
|
+
},
|
|
1328
|
+
e as Error
|
|
1329
|
+
);
|
|
1312
1330
|
}
|
|
1313
1331
|
|
|
1314
1332
|
// Gossip accepts adjacent slots within the clock disparity but fork choice only counts the current slot
|
|
@@ -226,5 +226,8 @@ export function validateDataColumnSidecarsByRangeRequest(
|
|
|
226
226
|
count = config.MAX_REQUEST_BLOCKS_DENEB;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
// Spec: sidecars MUST be sent in (slot, column_index) order, so serve each requested column once, ascending
|
|
230
|
+
const sortedColumns = Array.from(new Set(columns)).sort((a, b) => a - b);
|
|
231
|
+
|
|
232
|
+
return {startSlot, count, columns: sortedColumns};
|
|
230
233
|
}
|
package/src/sync/range/batch.ts
CHANGED
|
@@ -366,9 +366,13 @@ export class Batch {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
const needsEnvelope = !parentPayloadInput?.hasPayloadEnvelope();
|
|
369
|
+
// The parent precedes the batch, so it can be outside the DA window even when the batch is inside it
|
|
370
|
+
const parentPayload = this.getParentPayload();
|
|
369
371
|
const missingColumns = parentPayloadInput
|
|
370
372
|
? parentPayloadInput.getMissingSampledColumnMeta().missing
|
|
371
|
-
: this.
|
|
373
|
+
: isDaOutOfRange(this.config, parentPayload.forkName, parentPayload.slot, this.clock.currentEpoch)
|
|
374
|
+
? []
|
|
375
|
+
: this.custodyConfig.sampledColumns;
|
|
372
376
|
|
|
373
377
|
if (needsEnvelope || missingColumns.length > 0) {
|
|
374
378
|
requests.parentPayloadRequest = {
|
package/src/sync/range/range.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {EventEmitter} from "node:events";
|
|
2
2
|
import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
+
import {isForkPostGloas} from "@lodestar/params";
|
|
4
5
|
import {IBeaconStateViewGloas, computeStartSlotAtEpoch, isStatePostGloas} from "@lodestar/state-transition";
|
|
5
6
|
import {Epoch, Status, fulu, ssz} from "@lodestar/types";
|
|
6
7
|
import {Logger, byteArrayEquals, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
|
|
@@ -434,7 +435,12 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
|
|
|
434
435
|
// the batch then downloads the head's payload as dangling parent and validates it against the bid
|
|
435
436
|
const headState = this.chain.getHeadState();
|
|
436
437
|
let parentPayload: ParentPayload | undefined;
|
|
437
|
-
|
|
438
|
+
// A pre-Gloas head block in a state upgraded to Gloas carried its own payload, no envelope follows it
|
|
439
|
+
if (
|
|
440
|
+
isStatePostGloas(headState) &&
|
|
441
|
+
headState.latestBlockHeader.slot > 0 &&
|
|
442
|
+
isForkPostGloas(this.config.getForkName(headState.latestBlockHeader.slot))
|
|
443
|
+
) {
|
|
438
444
|
const header = ssz.phase0.BeaconBlockHeader.clone(headState.latestBlockHeader);
|
|
439
445
|
if (byteArrayEquals(header.stateRoot, ssz.Root.defaultValue())) {
|
|
440
446
|
header.stateRoot = headState.hashTreeRoot();
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -928,6 +928,19 @@ export class BlockInputSync {
|
|
|
928
928
|
const connectedPeers = this.network.getConnectedPeers();
|
|
929
929
|
const hasConnectedPeers = connectedPeers.length > 0;
|
|
930
930
|
|
|
931
|
+
// Gossip, getBlobs or column reconstruction can complete a pending block's data through the shared BlockInput.
|
|
932
|
+
// With only half the columns the block stays pending, its fetch asks a peer for the rest before reconstructing
|
|
933
|
+
for (const block of this.pendingBlocks.values()) {
|
|
934
|
+
if (
|
|
935
|
+
isPendingBlockInput(block) &&
|
|
936
|
+
block.status === PendingBlockInputStatus.pending &&
|
|
937
|
+
block.blockInput.hasBlockAndAllData() &&
|
|
938
|
+
(!isBlockInputColumns(block.blockInput) || block.blockInput.hasComputedAllData())
|
|
939
|
+
) {
|
|
940
|
+
block.status = PendingBlockInputStatus.downloaded;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
931
944
|
const {unknowns, ancestors} = getUnknownAndAncestorBlocks(this.pendingBlocks);
|
|
932
945
|
let processedBlocks = 0;
|
|
933
946
|
let shouldRerunBlockSearch = false;
|
|
@@ -2201,7 +2214,13 @@ export class BlockInputSync {
|
|
|
2201
2214
|
const cacheItemRootHex = getBlockInputSyncCacheItemRootHex(cacheItem);
|
|
2202
2215
|
// pruning may have dropped it mid-fetch
|
|
2203
2216
|
if (this.pendingBlocks.has(cacheItemRootHex)) {
|
|
2204
|
-
|
|
2217
|
+
// A partial download stays fetching while the next peer is asked, a pending entry would be fetched again
|
|
2218
|
+
this.pendingBlocks.set(
|
|
2219
|
+
cacheItemRootHex,
|
|
2220
|
+
cacheItem.status === PendingBlockInputStatus.pending
|
|
2221
|
+
? {...cacheItem, status: PendingBlockInputStatus.fetching}
|
|
2222
|
+
: cacheItem
|
|
2223
|
+
);
|
|
2205
2224
|
}
|
|
2206
2225
|
|
|
2207
2226
|
if (cacheItem.status === PendingBlockInputStatus.downloaded) {
|
|
@@ -825,12 +825,7 @@ export async function validateColumnsByRangeResponse(
|
|
|
825
825
|
}
|
|
826
826
|
|
|
827
827
|
seenSlotColumns.set(columnSidecar.index, columnSidecar);
|
|
828
|
-
|
|
829
|
-
// a new slot has started, reset index
|
|
830
|
-
currentIndex = -1;
|
|
831
|
-
} else {
|
|
832
|
-
currentIndex = columnSidecar.index;
|
|
833
|
-
}
|
|
828
|
+
currentIndex = columnSidecar.index;
|
|
834
829
|
currentSlot = slot;
|
|
835
830
|
}
|
|
836
831
|
|
|
@@ -104,15 +104,18 @@ export async function downloadByRoot({
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (isForkPostGloas(blockInput.forkName)) {
|
|
107
|
-
chain.seenPayloadEnvelopeInputCache.add(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
chain.seenPayloadEnvelopeInputCache.add(
|
|
108
|
+
{
|
|
109
|
+
blockRootHex: rootHex,
|
|
110
|
+
block: blockInput.getBlock() as SignedBeaconBlock<ForkPostGloas>,
|
|
111
|
+
forkName: blockInput.forkName,
|
|
112
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
113
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
114
|
+
seenTimestampSec: Date.now() / 1000,
|
|
115
|
+
source: PayloadEnvelopeInputSource.byRoot,
|
|
116
|
+
},
|
|
117
|
+
{unvalidated: true}
|
|
118
|
+
);
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
// Like range sync, download every sampled column, half of them only counts as available for reconstruction
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {RootHex} from "@lodestar/types";
|
|
2
2
|
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
|
3
4
|
import {
|
|
4
5
|
BlockInputSyncCacheItem,
|
|
5
6
|
PendingBlockInput,
|
|
@@ -61,9 +62,13 @@ export function getUnknownAndAncestorBlocks(blocks: Map<RootHex, BlockInputSyncC
|
|
|
61
62
|
const ancestors = new Map<RootHex, PendingBlockInput>();
|
|
62
63
|
|
|
63
64
|
for (const block of blocks.values()) {
|
|
65
|
+
// Half the columns counts as all data, but a pending block is only complete with all sampled columns
|
|
64
66
|
if (
|
|
65
67
|
block.status === PendingBlockInputStatus.pending &&
|
|
66
|
-
(isPendingBlockInput(block)
|
|
68
|
+
(isPendingBlockInput(block)
|
|
69
|
+
? !block.blockInput.hasBlockAndAllData() ||
|
|
70
|
+
(isBlockInputColumns(block.blockInput) && !block.blockInput.hasComputedAllData())
|
|
71
|
+
: true)
|
|
67
72
|
) {
|
|
68
73
|
unknowns.set(getBlockInputSyncCacheItemRootHex(block), block);
|
|
69
74
|
} else if (
|
package/src/util/sszBytes.ts
CHANGED
|
@@ -693,7 +693,7 @@ export function getLastProcessedSlotFromBeaconStateSerialized(data: Uint8Array):
|
|
|
693
693
|
|
|
694
694
|
const SLOT_BYTES_POSITION_IN_BEACON_STATE = 8 + 32;
|
|
695
695
|
export function getSlotFromBeaconStateSerialized(data: Uint8Array): Slot | null {
|
|
696
|
-
if (data.length < SLOT_BYTES_POSITION_IN_BEACON_STATE) {
|
|
696
|
+
if (data.length < SLOT_BYTES_POSITION_IN_BEACON_STATE + SLOT_SIZE) {
|
|
697
697
|
return null;
|
|
698
698
|
}
|
|
699
699
|
|
|
@@ -886,17 +886,16 @@ export function getBlobKzgCommitmentsCountFromSignedBeaconBlockSerialized(
|
|
|
886
886
|
const bodyIndex = Object.keys(BeaconBlock.fields).indexOf("body");
|
|
887
887
|
const bodyRange = blockFieldRanges[bodyIndex];
|
|
888
888
|
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
);
|
|
889
|
+
const bodyStart = messageRange.start + bodyRange.start;
|
|
890
|
+
const bodyEnd = messageRange.start + bodyRange.end;
|
|
891
|
+
|
|
892
|
+
const bodyFieldRanges = BeaconBlockBody.getFieldRanges(view, bodyStart, bodyEnd);
|
|
894
893
|
const kzgCommitmentsIndex = Object.keys(BeaconBlockBody.fields).indexOf("blobKzgCommitments");
|
|
895
894
|
const kzgCommitmentsRange = bodyFieldRanges[kzgCommitmentsIndex];
|
|
896
895
|
const commitmentSize = KZGCommitment.fixedSize;
|
|
897
896
|
|
|
898
|
-
const end =
|
|
899
|
-
const start =
|
|
897
|
+
const end = bodyStart + kzgCommitmentsRange.end;
|
|
898
|
+
const start = bodyStart + kzgCommitmentsRange.start;
|
|
900
899
|
|
|
901
900
|
return Math.round((Math.min(end, blockBytes.byteLength) - start) / commitmentSize);
|
|
902
901
|
}
|