filecoin-project / ref-fvm

Reference implementation of the Filecoin Virtual Machine
https://fvm.filecoin.io/
Other
380 stars 135 forks source link

Dynamic Module Linking #674

Open raulk opened 2 years ago

raulk commented 2 years ago

FVM actors will execute inside a sandbox that provides services such as state access, IPLD codecs, chain access, message sending, and more. Actor code will import FVM SDK modules in its source form (e.g. Rust actor code), but it is not clear to me how these libraries will be dynamically linked from the environment so as to not bloat the WASM bytecode with (redundant) statically linked libraries.

See https://github.com/WebAssembly/design/blob/main/Modules.md#imports.

Another angle to consider is the gas accounting from implicit libraries, and how that relates to the upgradability story.

  1. We want to be able to upgrade the "actor sandbox" such as to deploy fixes or optimisations. What kinds of changes are consensus-breaking?
  2. Is the sandbox code metered through standard gas? I'd assume no.
Stebalien commented 1 year ago

This would also let us implement the concept of "objects". I.e.:

  1. let obj_id = instantiate(code_cid, state_root).
  2. Do some stuff.
  3. let new_state_root = finalize(object_id).