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

feat: expose underlying nim-ethers errors to logs #985

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AuHau
Copy link
Member

@AuHau AuHau commented Nov 4, 2024

Brings in a version of nim-ethers where subscription callbacks are returned Result, which will give an error when there is some underlying problem in the subscription mechanisms. This PR exposes these errors through logging.

Copy link
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

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

Nice work. My main question is more around should we do more than just log these errors? Are they bad enough to raise a Defect (and crash the node)? Or should we add metrics and monitor how often they happen?

I'll approve now since the suggestions are not really blocked.

proc onBlock(_: Block) =
proc onBlock(blckResult: ?!Block) =
if eventError =? blckResult.errorOption:
error "There was an error in block subscription", msg=eventError.msg
Copy link
Contributor

Choose a reason for hiding this comment

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

Part of me thinks if the clock fails to update due to fetching a block error, then we should raise a Defect, because a correct clock is critical for proper node function. However, we don't know if it's a temporary error or not.

We could add an error count and trigger a Defect after a few errors, but that sounds potentially like an over-optimisation without data yet. Maybe for now we should add a metric and monitor it? Wdyt?

Comment on lines +135 to +140
proc onSlotFilled(eventRes: ?!SlotFilled) =
if event =? eventRes:
slotIdxFilled = some event.slotIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here...

Suggested change
proc onSlotFilled(eventRes: ?!SlotFilled) =
if event =? eventRes:
slotIdxFilled = some event.slotIndex
proc onSlotFilled(event: ?!SlotFilled) =
slotIdxFilled = some event.get.slotIndex

Comment on lines +281 to +283
without event =? eventResult, eventErr:
error "There was an error in Request subscription", msg = eventErr.msg
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment for most of these event subscriptions in the Market abstraction -- they are critical to node functionality, so should we log and continue or are they severe enough that we cannot assume normal node operation afterwards (thus warranting a Defect)?

Comment on lines +36 to +38
proc onStorageRequested(eventRes: ?!StorageRequested)=
if event =? eventRes:
requestId = event.requestId.some
Copy link
Contributor

Choose a reason for hiding this comment

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

Wdyt about raising a Defect (and fail the test) if there's an error in the callback?

Suggested change
proc onStorageRequested(eventRes: ?!StorageRequested)=
if event =? eventRes:
requestId = event.requestId.some
proc onStorageRequested(event: ?!StorageRequested)=
requestId = some event.get.requestId

@AuHau AuHau force-pushed the feat/nim-ethers-subscription-result branch from 63fee49 to 8a0e3ac Compare November 29, 2024 14:23
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