Add write_output Host function
Context
This closes #3330 (closed) See the specs
Strategy:
New Output_buffer datatype. the type is
type t = {content : bytes Map.t; mutable level : int32; mutable id : Z.t}
Here Map is a lazy_map whose keys have type:
{
outbox_level : int32; (** The outbox level at which the message exists.*)
message_index : Z.t; (** The index of the message in the outbox. *)
}
The last two parameters are level which is kept in sync with the level of the last read input and id which is the position of the outputat that level.
Invariants:
- level = level of the last read input
- the id increases each time a message is written
- when the input level changes, the id becomes zero.
Cf the specs, the write_input host function will receive a pointer to the start of the message (called src) and the length of this message. It then reads the message from the memory and writes it to the output buffer at the position given by (level, id). It then increases the id.
Other changes include encodings for output as well as a change in the read_input function that updates the level and the id of the output buffer in order to satisfy invariants 1. and 3. above.
Tests verify the invariants and check that the messages have been written in the right place. There are also encoding tests.
Manually testing the MR
dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe
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.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR