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

Long running Snaps for synchronous work #1604

Open
david0xd opened this issue Jul 14, 2023 · 4 comments · May be fixed by #1624
Open

Long running Snaps for synchronous work #1604

david0xd opened this issue Jul 14, 2023 · 4 comments · May be fixed by #1624
Assignees
Labels
area-developing Related to the process of developing snaps / snaps devX. area-execution-environments

Comments

@david0xd
Copy link
Contributor

This ticket should focus on implementing a solution that would allow Snaps to run for a longer period of time that is beyond the current timeout for execution. This is needed mostly for the use cases where cryptographic synchronous operations require longer periods of time to complete their work (e.g. ZK proofs, etc).

Proposal on how to achieve specified requirements:

  • Provide an endowment in the form of a callback with configuration.
  • Configuration should specify the time limit for timeout extension.
  • Callback should contain functionality that should be executed.
  • When a callback is called, pause the termination timers and reset according to the new time limit requested.

Security related requirements:

  • Specify maximum time limits that can be requested and used (consider having lowest and highest values).
  • Prevent calling the callback endowment multiple times while one is already in the state of execution.
  • Prevent (ignore) nested calls of a callback.
  • Track a number of the endowment callback calls and make sure there is a limitation to it.

Requirements for future improvements of the UX/UI:
Track current state of long running execution requests in order to provide that information to the UI and other platform's architectural elements, in order to improve user experience.

Notes:
Consider having e2e testing strategy for improvised use case.

Related resources:
#1483
https://github.com/MetaMask/MetaMask-planning/issues/517
Long running snaps research conclusion document: https://docs.google.com/document/d/1BsL75IiepnS1rbfzOVJ5xX3YS3W79Hmyk725lydsqq8/edit

@kenhkan
Copy link

kenhkan commented Aug 16, 2023

From standup: David needs some input from Erik on endowment copy, etc

@eriknson
Copy link
Member

Suggested metadata

  • Title: Extend runtime
  • Icon identifier: timer
  • Endowment name: endowment:extend-runtime
  • Description: Let this snap run for an extended duration. This can be used when processing large amounts of data.

@Montoya
Copy link
Collaborator

Montoya commented Sep 27, 2023

Will create another ticket in MetaMask-planning and mark this as blocked

@david0xd
Copy link
Contributor Author

david0xd commented Oct 3, 2023

This ticket is blocked since September 21st because of architectural obstacle with not having proper requestId communicated between the Snap Controller and Execution Environment

Several approaches to this are presented and communicated on Slack channel in the following thread: https://consensys.slack.com/archives/C02GL38PLE6/p1695301614878949
Since all known solutions to this have tradeoffs it is left to be determined which one would be or if should be acceptable or to search for new ideas around the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-developing Related to the process of developing snaps / snaps devX. area-execution-environments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants