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

RUES - Handle VM Event Finalization: Real-time Emission vs Rollback Management #2755

Open
herr-seppia opened this issue Oct 24, 2024 · 0 comments

Comments

@herr-seppia
Copy link
Member

Summary

The current behavior emits every event from the VM in real-time with the execution. Due to the rolling finality PR, when an event occurs, it is never immediately finalized. This may cause issues for clients, as they need to manage the rollback of these events' effects.

Detailed Description (optional)

The VM emits events in real-time as they occur. However, based on the rolling finality PR, these events are not finalized immediately. This creates a burden on clients, as they must handle the rollback of effects triggered by these events.

There are two possible solutions:

  1. Accept only finalized events:
    Instead of listening to contract events in real-time, a client could listen for the state_changed event of a block and, once that block is finalized, query the archival node for the list of events related to that block.

  2. Accept real-time events and manage rollbacks:
    This approach is more complex because the client needs to handle rollbacks both when online and offline. When a rollback event is emitted, it doesn’t contain information about the relevant contract events. However, every contract event has the transaction ID that originated it, and the transaction ID is part of the block accepted event. Therefore, it is possible (although not immediately straightforward) to determine which block hash each event is related to.

    • Online rollback management:
      Each time a rollback event is emitted, remove all side effects of the contract events associated with the rolled-back block hash.

    • Offline rollback management:
      On client startup, request the state of blocks for which there are locally non-finalized events. If these blocks are no longer present, remove all side effects of the contract events related to the missing block hash.

Relevant Context (optional)

  • This issue arises due to the rolling finality PR, which causes events to be emitted before they are finalized.
  • Clients must manage event rollbacks both online and offline to ensure data consistency.

Possible Solution (optional)

The two proposed solutions are:

  1. Listen only to finalized events by querying the archival node after blocks are finalized.
  2. Accept real-time events and implement both online and offline rollback handling mechanisms.
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

No branches or pull requests

1 participant