From 07a4e69acc1b7748a4a20430db92ca38c3751038 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Tue, 9 Aug 2022 11:38:26 +0100 Subject: [PATCH 1/5] Proto/Dal: expose type equalities for Slot header --- src/lib_crypto_dal/cryptobox.mli | 11 +++++++++-- src/lib_protocol_environment/environment_V7.ml | 1 + src/lib_protocol_environment/environment_V7.mli | 1 + src/proto_alpha/lib_protocol/alpha_context.mli | 2 +- src/proto_alpha/lib_protocol/dal_slot_repr.mli | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib_crypto_dal/cryptobox.mli b/src/lib_crypto_dal/cryptobox.mli index 90fdcb513fa5..0694fb1eac42 100644 --- a/src/lib_crypto_dal/cryptobox.mli +++ b/src/lib_crypto_dal/cryptobox.mli @@ -59,9 +59,16 @@ type t that both the [Verifier] and the [Builder] are instantiated with the same parameters and use the same trusted setup. *) -module Verifier : VERIFIER with type parameters = parameters +type commitment -include VERIFIER with type t := t and type parameters := parameters +module Verifier : + VERIFIER with type parameters = parameters and type commitment = commitment + +include + VERIFIER + with type t := t + and type parameters := parameters + and type commitment := commitment (** The primitives exposed in this modules require some preprocessing. This preprocessing generates data from an unknown diff --git a/src/lib_protocol_environment/environment_V7.ml b/src/lib_protocol_environment/environment_V7.ml index 4530ec20f80d..3104040d509a 100644 --- a/src/lib_protocol_environment/environment_V7.ml +++ b/src/lib_protocol_environment/environment_V7.ml @@ -100,6 +100,7 @@ module type T = sig Plonk.Main_protocol.verifier_public_parameters * Plonk.Main_protocol.transcript and type Dal.parameters = Tezos_crypto_dal.Cryptobox.Verifier.parameters + and type Dal.commitment = Tezos_crypto_dal.Cryptobox.commitment type error += Ecoproto_error of Error_monad.error diff --git a/src/lib_protocol_environment/environment_V7.mli b/src/lib_protocol_environment/environment_V7.mli index 2606546d63ff..cb2e600b44d1 100644 --- a/src/lib_protocol_environment/environment_V7.mli +++ b/src/lib_protocol_environment/environment_V7.mli @@ -100,6 +100,7 @@ module type T = sig Plonk.Main_protocol.verifier_public_parameters * Plonk.Main_protocol.transcript and type Dal.parameters = Tezos_crypto_dal.Cryptobox.Verifier.parameters + and type Dal.commitment = Tezos_crypto_dal.Cryptobox.commitment (** An [Ecoproto_error e] is a shell error that carry a protocol error. diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 88edffccba01..2816cf47d67b 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2799,7 +2799,7 @@ module Dal : sig end module Slot : sig - type header + type header = Dal.commitment type t = {level : Raw_level.t; index : Slot_index.t; header : header} diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli index 9d8ce16eed6e..7dd3e921990c 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.mli @@ -47,7 +47,7 @@ portion of the initial slot. *) module Header : sig - type t + type t = Dal.commitment val encoding : t Data_encoding.t end -- GitLab From 28bdf021ed266cb1c1d3c963fa79f7f29967d02f Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 8 Aug 2022 17:46:24 +0100 Subject: [PATCH 2/5] Scoru/Manifest: add dependency to dal node services --- manifest/main.ml | 1 + opam/tezos-sc-rollup-node-013-PtJakart.opam | 1 + opam/tezos-sc-rollup-node-014-PtKathma.opam | 1 + opam/tezos-sc-rollup-node-alpha.opam | 1 + src/proto_013_PtJakart/bin_sc_rollup_node/dune | 1 + src/proto_014_PtKathma/bin_sc_rollup_node/dune | 1 + src/proto_alpha/bin_sc_rollup_node/dune | 1 + 7 files changed, 7 insertions(+) diff --git a/manifest/main.ml b/manifest/main.ml index edb6d44c3554..b895b0ffbe3e 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4497,6 +4497,7 @@ module Protocol = Protocol octez_rpc |> open_; octez_rpc_http; octez_rpc_http_server; + octez_dal_node_services; octez_shell_services |> open_; sc_rollup |> if_some |> open_; data_encoding; diff --git a/opam/tezos-sc-rollup-node-013-PtJakart.opam b/opam/tezos-sc-rollup-node-013-PtJakart.opam index e5254f46a7f5..831b36c09c99 100644 --- a/opam/tezos-sc-rollup-node-013-PtJakart.opam +++ b/opam/tezos-sc-rollup-node-013-PtJakart.opam @@ -21,6 +21,7 @@ depends: [ "tezos-rpc" "tezos-rpc-http" "tezos-rpc-http-server" + "tezos-dal-node-services" "tezos-shell-services" "tezos-sc-rollup-013-PtJakart" "data-encoding" { >= "0.6" & < "0.7" } diff --git a/opam/tezos-sc-rollup-node-014-PtKathma.opam b/opam/tezos-sc-rollup-node-014-PtKathma.opam index 6aa273d7bf3c..acbb61d074e6 100644 --- a/opam/tezos-sc-rollup-node-014-PtKathma.opam +++ b/opam/tezos-sc-rollup-node-014-PtKathma.opam @@ -21,6 +21,7 @@ depends: [ "tezos-rpc" "tezos-rpc-http" "tezos-rpc-http-server" + "tezos-dal-node-services" "tezos-shell-services" "tezos-sc-rollup-014-PtKathma" "data-encoding" { >= "0.6" & < "0.7" } diff --git a/opam/tezos-sc-rollup-node-alpha.opam b/opam/tezos-sc-rollup-node-alpha.opam index 689cfb3d4529..e35d2004adc6 100644 --- a/opam/tezos-sc-rollup-node-alpha.opam +++ b/opam/tezos-sc-rollup-node-alpha.opam @@ -21,6 +21,7 @@ depends: [ "tezos-rpc" "tezos-rpc-http" "tezos-rpc-http-server" + "tezos-dal-node-services" "tezos-shell-services" "tezos-sc-rollup-alpha" "data-encoding" { >= "0.6" & < "0.7" } diff --git a/src/proto_013_PtJakart/bin_sc_rollup_node/dune b/src/proto_013_PtJakart/bin_sc_rollup_node/dune index 5604e9d4a02c..f43081102809 100644 --- a/src/proto_013_PtJakart/bin_sc_rollup_node/dune +++ b/src/proto_013_PtJakart/bin_sc_rollup_node/dune @@ -21,6 +21,7 @@ tezos-rpc tezos-rpc-http tezos-rpc-http-server + tezos_dal_node_services tezos-shell-services tezos-sc-rollup-013-PtJakart data-encoding diff --git a/src/proto_014_PtKathma/bin_sc_rollup_node/dune b/src/proto_014_PtKathma/bin_sc_rollup_node/dune index 8226a088f10f..32b2d4c52b52 100644 --- a/src/proto_014_PtKathma/bin_sc_rollup_node/dune +++ b/src/proto_014_PtKathma/bin_sc_rollup_node/dune @@ -21,6 +21,7 @@ tezos-rpc tezos-rpc-http tezos-rpc-http-server + tezos_dal_node_services tezos-shell-services tezos-sc-rollup-014-PtKathma data-encoding diff --git a/src/proto_alpha/bin_sc_rollup_node/dune b/src/proto_alpha/bin_sc_rollup_node/dune index f0d7fbdc4f4b..09ab2bdbf08f 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dune +++ b/src/proto_alpha/bin_sc_rollup_node/dune @@ -21,6 +21,7 @@ tezos-rpc tezos-rpc-http tezos-rpc-http-server + tezos_dal_node_services tezos-shell-services tezos-sc-rollup-alpha data-encoding -- GitLab From 70b22d0962994e6eda4dc793febc70ad51dff9bf Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 8 Aug 2022 11:06:32 +0100 Subject: [PATCH 3/5] Dal/rollup node: configuration parameter for connecting to dal node --- .../bin_sc_rollup_node/configuration.ml | 129 ++++++++++-------- .../bin_sc_rollup_node/configuration.mli | 12 ++ .../main_sc_rollup_node_alpha.ml | 38 +++++- 3 files changed, 122 insertions(+), 57 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/configuration.ml b/src/proto_alpha/bin_sc_rollup_node/configuration.ml index 0191e445fab1..8b0cc2cbadcd 100644 --- a/src/proto_alpha/bin_sc_rollup_node/configuration.ml +++ b/src/proto_alpha/bin_sc_rollup_node/configuration.ml @@ -50,6 +50,8 @@ type t = { fee_parameter : Injection.fee_parameter; mode : mode; loser_mode : Loser_mode.t; + dal_node_addr : string; + dal_node_port : int; } let default_data_dir = @@ -73,6 +75,10 @@ let default_rpc_port = 8932 let default_reconnection_delay = 2.0 (* seconds *) +let default_dal_node_addr = "127.0.0.1" + +let default_dal_node_port = 10732 + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2794 the below default values have been copied from `src/proto_alpha/lib_client/client_proto_args.ml`, but @@ -309,25 +315,29 @@ let encoding : t Data_encoding.t = fee_parameter; mode; loser_mode; + dal_node_addr; + dal_node_port; } -> - ( data_dir, - sc_rollup_address, - sc_rollup_node_operators, - rpc_addr, - rpc_port, - reconnection_delay, - fee_parameter, - mode, - loser_mode )) - (fun ( data_dir, - sc_rollup_address, - sc_rollup_node_operators, - rpc_addr, - rpc_port, - reconnection_delay, - fee_parameter, - mode, - loser_mode ) -> + ( ( data_dir, + sc_rollup_address, + sc_rollup_node_operators, + rpc_addr, + rpc_port, + reconnection_delay, + fee_parameter, + mode, + loser_mode ), + (dal_node_addr, dal_node_port) )) + (fun ( ( data_dir, + sc_rollup_address, + sc_rollup_node_operators, + rpc_addr, + rpc_port, + reconnection_delay, + fee_parameter, + mode, + loser_mode ), + (dal_node_addr, dal_node_port) ) -> { data_dir; sc_rollup_address; @@ -338,43 +348,54 @@ let encoding : t Data_encoding.t = fee_parameter; mode; loser_mode; + dal_node_addr; + dal_node_port; }) - (obj9 - (dft - "data-dir" - ~description:"Location of the data dir" - string - default_data_dir) - (req - "sc-rollup-address" - ~description:"Smart contract rollup address" - Protocol.Alpha_context.Sc_rollup.Address.encoding) - (req - "sc-rollup-node-operator" - ~description: - "Operators that sign operations of the smart contract rollup, by \ - purpose" - operators_encoding) - (dft "rpc-addr" ~description:"RPC address" string default_rpc_addr) - (dft "rpc-port" ~description:"RPC port" int16 default_rpc_port) - (dft - ~description:"The reconnection (to the tezos node) delay in seconds" - "reconnection_delay" - float - default_reconnection_delay) - (dft - "fee-parameter" - ~description:"The fee parameter used when injecting operations in L1" - fee_parameter_encoding - default_fee_parameter) - (req ~description:"The mode for this rollup node" "mode" mode_encoding) - (dft - "loser-mode" - ~description: - "If enabled, the rollup node will issue wrong commitments (for \ - test only!)" - Loser_mode.encoding - Loser_mode.no_failures)) + (merge_objs + (obj9 + (dft + "data-dir" + ~description:"Location of the data dir" + string + default_data_dir) + (req + "sc-rollup-address" + ~description:"Smart contract rollup address" + Protocol.Alpha_context.Sc_rollup.Address.encoding) + (req + "sc-rollup-node-operator" + ~description: + "Operators that sign operations of the smart contract rollup, \ + by purpose" + operators_encoding) + (dft "rpc-addr" ~description:"RPC address" string default_rpc_addr) + (dft "rpc-port" ~description:"RPC port" int16 default_rpc_port) + (dft + ~description: + "The reconnection (to the tezos node) delay in seconds" + "reconnection_delay" + float + default_reconnection_delay) + (dft + "fee-parameter" + ~description: + "The fee parameter used when injecting operations in L1" + fee_parameter_encoding + default_fee_parameter) + (req + ~description:"The mode for this rollup node" + "mode" + mode_encoding) + (dft + "loser-mode" + ~description: + "If enabled, the rollup node will issue wrong commitments (for \ + test only!)" + Loser_mode.encoding + Loser_mode.no_failures)) + (obj2 + (dft "DAL node address" string default_dal_node_addr) + (dft "DAL node port" int16 default_dal_node_port))) let check_mode config = let open Result_syntax in diff --git a/src/proto_alpha/bin_sc_rollup_node/configuration.mli b/src/proto_alpha/bin_sc_rollup_node/configuration.mli index 9c94ea2dd9fa..a3cbc25d42e9 100644 --- a/src/proto_alpha/bin_sc_rollup_node/configuration.mli +++ b/src/proto_alpha/bin_sc_rollup_node/configuration.mli @@ -51,6 +51,12 @@ type t = { fee_parameter : Injection.fee_parameter; mode : mode; loser_mode : Loser_mode.t; + (*DAL/FIXME: https://gitlab.com/tezos/tezos/-/issues/3718 + Decide whether we want to handle connections to multiple + Dal nodes for different slot indexes. + *) + dal_node_addr : string; + dal_node_port : int; } (** [make_purpose_map ~default purposes] constructs a purpose map from a list of @@ -90,6 +96,12 @@ val default_reconnection_delay : float (** [default_fee_parameter] is the default value for [fee_parameter] *) val default_fee_parameter : Injection.fee_parameter +(** [default_dal_node_addr] is the default value for [dal_node_addr]. *) +val default_dal_node_addr : string + +(** [default_dal_node_port] is the default value for [dal_node_port]. *) +val default_dal_node_port : int + (** This is the list of available modes. *) val modes : mode list diff --git a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml index ce332308bb75..37603a8c2355 100644 --- a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml +++ b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml @@ -111,6 +111,19 @@ let rpc_addr_arg = ~default Client_proto_args.string_parameter +let dal_node_addr_arg = + let default = Configuration.default_dal_node_addr in + Clic.default_arg + ~long:"dal-node-addr" + ~placeholder:"dal-node-address|ip" + ~doc: + (Format.sprintf + "The address of the dal node from which the smart-contract rollup \ + node downloads slots. Default value is %s" + default) + ~default + Client_proto_args.string_parameter + let rpc_port_arg = let default = Configuration.default_rpc_port |> string_of_int in Clic.default_arg @@ -124,6 +137,19 @@ let rpc_port_arg = ~default Client_proto_args.int_parameter +let dal_node_port_arg = + let default = Configuration.default_dal_node_port |> string_of_int in + Clic.default_arg + ~long:"dal-node-port" + ~placeholder:"dal-node-port" + ~doc: + (Format.sprintf + "The port of the dal node from which the smart-contract rollup node \ + downloads slots from. Default value is %s" + default) + ~default + Client_proto_args.int_parameter + let data_dir_arg = let default = Configuration.default_data_dir in Clic.default_arg @@ -262,7 +288,7 @@ let config_init_command = command ~group ~desc:"Configure the smart-contract rollup node." - (args11 + (args13 data_dir_arg rpc_addr_arg rpc_port_arg @@ -273,7 +299,9 @@ let config_init_command = fee_cap_arg burn_cap_arg loser_mode - reconnection_delay_arg) + reconnection_delay_arg + dal_node_addr_arg + dal_node_port_arg) (prefix "init" @@ mode_param @@ prefixes ["config"; "for"] @@ sc_rollup_address_param @@ -289,7 +317,9 @@ let config_init_command = fee_cap, burn_cap, loser_mode, - reconnection_delay ) + reconnection_delay, + dal_node_addr, + dal_node_port ) mode sc_rollup_address sc_rollup_node_operators @@ -321,6 +351,8 @@ let config_init_command = rpc_addr; rpc_port; reconnection_delay; + dal_node_addr; + dal_node_port; fee_parameter = { minimal_fees; -- GitLab From 1d08f830e76a6d9912bc37488a315b4b0c5eacd4 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 8 Aug 2022 17:43:49 +0100 Subject: [PATCH 4/5] Scoru/Rollup node: add client context for dal node --- src/proto_alpha/bin_sc_rollup_node/daemon.ml | 2 + .../bin_sc_rollup_node/dal_node_client.ml | 47 +++++++++++++++++++ .../bin_sc_rollup_node/dal_node_client.mli | 40 ++++++++++++++++ .../bin_sc_rollup_node/node_context.ml | 6 ++- .../bin_sc_rollup_node/node_context.mli | 5 +- 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml create mode 100644 src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli diff --git a/src/proto_alpha/bin_sc_rollup_node/daemon.ml b/src/proto_alpha/bin_sc_rollup_node/daemon.ml index 8a96bc9b0a73..520d512a624a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/daemon.ml +++ b/src/proto_alpha/bin_sc_rollup_node/daemon.ml @@ -434,6 +434,7 @@ let run ~data_dir (cctxt : Protocol_client_context.full) = Random.self_init () (* Initialize random state (for reconnection delays) *) ; let*! () = Event.starting_node () in let* configuration = Configuration.load ~data_dir in + let dal_cctxt = Dal_node_client.make_unix_cctxt configuration in let open Configuration in let* () = (* Check that the operators are valid keys. *) @@ -449,6 +450,7 @@ let run ~data_dir (cctxt : Protocol_client_context.full) = let* node_ctxt = Node_context.init cctxt + dal_cctxt l1_ctxt configuration.sc_rollup_address kind diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml new file mode 100644 index 000000000000..32b1b5fc419c --- /dev/null +++ b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml @@ -0,0 +1,47 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Trili Tech *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +class type cctxt = + object + inherit RPC_context.generic + end + +class unix_cctxt ~rpc_config : cctxt = + object + inherit + Tezos_rpc_http_client_unix.RPC_client_unix.http_ctxt + rpc_config + (Tezos_rpc_http.Media_type.Command_line.of_command_line + rpc_config.media_type) + end + +let make_unix_cctxt {Configuration.dal_node_addr; dal_node_port; _} = + let endpoint = + Uri.of_string ("http://" ^ dal_node_addr ^ ":" ^ string_of_int dal_node_port) + in + let rpc_config = + {Tezos_rpc_http_client_unix.RPC_client_unix.default_config with endpoint} + in + new unix_cctxt ~rpc_config diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli new file mode 100644 index 000000000000..a08bb0a73754 --- /dev/null +++ b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli @@ -0,0 +1,40 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Trili Tech *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Instance of [Tezos_client_base.Client_context] that only handles IOs and + RPCs. Can be used for keys and RPCs related commands. *) +class type cctxt = + object + inherit RPC_context.generic + end + +(** Instance of [cctxt] for linux systems. Relies on + [Tezos_rpc_http_client_unix]. *) +class unix_cctxt : + rpc_config:Tezos_rpc_http_client_unix.RPC_client_unix.config -> cctxt + +(** [make_unix_client_context config] generates a unix_sc_client_context from + the client configuration. *) +val make_unix_cctxt : Configuration.t -> cctxt diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.ml b/src/proto_alpha/bin_sc_rollup_node/node_context.ml index a13616d0d225..3143de985474 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.ml @@ -28,6 +28,7 @@ open Alpha_context type t = { cctxt : Protocol_client_context.full; + dal_cctxt : Dal_node_client.cctxt; l1_ctxt : Layer1.t; rollup_address : Sc_rollup.t; operators : Configuration.operators; @@ -53,12 +54,13 @@ let get_operator node_ctxt purpose = let retrieve_constants cctxt = Protocol.Constants_services.all cctxt (cctxt#chain, cctxt#block) -let init (cctxt : Protocol_client_context.full) l1_ctxt rollup_address kind - operators fee_parameter ~loser_mode store context = +let init (cctxt : Protocol_client_context.full) dal_cctxt l1_ctxt rollup_address + kind operators fee_parameter ~loser_mode store context = let open Lwt_result_syntax in let+ protocol_constants = retrieve_constants cctxt in { cctxt; + dal_cctxt; l1_ctxt; rollup_address; operators; diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.mli b/src/proto_alpha/bin_sc_rollup_node/node_context.mli index 5dcf4fe201fe..e442171c14b5 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.mli +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.mli @@ -31,6 +31,8 @@ open Alpha_context type t = { cctxt : Protocol_client_context.full; (** Client context used by the rollup node. *) + dal_cctxt : Dal_node_client.cctxt; + (** Client context to query the dal node. *) l1_ctxt : Layer1.t; (** Layer 1 context to fetch blocks and monitor heads, etc.*) rollup_address : Sc_rollup.t; @@ -59,13 +61,14 @@ type t = { val get_operator : t -> Configuration.purpose -> Signature.Public_key_hash.t option -(** [init cctxt l1_ctxt sc_rollup genesis_info kind operators fees +(** [init cctxt dal_cctxt l1_ctxt sc_rollup genesis_info kind operators fees ~loser_mode store context] initialises the rollup representation. The rollup origination level and kind are fetched via an RPC call to the layer1 node that [cctxt] uses for RPC requests. *) val init : Protocol_client_context.full -> + Dal_node_client.cctxt -> Layer1.t -> Sc_rollup.t -> Protocol.Alpha_context.Sc_rollup.Kind.t -> -- GitLab From e47b28df96ec856e5cbf57c64b72fe0fe29d81be Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 8 Aug 2022 18:25:40 +0100 Subject: [PATCH 5/5] Dal/Rollup node: define RPC calls to dal node --- .../bin_sc_rollup_node/dal_node_client.ml | 10 ++++++++++ .../bin_sc_rollup_node/dal_node_client.mli | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml index 32b1b5fc419c..7b3192e24f9f 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml +++ b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.ml @@ -23,6 +23,8 @@ (* *) (*****************************************************************************) +open Tezos_dal_node_services + class type cctxt = object inherit RPC_context.generic @@ -45,3 +47,11 @@ let make_unix_cctxt {Configuration.dal_node_addr; dal_node_port; _} = {Tezos_rpc_http_client_unix.RPC_client_unix.default_config with endpoint} in new unix_cctxt ~rpc_config + +let call (cctxt : #cctxt) = cctxt#call_service + +let get_slot cctxt ?(trim_slot = false) header = + call cctxt (Services.slot ()) ((), header) trim_slot () + +let get_shard cctxt header shard_index = + call cctxt (Services.shard ()) (((), header), shard_index) () () diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli index a08bb0a73754..15b832d4239a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli +++ b/src/proto_alpha/bin_sc_rollup_node/dal_node_client.mli @@ -23,6 +23,10 @@ (* *) (*****************************************************************************) +open Protocol +open Alpha_context +open Tezos_crypto_dal + (** Instance of [Tezos_client_base.Client_context] that only handles IOs and RPCs. Can be used for keys and RPCs related commands. *) class type cctxt = @@ -35,6 +39,12 @@ class type cctxt = class unix_cctxt : rpc_config:Tezos_rpc_http_client_unix.RPC_client_unix.config -> cctxt -(** [make_unix_client_context config] generates a unix_sc_client_context from +(** [make_unix_client_context config] generates a cctxt from the client configuration. *) val make_unix_cctxt : Configuration.t -> cctxt + +val get_slot : + #cctxt -> ?trim_slot:bool -> Dal.Slot.header -> string tzresult Lwt.t + +val get_shard : + #cctxt -> Dal.Slot.header -> int -> Cryptobox.shard tzresult Lwt.t -- GitLab