Mavryk_scoru_wasm.Wasm_vm
include Wasm_vm_sig.S
include Wasm_vm_sig.Generic
with type state := Wasm_pvm_state.Internal_state.pvm_state
val compute_step_many :
?reveal_builtins:Builtins.reveals ->
?write_debug:Builtins.write_debug ->
?stop_at_snapshot:bool ->
wasm_entrypoint:string ->
max_steps:int64 ->
Wasm_pvm_state.Internal_state.pvm_state ->
(Wasm_pvm_state.Internal_state.pvm_state * int64) Lwt.t
compute_step_many ~wasm_entrypoint ~max_steps pvm_state
forwards the VM by at most max_step
compute tick, yielding if it reaches the maximum number of ticks for executing wasm_entrypoint
.
If the VM is expecting input, it gets stuck. If the VM is already stuck, this function may raise an exception. It is more efficient than compute_step
if it has to be called for more than one tick, but its resulting pvm_state will be stricly equivalent. Returns a tuple containing the number of executed ticks and the new pvm_state.
val compute_step :
wasm_entrypoint:string ->
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.Internal_state.pvm_state Lwt.t
compute_step ~wasm_entrypoint pvm_state
forwards the VM by one compute tick. If the VM is expecting input, it gets stuck. If the VM is already stuck, this function may raise an exception.
It is strictly equivalent to compute_step_many ~wasm_entrypoint ~max_step:1 pvm_state
.
val compute_step_with_debug :
wasm_entrypoint:string ->
write_debug:Builtins.write_debug ->
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.Internal_state.pvm_state Lwt.t
compute_step_with_debug ~wasm_entrypoint ~debug_flag pvm_state
is exactly compute_step ~wasm_entrypoint
but it has the ability to enable the debugging host functions.
val set_input_step :
Wasm_pvm_state.input_info ->
string ->
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.Internal_state.pvm_state Lwt.t
set_input_step input_info message pvm_state
forwards the VM by one input tick. If the VM is not expecting input, it gets stuck. If the VM is already stuck, this function may raise an exception. Note at this point the function raises an exception if the VM is not expecting input.
val reveal_step :
bytes ->
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.Internal_state.pvm_state Lwt.t
reveal_step reveal_data pvm_state
loads the reveal_data
in the memory of module of the currently executed function.
If the VM does not expect any reveal data, this function raises an exception.
val get_info :
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.info Lwt.t
get_info pvm_state
provides a typed view of the current machine state. Should not raise.
val get_wasm_version :
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.version Lwt.t
get_wasm_version pvm_state
returns the current version at which the WASM PVM operates.
module Internal_for_tests :
Wasm_vm_sig.Internal_for_tests
with type state := Wasm_pvm_state.Internal_state.pvm_state
val compute_step_many_until :
wasm_entrypoint:string ->
?max_steps:int64 ->
?reveal_builtins:Builtins.reveals ->
?write_debug:Builtins.write_debug ->
(Wasm_pvm_state.Internal_state.pvm_state -> bool Lwt.t) ->
Wasm_pvm_state.Internal_state.pvm_state ->
(Wasm_pvm_state.Internal_state.pvm_state * int64) Lwt.t
compute_step_many_until ~wasm_entrypoint ?max_steps ?reveal_builtins ?write_debug should_continue pvm_state
advances forwards the VM in the same manners as compute_step_many
as long as should_continue
returns true.
Returns the new state and number of the executed ticks.
IS applied on pvm_state
rather than a tree.
/!\ as it allows to redefine the stop condition, this function should not be used in unit test: the test could hide regression if the condition change in the code, but not in the test.
val get_output :
Wasm_pvm_state.output_info ->
Mavryk_webassembly_interpreter.Output_buffer.t ->
string Lwt.t
get_output output buffer
returns the payload associated with the given output. The result is meant to be deserialized using Sc_rollup_PVM_sem.output_encoding
. Raises an exception if the output is not present.
val eval_has_finished : Wasm_pvm_state.Internal_state.tick_state -> bool
eval_has_finished tick_state
returns true
if the evaluation phase has finished successfully.
patch_flags_on_eval_successful durable
clears flags set by previous attempted runs of kernel_run. Once an evaluation has succeeded, these can be safely deleted.
val should_compute :
?reveal_builtins:Builtins.reveals ->
Wasm_pvm_state.Internal_state.pvm_state ->
bool
should_compute pvm_state
probes whether it is possible to continue with more computational steps.
val has_reboot_flag : Durable.t -> bool Lwt.t
has_reboot_flag durable
checks if the reboot flag is set in the durable storage.
val mark_for_reboot :
Wasm_pvm_state.Internal_state.pvm_state ->
[ `Forcing_yield | `Reboot | `Yielding ] Lwt.t
mark_for_reboot reboot_counter durable
figures out the computational status with respect to what the PVM shall do next. E.g. schedule a reboot.
val next_reboot_counter :
Wasm_pvm_state.Internal_state.pvm_state ->
Wasm_pvm_state.Internal_state.computation_status ->
Z.t
next_reboot_counter pvm_state status
computes the next reboot counter.