@lodestar/beacon-node 1.44.0-dev.d730eae4b6 → 1.44.0-dev.de5436c9ff
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 +13 -5
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +28 -0
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +8 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +4 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +7 -7
- package/lib/chain/forkChoice/index.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/network/gossip/topic.d.ts +19 -766
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/processor/index.d.ts +2 -2
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +24 -22
- package/lib/network/processor/index.js.map +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +16 -11
- package/lib/util/dataColumns.js.map +1 -1
- package/package.json +14 -14
- package/src/api/impl/beacon/blocks/index.ts +13 -5
- package/src/api/impl/lodestar/index.ts +30 -0
- package/src/chain/chain.ts +10 -1
- package/src/chain/forkChoice/index.ts +8 -0
- package/src/chain/options.ts +1 -0
- package/src/network/processor/index.ts +26 -26
- package/src/util/dataColumns.ts +17 -12
|
@@ -2,6 +2,7 @@ import {ChainForkConfig} from "@lodestar/config";
|
|
|
2
2
|
import {
|
|
3
3
|
ExecutionStatus,
|
|
4
4
|
ForkChoice,
|
|
5
|
+
ForkChoiceStateGetter,
|
|
5
6
|
ForkChoiceStore,
|
|
6
7
|
JustifiedBalancesGetter,
|
|
7
8
|
PayloadStatus,
|
|
@@ -45,6 +46,7 @@ export function initializeForkChoice(
|
|
|
45
46
|
isFinalizedState: boolean,
|
|
46
47
|
opts: ForkChoiceOpts,
|
|
47
48
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
49
|
+
stateGetter: ForkChoiceStateGetter,
|
|
48
50
|
metrics: Metrics | null,
|
|
49
51
|
logger?: Logger
|
|
50
52
|
): ForkChoice {
|
|
@@ -56,6 +58,7 @@ export function initializeForkChoice(
|
|
|
56
58
|
state,
|
|
57
59
|
opts,
|
|
58
60
|
justifiedBalancesGetter,
|
|
61
|
+
stateGetter,
|
|
59
62
|
metrics,
|
|
60
63
|
logger
|
|
61
64
|
)
|
|
@@ -66,6 +69,7 @@ export function initializeForkChoice(
|
|
|
66
69
|
state,
|
|
67
70
|
opts,
|
|
68
71
|
justifiedBalancesGetter,
|
|
72
|
+
stateGetter,
|
|
69
73
|
metrics,
|
|
70
74
|
logger
|
|
71
75
|
);
|
|
@@ -81,6 +85,7 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
81
85
|
state: IBeaconStateView,
|
|
82
86
|
opts: ForkChoiceOpts,
|
|
83
87
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
88
|
+
stateGetter: ForkChoiceStateGetter,
|
|
84
89
|
metrics: Metrics | null,
|
|
85
90
|
logger?: Logger
|
|
86
91
|
): ForkChoice {
|
|
@@ -112,6 +117,7 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
112
117
|
finalizedCheckpoint,
|
|
113
118
|
justifiedBalances,
|
|
114
119
|
justifiedBalancesGetter,
|
|
120
|
+
stateGetter,
|
|
115
121
|
{
|
|
116
122
|
onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
|
|
117
123
|
onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
|
|
@@ -172,6 +178,7 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
172
178
|
unfinalizedState: IBeaconStateView,
|
|
173
179
|
opts: ForkChoiceOpts,
|
|
174
180
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
181
|
+
stateGetter: ForkChoiceStateGetter,
|
|
175
182
|
metrics: Metrics | null,
|
|
176
183
|
logger?: Logger
|
|
177
184
|
): ForkChoice {
|
|
@@ -203,6 +210,7 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
203
210
|
finalizedCheckpoint,
|
|
204
211
|
justifiedBalances,
|
|
205
212
|
justifiedBalancesGetter,
|
|
213
|
+
stateGetter,
|
|
206
214
|
{
|
|
207
215
|
onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
|
|
208
216
|
onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
|
package/src/chain/options.ts
CHANGED
|
@@ -105,6 +105,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
105
105
|
proposerBoost: true,
|
|
106
106
|
proposerBoostReorg: true,
|
|
107
107
|
computeUnrealized: true,
|
|
108
|
+
fastConfirmation: false,
|
|
108
109
|
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
|
|
109
110
|
serveHistoricalState: false,
|
|
110
111
|
assertCorrectProgressiveBalances: false,
|
|
@@ -186,9 +186,11 @@ export class NetworkProcessor {
|
|
|
186
186
|
// we may not receive the block for messages like Attestation and SignedAggregateAndProof messages, in that case PendingGossipsubMessage needs
|
|
187
187
|
// to be stored in this Map and reprocessed once the block comes
|
|
188
188
|
private readonly awaitingMessagesByBlockRoot: MapDef<RootHex, Set<PendingGossipsubMessage>>;
|
|
189
|
+
private awaitingBlockMessageCount = 0;
|
|
189
190
|
// we may not receive the payload for messages that require the FULL payload variant to be processed,
|
|
190
191
|
// in that case PendingGossipsubMessage needs to be stored in this Map and reprocessed once the payload comes
|
|
191
192
|
private readonly awaitingMessagesByPayloadBlockRoot: MapDef<RootHex, Set<PendingGossipsubMessage>>;
|
|
193
|
+
private awaitingPayloadMessageCount = 0;
|
|
192
194
|
private unknownBlocksBySlot = new MapDef<Slot, Set<RootHex>>(() => new Set());
|
|
193
195
|
private unknownEnvelopesBySlot = new MapDef<Slot, Set<RootHex>>(() => new Set());
|
|
194
196
|
|
|
@@ -228,8 +230,8 @@ export class NetworkProcessor {
|
|
|
228
230
|
metrics.gossipValidationQueue.keySize.set({topic}, this.gossipQueues[topic].keySize);
|
|
229
231
|
metrics.gossipValidationQueue.concurrency.set({topic}, this.gossipTopicConcurrency[topic]);
|
|
230
232
|
}
|
|
231
|
-
metrics.awaitingBlockGossipMessages.countPerSlot.set(this.
|
|
232
|
-
metrics.awaitingPayloadGossipMessages.countPerSlot.set(this.
|
|
233
|
+
metrics.awaitingBlockGossipMessages.countPerSlot.set(this.awaitingBlockMessageCount);
|
|
234
|
+
metrics.awaitingPayloadGossipMessages.countPerSlot.set(this.awaitingPayloadMessageCount);
|
|
233
235
|
// specific metric for beacon_attestation topic
|
|
234
236
|
metrics.gossipValidationQueue.keyAge.reset();
|
|
235
237
|
for (const ageMs of this.gossipQueues.beacon_attestation.getDataAgeMs()) {
|
|
@@ -497,7 +499,7 @@ export class NetworkProcessor {
|
|
|
497
499
|
this.pushPendingGossipsubMessageToQueue(message);
|
|
498
500
|
break;
|
|
499
501
|
case PreprocessAction.AwaitBlock: {
|
|
500
|
-
if (this.
|
|
502
|
+
if (this.awaitingBlockMessageCount > MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS) {
|
|
501
503
|
// No need to report the dropped job to gossip. It will be eventually pruned from the mcache
|
|
502
504
|
this.metrics?.awaitingBlockGossipMessages.reject.inc({
|
|
503
505
|
reason: ReprocessRejectReason.reached_limit,
|
|
@@ -509,10 +511,11 @@ export class NetworkProcessor {
|
|
|
509
511
|
this.metrics?.awaitingBlockGossipMessages.queue.inc({topic: topicType});
|
|
510
512
|
const awaitingGossipsubMessages = this.awaitingMessagesByBlockRoot.getOrDefault(preprocessResult.root);
|
|
511
513
|
awaitingGossipsubMessages.add(message);
|
|
514
|
+
this.awaitingBlockMessageCount++;
|
|
512
515
|
break;
|
|
513
516
|
}
|
|
514
517
|
case PreprocessAction.AwaitEnvelope: {
|
|
515
|
-
if (this.
|
|
518
|
+
if (this.awaitingPayloadMessageCount > MAX_QUEUED_UNKNOWN_PAYLOAD_GOSSIP_OBJECTS) {
|
|
516
519
|
this.metrics?.awaitingPayloadGossipMessages.reject.inc({
|
|
517
520
|
reason: ReprocessRejectReason.reached_limit,
|
|
518
521
|
topic: topicType,
|
|
@@ -525,6 +528,7 @@ export class NetworkProcessor {
|
|
|
525
528
|
preprocessResult.root
|
|
526
529
|
);
|
|
527
530
|
awaitingPayloadGossipsubMessages.add(message);
|
|
531
|
+
this.awaitingPayloadMessageCount++;
|
|
528
532
|
break;
|
|
529
533
|
}
|
|
530
534
|
}
|
|
@@ -548,6 +552,12 @@ export class NetworkProcessor {
|
|
|
548
552
|
return;
|
|
549
553
|
}
|
|
550
554
|
|
|
555
|
+
// Atomically remove from map and update counter before async iteration to
|
|
556
|
+
// prevent double-decrement race with onClockSlot during yield points below
|
|
557
|
+
if (this.awaitingMessagesByBlockRoot.delete(rootHex)) {
|
|
558
|
+
this.awaitingBlockMessageCount -= waitingGossipsubMessages.size;
|
|
559
|
+
}
|
|
560
|
+
|
|
551
561
|
const nowSec = Date.now() / 1000;
|
|
552
562
|
let count = 0;
|
|
553
563
|
// TODO: we can group attestations to process in batches but since we have the SeenAttestationDatas
|
|
@@ -567,8 +577,6 @@ export class NetworkProcessor {
|
|
|
567
577
|
await sleep(AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS);
|
|
568
578
|
}
|
|
569
579
|
}
|
|
570
|
-
|
|
571
|
-
this.awaitingMessagesByBlockRoot.delete(rootHex);
|
|
572
580
|
};
|
|
573
581
|
|
|
574
582
|
private onPayloadEnvelopeProcessed = async ({blockRoot: rootHex}: {blockRoot: RootHex}): Promise<void> => {
|
|
@@ -577,6 +585,12 @@ export class NetworkProcessor {
|
|
|
577
585
|
return;
|
|
578
586
|
}
|
|
579
587
|
|
|
588
|
+
// Atomically remove from map and update counter before async iteration to
|
|
589
|
+
// prevent double-decrement race with onClockSlot during yield points below
|
|
590
|
+
if (this.awaitingMessagesByPayloadBlockRoot.delete(rootHex)) {
|
|
591
|
+
this.awaitingPayloadMessageCount -= waitingGossipsubMessages.size;
|
|
592
|
+
}
|
|
593
|
+
|
|
580
594
|
const nowSec = Date.now() / 1000;
|
|
581
595
|
let count = 0;
|
|
582
596
|
for (const message of waitingGossipsubMessages) {
|
|
@@ -593,8 +607,6 @@ export class NetworkProcessor {
|
|
|
593
607
|
await sleep(AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS);
|
|
594
608
|
}
|
|
595
609
|
}
|
|
596
|
-
|
|
597
|
-
this.awaitingMessagesByPayloadBlockRoot.delete(rootHex);
|
|
598
610
|
};
|
|
599
611
|
|
|
600
612
|
private onClockSlot = (clockSlot: Slot): void => {
|
|
@@ -618,7 +630,9 @@ export class NetworkProcessor {
|
|
|
618
630
|
);
|
|
619
631
|
// No need to report the dropped job to gossip. It will be eventually pruned from the mcache
|
|
620
632
|
}
|
|
621
|
-
this.awaitingMessagesByBlockRoot.delete(rootHex)
|
|
633
|
+
if (this.awaitingMessagesByBlockRoot.delete(rootHex)) {
|
|
634
|
+
this.awaitingBlockMessageCount -= gossipMessages.size;
|
|
635
|
+
}
|
|
622
636
|
}
|
|
623
637
|
}
|
|
624
638
|
this.unknownBlocksBySlot.delete(slot);
|
|
@@ -641,7 +655,9 @@ export class NetworkProcessor {
|
|
|
641
655
|
);
|
|
642
656
|
// No need to report the dropped job to gossip. It will be eventually pruned from the mcache
|
|
643
657
|
}
|
|
644
|
-
this.awaitingMessagesByPayloadBlockRoot.delete(rootHex)
|
|
658
|
+
if (this.awaitingMessagesByPayloadBlockRoot.delete(rootHex)) {
|
|
659
|
+
this.awaitingPayloadMessageCount -= gossipMessages.size;
|
|
660
|
+
}
|
|
645
661
|
}
|
|
646
662
|
}
|
|
647
663
|
this.unknownEnvelopesBySlot.delete(slot);
|
|
@@ -784,20 +800,4 @@ export class NetworkProcessor {
|
|
|
784
800
|
|
|
785
801
|
return null;
|
|
786
802
|
}
|
|
787
|
-
|
|
788
|
-
private get unknownBlockGossipsubMessagesCount(): number {
|
|
789
|
-
let count = 0;
|
|
790
|
-
for (const messages of this.awaitingMessagesByBlockRoot.values()) {
|
|
791
|
-
count += messages.size;
|
|
792
|
-
}
|
|
793
|
-
return count;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
private get unknownPayloadGossipsubMessagesCount(): number {
|
|
797
|
-
let count = 0;
|
|
798
|
-
for (const messages of this.awaitingMessagesByPayloadBlockRoot.values()) {
|
|
799
|
-
count += messages.size;
|
|
800
|
-
}
|
|
801
|
-
return count;
|
|
802
|
-
}
|
|
803
803
|
}
|
package/src/util/dataColumns.ts
CHANGED
|
@@ -470,15 +470,17 @@ export async function recoverDataColumnSidecars(
|
|
|
470
470
|
return DataColumnReconstructionCode.SuccessLate;
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
//
|
|
474
|
-
//
|
|
475
|
-
//
|
|
476
|
-
//
|
|
477
|
-
//
|
|
478
|
-
//
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
const
|
|
473
|
+
// Per consensus-specs PR #4657, only publish reconstructed columns the node is
|
|
474
|
+
// subscribed to (custody + sampling). Eagerly cross-seeding non-subscribed
|
|
475
|
+
// columns floods the network with duplicates because the sender has no
|
|
476
|
+
// visibility into which peers already saw the message via the topic mesh.
|
|
477
|
+
// This matches the getBlobsV2 path in `getDataColumnSidecarsFromExecution` and
|
|
478
|
+
// aligns with Lighthouse/Prysm. Capture missing sampled indices before adding
|
|
479
|
+
// any reconstructed columns so they are not filtered out by the subsequent
|
|
480
|
+
// `addColumn` calls.
|
|
481
|
+
const missingSampledColumns = new Set(input.getMissingSampledColumnMeta().missing);
|
|
482
|
+
const sidecarsReconstructed: DataColumnSidecar[] = [];
|
|
483
|
+
const sidecarsToPublish: DataColumnSidecar[] = [];
|
|
482
484
|
for (const columnSidecar of fullSidecars) {
|
|
483
485
|
if (!input.hasColumn(columnSidecar.index)) {
|
|
484
486
|
if (input instanceof PayloadEnvelopeInput) {
|
|
@@ -501,11 +503,14 @@ export async function recoverDataColumnSidecars(
|
|
|
501
503
|
source: BlockInputSource.recovery,
|
|
502
504
|
});
|
|
503
505
|
}
|
|
504
|
-
|
|
506
|
+
sidecarsReconstructed.push(columnSidecar);
|
|
507
|
+
if (missingSampledColumns.has(columnSidecar.index)) {
|
|
508
|
+
sidecarsToPublish.push(columnSidecar);
|
|
509
|
+
}
|
|
505
510
|
}
|
|
506
511
|
}
|
|
507
|
-
metrics?.peerDas.reconstructedColumns.inc(
|
|
508
|
-
metrics?.dataColumns.bySource.inc({source: BlockInputSource.recovery},
|
|
512
|
+
metrics?.peerDas.reconstructedColumns.inc(sidecarsReconstructed.length);
|
|
513
|
+
metrics?.dataColumns.bySource.inc({source: BlockInputSource.recovery}, sidecarsReconstructed.length);
|
|
509
514
|
emitter.emit(ChainEvent.publishDataColumns, sidecarsToPublish);
|
|
510
515
|
// TODO: Can we record dataColumns.sentPeersPerSubnet metric somehow
|
|
511
516
|
return DataColumnReconstructionCode.SuccessResolved;
|