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

FLIP 255: Cadence WebAssembly API #256

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

darkdrag00nv2
Copy link
Contributor

@darkdrag00nv2 darkdrag00nv2 commented Mar 9, 2024

Fixes #255

@darkdrag00nv2 darkdrag00nv2 marked this pull request as ready for review March 9, 2024 10:49
@KshitijChaudhary666
Copy link
Contributor

KshitijChaudhary666 commented Apr 11, 2024

Hi @darkdrag00nv2 - This FLIP is not reflected on FLIP project tracker. Can you pls follow the process outlined in https://github.com/onflow/flips? Specifically the following would help show the FLIP on the project tracker-

  • Create an issue by using one of the FLIP issue templates based on the type of the FLIP - application, governance, cadence or protocol
  • The title of the issue should be the title of your FLIP, e.g., "Dynamic Inclusion fees". Submit the issue. Note the issue number that gets assigned
  • Use the issue number generated in step 2 as the FLIP number on this PR. And mention the FLIP issue by copying the GitHub URL or the issue in the comment section here

Thank you!

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Looks good!

As we're finishing work on Cadence 1.0, we can finally come back to proposals like this. Thank you for your patience!

I left some comments and suggestions, and am happy to apply suggested edits and add remaining details. Does that sound good to you @darkdrag00nv2 ?

Once we addressed the outstanding issues, we can schedule to vote on it in the next WG call

cadence/20240225-cadence-webassembly-api.md Outdated Show resolved Hide resolved
cadence/20240225-cadence-webassembly-api.md Outdated Show resolved Hide resolved

### Dependencies

None
Copy link
Member

Choose a reason for hiding this comment

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

We'll likely won't implement a new WebAssembly runtime and use an existing one


While the specifics are dependant on the exact engine used, the high level idea is the following:
1. FVM should provide a way to remaining computation units: A new function `RemainingComputation(kind)` will be added in FVM.
2. Computation units should be converted to its WASM engine equivalent. For example, in wasmtime, it is called `Fuel`.
Copy link
Member

Choose a reason for hiding this comment

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

We'll need to define how fuel translates to computation usage in Flow

cadence/20240225-cadence-webassembly-api.md Show resolved Hide resolved
3. The user code must be executed with the computed amount of wasm engine computation units.

##### Memory
To limit the memory being consumed, some constraints will be defined on the various ways that memory is used in the wasm-engine.
Copy link
Member

Choose a reason for hiding this comment

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

### Drawbacks

None

Copy link
Member

Choose a reason for hiding this comment

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

We'll need to define which WebAssembly features will be supported. Currently the PoC specifies: https://github.com/onflow/cadence/pull/2760/files#diff-e898ac8338568dfcac62c2017b09e956e5f99c1cda6eedb3f7c48b830595f9d1R43-R70

### Drawbacks

None

Copy link
Member

Choose a reason for hiding this comment

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

We'll need to point out that deterministic execution is required. WebAssmbly allows non-determinism through NaNs. However, some WebAssembly runtiumes allow determinism by enforcing NaN-normalization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cadence WebAssembly API
3 participants