@lodestar/beacon-node 1.41.0-dev.9fa839a030 → 1.41.0-dev.aeb5a213ee
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 +121 -3
- 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 +1 -20
- 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 +5 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/lightclient/index.d.ts.map +1 -1
- package/lib/api/impl/lightclient/index.js +19 -2
- package/lib/api/impl/lightclient/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +101 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +1 -0
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +9 -0
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/utils/archivePayloads.d.ts +7 -0
- package/lib/chain/archiveStore/utils/archivePayloads.d.ts.map +1 -0
- package/lib/chain/archiveStore/utils/archivePayloads.js +10 -0
- package/lib/chain/archiveStore/utils/archivePayloads.js.map +1 -0
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +0 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +2 -1
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.js +3 -0
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +2 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +24 -6
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +2 -2
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/interface.d.ts +2 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +1 -1
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.js +3 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +10 -2
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +24 -2
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +22 -7
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +110 -10
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +2 -2
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/db/beacon.d.ts +3 -1
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +5 -1
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +3 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +2 -0
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +3 -1
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.d.ts +5 -3
- package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.js +14 -1
- package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.d.ts +5 -3
- package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.js +14 -1
- package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelope.d.ts +19 -0
- package/lib/db/repositories/executionPayloadEnvelope.d.ts.map +1 -0
- package/lib/db/repositories/executionPayloadEnvelope.js +22 -0
- package/lib/db/repositories/executionPayloadEnvelope.js.map +1 -0
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +18 -0
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -0
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js +28 -0
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -0
- package/lib/db/repositories/index.d.ts +2 -0
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +2 -0
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +1 -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 +5 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +9 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/metrics/metrics.d.ts.map +1 -1
- package/lib/metrics/metrics.js +8 -3
- package/lib/metrics/metrics.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +3 -3
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/topic.d.ts +113 -63
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +2 -2
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/interface.d.ts +3 -2
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +3 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +10 -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 +5 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/reqresp/handlers/lightClientUpdatesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js +7 -1
- package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js.map +1 -1
- package/lib/util/blobs.d.ts +2 -2
- package/lib/util/blobs.d.ts.map +1 -1
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/dataColumns.d.ts +11 -3
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +27 -0
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/multifork.d.ts +8 -0
- package/lib/util/multifork.d.ts.map +1 -1
- package/lib/util/multifork.js +37 -0
- package/lib/util/multifork.js.map +1 -1
- package/lib/util/serializedCache.d.ts +5 -0
- package/lib/util/serializedCache.d.ts.map +1 -1
- package/lib/util/serializedCache.js +5 -0
- package/lib/util/serializedCache.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +145 -2
- package/src/api/impl/beacon/state/utils.ts +10 -23
- package/src/api/impl/debug/index.ts +8 -5
- package/src/api/impl/lightclient/index.ts +19 -2
- package/src/api/impl/validator/index.ts +124 -1
- package/src/chain/archiveStore/archiveStore.ts +10 -0
- package/src/chain/archiveStore/utils/archivePayloads.ts +15 -0
- package/src/chain/blocks/importBlock.ts +0 -3
- package/src/chain/blocks/index.ts +2 -1
- package/src/chain/blocks/writeBlockInputToDb.ts +3 -0
- package/src/chain/chain.ts +41 -11
- package/src/chain/emitter.ts +2 -2
- package/src/chain/interface.ts +2 -2
- package/src/chain/lightClient/index.ts +4 -1
- package/src/chain/options.ts +1 -0
- package/src/chain/prepareNextSlot.ts +5 -5
- package/src/chain/produceBlock/computeNewStateRoot.ts +35 -3
- package/src/chain/produceBlock/produceBlockBody.ts +163 -13
- package/src/chain/validation/dataColumnSidecar.ts +2 -5
- package/src/db/beacon.ts +8 -0
- package/src/db/buckets.ts +3 -0
- package/src/db/interface.ts +5 -0
- package/src/db/repositories/dataColumnSidecar.ts +18 -3
- package/src/db/repositories/dataColumnSidecarArchive.ts +18 -3
- package/src/db/repositories/executionPayloadEnvelope.ts +26 -0
- package/src/db/repositories/executionPayloadEnvelopeArchive.ts +32 -0
- package/src/db/repositories/index.ts +2 -0
- package/src/metrics/metrics/beacon.ts +5 -0
- package/src/metrics/metrics/lodestar.ts +9 -0
- package/src/metrics/metrics.ts +8 -3
- package/src/network/gossip/interface.ts +3 -3
- package/src/network/gossip/topic.ts +2 -1
- package/src/network/interface.ts +4 -1
- package/src/network/network.ts +21 -3
- package/src/network/processor/gossipHandlers.ts +7 -1
- package/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +6 -1
- package/src/util/blobs.ts +3 -3
- package/src/util/dataColumns.ts +37 -1
- package/src/util/multifork.ts +45 -0
- package/src/util/serializedCache.ts +5 -0
package/src/network/network.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {ResponseIncoming} from "@lodestar/reqresp";
|
|
|
10
10
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
11
11
|
import {
|
|
12
12
|
AttesterSlashing,
|
|
13
|
+
DataColumnSidecar,
|
|
14
|
+
DataColumnSidecars,
|
|
13
15
|
LightClientBootstrap,
|
|
14
16
|
LightClientFinalityUpdate,
|
|
15
17
|
LightClientOptimisticUpdate,
|
|
@@ -24,6 +26,8 @@ import {
|
|
|
24
26
|
capella,
|
|
25
27
|
deneb,
|
|
26
28
|
fulu,
|
|
29
|
+
gloas,
|
|
30
|
+
isGloasDataColumnSidecar,
|
|
27
31
|
phase0,
|
|
28
32
|
} from "@lodestar/types";
|
|
29
33
|
import {prettyPrintIndices, sleep} from "@lodestar/utils";
|
|
@@ -354,8 +358,11 @@ export class Network implements INetwork {
|
|
|
354
358
|
});
|
|
355
359
|
}
|
|
356
360
|
|
|
357
|
-
async publishDataColumnSidecar(dataColumnSidecar:
|
|
358
|
-
const
|
|
361
|
+
async publishDataColumnSidecar(dataColumnSidecar: DataColumnSidecar): Promise<number> {
|
|
362
|
+
const slot = isGloasDataColumnSidecar(dataColumnSidecar)
|
|
363
|
+
? dataColumnSidecar.slot
|
|
364
|
+
: dataColumnSidecar.signedBlockHeader.message.slot;
|
|
365
|
+
const epoch = computeEpochAtSlot(slot);
|
|
359
366
|
const boundary = this.config.getForkBoundaryAtEpoch(epoch);
|
|
360
367
|
|
|
361
368
|
const subnet = computeSubnetForDataColumnSidecar(this.config, dataColumnSidecar);
|
|
@@ -489,6 +496,17 @@ export class Network implements INetwork {
|
|
|
489
496
|
);
|
|
490
497
|
}
|
|
491
498
|
|
|
499
|
+
async publishSignedExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope): Promise<number> {
|
|
500
|
+
const epoch = computeEpochAtSlot(signedEnvelope.message.slot);
|
|
501
|
+
const boundary = this.config.getForkBoundaryAtEpoch(epoch);
|
|
502
|
+
|
|
503
|
+
return this.publishGossip<GossipType.execution_payload>(
|
|
504
|
+
{type: GossipType.execution_payload, boundary},
|
|
505
|
+
signedEnvelope,
|
|
506
|
+
{ignoreDuplicatePublishError: true}
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
492
510
|
private async publishGossip<K extends GossipType>(
|
|
493
511
|
topic: GossipTopicMap[K],
|
|
494
512
|
object: GossipTypeMap[K],
|
|
@@ -765,7 +783,7 @@ export class Network implements INetwork {
|
|
|
765
783
|
this.core.setTargetGroupCount(count);
|
|
766
784
|
};
|
|
767
785
|
|
|
768
|
-
private onPublishDataColumns = (sidecars:
|
|
786
|
+
private onPublishDataColumns = (sidecars: DataColumnSidecars): Promise<number[]> => {
|
|
769
787
|
return promiseAllMaybeAsync(sidecars.map((sidecar) => () => this.publishDataColumnSidecar(sidecar)));
|
|
770
788
|
};
|
|
771
789
|
|
|
@@ -548,7 +548,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
548
548
|
seenTimestampSec,
|
|
549
549
|
}: GossipHandlerParamGeneric<GossipType.data_column_sidecar>) => {
|
|
550
550
|
const {serializedData} = gossipData;
|
|
551
|
-
|
|
551
|
+
// TODO GLOAS: handle gloas.DataColumnSidecar
|
|
552
|
+
const dataColumnSidecar = sszDeserialize(topic, serializedData) as fulu.DataColumnSidecar;
|
|
552
553
|
const dataColumnSlot = dataColumnSidecar.signedBlockHeader.message.slot;
|
|
553
554
|
const index = dataColumnSidecar.index;
|
|
554
555
|
|
|
@@ -821,11 +822,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
821
822
|
[GossipType.execution_payload]: async ({
|
|
822
823
|
gossipData,
|
|
823
824
|
topic,
|
|
825
|
+
seenTimestampSec,
|
|
824
826
|
}: GossipHandlerParamGeneric<GossipType.execution_payload>) => {
|
|
825
827
|
const {serializedData} = gossipData;
|
|
826
828
|
const executionPayloadEnvelope = sszDeserialize(topic, serializedData);
|
|
827
829
|
await validateGossipExecutionPayloadEnvelope(chain, executionPayloadEnvelope);
|
|
828
830
|
|
|
831
|
+
const slot = executionPayloadEnvelope.message.slot;
|
|
832
|
+
const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
|
|
833
|
+
metrics?.gossipExecutionPayloadEnvelope.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
834
|
+
|
|
829
835
|
// TODO GLOAS: Handle valid envelope. Need an import flow that calls `processExecutionPayloadEnvelope` and fork choice
|
|
830
836
|
},
|
|
831
837
|
[GossipType.payload_attestation_message]: async ({
|
|
@@ -19,6 +19,7 @@ export async function* onLightClientUpdatesByRange(
|
|
|
19
19
|
assertLightClientServer(chain.lightClientServer);
|
|
20
20
|
|
|
21
21
|
const count = Math.min(MAX_REQUEST_LIGHT_CLIENT_UPDATES, requestBody.count);
|
|
22
|
+
let started = false;
|
|
22
23
|
for (let period = requestBody.startPeriod; period < requestBody.startPeriod + count; period++) {
|
|
23
24
|
try {
|
|
24
25
|
const update = await chain.lightClientServer.getUpdate(period);
|
|
@@ -29,9 +30,13 @@ export async function* onLightClientUpdatesByRange(
|
|
|
29
30
|
data: type.serialize(update),
|
|
30
31
|
boundary,
|
|
31
32
|
};
|
|
33
|
+
started = true;
|
|
32
34
|
} catch (e) {
|
|
33
35
|
if ((e as LightClientServerError).type?.code === LightClientServerErrorCode.RESOURCE_UNAVAILABLE) {
|
|
34
|
-
|
|
36
|
+
// Period not available, if we already started yielding, stop to
|
|
37
|
+
// preserve consecutive order. Otherwise skip leading gaps.
|
|
38
|
+
if (started) return;
|
|
39
|
+
continue;
|
|
35
40
|
}
|
|
36
41
|
throw new ResponseError(RespStatus.SERVER_ERROR, (e as Error).message);
|
|
37
42
|
}
|
package/src/util/blobs.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
VERSIONED_HASH_VERSION_KZG,
|
|
14
14
|
} from "@lodestar/params";
|
|
15
15
|
import {signedBlockToSignedHeader} from "@lodestar/state-transition";
|
|
16
|
-
import {BeaconBlockBody, SSZTypesFor, SignedBeaconBlock, deneb, fulu, ssz} from "@lodestar/types";
|
|
16
|
+
import {BeaconBlockBody, DataColumnSidecars, SSZTypesFor, SignedBeaconBlock, deneb, fulu, ssz} from "@lodestar/types";
|
|
17
17
|
import {kzg} from "./kzg.js";
|
|
18
18
|
|
|
19
19
|
type VersionHash = Uint8Array;
|
|
@@ -149,7 +149,7 @@ export async function dataColumnMatrixRecovery(
|
|
|
149
149
|
* Reconstruct blobs from a set of data columns, at least 50%+ of all the columns
|
|
150
150
|
* must be provided to allow to reconstruct the full data matrix
|
|
151
151
|
*/
|
|
152
|
-
export async function reconstructBlobs(sidecars:
|
|
152
|
+
export async function reconstructBlobs(sidecars: DataColumnSidecars, indices?: number[]): Promise<deneb.Blobs> {
|
|
153
153
|
if (sidecars.length < NUMBER_OF_COLUMNS / 2) {
|
|
154
154
|
throw Error(
|
|
155
155
|
`Expected at least ${NUMBER_OF_COLUMNS / 2} data columns to reconstruct blobs, received ${sidecars.length}`
|
|
@@ -188,7 +188,7 @@ export async function reconstructBlobs(sidecars: fulu.DataColumnSidecars, indice
|
|
|
188
188
|
* Recover cells for specific blob indices from a set of data columns
|
|
189
189
|
*/
|
|
190
190
|
async function recoverBlobCells(
|
|
191
|
-
partialSidecars:
|
|
191
|
+
partialSidecars: DataColumnSidecars,
|
|
192
192
|
blobIndices: number[]
|
|
193
193
|
): Promise<Map<number, fulu.Cell[]> | null> {
|
|
194
194
|
const columnCount = partialSidecars.length;
|
package/src/util/dataColumns.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {ChainForkConfig} from "@lodestar/config";
|
|
|
4
4
|
import {
|
|
5
5
|
ForkAll,
|
|
6
6
|
ForkName,
|
|
7
|
+
ForkPostDeneb,
|
|
7
8
|
ForkPostFulu,
|
|
8
9
|
ForkPreGloas,
|
|
9
10
|
KZG_COMMITMENTS_GINDEX,
|
|
@@ -15,9 +16,11 @@ import {
|
|
|
15
16
|
BeaconBlockBody,
|
|
16
17
|
ColumnIndex,
|
|
17
18
|
CustodyIndex,
|
|
19
|
+
Root,
|
|
18
20
|
SSZTypesFor,
|
|
19
21
|
SignedBeaconBlock,
|
|
20
22
|
SignedBeaconBlockHeader,
|
|
23
|
+
Slot,
|
|
21
24
|
deneb,
|
|
22
25
|
fulu,
|
|
23
26
|
gloas,
|
|
@@ -269,7 +272,7 @@ export async function getCellsAndProofs(
|
|
|
269
272
|
*/
|
|
270
273
|
export function getBlobKzgCommitments(
|
|
271
274
|
fork: ForkName,
|
|
272
|
-
signedBlock: SignedBeaconBlock<
|
|
275
|
+
signedBlock: SignedBeaconBlock<ForkPostDeneb>
|
|
273
276
|
): deneb.KZGCommitment[] {
|
|
274
277
|
if (isForkPostGloas(fork)) {
|
|
275
278
|
return (signedBlock as gloas.SignedBeaconBlock).message.body.signedExecutionPayloadBid.message.blobKzgCommitments;
|
|
@@ -359,6 +362,39 @@ export function getDataColumnSidecarsFromColumnSidecar(
|
|
|
359
362
|
);
|
|
360
363
|
}
|
|
361
364
|
|
|
365
|
+
/**
|
|
366
|
+
* In Gloas, data column sidecars have a simplified structure with `slot` and `beaconBlockRoot`
|
|
367
|
+
* instead of `signedBlockHeader`, `kzgCommitments`, and `kzgCommitmentsInclusionProof`.
|
|
368
|
+
*/
|
|
369
|
+
export function getDataColumnSidecarsForGloas(
|
|
370
|
+
slot: Slot,
|
|
371
|
+
beaconBlockRoot: Root,
|
|
372
|
+
cellsAndKzgProofs: {cells: Uint8Array[]; proofs: Uint8Array[]}[]
|
|
373
|
+
): gloas.DataColumnSidecars {
|
|
374
|
+
// No need to create data column sidecars if there are no blobs
|
|
375
|
+
if (cellsAndKzgProofs.length === 0) {
|
|
376
|
+
return [];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const sidecars: gloas.DataColumnSidecars = [];
|
|
380
|
+
for (let columnIndex = 0; columnIndex < NUMBER_OF_COLUMNS; columnIndex++) {
|
|
381
|
+
const column: Uint8Array[] = [];
|
|
382
|
+
const kzgProofs: Uint8Array[] = [];
|
|
383
|
+
for (const {cells, proofs} of cellsAndKzgProofs) {
|
|
384
|
+
column.push(cells[columnIndex]);
|
|
385
|
+
kzgProofs.push(proofs[columnIndex]);
|
|
386
|
+
}
|
|
387
|
+
sidecars.push({
|
|
388
|
+
index: columnIndex,
|
|
389
|
+
column,
|
|
390
|
+
kzgProofs,
|
|
391
|
+
slot,
|
|
392
|
+
beaconBlockRoot,
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
return sidecars;
|
|
396
|
+
}
|
|
397
|
+
|
|
362
398
|
/**
|
|
363
399
|
* If we receive more than half of NUMBER_OF_COLUMNS (64) we should recover all remaining columns
|
|
364
400
|
*/
|
package/src/util/multifork.ts
CHANGED
|
@@ -9,6 +9,11 @@ import {getSlotFromSignedBeaconBlockSerialized} from "./sszBytes.js";
|
|
|
9
9
|
*/
|
|
10
10
|
const SLOT_BYTE_COUNT = 8;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* SSZ offset uint32
|
|
14
|
+
*/
|
|
15
|
+
const OFFSET_BYTE_COUNT = 4;
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* 8 + 32 = 40
|
|
14
19
|
* ```
|
|
@@ -67,3 +72,43 @@ export function getLightClientHeaderTypeFromBytes(
|
|
|
67
72
|
);
|
|
68
73
|
return config.getPostAltairForkTypes(slot).LightClientHeader;
|
|
69
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Position of first offset in DataColumnSidecar (after index field)
|
|
78
|
+
*
|
|
79
|
+
* Fulu DataColumnSidecar (6 fields):
|
|
80
|
+
* index: uint64 [fixed - 8 bytes]
|
|
81
|
+
* column: List [variable - 4-byte offset]
|
|
82
|
+
* kzgCommitments: List [variable - 4-byte offset]
|
|
83
|
+
* kzgProofs: List [variable - 4-byte offset]
|
|
84
|
+
* signedBlockHeader: Container [fixed - 208 bytes]
|
|
85
|
+
* kzgCommitmentsInclusionProof: Vector[Bytes32, 4] [fixed - 128 bytes]
|
|
86
|
+
* => First offset value = 8 + 4 + 4 + 4 + 208 + 128 = 356
|
|
87
|
+
*
|
|
88
|
+
* Gloas DataColumnSidecar (5 fields):
|
|
89
|
+
* index: uint64 [fixed - 8 bytes]
|
|
90
|
+
* column: List [variable - 4-byte offset]
|
|
91
|
+
* kzgProofs: List [variable - 4-byte offset]
|
|
92
|
+
* slot: uint64 [fixed - 8 bytes]
|
|
93
|
+
* beaconBlockRoot: Bytes32 [fixed - 32 bytes]
|
|
94
|
+
* => First offset value = 8 + 4 + 4 + 8 + 32 = 56
|
|
95
|
+
*/
|
|
96
|
+
const FIRST_OFFSET_POSITION_IN_DATA_COLUMN_SIDECAR = 8;
|
|
97
|
+
const GLOAS_DATA_COLUMN_SIDECAR_FIRST_OFFSET = 56;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Determines if DataColumnSidecar bytes are from Gloas fork by checking the SSZ offset structure.
|
|
101
|
+
*
|
|
102
|
+
* The first offset (bytes 8-12) indicates where variable-size data begins:
|
|
103
|
+
* - Gloas: 56 (small fixed section)
|
|
104
|
+
* - Fulu: 356
|
|
105
|
+
*/
|
|
106
|
+
export function isGloasDataColumnSidecarBytes(bytes: Uint8Array): boolean {
|
|
107
|
+
const firstOffset = bytesToInt(
|
|
108
|
+
bytes.subarray(
|
|
109
|
+
FIRST_OFFSET_POSITION_IN_DATA_COLUMN_SIDECAR,
|
|
110
|
+
FIRST_OFFSET_POSITION_IN_DATA_COLUMN_SIDECAR + OFFSET_BYTE_COUNT
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
return firstOffset === GLOAS_DATA_COLUMN_SIDECAR_FIRST_OFFSET;
|
|
114
|
+
}
|
|
@@ -14,6 +14,11 @@ export class SerializedCache {
|
|
|
14
14
|
this.map.set(obj, serialized);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Replace the internal WeakMap to force GC of all cached entries.
|
|
19
|
+
* Must only be called after all DB writes that may read from this cache have completed,
|
|
20
|
+
* otherwise cached serialized bytes will be unavailable and data will be re-serialized unnecessarily.
|
|
21
|
+
*/
|
|
17
22
|
clear(): void {
|
|
18
23
|
this.map = new WeakMap();
|
|
19
24
|
}
|