-
-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for justified
block id in Beacon Node API
#5459
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,13 @@ async function resolveBlockIdOrNull( | |
}; | ||
} | ||
|
||
if (blockId === "justified") { | ||
return { | ||
block: await db.blockArchive.get(forkChoice.getJustifiedBlock().slot), | ||
executionOptimistic: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can compute the correct executionOptimistic boolean value with the forkChoice returned data structure. Check other API endpoints can't recall the exact helper fn name |
||
}; | ||
} | ||
|
||
let blockSummary; | ||
let getBlockByBlockArchive; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -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(() => {}); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the silent catch all errors here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why, all other tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After reviewing this with @nazarhussain, we found that without the
|
||||
expect(dbStub.blockArchive.get).to.be.calledOnceWithExactly(expected); | ||||
}); | ||||
|
||||
it("should resolve finalized block root", async function () { | ||||
forkChoiceStub.getBlock.returns(expectedSummary); | ||||
forkChoiceStub.getFinalizedBlock.returns(expectedSummary); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non finalized blocks are not in the archive, but in the block hot db. blockArchive will most likely return null for this query. Instead grab by root from the hot db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a fix for this, thanks @nazarhussain for helping me to validate the solution.