Skip to content
Closed
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
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class BeaconChain implements IBeaconChain {
}

seenBlock(blockRoot: RootHex): boolean {
return this.seenBlockInputCache.hasBlock(blockRoot) || this.forkChoice.hasBlockHexUnsafe(blockRoot);
return this.seenBlockInputCache.has(blockRoot) || this.forkChoice.hasBlockHexUnsafe(blockRoot);
}

seenPayloadEnvelope(blockRoot: RootHex): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class SeenBlockInput {
return this.blockInputs.get(rootHex)?.hasBlock() ?? false;
}

has(rootHex: RootHex): boolean {
return this.blockInputs.has(rootHex);
}

get(rootHex: RootHex): IBlockInput | undefined {
return this.blockInputs.get(rootHex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
config,
generateBlock,
generateBlockWithBlobSidecars,
generateBlockWithColumnSidecars,
generateChainOfBlocks,
} from "../../../utils/blocksAndData.js";

Expand Down Expand Up @@ -83,6 +84,22 @@ describe("SeenBlockInputCache", async () => {
});
});

describe("has()", () => {
it("should return true for a cached fulu column-only BlockInput", () => {
const {columnSidecars, rootHex} = generateBlockWithColumnSidecars({forkName: ForkName.fulu});

cache.getByColumn({
columnSidecar: columnSidecars[0],
blockRootHex: rootHex,
source: BlockInputSource.gossip,
seenTimestampSec: Date.now() / 1000,
});

expect(cache.has(rootHex)).toBeTruthy();
expect(cache.hasBlock(rootHex)).toBeFalsy();
});
});

describe("get()", () => {
it("should return BlockInput if in cache", () => {
const {block, rootHex} = generateBlock({forkName: ForkName.capella});
Expand Down
Loading