Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/beacon-node/src/chain/ColumnReconstructionTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {ChainEventEmitter} from "./emitter.js";
/**
* Minimum time to wait before attempting reconstruction
*/
const RECONSTRUCTION_DELAY_MIN_MS = 800;
const RECONSTRUCTION_DELAY_MIN_BPS = 667;

/**
* Maximum time to wait before attempting reconstruction
*/
const RECONSTRUCTION_DELAY_MAX_MS = 1200;
const RECONSTRUCTION_DELAY_MAX_BPS = 1000;

export type ColumnReconstructionTrackerInit = {
logger: Logger;
Expand Down Expand Up @@ -41,11 +41,16 @@ export class ColumnReconstructionTracker {
/** Track if a reconstruction attempt is in-flight */
running = false;

private readonly minDelayMs: number;
private readonly maxDelayMs: number;

constructor(init: ColumnReconstructionTrackerInit) {
this.logger = init.logger;
this.emitter = init.emitter;
this.metrics = init.metrics;
this.config = init.config;
this.minDelayMs = this.config.getSlotComponentDurationMs(RECONSTRUCTION_DELAY_MIN_BPS);
this.maxDelayMs = this.config.getSlotComponentDurationMs(RECONSTRUCTION_DELAY_MAX_BPS);
}

triggerColumnReconstruction(blockInput: BlockInputColumns): void {
Expand All @@ -61,8 +66,7 @@ export class ColumnReconstructionTracker {
// just that it has been triggered for this block root.
this.running = true;
this.lastBlockRootHex = blockInput.blockRootHex;
const delay =
RECONSTRUCTION_DELAY_MIN_MS + Math.random() * (RECONSTRUCTION_DELAY_MAX_MS - RECONSTRUCTION_DELAY_MIN_MS);
const delay = this.minDelayMs + Math.random() * (this.maxDelayMs - this.minDelayMs);
sleep(delay)
.then(() => {
const logCtx = {slot: blockInput.slot, root: blockInput.blockRootHex};
Expand Down
Loading