-
Notifications
You must be signed in to change notification settings - Fork 233
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
Add support for POST /eth/v2/beacon/blocks #5214
Conversation
debug "Failed to deserialize REST JSON data", | ||
err = exc.formatMsg("<data>"), | ||
data = string.fromBytes(body.data) | ||
return err("Unable to deserialize data") |
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.
This message is going to be passed to client as stacktrace
message with InvalidBlockObjectError
error message. So maybe stacktrace
message could be more informative? Because currently its just provide logically same message as InvalidBlockObjectError
.
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.
Hmm. I replaced this line with
return err("Unable to deserialize JSON for fork " & version & ": " & exc.msg)
but am getting a compilation error cannot evaluate at compile time: version
. Tried various things (including the workaround at https://nim-lang.org/docs/strformat.html#limitations) to no avail.
I must be missing something obvious but... 🤔 any suggestions welcome.
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 just need to change return value of your function which is currently returns Result[T, cstring]
but could return Result[T, string]
.
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.
data = string.fromBytes(body.data) | ||
return err("Unable to deserialize data") | ||
except CatchableError: | ||
return err("Unexpected deserialization error") |
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.
ditto
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.
t: typedesc[RestPublishedSignedBlockContents], | ||
body: ContentBody, | ||
version: string | ||
): Result[RestPublishedSignedBlockContents, cstring] = |
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.
I think this function could return ForkedSignedBlock
?
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.
For Deneb we get (and need to return) both the block and blobs:
of ConsensusFork.Deneb: denebData*: DenebSignedBlockContents |
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.
So maybe you could introduce new type to spec/forks.nim
and add some helpers in there?
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.
If I'm understanding correctly you're suggesting to move
func init*(T: type ForkedSignedBeaconBlock, |
spec/forks.nim
?As
RestPublishedSignedBlockContents
is only used locally in the REST processing layer, I figured it belonged in rest_types.nim
, but happy to move over if you feel otherwise.
3864fc1
to
7796df4
Compare
23c1d0a
to
031de3f
Compare
@cheatfate thanks for the comments - i think i addressed them all, lmk if anything remaining |
which isn't per-se related to this PR, but was fixed by #5258; updating this branch to latest |
3af40e6
to
4066c0e
Compare
done |
No description provided.