From 658fdd4e7ade754e93df2196cbf474f8b34b068f Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 14 Feb 2023 11:27:49 +0100 Subject: [PATCH] SCORU/injector: move injector library to src/ --- .gitlab/ci/jobs/packaging/opam_package.yml | 16 +- dune-project | 3 +- manifest/main.ml | 28 +- ...njector-alpha.opam => octez-injector.opam} | 7 +- opam/octez-smart-rollup-node-PtMumbai.opam | 2 +- opam/octez-smart-rollup-node-alpha.opam | 2 +- opam/tezos-injector-016-PtMumbai.opam | 30 - opam/tezos-smart-rollup-016-PtMumbai.opam | 2 +- opam/tezos-smart-rollup-alpha.opam | 2 +- .../lib_injector/disk_persistence.ml | 0 .../lib_injector/disk_persistence.mli | 0 src/{proto_alpha => }/lib_injector/dune | 18 +- .../lib_injector/injector_common.ml | 0 .../lib_injector/injector_common.mli | 0 .../lib_injector/injector_errors.ml | 0 .../lib_injector/injector_errors.mli | 0 .../lib_injector/injector_events.ml | 0 .../lib_injector/injector_functor.ml | 0 .../lib_injector/injector_functor.mli | 0 .../lib_injector/injector_operation.ml | 0 .../lib_injector/injector_operation.mli | 0 .../lib_injector/injector_sigs.ml | 0 .../lib_injector/injector_tags.ml | 0 .../lib_injector/injector_tags.mli | 0 .../lib_injector/injector_worker_types.ml | 0 .../lib_injector/injector_worker_types.mli | 0 src/proto_016_PtMumbai/lib_injector/dune | 34 - .../lib_injector/injector_common.ml | 49 - .../lib_injector/injector_common.mli | 51 - .../lib_injector/injector_errors.ml | 72 -- .../lib_injector/injector_errors.mli | 35 - .../lib_injector/injector_functor.ml | 1152 ----------------- .../lib_injector/injector_worker_types.ml | 104 -- src/proto_016_PtMumbai/lib_sc_rollup/dune | 4 +- .../lib_sc_rollup_node/dune | 4 +- .../lib_injector/disk_persistence.ml | 395 ------ .../lib_injector/disk_persistence.mli | 149 --- .../lib_injector/injector_events.ml | 266 ---- .../lib_injector/injector_functor.mli | 36 - .../lib_injector/injector_operation.ml | 68 - .../lib_injector/injector_operation.mli | 28 - src/proto_alpha/lib_injector/injector_sigs.ml | 325 ----- src/proto_alpha/lib_injector/injector_tags.ml | 39 - .../lib_injector/injector_tags.mli | 35 - .../lib_injector/injector_worker_types.mli | 45 - src/proto_alpha/lib_sc_rollup/dune | 4 +- src/proto_alpha/lib_sc_rollup_node/dune | 4 +- 47 files changed, 52 insertions(+), 2957 deletions(-) rename opam/{tezos-injector-alpha.opam => octez-injector.opam} (79%) delete mode 100644 opam/tezos-injector-016-PtMumbai.opam rename src/{proto_016_PtMumbai => }/lib_injector/disk_persistence.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/disk_persistence.mli (100%) rename src/{proto_alpha => }/lib_injector/dune (56%) rename src/{proto_alpha => }/lib_injector/injector_common.ml (100%) rename src/{proto_alpha => }/lib_injector/injector_common.mli (100%) rename src/{proto_alpha => }/lib_injector/injector_errors.ml (100%) rename src/{proto_alpha => }/lib_injector/injector_errors.mli (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_events.ml (100%) rename src/{proto_alpha => }/lib_injector/injector_functor.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_functor.mli (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_operation.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_operation.mli (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_sigs.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_tags.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_tags.mli (100%) rename src/{proto_alpha => }/lib_injector/injector_worker_types.ml (100%) rename src/{proto_016_PtMumbai => }/lib_injector/injector_worker_types.mli (100%) delete mode 100644 src/proto_016_PtMumbai/lib_injector/dune delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_common.ml delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_common.mli delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_errors.ml delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_errors.mli delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_functor.ml delete mode 100644 src/proto_016_PtMumbai/lib_injector/injector_worker_types.ml delete mode 100644 src/proto_alpha/lib_injector/disk_persistence.ml delete mode 100644 src/proto_alpha/lib_injector/disk_persistence.mli delete mode 100644 src/proto_alpha/lib_injector/injector_events.ml delete mode 100644 src/proto_alpha/lib_injector/injector_functor.mli delete mode 100644 src/proto_alpha/lib_injector/injector_operation.ml delete mode 100644 src/proto_alpha/lib_injector/injector_operation.mli delete mode 100644 src/proto_alpha/lib_injector/injector_sigs.ml delete mode 100644 src/proto_alpha/lib_injector/injector_tags.ml delete mode 100644 src/proto_alpha/lib_injector/injector_tags.mli delete mode 100644 src/proto_alpha/lib_injector/injector_worker_types.mli diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 38b8da1829c2..dea994b3770a 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -258,6 +258,13 @@ opam:octez-codec: # Ignoring unreleased package octez-evm-proxy. +opam:octez-injector: + extends: + - .opam_template + - .rules_template__trigger_opam_batch_1 + variables: + package: octez-injector + opam:octez-node: extends: - .opam_template @@ -847,15 +854,6 @@ opam:tezos-injector-015-PtLimaPt: variables: package: tezos-injector-015-PtLimaPt -opam:tezos-injector-016-PtMumbai: - extends: - - .opam_template - - .rules_template__trigger_opam_batch_1 - variables: - package: tezos-injector-016-PtMumbai - -# Ignoring unreleased package tezos-injector-alpha. - opam:tezos-layer2-store: extends: - .opam_template diff --git a/dune-project b/dune-project index 8d0c9976320a..9adfa71339e4 100644 --- a/dune-project +++ b/dune-project @@ -15,6 +15,7 @@ (package (name octez-dac-node)) (package (name octez-dal-node)) (package (name octez-evm-proxy)) +(package (name octez-injector)) (package (name octez-node)) (package (name octez-node-config)) (package (name octez-protocol-compiler)) @@ -117,8 +118,6 @@ (package (name tezos-expect-helper)) (package (name tezos-hacl)) (package (name tezos-injector-015-PtLimaPt)) -(package (name tezos-injector-016-PtMumbai)) -(package (name tezos-injector-alpha)) (package (name tezos-layer2-store)(allow_empty)) (package (name tezos-layer2-utils-016-PtMumbai)) (package (name tezos-layer2-utils-alpha)) diff --git a/manifest/main.ml b/manifest/main.ml index 8bcf7e5c68a1..dbc196202cf1 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -197,6 +197,8 @@ let logs = external_lib "logs" V.True let logs_fmt = external_sublib logs "logs.fmt" +let logs_lwt = external_sublib logs "logs.lwt" + let lwt = external_lib ~js_compatible:true "lwt" V.(at_least "5.6.0") let lwt_canceler = @@ -3439,6 +3441,26 @@ let octez_node_config = octez_validation |> open_; ] +let octez_injector = + public_lib + "octez-injector" + ~path:"src/lib_injector" + ~synopsis:"Octez: library for building injectors" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives" + |> open_ ~m:"TzPervasives.Error_monad.Legacy_monad_globals" + |> open_; + logs_lwt; + octez_base_unix; + octez_stdlib_unix |> open_; + octez_crypto; + octez_micheline |> open_; + octez_client_base |> open_; + octez_workers |> open_; + octez_shell; + ] + let octez_scoru_wasm_helpers = public_lib "tezos-scoru-wasm-helpers" @@ -5036,7 +5058,7 @@ module Protocol = Protocol ~linkall:true in let injector = - only_if (active && N.(number >= 013)) @@ fun () -> + only_if (active && N.(number >= 013 && number <= 015)) @@ fun () -> public_lib (sf "tezos-injector-%s" name_dash) ~path:(path // "lib_injector") @@ -5074,7 +5096,7 @@ module Protocol = Protocol plugin |> if_some |> open_; parameters |> if_some |> open_; octez_rpc; - injector |> if_some |> open_; + octez_injector |> open_; ] ~inline_tests:ppx_expect ~linkall:true @@ -5115,7 +5137,7 @@ module Protocol = Protocol irmin; aches; aches_lwt; - injector |> if_some |> open_; + octez_injector |> open_; octez_scoru_wasm; octez_scoru_wasm_fast; octez_crypto_dal |> if_ N.(number >= 016) |> open_; diff --git a/opam/tezos-injector-alpha.opam b/opam/octez-injector.opam similarity index 79% rename from opam/tezos-injector-alpha.opam rename to opam/octez-injector.opam index 0133c8b3445a..48eae6fd1f3b 100644 --- a/opam/tezos-injector-alpha.opam +++ b/opam/octez-injector.opam @@ -10,21 +10,18 @@ license: "MIT" depends: [ "dune" { >= "3.0" } "ocaml" { >= "4.14" } - "ppx_expect" "tezos-base" + "logs" "tezos-stdlib-unix" "tezos-crypto" - "tezos-protocol-alpha" "tezos-micheline" - "tezos-client-alpha" "tezos-client-base" "tezos-workers" "tezos-shell" - "tezos-layer2-utils-alpha" ] build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -synopsis: "Tezos/Protocol: protocol specific library building injectors" +synopsis: "Octez: library for building injectors" diff --git a/opam/octez-smart-rollup-node-PtMumbai.opam b/opam/octez-smart-rollup-node-PtMumbai.opam index b3af85664f27..563c6e1fe2d7 100644 --- a/opam/octez-smart-rollup-node-PtMumbai.opam +++ b/opam/octez-smart-rollup-node-PtMumbai.opam @@ -34,7 +34,7 @@ depends: [ "irmin" { >= "3.6.0" & < "3.7.0" } "aches" { >= "1.0.0" } "aches-lwt" { >= "1.0.0" } - "tezos-injector-016-PtMumbai" + "octez-injector" "tezos-scoru-wasm" "tezos-scoru-wasm-fast" "tezos-crypto-dal" diff --git a/opam/octez-smart-rollup-node-alpha.opam b/opam/octez-smart-rollup-node-alpha.opam index 5146cbdb1495..f7e6e103f83d 100644 --- a/opam/octez-smart-rollup-node-alpha.opam +++ b/opam/octez-smart-rollup-node-alpha.opam @@ -34,7 +34,7 @@ depends: [ "irmin" { >= "3.6.0" & < "3.7.0" } "aches" { >= "1.0.0" } "aches-lwt" { >= "1.0.0" } - "tezos-injector-alpha" + "octez-injector" "tezos-scoru-wasm" "tezos-scoru-wasm-fast" "tezos-crypto-dal" diff --git a/opam/tezos-injector-016-PtMumbai.opam b/opam/tezos-injector-016-PtMumbai.opam deleted file mode 100644 index c03e76a04cfa..000000000000 --- a/opam/tezos-injector-016-PtMumbai.opam +++ /dev/null @@ -1,30 +0,0 @@ -# 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-stdlib-unix" - "tezos-crypto" - "tezos-protocol-016-PtMumbai" - "tezos-micheline" - "tezos-client-016-PtMumbai" - "tezos-client-base" - "tezos-workers" - "tezos-shell" - "tezos-layer2-utils-016-PtMumbai" -] -build: [ - ["rm" "-r" "vendors"] - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -synopsis: "Tezos/Protocol: protocol specific library building injectors" diff --git a/opam/tezos-smart-rollup-016-PtMumbai.opam b/opam/tezos-smart-rollup-016-PtMumbai.opam index f6b715dadb8e..c7623591739f 100644 --- a/opam/tezos-smart-rollup-016-PtMumbai.opam +++ b/opam/tezos-smart-rollup-016-PtMumbai.opam @@ -15,7 +15,7 @@ depends: [ "tezos-protocol-016-PtMumbai" "tezos-protocol-plugin-016-PtMumbai" "tezos-rpc" - "tezos-injector-016-PtMumbai" + "octez-injector" ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-smart-rollup-alpha.opam b/opam/tezos-smart-rollup-alpha.opam index 2804a275e256..eaed2d1e93cc 100644 --- a/opam/tezos-smart-rollup-alpha.opam +++ b/opam/tezos-smart-rollup-alpha.opam @@ -15,7 +15,7 @@ depends: [ "tezos-protocol-alpha" "tezos-protocol-plugin-alpha" "tezos-rpc" - "tezos-injector-alpha" + "octez-injector" ] build: [ ["rm" "-r" "vendors"] diff --git a/src/proto_016_PtMumbai/lib_injector/disk_persistence.ml b/src/lib_injector/disk_persistence.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/disk_persistence.ml rename to src/lib_injector/disk_persistence.ml diff --git a/src/proto_016_PtMumbai/lib_injector/disk_persistence.mli b/src/lib_injector/disk_persistence.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/disk_persistence.mli rename to src/lib_injector/disk_persistence.mli diff --git a/src/proto_alpha/lib_injector/dune b/src/lib_injector/dune similarity index 56% rename from src/proto_alpha/lib_injector/dune rename to src/lib_injector/dune index 8fe34ddecfc3..a59a37c0396b 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/lib_injector/dune @@ -2,33 +2,25 @@ ; Edit file manifest/main.ml instead. (library - (name tezos_injector_alpha) - (public_name tezos-injector-alpha) + (name octez_injector) + (public_name octez-injector) (instrumentation (backend bisect_ppx)) (libraries tezos-base + logs.lwt tezos-base.unix tezos-stdlib-unix tezos-crypto - tezos-protocol-alpha tezos-micheline - tezos-client-alpha tezos-client-base tezos-workers - tezos-shell - tezos-layer2-utils-alpha) - (inline_tests (flags -verbose) (modes native)) - (preprocess (pps ppx_expect)) - (library_flags (:standard -linkall)) + tezos-shell) (flags (:standard) -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_protocol_alpha -open Tezos_micheline - -open Tezos_client_alpha -open Tezos_client_base - -open Tezos_workers - -open Tezos_layer2_utils_alpha)) + -open Tezos_workers)) diff --git a/src/proto_alpha/lib_injector/injector_common.ml b/src/lib_injector/injector_common.ml similarity index 100% rename from src/proto_alpha/lib_injector/injector_common.ml rename to src/lib_injector/injector_common.ml diff --git a/src/proto_alpha/lib_injector/injector_common.mli b/src/lib_injector/injector_common.mli similarity index 100% rename from src/proto_alpha/lib_injector/injector_common.mli rename to src/lib_injector/injector_common.mli diff --git a/src/proto_alpha/lib_injector/injector_errors.ml b/src/lib_injector/injector_errors.ml similarity index 100% rename from src/proto_alpha/lib_injector/injector_errors.ml rename to src/lib_injector/injector_errors.ml diff --git a/src/proto_alpha/lib_injector/injector_errors.mli b/src/lib_injector/injector_errors.mli similarity index 100% rename from src/proto_alpha/lib_injector/injector_errors.mli rename to src/lib_injector/injector_errors.mli diff --git a/src/proto_016_PtMumbai/lib_injector/injector_events.ml b/src/lib_injector/injector_events.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_events.ml rename to src/lib_injector/injector_events.ml diff --git a/src/proto_alpha/lib_injector/injector_functor.ml b/src/lib_injector/injector_functor.ml similarity index 100% rename from src/proto_alpha/lib_injector/injector_functor.ml rename to src/lib_injector/injector_functor.ml diff --git a/src/proto_016_PtMumbai/lib_injector/injector_functor.mli b/src/lib_injector/injector_functor.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_functor.mli rename to src/lib_injector/injector_functor.mli diff --git a/src/proto_016_PtMumbai/lib_injector/injector_operation.ml b/src/lib_injector/injector_operation.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_operation.ml rename to src/lib_injector/injector_operation.ml diff --git a/src/proto_016_PtMumbai/lib_injector/injector_operation.mli b/src/lib_injector/injector_operation.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_operation.mli rename to src/lib_injector/injector_operation.mli diff --git a/src/proto_016_PtMumbai/lib_injector/injector_sigs.ml b/src/lib_injector/injector_sigs.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_sigs.ml rename to src/lib_injector/injector_sigs.ml diff --git a/src/proto_016_PtMumbai/lib_injector/injector_tags.ml b/src/lib_injector/injector_tags.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_tags.ml rename to src/lib_injector/injector_tags.ml diff --git a/src/proto_016_PtMumbai/lib_injector/injector_tags.mli b/src/lib_injector/injector_tags.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_tags.mli rename to src/lib_injector/injector_tags.mli diff --git a/src/proto_alpha/lib_injector/injector_worker_types.ml b/src/lib_injector/injector_worker_types.ml similarity index 100% rename from src/proto_alpha/lib_injector/injector_worker_types.ml rename to src/lib_injector/injector_worker_types.ml diff --git a/src/proto_016_PtMumbai/lib_injector/injector_worker_types.mli b/src/lib_injector/injector_worker_types.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_injector/injector_worker_types.mli rename to src/lib_injector/injector_worker_types.mli diff --git a/src/proto_016_PtMumbai/lib_injector/dune b/src/proto_016_PtMumbai/lib_injector/dune deleted file mode 100644 index 9410d3996fa2..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/dune +++ /dev/null @@ -1,34 +0,0 @@ -; This file was automatically generated, do not edit. -; Edit file manifest/main.ml instead. - -(library - (name tezos_injector_016_PtMumbai) - (public_name tezos-injector-016-PtMumbai) - (instrumentation (backend bisect_ppx)) - (libraries - tezos-base - tezos-base.unix - tezos-stdlib-unix - tezos-crypto - tezos-protocol-016-PtMumbai - tezos-micheline - tezos-client-016-PtMumbai - tezos-client-base - tezos-workers - tezos-shell - tezos-layer2-utils-016-PtMumbai) - (inline_tests (flags -verbose) (modes native)) - (preprocess (pps ppx_expect)) - (library_flags (:standard -linkall)) - (flags - (:standard) - -open Tezos_base.TzPervasives - -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals - -open Tezos_base - -open Tezos_stdlib_unix - -open Tezos_protocol_016_PtMumbai - -open Tezos_micheline - -open Tezos_client_016_PtMumbai - -open Tezos_client_base - -open Tezos_workers - -open Tezos_layer2_utils_016_PtMumbai)) diff --git a/src/proto_016_PtMumbai/lib_injector/injector_common.ml b/src/proto_016_PtMumbai/lib_injector/injector_common.ml deleted file mode 100644 index 4b1a5ad38ecd..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_common.ml +++ /dev/null @@ -1,49 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -type signer = { - alias : string; - pkh : Tezos_crypto.Signature.public_key_hash; - pk : Tezos_crypto.Signature.public_key; - sk : Client_keys.sk_uri; -} - -let get_signer cctxt pkh = - let open Lwt_result_syntax in - let* alias, pk, sk = Client_keys.get_key cctxt pkh in - return {alias; pkh; pk; sk} - -type 'block reorg = {old_chain : 'block list; new_chain : 'block list} - -let no_reorg = {old_chain = []; new_chain = []} - -let reorg_encoding block_encoding = - let open Data_encoding in - conv - (fun {old_chain; new_chain} -> (old_chain, new_chain)) - (fun (old_chain, new_chain) -> {old_chain; new_chain}) - @@ obj2 - (req "old_chain" (list block_encoding)) - (req "new_chain" (list block_encoding)) diff --git a/src/proto_016_PtMumbai/lib_injector/injector_common.mli b/src/proto_016_PtMumbai/lib_injector/injector_common.mli deleted file mode 100644 index d6088bb21aca..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_common.mli +++ /dev/null @@ -1,51 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -(** The type of signers for operations injected by the injector *) -type signer = { - alias : string; - pkh : Tezos_crypto.Signature.public_key_hash; - pk : Tezos_crypto.Signature.public_key; - sk : Client_keys.sk_uri; -} - -(** Type of chain reorganizations. *) -type 'block reorg = { - old_chain : 'block list; - (** The blocks that were in the old chain and which are not in the new one. *) - new_chain : 'block list; - (** The blocks that are now in the new chain. The length of [old_chain] and - [new_chain] may be different. *) -} - -(** Retrieve a signer from the client wallet. *) -val get_signer : - #Client_context.wallet -> - Tezos_crypto.Signature.public_key_hash -> - signer tzresult Lwt.t - -val no_reorg : 'a reorg - -val reorg_encoding : 'a Data_encoding.t -> 'a reorg Data_encoding.t diff --git a/src/proto_016_PtMumbai/lib_injector/injector_errors.ml b/src/proto_016_PtMumbai/lib_injector/injector_errors.ml deleted file mode 100644 index c1ba94461b90..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_errors.ml +++ /dev/null @@ -1,72 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t - -let () = - register_error_kind - ~id:"injector.no_worker_for_source" - ~title:"No injecting queue for source" - ~description: - "An L1 operation could not be queued because its source has no worker." - ~pp:(fun ppf s -> - Format.fprintf - ppf - "No worker for source %a" - Tezos_crypto.Signature.Public_key_hash.pp - s) - `Permanent - Data_encoding.( - obj1 (req "source" Tezos_crypto.Signature.Public_key_hash.encoding)) - (function No_worker_for_source s -> Some s | _ -> None) - (fun s -> No_worker_for_source s) - -type error += No_worker_for_tag of string - -let () = - register_error_kind - ~id:"injector.no_worker_for_tag" - ~title:"No injecting queue for tag" - ~description: - "An L1 operation could not be queued because its tag has no worker." - ~pp:(fun ppf t -> Format.fprintf ppf "No worker for tag %s" t) - `Permanent - Data_encoding.(obj1 (req "tag" Data_encoding.string)) - (function No_worker_for_tag t -> Some t | _ -> None) - (fun t -> No_worker_for_tag t) - -type error += Step_failed of string - -let () = - register_error_kind - ~id:"injector.step_failed" - ~title:"A step failed in the injector" - ~description:"A step failed in the injector." - ~pp:(fun ppf step -> - Format.fprintf ppf "%s failed in injector" (String.capitalize_ascii step)) - `Temporary - Data_encoding.(obj1 (req "step" string)) - (function Step_failed s -> Some s | _ -> None) - (fun s -> Step_failed s) diff --git a/src/proto_016_PtMumbai/lib_injector/injector_errors.mli b/src/proto_016_PtMumbai/lib_injector/injector_errors.mli deleted file mode 100644 index 3925237d599d..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_errors.mli +++ /dev/null @@ -1,35 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -(** Error when the injector has no worker for the source which must inject an - operation. *) -type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t - -(** Error when the injector has no worker for the tag of the operation to be - injected. *) -type error += No_worker_for_tag of string - -(** Error when a step of the injector failed. *) -type error += Step_failed of string diff --git a/src/proto_016_PtMumbai/lib_injector/injector_functor.ml b/src/proto_016_PtMumbai/lib_injector/injector_functor.ml deleted file mode 100644 index 33a8934fb57e..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_functor.ml +++ /dev/null @@ -1,1152 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_common -open Injector_worker_types -open Injector_sigs -open Injector_errors -module Block_cache = - Aches_lwt.Lache.Make_result - (Aches.Rache.Transfer (Aches.Rache.LRU) (Block_hash)) - -(* This is the Tenderbake finality for blocks. *) -(* TODO: https://gitlab.com/tezos/tezos/-/issues/2815 - Centralize this and maybe make it configurable. *) -let confirmations = 2 - -type injection_strategy = [`Each_block | `Delay_block of float] - -(** Builds a client context from another client context but uses logging instead - of printing on stdout directly. This client context cannot make the injector - exit. *) -let injector_context (cctxt : #Client_context.full) : Client_context.full = - let log _channel msg = Logs_lwt.info (fun m -> m "%s" msg) in - object - inherit Client_context.proxy_context cctxt - - inherit! Client_context.simple_printer log - - method! exit code = - Format.ksprintf Stdlib.failwith "Injector client wants to exit %d" code - end - -module Make - (Parameters : PARAMETERS) - (Proto_client : PROTOCOL_CLIENT - with type state := Parameters.state - and type operation := Parameters.Operation.t) = -struct - module Tags = Injector_tags.Make (Parameters.Tag) - module Tags_table = Hashtbl.Make (Parameters.Tag) - module POperation = Parameters.Operation - module Inj_operation = Injector_operation.Make (POperation) - module Request = Request (Inj_operation) - - type injected_info = { - op : Inj_operation.t; - oph : Operation_hash.t; - op_index : int; - } - - type included_info = { - op : Inj_operation.t; - oph : Operation_hash.t; - op_index : int; - l1_block : Block_hash.t; - l1_level : int32; - } - - type status = - | Pending of POperation.t - | Injected of injected_info - | Included of included_info - - let injected_info_encoding = - let open Data_encoding in - conv - (fun ({op; oph; op_index} : injected_info) -> (op, (oph, op_index))) - (fun (op, (oph, op_index)) -> {op; oph; op_index}) - @@ merge_objs - Inj_operation.encoding - (obj1 - (req - "layer1" - (obj2 - (req "operation_hash" Operation_hash.encoding) - (req "operation_index" int31)))) - - let included_info_encoding = - let open Data_encoding in - conv - (fun {op; oph; op_index; l1_block; l1_level} -> - (op, (oph, op_index, l1_block, l1_level))) - (fun (op, (oph, op_index, l1_block, l1_level)) -> - {op; oph; op_index; l1_block; l1_level}) - @@ merge_objs - Inj_operation.encoding - (obj1 - (req - "layer1" - (obj4 - (req "operation_hash" Operation_hash.encoding) - (req "operation_index" int31) - (req "block_hash" Block_hash.encoding) - (req "level" int32)))) - - module Op_queue = - Disk_persistence.Make_queue - (struct - let name = "operations_queue" - end) - (Inj_operation.Hash) - (Inj_operation) - - module Injected_operations = Disk_persistence.Make_table (struct - include Inj_operation.Hash.Table - - type value = injected_info - - let name = "injected_operations" - - let string_of_key = Inj_operation.Hash.to_b58check - - let key_of_string = Inj_operation.Hash.of_b58check_opt - - let value_encoding = injected_info_encoding - end) - - module Injected_ophs = Disk_persistence.Make_table (struct - include Operation_hash.Table - - type value = Inj_operation.Hash.t list - - let name = "injected_ophs" - - let string_of_key = Operation_hash.to_b58check - - let key_of_string = Operation_hash.of_b58check_opt - - let value_encoding = Data_encoding.list Inj_operation.Hash.encoding - end) - - (** The part of the state which gathers information about injected - operations (but not included). *) - type injected_state = { - injected_operations : Injected_operations.t; - (** A table mapping L1 manager operation hashes to the injection info for that - operation. *) - injected_ophs : Injected_ophs.t; - (** A mapping of all L1 manager operations contained in a L1 batch (i.e. an L1 - operation). *) - } - - module Included_operations = Disk_persistence.Make_table (struct - include Inj_operation.Hash.Table - - type value = included_info - - let name = "included_operations" - - let string_of_key = Inj_operation.Hash.to_b58check - - let key_of_string = Inj_operation.Hash.of_b58check_opt - - let value_encoding = included_info_encoding - end) - - module Included_in_blocks = Disk_persistence.Make_table (struct - include Block_hash.Table - - type value = int32 * Inj_operation.Hash.t list - - let name = "included_in_blocks" - - let string_of_key = Block_hash.to_b58check - - let key_of_string = Block_hash.of_b58check_opt - - let value_encoding = - let open Data_encoding in - obj2 (req "level" int32) (req "l1_ops" (list Inj_operation.Hash.encoding)) - end) - - (** The part of the state which gathers information about - operations which are included in the L1 chain (but not confirmed). *) - type included_state = { - included_operations : Included_operations.t; - included_in_blocks : Included_in_blocks.t; - } - - (** The internal state of each injector worker. *) - type state = { - cctxt : Client_context.full; - (** The client context which is used to perform the injections. *) - signer : signer; (** The signer for this worker. *) - tags : Tags.t; - (** The tags of this worker, for both informative and identification - purposes. *) - strategy : injection_strategy; - (** The strategy of this worker for injecting the pending operations. *) - save_dir : string; (** Path to where save persistent state *) - queue : Op_queue.t; - (** The queue of pending operations for this injector. *) - injected : injected_state; - (** The information about injected operations. *) - included : included_state; - (** The information about included operations. {b Note}: Operations which - are confirmed are simply removed from the state and do not appear - anymore. *) - state : Parameters.state; - retention_period : int; - (** Number of blocks for which the injector keeps the included - information. *) - } - - module Event = struct - include - Injector_events.Make (Parameters) (Tags) (POperation) (Inj_operation) - (Request) - - let emit1 e state x = emit e (state.signer.pkh, state.tags, x) - - let emit2 e state x y = emit e (state.signer.pkh, state.tags, x, y) - - let emit3 e state x y z = emit e (state.signer.pkh, state.tags, x, y, z) - end - - let init_injector cctxt ~data_dir state ~retention_period ~signer strategy - tags = - let open Lwt_result_syntax in - let* signer = get_signer cctxt signer in - let data_dir = Filename.concat data_dir "injector" in - let*! () = Lwt_utils_unix.create_dir data_dir in - let filter op_proj op = - Tags.mem (Parameters.operation_tag (op_proj op)) tags - in - let warn_unreadable = - (* Warn of corrupted files but don't fail *) - Some - (fun file error -> - Event.(emit corrupted_operation_on_disk) - (signer.pkh, tags, file, error)) - in - let emit_event_loaded kind nb = - Event.(emit loaded_from_disk) (signer.pkh, tags, nb, kind) - in - let* queue = - Op_queue.load_from_disk - ~warn_unreadable - ~capacity:50_000 - ~data_dir - ~filter:(filter (fun op -> op.Inj_operation.operation)) - in - let*! () = emit_event_loaded "operations_queue" @@ Op_queue.length queue in - (* Very coarse approximation for the number of operation we expect for each - block *) - let n = - Tags.fold (fun t acc -> acc + Parameters.table_estimated_size t) tags 0 - in - let* injected_operations = - Injected_operations.load_from_disk - ~warn_unreadable - ~initial_size:n - ~data_dir - ~filter:(filter (fun (i : injected_info) -> i.op.operation)) - in - let*! () = - emit_event_loaded "injected_operations" - @@ Injected_operations.length injected_operations - in - - let* included_operations = - Included_operations.load_from_disk - ~warn_unreadable - ~initial_size:((confirmations + retention_period) * n) - ~data_dir - ~filter:(filter (fun (i : included_info) -> i.op.operation)) - in - let*! () = - emit_event_loaded "included_operations" - @@ Included_operations.length included_operations - in - let* injected_ophs = - Injected_ophs.load_from_disk - ~warn_unreadable - ~initial_size:n - ~data_dir - ~filter:(List.exists (Injected_operations.mem injected_operations)) - in - let*! () = - emit_event_loaded "injected_ophs" @@ Injected_ophs.length injected_ophs - in - let* included_in_blocks = - Included_in_blocks.load_from_disk - ~warn_unreadable - ~initial_size:((confirmations + retention_period) * n) - ~data_dir - ~filter:(fun (_, ops) -> - List.exists (Included_operations.mem included_operations) ops) - in - let*! () = - emit_event_loaded "included_in_blocks" - @@ Included_in_blocks.length included_in_blocks - in - - return - { - cctxt = injector_context (cctxt :> #Client_context.full); - signer; - tags; - strategy; - save_dir = data_dir; - queue; - injected = {injected_operations; injected_ophs}; - included = {included_operations; included_in_blocks}; - state; - retention_period; - } - - (** Add an operation to the pending queue corresponding to the signer for this - operation. *) - let add_pending_operation ?(retry = false) state op = - let open Lwt_result_syntax in - let*! () = - Event.(emit1 (if retry then retry_operation else add_pending)) - state - op.Inj_operation.operation - in - let* () = Op_queue.replace state.queue op.hash op in - let*! () = - Event.(emit1 number_of_operations_in_queue) - state - (Op_queue.length state.queue) - in - return_unit - - (** Mark operations as injected (in [oph]). *) - let add_injected_operations state oph operations = - let open Lwt_result_syntax in - let infos = - List.map - (fun (op_index, op) -> (op.Inj_operation.hash, {op; oph; op_index})) - operations - in - let* () = - Injected_operations.replace_seq - state.injected.injected_operations - (List.to_seq infos) - in - Injected_ophs.replace state.injected.injected_ophs oph (List.map fst infos) - - (** [add_included_operations state oph l1_block l1_level operations] marks the - [operations] as included (in the L1 batch [oph]) in the Tezos block - [l1_block] of level [l1_level]. *) - let add_included_operations state l1_block l1_level - (operations : injected_info list) = - let open Lwt_result_syntax in - let*! () = - Event.(emit3 included) - state - l1_block - l1_level - (List.map - (fun (o : injected_info) -> o.op.Inj_operation.hash) - operations) - in - let infos = - List.map - (fun ({op; oph; op_index} : injected_info) -> - (op.Inj_operation.hash, {op; oph; op_index; l1_block; l1_level})) - operations - in - let* () = - Included_operations.replace_seq - state.included.included_operations - (List.to_seq infos) - in - Included_in_blocks.replace - state.included.included_in_blocks - l1_block - (l1_level, List.map fst infos) - - (** [remove state oph] removes the operations that correspond to the L1 batch - [oph] from the injected operations in the injector state. This function is - used to move operations from injected to included. *) - let remove_injected_operation state oph = - let open Lwt_result_syntax in - match Injected_ophs.find state.injected.injected_ophs oph with - | None -> - (* Nothing removed *) - return [] - | Some mophs -> - let* () = Injected_ophs.remove state.injected.injected_ophs oph in - let+ removed = - List.fold_left_es - (fun removed moph -> - match - Injected_operations.find state.injected.injected_operations moph - with - | None -> return removed - | Some info -> - let+ () = - Injected_operations.remove - state.injected.injected_operations - moph - in - info :: removed) - [] - mophs - in - List.rev removed - - (** [forget_block state block] removes the included operations that correspond - to all the L1 batches included in [block]. This function is used, - e.g. when [block] is on an alternative chain in the case of a - reorganization. *) - let forget_block state block = - let open Lwt_result_syntax in - match Included_in_blocks.find state.included.included_in_blocks block with - | None -> - (* Nothing removed *) - return [] - | Some (_level, mophs) -> - let* () = - Included_in_blocks.remove state.included.included_in_blocks block - in - List.fold_left_es - (fun removed moph -> - match - Included_operations.find state.included.included_operations moph - with - | None -> return removed - | Some info -> - let+ () = - Included_operations.remove - state.included.included_operations - moph - in - info :: removed) - [] - mophs - - let fee_parameter_of_operations state ops = - List.fold_left - (fun acc {Inj_operation.operation; _} -> - let param = Parameters.fee_parameter state operation in - { - minimal_fees = - {mutez = Int64.max acc.minimal_fees.mutez param.minimal_fees.mutez}; - minimal_nanotez_per_byte = - Q.max acc.minimal_nanotez_per_byte param.minimal_nanotez_per_byte; - minimal_nanotez_per_gas_unit = - Q.max - acc.minimal_nanotez_per_gas_unit - param.minimal_nanotez_per_gas_unit; - force_low_fee = acc.force_low_fee || param.force_low_fee; - fee_cap = {mutez = Int64.add acc.fee_cap.mutez param.fee_cap.mutez}; - burn_cap = {mutez = Int64.add acc.burn_cap.mutez param.burn_cap.mutez}; - }) - { - minimal_fees = {mutez = 0L}; - minimal_nanotez_per_byte = Q.zero; - minimal_nanotez_per_gas_unit = Q.zero; - force_low_fee = false; - fee_cap = {mutez = 0L}; - burn_cap = {mutez = 0L}; - } - ops - - (** Returns the first half of the list [ops] if there is more than two - elements, or [None] otherwise. *) - let keep_half ops = - let total = List.length ops in - if total <= 1 then None else Some (List.take_n (total / 2) ops) - - (** [simulate_operations ~must_succeed state operations] simulates the - injection of [operations] and returns a triple [(op, ops, results)] where - [op] is the packed operation with the adjusted limits, [ops] is the prefix - of [operations] which was considered (because it did not exceed the - quotas) and [results] are the results of the simulation. See - {!inject_operations} for the specification of [must_succeed]. *) - let rec simulate_operations ~must_succeed state - (operations : Inj_operation.t list) = - let open Lwt_result_syntax in - let force = - match operations with - | [] -> assert false - | [_] -> - (* If there is only one operation, fail when simulation fails *) - false - | _ -> ( - (* We want to see which operation failed in the batch if not all must - succeed *) - match must_succeed with `All -> false | `At_least_one -> true) - in - let op_operations = - List.map (fun o -> o.Inj_operation.operation) operations - in - let*! () = Event.(emit2 simulating_operations) state op_operations force in - let fee_parameter = fee_parameter_of_operations state.state operations in - let*! simulation_result = - Proto_client.simulate_operations - state.cctxt - ~force - ~source:state.signer.pkh - ~src_pk:state.signer.pk - ~successor_level:true - (* Operations are simulated in the next block, which is important for - rollups and ok for other applications. *) - ~fee_parameter - op_operations - in - match simulation_result with - | Error (`TzError trace) -> fail trace - | Error (`Exceeds_quotas trace) -> ( - let*! () = - Event.(emit1 number_of_operations_in_queue) - state - (Op_queue.length state.queue) - in - (* We perform a dichotomy by injecting the first half of the - operations (we are not looking to maximize the number of operations - injected because of the cost of simulation). Only the operations - which are actually injected will be removed from the queue so the - other half will be reconsidered later. *) - match keep_half operations with - | None -> - fail - @@ TzTrace.cons - (Exn (Failure "Quotas exceeded when simulating one operation")) - trace - | Some operations -> simulate_operations ~must_succeed state operations) - | Ok {operations_statuses; unsigned_operation} -> - let*? results = - List.combine - ~when_different_lengths: - [ - Exn - (Failure - "Injector: Not the same number of results as operations \ - in simulation."); - ] - operations - operations_statuses - in - return (results, unsigned_operation) - - let inject_on_node state ~nb unsigned_op = - let open Lwt_result_syntax in - let* signed_op_bytes = - Proto_client.sign_operation state.cctxt state.signer.sk unsigned_op - in - Tezos_shell_services.Shell_services.Injection.operation - state.cctxt - ~chain:state.cctxt#chain - signed_op_bytes - >>=? fun oph -> - let*! () = Event.(emit2 injected) state nb oph in - return oph - - (** Inject the given [operations] in an L1 batch. If [must_succeed] is [`All] - then all the operations must succeed in the simulation of injection. If - [must_succeed] is [`At_least_one] at least one operation in the list - [operations] must be successful in the simulation. In any case, only - operations which are known as successful will be included in the injected L1 - batch. {b Note}: [must_succeed = `At_least_one] allows to incrementally build - "or-batches" by iteratively removing operations that fail from the desired - batch. *) - let rec inject_operations ~must_succeed state - (operations : Inj_operation.t list) = - let open Lwt_result_syntax in - let* operations_results, raw_op = - trace (Step_failed "simulation") - @@ simulate_operations ~must_succeed state operations - in - let failure = ref false in - let*! rev_non_failing_operations = - List.fold_left_s - (fun acc (op, {status; _}) -> - let open Lwt_syntax in - match status with - | Unsuccessful (Failed error) -> - let+ () = - Event.(emit2 dropping_operation) - state - op.Inj_operation.operation - error - in - failure := true ; - acc - | Successful | Unsuccessful (Backtracked | Skipped | Other_branch) -> - (* Not known to be failing *) - return (op :: acc)) - [] - operations_results - in - if !failure then - (* Invariant: must_succeed = `At_least_one, otherwise the simulation would - have returned an error. We try to inject without the failing - operation. *) - let operations = List.rev rev_non_failing_operations in - inject_operations ~must_succeed state operations - else - (* Inject on node for real *) - let+ oph = - trace (Step_failed "injection") - @@ inject_on_node ~nb:(List.length operations) state raw_op - in - let operations = - List.map - (fun (op, {index_in_batch; _}) -> (index_in_batch, op)) - operations_results - in - (oph, operations) - - (** Returns the (upper bound on) the size of an L1 batch of operations composed - of the manager operations [ops]. *) - let size_l1_batch ops = - let size_shell_header = - (* Size of branch field *) - Block_hash.size - in - let signature_size = Signature.size Signature.zero in - let contents_size = - List.fold_left - (fun acc o -> - acc - + Proto_client.operation_size o.Inj_operation.operation - + Proto_client.operation_size_overhead) - 0 - ops - in - size_shell_header + contents_size + signature_size - - (** Retrieve as many operations from the queue while remaining below the size - limit. *) - let get_operations_from_queue ~size_limit state = - let exception Reached_limit of Inj_operation.t list in - let rev_ops = - try - Op_queue.fold - (fun _oph op ops -> - let new_ops = op :: ops in - let new_size = size_l1_batch new_ops in - if new_size > size_limit then raise (Reached_limit ops) ; - new_ops) - state.queue - [] - with Reached_limit ops -> ops - in - List.rev rev_ops - - (* Ignore operations that are allowed to fail. *) - let ignore_ignorable_failing_operations state operations = function - | Ok res -> return (`Injected res) - | Error err -> - let open Lwt_result_syntax in - let+ operations_to_drop = - List.fold_left_es - (fun to_drop op -> - let*! retry = - Parameters.retry_unsuccessful_operation - state.state - op.Inj_operation.operation - (Failed err) - in - match retry with - | Abort err -> fail err - | Retry -> return to_drop - | Forget -> return (op :: to_drop)) - [] - operations - in - `Ignored operations_to_drop - - (** [inject_pending_operations_for ~size_limit state pending] injects - operations from the pending queue [pending], whose total size does - not exceed [size_limit]. Upon successful injection, the - operations are removed from the queue and marked as injected. *) - let inject_pending_operations - ?(size_limit = Proto_client.max_operation_data_length) state = - let open Lwt_result_syntax in - (* Retrieve and remove operations from pending *) - let operations_to_inject = get_operations_from_queue ~size_limit state in - let*! () = - Event.(emit1 considered_operations_info) - state - (List.map (fun o -> o.Inj_operation.operation) operations_to_inject) - in - match operations_to_inject with - | [] -> return_unit - | _ -> ( - let*! () = - Event.(emit1 injecting_pending) - state - (List.length operations_to_inject) - in - let must_succeed = - Parameters.batch_must_succeed - @@ List.map - (fun op -> op.Inj_operation.operation) - operations_to_inject - in - let*! res = - inject_operations ~must_succeed state operations_to_inject - in - let* res = - ignore_ignorable_failing_operations state operations_to_inject res - in - match res with - | `Injected (oph, injected_operations) -> - (* Injection succeeded, remove from pending and add to injected *) - let* () = - List.iter_es - (fun (_index, op) -> - Op_queue.remove state.queue op.Inj_operation.hash) - injected_operations - in - add_injected_operations state oph injected_operations - | `Ignored operations_to_drop -> - (* Injection failed but we ignore the failure. *) - let*! () = - Event.(emit1 dropped_operations) - state - (List.map - (fun o -> o.Inj_operation.operation) - operations_to_drop) - in - let* () = - List.iter_es - (fun op -> Op_queue.remove state.queue op.Inj_operation.hash) - operations_to_drop - in - return_unit) - - (** [register_included_operation state block level op] marks the manager - operations contained in the L1 batch [op] as being included in the [block] - of level [level], by moving the successful ones from the "injected" state - to the "included" state, and re-queuing the operations that should be - retried. *) - let register_included_operation state block level oph = - let open Lwt_result_syntax in - let* injected_infos = remove_injected_operation state oph in - match injected_infos with - | [] -> - (* No operations injected by us *) - return_unit - | _ -> - let* included, to_retry = - List.fold_left_es - (fun (included, to_retry) (info : injected_info) -> - let* status = - Proto_client.operation_status - state.state - block - oph - ~index:info.op_index - in - match status with - | None -> - failwith - "Cannot get status for an operation which is not included \ - in the block" - | Some Successful -> return (info :: included, to_retry) - | Some (Unsuccessful status) -> ( - let*! retry = - Parameters.retry_unsuccessful_operation - state.state - info.op.operation - status - in - match retry with - | Retry -> return (included, info.op :: to_retry) - | Forget -> return (included, to_retry) - | Abort err -> fail err)) - ([], []) - injected_infos - in - let* () = - add_included_operations state block level (List.rev included) - in - List.iter_es - (add_pending_operation ~retry:true state) - (List.rev to_retry) - - (** Retrieve operation hashes of a block with a small LRU cache. *) - let manager_operations_hashes_of_block = - let blocks_ops_cache = Block_cache.create 32 in - fun state block_hash -> - Block_cache.bind_or_put - blocks_ops_cache - block_hash - (fun block_hash -> - Tezos_shell_services.Shell_services.Blocks.Operation_hashes - .operation_hashes_in_pass - state.cctxt - ~chain:state.cctxt#chain - ~block:(`Hash (block_hash, 0)) - Proto_client.manager_pass) - Lwt.return - - (** [register_included_operations state (block, level)] marks the known (by - this injector) manager operations contained in [block] as being included. *) - let register_included_operations state (block_hash, level) = - let open Lwt_result_syntax in - let* operation_hashes = - manager_operations_hashes_of_block state block_hash - in - List.iter_es - (fun oph -> register_included_operation state block_hash level oph) - operation_hashes - - (** [revert_included_operations state block] marks the known (by this injector) - manager operations contained in [block] as not being included any more, - typically in the case of a reorganization where [block] is on an alternative - chain. The operations are put back in the pending queue. *) - let revert_included_operations state block = - let open Lwt_result_syntax in - let* revert_infos = forget_block state block in - let*! () = - Event.(emit1 revert_operations) - state - (List.map (fun o -> o.op.hash) revert_infos) - in - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2814 - maybe put at the front of the queue for re-injection. *) - List.iter_es - (fun {op; _} -> - let*! requeue = - Parameters.retry_unsuccessful_operation - state.state - op.operation - Other_branch - in - match requeue with - | Retry -> add_pending_operation ~retry:true state op - | _ -> return_unit) - revert_infos - - (** [register_confirmed_level state confirmed_level] is called when the level - [confirmed_level] is known as confirmed. In this case, the operations of - block which are below this level are also considered as confirmed and are - removed from the "included" state. These operations cannot be part of a - reorganization so there will be no need to re-inject them anymore. *) - let register_confirmed_level state confirmed_level = - let open Lwt_result_syntax in - let*! () = - Event.(emit confirmed_level) - (state.signer.pkh, state.tags, confirmed_level) - in - Included_in_blocks.iter_es - (fun block (level, _operations) -> - if - level - <= Int32.sub confirmed_level (Int32.of_int state.retention_period) - then - let* _removed_ops = forget_block state block in - return_unit - else return_unit) - state.included.included_in_blocks - - (** [on_new_tezos_head state head reorg] is called when there is a new Tezos - head (with a potential reorganization [reorg]). It first reverts any blocks - that are in the alternative branch of the reorganization and then registers - the effect of the new branch (the newly included operation and confirmed - operations). *) - let on_new_tezos_head state (head_hash, head_level) - (reorg : (Block_hash.t * int32) reorg) = - let open Lwt_result_syntax in - let*! () = Event.(emit1 new_tezos_head) state head_hash in - let* () = - List.iter_es - (fun (removed_block, _) -> - revert_included_operations state removed_block) - (List.rev reorg.old_chain) - in - let* () = - List.iter_es - (fun added_block -> register_included_operations state added_block) - reorg.new_chain - in - (* Head is already included in the reorganization, so no need to process it - separately. *) - let confirmed_level = Int32.sub head_level (Int32.of_int confirmations) in - if confirmed_level >= 0l then register_confirmed_level state confirmed_level - else return_unit - - (* The request {Request.Inject} triggers an injection of the operations - the pending queue. *) - let on_inject state = inject_pending_operations state - - module Types = struct - type nonrec state = state - - type parameters = { - cctxt : Client_context.full; - data_dir : string; - state : Parameters.state; - retention_period : int; - strategy : injection_strategy; - tags : Tags.t; - } - end - - (* The worker for the injector. *) - module Worker = Worker.MakeSingle (Name) (Request) (Types) - - (* The queue for the requests to the injector worker is infinite. *) - type worker = Worker.infinite Worker.queue Worker.t - - let table = Worker.create_table Queue - - let tags_table = Tags_table.create 7 - - module Handlers = struct - type self = worker - - let on_request : - type r request_error. - worker -> - (r, request_error) Request.t -> - (r, request_error) result Lwt.t = - fun w request -> - let state = Worker.state w in - match request with - | Request.Add_pending op -> - (* The execution of the request handler is protected to avoid stopping the - worker in case of an exception. *) - protect @@ fun () -> add_pending_operation state op - | Request.New_tezos_head (head, reorg) -> - protect @@ fun () -> on_new_tezos_head state head reorg - | Request.Inject -> protect @@ fun () -> on_inject state - - type launch_error = error trace - - let on_launch _w signer - Types.{cctxt; data_dir; state; retention_period; strategy; tags} = - trace (Step_failed "initialization") - @@ init_injector - cctxt - ~data_dir - state - ~retention_period - ~signer - strategy - tags - - let on_error (type a b) w st (r : (a, b) Request.t) (errs : b) : - unit tzresult Lwt.t = - let open Lwt_result_syntax in - let state = Worker.state w in - let request_view = Request.view r in - let emit_and_return_errors errs = - (* Errors do not stop the worker but emit an entry in the log. *) - let*! () = Event.(emit3 request_failed) state request_view st errs in - return_unit - in - match r with - | Request.Add_pending _ -> emit_and_return_errors errs - | Request.New_tezos_head _ -> emit_and_return_errors errs - | Request.Inject -> emit_and_return_errors errs - - let on_completion w r _ st = - let state = Worker.state w in - match Request.view r with - | Request.View (Add_pending _ | New_tezos_head _) -> - Event.(emit2 request_completed_debug) state (Request.view r) st - | View Inject -> - Event.(emit2 request_completed_notice) state (Request.view r) st - - let on_no_request _ = Lwt.return_unit - - let on_close w = - let state = Worker.state w in - Tags.iter (Tags_table.remove tags_table) state.tags ; - Lwt.return_unit - end - - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2754 - Injector worker in a separate process *) - let init (cctxt : #Client_context.full) ~data_dir ?(retention_period = 0) - state ~signers = - let open Lwt_result_syntax in - assert (retention_period >= 0) ; - let signers_map = - List.fold_left - (fun acc (signer, strategy, tags) -> - let tags = Tags.of_list tags in - let strategy, tags = - match - Tezos_crypto.Signature.Public_key_hash.Map.find_opt signer acc - with - | None -> (strategy, tags) - | Some (other_strategy, other_tags) -> - let strategy = - match (strategy, other_strategy) with - | `Each_block, `Each_block -> `Each_block - | `Delay_block f, _ | _, `Delay_block f -> - (* Delay_block strategy takes over because we can always wait a - little bit more to inject operation which are to be injected - "each block". *) - `Delay_block f - in - (strategy, Tags.union other_tags tags) - in - Tezos_crypto.Signature.Public_key_hash.Map.add - signer - (strategy, tags) - acc) - Tezos_crypto.Signature.Public_key_hash.Map.empty - signers - in - Signature.Public_key_hash.Map.iter_es - (fun signer (strategy, tags) -> - let+ worker = - Worker.launch - table - signer - { - cctxt = (cctxt :> Client_context.full); - data_dir; - state; - retention_period; - strategy; - tags; - } - (module Handlers) - in - ignore worker) - signers_map - - let worker_of_signer signer_pkh = - match Worker.find_opt table signer_pkh with - | None -> - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2818 - maybe lazily start worker here *) - error (No_worker_for_source signer_pkh) - | Some worker -> ok worker - - let worker_of_tag tag = - match Tags_table.find_opt tags_table tag with - | None -> - Format.kasprintf - (fun s -> error (No_worker_for_tag s)) - "%a" - Parameters.Tag.pp - tag - | Some worker -> ok worker - - let add_pending_operation ?source op = - let open Lwt_result_syntax in - let operation = Inj_operation.make op in - let*? w = - match source with - | Some source -> worker_of_signer source - | None -> worker_of_tag (Parameters.operation_tag op) - in - let*! (_pushed : bool) = - Worker.Queue.push_request w (Request.Add_pending operation) - in - return operation.hash - - let new_tezos_head h reorg = - let open Lwt_syntax in - let workers = Worker.list table in - List.iter_p - (fun (_signer, w) -> - let* (_pushed : bool) = - Worker.Queue.push_request w (Request.New_tezos_head (h, reorg)) - in - return_unit) - workers - - let has_tag_in ~tags state = - match tags with - | None -> - (* Not filtering on tags *) - true - | Some tags -> not (Tags.disjoint state.tags tags) - - let delay_stategy state header f = - let open Lwt_syntax in - match state.strategy with - | `Each_block -> f () - | `Delay_block delay_factor -> - let time_until_next_block = - Proto_client.time_until_next_block state.state header - |> Ptime.Span.to_float_s - in - let delay = time_until_next_block *. delay_factor in - if delay <= 0. then f () - else - let promise = - let* () = Event.(emit1 inject_wait) state delay in - let* () = Lwt_unix.sleep delay in - f () - in - ignore promise ; - return_unit - - let inject ?tags ?header () = - let workers = Worker.list table in - let tags = Option.map Tags.of_list tags in - List.iter_p - (fun (_signer, w) -> - let open Lwt_syntax in - let worker_state = Worker.state w in - if has_tag_in ~tags worker_state then - delay_stategy worker_state header @@ fun () -> - let* _pushed = Worker.Queue.push_request w Request.Inject in - return_unit - else Lwt.return_unit) - workers - - let shutdown () = - let workers = Worker.list table in - List.iter_p (fun (_signer, w) -> Worker.shutdown w) workers - - let op_status_in_worker state l1_hash = - match Op_queue.find_opt state.queue l1_hash with - | Some op -> Some (Pending op.operation) - | None -> ( - match - Injected_operations.find state.injected.injected_operations l1_hash - with - | Some info -> Some (Injected info) - | None -> ( - match - Included_operations.find - state.included.included_operations - l1_hash - with - | Some info -> Some (Included info) - | None -> None)) - - let operation_status l1_hash = - let workers = Worker.list table in - List.find_map - (fun (_signer, w) -> op_status_in_worker (Worker.state w) l1_hash) - workers -end diff --git a/src/proto_016_PtMumbai/lib_injector/injector_worker_types.ml b/src/proto_016_PtMumbai/lib_injector/injector_worker_types.ml deleted file mode 100644 index 8f56e02ec8a5..000000000000 --- a/src/proto_016_PtMumbai/lib_injector/injector_worker_types.ml +++ /dev/null @@ -1,104 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_common -open Injector_sigs - -module Request (L1_operation : INJECTOR_OPERATION) = struct - type ('a, 'b) t = - | Add_pending : L1_operation.t -> (unit, error trace) t - | New_tezos_head : - (Block_hash.t * int32) * (Block_hash.t * int32) reorg - -> (unit, error trace) t - | Inject : (unit, error trace) t - - type view = View : _ t -> view - - let view req = View req - - let encoding = - let open Data_encoding in - union - [ - case - (Tag 0) - ~title:"Add_pending" - (merge_objs - (obj1 (req "request" (constant "add_pending"))) - L1_operation.encoding) - (function View (Add_pending op) -> Some ((), op) | _ -> None) - (fun ((), op) -> View (Add_pending op)); - case - (Tag 1) - ~title:"New_tezos_head" - (let block_level = - obj2 (req "block" Block_hash.encoding) (req "level" int32) - in - obj3 - (req "request" (constant "new_tezos_head")) - (req "head" block_level) - (req "reorg" (reorg_encoding block_level))) - (function - | View (New_tezos_head (b, r)) -> Some ((), b, r) | _ -> None) - (fun ((), b, r) -> View (New_tezos_head (b, r))); - case - (Tag 2) - ~title:"Inject" - (obj1 (req "request" (constant "inject"))) - (function View Inject -> Some () | _ -> None) - (fun () -> View Inject); - ] - - let pp ppf (View r) = - match r with - | Add_pending op -> - Format.fprintf ppf "request add %a to pending queue" L1_operation.pp op - | New_tezos_head ((block, level), r) -> - Format.fprintf - ppf - "switching to new Tezos head %a at level %ld" - Block_hash.pp - block - level ; - if r.old_chain <> [] || r.new_chain <> [] then - Format.fprintf - ppf - ", with reorg of -%d +%d" - (List.length r.old_chain) - (List.length r.new_chain) - | Inject -> Format.fprintf ppf "injection" -end - -module Name = struct - type t = Signature.public_key_hash - - let encoding = Tezos_crypto.Signature.Public_key_hash.encoding - - let base = ["injector"] - - let pp = Tezos_crypto.Signature.Public_key_hash.pp_short - - let equal = Tezos_crypto.Signature.Public_key_hash.equal -end diff --git a/src/proto_016_PtMumbai/lib_sc_rollup/dune b/src/proto_016_PtMumbai/lib_sc_rollup/dune index 1a91e3e074f9..4903349cc762 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup/dune @@ -11,7 +11,7 @@ tezos-protocol-plugin-016-PtMumbai tezos-protocol-016-PtMumbai.parameters tezos-rpc - tezos-injector-016-PtMumbai) + octez-injector) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) (library_flags (:standard -linkall)) @@ -21,4 +21,4 @@ -open Tezos_protocol_016_PtMumbai -open Tezos_protocol_plugin_016_PtMumbai -open Tezos_protocol_016_PtMumbai_parameters - -open Tezos_injector_016_PtMumbai)) + -open Octez_injector)) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/dune b/src/proto_016_PtMumbai/lib_sc_rollup_node/dune index 9f035473e51a..39af64145882 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/dune @@ -33,7 +33,7 @@ irmin aches aches-lwt - tezos-injector-016-PtMumbai + octez-injector tezos-scoru-wasm tezos-scoru-wasm-fast tezos-crypto-dal @@ -57,5 +57,5 @@ -open Tezos_smart_rollup_016_PtMumbai -open Tezos_layer2_utils_016_PtMumbai -open Tezos_layer2_store - -open Tezos_injector_016_PtMumbai + -open Octez_injector -open Tezos_crypto_dal)) diff --git a/src/proto_alpha/lib_injector/disk_persistence.ml b/src/proto_alpha/lib_injector/disk_persistence.ml deleted file mode 100644 index e31f9ca0b66d..000000000000 --- a/src/proto_alpha/lib_injector/disk_persistence.ml +++ /dev/null @@ -1,395 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -type error += - | Cannot_write_file of string - | Cannot_create_dir of string - | Cannot_delete_file of string - | Cannot_read_file of string - | Io_error of [`Close | `Open] Lwt_utils_unix.io_error - | Unix_error of Unix.error - | Decoding_error of Data_encoding.Binary.read_error - -let () = - register_error_kind - ~id:"rollups.injector.cannot_write_file" - ~title:"Cannot write file" - ~description:"An element for a persistent table could not be written" - ~pp:(fun ppf s -> - Format.fprintf ppf "The persistent element %s could not be written" s) - `Temporary - Data_encoding.(obj1 (req "file" string)) - (function Cannot_write_file s -> Some s | _ -> None) - (fun s -> Cannot_write_file s) ; - register_error_kind - ~id:"rollups.injector.cannot_create_dir" - ~title:"Cannot create directory" - ~description:"Directory for persistent data structure could not be created" - ~pp:(fun ppf s -> - Format.fprintf - ppf - "Directory %s for persistent data structure could not be created" - s) - `Temporary - Data_encoding.(obj1 (req "directory" string)) - (function Cannot_create_dir s -> Some s | _ -> None) - (fun s -> Cannot_create_dir s) ; - register_error_kind - ~id:"rollups.injector.cannot_delete_file" - ~title:"Cannot delete file" - ~description:"An element for a persistent table could not be deleted" - ~pp:(fun ppf s -> - Format.fprintf ppf "The persistent element %s could not be deleted" s) - `Temporary - Data_encoding.(obj1 (req "file" string)) - (function Cannot_delete_file s -> Some s | _ -> None) - (fun s -> Cannot_delete_file s) ; - register_error_kind - ~id:"rollups.injector.cannot_read_file" - ~title:"Cannot read file" - ~description:"A file for a persistent element could not be read" - ~pp:(fun ppf s -> - Format.fprintf ppf "The persistent element %s could not be read" s) - `Temporary - Data_encoding.(obj1 (req "file" string)) - (function Cannot_read_file s -> Some s | _ -> None) - (fun s -> Cannot_read_file s) ; - register_error_kind - ~id:"rollups.injector.io_error" - ~title:"IO error" - ~description:"IO error" - ~pp:(fun ppf (_action, unix_code, caller, arg) -> - Format.fprintf - ppf - "IO error in %s(%s): %s)" - caller - arg - (Unix.error_message unix_code)) - `Temporary - Data_encoding.( - obj4 - (req "action" (string_enum [("close", `Close); ("open", `Open)])) - (req "unix_code" Tezos_stdlib_unix.Unix_error.encoding) - (req "caller" string) - (req "arg" string)) - (function - | Io_error Lwt_utils_unix.{action; unix_code; caller; arg} -> - Some (action, unix_code, caller, arg) - | _ -> None) - (fun (action, unix_code, caller, arg) -> - Io_error Lwt_utils_unix.{action; unix_code; caller; arg}) ; - register_error_kind - ~id:"rollups.injector.unix_error" - ~title:"Unix error" - ~description:"Unix error" - ~pp:(fun ppf error -> - Format.fprintf ppf "Unix error: %s" (Unix.error_message error)) - `Temporary - Data_encoding.(obj1 (req "error" Tezos_stdlib_unix.Unix_error.encoding)) - (function Unix_error e -> Some e | _ -> None) - (fun e -> Unix_error e) ; - register_error_kind - ~id:"rollups.injector.decoding_error" - ~title:"Cannot decode file" - ~description:"A file for a persistent element could not be decoded" - ~pp:(fun ppf error -> - Format.fprintf - ppf - "Decoding error: %a" - Data_encoding.Json.pp - (Data_encoding.Json.construct - Data_encoding.Binary.read_error_encoding - error)) - `Permanent - Data_encoding.(obj1 (req "error" Data_encoding.Binary.read_error_encoding)) - (function Decoding_error e -> Some e | _ -> None) - (fun e -> Decoding_error e) ; - () - -module type H = sig - include Hashtbl.SeededS - - type value - - val name : string - - val string_of_key : key -> string - - val key_of_string : string -> key option - - val value_encoding : value Data_encoding.t -end - -let create_dir dir = - trace (Cannot_create_dir dir) - @@ protect - @@ fun () -> - let open Lwt_result_syntax in - let*! () = Lwt_utils_unix.create_dir dir in - return_unit - -let read_value file encoding = - let open Lwt_syntax in - trace (Cannot_read_file file) - @@ Lwt.catch - (fun () -> - Lwt_io.with_file ~flags:[Unix.O_RDONLY; O_CLOEXEC] ~mode:Input file - @@ fun channel -> - let+ bytes = Lwt_io.read channel in - Result.map_error (fun e -> [Decoding_error e]) - @@ Data_encoding.Binary.of_bytes - encoding - (Bytes.unsafe_of_string bytes)) - (function - | Unix.Unix_error (e, _, _) -> fail (Unix_error e) | e -> fail (Exn e)) - -let maybe_read_value ~warn file encoding = - let open Lwt_syntax in - let* v = read_value file encoding in - match v with - | Error e -> - let+ () = warn file e in - None - | Ok v -> return_some v - -let write_value file encoding value = - trace (Cannot_write_file file) - @@ protect - @@ fun () -> - Lwt_result.map_error (fun e -> [Io_error e]) - @@ Lwt_utils_unix.with_open_out ~overwrite:true file - @@ fun fd -> - let block_bytes = Data_encoding.Binary.to_bytes_exn encoding value in - Lwt_utils_unix.write_bytes fd block_bytes - -let delete_file file = - trace (Cannot_delete_file file) - @@ protect - @@ fun () -> - let open Lwt_result_syntax in - let*! () = Lwt_unix.unlink file in - return_unit - -module Make_table (H : H) = struct - type key = H.key - - type value = H.value - - type t = {path : string; table : value H.t} - - let filedata t k = Filename.concat t.path (H.string_of_key k) - - let create ~data_dir n = - let open Lwt_result_syntax in - let table = H.create n in - let path = Filename.concat data_dir H.name in - let+ () = create_dir path in - {path; table} - - let replace t k v = - H.replace t.table k v ; - write_value (filedata t k) H.value_encoding v - - let remove t k = - H.remove t.table k ; - delete_file (filedata t k) - - let find t k = H.find t.table k - - let mem t k = H.mem t.table k - - let iter_s f t = H.iter_s f t.table - - let iter_es f t = H.iter_es f t.table - - let length t = H.length t.table - - let replace_seq t seq = - H.replace_seq t.table seq ; - Seq.iter_es - (fun (k, v) -> write_value (filedata t k) H.value_encoding v) - seq - - let load_from_disk ~warn_unreadable ~initial_size ~data_dir ~filter = - let open Lwt_result_syntax in - let* t = create ~data_dir initial_size in - let*! d = Lwt_unix.opendir t.path in - let rec browse () = - let*! filename = - let open Lwt_syntax in - Lwt.catch - (fun () -> - let+ f = Lwt_unix.readdir d in - Some f) - (function End_of_file -> return_none | e -> raise e) - in - match filename with - | None -> return_unit - | Some filename -> - let* () = - match H.key_of_string filename with - | None -> return_unit - | Some k -> ( - let+ v = - match warn_unreadable with - | None -> - let+ v = read_value (filedata t k) H.value_encoding in - Some v - | Some warn -> - let*! v = - maybe_read_value ~warn (filedata t k) H.value_encoding - in - return v - in - match v with - | None -> () - | Some v -> if filter v then H.add t.table k v) - in - browse () - in - let+ () = browse () in - t -end - -module Make_queue (N : sig - val name : string -end) -(K : Tezos_crypto.Intfs.HASH) (V : sig - type t - - val encoding : t Data_encoding.t -end) = -struct - module Q = Hash_queue.Make (K) (V) - - type t = {path : string; metadata_path : string; queue : Q.t} - - let counter = ref min_int - - let filedata q k = Filename.concat q.path (K.to_b58check k) - - let filemetadata q k = Filename.concat q.metadata_path (K.to_b58check k) - - let create ~data_dir n = - let open Lwt_result_syntax in - let queue = Q.create n in - let path = Filename.concat data_dir N.name in - let metadata_path = Filename.concat path "metadata" in - let* () = create_dir path in - let+ () = create_dir metadata_path in - {path; metadata_path; queue} - - let remove q k = - let open Lwt_result_syntax in - Q.remove q.queue k ; - let* () = delete_file (filedata q k) - and* () = delete_file (filemetadata q k) in - return_unit - - let create_metadata () = - let time = Time.System.now () in - let d, ps = Ptime.to_span time |> Ptime.Span.to_d_ps in - let c = !counter in - incr counter ; - (d, ps, c) - - let metadata_encoding = - let open Data_encoding in - conv - (fun (d, ps, c) -> (Int64.of_int d, ps, Int64.of_int c)) - (fun (d, ps, c) -> (Int64.to_int d, ps, Int64.to_int c)) - @@ tup3 int64 int64 int64 - - let replace q k v = - let open Lwt_result_syntax in - Q.replace q.queue k v ; - let* () = write_value (filedata q k) V.encoding v - and* () = - write_value (filemetadata q k) metadata_encoding (create_metadata ()) - in - return_unit - - let fold f q = Q.fold f q.queue - - let length q = Q.length q.queue - - let find_opt q k = Q.find_opt q.queue k - - let load_from_disk ~warn_unreadable ~capacity ~data_dir ~filter = - let open Lwt_result_syntax in - let* q = create ~data_dir capacity in - let*! d = Lwt_unix.opendir q.path in - let rec browse acc = - let*! filename = - let open Lwt_syntax in - Lwt.catch - (fun () -> - let+ f = Lwt_unix.readdir d in - Some f) - (function End_of_file -> return_none | e -> raise e) - in - match filename with - | None -> return acc - | Some filename -> - let* acc = - match K.of_b58check_opt filename with - | None -> return acc - | Some k -> ( - let+ v_meta = - match warn_unreadable with - | None -> - let* v = read_value (filedata q k) V.encoding - and* meta = - read_value (filemetadata q k) metadata_encoding - in - return_some (v, meta) - | Some warn -> - let open Lwt_syntax in - let* v = maybe_read_value ~warn (filedata q k) V.encoding - and* meta = - maybe_read_value - ~warn - (filemetadata q k) - metadata_encoding - in - return_ok @@ Option.bind v - @@ fun v -> Option.bind meta @@ fun meta -> Some (v, meta) - in - match v_meta with - | None -> acc - | Some (v, meta) -> - if filter v then (k, v, meta) :: acc else acc) - in - browse acc - in - let* list = browse [] in - let list = - List.fast_sort - (fun (_, _, meta1) (_, _, meta2) -> Stdlib.compare meta1 meta2) - list - in - List.iter (fun (k, v, _) -> Q.replace q.queue k v) list ; - return q -end diff --git a/src/proto_alpha/lib_injector/disk_persistence.mli b/src/proto_alpha/lib_injector/disk_persistence.mli deleted file mode 100644 index 0245cbe641b8..000000000000 --- a/src/proto_alpha/lib_injector/disk_persistence.mli +++ /dev/null @@ -1,149 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -type error += - | Cannot_write_file of string - | Cannot_create_dir of string - | Cannot_read_file of string - | Io_error of [`Close | `Open] Lwt_utils_unix.io_error - | Unix_error of Unix.error - | Decoding_error of Data_encoding.Binary.read_error - -(** Signature for hash tables with additional information *) -module type H = sig - include Hashtbl.SeededS - - (** Type of values *) - type value - - (** Name used to derive a path (relative to [data_dir] in [load_from_disk]) of - where to store the persistent information for this hash table. *) - val name : string - - (** String version of key (used for filenames). *) - val string_of_key : key -> string - - (** Parse a key. We must have [key_of_string (string_of_key k) = k]. *) - val key_of_string : string -> key option - - (** Encoding for values (only the binary encoding is used *) - val value_encoding : value Data_encoding.t -end - -(** Create an on-disk persistent version of {!Hashtbl}. *) -module Make_table (H : H) : sig - type key = H.key - - type value = H.value - - (** Type of persistent hash tables *) - type t - - (** Persistent version of {!module-type-H.replace} *) - val replace : t -> key -> value -> unit tzresult Lwt.t - - (** Persistent version of {!module-type-H.remove} *) - val remove : t -> key -> unit tzresult Lwt.t - - (** Same as {!module-type-H.find} *) - val find : t -> key -> value option - - (** Same as {!module-type-H.mem} *) - val mem : t -> key -> bool - - (** Same as {!module-type-H.iter_s} *) - val iter_s : (key -> value -> unit Lwt.t) -> t -> unit Lwt.t - - (** Same as {!module-type-H.iter_es} *) - val iter_es : - (key -> value -> unit tzresult Lwt.t) -> t -> unit tzresult Lwt.t - - (** Same as {!module-type-H.length} *) - val length : t -> int - - (** Persistent version of {!module-type-H.replace_seq} *) - val replace_seq : t -> (key * value) Seq.t -> unit tzresult Lwt.t - - (** [load_from_disk ~warn_unreadable ~initial_size ~data_dir] creates a hash - table of size [initial_size]. The hash table is populated by persistent - elements present in [data_dir/H.name] which pass the [filter] (the - directory is created if it does not exist). If [warn_unreadable] is [Some - warn], unreadable files are ignored but a warning is printed with [warn], - otherwise the loading fails on the first unreadable file. *) - val load_from_disk : - warn_unreadable:(string -> error trace -> unit Lwt.t) option -> - initial_size:int -> - data_dir:string -> - filter:(value -> bool) -> - t tzresult Lwt.t -end - -(** Create an on-disk persistent version of the {!Hash_queue} data structure. *) -module Make_queue (N : sig - (** Name used to derive a path (relative to [data_dir] in [load_from_disk]) of where - to store the persistent information for this queue. *) - val name : string -end) -(K : Tezos_crypto.Intfs.HASH) (V : sig - type t - - val encoding : t Data_encoding.t -end) : sig - type t - - (** [remove q k] removes the binding from [k] in [q]. If [k] is not bound in - [c], it does nothing. The removal is persisted on disk. *) - val remove : t -> K.t -> unit tzresult Lwt.t - - (** [replace q k v] binds the key [k] to the value [v] in the queue [q]. This - may or may not cause another binding to be removed, depending on the - number of bindings already present in [q]. The addition (or replacement) - is persisted on disk. *) - val replace : t -> K.t -> V.t -> unit tzresult Lwt.t - - (** [fold f q init] folds the function [f] over the bindings - of [q] (in memory). The elements are iterated from oldest to newest. *) - val fold : (K.t -> V.t -> 'a -> 'a) -> t -> 'a -> 'a - - (** [find_opt q k] is [Some v] if [k] is bound to [v] in [q]. It is [None] - otherwise. *) - val find_opt : t -> K.t -> V.t option - - (** [length q] is the number of bindings held by [q]. *) - val length : t -> int - - (** [load_from_disk ~warn_unreadable ~capacity ~data_dir ~filter] creates a - bounded hash queue of capacity [capacity]. The queue is populated by - persistent elements present in [data_dir/N.name] which pass the [filter] - (the directory is created if it does not exist). If [warn_unreadable] is - [Some warn], unreadable files are ignored but a warning is printed with - [warn], otherwise the loading fails on the first unreadable file. *) - val load_from_disk : - warn_unreadable:(string -> error trace -> unit Lwt.t) option -> - capacity:int -> - data_dir:string -> - filter:(V.t -> bool) -> - t tzresult Lwt.t -end diff --git a/src/proto_alpha/lib_injector/injector_events.ml b/src/proto_alpha/lib_injector/injector_events.ml deleted file mode 100644 index d5cdbecd1b3c..000000000000 --- a/src/proto_alpha/lib_injector/injector_events.ml +++ /dev/null @@ -1,266 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_worker_types -open Injector_sigs - -module Make - (Parameters : PARAMETERS) - (Tags : module type of Injector_tags.Make (Parameters.Tag)) - (Operation : PARAM_OPERATION) - (Inj_operation : INJECTOR_OPERATION with type operation = Operation.t) - (Request : module type of Request (Inj_operation)) = - struct - include Internal_event.Simple - - let section = Parameters.events_section - - let declare_1 ~name ~msg ~level ?pp1 enc1 = - declare_3 - ~section - ~name - ~msg:("[{signer}: {tags}] " ^ msg) - ~level - ("signer", Signature.Public_key_hash.encoding) - ("tags", Tags.encoding) - enc1 - ~pp1:Signature.Public_key_hash.pp_short - ~pp2:Tags.pp - ?pp3:pp1 - - let declare_2 ~name ~msg ~level ?pp1 ?pp2 enc1 enc2 = - declare_4 - ~section - ~name - ~msg:("[{signer}: {tags}] " ^ msg) - ~level - ("signer", Signature.Public_key_hash.encoding) - ("tags", Tags.encoding) - enc1 - enc2 - ~pp1:Signature.Public_key_hash.pp_short - ~pp2:Tags.pp - ?pp3:pp1 - ?pp4:pp2 - - let declare_3 ~name ~msg ~level ?pp1 ?pp2 ?pp3 enc1 enc2 enc3 = - declare_5 - ~section - ~name - ~msg:("[{signer}: {tags}] " ^ msg) - ~level - ("signer", Signature.Public_key_hash.encoding) - ("tags", Tags.encoding) - enc1 - enc2 - enc3 - ~pp1:Signature.Public_key_hash.pp_short - ~pp2:Tags.pp - ?pp3:pp1 - ?pp4:pp2 - ?pp5:pp3 - - let request_failed = - declare_3 - ~name:"request_failed" - ~msg:"request {view} failed ({worker_status}): {errors}" - ~level:Warning - ("view", Request.encoding) - ~pp1:Request.pp - ("worker_status", Worker_types.request_status_encoding) - ~pp2:Worker_types.pp_status - ("errors", Error_monad.trace_encoding) - ~pp3:Error_monad.pp_print_trace - - let request_completed_notice = - declare_2 - ~name:"request_completed_notice" - ~msg:"{view} {worker_status}" - ~level:Notice - ("view", Request.encoding) - ("worker_status", Worker_types.request_status_encoding) - ~pp1:Request.pp - ~pp2:Worker_types.pp_status - - let request_completed_debug = - declare_2 - ~name:"request_completed_debug" - ~msg:"{view} {worker_status}" - ~level:Debug - ("view", Request.encoding) - ("worker_status", Worker_types.request_status_encoding) - ~pp1:Request.pp - ~pp2:Worker_types.pp_status - - let new_tezos_head = - declare_1 - ~name:"new_tezos_head" - ~msg:"processing new Tezos head {head}" - ~level:Debug - ("head", Block_hash.encoding) - - let injecting_pending = - declare_1 - ~name:"injecting_pending" - ~msg:"injecting {count} pending operations" - ~level:Notice - ("count", Data_encoding.int31) - - let pp_operations_list ppf operations = - Format.fprintf - ppf - "@[%a@]" - (Format.pp_print_list Operation.pp) - operations - - let pp_operations_hash_list ppf operations = - Format.fprintf - ppf - "@[%a@]" - (Format.pp_print_list Inj_operation.Hash.pp) - operations - - let number_of_operations_in_queue = - declare_1 - ~name:"number_of_operations_in_queue" - ~msg: - "injector's queue: there is currently {number_of_operations} \ - operations waiting to be injected" - ~level:Info - ("number_of_operations", Data_encoding.int31) - - let considered_operations_info = - declare_1 - ~name:"considered_operations_info" - ~msg: - "injector's queue: the following operations are being considered \ - for injection {operations}" - ~level:Debug - ("operations", Data_encoding.list Operation.encoding) - ~pp1:pp_operations_list - - let dropped_operations = - declare_1 - ~name:"dropped_operations" - ~msg: - "dropping operations: the following operations are dropped \ - {operations}" - ~level:Debug - ("operations", Data_encoding.list Operation.encoding) - ~pp1:pp_operations_list - - let simulating_operations = - declare_2 - ~name:"simulating_operations" - ~msg:"simulating operations (force = {force}): {operations}" - ~level:Debug - ("operations", Data_encoding.list Operation.encoding) - ("force", Data_encoding.bool) - ~pp1:pp_operations_list - - let dropping_operation = - declare_2 - ~name:"dropping_operation" - ~msg:"dropping operation {operation} failing with {error}" - ~level:Notice - ("operation", Operation.encoding) - ~pp1:Operation.pp - ("error", Error_monad.trace_encoding) - ~pp2:Error_monad.pp_print_trace - - let injected = - declare_2 - ~name:"injected" - ~msg:"injected {nb} operations in {oph}" - ~level:Notice - ("nb", Data_encoding.int31) - ("oph", Operation_hash.encoding) - - let add_pending = - declare_1 - ~name:"add_pending" - ~msg:"add {operation} to pending" - ~level:Notice - ("operation", Operation.encoding) - ~pp1:Operation.pp - - let retry_operation = - declare_1 - ~name:"retry_operation" - ~msg:"retry {operation}" - ~level:Notice - ("operation", Operation.encoding) - ~pp1:Operation.pp - - let included = - declare_3 - ~name:"included" - ~msg:"included operations of {block} at level {level}: {operations}" - ~level:Notice - ("block", Block_hash.encoding) - ("level", Data_encoding.int32) - ("operations", Data_encoding.list Inj_operation.Hash.encoding) - ~pp3:pp_operations_hash_list - - let revert_operations = - declare_1 - ~name:"revert_operations" - ~msg:"reverting operations: {operations}" - ~level:Notice - ("operations", Data_encoding.list Inj_operation.Hash.encoding) - ~pp1:pp_operations_hash_list - - let confirmed_level = - declare_1 - ~name:"confirmed_level" - ~msg:"confirmed Tezos level {level}" - ~level:Notice - ("level", Data_encoding.int32) - - let loaded_from_disk = - declare_2 - ~name:"loaded_from_disk" - ~msg:"loaded {nb} elements in {kind} from disk" - ~level:Notice - ("nb", Data_encoding.int31) - ("kind", Data_encoding.string) - - let corrupted_operation_on_disk = - declare_2 - ~name:"corrupted_operation_on_disk" - ~msg:"ignoring unreadable file {file} on disk: {error}" - ~level:Warning - ("file", Data_encoding.string) - ("error", Error_monad.trace_encoding) - ~pp1:Format.pp_print_string - ~pp2:Error_monad.pp_print_trace - - let inject_wait = - declare_1 - ~name:"inject_wait" - ~msg:"waiting {delay} seconds to trigger injection" - ~level:Notice - ("delay", Data_encoding.float) - end diff --git a/src/proto_alpha/lib_injector/injector_functor.mli b/src/proto_alpha/lib_injector/injector_functor.mli deleted file mode 100644 index ab5786a67469..000000000000 --- a/src/proto_alpha/lib_injector/injector_functor.mli +++ /dev/null @@ -1,36 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_sigs - -module Make - (P : PARAMETERS) - (_ : PROTOCOL_CLIENT - with type state := P.state - and type operation := P.Operation.t) : - S - with type state := P.state - and type tag := P.Tag.t - and type operation := P.Operation.t diff --git a/src/proto_alpha/lib_injector/injector_operation.ml b/src/proto_alpha/lib_injector/injector_operation.ml deleted file mode 100644 index b3738be6ba84..000000000000 --- a/src/proto_alpha/lib_injector/injector_operation.ml +++ /dev/null @@ -1,68 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_sigs - -module Make (O : PARAM_OPERATION) : - INJECTOR_OPERATION with type operation = O.t = struct - module Hash = - Tezos_crypto.Blake2B.Make - (Tezos_crypto.Base58) - (struct - let name = "injector_operation_hash" - - let title = "An identifier (hash) for an operation in the injector" - - let b58check_prefix = "\064\007\206" (* iop(53) *) - - let size = None - end) - - let () = - Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "iop" 53 - - type operation = O.t - - type hash = Hash.t - - type t = {hash : hash; operation : O.t} - - let hash_inner_operation op = - Hash.hash_bytes [Data_encoding.Binary.to_bytes_exn O.encoding op] - - let make operation = - let hash = hash_inner_operation operation in - {hash; operation} - - let encoding = - let open Data_encoding in - conv - (fun {hash; operation} -> (hash, operation)) - (fun (hash, operation) -> {hash; operation}) - @@ obj2 (req "hash" Hash.encoding) (req "operation" O.encoding) - - let pp ppf {hash; operation} = - Format.fprintf ppf "%a (%a)" O.pp operation Hash.pp hash -end diff --git a/src/proto_alpha/lib_injector/injector_operation.mli b/src/proto_alpha/lib_injector/injector_operation.mli deleted file mode 100644 index 97f9eadd65a5..000000000000 --- a/src/proto_alpha/lib_injector/injector_operation.mli +++ /dev/null @@ -1,28 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_sigs - -module Make (O : PARAM_OPERATION) : INJECTOR_OPERATION with type operation = O.t diff --git a/src/proto_alpha/lib_injector/injector_sigs.ml b/src/proto_alpha/lib_injector/injector_sigs.ml deleted file mode 100644 index 684606ad49fc..000000000000 --- a/src/proto_alpha/lib_injector/injector_sigs.ml +++ /dev/null @@ -1,325 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -type tez = {mutez : int64} - -type fee_parameter = { - minimal_fees : tez; - minimal_nanotez_per_byte : Q.t; - minimal_nanotez_per_gas_unit : Q.t; - force_low_fee : bool; - fee_cap : tez; - burn_cap : tez; -} - -type injection_strategy = - [ `Each_block (** Inject pending operations after each new L1 block *) - | `Delay_block of float - (** [`Delay_block f] strategy waits for [f] * the next block time to be - elapsed before injecting pending operations. This strategy allows for - maximizing the number of the same kind of operations to include in a - block. *) - ] - -(** Explanation for unsuccessful operations (that are included in a block). *) -type unsuccessful_status = - | Other_branch - (** The operation is included in a block that is not on the main chain - anymore, because of a reorganization. *) - | Backtracked - (** The operation is backtracked because of a further failing operation in - the same batch. *) - | Skipped - (** The operation is skipped because of a previous failing operation in - the same batch. *) - | Failed of error trace (** The operation failed with the provided error. *) - -type operation_status = Successful | Unsuccessful of unsuccessful_status - -type simulation_status = {index_in_batch : int; status : operation_status} - -type 'unsigned_op simulation_result = { - operations_statuses : simulation_status list; - unsigned_operation : 'unsigned_op; -} - -(** Action to be taken for unsuccessful operation. *) -type retry_action = - | Retry (** The operation is retried by being re-queued for injection. *) - | Forget (** The operation is forgotten without error. *) - | Abort of error trace - (** The error for the failing operation should be propagated at a higher - level. *) - -(** Signature for tags used in injector *) -module type TAG = sig - include Stdlib.Set.OrderedType - - include Stdlib.Hashtbl.HashedType with type t := t - - val pp : Format.formatter -> t -> unit - - val encoding : t Data_encoding.t -end - -module type PARAM_OPERATION = sig - (** The abstract type of operations to inject *) - type t - - (** An encoding for injector's operations *) - val encoding : t Data_encoding.t - - (** Pretty-printing injector's operations *) - val pp : Format.formatter -> t -> unit -end - -(** Internal representation of injector operations. *) -module type INJECTOR_OPERATION = sig - type operation - - (** Hash with b58check encoding iop(53), for hashes of injector operations *) - module Hash : Tezos_crypto.Intfs.HASH - - (** Alias for L1 operations hashes *) - type hash = Hash.t - - (** The type of L1 operations that are injected on Tezos. These have a hash - attached to them that allows tracking and retrieving their status. *) - type t = private {hash : hash; operation : operation} - - (** [make op] returns an L1 operation with the corresponding hash. *) - val make : operation -> t - - (** Encoding for L1 operations *) - val encoding : t Data_encoding.t - - (** Pretty printer for L1 operations. Only the relevant part for the rollup node - is printed. *) - val pp : Format.formatter -> t -> unit -end - -(** Module type for parameter of functor {!Injector_functor.Make}. *) -module type PARAMETERS = sig - (** The type of the state that the injector can access *) - type state - - (** A module which contains the different tags for the injector *) - module Tag : TAG - - (** A module for the injector operations *) - module Operation : PARAM_OPERATION - - (** Where to put the events for this injector *) - val events_section : string list - - (** Coarse approximation for the number of operation of each tag we expect to - inject for each block. *) - val table_estimated_size : Tag.t -> int - - (** Action (see {!retry_action}) to be taken on unsuccessful operation (see - {!unsuccessful_status}). *) - val retry_unsuccessful_operation : - state -> Operation.t -> unsuccessful_status -> retry_action Lwt.t - - (** The tag of a manager operation. This is used to send operations to the - correct queue automatically (when signer is not provided) and to recover - persistent information. *) - val operation_tag : Operation.t -> Tag.t - - (** Returns the fee_parameter (to compute fee w.r.t. gas, size, etc.) and the - caps of fee and burn for each operation. *) - val fee_parameter : state -> Operation.t -> fee_parameter - - (** When injecting the given [operations] in an L1 batch, if - [batch_must_succeed operations] returns [`All] then all the operations must - succeed in the simulation of injection. If it returns [`At_least_one], at - least one operation in the list [operations] must be successful in the - simulation. In any case, only operations which are known as successful will - be included in the injected L1 batch. {b Note}: Returning [`At_least_one] - allows to incrementally build "or-batches" by iteratively removing - operations that fail from the desired batch. *) - val batch_must_succeed : Operation.t list -> [`All | `At_least_one] -end - -module type PROTOCOL_CLIENT = sig - type state - - type operation - - type unsigned_operation - - val max_operation_data_length : int - - (** The validation pass of manager operations. *) - val manager_pass : int - - (** [operation_status block oph ~index] returns the status of the operation at - position [index] in the L1 batch [oph] included in the block [block]. It - returns [None] if the operation with the given index is not in the - block. *) - val operation_status : - state -> - Block_hash.t -> - Operation_hash.t -> - index:int -> - operation_status option tzresult Lwt.t - - (** Size of an operation in bytes according to the protocol. This only - accounts for the actual content of the corresponding manager operation - (and not its fees, gas, etc.). *) - val operation_size : operation -> int - - (** An upper bound of the overhead added to manager operations in - bytes. Typically, this would include the source, fees, counter, gas limit, - and storage limit. *) - val operation_size_overhead : int - - (** Simulating a batch of operations. This function returns the simulation - result for each of these operations (with its associated index in the - batch, in case there is a revelation operation added) together with a - Tezos raw unsigned operation that can be directly injected on a node if - one wishes to. *) - val simulate_operations : - #Client_context.full -> - force:bool -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> - successor_level:bool -> - fee_parameter:fee_parameter -> - operation list -> - ( unsigned_operation simulation_result, - [`Exceeds_quotas of tztrace | `TzError of tztrace] ) - result - Lwt.t - - (** Sign an unsigned operation an return the serialized signed operation, - ready for injection. *) - val sign_operation : - #Client_context.full -> - Client_keys.sk_uri -> - unsigned_operation -> - bytes tzresult Lwt.t - - (** [time_until_next_block state block_header] computes the time until the - block following [block_header], with respect to the current time. *) - val time_until_next_block : - state -> Tezos_base.Block_header.t option -> Ptime.span -end - -(** Output signature for functor {!Injector_functor.Make}. *) -module type S = sig - type state - - type tag - - type operation - - module Inj_operation : INJECTOR_OPERATION with type operation = operation - - (** Information stored about an L1 operation that was injected on a Tezos - node. *) - type injected_info = { - op : Inj_operation.t; (** The injector operation. *) - oph : Operation_hash.t; - (** The hash of the operation which contains [op] (this can be an L1 batch - of several manager operations). *) - op_index : int; - (** The index of the operation [op] in the L1 batch corresponding to [oph]. *) - } - - (** Information stored about an L1 operation that was included in a Tezos - block. *) - type included_info = { - op : Inj_operation.t; (** The injector operation. *) - oph : Operation_hash.t; - (** The hash of the operation which contains [op] (this can be an L1 batch - of several manager operations). *) - op_index : int; - (** The index of the operation [op] in the L1 batch corresponding to [oph]. *) - l1_block : Block_hash.t; - (** The hash of the L1 block in which the operation was included. *) - l1_level : int32; (** The level of [l1_block]. *) - } - - (** Status of an operation in the injector. *) - type status = - | Pending of operation (** The operation is pending injection. *) - | Injected of injected_info - (** The operation has been injected successfully in the node. *) - | Included of included_info - (** The operation has been included in a L1 block. *) - - val injected_info_encoding : injected_info Data_encoding.t - - val included_info_encoding : included_info Data_encoding.t - - (** Initializes the injector with the rollup node state, for a list of - signers, and start the workers. Each signer has its own worker with a - queue of operations to inject. - - [retention_period] is the number of blocks for which the injector keeps - the included information for, must be positive or zero. By default (when - [0]), the injector will not keep information longer than necessary. It can - be useful to set this value to something [> 0] if we want to retrieve - information about operations included on L1 for a given period. *) - val init : - #Client_context.full -> - data_dir:string -> - ?retention_period:int -> - state -> - signers:(Signature.public_key_hash * injection_strategy * tag list) list -> - unit tzresult Lwt.t - - (** Add an operation as pending injection in the injector. If the source is - not provided, the operation is queued to the worker which handles the - corresponding tag. It returns the hash of the operation in the injector - queue. *) - val add_pending_operation : - ?source:Signature.public_key_hash -> - operation -> - Inj_operation.Hash.t tzresult Lwt.t - - (** Notify the injector of a new Tezos head. The injector marks the operations - appropriately (for instance reverted operations that are part of a - reorganization are put back in the pending queue). When an operation is - considered as {e confirmed}, it disappears from the injector. *) - val new_tezos_head : - Block_hash.t * int32 -> - (Block_hash.t * int32) Injector_common.reorg -> - unit Lwt.t - - (** Trigger an injection of the pending operations for all workers. If [tags] - is given, only the workers which have a tag in [tags] inject their pending - operations. [header] must be provided for the [`Delay_block] strategy to - compute the next block timestamp. *) - val inject : - ?tags:tag list -> ?header:Tezos_base.Block_header.t -> unit -> unit Lwt.t - - (** Shutdown the injectors, waiting for the ongoing request to be processed. *) - val shutdown : unit -> unit Lwt.t - - (** The status of an operation in the injector. *) - val operation_status : Inj_operation.Hash.t -> status option -end diff --git a/src/proto_alpha/lib_injector/injector_tags.ml b/src/proto_alpha/lib_injector/injector_tags.ml deleted file mode 100644 index 1e92ff5de2cb..000000000000 --- a/src/proto_alpha/lib_injector/injector_tags.ml +++ /dev/null @@ -1,39 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Make (Tag : Injector_sigs.TAG) = struct - include Set.Make (Tag) - - let pp ppf tags = - Format.pp_print_list - ~pp_sep:(fun ppf () -> Format.fprintf ppf ",@ ") - Tag.pp - ppf - (elements tags) - - let encoding = - let open Data_encoding in - conv elements of_list (list Tag.encoding) -end diff --git a/src/proto_alpha/lib_injector/injector_tags.mli b/src/proto_alpha/lib_injector/injector_tags.mli deleted file mode 100644 index 9efa6842376a..000000000000 --- a/src/proto_alpha/lib_injector/injector_tags.mli +++ /dev/null @@ -1,35 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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. *) -(* *) -(*****************************************************************************) - -(** Make a set of tags given a module for tags. *) -module Make (Tag : Injector_sigs.TAG) : sig - include Set.S with type elt = Tag.t - - (** Pretty print a set of tags *) - val pp : Format.formatter -> t -> unit - - (** Encoding for sets of tags *) - val encoding : t Data_encoding.t -end diff --git a/src/proto_alpha/lib_injector/injector_worker_types.mli b/src/proto_alpha/lib_injector/injector_worker_types.mli deleted file mode 100644 index 1f70c5a48df0..000000000000 --- a/src/proto_alpha/lib_injector/injector_worker_types.mli +++ /dev/null @@ -1,45 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 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 Injector_common -open Injector_sigs - -module Request (Inj_operation : INJECTOR_OPERATION) : sig - type ('a, 'b) t = - | Add_pending : Inj_operation.t -> (unit, error trace) t - | New_tezos_head : - (Block_hash.t * int32) * (Block_hash.t * int32) reorg - -> (unit, error trace) t - | Inject : (unit, error trace) t - - type view = View : _ t -> view - - include - Worker_intf.REQUEST - with type ('a, 'request_error) t := ('a, 'request_error) t - and type view := view -end - -module Name : Worker_intf.NAME with type t = Signature.public_key_hash diff --git a/src/proto_alpha/lib_sc_rollup/dune b/src/proto_alpha/lib_sc_rollup/dune index 7eeca0d6858e..99132fbc73a3 100644 --- a/src/proto_alpha/lib_sc_rollup/dune +++ b/src/proto_alpha/lib_sc_rollup/dune @@ -11,7 +11,7 @@ tezos-protocol-plugin-alpha tezos-protocol-alpha.parameters tezos-rpc - tezos-injector-alpha) + octez-injector) (inline_tests (flags -verbose) (modes native)) (preprocess (pps ppx_expect)) (library_flags (:standard -linkall)) @@ -21,4 +21,4 @@ -open Tezos_protocol_alpha -open Tezos_protocol_plugin_alpha -open Tezos_protocol_alpha_parameters - -open Tezos_injector_alpha)) + -open Octez_injector)) diff --git a/src/proto_alpha/lib_sc_rollup_node/dune b/src/proto_alpha/lib_sc_rollup_node/dune index 2be8511c7df6..a4aed89c1e3c 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dune +++ b/src/proto_alpha/lib_sc_rollup_node/dune @@ -33,7 +33,7 @@ irmin aches aches-lwt - tezos-injector-alpha + octez-injector tezos-scoru-wasm tezos-scoru-wasm-fast tezos-crypto-dal @@ -57,5 +57,5 @@ -open Tezos_smart_rollup_alpha -open Tezos_layer2_utils_alpha -open Tezos_layer2_store - -open Tezos_injector_alpha + -open Octez_injector -open Tezos_crypto_dal)) -- GitLab