Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export function getBeaconBlockApi({
forkName: fork,
sampledColumns: chain.custodyConfig.sampledColumns,
custodyColumns: chain.custodyConfig.custodyColumns,
timeCreatedSec: seenTimestampSec,
seenTimestampSec,
source: PayloadEnvelopeInputSource.api,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ColumnWithSource,
CreateFromBidProps,
CreateFromBlockProps,
PayloadEnvelopeInputSource,
SourceMeta,
} from "./types.js";

Expand Down Expand Up @@ -71,6 +72,7 @@ export class PayloadEnvelopeInput {
readonly bid: gloas.ExecutionPayloadBid;
readonly versionedHashes: VersionedHashes;
readonly daOutOfRange: boolean;
readonly source: PayloadEnvelopeInputSource;

private columnsCache = new Map<ColumnIndex, ColumnWithSource>();

Expand All @@ -95,6 +97,7 @@ export class PayloadEnvelopeInput {
custodyColumns: ColumnIndex[];
timeCreatedSec: number;
daOutOfRange: boolean;
source: PayloadEnvelopeInputSource;
}) {
this.blockRootHex = props.blockRootHex;
this.slot = props.slot;
Expand All @@ -106,6 +109,7 @@ export class PayloadEnvelopeInput {
this.custodyColumns = props.custodyColumns;
this.timeCreatedSec = props.timeCreatedSec;
this.daOutOfRange = props.daOutOfRange;
this.source = props.source;
this.payloadEnvelopeDataPromise = createPromise();
this.allDataPromise = createPromise();
this.columnsDataPromise = createPromise();
Expand Down Expand Up @@ -133,8 +137,9 @@ export class PayloadEnvelopeInput {
bid,
sampledColumns: props.sampledColumns,
custodyColumns: props.custodyColumns,
timeCreatedSec: props.timeCreatedSec,
timeCreatedSec: props.seenTimestampSec,
daOutOfRange: props.daOutOfRange,
source: props.source,
});
}

Expand All @@ -153,8 +158,9 @@ export class PayloadEnvelopeInput {
bid: props.bid,
sampledColumns: props.sampledColumns,
custodyColumns: props.custodyColumns,
timeCreatedSec: props.timeCreatedSec,
timeCreatedSec: props.seenTimestampSec,
daOutOfRange: props.daOutOfRange,
source: props.source,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@ export enum PayloadEnvelopeInputSource {
engine = "engine",
byRange = "req_resp_by_range",
byRoot = "req_resp_by_root",
// Data-column reconstruction (KZG cell recovery), NOT a cache reload
recovery = "recovery",
// Entry reconstructed from the hot DB by SeenPayloadEnvelopeInput.getOrReload
reload = "reload",
// Entry seeded from a checkpoint anchor state's latestExecutionPayloadBid at chain init
anchorState = "anchor_state",
}

/**
* Reason a PayloadEnvelopeInput is evicted from SeenPayloadEnvelopeInput. Used for the `pruned` metric
* label and the eviction log.
* - belowParent: pruned below the new head's parent (canonical, FULL, all-columns)
* - finalized: below the finalized slot
* - prune: explicit prune by root
* - cap: insertion-order backstop cap (MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE)
*/
export type PayloadEnvelopeInputPruneReason = "belowParent" | "finalized" | "prune" | "cap";

export type SourceMeta = {
source: PayloadEnvelopeInputSource;
seenTimestampSec: number;
Expand All @@ -20,13 +35,12 @@ export type ColumnWithSource = SourceMeta & {
columnSidecar: gloas.DataColumnSidecar;
};

export type CreateFromBlockProps = {
export type CreateFromBlockProps = SourceMeta & {
blockRootHex: RootHex;
block: SignedBeaconBlock<ForkPostGloas>;
forkName: ForkName;
sampledColumns: ColumnIndex[];
custodyColumns: ColumnIndex[];
timeCreatedSec: number;
daOutOfRange: boolean;
};

Expand All @@ -35,15 +49,14 @@ export type CreateFromBlockProps = {
* the chain from a checkpoint anchor state — we have the bid via the state but not the
* full SignedBeaconBlock).
*/
export type CreateFromBidProps = {
export type CreateFromBidProps = SourceMeta & {
blockRootHex: RootHex;
slot: number;
forkName: ForkName;
proposerIndex: number;
bid: gloas.ExecutionPayloadBid;
sampledColumns: ColumnIndex[];
custodyColumns: ColumnIndex[];
timeCreatedSec: number;
daOutOfRange: boolean;
};

Expand Down
7 changes: 6 additions & 1 deletion packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import {CheckpointBalancesCache} from "./balancesCache.js";
import {BeaconProposerCache} from "./beaconProposerCache.js";
import {IBlockInput, isBlockInputBlobs, isBlockInputColumns} from "./blocks/blockInput/index.js";
import {BlockProcessor, ImportBlockOpts} from "./blocks/index.js";
import {PayloadEnvelopeInputSource} from "./blocks/payloadEnvelopeInput/index.js";
import {PayloadEnvelopeProcessor} from "./blocks/payloadEnvelopeProcessor.js";
import {ImportPayloadOpts} from "./blocks/types.js";
import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
Expand Down Expand Up @@ -451,6 +452,9 @@ export class BeaconChain implements IBeaconChain {
chainEvents: emitter,
signal,
serializedCache: this.serializedCache,
db,
seenBlockInputCache: this.seenBlockInputCache,
custodyConfig: this.custodyConfig,
metrics,
logger,
});
Expand All @@ -466,7 +470,8 @@ export class BeaconChain implements IBeaconChain {
bid: anchorBid,
sampledColumns: this.custodyConfig.sampledColumns,
custodyColumns: this.custodyConfig.custodyColumns,
timeCreatedSec: Math.floor(Date.now() / 1000),
seenTimestampSec: Date.now() / 1000,
source: PayloadEnvelopeInputSource.anchorState,
});
}

Expand Down
Loading
Loading