client (program)
communication with the host (the FPVM), and other implementation-specific features.
Host and Client Communication
While the program is running on top of the FPVM, it is considered to be in theclient role, while the VM is in the host role. The only way for the client and host
to communicate with one another is synchronously through the Preimage ABI (specification).
In order for the client to read from the host, the read and write syscalls are modified within the FPVM to allow the client to request preparation of and read foreign data.
Reading
When theclient wants to read data from the host, it must first send a “hint” to the host through the hint file descriptor, which signals a request for the host to prepare the data for reading. The host will then
prepare the data, and send a hint acknowledgement back to the client. The client can then read the data from the host through the designated file descriptor.
The preparation step (“hinting”) is an optimization that allows the host to know ahead of time the intents of the client and the data it requires for execution. This can allow
for lazy loading of data, and also prevent the need for unnecessary allocations within the host’s memory. This step is a no-op on-chain, and is only ran locally
when the host is the native implementation of the FPVM.
Full Example
Below, we have a full architecture diagram of theop-program (source: fault proof specs), the reference implementation for the OP Stack’s Fault Proof Program,
which has the objective of verifying claims about the state of an OP Stack layer two.
host for two reasons:
- To request preparation of L1 and L2 state data preimages.
- To read the L1 and L2 state data preimages that were prepared after the above requests.
host is responsible for:
- Preparing and maintaining a store of the L1 and L2 state data preimages, as well as localized bootstrap k/v pairs.
- Providing the L1 and L2 state data preimages to the
clientfor reading.
clients) may have different requirements for communication with the host, but the above is a common pattern for programs built on top of a FPVMs. In general:
- The
clientprogram is a state machine that is responsible for bootstrapping itself from the inputs, executing the program logic, and verifying the outcome. - The
hostis responsible for providing theclientwith data it wasn’t bootstrapped with, and for executing the program itself.