Skip to content
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

Use asyncraises in p2p #675

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Use asyncraises in p2p #675

merged 3 commits into from
Feb 14, 2024

Conversation

jangko
Copy link
Contributor

@jangko jangko commented Feb 13, 2024

No description provided.

@@ -155,7 +155,7 @@ type
MessageHandlerDecorator* = proc(msgId: int, n: NimNode): NimNode

ThunkProc* = proc(x: Peer, msgId: int, data: Rlp): Future[void]
{.gcsafe, raises: [RlpError].}
{.gcsafe, async: (raises: [RlpError, CatchableError]).}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no point adding CatchableError to raises - that's already the default at which point it's generally better to use just plain async

Copy link
Contributor Author

@jangko jangko Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, thanks. But unfortunately it doesn't works. The compiler/chronos still complaints.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be because you need to match usages to the declaration - ie either all use {.async.} or all use {.async: [errors].} - this is related to the guarantees that you want to uphold, ie either the thunk proc is responsible for handling errors or the thing calling it is and one needs to decide.

broadly though, this declaration is non-sensical: RlpError is a subclass of CatchableError so if this declaration is needed, something went wrong "somewhere else" and it would be interesting perhaps to investigate where that was - ie likely, there is some deeper change that will either remove RlpError or remove CatcahbleError from this declaration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the rlpx needs overhaul.

eth/p2p/rlpx.nim Outdated
@@ -176,7 +176,7 @@ proc messagePrinter[MsgType](msg: pointer): string {.gcsafe.} =
# result = $(cast[ptr MsgType](msg)[])

proc disconnect*(peer: Peer, reason: DisconnectionReason,
notifyOtherPeer = false) {.gcsafe, async.}
notifyOtherPeer = false) {.gcsafe, async: (raises:[CatchableError]).}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for gcsafe when async is specified

@jangko jangko merged commit b9c40e1 into master Feb 14, 2024
12 checks passed
@jangko jangko deleted the p2p-asyncraises branch February 14, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants