SCORU: Wasm: Add kernel loading logic to PVM
Goal
Extend the Wasm rollup state with /parse_state/input, which stores a Merkelized list, or Chunked_byte_vector and a field booter, storing a Public_key_hash.t.
During origination, the originator sends the booter and an optional initial boot sector chunk.
When the machine is in preboot, incoming inbox messages are parsed as { next_boot_sector_chunk : string, signature : Signature.t }. The signature is checked and the chunk is appended to the boot sector.
Whenever next_boot_sector_chunk is empty, the boot state is moved from Loading to Parsing, then proceeds with the normal boot process.
Alternative
Put this logic in the SCORU protocol https://hackmd.io/ugX9U_CPTXOeB3Tk7ZPgFA?view.
Believed to be more involved due to storage.
Context
During work on %(OKR 2022Q3 - 2.1) Wasm Kernel (Transactions) it has become clear that realistic kernels are not going to be smaller than ~2MB, which is in conflict with the (block-driven) size limits imposed in #3054 (closed).
This could be worked around with self-upgradable kernels, but this is out of scope for %(OKR 2022Q3 - 2.1) SCORU WebAssembly PVM I, hence we lack the capability to test realistically sized kernels. We here work around this by adding "append boot sector" logic in the Wasm rollup itself.
On finishing %(OKR 2022Q3 - 2.1) SCORU WebAssembly PVM I this logic can be moved from L1 to Kernel code if desired.
Data structure
We need lazy append. That is (append M N) where proof size is O(log M*N), and better than O(N).
Merkle list might be tricky, because consuming from the front means rewriting the entire KV structure for that list within the tree. Morally you need a reverse-linked merkle list.
You can't use Irmin move opeerations, as with the set/get pattern, indeed you risk not recognizing the shallow move in set and rewriting the entire structure. The easiest solution is probably an indexed map of pages, boxed with an offset for the parser state.