@lodestar/beacon-node 2.1.0-dev.ab28ad52c3 → 2.1.0-dev.b091dc24a3
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 +1 -3
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +3 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +3 -1
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +3 -0
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +3 -1
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/chain.d.ts +2 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +5 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +7 -0
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +1 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -0
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +1 -0
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +1 -0
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +5 -1
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts +16 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts.map +1 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js +56 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js.map +1 -0
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +12 -2
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +60 -2
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/util/dataColumns.d.ts +2 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +7 -2
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +2 -1
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -2
- package/lib/util/execution.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +1 -5
- package/src/chain/ColumnReconstructionTracker.ts +5 -1
- package/src/chain/GetBlobsTracker.ts +5 -0
- package/src/chain/chain.ts +5 -0
- package/src/chain/errors/dataColumnSidecarError.ts +8 -0
- package/src/chain/interface.ts +2 -0
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenBlockProposers.ts +11 -1
- package/src/chain/seenCache/seenDataColumnSidecars.ts +64 -0
- package/src/chain/validation/block.ts +11 -2
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/network/processor/gossipHandlers.ts +106 -2
- package/src/util/dataColumns.ts +13 -1
- package/src/util/execution.ts +16 -1
|
@@ -12,7 +12,11 @@ import {
|
|
|
12
12
|
isForkPostElectra,
|
|
13
13
|
isForkPostGloas,
|
|
14
14
|
} from "@lodestar/params";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
computeTimeAtSlot,
|
|
17
|
+
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
18
|
+
signedBlockToSignedHeader,
|
|
19
|
+
} from "@lodestar/state-transition";
|
|
16
20
|
import {
|
|
17
21
|
Root,
|
|
18
22
|
RootHex,
|
|
@@ -25,6 +29,7 @@ import {
|
|
|
25
29
|
gloas,
|
|
26
30
|
isGloasBeaconBlock,
|
|
27
31
|
isGloasDataColumnSidecar,
|
|
32
|
+
phase0,
|
|
28
33
|
ssz,
|
|
29
34
|
sszTypesFor,
|
|
30
35
|
} from "@lodestar/types";
|
|
@@ -380,6 +385,28 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
380
385
|
}
|
|
381
386
|
}
|
|
382
387
|
|
|
388
|
+
// The block input may have been pruned before the block was imported
|
|
389
|
+
if (
|
|
390
|
+
chain.seenDataColumnSidecars.isKnown(
|
|
391
|
+
slot,
|
|
392
|
+
dataColumnBlockHeader.proposerIndex,
|
|
393
|
+
dataColumnSidecar.index,
|
|
394
|
+
blockRootHex
|
|
395
|
+
)
|
|
396
|
+
) {
|
|
397
|
+
metrics?.peerDas.dataColumnSidecarProcessingSkip.inc();
|
|
398
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
399
|
+
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
400
|
+
columnIndex: dataColumnSidecar.index,
|
|
401
|
+
slot,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (isRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex)) {
|
|
406
|
+
await observeRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex);
|
|
407
|
+
throw repeatColumnProposalError(dataColumnSidecar, blockRootHex);
|
|
408
|
+
}
|
|
409
|
+
|
|
383
410
|
const verificationTimer = metrics?.peerDas.dataColumnSidecarGossipVerificationTime.startTimer();
|
|
384
411
|
|
|
385
412
|
const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
|
|
@@ -388,6 +415,17 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
388
415
|
|
|
389
416
|
try {
|
|
390
417
|
await validateGossipFuluDataColumnSidecar(chain, dataColumnSidecar, gossipSubnet, metrics);
|
|
418
|
+
observeColumnBlockHeader(chain, dataColumnSidecar.signedBlockHeader, blockRootHex);
|
|
419
|
+
// Another block root may have been seen for the same tuple while validating
|
|
420
|
+
if (isRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex)) {
|
|
421
|
+
throw repeatColumnProposalError(dataColumnSidecar, blockRootHex);
|
|
422
|
+
}
|
|
423
|
+
chain.seenDataColumnSidecars.add(
|
|
424
|
+
slot,
|
|
425
|
+
dataColumnBlockHeader.proposerIndex,
|
|
426
|
+
dataColumnSidecar.index,
|
|
427
|
+
blockRootHex
|
|
428
|
+
);
|
|
391
429
|
const blockInput = chain.seenBlockInputCache.getByColumn({
|
|
392
430
|
blockRootHex,
|
|
393
431
|
columnSidecar: dataColumnSidecar,
|
|
@@ -719,7 +757,12 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
719
757
|
e.type.code === BlockErrorCode.REPEAT_PROPOSAL &&
|
|
720
758
|
// Only a signature-verified sibling recorded in the seen cache is imported. The cache holds at most two
|
|
721
759
|
// roots per proposer and slot, which bounds full imports over gossip to one alternate
|
|
722
|
-
chain.seenBlockProposers.
|
|
760
|
+
chain.seenBlockProposers.hasBlockSignature(
|
|
761
|
+
signedBlock.message.slot,
|
|
762
|
+
e.type.proposerIndex,
|
|
763
|
+
e.type.root,
|
|
764
|
+
signedBlock.signature
|
|
765
|
+
) &&
|
|
723
766
|
// A sibling with an unknown parent cannot be imported, sync fetches it if its branch becomes relevant
|
|
724
767
|
chain.forkChoice.getBlockHexDefaultStatus(toRootHex(signedBlock.message.parentRoot)) !== null &&
|
|
725
768
|
(!isGloasBeaconBlock(signedBlock.message) ||
|
|
@@ -1663,3 +1706,64 @@ function getCutoffTimeMs(
|
|
|
1663
1706
|
0
|
|
1664
1707
|
);
|
|
1665
1708
|
}
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* [IGNORE] The sidecar is the first sidecar for the tuple (block_header.slot, block_header.proposer_index, sidecar.index)
|
|
1712
|
+
* with valid header signature, sidecar inclusion proof, and kzg proof
|
|
1713
|
+
*/
|
|
1714
|
+
function isRepeatColumnProposal(
|
|
1715
|
+
chain: IBeaconChain,
|
|
1716
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1717
|
+
blockRootHex: RootHex
|
|
1718
|
+
): boolean {
|
|
1719
|
+
const {slot, proposerIndex} = dataColumnSidecar.signedBlockHeader.message;
|
|
1720
|
+
return chain.seenDataColumnSidecars.isRepeatProposal(slot, proposerIndex, dataColumnSidecar.index, blockRootHex);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
function repeatColumnProposalError(
|
|
1724
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1725
|
+
blockRootHex: RootHex
|
|
1726
|
+
): DataColumnSidecarGossipError {
|
|
1727
|
+
const {slot, proposerIndex} = dataColumnSidecar.signedBlockHeader.message;
|
|
1728
|
+
return new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
1729
|
+
code: DataColumnSidecarErrorCode.REPEAT_PROPOSAL,
|
|
1730
|
+
slot,
|
|
1731
|
+
proposerIndex,
|
|
1732
|
+
columnIndex: dataColumnSidecar.index,
|
|
1733
|
+
root: blockRootHex,
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
function observeColumnBlockHeader(
|
|
1738
|
+
chain: IBeaconChain,
|
|
1739
|
+
signedBlockHeader: phase0.SignedBeaconBlockHeader,
|
|
1740
|
+
blockRootHex: RootHex
|
|
1741
|
+
): void {
|
|
1742
|
+
const {slot, proposerIndex} = signedBlockHeader.message;
|
|
1743
|
+
chain.seenBlockProposers.observeBlockRoot(slot, proposerIndex, blockRootHex, signedBlockHeader);
|
|
1744
|
+
if (chain.seenBlockProposers.isEquivocating(slot, proposerIndex)) {
|
|
1745
|
+
chain.processProposerEquivocation(slot, proposerIndex);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
async function observeRepeatColumnProposal(
|
|
1750
|
+
chain: IBeaconChain,
|
|
1751
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1752
|
+
blockRootHex: RootHex
|
|
1753
|
+
): Promise<void> {
|
|
1754
|
+
const {signedBlockHeader} = dataColumnSidecar;
|
|
1755
|
+
const {slot, proposerIndex} = signedBlockHeader.message;
|
|
1756
|
+
// Only needed as slashing evidence, so verify at most one conflicting header per slot and proposer
|
|
1757
|
+
if (
|
|
1758
|
+
chain.seenBlockProposers.hasBlockRoot(slot, proposerIndex, blockRootHex) ||
|
|
1759
|
+
chain.seenBlockProposers.isEquivocating(slot, proposerIndex) ||
|
|
1760
|
+
!chain.seenDataColumnSidecars.markEvidenceCheck(slot, proposerIndex)
|
|
1761
|
+
) {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(chain.config, signedBlockHeader);
|
|
1766
|
+
if (await chain.bls.verifySignatureSets([signatureSet])) {
|
|
1767
|
+
observeColumnBlockHeader(chain, signedBlockHeader, blockRootHex);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
package/src/util/dataColumns.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {BlockInputColumns} from "../chain/blocks/blockInput/blockInput.js";
|
|
|
33
33
|
import {BlockInputSource} from "../chain/blocks/blockInput/types.js";
|
|
34
34
|
import {PayloadEnvelopeInput, PayloadEnvelopeInputSource} from "../chain/blocks/payloadEnvelopeInput/index.js";
|
|
35
35
|
import {ChainEvent, ChainEventEmitter} from "../chain/emitter.js";
|
|
36
|
+
import {SeenDataColumnSidecars} from "../chain/seenCache/seenDataColumnSidecars.js";
|
|
36
37
|
import {Metrics} from "../metrics/metrics.js";
|
|
37
38
|
import {NodeId} from "../network/subnets/index.js";
|
|
38
39
|
import {dataColumnMatrixRecovery} from "./blobs.js";
|
|
@@ -434,6 +435,7 @@ export function getGloasDataColumnSidecars(
|
|
|
434
435
|
export async function recoverDataColumnSidecars(
|
|
435
436
|
input: BlockInputColumns | PayloadEnvelopeInput,
|
|
436
437
|
emitter: ChainEventEmitter,
|
|
438
|
+
seenDataColumnSidecars: SeenDataColumnSidecars,
|
|
437
439
|
metrics: Metrics | null
|
|
438
440
|
): Promise<DataColumnReconstructionCode> {
|
|
439
441
|
const existingColumns = input.getAllColumns();
|
|
@@ -486,6 +488,7 @@ export async function recoverDataColumnSidecars(
|
|
|
486
488
|
const sidecarsToPublish: DataColumnSidecar[] = [];
|
|
487
489
|
for (const columnSidecar of fullSidecars) {
|
|
488
490
|
if (!input.hasColumn(columnSidecar.index)) {
|
|
491
|
+
let isRepeatProposal = false;
|
|
489
492
|
if (input instanceof PayloadEnvelopeInput) {
|
|
490
493
|
if (!isGloasDataColumnSidecar(columnSidecar)) {
|
|
491
494
|
throw new Error(`Expected gloas DataColumnSidecar for block ${input.blockRootHex}`);
|
|
@@ -505,9 +508,18 @@ export async function recoverDataColumnSidecars(
|
|
|
505
508
|
seenTimestampSec: Date.now() / 1000,
|
|
506
509
|
source: BlockInputSource.recovery,
|
|
507
510
|
});
|
|
511
|
+
// Reconstructed columns count as received via gossip for the repeat proposal check
|
|
512
|
+
const {slot, proposerIndex} = columnSidecar.signedBlockHeader.message;
|
|
513
|
+
isRepeatProposal = seenDataColumnSidecars.isRepeatProposal(
|
|
514
|
+
slot,
|
|
515
|
+
proposerIndex,
|
|
516
|
+
columnSidecar.index,
|
|
517
|
+
input.blockRootHex
|
|
518
|
+
);
|
|
519
|
+
seenDataColumnSidecars.add(slot, proposerIndex, columnSidecar.index, input.blockRootHex);
|
|
508
520
|
}
|
|
509
521
|
sidecarsReconstructed.push(columnSidecar);
|
|
510
|
-
if (missingSampledColumns.has(columnSidecar.index)) {
|
|
522
|
+
if (missingSampledColumns.has(columnSidecar.index) && !isRepeatProposal) {
|
|
511
523
|
sidecarsToPublish.push(columnSidecar);
|
|
512
524
|
}
|
|
513
525
|
}
|
package/src/util/execution.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
EnvelopeReconstructionError,
|
|
12
12
|
EnvelopeReconstructionErrorCode,
|
|
13
13
|
} from "../chain/errors/envelopeReconstructionError.js";
|
|
14
|
+
import {SeenDataColumnSidecars} from "../chain/seenCache/seenDataColumnSidecars.js";
|
|
14
15
|
import {IBeaconDb} from "../db/index.js";
|
|
15
16
|
import {ArchivedEnvelope, decodeArchivedEnvelope} from "../db/repositories/index.js";
|
|
16
17
|
import {IExecutionEngine} from "../execution/index.js";
|
|
@@ -48,6 +49,7 @@ export async function getDataColumnSidecarsFromExecution(
|
|
|
48
49
|
config: ChainForkConfig,
|
|
49
50
|
executionEngine: Pick<IExecutionEngine, "getBlobs">,
|
|
50
51
|
emitter: ChainEventEmitter,
|
|
52
|
+
seenDataColumnSidecars: SeenDataColumnSidecars,
|
|
51
53
|
input: IBlockInput | PayloadEnvelopeInput,
|
|
52
54
|
metrics: Metrics | null,
|
|
53
55
|
blobAndProofBuffers?: Uint8Array[]
|
|
@@ -112,8 +114,18 @@ export async function getDataColumnSidecarsFromExecution(
|
|
|
112
114
|
const previouslyMissingColumns = input.getMissingSampledColumnMeta().missing;
|
|
113
115
|
const sampledColumns = previouslyMissingColumns.map((columnIndex) => dataColumnSidecars[columnIndex]);
|
|
114
116
|
|
|
117
|
+
const columnsToPublish = sampledColumns.filter(
|
|
118
|
+
(columnSidecar) =>
|
|
119
|
+
isGloasDataColumnSidecar(columnSidecar) ||
|
|
120
|
+
!seenDataColumnSidecars.isRepeatProposal(
|
|
121
|
+
columnSidecar.signedBlockHeader.message.slot,
|
|
122
|
+
columnSidecar.signedBlockHeader.message.proposerIndex,
|
|
123
|
+
columnSidecar.index,
|
|
124
|
+
input.blockRootHex
|
|
125
|
+
)
|
|
126
|
+
);
|
|
115
127
|
// for columns we have already seen, publishDataColumnSidecar() catches PublishError.Duplicate and marks alreadyPublished=true
|
|
116
|
-
emitter.emit(ChainEvent.publishDataColumns,
|
|
128
|
+
emitter.emit(ChainEvent.publishDataColumns, columnsToPublish);
|
|
117
129
|
// TODO: Can we record dataColumns.sentPeersPerSubnet metric here somehow
|
|
118
130
|
|
|
119
131
|
// add all sampled columns to the input, even if we didn't sample them
|
|
@@ -145,6 +157,9 @@ export async function getDataColumnSidecarsFromExecution(
|
|
|
145
157
|
source: BlockInputSource.engine,
|
|
146
158
|
seenTimestampSec,
|
|
147
159
|
});
|
|
160
|
+
// Columns from the execution layer count as received via gossip for the repeat proposal check
|
|
161
|
+
const {slot, proposerIndex} = columnSidecar.signedBlockHeader.message;
|
|
162
|
+
seenDataColumnSidecars.add(slot, proposerIndex, columnSidecar.index, input.blockRootHex);
|
|
148
163
|
}
|
|
149
164
|
|
|
150
165
|
if (emitter.listenerCount(routes.events.EventType.dataColumnSidecar)) {
|