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: on last event #34

Merged
merged 8 commits into from
Sep 5, 2024
Merged

feat: on last event #34

merged 8 commits into from
Sep 5, 2024

Conversation

0xyaco
Copy link
Collaborator

@0xyaco 0xyaco commented Sep 4, 2024

🤖 Linear

Closes GRT-153

Description

  • Renames onNewEvent to onLastEvent (seems more accurate)
  • Uses the new "last event" handlers during the enqueued events processing
  • Fixes last event handlers tests (most of their cases were skipped until this was implemented)
  • Refactors the shouldHandleEvent function to reflect its actual name lol

Copy link

linear bot commented Sep 4, 2024

GRT-153 Implement onNewEvent handler

Actor needs to react to the last known event by executing some RPCs.

AC:

  • React to all relevant events
    • RequestCreated
    • ResponseProposed
    • ReponseDisputed
    • DisputeStatusChanged
    • DisputeEscalated
    • RequestFinalized
  • Set old event handlers methods to private
  • Fix unit tests for old handlers
  • (small extra) rename shouldHandleRequest

Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

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

Left some comments/questions but otherwise looking good 👍🏻

return;
private async onLastEvent(event: EboEvent<EboEventName>) {
switch (event.name) {
case "RequestCreated":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we not need to handle NewEpoch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool that you've realized that there was this NewEpoch event! Right now we are not going to use it, as the new epoch will be handled by the EboProcessor so let me delete it from the events.

break;

default:
throw new UnknownEvent(event.name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

if EboEventName can be something other than the few specified in type EboEventName I'm wondering if we'd need to have a 'string' option in the type and log the event without trying to access event.name 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A handled event must be one of the listed events.

This is more of an explicitness + maintainability thingy, as we want to force anyone who wants to support a new event to include the new event handler here. Without the default: throw case this would be run silently while there's probably something wrong upstream with the event fetching logic (ie including unsupported events).

@jahabeebs jahabeebs self-requested a review September 4, 2024 22:17
jahabeebs
jahabeebs previously approved these changes Sep 4, 2024
Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

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

LGTM 🍰

Copy link
Collaborator

@0xkenj1 0xkenj1 left a comment

Choose a reason for hiding this comment

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

sweet

@0xyaco 0xyaco merged commit fccd01f into dev Sep 5, 2024
5 checks passed
@0xyaco 0xyaco deleted the feat/on-last-event branch September 5, 2024 18:01
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.

4 participants