diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index dea994b3770aa620ecf1fd6a9ed9f8523d9a3cc7..f7f00ab62324731378050683af407d9e47468202 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -453,14 +453,14 @@ opam:tezos-client-000-Ps9mPmXa: opam:tezos-client-001-PtCJ7pwo: extends: - .opam_template - - .rules_template__trigger_opam_batch_3 + - .rules_template__trigger_opam_batch_2 variables: package: tezos-client-001-PtCJ7pwo opam:tezos-client-002-PsYLVpVv: extends: - .opam_template - - .rules_template__trigger_opam_batch_3 + - .rules_template__trigger_opam_batch_2 variables: package: tezos-client-002-PsYLVpVv @@ -509,7 +509,7 @@ opam:tezos-client-008-PtEdo2Zk: opam:tezos-client-009-PsFLoren: extends: - .opam_template - - .rules_template__trigger_opam_batch_2 + - .rules_template__trigger_opam_batch_1 variables: package: tezos-client-009-PsFLoren @@ -743,21 +743,21 @@ opam:tezos-embedded-protocol-009-PsFLoren: opam:tezos-embedded-protocol-010-PtGRANAD: extends: - .opam_template - - .rules_template__trigger_opam_batch_4 + - .rules_template__trigger_opam_batch_3 variables: package: tezos-embedded-protocol-010-PtGRANAD opam:tezos-embedded-protocol-011-PtHangz2: extends: - .opam_template - - .rules_template__trigger_opam_batch_4 + - .rules_template__trigger_opam_batch_3 variables: package: tezos-embedded-protocol-011-PtHangz2 opam:tezos-embedded-protocol-012-Psithaca: extends: - .opam_template - - .rules_template__trigger_opam_batch_4 + - .rules_template__trigger_opam_batch_3 variables: package: tezos-embedded-protocol-012-Psithaca @@ -1079,7 +1079,7 @@ opam:tezos-protocol-016-PtMumbai: opam:tezos-protocol-alpha: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_5 variables: package: tezos-protocol-alpha @@ -1088,14 +1088,14 @@ opam:tezos-protocol-alpha: opam:tezos-protocol-demo-counter: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_5 variables: package: tezos-protocol-demo-counter opam:tezos-protocol-demo-noops: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_5 variables: package: tezos-protocol-demo-noops @@ -1276,14 +1276,14 @@ opam:tezos-protocol-plugin-alpha-registerer: opam:tezos-protocol-updater: extends: - .opam_template - - .rules_template__trigger_opam_batch_5 + - .rules_template__trigger_opam_batch_4 variables: package: tezos-protocol-updater opam:tezos-proxy: extends: - .opam_template - - .rules_template__trigger_opam_batch_5 + - .rules_template__trigger_opam_batch_4 variables: package: tezos-proxy @@ -1311,7 +1311,7 @@ opam:tezos-rpc: opam:tezos-rpc-http: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-rpc-http @@ -1409,7 +1409,7 @@ opam:tezos-shell-services-test-helpers: opam:tezos-signer-backends: extends: - .opam_template - - .rules_template__trigger_opam_batch_5 + - .rules_template__trigger_opam_batch_4 variables: package: tezos-signer-backends @@ -1423,11 +1423,25 @@ opam:tezos-signer-services: opam:tezos-smart-rollup-016-PtMumbai: extends: - .opam_template - - .rules_template__trigger_opam_batch_1 + - .rules_template__trigger_opam_batch_4 variables: package: tezos-smart-rollup-016-PtMumbai -# Ignoring unreleased package tezos-smart-rollup-alpha. +opam:tezos-smart-rollup-alpha: + extends: + - .opam_template + - .rules_template__trigger_opam_batch_5 + variables: + package: tezos-smart-rollup-alpha + +opam:tezos-smart-rollup-layer2-016-PtMumbai: + extends: + - .opam_template + - .rules_template__trigger_opam_batch_1 + variables: + package: tezos-smart-rollup-layer2-016-PtMumbai + +# Ignoring unreleased package tezos-smart-rollup-layer2-alpha. opam:tezos-stdlib: extends: @@ -1460,7 +1474,7 @@ opam:tezos-test-helpers: opam:tezos-test-helpers-extra: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-test-helpers-extra @@ -1471,7 +1485,7 @@ opam:tezos-test-helpers-extra: opam:tezos-tree-encoding: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-tree-encoding @@ -1494,7 +1508,7 @@ opam:tezos-validation: opam:tezos-version: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-version diff --git a/CHANGES.rst b/CHANGES.rst index 06ffb89f5db8fe9f398250cdf79f753e238c2e2d..66468107d5f96b893c3ef6396ff7da59e2e55090 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -60,6 +60,12 @@ Node indexing strategy. For now, only the ``minimal`` indexing strategy is allowed. +- Added an RPC ``POST + /chains/main/blocks/head/context/smart_rollups/all/origination_proof`` + with input ``{"kind":"", "kernel"=""}`` to produce the origination proof needed to originate a + smart rollup. + Client ------ diff --git a/dune-project b/dune-project index 9adfa71339e4617723c4c2b305e5da1bc8c00300..6baad27fb6fddfba39ea07add7fc4ce47a9a34e8 100644 --- a/dune-project +++ b/dune-project @@ -213,6 +213,8 @@ (package (name tezos-signer-services)) (package (name tezos-smart-rollup-016-PtMumbai)) (package (name tezos-smart-rollup-alpha)) +(package (name tezos-smart-rollup-layer2-016-PtMumbai)) +(package (name tezos-smart-rollup-layer2-alpha)) (package (name tezos-stdlib)) (package (name tezos-stdlib-unix)) (package (name tezos-store)) diff --git a/manifest/main.ml b/manifest/main.ml index c11364da4d3d0c7b38d33b55629a3e005c8079a5..0e3449a2a5410867d232513f98078150ae500f69 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4587,6 +4587,18 @@ module Protocol = Protocol ]) ~bisect_ppx:false in + let octez_sc_rollup = + only_if N.(number >= 016) @@ fun () -> + public_lib + (sf "tezos-smart-rollup-%s" name_dash) + ~path:(path // "lib_sc_rollup") + ~synopsis: + "Tezos/Protocol: protocol specific library of helpers for \ + `tezos-smart-rollup`" + ~deps:[octez_base |> open_ ~m:"TzPervasives"; main |> open_] + ~inline_tests:ppx_expect + ~linkall:true + in let plugin = only_if (N.(number >= 007) && not_overridden) @@ fun () -> public_lib @@ -4598,6 +4610,7 @@ module Protocol = Protocol octez_base |> open_ ~m:"TzPervasives" |> open_ ~m:"TzPervasives.Error_monad.Legacy_monad_globals"; main |> open_; + octez_sc_rollup |> if_some |> if_ N.(number >= 016) |> open_; ] ~all_modules_except:["Plugin_registerer"] ~bisect_ppx:N.(number >= 008) @@ -4643,6 +4656,7 @@ module Protocol = Protocol octez_rpc; octez_client_commands |> if_ N.(number == 000) |> open_; octez_stdlib_unix |> if_ N.(number == 000); + octez_sc_rollup |> if_some |> if_ N.(number >= 016) |> open_; uri |> if_ N.(number >= 001); ] ~bisect_ppx:N.(number >= 008) @@ -5076,20 +5090,17 @@ module Protocol = Protocol ~inline_tests:ppx_expect ~linkall:true in - let octez_sc_rollup = + let octez_sc_rollup_layer2 = only_if N.(number >= 016) @@ fun () -> public_lib - (sf "tezos-smart-rollup-%s" name_dash) - ~path:(path // "lib_sc_rollup") + (sf "tezos-smart-rollup-layer2-%s" name_dash) + ~path:(path // "lib_sc_rollup_layer2") ~synopsis: "Tezos/Protocol: protocol specific library for `tezos-smart-rollup`" ~deps: [ octez_base |> open_ ~m:"TzPervasives"; main |> open_; - plugin |> if_some |> open_; - parameters |> if_some |> open_; - octez_rpc; octez_injector |> open_; ] ~inline_tests:ppx_expect @@ -5122,6 +5133,7 @@ module Protocol = Protocol octez_dal_node_lib |> open_; octez_shell_services |> open_; octez_sc_rollup |> if_some |> open_; + octez_sc_rollup_layer2 |> if_some |> open_; layer2_utils |> if_some |> open_; octez_layer2_store |> open_; tree_encoding; @@ -5155,6 +5167,7 @@ module Protocol = Protocol octez_client_base_unix |> open_; client |> if_some |> open_; octez_sc_rollup |> if_some |> open_; + octez_sc_rollup_layer2 |> if_some |> open_; ] in let _sc_rollup_client = diff --git a/opam/octez-smart-rollup-client-PtMumbai.opam b/opam/octez-smart-rollup-client-PtMumbai.opam index b7cb605e0dd02479d5edbb0e730090b60540afdc..2c4a83765c9a11828fa529789963facb7ce89932 100644 --- a/opam/octez-smart-rollup-client-PtMumbai.opam +++ b/opam/octez-smart-rollup-client-PtMumbai.opam @@ -17,6 +17,7 @@ depends: [ "tezos-client-base-unix" "tezos-client-016-PtMumbai" "tezos-smart-rollup-016-PtMumbai" + "tezos-smart-rollup-layer2-016-PtMumbai" "tezos-clic" ] build: [ diff --git a/opam/octez-smart-rollup-client-alpha.opam b/opam/octez-smart-rollup-client-alpha.opam index ae34ea100e43c96ed10c182ecd1df1fbd5cc7404..7b4611bad7509f6236fae0bbd79ef6bbbc094176 100644 --- a/opam/octez-smart-rollup-client-alpha.opam +++ b/opam/octez-smart-rollup-client-alpha.opam @@ -17,6 +17,7 @@ depends: [ "tezos-client-base-unix" "tezos-client-alpha" "tezos-smart-rollup-alpha" + "tezos-smart-rollup-layer2-alpha" "tezos-clic" ] build: [ diff --git a/opam/octez-smart-rollup-node-PtMumbai.opam b/opam/octez-smart-rollup-node-PtMumbai.opam index 563c6e1fe2d7cdf3a5f385c852817a89678c730e..598e7461c46dc088f4f43574012a9326c87ea764 100644 --- a/opam/octez-smart-rollup-node-PtMumbai.opam +++ b/opam/octez-smart-rollup-node-PtMumbai.opam @@ -26,6 +26,7 @@ depends: [ "tezos-dal-node-lib" "tezos-shell-services" "tezos-smart-rollup-016-PtMumbai" + "tezos-smart-rollup-layer2-016-PtMumbai" "tezos-layer2-utils-016-PtMumbai" "tezos-layer2-store" "tezos-tree-encoding" diff --git a/opam/octez-smart-rollup-node-alpha.opam b/opam/octez-smart-rollup-node-alpha.opam index f7e6e103f83d409ae3bb766ae69a5446dd92197c..cf8a0b48f0fba850c9965d81e02e2940c19c02d0 100644 --- a/opam/octez-smart-rollup-node-alpha.opam +++ b/opam/octez-smart-rollup-node-alpha.opam @@ -26,6 +26,7 @@ depends: [ "tezos-dal-node-lib" "tezos-shell-services" "tezos-smart-rollup-alpha" + "tezos-smart-rollup-layer2-alpha" "tezos-layer2-utils-alpha" "tezos-layer2-store" "tezos-tree-encoding" diff --git a/opam/tezos-client-016-PtMumbai.opam b/opam/tezos-client-016-PtMumbai.opam index 14872bbc7de112e28356ed769f9a2eed2940d753..a38b3d232e82c67c83a5b8ca38c24cd29e109f27 100644 --- a/opam/tezos-client-016-PtMumbai.opam +++ b/opam/tezos-client-016-PtMumbai.opam @@ -21,6 +21,7 @@ depends: [ "tezos-signer-backends" "tezos-protocol-plugin-016-PtMumbai" "tezos-rpc" + "tezos-smart-rollup-016-PtMumbai" "uri" { >= "3.1.0" } "tezos-stdlib-unix" "tezos-protocol-environment" diff --git a/opam/tezos-client-alpha.opam b/opam/tezos-client-alpha.opam index 4f5b2cf4c232c78b948c17a6be10a4f6f2dbf112..7a773bbe0bf7b41124198c13c059e707da40b559 100644 --- a/opam/tezos-client-alpha.opam +++ b/opam/tezos-client-alpha.opam @@ -21,6 +21,7 @@ depends: [ "tezos-signer-backends" "tezos-protocol-plugin-alpha" "tezos-rpc" + "tezos-smart-rollup-alpha" "uri" { >= "3.1.0" } "tezos-stdlib-unix" "tezos-protocol-environment" diff --git a/opam/tezos-protocol-plugin-016-PtMumbai.opam b/opam/tezos-protocol-plugin-016-PtMumbai.opam index c086b3fe62076b11081b1ecc660fc4a3d16b89f4..f7f614dad98c6290708f2d58b447f135ddd28076 100644 --- a/opam/tezos-protocol-plugin-016-PtMumbai.opam +++ b/opam/tezos-protocol-plugin-016-PtMumbai.opam @@ -12,6 +12,7 @@ depends: [ "ocaml" { >= "4.14" } "tezos-base" "tezos-protocol-016-PtMumbai" + "tezos-smart-rollup-016-PtMumbai" ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-protocol-plugin-alpha.opam b/opam/tezos-protocol-plugin-alpha.opam index c0b87630da7ab1474f7df9247ac8438b1927e6d2..750701e9cc2a1544df8fb5a6ea984e22fe55b76d 100644 --- a/opam/tezos-protocol-plugin-alpha.opam +++ b/opam/tezos-protocol-plugin-alpha.opam @@ -12,6 +12,7 @@ depends: [ "ocaml" { >= "4.14" } "tezos-base" "tezos-protocol-alpha" + "tezos-smart-rollup-alpha" ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-smart-rollup-016-PtMumbai.opam b/opam/tezos-smart-rollup-016-PtMumbai.opam index c7623591739f7a3512c1a451a54132611147663f..18eb0ec2b809523ac439cc0ea5ea677eeaba30a2 100644 --- a/opam/tezos-smart-rollup-016-PtMumbai.opam +++ b/opam/tezos-smart-rollup-016-PtMumbai.opam @@ -13,13 +13,10 @@ depends: [ "ppx_expect" "tezos-base" "tezos-protocol-016-PtMumbai" - "tezos-protocol-plugin-016-PtMumbai" - "tezos-rpc" - "octez-injector" ] build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -synopsis: "Tezos/Protocol: protocol specific library for `tezos-smart-rollup`" +synopsis: "Tezos/Protocol: protocol specific library of helpers for `tezos-smart-rollup`" diff --git a/opam/tezos-smart-rollup-alpha.opam b/opam/tezos-smart-rollup-alpha.opam index eaed2d1e93cc07ec483312a670f51bfa2585c657..46d3f7f80f1a24257ee64aabb97bdbc7b47231c7 100644 --- a/opam/tezos-smart-rollup-alpha.opam +++ b/opam/tezos-smart-rollup-alpha.opam @@ -13,13 +13,10 @@ depends: [ "ppx_expect" "tezos-base" "tezos-protocol-alpha" - "tezos-protocol-plugin-alpha" - "tezos-rpc" - "octez-injector" ] build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -synopsis: "Tezos/Protocol: protocol specific library for `tezos-smart-rollup`" +synopsis: "Tezos/Protocol: protocol specific library of helpers for `tezos-smart-rollup`" diff --git a/opam/tezos-smart-rollup-layer2-016-PtMumbai.opam b/opam/tezos-smart-rollup-layer2-016-PtMumbai.opam new file mode 100644 index 0000000000000000000000000000000000000000..18bc6cb044123c3d829be40d68b45419b3c926f1 --- /dev/null +++ b/opam/tezos-smart-rollup-layer2-016-PtMumbai.opam @@ -0,0 +1,23 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.0" } + "ocaml" { >= "4.14" } + "ppx_expect" + "tezos-base" + "tezos-protocol-016-PtMumbai" + "octez-injector" +] +build: [ + ["rm" "-r" "vendors"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Tezos/Protocol: protocol specific library for `tezos-smart-rollup`" diff --git a/opam/tezos-smart-rollup-layer2-alpha.opam b/opam/tezos-smart-rollup-layer2-alpha.opam new file mode 100644 index 0000000000000000000000000000000000000000..5e0b7af27672eb10714f495bd7ac9896a4ff0b3f --- /dev/null +++ b/opam/tezos-smart-rollup-layer2-alpha.opam @@ -0,0 +1,23 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.0" } + "ocaml" { >= "4.14" } + "ppx_expect" + "tezos-base" + "tezos-protocol-alpha" + "octez-injector" +] +build: [ + ["rm" "-r" "vendors"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Tezos/Protocol: protocol specific library for `tezos-smart-rollup`" diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_context.ml b/src/proto_016_PtMumbai/lib_client/client_proto_context.ml index 2db3f6c84b83e12ff861f09d9b20d771efbb12e2..c881b09d666064a7ff0d1af7734cdbbcac5fc305 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_context.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_context.ml @@ -1314,8 +1314,9 @@ let transfer_ticket (cctxt : #full) ~chain ~block ?confirmations ?dry_run let sc_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?storage_limit ?counter ~source ~kind ~boot_sector ~parameters_ty ~src_pk ~src_sk ~fee_parameter () = - Client_proto_rollups.ScRollup.origination_proof_exn ~boot_sector kind - >>= fun origination_proof -> + Proof_helpers.origination_proof ~boot_sector kind + >|= Environment.wrap_tzresult + >>=? fun origination_proof -> let op = Annotated_manager_operation.Single_manager (Injection.prepare_manager_operation diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_rollups.ml b/src/proto_016_PtMumbai/lib_client/client_proto_rollups.ml index aee31002094d290741fcf2f6aa3238e376a2bcaf..dc969c5712fd1fac56923cdaa72156c59076b45c 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_rollups.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_rollups.ml @@ -76,124 +76,6 @@ end module TxRollupAlias = Client_aliases.Alias (TxRollupEntity) -module ScRollup = struct - module In_memory_context = struct - open Tezos_context_memory - - module Tree = struct - include Context_binary.Tree - - type tree = Context_binary.tree - - type t = Context_binary.t - - type key = string list - - type value = bytes - end - - type tree = Tree.tree - - type proof = Context.Proof.tree Context.Proof.t - - let hash_tree _ = assert false - - let verify_proof p f = - Lwt.map Result.to_option (Context_binary.verify_tree_proof p f) - - let produce_proof context state step = - let open Lwt_syntax in - let* context = Context_binary.add_tree context [] state in - let* h = Context_binary.commit ~time:Time.Protocol.epoch context in - let index = Context_binary.index context in - let* context = Context_binary.checkout_exn index h in - match Tree.kinded_key state with - | Some k -> - let index = Context_binary.index context in - let* p = Context_binary.produce_tree_proof index k step in - return (Some p) - | None -> return None - - let kinded_hash_to_state_hash = function - | `Value hash | `Node hash -> - 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_after proof = kinded_hash_to_state_hash proof.Context.Proof.after - - let proof_encoding = - Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 - .tree_proof_encoding - end - - module Arith_pvm : - Sc_rollup.PVM.S - with type context = In_memory_context.Tree.t - and type state = In_memory_context.tree - and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t = - Sc_rollup.ArithPVM.Make (In_memory_context) - - module Wasm_pvm : - Sc_rollup.PVM.S - with type context = In_memory_context.Tree.t - and type state = In_memory_context.tree - and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t = - Sc_rollup.Wasm_2_0_0PVM.Make - (Environment.Wasm_2_0_0.Make) - (In_memory_context) - - (* 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 origination_proof_exn ~boot_sector kind = - let aux = function - | Sc_rollup.Kind.Example_arith -> - let open Lwt_result_syntax in - let context = make_empty_context () in - let* proof = - Arith_pvm.produce_origination_proof context boot_sector - in - let*? proof = - Sc_rollup.Proof.serialize_pvm_step ~pvm:(module Wasm_pvm) proof - in - return proof - | Sc_rollup.Kind.Wasm_2_0_0 -> - let open Lwt_result_syntax in - let context = make_empty_context () in - let* proof = Wasm_pvm.produce_origination_proof context boot_sector in - let*? proof = - Sc_rollup.Proof.serialize_pvm_step ~pvm:(module Wasm_pvm) proof - in - return proof - in - let open Lwt_syntax in - let* res = aux kind in - match res with - | Ok res -> Lwt.return res - | Error _ -> - raise - (Invalid_argument - "origination_proof_exn: could not produce an origination proof") -end - module EpoxyEntity = struct include Zk_rollup.Address diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_rollups.mli b/src/proto_016_PtMumbai/lib_client/client_proto_rollups.mli index e8b6662506110fcef95e7aa529310de2de2247a2..2ffa8bcf787ccb56d86346183235f30428a423b0 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_rollups.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_rollups.mli @@ -30,9 +30,4 @@ type rollup_entity = {rollup : Tx_rollup.t; origination_level : int32 option} module TxRollupAlias : Client_aliases.Alias with type t = rollup_entity -module ScRollup : sig - val origination_proof_exn : - boot_sector:string -> Sc_rollup.Kind.t -> Sc_rollup.Proof.serialized Lwt.t -end - module EpoxyAlias : Client_aliases.Alias with type t = Zk_rollup.t diff --git a/src/proto_016_PtMumbai/lib_client/dune b/src/proto_016_PtMumbai/lib_client/dune index 3148dc22d912d9620a061875199280aeb14ea6fd..2afbaa862608ff043032e86cd58db52b8c1e9d8d 100644 --- a/src/proto_016_PtMumbai/lib_client/dune +++ b/src/proto_016_PtMumbai/lib_client/dune @@ -17,6 +17,7 @@ tezos-protocol-plugin-016-PtMumbai tezos-protocol-016-PtMumbai.parameters tezos-rpc + tezos-smart-rollup-016-PtMumbai uri) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) @@ -29,4 +30,5 @@ -open Tezos_client_base -open Tezos_protocol_016_PtMumbai -open Tezos_protocol_plugin_016_PtMumbai - -open Tezos_protocol_016_PtMumbai_parameters)) + -open Tezos_protocol_016_PtMumbai_parameters + -open Tezos_smart_rollup_016_PtMumbai)) diff --git a/src/proto_016_PtMumbai/lib_plugin/RPC.ml b/src/proto_016_PtMumbai/lib_plugin/RPC.ml index ad6a38ae12b3745b80f295fda20b1d02f1939d3d..722c001df1f0b75e4807137bafb7176e45b86110 100644 --- a/src/proto_016_PtMumbai/lib_plugin/RPC.ml +++ b/src/proto_016_PtMumbai/lib_plugin/RPC.ml @@ -2158,6 +2158,17 @@ module Sc_rollup = struct path_sc_rollup / "commitment" /: Sc_rollup.Commitment.Hash.rpc_arg / "can_be_cemented") + let origination_proof = + RPC_service.post_service + ~description:"Proof for a smart rollup origination" + ~query:RPC_query.empty + ~input: + (obj2 + (req "kind" Sc_rollup.Kind.encoding) + (req "kernel" (string Hex))) + ~output:Sc_rollup.Proof.serialized_encoding + RPC_path.(path_sc_rollups / "origination_proof") + let root = RPC_service.get_service ~description:"List of all originated smart rollups" @@ -2180,6 +2191,13 @@ module Sc_rollup = struct Registration.register0 ~chunked:true S.inbox (fun ctxt () () -> Sc_rollup.Inbox.get_inbox ctxt >>=? fun (inbox, _ctxt) -> return inbox) + let register_origination_proof () = + Registration.register0 + ~chunked:true + S.origination_proof + (fun _ctxt () (kind, boot_sector) -> + Proof_helpers.origination_proof ~boot_sector kind) + let register_kind () = Registration.opt_register1 ~chunked:true S.kind @@ fun ctxt address () () -> Alpha_context.Sc_rollup.kind ctxt address >|=? fun (_ctxt, kind) -> @@ -2355,6 +2373,7 @@ module Sc_rollup = struct let register () = register_kind () ; register_inbox () ; + register_origination_proof () ; register_genesis_info () ; register_last_cemented_commitment_hash_with_level () ; register_staked_on_commitment () ; @@ -2375,6 +2394,9 @@ module Sc_rollup = struct let inbox ctxt block = RPC_context.make_call0 S.inbox ctxt block () () + let origination_proof ctxt block kind boot_sector = + RPC_context.make_call0 S.origination_proof ctxt block () (kind, boot_sector) + let genesis_info ctxt block sc_rollup_address = RPC_context.make_call1 S.genesis_info ctxt block sc_rollup_address () () diff --git a/src/proto_016_PtMumbai/lib_plugin/dune b/src/proto_016_PtMumbai/lib_plugin/dune index 74187995cbc15f29041fad849203f73246c5f363..4b63789b72b73579e16bd4d06c17a323ca19437e 100644 --- a/src/proto_016_PtMumbai/lib_plugin/dune +++ b/src/proto_016_PtMumbai/lib_plugin/dune @@ -7,12 +7,14 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-016-PtMumbai) + tezos-protocol-016-PtMumbai + tezos-smart-rollup-016-PtMumbai) (flags (:standard) -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals - -open Tezos_protocol_016_PtMumbai) + -open Tezos_protocol_016_PtMumbai + -open Tezos_smart_rollup_016_PtMumbai) (modules (:standard \ Plugin_registerer))) (library diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/README.md b/src/proto_016_PtMumbai/lib_sc_rollup/README.md new file mode 100644 index 0000000000000000000000000000000000000000..47d56492957751de7c38aaf98e8deb13837c5d0b --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/README.md @@ -0,0 +1,8 @@ +# lib smart rollup =lib_sc_rollup= + +This is a place designed as wrapper of the protocol specifically for +the smart rollup type. It may include helpers for all smart rollup +feature. + +This includes so far in memory context, PVM instance, refutation game +and proof helpers. diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml new file mode 100644 index 0000000000000000000000000000000000000000..122bb2ca52fdb9dcaca05d49ff7276bb4c20d28c --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml @@ -0,0 +1,90 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +module In_memory = struct + open Tezos_context_memory + + module Tree = struct + include Context_binary.Tree + + type tree = Context_binary.tree + + type t = Context_binary.t + + type key = string list + + type value = bytes + end + + type tree = Tree.tree + + type proof = Context.Proof.tree Context.Proof.t + + let hash_tree _ = assert false + + let verify_proof p f = + Lwt.map Result.to_option (Context_binary.verify_tree_proof p f) + + let produce_proof context state step = + let open Lwt_syntax in + let* context = Context_binary.add_tree context [] state in + let* h = Context_binary.commit ~time:Time.Protocol.epoch context in + let index = Context_binary.index context in + let* context = Context_binary.checkout_exn index h in + match Tree.kinded_key state with + | Some k -> + let index = Context_binary.index context in + let* p = Context_binary.produce_tree_proof index k step in + return (Some p) + | None -> return None + + let kinded_hash_to_state_hash = function + | `Value hash | `Node hash -> + 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_after proof = kinded_hash_to_state_hash proof.Context.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 +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 new file mode 100644 index 0000000000000000000000000000000000000000..35ba7e64cf5a87a71b700a24c56b3ab441b1be3d --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli @@ -0,0 +1,38 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** [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} *) +module In_memory : sig + include + Protocol.Alpha_context.Sc_rollup.ArithPVM.P + with type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + + val make_empty_context : ?root:string -> unit -> Tree.t +end diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/dune b/src/proto_016_PtMumbai/lib_sc_rollup/dune index 4903349cc762a9d13c0c069d36d4a8bcdcd26ce9..4de3285663a97a0d1854c862331d3540f4319182 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup/dune @@ -7,18 +7,11 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-016-PtMumbai - tezos-protocol-plugin-016-PtMumbai - tezos-protocol-016-PtMumbai.parameters - tezos-rpc - octez-injector) + tezos-protocol-016-PtMumbai) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) (library_flags (:standard -linkall)) (flags (:standard) -open Tezos_base.TzPervasives - -open Tezos_protocol_016_PtMumbai - -open Tezos_protocol_plugin_016_PtMumbai - -open Tezos_protocol_016_PtMumbai_parameters - -open Octez_injector)) + -open Tezos_protocol_016_PtMumbai)) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.ml b/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.ml new file mode 100644 index 0000000000000000000000000000000000000000..d1fee7a23c13acee2577287c16f0ad26e959b66f --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.ml @@ -0,0 +1,55 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +let origination_proof ~boot_sector kind = + let aux = function + | Sc_rollup.Kind.Example_arith -> + let open Lwt_result_syntax in + let context = Context_helpers.In_memory.make_empty_context () in + let* proof = + Pvm.Arith_pvm_in_memory.produce_origination_proof context boot_sector + in + let*? proof = + Sc_rollup.Proof.serialize_pvm_step + ~pvm:(module Pvm.Arith_pvm_in_memory) + proof + in + return proof + | Sc_rollup.Kind.Wasm_2_0_0 -> + let open Lwt_result_syntax in + let context = Context_helpers.In_memory.make_empty_context () in + let* proof = + Pvm.Wasm_pvm_in_memory.produce_origination_proof context boot_sector + in + let*? proof = + Sc_rollup.Proof.serialize_pvm_step + ~pvm:(module Pvm.Wasm_pvm_in_memory) + proof + in + return proof + in + aux kind diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.mli b/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.mli new file mode 100644 index 0000000000000000000000000000000000000000..43f55342f92e8f7ae8c08f47c109867646a7889c --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.mli @@ -0,0 +1,34 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +(** [origination_proof ~boot_sector kind] instantiate a [kind] PVM + with an in memory context and produce the origination_proof for + [boot_sector] *) +val origination_proof : + boot_sector:string -> + Sc_rollup.Kind.t -> + Sc_rollup.Proof.serialized Environment.Error_monad.tzresult Lwt.t diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/pvm.ml b/src/proto_016_PtMumbai/lib_sc_rollup/pvm.ml new file mode 100644 index 0000000000000000000000000000000000000000..b785f14ce41d5fa66cd27f0441f8b4f11be3bf5d --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/pvm.ml @@ -0,0 +1,46 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +module Arith_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t = + Sc_rollup.ArithPVM.Make (Context_helpers.In_memory) + +module Wasm_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t = + Sc_rollup.Wasm_2_0_0PVM.Make + (Environment.Wasm_2_0_0.Make) + (Context_helpers.In_memory) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/pvm.mli b/src/proto_016_PtMumbai/lib_sc_rollup/pvm.mli new file mode 100644 index 0000000000000000000000000000000000000000..8dea749c591a06f2d1b3d0d417b30591fdf0b85c --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup/pvm.mli @@ -0,0 +1,46 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +(** [Arith_pvm_in_memory]: Arith PVM with an in memory context + {!Tezos_context_memory}. *) +module Arith_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + +(** [Wasm_pvm_in_memory] Wasm PVM with an in memory context + {!Tezos_context_memory}. *) +module Wasm_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + 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_client/dune b/src/proto_016_PtMumbai/lib_sc_rollup_client/dune index 648cce5758d10748d1ee1e2acb21faa7ba6081a2..e2ccc55150799676704e59c1f96157b5eb1d6415 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_client/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup_client/dune @@ -12,7 +12,8 @@ tezos-client-base tezos-client-base-unix tezos-client-016-PtMumbai - tezos-smart-rollup-016-PtMumbai) + tezos-smart-rollup-016-PtMumbai + tezos-smart-rollup-layer2-016-PtMumbai) (flags (:standard) -open Tezos_base @@ -23,4 +24,5 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_016_PtMumbai - -open Tezos_smart_rollup_016_PtMumbai)) + -open Tezos_smart_rollup_016_PtMumbai + -open Tezos_smart_rollup_layer2_016_PtMumbai)) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/README.md b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4b77ba36979a64e3aa002fcb16d844e7eb4823ef --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/README.md @@ -0,0 +1,7 @@ +# lib smart rollup layer2 =lib_sc_rollup_layer2= + +This is a place designed for types and functions that are needed by +the rollup node and the client. + +This library allows to not have a direct dependency between the client +and the node. diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/dune b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/dune new file mode 100644 index 0000000000000000000000000000000000000000..3e1e19641b52f11bfe4cf738167ab76a80017dea --- /dev/null +++ b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/dune @@ -0,0 +1,19 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_smart_rollup_layer2_016_PtMumbai) + (public_name tezos-smart-rollup-layer2-016-PtMumbai) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezos-protocol-016-PtMumbai + octez-injector) + (inline_tests (flags -verbose) (modes native)) + (preprocess (pps ppx_expect)) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_protocol_016_PtMumbai + -open Octez_injector)) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/error.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/error.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/error.mli b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/error.mli rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.mli diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/l1_operation.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/l1_operation.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/l1_operation.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/l1_operation.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/l1_operation.mli b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/l1_operation.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/l1_operation.mli rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/l1_operation.mli diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/l2_message.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/l2_message.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/l2_message.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/l2_message.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/l2_message.mli b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/l2_message.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/l2_message.mli rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/l2_message.mli diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_block.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_block.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_block.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_block.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_block.mli b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_block.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_block.mli rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_block.mli diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_context_hash.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_context_hash.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_context_hash.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_context_hash.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_context_hash.mli b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_context_hash.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_context_hash.mli rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_context_hash.mli diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_services.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_services.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup/sc_rollup_services.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_services.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/dune b/src/proto_016_PtMumbai/lib_sc_rollup_node/dune index 39af641458821d907eed871ff4fcdfea676ed272..6377f8f580514660593d7e365827dd860005e168 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/dune @@ -24,6 +24,7 @@ tezos_dal_node_lib tezos-shell-services tezos-smart-rollup-016-PtMumbai + tezos-smart-rollup-layer2-016-PtMumbai tezos-layer2-utils-016-PtMumbai tezos_layer2_store tezos-tree-encoding @@ -55,6 +56,7 @@ -open Tezos_dal_node_lib -open Tezos_shell_services -open Tezos_smart_rollup_016_PtMumbai + -open Tezos_smart_rollup_layer2_016_PtMumbai -open Tezos_layer2_utils_016_PtMumbai -open Tezos_layer2_store -open Octez_injector diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index ea7acee0935b5b406aa700b2af8ab3b8be781a5a..7c5d8a55d2b31004ef6bc980c6f9fdba7745a885 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -996,8 +996,9 @@ let transfer_ticket (cctxt : #full) ~chain ~block ?confirmations ?dry_run let sc_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?storage_limit ?counter ~source ~kind ~boot_sector ~parameters_ty ~src_pk ~src_sk ~fee_parameter () = - Client_proto_rollups.ScRollup.origination_proof_exn ~boot_sector kind - >>= fun origination_proof -> + Proof_helpers.origination_proof ~boot_sector kind + >|= Environment.wrap_tzresult + >>=? fun origination_proof -> let op = Annotated_manager_operation.Single_manager (Injection.prepare_manager_operation diff --git a/src/proto_alpha/lib_client/client_proto_rollups.ml b/src/proto_alpha/lib_client/client_proto_rollups.ml index 60d267dacc76b99f897da5059af86b47ec6dd4b0..90a8aa125e9c78f3e73d063dae75085164a7080d 100644 --- a/src/proto_alpha/lib_client/client_proto_rollups.ml +++ b/src/proto_alpha/lib_client/client_proto_rollups.ml @@ -28,124 +28,6 @@ open Alpha_context type rollup_entity = {rollup : Tx_rollup.t; origination_level : int32 option} -module ScRollup = struct - module In_memory_context = struct - open Tezos_context_memory - - module Tree = struct - include Context_binary.Tree - - type tree = Context_binary.tree - - type t = Context_binary.t - - type key = string list - - type value = bytes - end - - type tree = Tree.tree - - type proof = Context.Proof.tree Context.Proof.t - - let hash_tree _ = assert false - - let verify_proof p f = - Lwt.map Result.to_option (Context_binary.verify_tree_proof p f) - - let produce_proof context state step = - let open Lwt_syntax in - let* context = Context_binary.add_tree context [] state in - let* h = Context_binary.commit ~time:Time.Protocol.epoch context in - let index = Context_binary.index context in - let* context = Context_binary.checkout_exn index h in - match Tree.kinded_key state with - | Some k -> - let index = Context_binary.index context in - let* p = Context_binary.produce_tree_proof index k step in - return (Some p) - | None -> return None - - let kinded_hash_to_state_hash = function - | `Value hash | `Node hash -> - 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_after proof = kinded_hash_to_state_hash proof.Context.Proof.after - - let proof_encoding = - Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 - .tree_proof_encoding - end - - module Arith_pvm : - Sc_rollup.PVM.S - with type context = In_memory_context.Tree.t - and type state = In_memory_context.tree - and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t = - Sc_rollup.ArithPVM.Make (In_memory_context) - - module Wasm_pvm : - Sc_rollup.PVM.S - with type context = In_memory_context.Tree.t - and type state = In_memory_context.tree - and type proof = - Tezos_context_memory.Context.Proof.tree - Tezos_context_memory.Context.Proof.t = - Sc_rollup.Wasm_2_0_0PVM.Make - (Environment.Wasm_2_0_0.Make) - (In_memory_context) - - (* 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 origination_proof_exn ~boot_sector kind = - let aux = function - | Sc_rollup.Kind.Example_arith -> - let open Lwt_result_syntax in - let context = make_empty_context () in - let* proof = - Arith_pvm.produce_origination_proof context boot_sector - in - let*? proof = - Sc_rollup.Proof.serialize_pvm_step ~pvm:(module Wasm_pvm) proof - in - return proof - | Sc_rollup.Kind.Wasm_2_0_0 -> - let open Lwt_result_syntax in - let context = make_empty_context () in - let* proof = Wasm_pvm.produce_origination_proof context boot_sector in - let*? proof = - Sc_rollup.Proof.serialize_pvm_step ~pvm:(module Wasm_pvm) proof - in - return proof - in - let open Lwt_syntax in - let* res = aux kind in - match res with - | Ok res -> Lwt.return res - | Error _ -> - raise - (Invalid_argument - "origination_proof_exn: could not produce an origination proof") -end - module EpoxyEntity = struct include Zk_rollup.Address diff --git a/src/proto_alpha/lib_client/client_proto_rollups.mli b/src/proto_alpha/lib_client/client_proto_rollups.mli index 47a2165f276c4d0a118107398dcc0a35b2c54f58..da08ce2a42dc94949352d801b41d7bb828b500a7 100644 --- a/src/proto_alpha/lib_client/client_proto_rollups.mli +++ b/src/proto_alpha/lib_client/client_proto_rollups.mli @@ -28,9 +28,4 @@ open Alpha_context type rollup_entity = {rollup : Tx_rollup.t; origination_level : int32 option} -module ScRollup : sig - val origination_proof_exn : - boot_sector:string -> Sc_rollup.Kind.t -> Sc_rollup.Proof.serialized Lwt.t -end - module EpoxyAlias : Client_aliases.Alias with type t = Zk_rollup.t diff --git a/src/proto_alpha/lib_client/dune b/src/proto_alpha/lib_client/dune index 438d559c06b4d67727644cf8f39869e4afc3cc1b..3668f2e00086ac0c384662eb21ba6a3b9f402a6f 100644 --- a/src/proto_alpha/lib_client/dune +++ b/src/proto_alpha/lib_client/dune @@ -17,6 +17,7 @@ tezos-protocol-plugin-alpha tezos-protocol-alpha.parameters tezos-rpc + tezos-smart-rollup-alpha uri) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) @@ -29,4 +30,5 @@ -open Tezos_client_base -open Tezos_protocol_alpha -open Tezos_protocol_plugin_alpha - -open Tezos_protocol_alpha_parameters)) + -open Tezos_protocol_alpha_parameters + -open Tezos_smart_rollup_alpha)) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index f6adfc617609982beb9427ab10bd4d37d5fac4c6..cd6422db60747757a7104943f223aa1fdc92796b 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -2157,6 +2157,17 @@ module Sc_rollup = struct path_sc_rollup / "commitment" /: Sc_rollup.Commitment.Hash.rpc_arg / "can_be_cemented") + let origination_proof = + RPC_service.post_service + ~description:"Proof for a smart rollup origination" + ~query:RPC_query.empty + ~input: + (obj2 + (req "kind" Sc_rollup.Kind.encoding) + (req "kernel" (string Hex))) + ~output:Sc_rollup.Proof.serialized_encoding + RPC_path.(path_sc_rollups / "origination_proof") + let root = RPC_service.get_service ~description:"List of all originated smart rollups" @@ -2179,6 +2190,13 @@ module Sc_rollup = struct Registration.register0 ~chunked:true S.inbox (fun ctxt () () -> Sc_rollup.Inbox.get_inbox ctxt >>=? fun (inbox, _ctxt) -> return inbox) + let register_origination_proof () = + Registration.register0 + ~chunked:true + S.origination_proof + (fun _ctxt () (kind, boot_sector) -> + Proof_helpers.origination_proof ~boot_sector kind) + let register_kind () = Registration.opt_register1 ~chunked:true S.kind @@ fun ctxt address () () -> Alpha_context.Sc_rollup.kind ctxt address >|=? fun (_ctxt, kind) -> @@ -2354,6 +2372,7 @@ module Sc_rollup = struct let register () = register_kind () ; register_inbox () ; + register_origination_proof () ; register_genesis_info () ; register_last_cemented_commitment_hash_with_level () ; register_staked_on_commitment () ; @@ -2374,6 +2393,9 @@ module Sc_rollup = struct let inbox ctxt block = RPC_context.make_call0 S.inbox ctxt block () () + let origination_proof ctxt block kind boot_sector = + RPC_context.make_call0 S.origination_proof ctxt block () (kind, boot_sector) + let genesis_info ctxt block sc_rollup_address = RPC_context.make_call1 S.genesis_info ctxt block sc_rollup_address () () diff --git a/src/proto_alpha/lib_plugin/dune b/src/proto_alpha/lib_plugin/dune index 148f8d0e9c9c47d0402edcf358759a4d636eefe5..d68db6e047471cf25517c61fe7b66cd7f03587a3 100644 --- a/src/proto_alpha/lib_plugin/dune +++ b/src/proto_alpha/lib_plugin/dune @@ -7,12 +7,14 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-alpha) + tezos-protocol-alpha + tezos-smart-rollup-alpha) (flags (:standard) -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals - -open Tezos_protocol_alpha) + -open Tezos_protocol_alpha + -open Tezos_smart_rollup_alpha) (modules (:standard \ Plugin_registerer))) (library diff --git a/src/proto_alpha/lib_sc_rollup/README.md b/src/proto_alpha/lib_sc_rollup/README.md new file mode 100644 index 0000000000000000000000000000000000000000..47d56492957751de7c38aaf98e8deb13837c5d0b --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/README.md @@ -0,0 +1,8 @@ +# lib smart rollup =lib_sc_rollup= + +This is a place designed as wrapper of the protocol specifically for +the smart rollup type. It may include helpers for all smart rollup +feature. + +This includes so far in memory context, PVM instance, refutation game +and proof helpers. diff --git a/src/proto_alpha/lib_sc_rollup/context_helpers.ml b/src/proto_alpha/lib_sc_rollup/context_helpers.ml new file mode 100644 index 0000000000000000000000000000000000000000..122bb2ca52fdb9dcaca05d49ff7276bb4c20d28c --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/context_helpers.ml @@ -0,0 +1,90 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +module In_memory = struct + open Tezos_context_memory + + module Tree = struct + include Context_binary.Tree + + type tree = Context_binary.tree + + type t = Context_binary.t + + type key = string list + + type value = bytes + end + + type tree = Tree.tree + + type proof = Context.Proof.tree Context.Proof.t + + let hash_tree _ = assert false + + let verify_proof p f = + Lwt.map Result.to_option (Context_binary.verify_tree_proof p f) + + let produce_proof context state step = + let open Lwt_syntax in + let* context = Context_binary.add_tree context [] state in + let* h = Context_binary.commit ~time:Time.Protocol.epoch context in + let index = Context_binary.index context in + let* context = Context_binary.checkout_exn index h in + match Tree.kinded_key state with + | Some k -> + let index = Context_binary.index context in + let* p = Context_binary.produce_tree_proof index k step in + return (Some p) + | None -> return None + + let kinded_hash_to_state_hash = function + | `Value hash | `Node hash -> + 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_after proof = kinded_hash_to_state_hash proof.Context.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 +end diff --git a/src/proto_alpha/lib_sc_rollup/context_helpers.mli b/src/proto_alpha/lib_sc_rollup/context_helpers.mli new file mode 100644 index 0000000000000000000000000000000000000000..35ba7e64cf5a87a71b700a24c56b3ab441b1be3d --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/context_helpers.mli @@ -0,0 +1,38 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** [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} *) +module In_memory : sig + include + Protocol.Alpha_context.Sc_rollup.ArithPVM.P + with type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + + val make_empty_context : ?root:string -> unit -> Tree.t +end diff --git a/src/proto_alpha/lib_sc_rollup/dune b/src/proto_alpha/lib_sc_rollup/dune index 99132fbc73a3ec8534405f228c324d23a2760bd8..e725e6fe51502e79da4530c9f07268c6b282bcd1 100644 --- a/src/proto_alpha/lib_sc_rollup/dune +++ b/src/proto_alpha/lib_sc_rollup/dune @@ -7,18 +7,11 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-alpha - tezos-protocol-plugin-alpha - tezos-protocol-alpha.parameters - tezos-rpc - octez-injector) + tezos-protocol-alpha) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) (library_flags (:standard -linkall)) (flags (:standard) -open Tezos_base.TzPervasives - -open Tezos_protocol_alpha - -open Tezos_protocol_plugin_alpha - -open Tezos_protocol_alpha_parameters - -open Octez_injector)) + -open Tezos_protocol_alpha)) diff --git a/src/proto_alpha/lib_sc_rollup/proof_helpers.ml b/src/proto_alpha/lib_sc_rollup/proof_helpers.ml new file mode 100644 index 0000000000000000000000000000000000000000..d1fee7a23c13acee2577287c16f0ad26e959b66f --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/proof_helpers.ml @@ -0,0 +1,55 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +let origination_proof ~boot_sector kind = + let aux = function + | Sc_rollup.Kind.Example_arith -> + let open Lwt_result_syntax in + let context = Context_helpers.In_memory.make_empty_context () in + let* proof = + Pvm.Arith_pvm_in_memory.produce_origination_proof context boot_sector + in + let*? proof = + Sc_rollup.Proof.serialize_pvm_step + ~pvm:(module Pvm.Arith_pvm_in_memory) + proof + in + return proof + | Sc_rollup.Kind.Wasm_2_0_0 -> + let open Lwt_result_syntax in + let context = Context_helpers.In_memory.make_empty_context () in + let* proof = + Pvm.Wasm_pvm_in_memory.produce_origination_proof context boot_sector + in + let*? proof = + Sc_rollup.Proof.serialize_pvm_step + ~pvm:(module Pvm.Wasm_pvm_in_memory) + proof + in + return proof + in + aux kind diff --git a/src/proto_alpha/lib_sc_rollup/proof_helpers.mli b/src/proto_alpha/lib_sc_rollup/proof_helpers.mli new file mode 100644 index 0000000000000000000000000000000000000000..43f55342f92e8f7ae8c08f47c109867646a7889c --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/proof_helpers.mli @@ -0,0 +1,34 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +(** [origination_proof ~boot_sector kind] instantiate a [kind] PVM + with an in memory context and produce the origination_proof for + [boot_sector] *) +val origination_proof : + boot_sector:string -> + Sc_rollup.Kind.t -> + Sc_rollup.Proof.serialized Environment.Error_monad.tzresult Lwt.t diff --git a/src/proto_alpha/lib_sc_rollup/pvm.ml b/src/proto_alpha/lib_sc_rollup/pvm.ml new file mode 100644 index 0000000000000000000000000000000000000000..b785f14ce41d5fa66cd27f0441f8b4f11be3bf5d --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/pvm.ml @@ -0,0 +1,46 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +module Arith_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t = + Sc_rollup.ArithPVM.Make (Context_helpers.In_memory) + +module Wasm_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t = + Sc_rollup.Wasm_2_0_0PVM.Make + (Environment.Wasm_2_0_0.Make) + (Context_helpers.In_memory) diff --git a/src/proto_alpha/lib_sc_rollup/pvm.mli b/src/proto_alpha/lib_sc_rollup/pvm.mli new file mode 100644 index 0000000000000000000000000000000000000000..8dea749c591a06f2d1b3d0d417b30591fdf0b85c --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup/pvm.mli @@ -0,0 +1,46 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol.Alpha_context + +(** [Arith_pvm_in_memory]: Arith PVM with an in memory context + {!Tezos_context_memory}. *) +module Arith_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + +(** [Wasm_pvm_in_memory] Wasm PVM with an in memory context + {!Tezos_context_memory}. *) +module Wasm_pvm_in_memory : + Sc_rollup.PVM.S + with type context = Context_helpers.In_memory.Tree.t + and type state = Context_helpers.In_memory.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t diff --git a/src/proto_alpha/lib_sc_rollup_client/dune b/src/proto_alpha/lib_sc_rollup_client/dune index 0a201e58a5bcda066d6f1afb04e756a578fcc11f..c04fc5e10fcf1a849d384e94a73441725f9cdbe7 100644 --- a/src/proto_alpha/lib_sc_rollup_client/dune +++ b/src/proto_alpha/lib_sc_rollup_client/dune @@ -12,7 +12,8 @@ tezos-client-base tezos-client-base-unix tezos-client-alpha - tezos-smart-rollup-alpha) + tezos-smart-rollup-alpha + tezos-smart-rollup-layer2-alpha) (flags (:standard) -open Tezos_base @@ -23,4 +24,5 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_alpha - -open Tezos_smart_rollup_alpha)) + -open Tezos_smart_rollup_alpha + -open Tezos_smart_rollup_layer2_alpha)) diff --git a/src/proto_alpha/lib_sc_rollup_layer2/README.md b/src/proto_alpha/lib_sc_rollup_layer2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4b77ba36979a64e3aa002fcb16d844e7eb4823ef --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup_layer2/README.md @@ -0,0 +1,7 @@ +# lib smart rollup layer2 =lib_sc_rollup_layer2= + +This is a place designed for types and functions that are needed by +the rollup node and the client. + +This library allows to not have a direct dependency between the client +and the node. diff --git a/src/proto_alpha/lib_sc_rollup_layer2/dune b/src/proto_alpha/lib_sc_rollup_layer2/dune new file mode 100644 index 0000000000000000000000000000000000000000..ced3408b31b9eabdfc16fffbda55bb24b360cf4a --- /dev/null +++ b/src/proto_alpha/lib_sc_rollup_layer2/dune @@ -0,0 +1,19 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_smart_rollup_layer2_alpha) + (public_name tezos-smart-rollup-layer2-alpha) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezos-protocol-alpha + octez-injector) + (inline_tests (flags -verbose) (modes native)) + (preprocess (pps ppx_expect)) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_protocol_alpha + -open Octez_injector)) diff --git a/src/proto_alpha/lib_sc_rollup/error.ml b/src/proto_alpha/lib_sc_rollup_layer2/error.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/error.ml rename to src/proto_alpha/lib_sc_rollup_layer2/error.ml diff --git a/src/proto_alpha/lib_sc_rollup/error.mli b/src/proto_alpha/lib_sc_rollup_layer2/error.mli similarity index 100% rename from src/proto_alpha/lib_sc_rollup/error.mli rename to src/proto_alpha/lib_sc_rollup_layer2/error.mli diff --git a/src/proto_alpha/lib_sc_rollup/l1_operation.ml b/src/proto_alpha/lib_sc_rollup_layer2/l1_operation.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/l1_operation.ml rename to src/proto_alpha/lib_sc_rollup_layer2/l1_operation.ml diff --git a/src/proto_alpha/lib_sc_rollup/l1_operation.mli b/src/proto_alpha/lib_sc_rollup_layer2/l1_operation.mli similarity index 100% rename from src/proto_alpha/lib_sc_rollup/l1_operation.mli rename to src/proto_alpha/lib_sc_rollup_layer2/l1_operation.mli diff --git a/src/proto_alpha/lib_sc_rollup/l2_message.ml b/src/proto_alpha/lib_sc_rollup_layer2/l2_message.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/l2_message.ml rename to src/proto_alpha/lib_sc_rollup_layer2/l2_message.ml diff --git a/src/proto_alpha/lib_sc_rollup/l2_message.mli b/src/proto_alpha/lib_sc_rollup_layer2/l2_message.mli similarity index 100% rename from src/proto_alpha/lib_sc_rollup/l2_message.mli rename to src/proto_alpha/lib_sc_rollup_layer2/l2_message.mli diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_block.ml b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_block.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/sc_rollup_block.ml rename to src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_block.ml diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_block.mli b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_block.mli similarity index 100% rename from src/proto_alpha/lib_sc_rollup/sc_rollup_block.mli rename to src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_block.mli diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_context_hash.ml b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_context_hash.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/sc_rollup_context_hash.ml rename to src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_context_hash.ml diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_context_hash.mli b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_context_hash.mli similarity index 100% rename from src/proto_alpha/lib_sc_rollup/sc_rollup_context_hash.mli rename to src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_context_hash.mli diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_services.ml similarity index 100% rename from src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml rename to src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_services.ml diff --git a/src/proto_alpha/lib_sc_rollup_node/dune b/src/proto_alpha/lib_sc_rollup_node/dune index a4aed89c1e3c991bb0bad849e9e186f8c231a6d5..bbb1f5a0e6b80d023a464f9c1dff6cddd1d7fdeb 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dune +++ b/src/proto_alpha/lib_sc_rollup_node/dune @@ -24,6 +24,7 @@ tezos_dal_node_lib tezos-shell-services tezos-smart-rollup-alpha + tezos-smart-rollup-layer2-alpha tezos-layer2-utils-alpha tezos_layer2_store tezos-tree-encoding @@ -55,6 +56,7 @@ -open Tezos_dal_node_lib -open Tezos_shell_services -open Tezos_smart_rollup_alpha + -open Tezos_smart_rollup_layer2_alpha -open Tezos_layer2_utils_alpha -open Tezos_layer2_store -open Octez_injector diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 034089d8b1759276ce90753104db223d15591f76..0aedd341e663f791210d61339dd625808681c9b2 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -844,6 +844,26 @@ let get_chain_block_context_smart_rollups_all_inbox ?(chain = "main") ] Fun.id +let post_chain_block_context_smart_rollups_all_origination_proof + ?(chain = "main") ?(block = "head") ~kind ~boot_sector () = + let data : RPC_core.data = + Data (`O [("kind", `String kind); ("kernel", `String boot_sector)]) + in + make + ~data + POST + [ + "chains"; + chain; + "blocks"; + block; + "context"; + "smart_rollups"; + "all"; + "origination_proof"; + ] + Fun.id + let get_chain_block_context_smart_rollups_smart_rollup_genesis_info ?(chain = "main") ?(block = "head") sc_rollup = make diff --git a/tezt/lib_tezos/RPC.mli b/tezt/lib_tezos/RPC.mli index 2919f8d42c02401fc8dbe1aa2259da6ee0ecbe42..8dca5ce56d071f4918c45fdd2b3b348394b96ef9 100644 --- a/tezt/lib_tezos/RPC.mli +++ b/tezt/lib_tezos/RPC.mli @@ -792,6 +792,15 @@ val get_chain_block_context_smart_rollups_smart_rollup_staker_games : val get_chain_block_context_smart_rollups_all_inbox : ?chain:string -> ?block:string -> unit -> JSON.t t +(** RPC: [POST chains//blocks//context/smart_rollups/all/origination_proof] *) +val post_chain_block_context_smart_rollups_all_origination_proof : + ?chain:string -> + ?block:string -> + kind:string -> + boot_sector:string -> + unit -> + JSON.t t + (** RPC: [GET chains//blocks//context/smart_rollups/smart_rollup//genesis_info] *) val get_chain_block_context_smart_rollups_smart_rollup_genesis_info : ?chain:string -> ?block:string -> string -> JSON.t t diff --git a/tezt/lib_tezos/sc_rollup_helpers.ml b/tezt/lib_tezos/sc_rollup_helpers.ml index 5f85d34bc5d3499a9812c413d8d80597db7bf1c6..bdf0455e55b56a972cb758732a15d351b60ace23 100644 --- a/tezt/lib_tezos/sc_rollup_helpers.ml +++ b/tezt/lib_tezos/sc_rollup_helpers.ml @@ -92,9 +92,8 @@ let prepare_installer_kernel in return installer -(** [boot_sector_of k] returns a valid boot sector for a PVM of - kind [kind]. *) -let boot_sector_of = function +let default_boot_sector_of ~kind = + match kind with | "arith" -> "" | "wasm_2_0_0" -> Constant.wasm_echo_kernel_boot_sector | kind -> raise (Invalid_argument kind) @@ -122,7 +121,7 @@ let setup_l1 ?commitment_period ?challenge_window ?timeout protocol = originated rollup *) let originate_sc_rollup ?(hooks = hooks) ?(burn_cap = Tez.(of_int 9999999)) ?(src = Constant.bootstrap1.alias) ~kind ?(parameters_ty = "string") - ?(boot_sector = boot_sector_of kind) client = + ?(boot_sector = default_boot_sector_of ~kind) client = let* sc_rollup = Client.Sc_rollup.( originate ~hooks ~burn_cap ~src ~kind ~parameters_ty ~boot_sector client) diff --git a/tezt/lib_tezos/sc_rollup_helpers.mli b/tezt/lib_tezos/sc_rollup_helpers.mli index 331d2e914f89d2f15d1aef77d5f5772c9edbeccf..9bd271f84ae4b045e291b2288958d617308604c5 100644 --- a/tezt/lib_tezos/sc_rollup_helpers.mli +++ b/tezt/lib_tezos/sc_rollup_helpers.mli @@ -65,3 +65,7 @@ val originate_sc_rollup : ?boot_sector:string -> Client.t -> string Lwt.t + +(** [default_boot_sector_of k] returns a valid boot sector for a PVM of + kind [kind]. *) +val default_boot_sector_of : kind:string -> string diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - RPC API should work and be stable.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - RPC API should work and be stable.out index ae51f620dad67555f2fef97b1343c27db7da86b4..d4f4411e4fbab5569e737b8b58a7823f2ad9874d 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - RPC API should work and be stable.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - RPC API should work and be stable.out @@ -33,6 +33,12 @@ This sequence of operations was run: storage fees ........................... +ꜩ1.638 +./octez-client rpc post /chains/main/blocks/head/context/smart_rollups/all/origination_proof with '{ + "kind": "arith", + "kernel": "" +}' +"030002104135165622d08b0c6eac951c9d4fd65109585907bc30ef0617f6c26853c6badb10db4d3b595f59e0b53740f164bf951bcfae9e0873fd23fbce82fac4f404e18106737461747573c87a31b1c8e3af61756b336bcfc3b0c292c89b40cc8a5080ba99c45463d110ce8b" + ./octez-smart-rollup-client-alpha rpc get /global/smart_rollup_address "[SMART_ROLLUP_HASH]" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out index dc9b1dae64fde32fdd53226091e1887df47f5d6f..9b7b95693a14f75cee44388b2c6f3cfd300581da 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out @@ -33,6 +33,12 @@ This sequence of operations was run: storage fees ........................... +ꜩ1.638 +./octez-client rpc post /chains/main/blocks/head/context/smart_rollups/all/origination_proof with '{ + "kind": "wasm_2_0_0", + "kernel": "0061736d0100000001280760037f7f7f017f60027f7f017f60057f7f7f7f7f017f60017f0060017f017f60027f7f0060000002610311736d6172745f726f6c6c75705f636f72650a726561645f696e707574000011736d6172745f726f6c6c75705f636f72650c77726974655f6f7574707574000111736d6172745f726f6c6c75705f636f72650b73746f72655f77726974650002030504030405060503010001071402036d656d02000a6b65726e656c5f72756e00060aa401042a01027f41fa002f0100210120002f010021022001200247044041e4004112410041e400410010021a0b0b0800200041c4006b0b5001057f41fe002d0000210341fc002f0100210220002d0000210420002f0100210520011004210620042003460440200041016a200141016b10011a0520052002460440200041076a200610011a0b0b0b1d01017f41dc0141840241901c100021004184022000100541840210030b0b38050041e4000b122f6b65726e656c2f656e762f7265626f6f740041f8000b0200010041fa000b0200020041fc000b0200000041fe000b0101" +}' +"0300025f45ebe327976c17291e132fcf2ffb415af11d632e83bc3601e4add75c25623903fad519c60ce458d8173d60347a7165a47f94f34bb09563e3f916508a568ae5810764757261626c658108726561646f6e6c79d0464102ac30637013668aed2274607f62953bacec2e711debf922e51a89907a2b" + ./octez-smart-rollup-client-alpha rpc get /global/smart_rollup_address "[SMART_ROLLUP_HASH]" diff --git a/tezt/tests/expected/sc_rollup.ml/Mumbai- arith - RPC API should work and be stable.out b/tezt/tests/expected/sc_rollup.ml/Mumbai- arith - RPC API should work and be stable.out index 32f483b6f774e4fa5bd25b08e59866c845e85ad7..e5b4fbde1af576e132ed3d37370e325c7d69e2a2 100644 --- a/tezt/tests/expected/sc_rollup.ml/Mumbai- arith - RPC API should work and be stable.out +++ b/tezt/tests/expected/sc_rollup.ml/Mumbai- arith - RPC API should work and be stable.out @@ -33,6 +33,12 @@ This sequence of operations was run: storage fees ........................... +ꜩ1.638 +./octez-client rpc post /chains/main/blocks/head/context/smart_rollups/all/origination_proof with '{ + "kind": "arith", + "kernel": "" +}' +"030002104135165622d08b0c6eac951c9d4fd65109585907bc30ef0617f6c26853c6badb10db4d3b595f59e0b53740f164bf951bcfae9e0873fd23fbce82fac4f404e18106737461747573c87a31b1c8e3af61756b336bcfc3b0c292c89b40cc8a5080ba99c45463d110ce8b" + ./octez-smart-rollup-client-PtMumbai rpc get /global/smart_rollup_address "[SMART_ROLLUP_HASH]" diff --git a/tezt/tests/expected/sc_rollup.ml/Mumbai- wasm_2_0_0 - RPC API should work and be stable.out b/tezt/tests/expected/sc_rollup.ml/Mumbai- wasm_2_0_0 - RPC API should work and be stable.out index 91e75042fca0a7ecc2d4c1673a79a05aca062044..7fd0349713df68eb60b20e5689c7815b0f08dd8c 100644 --- a/tezt/tests/expected/sc_rollup.ml/Mumbai- wasm_2_0_0 - RPC API should work and be stable.out +++ b/tezt/tests/expected/sc_rollup.ml/Mumbai- wasm_2_0_0 - RPC API should work and be stable.out @@ -33,6 +33,12 @@ This sequence of operations was run: storage fees ........................... +ꜩ1.638 +./octez-client rpc post /chains/main/blocks/head/context/smart_rollups/all/origination_proof with '{ + "kind": "wasm_2_0_0", + "kernel": "0061736d0100000001280760037f7f7f017f60027f7f017f60057f7f7f7f7f017f60017f0060017f017f60027f7f0060000002610311736d6172745f726f6c6c75705f636f72650a726561645f696e707574000011736d6172745f726f6c6c75705f636f72650c77726974655f6f7574707574000111736d6172745f726f6c6c75705f636f72650b73746f72655f77726974650002030504030405060503010001071402036d656d02000a6b65726e656c5f72756e00060aa401042a01027f41fa002f0100210120002f010021022001200247044041e4004112410041e400410010021a0b0b0800200041c4006b0b5001057f41fe002d0000210341fc002f0100210220002d0000210420002f0100210520011004210620042003460440200041016a200141016b10011a0520052002460440200041076a200610011a0b0b0b1d01017f41dc0141840241901c100021004184022000100541840210030b0b38050041e4000b122f6b65726e656c2f656e762f7265626f6f740041f8000b0200010041fa000b0200020041fc000b0200000041fe000b0101" +}' +"0300020c4a316fa1079bfc23dac5ecc609ab10e26490e378a81e774c51176040bea180467070f4682a44b982768d522ec6380982f446488c0176ed7c13aa1d6c12a03a810764757261626c658108726561646f6e6c79d00b749948da9186d29aed2f9327b46793f18b1e6499c40f0ddbf0bf785e85e2e9" + ./octez-smart-rollup-client-PtMumbai rpc get /global/smart_rollup_address "[SMART_ROLLUP_HASH]" diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 699a912a092f960cece54d2063f5446a77ff3082..fa1c63056aee521b100cb619165c49e718386d6c 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -3735,16 +3735,25 @@ let test_outbox_message ?regression ?expected_error ~earliness ?entrypoint ~kind ~message_kind ~kind -let test_rpcs ~kind = +let test_rpcs ~kind + ?(boot_sector = Sc_rollup_helpers.default_boot_sector_of ~kind) = test_full_scenario ~regression:true ~kind + ~boot_sector { tags = ["rpc"; "api"]; variant = None; description = "RPC API should work and be stable"; } @@ fun protocol sc_rollup_node sc_client sc_rollup node client -> + let* _origination_proof = + RPC.Client.call ~hooks client + @@ RPC.post_chain_block_context_smart_rollups_all_origination_proof + ~kind + ~boot_sector + () + in let* () = Sc_rollup_node.run sc_rollup_node [] in (* Smart rollup address endpoint test *) let*! sc_rollup_address =