Skip to content

Commit

Permalink
feat: add support for justified block id
Browse files Browse the repository at this point in the history
  • Loading branch information
acuarica committed May 3, 2023
1 parent 0ed1cd1 commit b8d1f06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/beacon-node/src/api/impl/beacon/blocks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ async function resolveBlockIdOrNull(
};
}

if (blockId === "justified") {
return {
block: await db.blockArchive.get(forkChoice.getJustifiedBlock().slot),
executionOptimistic: false,
};
}

let blockSummary;
let getBlockByBlockArchive;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ describe("block api utils", function () {
expect(dbStub.blockArchive.get).to.be.calledOnceWithExactly(expected);
});

it("should resolve justified", async function () {
const expected = 0;
forkChoiceStub.getJustifiedBlock.returns(expectedSummary);
await resolveBlockId(forkChoiceStub, dbStub, "justified").catch(() => {});
expect(dbStub.blockArchive.get).to.be.calledOnceWithExactly(expected);
});

it("should resolve finalized block root", async function () {
forkChoiceStub.getBlock.returns(expectedSummary);
forkChoiceStub.getFinalizedBlock.returns(expectedSummary);
Expand Down

0 comments on commit b8d1f06

Please sign in to comment.