Skip to content

SCORU: Wasm: Strongly typed Proto/Environment bridge

Hans Hoglund requested to merge hans@scoru-wasm-size-tests into master

This MR expands the environment signature Wasm_2_0_0 to use strongly typed values for input, output and tick counts.

The Sc_rollup_wasm : PVM_sem module is accordingly rewritten to delegate all tree encoding/decoding to lib_scoru_wasm.

Before:

val step : tree -> tree Lwt.t

After:

type input = {inbox_level : NonNegative.t; message_counter : Z.t}
type output = {outbox_level : NonNegative.t; message_index : Z.t}
type input_request = No_input_required | Input_required
type info = {
  current_tick : Z.t;
  last_input_read : input option;
  input_request : input_request;
}

val compute_step : tree -> tree Lwt.t
val set_input_step : input -> string -> tree -> tree Lwt.t
val get_output : output -> tree -> string Lwt.t
val get_info : tree -> info Lwt.t

The implementation remains backed by lib_scoru_wasm.

(Please ignore the branch name, you can't change the source branch of Gitlab MRs).

Context

Before this patch, both the Protocol and Environment side of the WebAssembly implementation was required to encode/decode untyped trees, forcing them to agree on structure, creating a large surface for introducing bugs.

After this patch, all tree encoding/decoding can happen on the Environment side, the Protocol side a passive consumer.

TODO

  • Check requirements for proof consumption - do we need another Env function to remove outputs from the state tree
  • Check all TODOs have been ported to lib_scoru_wasm

Manually testing the MR

dune exec src/proto_alpha/lib_protocol/test/integration/main.exe -- test "^sc rollup wasm$"

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Hans Hoglund

Merge request reports