diff --git a/src/lib_scoru_wasm/regressions/tezos_scoru_wasm_regressions.ml b/src/lib_scoru_wasm/regressions/tezos_scoru_wasm_regressions.ml index 8528e7626f47b3ac483ac6d3e056860afa025c2d..38e09eb382e4d50ab2079f4b3dc88afc6013a95a 100644 --- a/src/lib_scoru_wasm/regressions/tezos_scoru_wasm_regressions.ml +++ b/src/lib_scoru_wasm/regressions/tezos_scoru_wasm_regressions.ml @@ -53,7 +53,7 @@ module Prover = struct end module WASM_P : - Alpha_context.Sc_rollup.Wasm_2_0_0PVM.P + Alpha_context.Sc_rollup.Generic_pvm_context_sig with type Tree.t = Context_binary.t and type Tree.tree = Context_binary.tree and type Tree.key = string list diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml index 122bb2ca52fdb9dcaca05d49ff7276bb4c20d28c..a0ff2c67dde4977483ba9f79b7c5cf81c02bd52d 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml @@ -22,6 +22,32 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +open Protocol.Alpha_context + +module type P = sig + module Tree : + Tezos_context_sigs.Context.TREE + with type key = string list + and type value = bytes + + type tree = Tree.tree + + val hash_tree : tree -> Sc_rollup.State_hash.t + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup.State_hash.t + + val proof_after : proof -> Sc_rollup.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t +end module In_memory = struct open Tezos_context_memory @@ -40,7 +66,7 @@ module In_memory = struct type tree = Tree.tree - type proof = Context.Proof.tree Context.Proof.t + type proof = Context_binary.Proof.tree Context_binary.Proof.t let hash_tree _ = assert false @@ -65,26 +91,16 @@ module In_memory = struct Protocol.Alpha_context.Sc_rollup.State_hash.context_hash_to_state_hash hash - let proof_before proof = kinded_hash_to_state_hash proof.Context.Proof.before + let proof_before proof = + kinded_hash_to_state_hash proof.Context_binary.Proof.before - let proof_after proof = kinded_hash_to_state_hash proof.Context.Proof.after + let proof_after proof = + kinded_hash_to_state_hash proof.Context_binary.Proof.after let proof_encoding = Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 .tree_proof_encoding - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4386 - Extracted and adapted from {!Tezos_context_memory}. *) - let make_empty_context ?(root = "/tmp") () = - let open Lwt_syntax in - let context_promise = - let+ index = Tezos_context_memory.Context_binary.init root in - Tezos_context_memory.Context_binary.empty index - in - match Lwt.state context_promise with - | Lwt.Return result -> result - | Lwt.Fail exn -> raise exn - | Lwt.Sleep -> - (* The in-memory context should never block *) - assert false + let make_empty_context = + Tezos_context_memory.Context_binary.make_empty_context end diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli index 35ba7e64cf5a87a71b700a24c56b3ab441b1be3d..a7611201c86dd29f0a56a2f0dd4793657e718e5d 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli +++ b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli @@ -22,6 +22,32 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +open Protocol.Alpha_context + +module type P = sig + module Tree : + Tezos_context_sigs.Context.TREE + with type key = string list + and type value = bytes + + type tree = Tree.tree + + val hash_tree : tree -> Sc_rollup.State_hash.t + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup.State_hash.t + + val proof_after : proof -> Sc_rollup.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t +end (** [In_memory] is a context that can be used to instantiate an Arith or Wasm PVM. It's signature is @@ -29,8 +55,10 @@ {!Protocol.Alpha_context.Sc_rollup.Wasm_2_0_0PVM.P} *) module In_memory : sig include - Protocol.Alpha_context.Sc_rollup.ArithPVM.P - with type proof = + P + with type Tree.tree = Tezos_context_memory.Context_binary.tree + and type Tree.t = Tezos_context_memory.Context_binary.t + and type proof = Tezos_context_memory.Context.Proof.tree Tezos_context_memory.Context.Proof.t diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.ml b/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.ml index eedebb959617b85ce33ac7b5051af2d9b4626e11..e626aa543a963adc4c7595e091f9eb05b1d80f00 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.ml @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t module Arith : S = Sc_rollup.ArithPVM.Make (Context_helpers.In_memory) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.mli b/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.mli index 3871cb4c4a9fcec3a32c2a768534a06c8298296e..c0ae57cf3e9fb862cd6bcd6e5029176cf2636406 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.mli +++ b/src/proto_016_PtMumbai/lib_sc_rollup/pvm_in_memory.mli @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t (** [Arith]: Arith PVM with an in memory context {!Tezos_context_memory}. *) module Arith : S diff --git a/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.ml b/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.ml index 122bb2ca52fdb9dcaca05d49ff7276bb4c20d28c..febdce5843101cc988978fd2dd83574780345c1e 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.ml @@ -22,6 +22,32 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +open Protocol.Alpha_context + +module type P = sig + module Tree : + Tezos_context_sigs.Context.TREE + with type key = string list + and type value = bytes + + type tree = Tree.tree + + val hash_tree : tree -> Sc_rollup.State_hash.t + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup.State_hash.t + + val proof_after : proof -> Sc_rollup.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t +end module In_memory = struct open Tezos_context_memory @@ -73,18 +99,6 @@ module In_memory = struct Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 .tree_proof_encoding - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4386 - Extracted and adapted from {!Tezos_context_memory}. *) - let make_empty_context ?(root = "/tmp") () = - let open Lwt_syntax in - let context_promise = - let+ index = Tezos_context_memory.Context_binary.init root in - Tezos_context_memory.Context_binary.empty index - in - match Lwt.state context_promise with - | Lwt.Return result -> result - | Lwt.Fail exn -> raise exn - | Lwt.Sleep -> - (* The in-memory context should never block *) - assert false + let make_empty_context = + Tezos_context_memory.Context_binary.make_empty_context end diff --git a/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.mli b/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.mli index 35ba7e64cf5a87a71b700a24c56b3ab441b1be3d..a7611201c86dd29f0a56a2f0dd4793657e718e5d 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.mli +++ b/src/proto_017_PtNairob/lib_sc_rollup/context_helpers.mli @@ -22,6 +22,32 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +open Protocol.Alpha_context + +module type P = sig + module Tree : + Tezos_context_sigs.Context.TREE + with type key = string list + and type value = bytes + + type tree = Tree.tree + + val hash_tree : tree -> Sc_rollup.State_hash.t + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup.State_hash.t + + val proof_after : proof -> Sc_rollup.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t +end (** [In_memory] is a context that can be used to instantiate an Arith or Wasm PVM. It's signature is @@ -29,8 +55,10 @@ {!Protocol.Alpha_context.Sc_rollup.Wasm_2_0_0PVM.P} *) module In_memory : sig include - Protocol.Alpha_context.Sc_rollup.ArithPVM.P - with type proof = + P + with type Tree.tree = Tezos_context_memory.Context_binary.tree + and type Tree.t = Tezos_context_memory.Context_binary.t + and type proof = Tezos_context_memory.Context.Proof.tree Tezos_context_memory.Context.Proof.t diff --git a/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.ml b/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.ml index eedebb959617b85ce33ac7b5051af2d9b4626e11..e626aa543a963adc4c7595e091f9eb05b1d80f00 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.ml @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t module Arith : S = Sc_rollup.ArithPVM.Make (Context_helpers.In_memory) diff --git a/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.mli b/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.mli index 3871cb4c4a9fcec3a32c2a768534a06c8298296e..c0ae57cf3e9fb862cd6bcd6e5029176cf2636406 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.mli +++ b/src/proto_017_PtNairob/lib_sc_rollup/pvm_in_memory.mli @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t (** [Arith]: Arith PVM with an in memory context {!Tezos_context_memory}. *) module Arith : S diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 4357862cff42a53dd1809bbe741dcc7b95d3baee..935006bc2158fa9ce8eb331a0e2cae897b3ea8b7 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3130,6 +3130,27 @@ module Sc_rollup : sig | Dissection_invalid_successive_states_shape end + module type Generic_pvm_context_sig = sig + module Tree : + Context.TREE with type key = string list and type value = bytes + + type tree = Tree.tree + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup_repr.State_hash.t + + val proof_after : proof -> Sc_rollup_repr.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t + end + module PVM : sig type boot_sector = string @@ -3240,33 +3261,7 @@ module Sc_rollup : sig val genesis_state_hash_of : boot_sector:string -> Kind.t -> State_hash.t Lwt.t module ArithPVM : sig - module type P = sig - module Tree : - Context.TREE with type key = string list and type value = bytes - - type tree = Tree.tree - - val hash_tree : tree -> State_hash.t - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> State_hash.t - - val proof_after : proof -> State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> - tree -> - (tree -> (tree * 'a) Lwt.t) -> - (proof * 'a) option Lwt.t - end - - module Make (C : P) : sig + module Make (C : Generic_pvm_context_sig) : sig include PVM.S with type context = C.Tree.t @@ -3310,33 +3305,9 @@ module Sc_rollup : sig val well_known_reveal_hash : Sc_rollup_reveal_hash.t - module type P = sig - module Tree : - Context.TREE with type key = string list and type value = bytes - - type tree = Tree.tree - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> State_hash.t - - val proof_after : proof -> State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> - tree -> - (tree -> (tree * 'a) Lwt.t) -> - (proof * 'a) option Lwt.t - end - module type Make_wasm = module type of Wasm_2_0_0.Make - module Make (Wasm_backend : Make_wasm) (C : P) : sig + module Make (Wasm_backend : Make_wasm) (C : Generic_pvm_context_sig) : sig include PVM.S with type context = C.Tree.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml index 296f0a41988bf4b3bdc477b728345a1c01795c65..bf4bdd7138b9be62abda66b04747555278c0ae7b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -553,3 +553,23 @@ module type S = sig val insert_failure : state -> state Lwt.t end end + +module type Generic_pvm_context_sig = sig + module Tree : Context.TREE with type key = string list and type value = bytes + + type tree = Tree.tree + + type proof + + val proof_encoding : proof Data_encoding.t + + val proof_before : proof -> Sc_rollup_repr.State_hash.t + + val proof_after : proof -> Sc_rollup_repr.State_hash.t + + val verify_proof : + proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t + + val produce_proof : + Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t +end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 5a2a9ee32fc94546199a499115390bb46cd5b16e..287354f712d2b49961d83e34c5f4677d405d4923 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -91,28 +91,6 @@ let () = (function Arith_proof_production_failed -> Some () | _ -> None) (fun () -> Arith_proof_production_failed) -module type P = sig - module Tree : Context.TREE with type key = string list and type value = bytes - - type tree = Tree.tree - - val hash_tree : tree -> State_hash.t - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> State_hash.t - - val proof_after : proof -> State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t -end - module type S = sig include PS.S @@ -161,7 +139,7 @@ module type S = sig val get_is_stuck : state -> string option Lwt.t end -module Make (Context : P) : +module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : S with type context = Context.Tree.t and type state = Context.tree @@ -1751,8 +1729,6 @@ module Protocol_implementation = Make (struct type tree = Context.tree - let hash_tree t = State_hash.context_hash_to_state_hash (Tree.hash t) - type proof = Context.Proof.tree Context.Proof.t let verify_proof p f = diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli index 74e27140887264bc07e34937e11c3f65c3139d19..9bd8f8da76b281bc34ecf199e7c3e8c4f8fd4821 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli @@ -165,29 +165,7 @@ module Protocol_implementation : tree structure). *) val reference_initial_state_hash : Sc_rollup_repr.State_hash.t -module type P = sig - module Tree : Context.TREE with type key = string list and type value = bytes - - type tree = Tree.tree - - val hash_tree : tree -> Sc_rollup_repr.State_hash.t - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> Sc_rollup_repr.State_hash.t - - val proof_after : proof -> Sc_rollup_repr.State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t -end - -module Make (Context : P) : +module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : S with type context = Context.Tree.t and type state = Context.tree diff --git a/src/proto_alpha/lib_protocol/sc_rollup_machine_no_proofs.ml b/src/proto_alpha/lib_protocol/sc_rollup_machine_no_proofs.ml index 6885b4b381d00b64e236402c072c6a57e541d5b4..c08158f9fb71b58a0fdc103dc25c2be6fe515695 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_machine_no_proofs.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_machine_no_proofs.ml @@ -43,9 +43,6 @@ module Context_no_proofs = struct type tree = Context_binary.tree - let hash_tree tree = - Sc_rollup_repr.State_hash.context_hash_to_state_hash (Tree.hash tree) - type proof = void let verify_proof = function (_ : proof) -> . diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index b17f75e4cc16ffff8b5c56ecb59a815ca98b5ab1..e7342c101df265027c7a8d3a424440338e9c8cf4 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -129,26 +129,6 @@ module V2_0_0 = struct module type Make_wasm = module type of Wasm_2_0_0.Make - module type P = sig - module Tree : TreeS - - type tree = Tree.tree - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> State_hash.t - - val proof_after : proof -> State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t - end - module type S = sig include Sc_rollup_PVM_sig.S @@ -180,7 +160,9 @@ module V2_0_0 = struct The Make_backend is a functor that creates the backend of the PVM. The Conext provides the tree and the proof types. *) - module Make (Make_backend : Make_wasm) (Context : P) : + module Make + (Make_backend : Make_wasm) + (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : S with type context = Context.Tree.t and type state = Context.tree diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli index 556c9cef0a9707853f7a464c5073f8c4712a37a3..11b9bb2ec318c6694730c74bdfff73bc8f008848 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli @@ -64,31 +64,12 @@ module V2_0_0 : sig Raw_level_repr.t -> state -> Sc_rollup_PVM_sig.output list Lwt.t end - module type P = sig - module Tree : - Context.TREE with type key = string list and type value = bytes - - type tree = Tree.tree - - type proof - - val proof_encoding : proof Data_encoding.t - - val proof_before : proof -> Sc_rollup_repr.State_hash.t - - val proof_after : proof -> Sc_rollup_repr.State_hash.t - - val verify_proof : - proof -> (tree -> (tree * 'a) Lwt.t) -> (tree * 'a) option Lwt.t - - val produce_proof : - Tree.t -> tree -> (tree -> (tree * 'a) Lwt.t) -> (proof * 'a) option Lwt.t - end - module type Make_wasm = module type of Wasm_2_0_0.Make (** Build a WebAssembly PVM using the given proof-supporting context. *) - module Make (Lib_scoru_Wasm : Make_wasm) (Context : P) : + module Make + (Lib_scoru_Wasm : Make_wasm) + (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : S with type context = Context.Tree.t and type state = Context.tree diff --git a/src/proto_alpha/lib_sc_rollup/context_helpers.ml b/src/proto_alpha/lib_sc_rollup/context_helpers.ml index 2ab44f26d043bd2b8a6555207e4353249d3af583..af5e6a6d08f85cb5c384fceeaa2dd29aea5989e5 100644 --- a/src/proto_alpha/lib_sc_rollup/context_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup/context_helpers.ml @@ -40,9 +40,7 @@ module In_memory = struct type tree = Tree.tree - type proof = Context.Proof.tree Context.Proof.t - - let hash_tree _ = assert false + type proof = Context_binary.Proof.tree Context_binary.Proof.t let verify_proof p f = Lwt.map Result.to_option (Context_binary.verify_tree_proof p f) @@ -65,9 +63,11 @@ module In_memory = struct Protocol.Alpha_context.Sc_rollup.State_hash.context_hash_to_state_hash hash - let proof_before proof = kinded_hash_to_state_hash proof.Context.Proof.before + let proof_before proof = + kinded_hash_to_state_hash proof.Context_binary.Proof.before - let proof_after proof = kinded_hash_to_state_hash proof.Context.Proof.after + let proof_after proof = + kinded_hash_to_state_hash proof.Context_binary.Proof.after let proof_encoding = Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 diff --git a/src/proto_alpha/lib_sc_rollup/context_helpers.mli b/src/proto_alpha/lib_sc_rollup/context_helpers.mli index 35ba7e64cf5a87a71b700a24c56b3ab441b1be3d..fed32af2901ef78d5512b1dd591526b954d7a1e5 100644 --- a/src/proto_alpha/lib_sc_rollup/context_helpers.mli +++ b/src/proto_alpha/lib_sc_rollup/context_helpers.mli @@ -22,15 +22,17 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +open Protocol.Alpha_context (** [In_memory] is a context that can be used to instantiate an Arith or Wasm PVM. It's signature is - {!Protocol.Alpha_context.Sc_rollup.ArithPVM.P} = - {!Protocol.Alpha_context.Sc_rollup.Wasm_2_0_0PVM.P} *) + {!Protocol.Alpha_context.Sc_rollup.Generic_pvm_context_sig} *) module In_memory : sig include - Protocol.Alpha_context.Sc_rollup.ArithPVM.P - with type proof = + Sc_rollup.Generic_pvm_context_sig + with type Tree.tree = Tezos_context_memory.Context_binary.tree + and type Tree.t = Tezos_context_memory.Context_binary.t + and type proof = Tezos_context_memory.Context.Proof.tree Tezos_context_memory.Context.Proof.t diff --git a/src/proto_alpha/lib_sc_rollup/pvm_in_memory.ml b/src/proto_alpha/lib_sc_rollup/pvm_in_memory.ml index eedebb959617b85ce33ac7b5051af2d9b4626e11..e626aa543a963adc4c7595e091f9eb05b1d80f00 100644 --- a/src/proto_alpha/lib_sc_rollup/pvm_in_memory.ml +++ b/src/proto_alpha/lib_sc_rollup/pvm_in_memory.ml @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t module Arith : S = Sc_rollup.ArithPVM.Make (Context_helpers.In_memory) diff --git a/src/proto_alpha/lib_sc_rollup/pvm_in_memory.mli b/src/proto_alpha/lib_sc_rollup/pvm_in_memory.mli index 3871cb4c4a9fcec3a32c2a768534a06c8298296e..c0ae57cf3e9fb862cd6bcd6e5029176cf2636406 100644 --- a/src/proto_alpha/lib_sc_rollup/pvm_in_memory.mli +++ b/src/proto_alpha/lib_sc_rollup/pvm_in_memory.mli @@ -27,11 +27,11 @@ open Protocol.Alpha_context module type S = Sc_rollup.PVM.S - with type context = Context_helpers.In_memory.Tree.t - and type state = Context_helpers.In_memory.tree + with type context = Tezos_context_memory.Context_binary.t + and type state = Tezos_context_memory.Context_binary.tree and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t + Tezos_context_memory.Context_binary.Proof.tree + Tezos_context_memory.Context_binary.Proof.t (** [Arith]: Arith PVM with an in memory context {!Tezos_context_memory}. *) module Arith : S