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

Persistent cosmic-swingset state #8222

Open
mhofman opened this issue Aug 19, 2023 · 1 comment
Open

Persistent cosmic-swingset state #8222

mhofman opened this issue Aug 19, 2023 · 1 comment
Assignees
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request swing-store SwingSet package: SwingSet

Comments

@mhofman
Copy link
Member

mhofman commented Aug 19, 2023

What is the Problem Being Solved?

Cosmic-swingset has access to a "host" section of the swing-store to keep some state across blocks. However to simplify state-sync (#3769), the implementation in #7225 removed all such host storage that wasn't participating in hangover inconsistency handling, and is not part of the exported data. Only the blockHeight and chainSends performed in the previous block are now kept in the swing-store host storage, and a state-sync restore just repopulates the blockHeight from the snapshot info, and chainSends are empty because state-sync arranges to restore a state not suffering from hangover.

All other state cosmic-swingset currently keeps is transient and can be safely discarded.

However we find ourselves in need of persisting some state again across blocks in cosmic-swingset. In the future, we may want to keep contextual information associated to some of the swingset execution (#7875) or provide a unified persistent storage capability for the host part of a device (e.g. if the host starts recording timers wakeup, see #7846).

This cosmic-swingset state storage needs to be resilient against hangover inconsistency issues, and be captured in and restored from state-sync snapshots.

Description of the Design

TBD

Security Considerations

Making sure any hangover cannot introduce divergence.

Scaling Considerations

TBD

Test Plan

We should actually exercise hangover logic in a test, possibly by forcing a node in a multi-validator setup to rollback the cosmos state by 1 block, or simulate a state-sync when host state is kept.

Upgrade Considerations

TBD

@mhofman mhofman added enhancement New feature or request SwingSet package: SwingSet cosmic-swingset package: cosmic-swingset labels Aug 19, 2023
@mhofman
Copy link
Member Author

mhofman commented Aug 19, 2023

Conceptually there are 2 existing storages where we can keep cosmic-swingset state: cosmos DB or swing-store.

If we're keeping state in cosmos DB, we have the following constraints:

  • read state "synchronously" from the cosmos golang process while processing blocking sends
  • record changes to that state with other chainSends so that a hangover can re-apply changes to the cosmos DB

If we're keeping state in the swing-store, we have the following constraints:

  • copy state changes into the cosmos DB along other swing-store "export data", and restore it during swing-store import
  • Separate it from the current "host" section which keeps hangover handling state and is not exported to the cosmos DB
    • However similarly to other streamed swing-store "export data", these changes must be replayed in case of hangover

I believe the latter may be simpler and provide more flexibility long term, while still exercising existing pathways. We just need to designate some part of the host storage as part of the swing-store export/import process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request swing-store SwingSet package: SwingSet
Projects
None yet
Development

No branches or pull requests

1 participant