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: ebo processor event loop #27

Merged
merged 14 commits into from
Sep 3, 2024
Merged

feat: ebo processor event loop #27

merged 14 commits into from
Sep 3, 2024

Conversation

0xyaco
Copy link
Collaborator

@0xyaco 0xyaco commented Aug 23, 2024

🤖 Linear

Closes GRT-58, GRT-109

Description

Feature PR, branched out of #26.

I'll open one PR per main task and merge them into this branch, so it's easier to review and work on changes.

⚠️ DO NOT REVIEW THIS PR UNTIL EVERY TASK HAS BEEN COMPLETED

  • Refactor EboActorManager to also create actors and EboActor constructor to stop asking for onTerminate callback as it will be handled by EboProcessor
  • Implement EboProcessor main event loop
  • Implement new EboActor functions based on EboProcessor main event loop needs

Copy link

linear bot commented Aug 23, 2024

GRT-58 Implement `start()` ( bootstrap & eventLoop)

Use an interval to handle events, and save the reference on a class attribute.

https://www.figma.com/board/BbciqJb5spg35ZglTsRRBb/Offchain?node-id=239-2645&t=rxiyrWw25Xi7qLak-4

AC:

  • start method implemented successfully
  • unit tests

@0xyaco 0xyaco changed the title Feat/processor start feat: ebo processor event loop Aug 23, 2024
0xyaco added 3 commits August 23, 2024 18:14
# 🤖 Linear

Part of GRT-58

## Description
* Removes `onTerminate` callback from `EboActor` as this functionality
will be handled by the `EboProcessor`.
* Allows the `EboActorsManager` to build new actors while registering
them inside its registry.
# 🤖 Linear

Part of GRT-58

## Description
Periodic interval inside `EboProcessor` to process new events and
forward them to actors.
# 🤖 Linear

Part of GRT-58

## Description
* Check for finalizable request and _settleable_ disputes
* Adds `createdAt` to all Prophet entities
* Refactor `EboRegistry` getters to return arrays of entities instead of
maps (we were always doing `.values()` or `.keys()`)

**NOTE**: we might end up extracting some of the functionality added
here into another service (some `TODO` comments were left there marking
those places), but for the moment I prefer to have this working to reach
the E2E stage with the core logic already developed. 👼
Copy link

linear bot commented Sep 3, 2024

GRT-109 Implement checkRequestState

EboActor should be able to react to proposal and dispute windows being closed to trigger actions on Prophet's side.

Flows and more details can be found on the Notion's Tech Design doc.

# 🤖 Linear

Closes GRT-58

## Description
* Changes `EboActor` public methods to only `enqueue` and
`processEvents`
* Enqueues corresponding events into a heap inside the `EboActor`
instances to process them later
* Creates a new interface `EboRegistryCommand` implementing the
_Command_ design pattern to be able to rollback internal `EboActor`
state if an RPC call fails after updating the state, simulating a
"transaction".
* Refactor actor creation to remove dependency with `protocolProvider`
during this method

### EboActor processEvents flow
```mermaid
flowchart LR
  start(((start)))
  peekNextEvent[Peek next event]
  noMoreEvents?{No more events?}
  updateActorState[Update actor state]
  rpcCall[Execute RPC]
  rpcFailed?{RPC failed?}
  rollbackStateUpdate[Rollback state update]
  popProcessedEvent[Pop processed event]
  _end(((end)))

  start-->peekNextEvent
  peekNextEvent-->noMoreEvents?
  noMoreEvents?-->|true|_end
  noMoreEvents?-->|false|updateActorState
  updateActorState-->rpcCall
  rpcCall-->rpcFailed?
  rpcFailed?-->|yes|rollbackStateUpdate
  rollbackStateUpdate-- Will retry during next periodic check -->_end
  rpcFailed?-->|no|popProcessedEvent
  popProcessedEvent-->peekNextEvent
```
@0xyaco 0xyaco requested review from 0xkenj1 and 0xnigir1 September 3, 2024 20:05
@0xyaco 0xyaco marked this pull request as ready for review September 3, 2024 20:12
@0xyaco 0xyaco merged commit 6a0bde0 into dev Sep 3, 2024
5 checks passed
@0xyaco 0xyaco deleted the feat/processor-start branch September 3, 2024 20:38
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.

3 participants