From 502017c863e07eedda6fc3149e83b2f96a10f932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sat, 26 May 2018 12:11:08 +0200 Subject: [PATCH] Signer: create packages `tezos-signer-services` and `tezos-signed-backends` --- .gitlab-ci.yml | 22 +++++++++++++----- src/bin_client/jbuild | 3 ++- src/bin_signer/handler.ml | 2 +- src/bin_signer/https_daemon.ml | 4 ++-- src/bin_signer/jbuild | 5 +++- src/bin_signer/socket_daemon.ml | 2 +- .../encrypted.ml} | 0 src/lib_signer_backends/jbuild | 23 +++++++++++++++++++ .../remote.ml} | 8 +++---- .../tezos-signer-backends.opam | 21 +++++++++++++++++ .../unencrypted.ml} | 0 src/lib_signer_services/jbuild | 19 +++++++++++++++ .../signer_messages.ml} | 0 .../signer_messages.mli} | 0 .../signer_services.ml} | 2 +- .../signer_services.mli} | 2 +- .../tezos-signer-services.opam | 21 +++++++++++++++++ src/proto_alpha/lib_baking/test/jbuild | 1 + 18 files changed, 116 insertions(+), 19 deletions(-) rename src/{lib_client_base_unix/client_signer_encrypted.ml => lib_signer_backends/encrypted.ml} (100%) create mode 100644 src/lib_signer_backends/jbuild rename src/{lib_client_base_unix/client_signer_remote.ml => lib_signer_backends/remote.ml} (96%) create mode 100644 src/lib_signer_backends/tezos-signer-backends.opam rename src/{lib_client_base_unix/client_signer_unencrypted.ml => lib_signer_backends/unencrypted.ml} (100%) create mode 100644 src/lib_signer_services/jbuild rename src/{lib_client_base_unix/client_signer_remote_messages.ml => lib_signer_services/signer_messages.ml} (100%) rename src/{lib_client_base_unix/client_signer_remote_messages.mli => lib_signer_services/signer_messages.mli} (100%) rename src/{lib_client_base_unix/client_signer_remote_services.ml => lib_signer_services/signer_services.ml} (96%) rename src/{lib_client_base_unix/client_signer_remote_services.mli => lib_signer_services/signer_services.mli} (95%) create mode 100644 src/lib_signer_services/tezos-signer-services.opam diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3daec0dbc..7cf99f69a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -480,32 +480,42 @@ opam:45:tezos-client: variables: package: tezos-client -opam:46:ocplib-ezresto-directory: +opam:46:tezos-signer-services: + <<: *opam_definition + variables: + package: tezos-signer-services + +opam:47:ocplib-ezresto-directory: <<: *opam_definition variables: package: ocplib-ezresto-directory -opam:47:tezos-baker-alpha: +opam:48:tezos-baker-alpha: <<: *opam_definition variables: package: tezos-baker-alpha -opam:48:tezos-protocol-demo: +opam:49:tezos-protocol-demo: <<: *opam_definition variables: package: tezos-protocol-demo -opam:49:tezos-signer: +opam:50:tezos-signer: <<: *opam_definition variables: package: tezos-signer -opam:50:tezos-node: +opam:51:tezos-signer-backends: + <<: *opam_definition + variables: + package: tezos-signer-backends + +opam:52:tezos-node: <<: *opam_definition variables: package: tezos-node -opam:51:ocplib-json-typed-browser: +opam:53:ocplib-json-typed-browser: <<: *opam_definition variables: package: ocplib-json-typed-browser diff --git a/src/bin_client/jbuild b/src/bin_client/jbuild index dc517a264..06d781351 100644 --- a/src/bin_client/jbuild +++ b/src/bin_client/jbuild @@ -13,7 +13,8 @@ tezos-stdlib-unix tezos-client-base-unix tezos-client-alpha-commands.registration - tezos-baking-alpha-commands.registration)) + tezos-baking-alpha-commands.registration + tezos-signer-backends)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives diff --git a/src/bin_signer/handler.ml b/src/bin_signer/handler.ml index 324974dd8..682a5579e 100644 --- a/src/bin_signer/handler.ml +++ b/src/bin_signer/handler.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Client_signer_remote_messages +open Signer_messages let log = Logging.Client.Sign.lwt_log_notice diff --git a/src/bin_signer/https_daemon.ml b/src/bin_signer/https_daemon.ml index 67d3e51cd..b7e3b8156 100644 --- a/src/bin_signer/https_daemon.ml +++ b/src/bin_signer/https_daemon.ml @@ -15,11 +15,11 @@ let run (cctxt : #Client_context.io_wallet) ~host ~port ~cert ~key = `TLS (`Crt_file_path cert, `Key_file_path key, `No_password, `Port port) in let dir = RPC_directory.empty in let dir = - RPC_directory.register0 dir Client_signer_remote_services.sign begin fun () req -> + RPC_directory.register0 dir Signer_services.sign begin fun () req -> Handler.sign cctxt req.key req.data end in let dir = - RPC_directory.register0 dir Client_signer_remote_services.public_key begin fun () req -> + RPC_directory.register0 dir Signer_services.public_key begin fun () req -> Handler.public_key cctxt req.key end in Lwt.catch diff --git a/src/bin_signer/jbuild b/src/bin_signer/jbuild index dca8e036a..5e4b6f8f5 100644 --- a/src/bin_signer/jbuild +++ b/src/bin_signer/jbuild @@ -7,14 +7,17 @@ tezos-client-base tezos-client-base-unix tezos-client-commands + tezos-signer-services tezos-rpc-http - tezos-stdlib-unix)) + tezos-stdlib-unix + tezos-signer-backends)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_commands + -open Tezos_signer_services -open Tezos_rpc_http -open Tezos_stdlib_unix)))) diff --git a/src/bin_signer/socket_daemon.ml b/src/bin_signer/socket_daemon.ml index 1b67156b2..d41cbd940 100644 --- a/src/bin_signer/socket_daemon.ml +++ b/src/bin_signer/socket_daemon.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Client_signer_remote_messages +open Signer_messages let log = Logging.Client.Sign.lwt_log_notice diff --git a/src/lib_client_base_unix/client_signer_encrypted.ml b/src/lib_signer_backends/encrypted.ml similarity index 100% rename from src/lib_client_base_unix/client_signer_encrypted.ml rename to src/lib_signer_backends/encrypted.ml diff --git a/src/lib_signer_backends/jbuild b/src/lib_signer_backends/jbuild new file mode 100644 index 000000000..9944babab --- /dev/null +++ b/src/lib_signer_backends/jbuild @@ -0,0 +1,23 @@ +(jbuild_version 1) + +(library + ((name tezos_signer_backends) + (public_name tezos-signer-backends) + (libraries (tezos-base + tezos-stdlib-unix + tezos-client-base + tezos-rpc-http + tezos-signer-services + pbkdf + bip39)) + (flags (:standard -open Tezos_base__TzPervasives + -open Tezos_stdlib_unix + -open Tezos_client_base + -open Tezos_signer_services + -open Tezos_rpc_http + -linkall -w -9)))) + +(alias + ((name runtest_indent) + (deps ((glob_files *.ml*))) + (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_client_base_unix/client_signer_remote.ml b/src/lib_signer_backends/remote.ml similarity index 96% rename from src/lib_client_base_unix/client_signer_remote.ml rename to src/lib_signer_backends/remote.ml index a8739b6c9..d43fcfd37 100644 --- a/src/lib_client_base_unix/client_signer_remote.ml +++ b/src/lib_signer_backends/remote.ml @@ -8,7 +8,7 @@ (**************************************************************************) open Client_keys -open Client_signer_remote_messages +open Signer_messages let call host port service arg = RPC_client.call_service @@ -41,15 +41,13 @@ let socket_request_public_key path key = let sign path key data = match path with | Socket path -> socket_sign path key data | Https (host, port) -> - call host port - Client_signer_remote_services.sign { key ; data } >>=? fun res -> + call host port Signer_services.sign { key ; data } >>=? fun res -> return res.signature let request_public_key path key = match path with | Socket path -> socket_request_public_key path key | Https (host, port) -> - call host port - Client_signer_remote_services.public_key { key } >>=? fun res -> + call host port Signer_services.public_key { key } >>=? fun res -> return res.public_key module Remote_signer : SIGNER = struct diff --git a/src/lib_signer_backends/tezos-signer-backends.opam b/src/lib_signer_backends/tezos-signer-backends.opam new file mode 100644 index 000000000..1fcbf3280 --- /dev/null +++ b/src/lib_signer_backends/tezos-signer-backends.opam @@ -0,0 +1,21 @@ +opam-version: "1.2" +version: "dev" +maintainer: "contact@tezos.com" +authors: [ "Tezos devteam" ] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "https://gitlab.com/tezos/tezos.git" +license: "unreleased" +depends: [ + "ocamlfind" { build } + "jbuilder" { build & = "1.0+beta19.1" } + "tezos-base" + "tezos-client-base" + "tezos-client-commands" +] +build: [ + [ "jbuilder" "build" "-p" name "-j" jobs ] +] +build-test: [ + [ "jbuilder" "runtest" "-p" name "-j" jobs ] +] diff --git a/src/lib_client_base_unix/client_signer_unencrypted.ml b/src/lib_signer_backends/unencrypted.ml similarity index 100% rename from src/lib_client_base_unix/client_signer_unencrypted.ml rename to src/lib_signer_backends/unencrypted.ml diff --git a/src/lib_signer_services/jbuild b/src/lib_signer_services/jbuild new file mode 100644 index 000000000..f6066f29c --- /dev/null +++ b/src/lib_signer_services/jbuild @@ -0,0 +1,19 @@ +(jbuild_version 1) + +(library + ((name tezos_signer_services) + (public_name tezos-signer-services) + (libraries (tezos-base + tezos-client-base + tezos-rpc)) + (flags (:standard -w -9+27-30-32-40@8 + -safe-string + -open Tezos_base__TzPervasives + -open Tezos_rpc + -open Tezos_client_base + -linkall)))) + +(alias + ((name runtest_indent) + (deps ((glob_files *.ml*))) + (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_client_base_unix/client_signer_remote_messages.ml b/src/lib_signer_services/signer_messages.ml similarity index 100% rename from src/lib_client_base_unix/client_signer_remote_messages.ml rename to src/lib_signer_services/signer_messages.ml diff --git a/src/lib_client_base_unix/client_signer_remote_messages.mli b/src/lib_signer_services/signer_messages.mli similarity index 100% rename from src/lib_client_base_unix/client_signer_remote_messages.mli rename to src/lib_signer_services/signer_messages.mli diff --git a/src/lib_client_base_unix/client_signer_remote_services.ml b/src/lib_signer_services/signer_services.ml similarity index 96% rename from src/lib_client_base_unix/client_signer_remote_services.ml rename to src/lib_signer_services/signer_services.ml index b549660e7..769241eee 100644 --- a/src/lib_client_base_unix/client_signer_remote_services.ml +++ b/src/lib_signer_services/signer_services.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Client_signer_remote_messages +open Signer_messages let sign = RPC_service.post_service ~description: "Sign a piece of data with a given remote key" diff --git a/src/lib_client_base_unix/client_signer_remote_services.mli b/src/lib_signer_services/signer_services.mli similarity index 95% rename from src/lib_client_base_unix/client_signer_remote_services.mli rename to src/lib_signer_services/signer_services.mli index 223a1bb6e..9b8808a98 100644 --- a/src/lib_client_base_unix/client_signer_remote_services.mli +++ b/src/lib_signer_services/signer_services.mli @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Client_signer_remote_messages +open Signer_messages val sign : ([ `POST ], unit, unit, unit, Sign.Request.t, Sign.Response.t) RPC_service.t diff --git a/src/lib_signer_services/tezos-signer-services.opam b/src/lib_signer_services/tezos-signer-services.opam new file mode 100644 index 000000000..1fcbf3280 --- /dev/null +++ b/src/lib_signer_services/tezos-signer-services.opam @@ -0,0 +1,21 @@ +opam-version: "1.2" +version: "dev" +maintainer: "contact@tezos.com" +authors: [ "Tezos devteam" ] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "https://gitlab.com/tezos/tezos.git" +license: "unreleased" +depends: [ + "ocamlfind" { build } + "jbuilder" { build & = "1.0+beta19.1" } + "tezos-base" + "tezos-client-base" + "tezos-client-commands" +] +build: [ + [ "jbuilder" "build" "-p" name "-j" jobs ] +] +build-test: [ + [ "jbuilder" "runtest" "-p" name "-j" jobs ] +] diff --git a/src/proto_alpha/lib_baking/test/jbuild b/src/proto_alpha/lib_baking/test/jbuild index 0540a0692..0f03dbd09 100644 --- a/src/proto_alpha/lib_baking/test/jbuild +++ b/src/proto_alpha/lib_baking/test/jbuild @@ -15,6 +15,7 @@ tezos-client-alpha tezos-baking-alpha tezos-client-base-unix + tezos-signer-backends alcotest-lwt)) (flags (:standard -w -9-32 -safe-string -open Tezos_base__TzPervasives