-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Conversation
|
Performance Report✔️ no performance regression detected Full benchmark results
|
justified
block id in Beacon Node APIjustified
block id in Beacon Node API
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why, all other tests for resolveBlockId
have the same structure, so I didn't want to make it different in case I'm missing something.
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.
After reviewing this with @nazarhussain, we found that without the catch
all these tests fail here
throw new ApiError(404, `No block found for id '${blockId}'`); |
@@ -65,6 +65,13 @@ async function resolveBlockIdOrNull( | |||
}; | |||
} | |||
|
|||
if (blockId === "justified") { | |||
return { | |||
block: await db.blockArchive.get(forkChoice.getJustifiedBlock().slot), |
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.
const justified = forkChoice.getJustifiedBlock(); | ||
return { | ||
block: await db.block.get(fromHexString(justified.blockRoot)), | ||
executionOptimistic: false, |
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.
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
const justified = forkChoice.getJustifiedBlock(); | ||
return { | ||
block: await db.block.get(fromHexString(justified.blockRoot)), | ||
executionOptimistic: isOptimisticBlock(justified), |
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.
Hey @dapplion, is this what you meant regarding #5459 (comment)?
🎉 This PR is included in v1.9.0 🎉 |
Motivation
This PR closes #4255.
Description
The
ethereum-metrics-exporter
usesjustified
as block id to retrieve block details https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.0#/Beacon/getBlockV2.This PR adds support for the
justified
block id, even if it is not explicitly stated in the Beacon API.