diff --git a/src/lib_scoru_wasm/gather_floppies.ml b/src/lib_scoru_wasm/gather_floppies.ml index 56f94b729d7b612266ab4d29d41c108c6f2bc3c1..0459d8538d427a3e97e9a3c527b32db8fa6c9112 100644 --- a/src/lib_scoru_wasm/gather_floppies.ml +++ b/src/lib_scoru_wasm/gather_floppies.ml @@ -418,6 +418,8 @@ module Make inner_info.last_input_read; }) + let compute_step_many = Wasm.compute_step_many + module Internal_for_tests = struct include Wasm.Internal_for_tests diff --git a/src/lib_scoru_wasm/test/test_hash_consistency.ml b/src/lib_scoru_wasm/test/test_hash_consistency.ml index b1517c150c29ce3728236ee50beb0f68ac33c67d..80c63d6b87e08bb22e0a473f7059c1f65958039b 100644 --- a/src/lib_scoru_wasm/test/test_hash_consistency.ml +++ b/src/lib_scoru_wasm/test/test_hash_consistency.ml @@ -40,12 +40,10 @@ let test_execution_correspondance skip count () = let* tree = initial_tree ~from_binary:true ~max_tick:40_000L kernel in let* tree = if skip = 0L then Lwt.return tree - else Wasm.Internal_for_tests.compute_step_many ~max_steps:skip tree + else Wasm.compute_step_many ~max_steps:skip tree in let rec explore tree' n = - let* tree_ref = - Wasm.Internal_for_tests.compute_step_many ~max_steps:n tree - in + let* tree_ref = Wasm.compute_step_many ~max_steps:n tree in let* tree' = Wasm.compute_step tree' in assert ( Context_hash.(Context.Tree.hash tree_ref = Context.Tree.hash tree')) ; diff --git a/src/lib_scoru_wasm/test/wasm_utils.ml b/src/lib_scoru_wasm/test/wasm_utils.ml index ea25626ce55ab5f1024f06c67679b593e2bc73ec..eda9c920cb2eb88a6a51798d5cad69b88100012d 100644 --- a/src/lib_scoru_wasm/test/wasm_utils.ml +++ b/src/lib_scoru_wasm/test/wasm_utils.ml @@ -58,7 +58,7 @@ let initial_tree ?(max_tick = 100000L) ?(from_binary = false) code = let eval_until_stuck ?(max_steps = 20000L) tree = let open Lwt.Syntax in let rec go counter tree = - let* tree = Wasm.Internal_for_tests.compute_step_many ~max_steps tree in + let* tree = Wasm.compute_step_many ~max_steps tree in let* stuck = Wasm.Internal_for_tests.is_stuck tree in match stuck with | Some stuck -> Lwt_result.return (stuck, tree) @@ -73,7 +73,7 @@ let rec eval_until_input_requested ?(max_steps = Int64.max_int) tree = let* info = Wasm.get_info tree in match info.input_request with | No_input_required -> - let* tree = Wasm.Internal_for_tests.compute_step_many ~max_steps tree in + let* tree = Wasm.compute_step_many ~max_steps tree in eval_until_input_requested tree | Input_required -> return tree diff --git a/src/lib_scoru_wasm/wasm_pvm.ml b/src/lib_scoru_wasm/wasm_pvm.ml index c0e379e9380f4544a08320fad72512ea6c488e7f..7623e06029913bf0db6b61dc9a182523b997973d 100644 --- a/src/lib_scoru_wasm/wasm_pvm.ml +++ b/src/lib_scoru_wasm/wasm_pvm.ml @@ -409,7 +409,7 @@ struct in return pvm_state - let compute_step_many ?(max_steps = 1L) tree = + let compute_step_many ~max_steps tree = let open Lwt.Syntax in assert (max_steps > 0L) ; @@ -549,8 +549,6 @@ struct | Stuck error -> Lwt.return_some error | _ -> Lwt.return_none - let compute_step_many = compute_step_many - let set_max_nb_ticks n tree = let open Lwt_syntax in let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in diff --git a/src/lib_scoru_wasm/wasm_pvm_sig.ml b/src/lib_scoru_wasm/wasm_pvm_sig.ml index bfb17853e2d1f66c35c2b7c9c2123b221635cb12..2a054ed041bc26424cfab0fa985d9c0f637bec71 100644 --- a/src/lib_scoru_wasm/wasm_pvm_sig.ml +++ b/src/lib_scoru_wasm/wasm_pvm_sig.ml @@ -61,8 +61,6 @@ module type Internal_for_tests = sig val is_stuck : tree -> Wasm_pvm_errors.t option Lwt.t - val compute_step_many : ?max_steps:int64 -> tree -> tree Lwt.t - val set_max_nb_ticks : Z.t -> tree -> tree Lwt.t end @@ -72,16 +70,24 @@ module type S = sig type tick_state - (** [compute_step] 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. *) + (** [compute_step_many ~max_steps tree] forwards the VM by at most [max_step] + compute tick, yielding if it reaches the maximum number of ticks for a + toplevel kernel call. 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 tree will be stricly equivalent. *) + val compute_step_many : max_steps:int64 -> tree -> tree Lwt.t + + (** [compute_step tree] 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 ~max_step=1 + tree]. *) val compute_step : tree -> tree Lwt.t - (** [set_input_step] 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. WHen we implement astuck - state this needs to be slightly changed.*) + (** [set_input_step input_info message tree] 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 set_input_step : input_info -> string -> tree -> tree Lwt.t (** [get_output output state] returns the payload associated with the given