@lodestar/beacon-node 2.1.0-dev.52f6c9664e → 2.1.0-dev.5b89ed1248
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 +24 -5
- 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.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- 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/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +4 -2
- 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 +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/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +1 -0
- 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 +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 +6 -0
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +13 -8
- 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 -20
- 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 +29 -5
- package/src/chain/forkChoice/index.ts +235 -13
- package/src/chain/opPools/opPool.ts +27 -16
- package/src/chain/options.ts +1 -0
- package/src/chain/seenCache/seenGossipBlockInput.ts +1 -1
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
- package/src/chain/validation/attestation.ts +4 -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/chain.ts +1 -0
- package/src/sync/range/range.ts +7 -1
- package/src/sync/unknownBlock.ts +20 -1
- package/src/sync/utils/downloadByRange.ts +27 -7
- package/src/sync/utils/downloadByRoot.ts +12 -9
- package/src/sync/utils/pendingBlocksTree.ts +6 -1
- package/src/util/sszBytes.ts +7 -8
|
@@ -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/chain.ts
CHANGED
|
@@ -627,6 +627,7 @@ export class SyncChain {
|
|
|
627
627
|
case DownloadByRangeErrorCode.INVALID_ENVELOPE_BLOCK_HASH:
|
|
628
628
|
case DownloadByRangeErrorCode.INVALID_ENVELOPE_SLOT:
|
|
629
629
|
case DownloadByRangeErrorCode.INVALID_CHAIN_SEGMENT:
|
|
630
|
+
case DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS:
|
|
630
631
|
case DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT:
|
|
631
632
|
case DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT:
|
|
632
633
|
case DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
|
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) {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ForkName,
|
|
4
|
+
ForkPostDeneb,
|
|
5
|
+
ForkPostFulu,
|
|
6
|
+
ForkPostGloas,
|
|
7
|
+
isForkPostDeneb,
|
|
8
|
+
isForkPostFulu,
|
|
9
|
+
isForkPostGloas,
|
|
10
|
+
} from "@lodestar/params";
|
|
11
|
+
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
3
12
|
import {
|
|
4
13
|
ColumnIndex,
|
|
5
14
|
DataColumnSidecar,
|
|
@@ -697,6 +706,15 @@ export function validateBlockByRangeResponse(
|
|
|
697
706
|
|
|
698
707
|
for (let i = 0; i < blocks.length; i++) {
|
|
699
708
|
const block = blocks[i];
|
|
709
|
+
const slot = block.message.slot;
|
|
710
|
+
const fork = config.getForkName(slot);
|
|
711
|
+
if (isForkPostDeneb(fork)) {
|
|
712
|
+
const count = getBlobKzgCommitments(fork, block as SignedBeaconBlock<ForkPostDeneb>).length;
|
|
713
|
+
const limit = config.getMaxBlobsPerBlock(computeEpochAtSlot(slot));
|
|
714
|
+
if (count > limit) {
|
|
715
|
+
throw new DownloadByRangeError({code: DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS, slot, count, limit});
|
|
716
|
+
}
|
|
717
|
+
}
|
|
700
718
|
const blockRoot = type.hashTreeRoot(block.message);
|
|
701
719
|
response.push({block, blockRoot});
|
|
702
720
|
|
|
@@ -825,12 +843,7 @@ export async function validateColumnsByRangeResponse(
|
|
|
825
843
|
}
|
|
826
844
|
|
|
827
845
|
seenSlotColumns.set(columnSidecar.index, columnSidecar);
|
|
828
|
-
|
|
829
|
-
// a new slot has started, reset index
|
|
830
|
-
currentIndex = -1;
|
|
831
|
-
} else {
|
|
832
|
-
currentIndex = columnSidecar.index;
|
|
833
|
-
}
|
|
846
|
+
currentIndex = columnSidecar.index;
|
|
834
847
|
currentSlot = slot;
|
|
835
848
|
}
|
|
836
849
|
|
|
@@ -1030,6 +1043,7 @@ export enum DownloadByRangeErrorCode {
|
|
|
1030
1043
|
|
|
1031
1044
|
PARENT_ROOT_MISMATCH = "DOWNLOAD_BY_RANGE_ERROR_PARENT_ROOT_MISMATCH",
|
|
1032
1045
|
EXTRA_BLOCKS = "DOWNLOAD_BY_RANGE_ERROR_EXTRA_BLOCKS",
|
|
1046
|
+
TOO_MANY_KZG_COMMITMENTS = "DOWNLOAD_BY_RANGE_ERROR_TOO_MANY_KZG_COMMITMENTS",
|
|
1033
1047
|
OUT_OF_RANGE_BLOCKS = "DOWNLOAD_BY_RANGE_OUT_OF_RANGE_BLOCKS",
|
|
1034
1048
|
OUT_OF_ORDER_BLOCKS = "DOWNLOAD_BY_RANGE_OUT_OF_ORDER_BLOCKS",
|
|
1035
1049
|
|
|
@@ -1072,6 +1086,12 @@ export type DownloadByRangeErrorType =
|
|
|
1072
1086
|
columnSidecarCount: number;
|
|
1073
1087
|
payloadEnvelopeCount: number;
|
|
1074
1088
|
}
|
|
1089
|
+
| {
|
|
1090
|
+
code: DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS;
|
|
1091
|
+
slot: Slot;
|
|
1092
|
+
count: number;
|
|
1093
|
+
limit: number;
|
|
1094
|
+
}
|
|
1075
1095
|
| {
|
|
1076
1096
|
code: DownloadByRangeErrorCode.OUT_OF_RANGE_BLOCKS;
|
|
1077
1097
|
slot: number;
|
|
@@ -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
|
}
|