From 425cea85e3760c24d44c3f885b0598464f324d43 Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 09:38:15 +0100 Subject: [PATCH 1/7] manifest: remove unused dependency --- manifest/main.ml | 3 --- opam/tezos-smart-rollup-016-PtMumbai.opam | 2 -- opam/tezos-smart-rollup-alpha.opam | 2 -- src/proto_016_PtMumbai/lib_sc_rollup/dune | 5 ----- src/proto_alpha/lib_sc_rollup/dune | 5 ----- 5 files changed, 17 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index c11364da4d3d..c97ce58ebdcc 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -5087,9 +5087,6 @@ module Protocol = Protocol [ octez_base |> open_ ~m:"TzPervasives"; main |> open_; - plugin |> if_some |> open_; - parameters |> if_some |> open_; - octez_rpc; octez_injector |> open_; ] ~inline_tests:ppx_expect diff --git a/opam/tezos-smart-rollup-016-PtMumbai.opam b/opam/tezos-smart-rollup-016-PtMumbai.opam index c7623591739f..18bc6cb04412 100644 --- a/opam/tezos-smart-rollup-016-PtMumbai.opam +++ b/opam/tezos-smart-rollup-016-PtMumbai.opam @@ -13,8 +13,6 @@ depends: [ "ppx_expect" "tezos-base" "tezos-protocol-016-PtMumbai" - "tezos-protocol-plugin-016-PtMumbai" - "tezos-rpc" "octez-injector" ] build: [ diff --git a/opam/tezos-smart-rollup-alpha.opam b/opam/tezos-smart-rollup-alpha.opam index eaed2d1e93cc..5e0b7af27672 100644 --- a/opam/tezos-smart-rollup-alpha.opam +++ b/opam/tezos-smart-rollup-alpha.opam @@ -13,8 +13,6 @@ depends: [ "ppx_expect" "tezos-base" "tezos-protocol-alpha" - "tezos-protocol-plugin-alpha" - "tezos-rpc" "octez-injector" ] build: [ diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/dune b/src/proto_016_PtMumbai/lib_sc_rollup/dune index 4903349cc762..f95750fbea5b 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup/dune @@ -8,9 +8,6 @@ (libraries tezos-base tezos-protocol-016-PtMumbai - tezos-protocol-plugin-016-PtMumbai - tezos-protocol-016-PtMumbai.parameters - tezos-rpc octez-injector) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) @@ -19,6 +16,4 @@ (: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)) diff --git a/src/proto_alpha/lib_sc_rollup/dune b/src/proto_alpha/lib_sc_rollup/dune index 99132fbc73a3..2e76e4a59677 100644 --- a/src/proto_alpha/lib_sc_rollup/dune +++ b/src/proto_alpha/lib_sc_rollup/dune @@ -8,9 +8,6 @@ (libraries tezos-base tezos-protocol-alpha - tezos-protocol-plugin-alpha - tezos-protocol-alpha.parameters - tezos-rpc octez-injector) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) @@ -19,6 +16,4 @@ (:standard) -open Tezos_base.TzPervasives -open Tezos_protocol_alpha - -open Tezos_protocol_plugin_alpha - -open Tezos_protocol_alpha_parameters -open Octez_injector)) -- GitLab From 3189d3e3529596de17b8382697b235b17b48f226 Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 16:21:57 +0100 Subject: [PATCH 2/7] manifest: split lib_sc_rollup in two one is only composed of helper above the protocol where the other one is for the rollup node and client. --- .gitlab/ci/jobs/packaging/opam_package.yml | 47 +++++++++++-------- dune-project | 1 + manifest/main.ml | 20 ++++++-- opam/octez-smart-rollup-client-alpha.opam | 1 + opam/octez-smart-rollup-node-alpha.opam | 1 + opam/tezos-smart-rollup-alpha.opam | 3 +- opam/tezos-smart-rollup-layer2-alpha.opam | 23 +++++++++ src/proto_alpha/lib_sc_rollup/dune | 6 +-- src/proto_alpha/lib_sc_rollup_client/dune | 6 ++- .../lib_sc_rollup_layer2/README.md | 7 +++ src/proto_alpha/lib_sc_rollup_layer2/dune | 19 ++++++++ .../error.ml | 0 .../error.mli | 0 .../lib_sc_rollup_layer2}/l1_operation.ml | 0 .../lib_sc_rollup_layer2}/l1_operation.mli | 0 .../l2_message.ml | 0 .../l2_message.mli | 0 .../sc_rollup_block.ml | 0 .../sc_rollup_block.mli | 0 .../sc_rollup_context_hash.ml | 0 .../sc_rollup_context_hash.mli | 0 .../sc_rollup_services.ml | 0 src/proto_alpha/lib_sc_rollup_node/dune | 2 + 23 files changed, 106 insertions(+), 30 deletions(-) create mode 100644 opam/tezos-smart-rollup-layer2-alpha.opam create mode 100644 src/proto_alpha/lib_sc_rollup_layer2/README.md create mode 100644 src/proto_alpha/lib_sc_rollup_layer2/dune rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/error.ml (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/error.mli (100%) rename src/{proto_016_PtMumbai/lib_sc_rollup => proto_alpha/lib_sc_rollup_layer2}/l1_operation.ml (100%) rename src/{proto_016_PtMumbai/lib_sc_rollup => proto_alpha/lib_sc_rollup_layer2}/l1_operation.mli (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/l2_message.ml (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/l2_message.mli (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_block.ml (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_block.mli (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_context_hash.ml (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_context_hash.mli (100%) rename src/proto_alpha/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_services.ml (100%) diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index dea994b3770a..55c0c6aa8a82 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 @@ -1109,7 +1109,7 @@ opam:tezos-protocol-environment: opam:tezos-protocol-genesis: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_5 variables: package: tezos-protocol-genesis @@ -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,12 +1423,21 @@ 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-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: - .opam_template @@ -1460,7 +1469,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 +1480,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 +1503,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 @@ -1522,7 +1531,7 @@ opam:tezos-webassembly-interpreter-extra: opam:tezos-workers: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-workers diff --git a/dune-project b/dune-project index 9adfa71339e4..28fab3dc28a0 100644 --- a/dune-project +++ b/dune-project @@ -213,6 +213,7 @@ (package (name tezos-signer-services)) (package (name tezos-smart-rollup-016-PtMumbai)) (package (name tezos-smart-rollup-alpha)) +(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 c97ce58ebdcc..a2c05c6b69b5 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 @@ -5076,11 +5088,11 @@ 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: @@ -5119,6 +5131,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; @@ -5152,6 +5165,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-alpha.opam b/opam/octez-smart-rollup-client-alpha.opam index ae34ea100e43..7b4611bad750 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-alpha.opam b/opam/octez-smart-rollup-node-alpha.opam index f7e6e103f83d..cf8a0b48f0fb 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-smart-rollup-alpha.opam b/opam/tezos-smart-rollup-alpha.opam index 5e0b7af27672..46d3f7f80f1a 100644 --- a/opam/tezos-smart-rollup-alpha.opam +++ b/opam/tezos-smart-rollup-alpha.opam @@ -13,11 +13,10 @@ depends: [ "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`" +synopsis: "Tezos/Protocol: protocol specific library of helpers 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 000000000000..5e0b7af27672 --- /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_alpha/lib_sc_rollup/dune b/src/proto_alpha/lib_sc_rollup/dune index 2e76e4a59677..e725e6fe5150 100644 --- a/src/proto_alpha/lib_sc_rollup/dune +++ b/src/proto_alpha/lib_sc_rollup/dune @@ -7,13 +7,11 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-alpha - 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 Octez_injector)) + -open Tezos_protocol_alpha)) diff --git a/src/proto_alpha/lib_sc_rollup_client/dune b/src/proto_alpha/lib_sc_rollup_client/dune index 0a201e58a5bc..c04fc5e10fcf 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 000000000000..4b77ba36979a --- /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 000000000000..ced3408b31b9 --- /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_016_PtMumbai/lib_sc_rollup/l1_operation.ml b/src/proto_alpha/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_alpha/lib_sc_rollup_layer2/l1_operation.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/l1_operation.mli b/src/proto_alpha/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_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 a4aed89c1e3c..bbb1f5a0e6b8 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 -- GitLab From 483e60c748038b0e40d3fb5f62fe517a69d7a4e6 Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 16:27:28 +0100 Subject: [PATCH 3/7] client: move originitation_proof helpers to lib --- .gitlab/ci/jobs/packaging/opam_package.yml | 9 +- manifest/main.ml | 1 + opam/tezos-client-alpha.opam | 1 + .../lib_client/client_proto_context.ml | 5 +- .../lib_client/client_proto_rollups.ml | 118 ------------------ .../lib_client/client_proto_rollups.mli | 5 - src/proto_alpha/lib_client/dune | 4 +- src/proto_alpha/lib_sc_rollup/README.md | 8 ++ .../lib_sc_rollup/context_helpers.ml | 90 +++++++++++++ .../lib_sc_rollup/context_helpers.mli | 38 ++++++ .../lib_sc_rollup/proof_helpers.ml | 55 ++++++++ .../lib_sc_rollup/proof_helpers.mli | 34 +++++ src/proto_alpha/lib_sc_rollup/pvm.ml | 46 +++++++ src/proto_alpha/lib_sc_rollup/pvm.mli | 46 +++++++ 14 files changed, 332 insertions(+), 128 deletions(-) create mode 100644 src/proto_alpha/lib_sc_rollup/README.md create mode 100644 src/proto_alpha/lib_sc_rollup/context_helpers.ml create mode 100644 src/proto_alpha/lib_sc_rollup/context_helpers.mli create mode 100644 src/proto_alpha/lib_sc_rollup/proof_helpers.ml create mode 100644 src/proto_alpha/lib_sc_rollup/proof_helpers.mli create mode 100644 src/proto_alpha/lib_sc_rollup/pvm.ml create mode 100644 src/proto_alpha/lib_sc_rollup/pvm.mli diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 55c0c6aa8a82..66f4ca4546d7 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -1109,7 +1109,7 @@ opam:tezos-protocol-environment: opam:tezos-protocol-genesis: extends: - .opam_template - - .rules_template__trigger_opam_batch_5 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-protocol-genesis @@ -1427,7 +1427,12 @@ opam:tezos-smart-rollup-016-PtMumbai: 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: diff --git a/manifest/main.ml b/manifest/main.ml index a2c05c6b69b5..81575cdb8216 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4655,6 +4655,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) diff --git a/opam/tezos-client-alpha.opam b/opam/tezos-client-alpha.opam index 4f5b2cf4c232..7a773bbe0bf7 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/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index ea7acee0935b..7c5d8a55d2b3 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 60d267dacc76..90a8aa125e9c 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 47a2165f276c..da08ce2a42dc 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 438d559c06b4..3668f2e00086 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_sc_rollup/README.md b/src/proto_alpha/lib_sc_rollup/README.md new file mode 100644 index 000000000000..47d564929577 --- /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 000000000000..122bb2ca52fd --- /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 000000000000..35ba7e64cf5a --- /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/proof_helpers.ml b/src/proto_alpha/lib_sc_rollup/proof_helpers.ml new file mode 100644 index 000000000000..d1fee7a23c13 --- /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 000000000000..43f55342f92e --- /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 000000000000..b785f14ce41d --- /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 000000000000..8dea749c591a --- /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 -- GitLab From a1763a622a6a9c8fff0ca17c4dcc80faf8a6693c Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 16:37:35 +0100 Subject: [PATCH 4/7] plugin/rpc: add plugin to produce origination proof --- manifest/main.ml | 1 + opam/tezos-protocol-plugin-alpha.opam | 1 + src/proto_alpha/lib_plugin/RPC.ml | 22 ++++++++++++++++++++++ src/proto_alpha/lib_plugin/dune | 6 ++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 81575cdb8216..0e3449a2a541 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4610,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) diff --git a/opam/tezos-protocol-plugin-alpha.opam b/opam/tezos-protocol-plugin-alpha.opam index c0b87630da7a..750701e9cc2a 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/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index f6adfc617609..cd6422db6074 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 148f8d0e9c9c..d68db6e04747 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 -- GitLab From 751c004e28a2687248f02d4a32ca844bc057a08c Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 16:26:32 +0100 Subject: [PATCH 5/7] Mumbai: Backport origination_proof_RPC --- .gitlab/ci/jobs/packaging/opam_package.yml | 2 +- dune-project | 1 + opam/octez-smart-rollup-client-PtMumbai.opam | 1 + opam/octez-smart-rollup-node-PtMumbai.opam | 1 + opam/tezos-client-016-PtMumbai.opam | 1 + opam/tezos-protocol-plugin-016-PtMumbai.opam | 1 + opam/tezos-smart-rollup-016-PtMumbai.opam | 3 +- ...ezos-smart-rollup-layer2-016-PtMumbai.opam | 23 ++++ .../lib_client/client_proto_context.ml | 5 +- .../lib_client/client_proto_rollups.ml | 118 ------------------ .../lib_client/client_proto_rollups.mli | 5 - src/proto_016_PtMumbai/lib_client/dune | 4 +- src/proto_016_PtMumbai/lib_plugin/RPC.ml | 22 ++++ src/proto_016_PtMumbai/lib_plugin/dune | 6 +- .../lib_sc_rollup/README.md | 8 ++ .../lib_sc_rollup/context_helpers.ml | 90 +++++++++++++ .../lib_sc_rollup/context_helpers.mli | 38 ++++++ src/proto_016_PtMumbai/lib_sc_rollup/dune | 6 +- .../lib_sc_rollup/proof_helpers.ml | 55 ++++++++ .../lib_sc_rollup/proof_helpers.mli | 34 +++++ src/proto_016_PtMumbai/lib_sc_rollup/pvm.ml | 46 +++++++ src/proto_016_PtMumbai/lib_sc_rollup/pvm.mli | 46 +++++++ .../lib_sc_rollup_client/dune | 6 +- .../lib_sc_rollup_layer2/README.md | 7 ++ .../lib_sc_rollup_layer2/dune | 19 +++ .../error.ml | 0 .../error.mli | 0 .../lib_sc_rollup_layer2}/l1_operation.ml | 0 .../lib_sc_rollup_layer2}/l1_operation.mli | 0 .../l2_message.ml | 0 .../l2_message.mli | 0 .../sc_rollup_block.ml | 0 .../sc_rollup_block.mli | 0 .../sc_rollup_context_hash.ml | 0 .../sc_rollup_context_hash.mli | 0 .../sc_rollup_services.ml | 0 .../lib_sc_rollup_node/dune | 2 + 37 files changed, 413 insertions(+), 137 deletions(-) create mode 100644 opam/tezos-smart-rollup-layer2-016-PtMumbai.opam create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/README.md create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.ml create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/context_helpers.mli create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.ml create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/proof_helpers.mli create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/pvm.ml create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup/pvm.mli create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup_layer2/README.md create mode 100644 src/proto_016_PtMumbai/lib_sc_rollup_layer2/dune rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/error.ml (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/error.mli (100%) rename src/{proto_alpha/lib_sc_rollup => proto_016_PtMumbai/lib_sc_rollup_layer2}/l1_operation.ml (100%) rename src/{proto_alpha/lib_sc_rollup => proto_016_PtMumbai/lib_sc_rollup_layer2}/l1_operation.mli (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/l2_message.ml (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/l2_message.mli (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_block.ml (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_block.mli (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_context_hash.ml (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_context_hash.mli (100%) rename src/proto_016_PtMumbai/{lib_sc_rollup => lib_sc_rollup_layer2}/sc_rollup_services.ml (100%) diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 66f4ca4546d7..f7f00ab62324 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -1536,7 +1536,7 @@ opam:tezos-webassembly-interpreter-extra: opam:tezos-workers: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_7 variables: package: tezos-workers diff --git a/dune-project b/dune-project index 28fab3dc28a0..6baad27fb6fd 100644 --- a/dune-project +++ b/dune-project @@ -213,6 +213,7 @@ (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)) diff --git a/opam/octez-smart-rollup-client-PtMumbai.opam b/opam/octez-smart-rollup-client-PtMumbai.opam index b7cb605e0dd0..2c4a83765c9a 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-node-PtMumbai.opam b/opam/octez-smart-rollup-node-PtMumbai.opam index 563c6e1fe2d7..598e7461c46d 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/tezos-client-016-PtMumbai.opam b/opam/tezos-client-016-PtMumbai.opam index 14872bbc7de1..a38b3d232e82 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-protocol-plugin-016-PtMumbai.opam b/opam/tezos-protocol-plugin-016-PtMumbai.opam index c086b3fe6207..f7f614dad98c 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-smart-rollup-016-PtMumbai.opam b/opam/tezos-smart-rollup-016-PtMumbai.opam index 18bc6cb04412..18eb0ec2b809 100644 --- a/opam/tezos-smart-rollup-016-PtMumbai.opam +++ b/opam/tezos-smart-rollup-016-PtMumbai.opam @@ -13,11 +13,10 @@ depends: [ "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`" +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 000000000000..18bc6cb04412 --- /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/src/proto_016_PtMumbai/lib_client/client_proto_context.ml b/src/proto_016_PtMumbai/lib_client/client_proto_context.ml index 2db3f6c84b83..c881b09d6660 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 aee31002094d..dc969c5712fd 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 e8b666250611..2ffa8bcf787c 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 3148dc22d912..2afbaa862608 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 ad6a38ae12b3..722c001df1f0 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 74187995cbc1..4b63789b72b7 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 000000000000..47d564929577 --- /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 000000000000..122bb2ca52fd --- /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 000000000000..35ba7e64cf5a --- /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 f95750fbea5b..4de3285663a9 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup/dune @@ -7,13 +7,11 @@ (instrumentation (backend bisect_ppx)) (libraries tezos-base - tezos-protocol-016-PtMumbai - 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 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 000000000000..d1fee7a23c13 --- /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 000000000000..43f55342f92e --- /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 000000000000..b785f14ce41d --- /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 000000000000..8dea749c591a --- /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 648cce5758d1..e2ccc5515079 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 000000000000..4b77ba36979a --- /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 000000000000..3e1e19641b52 --- /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_alpha/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_alpha/lib_sc_rollup/l1_operation.ml rename to src/proto_016_PtMumbai/lib_sc_rollup_layer2/l1_operation.ml diff --git a/src/proto_alpha/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_alpha/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 39af64145882..6377f8f58051 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 -- GitLab From bd0348f4a22b065316544562f9238e9238f367db Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Thu, 23 Feb 2023 16:37:54 +0100 Subject: [PATCH 6/7] tezt/soru: add regression trace for origination proof --- tezt/lib_tezos/RPC.ml | 20 +++++++++++++++++++ tezt/lib_tezos/RPC.mli | 9 +++++++++ tezt/lib_tezos/sc_rollup_helpers.ml | 7 +++---- tezt/lib_tezos/sc_rollup_helpers.mli | 4 ++++ ...th - RPC API should work and be stable.out | 6 ++++++ ..._0 - RPC API should work and be stable.out | 6 ++++++ ...th - RPC API should work and be stable.out | 6 ++++++ ..._0 - RPC API should work and be stable.out | 6 ++++++ tezt/tests/sc_rollup.ml | 11 +++++++++- 9 files changed, 70 insertions(+), 5 deletions(-) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 034089d8b175..0aedd341e663 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 2919f8d42c02..8dca5ce56d07 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 5f85d34bc5d3..bdf0455e55b5 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 331d2e914f89..9bd271f84ae4 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 ae51f620dad6..d4f4411e4fba 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 dc9b1dae64fd..9b7b95693a14 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 32f483b6f774..e5b4fbde1af5 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 91e75042fca0..7fd0349713df 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 699a912a092f..fa1c63056aee 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 = -- GitLab From 81ba021b4f3a4d42c57f0148a3eea07c3a97b64e Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Wed, 1 Mar 2023 14:46:15 +0100 Subject: [PATCH 7/7] changelog: add line for new RPC --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 06ffb89f5db8..66468107d5f9 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 ------ -- GitLab