From a3d0ee644a57a718d35dd6b3fc988f91d3833c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 18:30:12 +0100 Subject: [PATCH 01/27] Refactor: Rename `lib_rpc_base` -> `lib_rpc` --- src/lib_base/jbuild | 4 ++-- src/lib_base/tzPervasives.ml | 2 +- src/lib_base/tzPervasives.mli | 2 +- src/lib_crypto/jbuild | 4 ++-- src/lib_crypto/tezos-crypto.opam | 2 +- src/{lib_rpc_base => lib_rpc}/RPC_arg.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_arg.mli | 0 src/{lib_rpc_base => lib_rpc}/RPC_description.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_description.mli | 0 src/{lib_rpc_base => lib_rpc}/RPC_encoding.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_encoding.mli | 0 src/{lib_rpc_base => lib_rpc}/RPC_path.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_path.mli | 0 src/{lib_rpc_base => lib_rpc}/RPC_query.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_query.mli | 0 src/{lib_rpc_base => lib_rpc}/RPC_service.ml | 0 src/{lib_rpc_base => lib_rpc}/RPC_service.mli | 0 src/{lib_rpc_base => lib_rpc}/jbuild | 4 ++-- .../tezos-rpc-base.opam => lib_rpc/tezos-rpc.opam} | 0 src/lib_rpc_http/jbuild | 2 +- 20 files changed, 10 insertions(+), 10 deletions(-) rename src/{lib_rpc_base => lib_rpc}/RPC_arg.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_arg.mli (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_description.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_description.mli (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_encoding.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_encoding.mli (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_path.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_path.mli (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_query.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_query.mli (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_service.ml (100%) rename src/{lib_rpc_base => lib_rpc}/RPC_service.mli (100%) rename src/{lib_rpc_base => lib_rpc}/jbuild (86%) rename src/{lib_rpc_base/tezos-rpc-base.opam => lib_rpc/tezos-rpc.opam} (100%) diff --git a/src/lib_base/jbuild b/src/lib_base/jbuild index 288c39b08..49a4a0340 100644 --- a/src/lib_base/jbuild +++ b/src/lib_base/jbuild @@ -8,14 +8,14 @@ -open Tezos_crypto -open Tezos_data_encoding -open Tezos_error_monad - -open Tezos_rpc_base + -open Tezos_rpc -safe-string)) (libraries (tezos-stdlib tezos-stdlib-lwt tezos-crypto tezos-data-encoding tezos-error-monad - tezos-rpc-base + tezos-rpc calendar ezjsonm mtime.clock.os)))) diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index 9dfee0838..c76e757b9 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -12,7 +12,7 @@ include Tezos_stdlib_lwt include Tezos_crypto include Tezos_data_encoding include Tezos_error_monad -include Tezos_rpc_base +include Tezos_rpc module List = struct include List diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index 3bbda6c9e..dce6e6653 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -12,7 +12,7 @@ include (module type of (struct include Tezos_data_encoding end)) include (module type of (struct include Tezos_stdlib_lwt end)) include (module type of (struct include Tezos_crypto end)) include (module type of (struct include Tezos_error_monad end)) -include (module type of (struct include Tezos_rpc_base end)) +include (module type of (struct include Tezos_rpc end)) module List : sig include (module type of (struct include List end)) diff --git a/src/lib_crypto/jbuild b/src/lib_crypto/jbuild index e5020e221..d794d6772 100644 --- a/src/lib_crypto/jbuild +++ b/src/lib_crypto/jbuild @@ -6,14 +6,14 @@ (flags (:standard -open Tezos_stdlib -open Tezos_data_encoding -open Tezos_stdlib_lwt - -open Tezos_rpc_base + -open Tezos_rpc -open Tezos_error_monad__Error_monad -safe-string)) (libraries (tezos-stdlib tezos-stdlib-lwt tezos-data-encoding tezos-error-monad - tezos-rpc-base + tezos-rpc nocrypto sodium zarith)))) diff --git a/src/lib_crypto/tezos-crypto.opam b/src/lib_crypto/tezos-crypto.opam index ba2039a05..cbc32b7bc 100644 --- a/src/lib_crypto/tezos-crypto.opam +++ b/src/lib_crypto/tezos-crypto.opam @@ -13,7 +13,7 @@ depends: [ "tezos-stdlib-lwt" "tezos-data-encoding" "tezos-error-monad" - "tezos-rpc-base" + "tezos-rpc" "nocrypto" "sodium" "zarith" diff --git a/src/lib_rpc_base/RPC_arg.ml b/src/lib_rpc/RPC_arg.ml similarity index 100% rename from src/lib_rpc_base/RPC_arg.ml rename to src/lib_rpc/RPC_arg.ml diff --git a/src/lib_rpc_base/RPC_arg.mli b/src/lib_rpc/RPC_arg.mli similarity index 100% rename from src/lib_rpc_base/RPC_arg.mli rename to src/lib_rpc/RPC_arg.mli diff --git a/src/lib_rpc_base/RPC_description.ml b/src/lib_rpc/RPC_description.ml similarity index 100% rename from src/lib_rpc_base/RPC_description.ml rename to src/lib_rpc/RPC_description.ml diff --git a/src/lib_rpc_base/RPC_description.mli b/src/lib_rpc/RPC_description.mli similarity index 100% rename from src/lib_rpc_base/RPC_description.mli rename to src/lib_rpc/RPC_description.mli diff --git a/src/lib_rpc_base/RPC_encoding.ml b/src/lib_rpc/RPC_encoding.ml similarity index 100% rename from src/lib_rpc_base/RPC_encoding.ml rename to src/lib_rpc/RPC_encoding.ml diff --git a/src/lib_rpc_base/RPC_encoding.mli b/src/lib_rpc/RPC_encoding.mli similarity index 100% rename from src/lib_rpc_base/RPC_encoding.mli rename to src/lib_rpc/RPC_encoding.mli diff --git a/src/lib_rpc_base/RPC_path.ml b/src/lib_rpc/RPC_path.ml similarity index 100% rename from src/lib_rpc_base/RPC_path.ml rename to src/lib_rpc/RPC_path.ml diff --git a/src/lib_rpc_base/RPC_path.mli b/src/lib_rpc/RPC_path.mli similarity index 100% rename from src/lib_rpc_base/RPC_path.mli rename to src/lib_rpc/RPC_path.mli diff --git a/src/lib_rpc_base/RPC_query.ml b/src/lib_rpc/RPC_query.ml similarity index 100% rename from src/lib_rpc_base/RPC_query.ml rename to src/lib_rpc/RPC_query.ml diff --git a/src/lib_rpc_base/RPC_query.mli b/src/lib_rpc/RPC_query.mli similarity index 100% rename from src/lib_rpc_base/RPC_query.mli rename to src/lib_rpc/RPC_query.mli diff --git a/src/lib_rpc_base/RPC_service.ml b/src/lib_rpc/RPC_service.ml similarity index 100% rename from src/lib_rpc_base/RPC_service.ml rename to src/lib_rpc/RPC_service.ml diff --git a/src/lib_rpc_base/RPC_service.mli b/src/lib_rpc/RPC_service.mli similarity index 100% rename from src/lib_rpc_base/RPC_service.mli rename to src/lib_rpc/RPC_service.mli diff --git a/src/lib_rpc_base/jbuild b/src/lib_rpc/jbuild similarity index 86% rename from src/lib_rpc_base/jbuild rename to src/lib_rpc/jbuild index 0ec17c9f4..83680e92c 100644 --- a/src/lib_rpc_base/jbuild +++ b/src/lib_rpc/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_rpc_base) - (public_name tezos-rpc-base) + ((name tezos_rpc) + (public_name tezos-rpc) (libraries (tezos-data-encoding ocplib-resto)) (flags (:standard -w -9+27-30-32-40@8 diff --git a/src/lib_rpc_base/tezos-rpc-base.opam b/src/lib_rpc/tezos-rpc.opam similarity index 100% rename from src/lib_rpc_base/tezos-rpc-base.opam rename to src/lib_rpc/tezos-rpc.opam diff --git a/src/lib_rpc_http/jbuild b/src/lib_rpc_http/jbuild index 0fe821d41..8b970fba7 100644 --- a/src/lib_rpc_http/jbuild +++ b/src/lib_rpc_http/jbuild @@ -10,7 +10,7 @@ (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_rpc_base + -open Tezos_rpc -open Tezos_node_services)))) (alias From 1f3c68cbd8d23e0b1b306658ac7f66382cbc3b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 18:43:58 +0100 Subject: [PATCH 02/27] Refactor: Regroup protocols --- scripts/alphanet_constants.patch | 6 +++--- src/lib_embedded_protocol_alpha/jbuild | 1 - src/lib_embedded_protocol_alpha/src/jbuild | 1 - src/lib_embedded_protocol_demo/jbuild | 1 - src/lib_embedded_protocol_demo/src/jbuild | 1 - src/lib_embedded_protocol_genesis/jbuild | 1 - src/lib_embedded_protocol_genesis/src/jbuild | 1 - src/lib_protocol_compiler/jbuild_embedded_protocol_template | 2 +- src/lib_protocol_compiler/jbuild_protocol_template | 4 ++-- .../lib_client_alpha}/alpha.ml | 0 .../lib_client_alpha}/alpha.mli | 0 .../lib_client_alpha}/client_baking_blocks.ml | 0 .../lib_client_alpha}/client_baking_blocks.mli | 0 .../lib_client_alpha}/client_baking_daemon.ml | 0 .../lib_client_alpha}/client_baking_daemon.mli | 0 .../lib_client_alpha}/client_baking_denunciation.ml | 0 .../lib_client_alpha}/client_baking_denunciation.mli | 0 .../lib_client_alpha}/client_baking_endorsement.ml | 0 .../lib_client_alpha}/client_baking_endorsement.mli | 0 .../lib_client_alpha}/client_baking_forge.ml | 0 .../lib_client_alpha}/client_baking_forge.mli | 0 .../lib_client_alpha}/client_baking_lib.ml | 0 .../lib_client_alpha}/client_baking_lib.mli | 0 .../lib_client_alpha}/client_baking_main.ml | 0 .../lib_client_alpha}/client_baking_main.mli | 0 .../lib_client_alpha}/client_baking_operations.ml | 0 .../lib_client_alpha}/client_baking_operations.mli | 0 .../lib_client_alpha}/client_baking_revelation.ml | 0 .../lib_client_alpha}/client_baking_revelation.mli | 0 .../lib_client_alpha}/client_proto_args.ml | 0 .../lib_client_alpha}/client_proto_args.mli | 0 .../lib_client_alpha}/client_proto_context.ml | 0 .../lib_client_alpha}/client_proto_context.mli | 0 .../lib_client_alpha}/client_proto_context_commands.ml | 0 .../lib_client_alpha}/client_proto_contracts.ml | 0 .../lib_client_alpha}/client_proto_contracts.mli | 0 .../lib_client_alpha}/client_proto_contracts_commands.ml | 0 .../lib_client_alpha}/client_proto_main.ml | 0 .../lib_client_alpha}/client_proto_main.mli | 0 .../lib_client_alpha}/client_proto_nonces.ml | 0 .../lib_client_alpha}/client_proto_nonces.mli | 0 .../lib_client_alpha}/client_proto_programs.ml | 0 .../lib_client_alpha}/client_proto_programs.mli | 0 .../lib_client_alpha}/client_proto_programs_commands.ml | 0 .../lib_client_alpha}/client_proto_programs_commands.mli | 0 .../lib_client_alpha}/client_proto_rpcs.ml | 0 .../lib_client_alpha}/client_proto_rpcs.mli | 0 .../lib_client_alpha}/jbuild | 0 .../lib_client_alpha}/michelson_macros.ml | 0 .../lib_client_alpha}/michelson_macros.mli | 0 .../lib_client_alpha}/michelson_v1_emacs.ml | 0 .../lib_client_alpha}/michelson_v1_emacs.mli | 0 .../lib_client_alpha}/michelson_v1_error_reporter.ml | 0 .../lib_client_alpha}/michelson_v1_error_reporter.mli | 0 .../lib_client_alpha}/michelson_v1_parser.ml | 0 .../lib_client_alpha}/michelson_v1_parser.mli | 0 .../lib_client_alpha}/michelson_v1_printer.ml | 0 .../lib_client_alpha}/michelson_v1_printer.mli | 0 .../lib_client_alpha}/tezos-embedded-client-alpha.opam | 0 src/proto_alpha/lib_protocol_alpha/jbuild | 1 + .../lib_protocol_alpha}/src/TEZOS_PROTOCOL | 0 .../lib_protocol_alpha}/src/amendment.ml | 0 .../lib_protocol_alpha}/src/amendment.mli | 0 .../lib_protocol_alpha}/src/apply.ml | 0 .../lib_protocol_alpha}/src/baking.ml | 0 .../lib_protocol_alpha}/src/baking.mli | 0 .../lib_protocol_alpha}/src/block_header_repr.ml | 0 .../lib_protocol_alpha}/src/block_header_repr.mli | 0 .../lib_protocol_alpha}/src/bootstrap_storage.ml | 0 .../lib_protocol_alpha}/src/bootstrap_storage.mli | 0 .../lib_protocol_alpha}/src/constants_repr.ml | 0 .../lib_protocol_alpha}/src/contract_repr.ml | 0 .../lib_protocol_alpha}/src/contract_repr.mli | 0 .../lib_protocol_alpha}/src/contract_storage.ml | 0 .../lib_protocol_alpha}/src/contract_storage.mli | 0 .../lib_protocol_alpha}/src/cycle_repr.ml | 0 .../lib_protocol_alpha}/src/cycle_repr.mli | 0 .../lib_protocol_alpha}/src/fitness_repr.ml | 0 .../lib_protocol_alpha}/src/fitness_storage.ml | 0 .../lib_protocol_alpha}/src/gas.ml | 0 .../lib_protocol_alpha}/src/gas.mli | 0 .../lib_protocol_alpha}/src/init_storage.ml | 0 src/proto_alpha/lib_protocol_alpha/src/jbuild | 1 + .../lib_protocol_alpha}/src/level_repr.ml | 0 .../lib_protocol_alpha}/src/level_repr.mli | 0 .../lib_protocol_alpha}/src/level_storage.ml | 0 .../lib_protocol_alpha}/src/level_storage.mli | 0 .../lib_protocol_alpha}/src/main.ml | 0 .../lib_protocol_alpha}/src/main.mli | 0 .../lib_protocol_alpha}/src/manager_repr.ml | 0 .../lib_protocol_alpha}/src/manager_repr.mli | 0 .../lib_protocol_alpha}/src/michelson_v1_primitives.ml | 0 .../lib_protocol_alpha}/src/michelson_v1_primitives.mli | 0 .../lib_protocol_alpha}/src/misc.ml | 0 .../lib_protocol_alpha}/src/misc.mli | 0 .../lib_protocol_alpha}/src/nonce_storage.ml | 0 .../lib_protocol_alpha}/src/nonce_storage.mli | 0 .../lib_protocol_alpha}/src/operation_repr.ml | 0 .../lib_protocol_alpha}/src/operation_repr.mli | 0 .../lib_protocol_alpha}/src/period_repr.ml | 0 .../lib_protocol_alpha}/src/period_repr.mli | 0 .../lib_protocol_alpha}/src/public_key_storage.ml | 0 .../lib_protocol_alpha}/src/public_key_storage.mli | 0 .../lib_protocol_alpha}/src/qty_repr.ml | 0 .../lib_protocol_alpha}/src/raw_context.ml | 0 .../lib_protocol_alpha}/src/raw_context.mli | 0 .../lib_protocol_alpha}/src/raw_level_repr.ml | 0 .../lib_protocol_alpha}/src/raw_level_repr.mli | 0 .../lib_protocol_alpha}/src/reward_storage.ml | 0 .../lib_protocol_alpha}/src/reward_storage.mli | 0 .../lib_protocol_alpha}/src/roll_repr.ml | 0 .../lib_protocol_alpha}/src/roll_repr.mli | 0 .../lib_protocol_alpha}/src/roll_storage.ml | 0 .../lib_protocol_alpha}/src/roll_storage.mli | 0 .../lib_protocol_alpha}/src/script_int_repr.ml | 0 .../lib_protocol_alpha}/src/script_int_repr.mli | 0 .../lib_protocol_alpha}/src/script_interpreter.ml | 0 .../lib_protocol_alpha}/src/script_interpreter.mli | 0 .../lib_protocol_alpha}/src/script_ir_translator.ml | 0 .../lib_protocol_alpha}/src/script_ir_translator.mli | 0 .../lib_protocol_alpha}/src/script_repr.ml | 0 .../lib_protocol_alpha}/src/script_repr.mli | 0 .../lib_protocol_alpha}/src/script_timestamp_repr.ml | 0 .../lib_protocol_alpha}/src/script_timestamp_repr.mli | 0 .../lib_protocol_alpha}/src/script_typed_ir.ml | 0 .../lib_protocol_alpha}/src/seed_repr.ml | 0 .../lib_protocol_alpha}/src/seed_repr.mli | 0 .../lib_protocol_alpha}/src/seed_storage.ml | 0 .../lib_protocol_alpha}/src/seed_storage.mli | 0 .../lib_protocol_alpha}/src/services.ml | 0 .../lib_protocol_alpha}/src/services_registration.ml | 0 .../lib_protocol_alpha}/src/storage.ml | 0 .../lib_protocol_alpha}/src/storage.mli | 0 .../lib_protocol_alpha}/src/storage_functors.ml | 0 .../lib_protocol_alpha}/src/storage_functors.mli | 0 .../lib_protocol_alpha}/src/storage_sigs.ml | 0 .../lib_protocol_alpha}/src/tez_repr.ml | 0 .../lib_protocol_alpha}/src/tez_repr.mli | 0 .../lib_protocol_alpha}/src/tezos_context.ml | 0 .../lib_protocol_alpha}/src/tezos_context.mli | 0 .../lib_protocol_alpha}/src/tezos_hash.ml | 0 .../lib_protocol_alpha}/src/time_repr.ml | 0 .../lib_protocol_alpha}/src/time_repr.mli | 0 .../lib_protocol_alpha}/src/vote_repr.ml | 0 .../lib_protocol_alpha}/src/vote_repr.mli | 0 .../lib_protocol_alpha}/src/vote_storage.ml | 0 .../lib_protocol_alpha}/src/vote_storage.mli | 0 .../lib_protocol_alpha}/src/voting_period_repr.ml | 0 .../lib_protocol_alpha}/src/voting_period_repr.mli | 0 .../lib_protocol_alpha}/tezos-embedded-protocol-alpha.opam | 0 .../lib_protocol_alpha}/tezos-protocol-alpha.opam | 0 .../lib_client_demo}/client_proto_main.ml | 0 .../lib_client_demo}/client_proto_main.mli | 0 .../lib_client_demo}/client_proto_rpcs.ml | 0 .../lib_client_demo}/client_proto_rpcs.mli | 0 src/proto_demo/lib_protocol_demo/jbuild | 1 + .../lib_protocol_demo}/src/TEZOS_PROTOCOL | 0 .../lib_protocol_demo}/src/error.ml | 0 src/proto_demo/lib_protocol_demo/src/jbuild | 1 + .../lib_protocol_demo}/src/main.ml | 0 .../lib_protocol_demo}/src/services.ml | 0 .../lib_protocol_demo}/tezos-embedded-protocol-demo.opam | 0 .../lib_protocol_demo}/tezos-protocol-demo.opam | 0 .../lib_client_genesis}/client_proto_main.ml | 0 .../lib_client_genesis}/client_proto_main.mli | 0 .../lib_client_genesis}/jbuild | 0 .../lib_client_genesis}/tezos-embedded-client-genesis.opam | 0 src/proto_genesis/lib_protocol_genesis/jbuild | 1 + .../lib_protocol_genesis}/src/TEZOS_PROTOCOL | 0 .../lib_protocol_genesis}/src/data.ml | 0 src/proto_genesis/lib_protocol_genesis/src/jbuild | 1 + .../lib_protocol_genesis}/src/main.ml | 0 .../lib_protocol_genesis}/src/services.ml | 0 .../tezos-embedded-protocol-genesis.opam | 0 .../lib_protocol_genesis}/tezos-protocol-genesis.opam | 0 175 files changed, 12 insertions(+), 12 deletions(-) delete mode 120000 src/lib_embedded_protocol_alpha/jbuild delete mode 120000 src/lib_embedded_protocol_alpha/src/jbuild delete mode 120000 src/lib_embedded_protocol_demo/jbuild delete mode 120000 src/lib_embedded_protocol_demo/src/jbuild delete mode 120000 src/lib_embedded_protocol_genesis/jbuild delete mode 120000 src/lib_embedded_protocol_genesis/src/jbuild rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/alpha.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/alpha.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_blocks.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_blocks.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_daemon.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_daemon.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_denunciation.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_denunciation.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_endorsement.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_endorsement.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_forge.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_forge.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_lib.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_lib.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_main.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_main.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_operations.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_operations.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_revelation.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_baking_revelation.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_args.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_args.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_context.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_context.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_context_commands.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_contracts.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_contracts.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_contracts_commands.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_main.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_main.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_nonces.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_nonces.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_programs.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_programs.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_programs_commands.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_programs_commands.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_rpcs.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/client_proto_rpcs.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/jbuild (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_macros.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_macros.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_emacs.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_emacs.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_error_reporter.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_error_reporter.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_parser.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_parser.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_printer.ml (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/michelson_v1_printer.mli (100%) rename src/{lib_embedded_client_alpha => proto_alpha/lib_client_alpha}/tezos-embedded-client-alpha.opam (100%) create mode 120000 src/proto_alpha/lib_protocol_alpha/jbuild rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/TEZOS_PROTOCOL (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/amendment.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/amendment.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/apply.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/baking.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/baking.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/block_header_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/block_header_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/bootstrap_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/bootstrap_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/constants_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/contract_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/contract_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/contract_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/contract_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/cycle_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/cycle_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/fitness_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/fitness_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/gas.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/gas.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/init_storage.ml (100%) create mode 120000 src/proto_alpha/lib_protocol_alpha/src/jbuild rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/level_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/level_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/level_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/level_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/main.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/main.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/manager_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/manager_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/michelson_v1_primitives.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/michelson_v1_primitives.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/misc.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/misc.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/nonce_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/nonce_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/operation_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/operation_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/period_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/period_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/public_key_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/public_key_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/qty_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/raw_context.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/raw_context.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/raw_level_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/raw_level_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/reward_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/reward_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/roll_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/roll_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/roll_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/roll_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_int_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_int_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_interpreter.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_interpreter.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_ir_translator.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_ir_translator.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_timestamp_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_timestamp_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/script_typed_ir.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/seed_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/seed_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/seed_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/seed_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/services.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/services_registration.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/storage_functors.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/storage_functors.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/storage_sigs.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/tez_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/tez_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/tezos_context.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/tezos_context.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/tezos_hash.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/time_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/time_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/vote_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/vote_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/vote_storage.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/vote_storage.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/voting_period_repr.ml (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/src/voting_period_repr.mli (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/tezos-embedded-protocol-alpha.opam (100%) rename src/{lib_embedded_protocol_alpha => proto_alpha/lib_protocol_alpha}/tezos-protocol-alpha.opam (100%) rename src/{lib_embedded_client_demo => proto_demo/lib_client_demo}/client_proto_main.ml (100%) rename src/{lib_embedded_client_demo => proto_demo/lib_client_demo}/client_proto_main.mli (100%) rename src/{lib_embedded_client_demo => proto_demo/lib_client_demo}/client_proto_rpcs.ml (100%) rename src/{lib_embedded_client_demo => proto_demo/lib_client_demo}/client_proto_rpcs.mli (100%) create mode 120000 src/proto_demo/lib_protocol_demo/jbuild rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/src/TEZOS_PROTOCOL (100%) rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/src/error.ml (100%) create mode 120000 src/proto_demo/lib_protocol_demo/src/jbuild rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/src/main.ml (100%) rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/src/services.ml (100%) rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/tezos-embedded-protocol-demo.opam (100%) rename src/{lib_embedded_protocol_demo => proto_demo/lib_protocol_demo}/tezos-protocol-demo.opam (100%) rename src/{lib_embedded_client_genesis => proto_genesis/lib_client_genesis}/client_proto_main.ml (100%) rename src/{lib_embedded_client_genesis => proto_genesis/lib_client_genesis}/client_proto_main.mli (100%) rename src/{lib_embedded_client_genesis => proto_genesis/lib_client_genesis}/jbuild (100%) rename src/{lib_embedded_client_genesis => proto_genesis/lib_client_genesis}/tezos-embedded-client-genesis.opam (100%) create mode 120000 src/proto_genesis/lib_protocol_genesis/jbuild rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/src/TEZOS_PROTOCOL (100%) rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/src/data.ml (100%) create mode 120000 src/proto_genesis/lib_protocol_genesis/src/jbuild rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/src/main.ml (100%) rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/src/services.ml (100%) rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/tezos-embedded-protocol-genesis.opam (100%) rename src/{lib_embedded_protocol_genesis => proto_genesis/lib_protocol_genesis}/tezos-protocol-genesis.opam (100%) diff --git a/scripts/alphanet_constants.patch b/scripts/alphanet_constants.patch index 726ebb888..64b54eac2 100644 --- a/scripts/alphanet_constants.patch +++ b/scripts/alphanet_constants.patch @@ -1,7 +1,7 @@ -diff --git a/src/lib_embedded_protocol_alpha/src/constants_repr.ml b/src/lib_embedded_protocol_alpha/src/constants_repr.ml +diff --git a/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml index 61e79c8a..f91ce282 100644 ---- a/src/lib_embedded_protocol_alpha/src/constants_repr.ml -+++ b/src/lib_embedded_protocol_alpha/src/constants_repr.ml +--- a/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml ++++ b/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml @@ -49,15 +49,14 @@ let read_public_key s = Ed25519.Public_key.of_bytes (Bytes.of_string (Hex_encode.hex_decode s)) diff --git a/src/lib_embedded_protocol_alpha/jbuild b/src/lib_embedded_protocol_alpha/jbuild deleted file mode 120000 index b07d3e876..000000000 --- a/src/lib_embedded_protocol_alpha/jbuild +++ /dev/null @@ -1 +0,0 @@ -../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_alpha/src/jbuild b/src/lib_embedded_protocol_alpha/src/jbuild deleted file mode 120000 index 416ee606d..000000000 --- a/src/lib_embedded_protocol_alpha/src/jbuild +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_demo/jbuild b/src/lib_embedded_protocol_demo/jbuild deleted file mode 120000 index b07d3e876..000000000 --- a/src/lib_embedded_protocol_demo/jbuild +++ /dev/null @@ -1 +0,0 @@ -../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_demo/src/jbuild b/src/lib_embedded_protocol_demo/src/jbuild deleted file mode 120000 index 416ee606d..000000000 --- a/src/lib_embedded_protocol_demo/src/jbuild +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_genesis/jbuild b/src/lib_embedded_protocol_genesis/jbuild deleted file mode 120000 index b07d3e876..000000000 --- a/src/lib_embedded_protocol_genesis/jbuild +++ /dev/null @@ -1 +0,0 @@ -../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_genesis/src/jbuild b/src/lib_embedded_protocol_genesis/src/jbuild deleted file mode 120000 index 416ee606d..000000000 --- a/src/lib_embedded_protocol_genesis/src/jbuild +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index 9ce7c7587..08449bc9b 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -1,6 +1,6 @@ (* -*- tuareg -*- *) -let prefix = "lib_embedded_protocol_" +let prefix = "lib_protocol_" let dirname = Filename.basename @@ Filename.dirname @@ Sys.getcwd () let predefined_version = None (* to be substituted in opam packages *) diff --git a/src/lib_protocol_compiler/jbuild_protocol_template b/src/lib_protocol_compiler/jbuild_protocol_template index 12df7c31d..b80125bbb 100644 --- a/src/lib_protocol_compiler/jbuild_protocol_template +++ b/src/lib_protocol_compiler/jbuild_protocol_template @@ -11,7 +11,7 @@ #require "unix" -let prefix = "lib_embedded_protocol_" +let prefix = "lib_protocol_" let dirname = Filename.basename @@ Sys.getcwd () let predefined_version = None (* to be substituted in opam packages *) @@ -28,7 +28,7 @@ let version = let path = match predefined_version with - | None -> "src/lib_embedded_protocol_" ^ version + | None -> "src/proto_" ^ version ^ "/lib_protocol_" ^ version | Some _ -> "." let sources = diff --git a/src/lib_embedded_client_alpha/alpha.ml b/src/proto_alpha/lib_client_alpha/alpha.ml similarity index 100% rename from src/lib_embedded_client_alpha/alpha.ml rename to src/proto_alpha/lib_client_alpha/alpha.ml diff --git a/src/lib_embedded_client_alpha/alpha.mli b/src/proto_alpha/lib_client_alpha/alpha.mli similarity index 100% rename from src/lib_embedded_client_alpha/alpha.mli rename to src/proto_alpha/lib_client_alpha/alpha.mli diff --git a/src/lib_embedded_client_alpha/client_baking_blocks.ml b/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_blocks.ml rename to src/proto_alpha/lib_client_alpha/client_baking_blocks.ml diff --git a/src/lib_embedded_client_alpha/client_baking_blocks.mli b/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_blocks.mli rename to src/proto_alpha/lib_client_alpha/client_baking_blocks.mli diff --git a/src/lib_embedded_client_alpha/client_baking_daemon.ml b/src/proto_alpha/lib_client_alpha/client_baking_daemon.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_daemon.ml rename to src/proto_alpha/lib_client_alpha/client_baking_daemon.ml diff --git a/src/lib_embedded_client_alpha/client_baking_daemon.mli b/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_daemon.mli rename to src/proto_alpha/lib_client_alpha/client_baking_daemon.mli diff --git a/src/lib_embedded_client_alpha/client_baking_denunciation.ml b/src/proto_alpha/lib_client_alpha/client_baking_denunciation.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_denunciation.ml rename to src/proto_alpha/lib_client_alpha/client_baking_denunciation.ml diff --git a/src/lib_embedded_client_alpha/client_baking_denunciation.mli b/src/proto_alpha/lib_client_alpha/client_baking_denunciation.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_denunciation.mli rename to src/proto_alpha/lib_client_alpha/client_baking_denunciation.mli diff --git a/src/lib_embedded_client_alpha/client_baking_endorsement.ml b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_endorsement.ml rename to src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml diff --git a/src/lib_embedded_client_alpha/client_baking_endorsement.mli b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_endorsement.mli rename to src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli diff --git a/src/lib_embedded_client_alpha/client_baking_forge.ml b/src/proto_alpha/lib_client_alpha/client_baking_forge.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_forge.ml rename to src/proto_alpha/lib_client_alpha/client_baking_forge.ml diff --git a/src/lib_embedded_client_alpha/client_baking_forge.mli b/src/proto_alpha/lib_client_alpha/client_baking_forge.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_forge.mli rename to src/proto_alpha/lib_client_alpha/client_baking_forge.mli diff --git a/src/lib_embedded_client_alpha/client_baking_lib.ml b/src/proto_alpha/lib_client_alpha/client_baking_lib.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_lib.ml rename to src/proto_alpha/lib_client_alpha/client_baking_lib.ml diff --git a/src/lib_embedded_client_alpha/client_baking_lib.mli b/src/proto_alpha/lib_client_alpha/client_baking_lib.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_lib.mli rename to src/proto_alpha/lib_client_alpha/client_baking_lib.mli diff --git a/src/lib_embedded_client_alpha/client_baking_main.ml b/src/proto_alpha/lib_client_alpha/client_baking_main.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_main.ml rename to src/proto_alpha/lib_client_alpha/client_baking_main.ml diff --git a/src/lib_embedded_client_alpha/client_baking_main.mli b/src/proto_alpha/lib_client_alpha/client_baking_main.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_main.mli rename to src/proto_alpha/lib_client_alpha/client_baking_main.mli diff --git a/src/lib_embedded_client_alpha/client_baking_operations.ml b/src/proto_alpha/lib_client_alpha/client_baking_operations.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_operations.ml rename to src/proto_alpha/lib_client_alpha/client_baking_operations.ml diff --git a/src/lib_embedded_client_alpha/client_baking_operations.mli b/src/proto_alpha/lib_client_alpha/client_baking_operations.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_operations.mli rename to src/proto_alpha/lib_client_alpha/client_baking_operations.mli diff --git a/src/lib_embedded_client_alpha/client_baking_revelation.ml b/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_revelation.ml rename to src/proto_alpha/lib_client_alpha/client_baking_revelation.ml diff --git a/src/lib_embedded_client_alpha/client_baking_revelation.mli b/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_baking_revelation.mli rename to src/proto_alpha/lib_client_alpha/client_baking_revelation.mli diff --git a/src/lib_embedded_client_alpha/client_proto_args.ml b/src/proto_alpha/lib_client_alpha/client_proto_args.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_args.ml rename to src/proto_alpha/lib_client_alpha/client_proto_args.ml diff --git a/src/lib_embedded_client_alpha/client_proto_args.mli b/src/proto_alpha/lib_client_alpha/client_proto_args.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_args.mli rename to src/proto_alpha/lib_client_alpha/client_proto_args.mli diff --git a/src/lib_embedded_client_alpha/client_proto_context.ml b/src/proto_alpha/lib_client_alpha/client_proto_context.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_context.ml rename to src/proto_alpha/lib_client_alpha/client_proto_context.ml diff --git a/src/lib_embedded_client_alpha/client_proto_context.mli b/src/proto_alpha/lib_client_alpha/client_proto_context.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_context.mli rename to src/proto_alpha/lib_client_alpha/client_proto_context.mli diff --git a/src/lib_embedded_client_alpha/client_proto_context_commands.ml b/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_context_commands.ml rename to src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml diff --git a/src/lib_embedded_client_alpha/client_proto_contracts.ml b/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_contracts.ml rename to src/proto_alpha/lib_client_alpha/client_proto_contracts.ml diff --git a/src/lib_embedded_client_alpha/client_proto_contracts.mli b/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_contracts.mli rename to src/proto_alpha/lib_client_alpha/client_proto_contracts.mli diff --git a/src/lib_embedded_client_alpha/client_proto_contracts_commands.ml b/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_contracts_commands.ml rename to src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml diff --git a/src/lib_embedded_client_alpha/client_proto_main.ml b/src/proto_alpha/lib_client_alpha/client_proto_main.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_main.ml rename to src/proto_alpha/lib_client_alpha/client_proto_main.ml diff --git a/src/lib_embedded_client_alpha/client_proto_main.mli b/src/proto_alpha/lib_client_alpha/client_proto_main.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_main.mli rename to src/proto_alpha/lib_client_alpha/client_proto_main.mli diff --git a/src/lib_embedded_client_alpha/client_proto_nonces.ml b/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_nonces.ml rename to src/proto_alpha/lib_client_alpha/client_proto_nonces.ml diff --git a/src/lib_embedded_client_alpha/client_proto_nonces.mli b/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_nonces.mli rename to src/proto_alpha/lib_client_alpha/client_proto_nonces.mli diff --git a/src/lib_embedded_client_alpha/client_proto_programs.ml b/src/proto_alpha/lib_client_alpha/client_proto_programs.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_programs.ml rename to src/proto_alpha/lib_client_alpha/client_proto_programs.ml diff --git a/src/lib_embedded_client_alpha/client_proto_programs.mli b/src/proto_alpha/lib_client_alpha/client_proto_programs.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_programs.mli rename to src/proto_alpha/lib_client_alpha/client_proto_programs.mli diff --git a/src/lib_embedded_client_alpha/client_proto_programs_commands.ml b/src/proto_alpha/lib_client_alpha/client_proto_programs_commands.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_programs_commands.ml rename to src/proto_alpha/lib_client_alpha/client_proto_programs_commands.ml diff --git a/src/lib_embedded_client_alpha/client_proto_programs_commands.mli b/src/proto_alpha/lib_client_alpha/client_proto_programs_commands.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_programs_commands.mli rename to src/proto_alpha/lib_client_alpha/client_proto_programs_commands.mli diff --git a/src/lib_embedded_client_alpha/client_proto_rpcs.ml b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_rpcs.ml rename to src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml diff --git a/src/lib_embedded_client_alpha/client_proto_rpcs.mli b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli similarity index 100% rename from src/lib_embedded_client_alpha/client_proto_rpcs.mli rename to src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli diff --git a/src/lib_embedded_client_alpha/jbuild b/src/proto_alpha/lib_client_alpha/jbuild similarity index 100% rename from src/lib_embedded_client_alpha/jbuild rename to src/proto_alpha/lib_client_alpha/jbuild diff --git a/src/lib_embedded_client_alpha/michelson_macros.ml b/src/proto_alpha/lib_client_alpha/michelson_macros.ml similarity index 100% rename from src/lib_embedded_client_alpha/michelson_macros.ml rename to src/proto_alpha/lib_client_alpha/michelson_macros.ml diff --git a/src/lib_embedded_client_alpha/michelson_macros.mli b/src/proto_alpha/lib_client_alpha/michelson_macros.mli similarity index 100% rename from src/lib_embedded_client_alpha/michelson_macros.mli rename to src/proto_alpha/lib_client_alpha/michelson_macros.mli diff --git a/src/lib_embedded_client_alpha/michelson_v1_emacs.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_emacs.ml rename to src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml diff --git a/src/lib_embedded_client_alpha/michelson_v1_emacs.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_emacs.mli rename to src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli diff --git a/src/lib_embedded_client_alpha/michelson_v1_error_reporter.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_error_reporter.ml rename to src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml diff --git a/src/lib_embedded_client_alpha/michelson_v1_error_reporter.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.mli similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_error_reporter.mli rename to src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.mli diff --git a/src/lib_embedded_client_alpha/michelson_v1_parser.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_parser.ml rename to src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml diff --git a/src/lib_embedded_client_alpha/michelson_v1_parser.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_parser.mli rename to src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli diff --git a/src/lib_embedded_client_alpha/michelson_v1_printer.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_printer.ml rename to src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml diff --git a/src/lib_embedded_client_alpha/michelson_v1_printer.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli similarity index 100% rename from src/lib_embedded_client_alpha/michelson_v1_printer.mli rename to src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli diff --git a/src/lib_embedded_client_alpha/tezos-embedded-client-alpha.opam b/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam similarity index 100% rename from src/lib_embedded_client_alpha/tezos-embedded-client-alpha.opam rename to src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam diff --git a/src/proto_alpha/lib_protocol_alpha/jbuild b/src/proto_alpha/lib_protocol_alpha/jbuild new file mode 120000 index 000000000..3dc6e1fbd --- /dev/null +++ b/src/proto_alpha/lib_protocol_alpha/jbuild @@ -0,0 +1 @@ +../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_alpha/src/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol_alpha/src/TEZOS_PROTOCOL similarity index 100% rename from src/lib_embedded_protocol_alpha/src/TEZOS_PROTOCOL rename to src/proto_alpha/lib_protocol_alpha/src/TEZOS_PROTOCOL diff --git a/src/lib_embedded_protocol_alpha/src/amendment.ml b/src/proto_alpha/lib_protocol_alpha/src/amendment.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/amendment.ml rename to src/proto_alpha/lib_protocol_alpha/src/amendment.ml diff --git a/src/lib_embedded_protocol_alpha/src/amendment.mli b/src/proto_alpha/lib_protocol_alpha/src/amendment.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/amendment.mli rename to src/proto_alpha/lib_protocol_alpha/src/amendment.mli diff --git a/src/lib_embedded_protocol_alpha/src/apply.ml b/src/proto_alpha/lib_protocol_alpha/src/apply.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/apply.ml rename to src/proto_alpha/lib_protocol_alpha/src/apply.ml diff --git a/src/lib_embedded_protocol_alpha/src/baking.ml b/src/proto_alpha/lib_protocol_alpha/src/baking.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/baking.ml rename to src/proto_alpha/lib_protocol_alpha/src/baking.ml diff --git a/src/lib_embedded_protocol_alpha/src/baking.mli b/src/proto_alpha/lib_protocol_alpha/src/baking.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/baking.mli rename to src/proto_alpha/lib_protocol_alpha/src/baking.mli diff --git a/src/lib_embedded_protocol_alpha/src/block_header_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/block_header_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/block_header_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/block_header_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/block_header_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/block_header_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/block_header_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/block_header_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/bootstrap_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/bootstrap_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/bootstrap_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/bootstrap_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/constants_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/constants_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/contract_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/contract_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/contract_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/contract_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/contract_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/contract_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/contract_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/contract_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/contract_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/contract_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/contract_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/contract_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/contract_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/contract_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/contract_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/contract_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/cycle_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/cycle_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/cycle_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/cycle_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/cycle_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/cycle_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/cycle_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/cycle_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/fitness_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/fitness_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/fitness_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/fitness_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/fitness_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/fitness_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/fitness_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/fitness_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/gas.ml b/src/proto_alpha/lib_protocol_alpha/src/gas.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/gas.ml rename to src/proto_alpha/lib_protocol_alpha/src/gas.ml diff --git a/src/lib_embedded_protocol_alpha/src/gas.mli b/src/proto_alpha/lib_protocol_alpha/src/gas.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/gas.mli rename to src/proto_alpha/lib_protocol_alpha/src/gas.mli diff --git a/src/lib_embedded_protocol_alpha/src/init_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/init_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/init_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/init_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/jbuild b/src/proto_alpha/lib_protocol_alpha/src/jbuild new file mode 120000 index 000000000..acda1b059 --- /dev/null +++ b/src/proto_alpha/lib_protocol_alpha/src/jbuild @@ -0,0 +1 @@ +../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_alpha/src/level_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/level_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/level_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/level_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/level_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/level_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/level_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/level_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/level_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/level_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/level_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/level_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/level_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/level_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/level_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/level_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/main.ml b/src/proto_alpha/lib_protocol_alpha/src/main.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/main.ml rename to src/proto_alpha/lib_protocol_alpha/src/main.ml diff --git a/src/lib_embedded_protocol_alpha/src/main.mli b/src/proto_alpha/lib_protocol_alpha/src/main.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/main.mli rename to src/proto_alpha/lib_protocol_alpha/src/main.mli diff --git a/src/lib_embedded_protocol_alpha/src/manager_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/manager_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/manager_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/manager_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/manager_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/manager_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/manager_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/manager_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/michelson_v1_primitives.ml rename to src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.ml diff --git a/src/lib_embedded_protocol_alpha/src/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/michelson_v1_primitives.mli rename to src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.mli diff --git a/src/lib_embedded_protocol_alpha/src/misc.ml b/src/proto_alpha/lib_protocol_alpha/src/misc.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/misc.ml rename to src/proto_alpha/lib_protocol_alpha/src/misc.ml diff --git a/src/lib_embedded_protocol_alpha/src/misc.mli b/src/proto_alpha/lib_protocol_alpha/src/misc.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/misc.mli rename to src/proto_alpha/lib_protocol_alpha/src/misc.mli diff --git a/src/lib_embedded_protocol_alpha/src/nonce_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/nonce_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/nonce_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/nonce_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/nonce_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/nonce_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/nonce_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/nonce_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/operation_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/operation_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/operation_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/operation_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/operation_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/operation_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/operation_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/operation_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/period_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/period_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/period_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/period_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/period_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/period_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/period_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/period_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/public_key_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/public_key_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/public_key_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/public_key_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/public_key_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/public_key_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/public_key_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/public_key_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/qty_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/qty_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/qty_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/qty_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/raw_context.ml b/src/proto_alpha/lib_protocol_alpha/src/raw_context.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/raw_context.ml rename to src/proto_alpha/lib_protocol_alpha/src/raw_context.ml diff --git a/src/lib_embedded_protocol_alpha/src/raw_context.mli b/src/proto_alpha/lib_protocol_alpha/src/raw_context.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/raw_context.mli rename to src/proto_alpha/lib_protocol_alpha/src/raw_context.mli diff --git a/src/lib_embedded_protocol_alpha/src/raw_level_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/raw_level_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/raw_level_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/raw_level_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/reward_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/reward_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/reward_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/reward_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/reward_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/reward_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/reward_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/reward_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/roll_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/roll_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/roll_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/roll_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/roll_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/roll_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/roll_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/roll_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/roll_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/roll_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/roll_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/roll_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/roll_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/roll_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/roll_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/roll_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_int_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/script_int_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_int_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_int_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/script_int_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/script_int_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_int_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/script_int_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_interpreter.ml b/src/proto_alpha/lib_protocol_alpha/src/script_interpreter.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_interpreter.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_interpreter.ml diff --git a/src/lib_embedded_protocol_alpha/src/script_interpreter.mli b/src/proto_alpha/lib_protocol_alpha/src/script_interpreter.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_interpreter.mli rename to src/proto_alpha/lib_protocol_alpha/src/script_interpreter.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_ir_translator.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.ml diff --git a/src/lib_embedded_protocol_alpha/src/script_ir_translator.mli b/src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_ir_translator.mli rename to src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/script_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/script_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/script_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/script_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_timestamp_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_timestamp_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/script_timestamp_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_timestamp_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/script_typed_ir.ml b/src/proto_alpha/lib_protocol_alpha/src/script_typed_ir.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/script_typed_ir.ml rename to src/proto_alpha/lib_protocol_alpha/src/script_typed_ir.ml diff --git a/src/lib_embedded_protocol_alpha/src/seed_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/seed_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/seed_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/seed_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/seed_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/seed_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/seed_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/seed_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/seed_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/seed_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/seed_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/seed_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/seed_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/seed_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/seed_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/seed_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/services.ml b/src/proto_alpha/lib_protocol_alpha/src/services.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/services.ml rename to src/proto_alpha/lib_protocol_alpha/src/services.ml diff --git a/src/lib_embedded_protocol_alpha/src/services_registration.ml b/src/proto_alpha/lib_protocol_alpha/src/services_registration.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/services_registration.ml rename to src/proto_alpha/lib_protocol_alpha/src/services_registration.ml diff --git a/src/lib_embedded_protocol_alpha/src/storage.ml b/src/proto_alpha/lib_protocol_alpha/src/storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/storage.mli b/src/proto_alpha/lib_protocol_alpha/src/storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/storage_functors.ml b/src/proto_alpha/lib_protocol_alpha/src/storage_functors.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/storage_functors.ml rename to src/proto_alpha/lib_protocol_alpha/src/storage_functors.ml diff --git a/src/lib_embedded_protocol_alpha/src/storage_functors.mli b/src/proto_alpha/lib_protocol_alpha/src/storage_functors.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/storage_functors.mli rename to src/proto_alpha/lib_protocol_alpha/src/storage_functors.mli diff --git a/src/lib_embedded_protocol_alpha/src/storage_sigs.ml b/src/proto_alpha/lib_protocol_alpha/src/storage_sigs.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/storage_sigs.ml rename to src/proto_alpha/lib_protocol_alpha/src/storage_sigs.ml diff --git a/src/lib_embedded_protocol_alpha/src/tez_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/tez_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/tez_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/tez_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/tez_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/tez_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/tez_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/tez_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/tezos_context.ml b/src/proto_alpha/lib_protocol_alpha/src/tezos_context.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/tezos_context.ml rename to src/proto_alpha/lib_protocol_alpha/src/tezos_context.ml diff --git a/src/lib_embedded_protocol_alpha/src/tezos_context.mli b/src/proto_alpha/lib_protocol_alpha/src/tezos_context.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/tezos_context.mli rename to src/proto_alpha/lib_protocol_alpha/src/tezos_context.mli diff --git a/src/lib_embedded_protocol_alpha/src/tezos_hash.ml b/src/proto_alpha/lib_protocol_alpha/src/tezos_hash.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/tezos_hash.ml rename to src/proto_alpha/lib_protocol_alpha/src/tezos_hash.ml diff --git a/src/lib_embedded_protocol_alpha/src/time_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/time_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/time_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/time_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/time_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/time_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/time_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/time_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/vote_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/vote_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/vote_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/vote_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/vote_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/vote_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/vote_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/vote_repr.mli diff --git a/src/lib_embedded_protocol_alpha/src/vote_storage.ml b/src/proto_alpha/lib_protocol_alpha/src/vote_storage.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/vote_storage.ml rename to src/proto_alpha/lib_protocol_alpha/src/vote_storage.ml diff --git a/src/lib_embedded_protocol_alpha/src/vote_storage.mli b/src/proto_alpha/lib_protocol_alpha/src/vote_storage.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/vote_storage.mli rename to src/proto_alpha/lib_protocol_alpha/src/vote_storage.mli diff --git a/src/lib_embedded_protocol_alpha/src/voting_period_repr.ml b/src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.ml similarity index 100% rename from src/lib_embedded_protocol_alpha/src/voting_period_repr.ml rename to src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.ml diff --git a/src/lib_embedded_protocol_alpha/src/voting_period_repr.mli b/src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.mli similarity index 100% rename from src/lib_embedded_protocol_alpha/src/voting_period_repr.mli rename to src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.mli diff --git a/src/lib_embedded_protocol_alpha/tezos-embedded-protocol-alpha.opam b/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam similarity index 100% rename from src/lib_embedded_protocol_alpha/tezos-embedded-protocol-alpha.opam rename to src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam diff --git a/src/lib_embedded_protocol_alpha/tezos-protocol-alpha.opam b/src/proto_alpha/lib_protocol_alpha/tezos-protocol-alpha.opam similarity index 100% rename from src/lib_embedded_protocol_alpha/tezos-protocol-alpha.opam rename to src/proto_alpha/lib_protocol_alpha/tezos-protocol-alpha.opam diff --git a/src/lib_embedded_client_demo/client_proto_main.ml b/src/proto_demo/lib_client_demo/client_proto_main.ml similarity index 100% rename from src/lib_embedded_client_demo/client_proto_main.ml rename to src/proto_demo/lib_client_demo/client_proto_main.ml diff --git a/src/lib_embedded_client_demo/client_proto_main.mli b/src/proto_demo/lib_client_demo/client_proto_main.mli similarity index 100% rename from src/lib_embedded_client_demo/client_proto_main.mli rename to src/proto_demo/lib_client_demo/client_proto_main.mli diff --git a/src/lib_embedded_client_demo/client_proto_rpcs.ml b/src/proto_demo/lib_client_demo/client_proto_rpcs.ml similarity index 100% rename from src/lib_embedded_client_demo/client_proto_rpcs.ml rename to src/proto_demo/lib_client_demo/client_proto_rpcs.ml diff --git a/src/lib_embedded_client_demo/client_proto_rpcs.mli b/src/proto_demo/lib_client_demo/client_proto_rpcs.mli similarity index 100% rename from src/lib_embedded_client_demo/client_proto_rpcs.mli rename to src/proto_demo/lib_client_demo/client_proto_rpcs.mli diff --git a/src/proto_demo/lib_protocol_demo/jbuild b/src/proto_demo/lib_protocol_demo/jbuild new file mode 120000 index 000000000..3dc6e1fbd --- /dev/null +++ b/src/proto_demo/lib_protocol_demo/jbuild @@ -0,0 +1 @@ +../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_demo/src/TEZOS_PROTOCOL b/src/proto_demo/lib_protocol_demo/src/TEZOS_PROTOCOL similarity index 100% rename from src/lib_embedded_protocol_demo/src/TEZOS_PROTOCOL rename to src/proto_demo/lib_protocol_demo/src/TEZOS_PROTOCOL diff --git a/src/lib_embedded_protocol_demo/src/error.ml b/src/proto_demo/lib_protocol_demo/src/error.ml similarity index 100% rename from src/lib_embedded_protocol_demo/src/error.ml rename to src/proto_demo/lib_protocol_demo/src/error.ml diff --git a/src/proto_demo/lib_protocol_demo/src/jbuild b/src/proto_demo/lib_protocol_demo/src/jbuild new file mode 120000 index 000000000..acda1b059 --- /dev/null +++ b/src/proto_demo/lib_protocol_demo/src/jbuild @@ -0,0 +1 @@ +../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_demo/src/main.ml b/src/proto_demo/lib_protocol_demo/src/main.ml similarity index 100% rename from src/lib_embedded_protocol_demo/src/main.ml rename to src/proto_demo/lib_protocol_demo/src/main.ml diff --git a/src/lib_embedded_protocol_demo/src/services.ml b/src/proto_demo/lib_protocol_demo/src/services.ml similarity index 100% rename from src/lib_embedded_protocol_demo/src/services.ml rename to src/proto_demo/lib_protocol_demo/src/services.ml diff --git a/src/lib_embedded_protocol_demo/tezos-embedded-protocol-demo.opam b/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam similarity index 100% rename from src/lib_embedded_protocol_demo/tezos-embedded-protocol-demo.opam rename to src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam diff --git a/src/lib_embedded_protocol_demo/tezos-protocol-demo.opam b/src/proto_demo/lib_protocol_demo/tezos-protocol-demo.opam similarity index 100% rename from src/lib_embedded_protocol_demo/tezos-protocol-demo.opam rename to src/proto_demo/lib_protocol_demo/tezos-protocol-demo.opam diff --git a/src/lib_embedded_client_genesis/client_proto_main.ml b/src/proto_genesis/lib_client_genesis/client_proto_main.ml similarity index 100% rename from src/lib_embedded_client_genesis/client_proto_main.ml rename to src/proto_genesis/lib_client_genesis/client_proto_main.ml diff --git a/src/lib_embedded_client_genesis/client_proto_main.mli b/src/proto_genesis/lib_client_genesis/client_proto_main.mli similarity index 100% rename from src/lib_embedded_client_genesis/client_proto_main.mli rename to src/proto_genesis/lib_client_genesis/client_proto_main.mli diff --git a/src/lib_embedded_client_genesis/jbuild b/src/proto_genesis/lib_client_genesis/jbuild similarity index 100% rename from src/lib_embedded_client_genesis/jbuild rename to src/proto_genesis/lib_client_genesis/jbuild diff --git a/src/lib_embedded_client_genesis/tezos-embedded-client-genesis.opam b/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam similarity index 100% rename from src/lib_embedded_client_genesis/tezos-embedded-client-genesis.opam rename to src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam diff --git a/src/proto_genesis/lib_protocol_genesis/jbuild b/src/proto_genesis/lib_protocol_genesis/jbuild new file mode 120000 index 000000000..3dc6e1fbd --- /dev/null +++ b/src/proto_genesis/lib_protocol_genesis/jbuild @@ -0,0 +1 @@ +../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_genesis/src/TEZOS_PROTOCOL b/src/proto_genesis/lib_protocol_genesis/src/TEZOS_PROTOCOL similarity index 100% rename from src/lib_embedded_protocol_genesis/src/TEZOS_PROTOCOL rename to src/proto_genesis/lib_protocol_genesis/src/TEZOS_PROTOCOL diff --git a/src/lib_embedded_protocol_genesis/src/data.ml b/src/proto_genesis/lib_protocol_genesis/src/data.ml similarity index 100% rename from src/lib_embedded_protocol_genesis/src/data.ml rename to src/proto_genesis/lib_protocol_genesis/src/data.ml diff --git a/src/proto_genesis/lib_protocol_genesis/src/jbuild b/src/proto_genesis/lib_protocol_genesis/src/jbuild new file mode 120000 index 000000000..acda1b059 --- /dev/null +++ b/src/proto_genesis/lib_protocol_genesis/src/jbuild @@ -0,0 +1 @@ +../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file diff --git a/src/lib_embedded_protocol_genesis/src/main.ml b/src/proto_genesis/lib_protocol_genesis/src/main.ml similarity index 100% rename from src/lib_embedded_protocol_genesis/src/main.ml rename to src/proto_genesis/lib_protocol_genesis/src/main.ml diff --git a/src/lib_embedded_protocol_genesis/src/services.ml b/src/proto_genesis/lib_protocol_genesis/src/services.ml similarity index 100% rename from src/lib_embedded_protocol_genesis/src/services.ml rename to src/proto_genesis/lib_protocol_genesis/src/services.ml diff --git a/src/lib_embedded_protocol_genesis/tezos-embedded-protocol-genesis.opam b/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam similarity index 100% rename from src/lib_embedded_protocol_genesis/tezos-embedded-protocol-genesis.opam rename to src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam diff --git a/src/lib_embedded_protocol_genesis/tezos-protocol-genesis.opam b/src/proto_genesis/lib_protocol_genesis/tezos-protocol-genesis.opam similarity index 100% rename from src/lib_embedded_protocol_genesis/tezos-protocol-genesis.opam rename to src/proto_genesis/lib_protocol_genesis/tezos-protocol-genesis.opam From e0a2570988138a0b0441a489681233777bbc924e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 18:58:43 +0100 Subject: [PATCH 03/27] Refactor: Rename `Node_rpc_services.Network` into `P2p_services` --- src/lib_client_base/client_node_rpcs.ml | 10 +- src/lib_node_p2p_base/p2p_services.ml | 167 +++++++++++++ src/lib_node_p2p_base/p2p_services.mli | 83 +++++++ src/lib_node_services/node_rpc_services.ml | 235 ++---------------- src/lib_node_services/node_rpc_services.mli | 84 ------- src/lib_node_shell/node_rpc.ml | 31 ++- src/lib_rpc/RPC_error.ml | 46 ++++ src/lib_rpc/RPC_error.mli | 15 ++ src/lib_rpc/jbuild | 4 +- .../lib_client_alpha/client_baking_forge.ml | 2 +- 10 files changed, 353 insertions(+), 324 deletions(-) create mode 100644 src/lib_node_p2p_base/p2p_services.ml create mode 100644 src/lib_node_p2p_base/p2p_services.mli create mode 100644 src/lib_rpc/RPC_error.ml create mode 100644 src/lib_rpc/RPC_error.mli diff --git a/src/lib_client_base/client_node_rpcs.ml b/src/lib_client_base/client_node_rpcs.ml index fd25d3f4e..39439e239 100644 --- a/src/lib_client_base/client_node_rpcs.ml +++ b/src/lib_client_base/client_node_rpcs.ml @@ -13,7 +13,7 @@ open Client_rpcs module Services = Node_rpc_services let errors (rpc : #Client_rpcs.ctxt) = - call_service0 rpc Services.Error.service () + call_service0 rpc RPC_error.service () let forge_block_header rpc header = call_service0 rpc Services.forge_block_header header @@ -147,15 +147,15 @@ end module Network = struct let stat cctxt = - call_service0 cctxt Services.Network.stat () + call_service0 cctxt P2p_services.stat () let connections cctxt = - call_service0 cctxt Services.Network.Connection.list () + call_service0 cctxt P2p_services.Connection.list () let peers cctxt = - call_service0 cctxt Services.Network.Peer_id.list [] + call_service0 cctxt P2p_services.Peer_id.list [] let points cctxt = - call_service0 cctxt Services.Network.Point.list [] + call_service0 cctxt P2p_services.Point.list [] end diff --git a/src/lib_node_p2p_base/p2p_services.ml b/src/lib_node_p2p_base/p2p_services.ml new file mode 100644 index 000000000..08907c4df --- /dev/null +++ b/src/lib_node_p2p_base/p2p_services.ml @@ -0,0 +1,167 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open P2p_types + +let (peer_id_arg : P2p_types.Peer_id.t RPC_arg.arg) = + Crypto_box.Public_key_hash.rpc_arg + +let point_arg = + RPC_arg.make + ~name:"point" + ~descr:"A network point (ipv4:port or [ipv6]:port)." + ~destruct:Point.of_string + ~construct:Point.to_string + () + +let versions = + RPC_service.post_service + ~description:"Supported network layer versions." + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: (Data_encoding.list P2p_types.Version.encoding) + ~error: Data_encoding.empty + RPC_path.(root / "network" / "versions") + +let stat = + RPC_service.post_service + ~description:"Global network bandwidth statistics in B/s." + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: P2p_types.Stat.encoding + ~error: Data_encoding.empty + RPC_path.(root / "network" / "stat") + +let events = + RPC_service.post_service + ~description:"Stream of all network events" + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: P2p_types.Connection_pool_log_event.encoding + ~error: Data_encoding.empty + RPC_path.(root / "network" / "log") + +let connect = + RPC_service.post_service + ~description:"Connect to a peer" + ~query: RPC_query.empty + ~input: Data_encoding.(obj1 (dft "timeout" float 5.)) + ~output: (RPC_error.wrap Data_encoding.empty) + ~error: Data_encoding.empty + RPC_path.(root / "network" / "connect" /: point_arg) + +let monitor_encoding = Data_encoding.(obj1 (dft "monitor" bool false)) + +module Connection = struct + + let list = + RPC_service.post_service + ~description:"List the running P2P connection." + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: (Data_encoding.list P2p_types.Connection_info.encoding) + ~error: Data_encoding.empty + RPC_path.(root / "network" / "connection") + + let info = + RPC_service.post_service + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: (Data_encoding.option P2p_types.Connection_info.encoding) + ~error: Data_encoding.empty + ~description:"Details about the current P2P connection to the given peer." + RPC_path.(root / "network" / "connection" /: peer_id_arg) + + let kick = + RPC_service.post_service + ~query: RPC_query.empty + ~input: Data_encoding.(obj1 (req "wait" bool)) + ~output: Data_encoding.empty + ~error: Data_encoding.empty + ~description:"Forced close of the current P2P connection to the given peer." + RPC_path.(root / "network" / "connection" /: peer_id_arg / "kick") + +end + +module Point = struct + + let info = + RPC_service.post_service + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: (Data_encoding.option P2p_types.Point_info.encoding) + ~error: Data_encoding.empty + ~description: "Details about a given `IP:addr`." + RPC_path.(root / "network" / "point" /: point_arg) + + let events = + RPC_service.post_service + ~query: RPC_query.empty + ~input: monitor_encoding + ~output: (Data_encoding.list + P2p_connection_pool_types.Point_info.Event.encoding) + ~error: Data_encoding.empty + ~description: "Monitor network events related to an `IP:addr`." + RPC_path.(root / "network" / "point" /: point_arg / "log") + + let list = + let filter = + let open Data_encoding in + obj1 (dft "filter" (list P2p_types.Point_state.encoding) []) in + RPC_service.post_service + ~query: RPC_query.empty + ~input: filter + ~output: + Data_encoding.(list (tup2 + P2p_types.Point.encoding + P2p_types.Point_info.encoding)) + ~error: Data_encoding.empty + ~description:"List the pool of known `IP:port` \ + used for establishing P2P connections ." + RPC_path.(root / "network" / "point") + +end + +module Peer_id = struct + + let info = + RPC_service.post_service + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: (Data_encoding.option P2p_types.Peer_info.encoding) + ~error: Data_encoding.empty + ~description:"Details about a given peer." + RPC_path.(root / "network" / "peer_id" /: peer_id_arg) + + let events = + RPC_service.post_service + ~query: RPC_query.empty + ~input: monitor_encoding + ~output: (Data_encoding.list + P2p_connection_pool_types.Peer_info.Event.encoding) + ~error: Data_encoding.empty + ~description:"Monitor network events related to a given peer." + RPC_path.(root / "network" / "peer_id" /: peer_id_arg / "log") + + let list = + let filter = + let open Data_encoding in + obj1 (dft "filter" (list P2p_types.Peer_state.encoding) []) in + RPC_service.post_service + ~query: RPC_query.empty + ~input: filter + ~output: + Data_encoding.(list (tup2 + P2p_types.Peer_id.encoding + P2p_types.Peer_info.encoding)) + ~error: Data_encoding.empty + ~description:"List the peers the node ever met." + RPC_path.(root / "network" / "peer_id") + +end diff --git a/src/lib_node_p2p_base/p2p_services.mli b/src/lib_node_p2p_base/p2p_services.mli new file mode 100644 index 000000000..719640c47 --- /dev/null +++ b/src/lib_node_p2p_base/p2p_services.mli @@ -0,0 +1,83 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open P2p_types + +val stat : + ([ `POST ], unit, + unit, unit, unit, + Stat.t, unit) RPC_service.t + +val versions : + ([ `POST ], unit, + unit, unit, unit, + Version.t list, unit) RPC_service.t + +val events : + ([ `POST ], unit, + unit, unit, unit, + Connection_pool_log_event.t, unit) RPC_service.t + +val connect : + ([ `POST ], unit, + unit * Point.t, unit, float, + unit tzresult, unit) RPC_service.t + +module Connection : sig + + val list : + ([ `POST ], unit, + unit, unit, unit, + Connection_info.t list, unit) RPC_service.t + + val info : + ([ `POST ], unit, + unit * Peer_id.t, unit, unit, + Connection_info.t option, unit) RPC_service.t + + val kick : + ([ `POST ], unit, + unit * Peer_id.t, unit, bool, + unit, unit) RPC_service.t + +end + +module Point : sig + val list : + ([ `POST ], unit, + unit, unit, Point_state.t list, + (Point.t * Point_info.t) list, unit) RPC_service.t + val info : + ([ `POST ], unit, + unit * Point.t, unit, unit, + Point_info.t option, unit) RPC_service.t + val events : + ([ `POST ], unit, + unit * Point.t, unit, bool, + P2p_connection_pool_types.Point_info.Event.t list, unit) RPC_service.t +end + +module Peer_id : sig + + val list : + ([ `POST ], unit, + unit, unit, Peer_state.t list, + (Peer_id.t * Peer_info.t) list, unit) RPC_service.t + + val info : + ([ `POST ], unit, + unit * Peer_id.t, unit, unit, + Peer_info.t option, unit) RPC_service.t + + val events : + ([ `POST ], unit, + unit * Peer_id.t, unit, bool, + P2p_connection_pool_types.Peer_info.Event.t list, unit) RPC_service.t + +end diff --git a/src/lib_node_services/node_rpc_services.ml b/src/lib_node_services/node_rpc_services.ml index 1ce69227f..9189de1e2 100644 --- a/src/lib_node_services/node_rpc_services.ml +++ b/src/lib_node_services/node_rpc_services.ml @@ -9,46 +9,6 @@ open Data_encoding -module Error = struct - - let service = - RPC_service.post_service - ~description: "Schema for all the RPC errors from the shell" - ~query: RPC_query.empty - ~input: Data_encoding.empty - ~output: Data_encoding.json_schema - ~error: Data_encoding.empty - RPC_path.(root / "errors") - - let encoding = - let { RPC_service.meth ; uri ; _ } = - RPC_service.forge_request service () () in - describe - ~description: - (Printf.sprintf - "The full list of error is available with \ - the global RPC `%s %s`" - (RPC_service.string_of_meth meth) (Uri.path_and_query uri)) - (conv - ~schema:Json_schema.any - (fun exn -> `A (List.map json_of_error exn)) - (function `A exns -> List.map error_of_json exns | _ -> []) - json) - - let wrap param_encoding = - union [ - case (Tag 0) - (obj1 (req "ok" param_encoding)) - (function Ok x -> Some x | _ -> None) - (fun x -> Ok x) ; - case (Tag 1) - (obj1 (req "error" encoding)) - (function Error x -> Some x | _ -> None) - (fun x -> Error x) ; - ] - -end - module Blocks = struct type block = [ @@ -306,7 +266,7 @@ module Blocks = struct unprocessed Operation_hash.Map.empty)) (merge_objs (dynamic_size - (Preapply_result.encoding Error.encoding)) + (Preapply_result.encoding RPC_error.encoding)) (obj1 (req "unprocessed" (list (dynamic_size operation_encoding)))))) ~error: Data_encoding.empty RPC_path.(block_path / "pending_operations") @@ -347,7 +307,7 @@ module Blocks = struct (obj2 (req "shell_header" Block_header.shell_header_encoding) (req "operations" - (list (Preapply_result.encoding Error.encoding))))) + (list (Preapply_result.encoding RPC_error.encoding))))) let preapply = RPC_service.post_service @@ -356,7 +316,7 @@ module Blocks = struct the given operations and return the resulting fitness." ~query: RPC_query.empty ~input: preapply_param_encoding - ~output: (Error.wrap preapply_result_encoding) + ~output: (RPC_error.wrap preapply_result_encoding) ~error: Data_encoding.empty RPC_path.(block_path / "preapply") @@ -463,7 +423,7 @@ module Blocks = struct (obj3 (req "block" Block_hash.encoding) (req "level" int32) - (req "errors" Error.encoding))) + (req "errors" RPC_error.encoding))) ~error: Data_encoding.empty RPC_path.(root / "invalid_blocks") @@ -549,7 +509,7 @@ module Workers = struct (list (obj2 (req "net_id" Net_id.encoding) - (req "status" (Worker_types.worker_status_encoding Error.encoding)))) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) RPC_path.(root / "workers" / "prevalidators") let state = @@ -562,8 +522,8 @@ module Workers = struct ~output: (Worker_types.full_status_encoding Prevalidator_worker_state.Request.encoding - (Prevalidator_worker_state.Event.encoding Error.encoding) - Error.encoding) + (Prevalidator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) RPC_path.(root / "workers" / "prevalidators" /: net_id_arg ) end @@ -580,8 +540,8 @@ module Workers = struct ~output: (Worker_types.full_status_encoding Block_validator_worker_state.Request.encoding - (Block_validator_worker_state.Event.encoding Error.encoding) - Error.encoding) + (Block_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) RPC_path.(root / "workers" / "block_validator") end @@ -618,7 +578,7 @@ module Workers = struct (list (obj2 (req "peer_id" P2p_types.Peer_id.encoding) - (req "status" (Worker_types.worker_status_encoding Error.encoding)))) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) RPC_path.(root / "workers" / "peer_validators" /: net_id_arg) let state = @@ -631,8 +591,8 @@ module Workers = struct ~output: (Worker_types.full_status_encoding Peer_validator_worker_state.Request.encoding - (Peer_validator_worker_state.Event.encoding Error.encoding) - Error.encoding) + (Peer_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg) end @@ -659,7 +619,7 @@ module Workers = struct (list (obj2 (req "net_id" Net_id.encoding) - (req "status" (Worker_types.worker_status_encoding Error.encoding)))) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) RPC_path.(root / "workers" / "net_validators") let state = @@ -672,8 +632,8 @@ module Workers = struct ~output: (Worker_types.full_status_encoding Net_validator_worker_state.Request.encoding - (Net_validator_worker_state.Event.encoding Error.encoding) - Error.encoding) + (Net_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) RPC_path.(root / "workers" / "net_validators" /: net_id_arg ) end @@ -681,165 +641,6 @@ module Workers = struct end -module Network = struct - - open P2p_types - - let (peer_id_arg : P2p_types.Peer_id.t RPC_arg.arg) = - Crypto_box.Public_key_hash.rpc_arg - - let point_arg = - RPC_arg.make - ~name:"point" - ~descr:"A network point (ipv4:port or [ipv6]:port)." - ~destruct:Point.of_string - ~construct:Point.to_string - () - - let versions = - RPC_service.post_service - ~description:"Supported network layer versions." - ~query: RPC_query.empty - ~input: empty - ~output: (list P2p_types.Version.encoding) - ~error: Data_encoding.empty - RPC_path.(root / "network" / "versions") - - let stat = - RPC_service.post_service - ~description:"Global network bandwidth statistics in B/s." - ~query: RPC_query.empty - ~input: empty - ~output: P2p_types.Stat.encoding - ~error: Data_encoding.empty - RPC_path.(root / "network" / "stat") - - let events = - RPC_service.post_service - ~description:"Stream of all network events" - ~query: RPC_query.empty - ~input: empty - ~output: P2p_types.Connection_pool_log_event.encoding - ~error: Data_encoding.empty - RPC_path.(root / "network" / "log") - - let connect = - RPC_service.post_service - ~description:"Connect to a peer" - ~query: RPC_query.empty - ~input: (obj1 (dft "timeout" float 5.)) - ~output: (Error.wrap @@ empty) - ~error: Data_encoding.empty - RPC_path.(root / "network" / "connect" /: point_arg) - - let monitor_encoding = obj1 (dft "monitor" bool false) - - module Connection = struct - - let list = - RPC_service.post_service - ~description:"List the running P2P connection." - ~query: RPC_query.empty - ~input: empty - ~output: (list P2p_types.Connection_info.encoding) - ~error: Data_encoding.empty - RPC_path.(root / "network" / "connection") - - let info = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: (option P2p_types.Connection_info.encoding) - ~error: Data_encoding.empty - ~description:"Details about the current P2P connection to the given peer." - RPC_path.(root / "network" / "connection" /: peer_id_arg) - - let kick = - RPC_service.post_service - ~query: RPC_query.empty - ~input: (obj1 (req "wait" bool)) - ~output: empty - ~error: Data_encoding.empty - ~description:"Forced close of the current P2P connection to the given peer." - RPC_path.(root / "network" / "connection" /: peer_id_arg / "kick") - - end - - module Point = struct - - let info = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: (option P2p_types.Point_info.encoding) - ~error: Data_encoding.empty - ~description: "Details about a given `IP:addr`." - RPC_path.(root / "network" / "point" /: point_arg) - - let events = - RPC_service.post_service - ~query: RPC_query.empty - ~input: monitor_encoding - ~output: (list P2p_connection_pool_types.Point_info.Event.encoding) - ~error: Data_encoding.empty - ~description: "Monitor network events related to an `IP:addr`." - RPC_path.(root / "network" / "point" /: point_arg / "log") - - let list = - let filter = - obj1 (dft "filter" (list P2p_types.Point_state.encoding) []) in - RPC_service.post_service - ~query: RPC_query.empty - ~input: filter - ~output: - (list (tup2 - P2p_types.Point.encoding - P2p_types.Point_info.encoding)) - ~error: Data_encoding.empty - ~description:"List the pool of known `IP:port` \ - used for establishing P2P connections ." - RPC_path.(root / "network" / "point") - - end - - module Peer_id = struct - - let info = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: (option P2p_types.Peer_info.encoding) - ~error: Data_encoding.empty - ~description:"Details about a given peer." - RPC_path.(root / "network" / "peer_id" /: peer_id_arg) - - let events = - RPC_service.post_service - ~query: RPC_query.empty - ~input: monitor_encoding - ~output: (list P2p_connection_pool_types.Peer_info.Event.encoding) - ~error: Data_encoding.empty - ~description:"Monitor network events related to a given peer." - RPC_path.(root / "network" / "peer_id" /: peer_id_arg / "log") - - let list = - let filter = - obj1 (dft "filter" (list P2p_types.Peer_state.encoding) []) in - RPC_service.post_service - ~query: RPC_query.empty - ~input: filter - ~output: - (list (tup2 - P2p_types.Peer_id.encoding - P2p_types.Peer_info.encoding)) - ~error: Data_encoding.empty - ~description:"List the peers the node ever met." - RPC_path.(root / "network" / "peer_id") - - end - -end - let forge_block_header = RPC_service.post_service ~description: "Forge a block header" @@ -897,7 +698,7 @@ let inject_block = ~query: RPC_query.empty ~input: inject_block_param ~output: - (Error.wrap @@ + (RPC_error.wrap @@ (obj1 (req "block_hash" Block_hash.encoding))) ~error: Data_encoding.empty RPC_path.(root / "inject_block") @@ -927,7 +728,7 @@ let inject_operation = true) (opt "net_id" Net_id.encoding)) ~output: - (Error.wrap @@ + (RPC_error.wrap @@ describe ~title: "Hash of the injected operation" @@ (obj1 (req "injectedOperation" Operation_hash.encoding))) @@ -956,7 +757,7 @@ let inject_protocol = "Should we inject protocol that is invalid. (default: false)" bool))) ~output: - (Error.wrap @@ + (RPC_error.wrap @@ describe ~title: "Hash of the injected protocol" @@ (obj1 (req "injectedProtocol" Protocol_hash.encoding))) diff --git a/src/lib_node_services/node_rpc_services.mli b/src/lib_node_services/node_rpc_services.mli index c6c86fb10..1b553f194 100644 --- a/src/lib_node_services/node_rpc_services.mli +++ b/src/lib_node_services/node_rpc_services.mli @@ -7,13 +7,6 @@ (* *) (**************************************************************************) -module Error : sig - val service: - ([ `POST ], unit, unit, unit, unit, Json_schema.schema, unit) RPC_service.t - val encoding: error list Data_encoding.t - val wrap: 'a Data_encoding.t -> 'a tzresult Data_encoding.encoding -end - module Blocks : sig type block = [ @@ -237,83 +230,6 @@ module Workers : sig end -module Network : sig - - val stat : - ([ `POST ], unit, - unit, unit, unit, - P2p_types.Stat.t, unit) RPC_service.t - - val versions : - ([ `POST ], unit, - unit, unit, unit, - P2p_types.Version.t list, unit) RPC_service.t - - val events : - ([ `POST ], unit, - unit, unit, unit, - P2p_types.Connection_pool_log_event.t, unit) RPC_service.t - - val connect : - ([ `POST ], unit, - unit * P2p_types.Point.t, unit, float, - unit tzresult, unit) RPC_service.t - - module Connection : sig - - val list : - ([ `POST ], unit, - unit, unit, unit, - P2p_types.Connection_info.t list, unit) RPC_service.t - - val info : - ([ `POST ], unit, - unit * P2p_types.Peer_id.t, unit, unit, - P2p_types.Connection_info.t option, unit) RPC_service.t - - val kick : - ([ `POST ], unit, - unit * P2p_types.Peer_id.t, unit, bool, - unit, unit) RPC_service.t - - end - - module Point : sig - val list : - ([ `POST ], unit, - unit, unit, P2p_types.Point_state.t list, - (P2p_types.Point.t * P2p_types.Point_info.t) list, unit) RPC_service.t - val info : - ([ `POST ], unit, - unit * P2p_types.Point.t, unit, unit, - P2p_types.Point_info.t option, unit) RPC_service.t - val events : - ([ `POST ], unit, - unit * P2p_types.Point.t, unit, bool, - P2p_connection_pool_types.Point_info.Event.t list, unit) RPC_service.t - end - - module Peer_id : sig - - val list : - ([ `POST ], unit, - unit, unit, P2p_types.Peer_state.t list, - (P2p_types.Peer_id.t * P2p_types.Peer_info.t) list, unit) RPC_service.t - - val info : - ([ `POST ], unit, - unit * P2p_types.Peer_id.t, unit, unit, - P2p_types.Peer_info.t option, unit) RPC_service.t - - val events : - ([ `POST ], unit, - unit * P2p_types.Peer_id.t, unit, bool, - P2p_connection_pool_types.Peer_info.Event.t list, unit) RPC_service.t - - end - -end - val forge_block_header: ([ `POST ], unit, unit, unit, Block_header.t, diff --git a/src/lib_node_shell/node_rpc.ml b/src/lib_node_shell/node_rpc.ml index 9745eaa3d..8739f1e1c 100644 --- a/src/lib_node_shell/node_rpc.ml +++ b/src/lib_node_shell/node_rpc.ml @@ -442,7 +442,7 @@ let build_rpc_directory node = let implementation () () = RPC_answer.return Data_encoding.Json.(schema Error_monad.error_encoding) in - RPC_directory.register0 dir Services.Error.service implementation in + RPC_directory.register0 dir RPC_error.service implementation in let dir = RPC_directory.register1 dir Services.complete (fun s () () -> @@ -527,50 +527,49 @@ let build_rpc_directory node = (* Network : Global *) let dir = - let implementation () () = - Node.RPC.Network.stat node |> RPC_answer.return in - RPC_directory.register0 dir Services.Network.stat implementation in + let implementation () () = Node.RPC.Network.stat node |> RPC_answer.return in + RPC_directory.register0 dir P2p_services.stat implementation in let dir = let implementation () () = RPC_answer.return Distributed_db.Raw.supported_versions in - RPC_directory.register0 dir Services.Network.versions implementation in + RPC_directory.register0 dir P2p_services.versions implementation in let dir = let implementation () () = let stream, stopper = Node.RPC.Network.watch node in let shutdown () = Lwt_watcher.shutdown stopper in let next () = Lwt_stream.get stream in RPC_answer.return_stream { next ; shutdown } in - RPC_directory.register0 dir Services.Network.events implementation in + RPC_directory.register0 dir P2p_services.events implementation in let dir = let implementation point () timeout = Node.RPC.Network.connect node point timeout >>= RPC_answer.return in - RPC_directory.register1 dir Services.Network.connect implementation in + RPC_directory.register1 dir P2p_services.connect implementation in (* Network : Connection *) let dir = let implementation peer_id () () = Node.RPC.Network.Connection.info node peer_id |> RPC_answer.return in - RPC_directory.register1 dir Services.Network.Connection.info implementation in + RPC_directory.register1 dir P2p_services.Connection.info implementation in let dir = let implementation peer_id () wait = Node.RPC.Network.Connection.kick node peer_id wait >>= RPC_answer.return in - RPC_directory.register1 dir Services.Network.Connection.kick implementation in + RPC_directory.register1 dir P2p_services.Connection.kick implementation in let dir = let implementation () () = Node.RPC.Network.Connection.list node |> RPC_answer.return in - RPC_directory.register0 dir Services.Network.Connection.list implementation in + RPC_directory.register0 dir P2p_services.Connection.list implementation in (* Network : Peer_id *) let dir = let implementation () state = Node.RPC.Network.Peer_id.list node ~restrict:state |> RPC_answer.return in - RPC_directory.register0 dir Services.Network.Peer_id.list implementation in + RPC_directory.register0 dir P2p_services.Peer_id.list implementation in let dir = let implementation peer_id () () = Node.RPC.Network.Peer_id.info node peer_id |> RPC_answer.return in - RPC_directory.register1 dir Services.Network.Peer_id.info implementation in + RPC_directory.register1 dir P2p_services.Peer_id.info implementation in let dir = let implementation peer_id () monitor = if monitor then @@ -587,18 +586,18 @@ let build_rpc_directory node = RPC_answer.return_stream { next ; shutdown } else Node.RPC.Network.Peer_id.events node peer_id |> RPC_answer.return in - RPC_directory.register1 dir Services.Network.Peer_id.events implementation in + RPC_directory.register1 dir P2p_services.Peer_id.events implementation in (* Network : Point *) let dir = let implementation () state = Node.RPC.Network.Point.list node ~restrict:state |> RPC_answer.return in - RPC_directory.register0 dir Services.Network.Point.list implementation in + RPC_directory.register0 dir P2p_services.Point.list implementation in let dir = let implementation point () () = Node.RPC.Network.Point.info node point |> RPC_answer.return in - RPC_directory.register1 dir Services.Network.Point.info implementation in + RPC_directory.register1 dir P2p_services.Point.info implementation in let dir = let implementation point () monitor = if monitor then @@ -615,7 +614,7 @@ let build_rpc_directory node = RPC_answer.return_stream { next ; shutdown } else Node.RPC.Network.Point.events node point |> RPC_answer.return in - RPC_directory.register1 dir Services.Network.Point.events implementation in + RPC_directory.register1 dir P2p_services.Point.events implementation in let dir = RPC_directory.register_describe_directory_service dir Services.describe in dir diff --git a/src/lib_rpc/RPC_error.ml b/src/lib_rpc/RPC_error.ml new file mode 100644 index 000000000..eb3b86339 --- /dev/null +++ b/src/lib_rpc/RPC_error.ml @@ -0,0 +1,46 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +let service = + RPC_service.post_service + ~description: "Schema for all the RPC errors from the shell" + ~query: RPC_query.empty + ~input: Data_encoding.empty + ~output: Data_encoding.json_schema + ~error: Data_encoding.empty + RPC_path.(root / "errors") + +let encoding = + let { RPC_service.meth ; uri ; _ } = + RPC_service.forge_request service () () in + let open Data_encoding in + describe + ~description: + (Printf.sprintf + "The full list of error is available with \ + the global RPC `%s %s`" + (RPC_service.string_of_meth meth) (Uri.path_and_query uri)) + (conv + ~schema:Json_schema.any + (fun exn -> `A (List.map Error_monad.json_of_error exn)) + (function `A exns -> List.map Error_monad.error_of_json exns | _ -> []) + json) + +let wrap param_encoding = + let open Data_encoding in + union [ + case (Tag 0) + (obj1 (req "ok" param_encoding)) + (function Ok x -> Some x | _ -> None) + (fun x -> Ok x) ; + case (Tag 1) + (obj1 (req "error" encoding)) + (function Error x -> Some x | _ -> None) + (fun x -> Error x) ; + ] diff --git a/src/lib_rpc/RPC_error.mli b/src/lib_rpc/RPC_error.mli new file mode 100644 index 000000000..60acdac91 --- /dev/null +++ b/src/lib_rpc/RPC_error.mli @@ -0,0 +1,15 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Error_monad + +val service: + ([ `POST ], unit, unit, unit, unit, Json_schema.schema, unit) RPC_service.t +val encoding: error list Data_encoding.t +val wrap: 'a Data_encoding.t -> 'a tzresult Data_encoding.encoding diff --git a/src/lib_rpc/jbuild b/src/lib_rpc/jbuild index 83680e92c..497f3795c 100644 --- a/src/lib_rpc/jbuild +++ b/src/lib_rpc/jbuild @@ -4,10 +4,12 @@ ((name tezos_rpc) (public_name tezos-rpc) (libraries (tezos-data-encoding + tezos-error-monad ocplib-resto)) (flags (:standard -w -9+27-30-32-40@8 -safe-string - -open Tezos_data_encoding)))) + -open Tezos_data_encoding + -open Tezos_error_monad)))) (alias ((name runtest_indent) diff --git a/src/proto_alpha/lib_client_alpha/client_baking_forge.ml b/src/proto_alpha/lib_client_alpha/client_baking_forge.ml index 3ad8ebbbe..9c9a32c81 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_forge.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_forge.ml @@ -86,7 +86,7 @@ let () = Data_encoding. (obj2 (req "operation" (dynamic_size Tezos_base.Operation.encoding)) - (req "error" Node_rpc_services.Error.encoding)) + (req "error" RPC_error.encoding)) (function | Failed_to_preapply (hash, err) -> Some (hash, err) | _ -> None) From 4acdfc67fb539222d0bd3940a7e336c0c4048590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 19:08:18 +0100 Subject: [PATCH 04/27] Refactor: Remame `lib_node_p2p/p2p_base` into `lib_p2p/p2p_services` --- src/bin_node/jbuild | 12 ++++++------ src/lib_client_base/jbuild | 4 ++-- src/lib_client_base/tezos-client-base.opam | 2 +- src/lib_node_services/jbuild | 4 ++-- src/lib_node_services/tezos-node-services.opam | 3 +-- src/lib_node_shell/jbuild | 8 ++++---- src/lib_node_shell/tezos-node-shell.opam | 4 ++-- src/lib_node_shell_base/jbuild | 4 ++-- src/lib_node_shell_base/tezos-node-shell-base.opam | 2 +- src/lib_node_updater/jbuild | 6 +++--- src/lib_node_updater/tezos-node-updater.opam | 2 +- src/{lib_node_p2p => lib_p2p}/jbuild | 8 ++++---- src/{lib_node_p2p => lib_p2p}/moving_average.ml | 0 src/{lib_node_p2p => lib_p2p}/moving_average.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_connection.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p_connection.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_connection_pool.ml | 0 .../p2p_connection_pool.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_discovery.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p_discovery.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_io_scheduler.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p_io_scheduler.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_maintenance.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p_maintenance.mli | 0 src/{lib_node_p2p => lib_p2p}/p2p_welcome.ml | 0 src/{lib_node_p2p => lib_p2p}/p2p_welcome.mli | 0 .../tezos-node-p2p.opam => lib_p2p/tezos-p2p.opam} | 2 +- src/{lib_node_p2p_base => lib_p2p_services}/jbuild | 4 ++-- .../p2p_connection_pool_types.ml | 0 .../p2p_connection_pool_types.mli | 0 .../p2p_services.ml | 0 .../p2p_services.mli | 0 .../p2p_types.ml | 0 .../p2p_types.mli | 0 .../tezos-p2p-services.opam} | 0 test/p2p/jbuild | 8 ++++---- 38 files changed, 36 insertions(+), 37 deletions(-) rename src/{lib_node_p2p => lib_p2p}/jbuild (70%) rename src/{lib_node_p2p => lib_p2p}/moving_average.ml (100%) rename src/{lib_node_p2p => lib_p2p}/moving_average.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_connection.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_connection.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_connection_pool.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_connection_pool.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_discovery.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_discovery.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_io_scheduler.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_io_scheduler.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_maintenance.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_maintenance.mli (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_welcome.ml (100%) rename src/{lib_node_p2p => lib_p2p}/p2p_welcome.mli (100%) rename src/{lib_node_p2p/tezos-node-p2p.opam => lib_p2p/tezos-p2p.opam} (95%) rename src/{lib_node_p2p_base => lib_p2p_services}/jbuild (80%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_connection_pool_types.ml (100%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_connection_pool_types.mli (100%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_services.ml (100%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_services.mli (100%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_types.ml (100%) rename src/{lib_node_p2p_base => lib_p2p_services}/p2p_types.mli (100%) rename src/{lib_node_p2p_base/tezos-node-p2p-base.opam => lib_p2p_services/tezos-p2p-services.opam} (100%) diff --git a/src/bin_node/jbuild b/src/bin_node/jbuild index 6ff24d1d9..302c3922f 100644 --- a/src/bin_node/jbuild +++ b/src/bin_node/jbuild @@ -5,11 +5,11 @@ (public_name tezos-node) (libraries (tezos-base tezos-rpc-http - tezos-node-updater - tezos-node-p2p-base - tezos-node-p2p + tezos-p2p-services + tezos-p2p tezos-node-shell-base tezos-node-shell + tezos-node-updater tezos-embedded-protocol-genesis tezos-embedded-protocol-demo tezos-embedded-protocol-alpha @@ -19,11 +19,11 @@ -safe-string -open Tezos_base__TzPervasives -open Tezos_rpc_http - -open Tezos_node_updater - -open Tezos_node_p2p_base - -open Tezos_node_p2p + -open Tezos_p2p_services + -open Tezos_p2p -open Tezos_node_shell_base -open Tezos_node_shell + -open Tezos_node_updater -linkall)))) (install diff --git a/src/lib_client_base/jbuild b/src/lib_client_base/jbuild index f98e81a83..e1705498c 100644 --- a/src/lib_client_base/jbuild +++ b/src/lib_client_base/jbuild @@ -6,7 +6,7 @@ (libraries (tezos-base tezos-storage tezos-rpc-http - tezos-node-p2p-base + tezos-p2p-services tezos-node-shell-base tezos-node-services tezos-node-updater @@ -16,7 +16,7 @@ -open Tezos_base__TzPervasives -open Tezos_storage -open Tezos_rpc_http - -open Tezos_node_p2p_base + -open Tezos_p2p_services -open Tezos_node_services -open Tezos_node_updater)))) diff --git a/src/lib_client_base/tezos-client-base.opam b/src/lib_client_base/tezos-client-base.opam index 198d70272..aaf13ba9c 100644 --- a/src/lib_client_base/tezos-client-base.opam +++ b/src/lib_client_base/tezos-client-base.opam @@ -12,7 +12,7 @@ depends: [ "tezos-base" "tezos-storage" "tezos-rpc-http" - "tezos-node-p2p-base" + "tezos-p2p-services" "tezos-node-services" "tezos-node-updater" "tezos-protocol-compiler" diff --git a/src/lib_node_services/jbuild b/src/lib_node_services/jbuild index 14900bbfd..5cd78cf2b 100644 --- a/src/lib_node_services/jbuild +++ b/src/lib_node_services/jbuild @@ -4,12 +4,12 @@ ((name tezos_node_services) (public_name tezos-node-services) (libraries (tezos-base - tezos-node-p2p-base + tezos-p2p-services tezos-node-shell-base)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_node_p2p_base + -open Tezos_p2p_services -open Tezos_node_shell_base)))) (alias diff --git a/src/lib_node_services/tezos-node-services.opam b/src/lib_node_services/tezos-node-services.opam index d0af2fd65..0cf858edc 100644 --- a/src/lib_node_services/tezos-node-services.opam +++ b/src/lib_node_services/tezos-node-services.opam @@ -10,8 +10,7 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-node-p2p-base" - "tezos-node-shell-base" + "tezos-p2p-services" "ocplib-resto" ] build: [ diff --git a/src/lib_node_shell/jbuild b/src/lib_node_shell/jbuild index ca6b7db91..337291134 100644 --- a/src/lib_node_shell/jbuild +++ b/src/lib_node_shell/jbuild @@ -6,20 +6,20 @@ (libraries (tezos-base tezos-storage tezos-rpc-http + tezos-p2p-services + tezos-p2p tezos-node-services - tezos-node-p2p-base tezos-node-shell-base - tezos-node-p2p tezos-node-updater)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives -open Tezos_storage -open Tezos_rpc_http + -open Tezos_p2p_services + -open Tezos_p2p -open Tezos_node_services - -open Tezos_node_p2p_base -open Tezos_node_shell_base - -open Tezos_node_p2p -open Tezos_node_updater)))) (alias diff --git a/src/lib_node_shell/tezos-node-shell.opam b/src/lib_node_shell/tezos-node-shell.opam index 28b78fbea..0467071d1 100644 --- a/src/lib_node_shell/tezos-node-shell.opam +++ b/src/lib_node_shell/tezos-node-shell.opam @@ -12,8 +12,8 @@ depends: [ "tezos-base" "tezos-storage" "tezos-node-services" - "tezos-node-p2p-base" - "tezos-node-p2p" + "tezos-p2p-services" + "tezos-p2p" "tezos-node-updater" ] build: [ diff --git a/src/lib_node_shell_base/jbuild b/src/lib_node_shell_base/jbuild index 059b9a5c6..abb916874 100644 --- a/src/lib_node_shell_base/jbuild +++ b/src/lib_node_shell_base/jbuild @@ -4,9 +4,9 @@ ((name tezos_node_shell_base) (public_name tezos-node-shell-base) (libraries (tezos-base - tezos-node-p2p-base)) + tezos-p2p-services)) (flags (:standard -open Tezos_base__TzPervasives - -open Tezos_node_p2p_base)))) + -open Tezos_p2p_services)))) (alias ((name runtest_indent) diff --git a/src/lib_node_shell_base/tezos-node-shell-base.opam b/src/lib_node_shell_base/tezos-node-shell-base.opam index 1324a9737..c8bfdf9bf 100644 --- a/src/lib_node_shell_base/tezos-node-shell-base.opam +++ b/src/lib_node_shell_base/tezos-node-shell-base.opam @@ -13,7 +13,7 @@ depends: [ "mtime" "ocplib-resto-cohttp" "tezos-base" - "tezos-node-p2p-base" + "tezos-p2p-services" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_node_updater/jbuild b/src/lib_node_updater/jbuild index 8fc173087..e433b96d9 100644 --- a/src/lib_node_updater/jbuild +++ b/src/lib_node_updater/jbuild @@ -8,8 +8,8 @@ tezos-protocol-compiler tezos-storage tezos-rpc-http + tezos-p2p-services tezos-node-services - tezos-node-p2p-base dynlink)) (flags (:standard -w -9+27-30-32-40@8 -safe-string @@ -18,8 +18,8 @@ -open Tezos_protocol_compiler -open Tezos_storage -open Tezos_rpc_http - -open Tezos_node_services - -open Tezos_node_p2p_base)))) + -open Tezos_p2p_services + -open Tezos_node_services)))) (alias ((name runtest_indent) diff --git a/src/lib_node_updater/tezos-node-updater.opam b/src/lib_node_updater/tezos-node-updater.opam index 3612c2d14..f1a0215d3 100644 --- a/src/lib_node_updater/tezos-node-updater.opam +++ b/src/lib_node_updater/tezos-node-updater.opam @@ -14,8 +14,8 @@ depends: [ "tezos-protocol-compiler" "tezos-storage" "tezos-rpc-http" + "tezos-p2p-services" "tezos-node-services" - "tezos-node-p2p-base" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_node_p2p/jbuild b/src/lib_p2p/jbuild similarity index 70% rename from src/lib_node_p2p/jbuild rename to src/lib_p2p/jbuild index a76ffe6e0..79bbd456b 100644 --- a/src/lib_node_p2p/jbuild +++ b/src/lib_p2p/jbuild @@ -1,14 +1,14 @@ (jbuild_version 1) (library - ((name tezos_node_p2p) - (public_name tezos-node-p2p) + ((name tezos_p2p) + (public_name tezos-p2p) (libraries (tezos-base - tezos-node-p2p-base)) + tezos-p2p-services)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_node_p2p_base)))) + -open Tezos_p2p_services)))) (alias ((name runtest_indent) diff --git a/src/lib_node_p2p/moving_average.ml b/src/lib_p2p/moving_average.ml similarity index 100% rename from src/lib_node_p2p/moving_average.ml rename to src/lib_p2p/moving_average.ml diff --git a/src/lib_node_p2p/moving_average.mli b/src/lib_p2p/moving_average.mli similarity index 100% rename from src/lib_node_p2p/moving_average.mli rename to src/lib_p2p/moving_average.mli diff --git a/src/lib_node_p2p/p2p.ml b/src/lib_p2p/p2p.ml similarity index 100% rename from src/lib_node_p2p/p2p.ml rename to src/lib_p2p/p2p.ml diff --git a/src/lib_node_p2p/p2p.mli b/src/lib_p2p/p2p.mli similarity index 100% rename from src/lib_node_p2p/p2p.mli rename to src/lib_p2p/p2p.mli diff --git a/src/lib_node_p2p/p2p_connection.ml b/src/lib_p2p/p2p_connection.ml similarity index 100% rename from src/lib_node_p2p/p2p_connection.ml rename to src/lib_p2p/p2p_connection.ml diff --git a/src/lib_node_p2p/p2p_connection.mli b/src/lib_p2p/p2p_connection.mli similarity index 100% rename from src/lib_node_p2p/p2p_connection.mli rename to src/lib_p2p/p2p_connection.mli diff --git a/src/lib_node_p2p/p2p_connection_pool.ml b/src/lib_p2p/p2p_connection_pool.ml similarity index 100% rename from src/lib_node_p2p/p2p_connection_pool.ml rename to src/lib_p2p/p2p_connection_pool.ml diff --git a/src/lib_node_p2p/p2p_connection_pool.mli b/src/lib_p2p/p2p_connection_pool.mli similarity index 100% rename from src/lib_node_p2p/p2p_connection_pool.mli rename to src/lib_p2p/p2p_connection_pool.mli diff --git a/src/lib_node_p2p/p2p_discovery.ml b/src/lib_p2p/p2p_discovery.ml similarity index 100% rename from src/lib_node_p2p/p2p_discovery.ml rename to src/lib_p2p/p2p_discovery.ml diff --git a/src/lib_node_p2p/p2p_discovery.mli b/src/lib_p2p/p2p_discovery.mli similarity index 100% rename from src/lib_node_p2p/p2p_discovery.mli rename to src/lib_p2p/p2p_discovery.mli diff --git a/src/lib_node_p2p/p2p_io_scheduler.ml b/src/lib_p2p/p2p_io_scheduler.ml similarity index 100% rename from src/lib_node_p2p/p2p_io_scheduler.ml rename to src/lib_p2p/p2p_io_scheduler.ml diff --git a/src/lib_node_p2p/p2p_io_scheduler.mli b/src/lib_p2p/p2p_io_scheduler.mli similarity index 100% rename from src/lib_node_p2p/p2p_io_scheduler.mli rename to src/lib_p2p/p2p_io_scheduler.mli diff --git a/src/lib_node_p2p/p2p_maintenance.ml b/src/lib_p2p/p2p_maintenance.ml similarity index 100% rename from src/lib_node_p2p/p2p_maintenance.ml rename to src/lib_p2p/p2p_maintenance.ml diff --git a/src/lib_node_p2p/p2p_maintenance.mli b/src/lib_p2p/p2p_maintenance.mli similarity index 100% rename from src/lib_node_p2p/p2p_maintenance.mli rename to src/lib_p2p/p2p_maintenance.mli diff --git a/src/lib_node_p2p/p2p_welcome.ml b/src/lib_p2p/p2p_welcome.ml similarity index 100% rename from src/lib_node_p2p/p2p_welcome.ml rename to src/lib_p2p/p2p_welcome.ml diff --git a/src/lib_node_p2p/p2p_welcome.mli b/src/lib_p2p/p2p_welcome.mli similarity index 100% rename from src/lib_node_p2p/p2p_welcome.mli rename to src/lib_p2p/p2p_welcome.mli diff --git a/src/lib_node_p2p/tezos-node-p2p.opam b/src/lib_p2p/tezos-p2p.opam similarity index 95% rename from src/lib_node_p2p/tezos-node-p2p.opam rename to src/lib_p2p/tezos-p2p.opam index d67e36e02..9f16483f5 100644 --- a/src/lib_node_p2p/tezos-node-p2p.opam +++ b/src/lib_p2p/tezos-p2p.opam @@ -10,7 +10,7 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-node-p2p-base" + "tezos-p2p-services" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_node_p2p_base/jbuild b/src/lib_p2p_services/jbuild similarity index 80% rename from src/lib_node_p2p_base/jbuild rename to src/lib_p2p_services/jbuild index 3f0670abb..087691f0e 100644 --- a/src/lib_node_p2p_base/jbuild +++ b/src/lib_p2p_services/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_node_p2p_base) - (public_name tezos-node-p2p-base) + ((name tezos_p2p_services) + (public_name tezos-p2p-services) (libraries (tezos-base)) (flags (:standard -open Tezos_base__TzPervasives -safe-string)))) diff --git a/src/lib_node_p2p_base/p2p_connection_pool_types.ml b/src/lib_p2p_services/p2p_connection_pool_types.ml similarity index 100% rename from src/lib_node_p2p_base/p2p_connection_pool_types.ml rename to src/lib_p2p_services/p2p_connection_pool_types.ml diff --git a/src/lib_node_p2p_base/p2p_connection_pool_types.mli b/src/lib_p2p_services/p2p_connection_pool_types.mli similarity index 100% rename from src/lib_node_p2p_base/p2p_connection_pool_types.mli rename to src/lib_p2p_services/p2p_connection_pool_types.mli diff --git a/src/lib_node_p2p_base/p2p_services.ml b/src/lib_p2p_services/p2p_services.ml similarity index 100% rename from src/lib_node_p2p_base/p2p_services.ml rename to src/lib_p2p_services/p2p_services.ml diff --git a/src/lib_node_p2p_base/p2p_services.mli b/src/lib_p2p_services/p2p_services.mli similarity index 100% rename from src/lib_node_p2p_base/p2p_services.mli rename to src/lib_p2p_services/p2p_services.mli diff --git a/src/lib_node_p2p_base/p2p_types.ml b/src/lib_p2p_services/p2p_types.ml similarity index 100% rename from src/lib_node_p2p_base/p2p_types.ml rename to src/lib_p2p_services/p2p_types.ml diff --git a/src/lib_node_p2p_base/p2p_types.mli b/src/lib_p2p_services/p2p_types.mli similarity index 100% rename from src/lib_node_p2p_base/p2p_types.mli rename to src/lib_p2p_services/p2p_types.mli diff --git a/src/lib_node_p2p_base/tezos-node-p2p-base.opam b/src/lib_p2p_services/tezos-p2p-services.opam similarity index 100% rename from src/lib_node_p2p_base/tezos-node-p2p-base.opam rename to src/lib_p2p_services/tezos-p2p-services.opam diff --git a/test/p2p/jbuild b/test/p2p/jbuild index f410f6892..8eadbb74d 100644 --- a/test/p2p/jbuild +++ b/test/p2p/jbuild @@ -5,16 +5,16 @@ test_p2p_connection_pool test_p2p_io_scheduler)) (libraries (tezos-base - tezos-node-p2p-base - tezos-node-p2p + tezos-p2p-services + tezos-p2p lwt.unix test_lib)) (flags (:standard -w -9-32 -linkall -safe-string -open Tezos_base__TzPervasives - -open Tezos_node_p2p_base - -open Tezos_node_p2p)))) + -open Tezos_p2p_services + -open Tezos_p2p)))) (alias ((name buildtest) From 552237673e243585c7ddd5f3edaa1732b17e75c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 19:25:07 +0100 Subject: [PATCH 05/27] Refactor: Move `Mempool` and `Block_locator` into `lib_base` --- .../block_locator.ml | 29 ++++++------------- .../block_locator.mli | 7 +++-- .../mempool.ml | 0 .../mempool.mli | 0 src/lib_base/tzPervasives.ml | 3 ++ src/lib_base/tzPervasives.mli | 2 ++ src/lib_node_shell/state.ml | 14 ++++++++- 7 files changed, 31 insertions(+), 24 deletions(-) rename src/{lib_node_shell => lib_base}/block_locator.ml (70%) rename src/{lib_node_shell => lib_base}/block_locator.mli (85%) rename src/{lib_node_shell_base => lib_base}/mempool.ml (100%) rename src/{lib_node_shell_base => lib_base}/mempool.mli (100%) diff --git a/src/lib_node_shell/block_locator.ml b/src/lib_base/block_locator.ml similarity index 70% rename from src/lib_node_shell/block_locator.ml rename to src/lib_base/block_locator.ml index 86fe94c93..ee5b24263 100644 --- a/src/lib_node_shell/block_locator.ml +++ b/src/lib_base/block_locator.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Lwt.Infix + type t = raw (** Non private version of Block_store_locator.t for coercions *) @@ -21,37 +23,24 @@ let encoding = (req "current_head" (dynamic_size Block_header.encoding)) (req "history" (dynamic_size (list Block_hash.encoding)))) -let predecessor (store : Store.Block.store) (b: Block_hash.t) = - Store.Block.Contents.read_exn (store, b) >>= fun contents -> - let predecessor = contents.header.shell.predecessor in - if Block_hash.equal b predecessor then - Lwt.return_none - else - Lwt.return_some predecessor - -let compute (store : Store.Block.store) (b: Block_hash.t) sz = +let compute ~pred (h: Block_hash.t) (bh: Block_header.t) sz = let rec loop acc ~sz step cpt b = if sz = 0 then Lwt.return (List.rev acc) else - predecessor store b >>= function + pred b step >>= function | None -> Lwt.return (List.rev (b :: acc)) | Some predecessor -> if cpt = 0 then - loop (b :: acc) ~sz:(sz - 1) - (step * 2) (step * 20 - 1) predecessor - else if cpt mod step = 0 then - loop (b :: acc) ~sz:(sz - 1) - step (cpt - 1) predecessor + loop (b :: acc) ~sz:(sz - 1) (step * 2) 10 predecessor else - loop acc ~sz step (cpt - 1) predecessor in - Store.Block.Contents.read_exn (store, b) >>= fun { header } -> - predecessor store b >>= function - | None -> Lwt.return (header, []) + loop (b :: acc) ~sz:(sz - 1) step (cpt - 1) predecessor in + pred h 1 >>= function + | None -> Lwt.return (bh, []) | Some p -> loop [] ~sz 1 9 p >>= fun hist -> - Lwt.return (header, hist) + Lwt.return (bh, hist) type validity = | Unknown diff --git a/src/lib_node_shell/block_locator.mli b/src/lib_base/block_locator.mli similarity index 85% rename from src/lib_node_shell/block_locator.mli rename to src/lib_base/block_locator.mli index f5aeb9f74..37cb0ded0 100644 --- a/src/lib_node_shell/block_locator.mli +++ b/src/lib_base/block_locator.mli @@ -17,9 +17,10 @@ val raw: t -> raw val encoding: t Data_encoding.t -val compute: Store.Block.store -> Block_hash.t -> int -> t Lwt.t -(** [compute block max_length] compute the sparse block locator for - the [block]. The locator contains at most [max_length] elements. *) +val compute: + pred:(Block_hash.t -> int -> Block_hash.t option Lwt.t) -> + Block_hash.t -> Block_header.t -> int -> + t Lwt.t type validity = | Unknown diff --git a/src/lib_node_shell_base/mempool.ml b/src/lib_base/mempool.ml similarity index 100% rename from src/lib_node_shell_base/mempool.ml rename to src/lib_base/mempool.ml diff --git a/src/lib_node_shell_base/mempool.mli b/src/lib_base/mempool.mli similarity index 100% rename from src/lib_node_shell_base/mempool.mli rename to src/lib_base/mempool.mli diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index c76e757b9..3072cdf95 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -33,5 +33,8 @@ module Protocol = Protocol module Test_network_status = Test_network_status module Preapply_result = Preapply_result +module Block_locator = Block_locator +module Mempool = Mempool + include Utils.Infix include Error_monad diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index dce6e6653..3c2ac4704 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -31,6 +31,8 @@ module Operation = Operation module Protocol = Protocol module Test_network_status = Test_network_status module Preapply_result = Preapply_result +module Block_locator = Block_locator +module Mempool = Mempool include (module type of (struct include Utils.Infix end)) include (module type of (struct include Error_monad end)) diff --git a/src/lib_node_shell/state.ml b/src/lib_node_shell/state.ml index 062d5333f..00ab5ceb5 100644 --- a/src/lib_node_shell/state.ml +++ b/src/lib_node_shell/state.ml @@ -133,9 +133,21 @@ let update_chain_store { net_id ; context_index ; chain_state } f = Lwt.return res end +let rec predecessor (store : Store.Block.store) (b: Block_hash.t) n = + (* TODO optimize *) + if n = 0 then Lwt.return_some b else begin + Store.Block.Contents.read_exn (store, b) >>= fun contents -> + let pred = contents.header.shell.predecessor in + if Block_hash.equal b pred then + Lwt.return_none + else + predecessor store pred (n-1) + end + let compute_locator_from_hash (net : net_state) ?(size = 200) head = Shared.use net.block_store begin fun block_store -> - Block_locator.compute block_store head size + Store.Block.Contents.read_exn (block_store, head) >>= fun { header } -> + Block_locator.compute ~pred:(predecessor block_store) head header size end let compute_locator net ?size head = From 58388bd3048c7a2c0d5d9c2273ecfe678f8fe746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 20:08:44 +0100 Subject: [PATCH 06/27] Refactor: Merge `lib_node_shell_base/lib_node_services}` -> `lib_shell_services` --- src/bin_node/jbuild | 4 ++-- src/bin_node/tezos-node.opam | 6 +++++ src/lib_client_base/client_commands.ml | 2 +- src/lib_client_base/client_commands.mli | 6 ++--- src/lib_client_base/client_config.ml | 6 ++--- src/lib_client_base/client_debug.ml | 6 ++--- src/lib_client_base/client_node_rpcs.ml | 4 ++-- src/lib_client_base/client_node_rpcs.mli | 2 +- src/lib_client_base/client_rpcs.ml | 2 +- src/lib_client_base/client_rpcs.mli | 2 +- src/lib_client_base/jbuild | 5 ++-- src/lib_client_base/tezos-client-base.opam | 2 +- src/lib_node_services/jbuild | 18 --------------- src/lib_node_shell/jbuild | 6 ++--- src/lib_node_shell/node.ml | 4 ++-- src/lib_node_shell/node.mli | 4 ++-- src/lib_node_shell/node_rpc.ml | 20 ++++++++-------- src/lib_node_shell/tezos-node-shell.opam | 4 ++-- .../tezos-node-shell-base.opam | 23 ------------------- src/lib_node_updater/jbuild | 4 ++-- src/lib_node_updater/tezos-node-updater.opam | 2 +- src/lib_rpc_http/jbuild | 4 +--- src/lib_rpc_http/tezos-rpc-http.opam | 1 - .../block_validator_errors.ml | 0 .../block_validator_errors.mli | 0 .../block_validator_worker_state.ml | 0 .../block_validator_worker_state.mli | 0 .../jbuild | 8 ++++--- .../net_validator_worker_state.ml | 0 .../net_validator_worker_state.mli | 0 .../peer_validator_worker_state.ml | 0 .../peer_validator_worker_state.mli | 0 .../prevalidator_worker_state.ml | 0 .../prevalidator_worker_state.mli | 0 .../shell_services.ml} | 1 - .../shell_services.mli} | 0 .../tezos-shell-services.opam} | 2 -- .../worker_types.ml | 0 .../worker_types.mli | 0 .../lib_client_alpha/client_proto_rpcs.ml | 8 +++---- .../lib_client_alpha/client_proto_rpcs.mli | 2 +- src/proto_alpha/lib_client_alpha/jbuild | 4 ++-- .../tezos-embedded-client-alpha.opam | 2 +- .../lib_client_demo/client_proto_rpcs.ml | 2 +- .../lib_client_demo/client_proto_rpcs.mli | 2 +- .../lib_client_genesis/client_proto_main.ml | 2 +- src/proto_genesis/lib_client_genesis/jbuild | 4 ++-- .../tezos-embedded-client-genesis.opam | 2 +- 48 files changed, 67 insertions(+), 109 deletions(-) delete mode 100644 src/lib_node_services/jbuild delete mode 100644 src/lib_node_shell_base/tezos-node-shell-base.opam rename src/{lib_node_shell_base => lib_shell_services}/block_validator_errors.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/block_validator_errors.mli (100%) rename src/{lib_node_shell_base => lib_shell_services}/block_validator_worker_state.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/block_validator_worker_state.mli (100%) rename src/{lib_node_shell_base => lib_shell_services}/jbuild (60%) rename src/{lib_node_shell_base => lib_shell_services}/net_validator_worker_state.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/net_validator_worker_state.mli (100%) rename src/{lib_node_shell_base => lib_shell_services}/peer_validator_worker_state.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/peer_validator_worker_state.mli (100%) rename src/{lib_node_shell_base => lib_shell_services}/prevalidator_worker_state.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/prevalidator_worker_state.mli (100%) rename src/{lib_node_services/node_rpc_services.ml => lib_shell_services/shell_services.ml} (99%) rename src/{lib_node_services/node_rpc_services.mli => lib_shell_services/shell_services.mli} (100%) rename src/{lib_node_services/tezos-node-services.opam => lib_shell_services/tezos-shell-services.opam} (92%) rename src/{lib_node_shell_base => lib_shell_services}/worker_types.ml (100%) rename src/{lib_node_shell_base => lib_shell_services}/worker_types.mli (100%) diff --git a/src/bin_node/jbuild b/src/bin_node/jbuild index 302c3922f..84d05edc1 100644 --- a/src/bin_node/jbuild +++ b/src/bin_node/jbuild @@ -7,7 +7,7 @@ tezos-rpc-http tezos-p2p-services tezos-p2p - tezos-node-shell-base + tezos-shell-services tezos-node-shell tezos-node-updater tezos-embedded-protocol-genesis @@ -21,7 +21,7 @@ -open Tezos_rpc_http -open Tezos_p2p_services -open Tezos_p2p - -open Tezos_node_shell_base + -open Tezos_shell_services -open Tezos_node_shell -open Tezos_node_updater -linkall)))) diff --git a/src/bin_node/tezos-node.opam b/src/bin_node/tezos-node.opam index 9799a9509..086c59147 100644 --- a/src/bin_node/tezos-node.opam +++ b/src/bin_node/tezos-node.opam @@ -10,6 +10,12 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" + "tezos-rpc-http" + "tezos-p2p-services" + "tezos-p2p" + "tezos-shell-services" + "tezos-node-shell" + "tezos-node-updater" "tezos-embedded-protocol-genesis" "tezos-embedded-protocol-demo" "tezos-embedded-protocol-alpha" diff --git a/src/lib_client_base/client_commands.ml b/src/lib_client_base/client_commands.ml index d31a300f4..305484caa 100644 --- a/src/lib_client_base/client_commands.ml +++ b/src/lib_client_base/client_commands.ml @@ -44,7 +44,7 @@ class type wallet = object end class type block = object - method block : Node_rpc_services.Blocks.block + method block : Shell_services.Blocks.block end class type logging_wallet = object diff --git a/src/lib_client_base/client_commands.mli b/src/lib_client_base/client_commands.mli index 60a290b87..740a8c7ef 100644 --- a/src/lib_client_base/client_commands.mli +++ b/src/lib_client_base/client_commands.mli @@ -28,7 +28,7 @@ class type wallet = object end class type block = object - method block : Node_rpc_services.Blocks.block + method block : Shell_services.Blocks.block end class type logging_wallet = object @@ -56,7 +56,7 @@ end val make_context : ?base_dir:string -> - ?block:Node_rpc_services.Blocks.block -> + ?block:Shell_services.Blocks.block -> ?rpc_config:Client_rpcs.config -> (string -> string -> unit Lwt.t) -> full_context (** [make_context ?config log_fun] builds a context whose logging @@ -81,4 +81,4 @@ val get_versions: unit -> (Protocol_hash.t * (command list)) list val force_switch : (bool, full_context) Cli_entries.arg val default_base_dir : string -val default_block : Node_rpc_services.Blocks.block +val default_block : Shell_services.Blocks.block diff --git a/src/lib_client_base/client_config.ml b/src/lib_client_base/client_config.ml index 75f1cc42b..f5cf391ea 100644 --- a/src/lib_client_base/client_config.ml +++ b/src/lib_client_base/client_config.ml @@ -103,7 +103,7 @@ module Cfg_file = struct end type cli_args = { - block: Node_rpc_services.Blocks.block ; + block: Shell_services.Blocks.block ; protocol: Protocol_hash.t option ; print_timings: bool ; log_requests: bool ; @@ -124,7 +124,7 @@ let string_parameter : (string, Client_commands.full_context) parameter = let block_parameter = parameter - (fun _ block -> match Node_rpc_services.Blocks.parse_block block with + (fun _ block -> match Shell_services.Blocks.parse_block block with | Error _ -> fail (Invalid_block_argument block) | Ok block -> return block) @@ -161,7 +161,7 @@ let block_arg = default_arg ~parameter:"-block" ~doc:"The block on which to apply contextual commands." - ~default:(Node_rpc_services.Blocks.to_string default_cli_args.block) + ~default:(Shell_services.Blocks.to_string default_cli_args.block) block_parameter let protocol_arg = arg diff --git a/src/lib_client_base/client_debug.ml b/src/lib_client_base/client_debug.ml index 4b3da078a..41c5c71b1 100644 --- a/src/lib_client_base/client_debug.ml +++ b/src/lib_client_base/client_debug.ml @@ -10,7 +10,7 @@ (* Commands used to debug the node/alphanet *) let pp_block ppf - { Node_rpc_services.Blocks.hash ; net_id ; level ; + { Shell_services.Blocks.hash ; net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness ; data ; operations ; protocol ; test_network } = @@ -62,7 +62,7 @@ let registered_protocols ppf = (Client_commands.get_versions ()) let print_heads ppf cctxt = - Client_rpcs.call_service0 cctxt Node_rpc_services.Blocks.list + Client_rpcs.call_service0 cctxt Shell_services.Blocks.list { include_ops = true ; length = Some 1 ; heads = None ; @@ -82,7 +82,7 @@ let print_heads ppf cctxt = let print_rejected ppf cctxt = Client_rpcs.call_service0 cctxt - Node_rpc_services.Blocks.list_invalid () >>=? fun invalid -> + Shell_services.Blocks.list_invalid () >>=? fun invalid -> return @@ Format.pp_print_list (fun ppf (hash, level, errors) -> diff --git a/src/lib_client_base/client_node_rpcs.ml b/src/lib_client_base/client_node_rpcs.ml index 39439e239..0cf10f552 100644 --- a/src/lib_client_base/client_node_rpcs.ml +++ b/src/lib_client_base/client_node_rpcs.ml @@ -10,7 +10,7 @@ (* Tezos Command line interface - RPC Calls *) open Client_rpcs -module Services = Node_rpc_services +module Services = Shell_services let errors (rpc : #Client_rpcs.ctxt) = call_service0 rpc RPC_error.service () @@ -44,7 +44,7 @@ let complete cctxt ?block prefix = let describe cctxt ?(recurse = true) path = Client_rpcs.call_service cctxt - Node_rpc_services.describe + Shell_services.describe ((), path) { recurse } () module Blocks = struct diff --git a/src/lib_client_base/client_node_rpcs.mli b/src/lib_client_base/client_node_rpcs.mli index b92ffc880..994c77a3b 100644 --- a/src/lib_client_base/client_node_rpcs.mli +++ b/src/lib_client_base/client_node_rpcs.mli @@ -40,7 +40,7 @@ val inject_protocol: module Blocks : sig - type block = Node_rpc_services.Blocks.block + type block = Shell_services.Blocks.block val net_id: #Client_rpcs.ctxt -> diff --git a/src/lib_client_base/client_rpcs.ml b/src/lib_client_base/client_rpcs.ml index 5dd884775..472ea84f4 100644 --- a/src/lib_client_base/client_rpcs.ml +++ b/src/lib_client_base/client_rpcs.ml @@ -130,7 +130,7 @@ let call_err_service1 ctxt service a1 body = let call_err_service2 ctxt service a1 a2 body = call_err_service ctxt service (((), a1), a2) () body -type block = Node_rpc_services.Blocks.block +type block = Shell_services.Blocks.block let last_baked_block = function | `Prevalidation -> `Head 0 diff --git a/src/lib_client_base/client_rpcs.mli b/src/lib_client_base/client_rpcs.mli index d8484b6b7..b8f251b1c 100644 --- a/src/lib_client_base/client_rpcs.mli +++ b/src/lib_client_base/client_rpcs.mli @@ -106,7 +106,7 @@ val call_err_service2: 'o tzresult, 'e) RPC_service.t -> 'a -> 'b -> 'i -> 'o tzresult Lwt.t -type block = Node_rpc_services.Blocks.block +type block = Shell_services.Blocks.block val last_baked_block: block -> [> diff --git a/src/lib_client_base/jbuild b/src/lib_client_base/jbuild index e1705498c..234d75fa0 100644 --- a/src/lib_client_base/jbuild +++ b/src/lib_client_base/jbuild @@ -7,8 +7,7 @@ tezos-storage tezos-rpc-http tezos-p2p-services - tezos-node-shell-base - tezos-node-services + tezos-shell-services tezos-node-updater tezos-protocol-compiler)) (flags (:standard -w -9+27-30-32-40@8 @@ -17,7 +16,7 @@ -open Tezos_storage -open Tezos_rpc_http -open Tezos_p2p_services - -open Tezos_node_services + -open Tezos_shell_services -open Tezos_node_updater)))) (alias diff --git a/src/lib_client_base/tezos-client-base.opam b/src/lib_client_base/tezos-client-base.opam index aaf13ba9c..2bc8483d5 100644 --- a/src/lib_client_base/tezos-client-base.opam +++ b/src/lib_client_base/tezos-client-base.opam @@ -13,7 +13,7 @@ depends: [ "tezos-storage" "tezos-rpc-http" "tezos-p2p-services" - "tezos-node-services" + "tezos-shell-services" "tezos-node-updater" "tezos-protocol-compiler" "tezos-embedded-protocol-genesis" diff --git a/src/lib_node_services/jbuild b/src/lib_node_services/jbuild deleted file mode 100644 index 5cd78cf2b..000000000 --- a/src/lib_node_services/jbuild +++ /dev/null @@ -1,18 +0,0 @@ -(jbuild_version 1) - -(library - ((name tezos_node_services) - (public_name tezos-node-services) - (libraries (tezos-base - tezos-p2p-services - tezos-node-shell-base)) - (flags (:standard -w -9+27-30-32-40@8 - -safe-string - -open Tezos_base__TzPervasives - -open Tezos_p2p_services - -open Tezos_node_shell_base)))) - -(alias - ((name runtest_indent) - (deps ((glob_files *.ml) (glob_files *.mli))) - (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_node_shell/jbuild b/src/lib_node_shell/jbuild index 337291134..8b1d3dae8 100644 --- a/src/lib_node_shell/jbuild +++ b/src/lib_node_shell/jbuild @@ -8,8 +8,7 @@ tezos-rpc-http tezos-p2p-services tezos-p2p - tezos-node-services - tezos-node-shell-base + tezos-shell-services tezos-node-updater)) (flags (:standard -w -9+27-30-32-40@8 -safe-string @@ -18,8 +17,7 @@ -open Tezos_rpc_http -open Tezos_p2p_services -open Tezos_p2p - -open Tezos_node_services - -open Tezos_node_shell_base + -open Tezos_shell_services -open Tezos_node_updater)))) (alias diff --git a/src/lib_node_shell/node.ml b/src/lib_node_shell/node.ml index 49274819d..7539081f2 100644 --- a/src/lib_node_shell/node.ml +++ b/src/lib_node_shell/node.ml @@ -159,8 +159,8 @@ let shutdown node = node.shutdown () module RPC = struct - type block = Node_rpc_services.Blocks.block - type block_info = Node_rpc_services.Blocks.block_info = { + type block = Shell_services.Blocks.block + type block_info = Shell_services.Blocks.block_info = { hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; diff --git a/src/lib_node_shell/node.mli b/src/lib_node_shell/node.mli index b571d76b8..60e253587 100644 --- a/src/lib_node_shell/node.mli +++ b/src/lib_node_shell/node.mli @@ -49,8 +49,8 @@ val create: module RPC : sig - type block = Node_rpc_services.Blocks.block - type block_info = Node_rpc_services.Blocks.block_info + type block = Shell_services.Blocks.block + type block_info = Shell_services.Blocks.block_info val inject_block: t -> ?force:bool -> ?net_id:Net_id.t -> diff --git a/src/lib_node_shell/node_rpc.ml b/src/lib_node_shell/node_rpc.ml index 8739f1e1c..8a488df10 100644 --- a/src/lib_node_shell/node_rpc.ml +++ b/src/lib_node_shell/node_rpc.ml @@ -9,7 +9,7 @@ open Logging.RPC -module Services = Node_rpc_services +module Services = Shell_services let filter_bi operations (bi: Services.Blocks.block_info) = let bi = if operations then bi else { bi with operations = None } in @@ -102,7 +102,7 @@ let register_bi_dir node dir = RPC_directory.register1 dir Services.Blocks.test_network implementation in let dir = - let implementation b () { Node_rpc_services.Blocks.contents ; monitor } = + let implementation b () { Shell_services.Blocks.contents ; monitor } = match b with | `Prevalidation when monitor -> monitor_operations node contents @@ -411,7 +411,7 @@ let build_rpc_directory node = implementation in let dir = let implementation () - { Node_rpc_services.raw ; blocking ; force ; operations } = + { Shell_services.raw ; blocking ; force ; operations } = begin Node.RPC.inject_block node ~force @@ -455,14 +455,14 @@ let build_rpc_directory node = (* Workers : Prevalidators *) let dir = - RPC_directory.register0 dir Services.Workers.Prevalidators.list + RPC_directory.register0 dir Shell_services.Workers.Prevalidators.list (fun () () -> RPC_answer.return (List.map (fun (id, w) -> (id, Prevalidator.status w)) (Prevalidator.running_workers ()))) in let dir = - RPC_directory.register1 dir Services.Workers.Prevalidators.state + RPC_directory.register1 dir Shell_services.Workers.Prevalidators.state (fun net_id () () -> let w = List.assoc net_id (Prevalidator.running_workers ()) in RPC_answer.return @@ -474,7 +474,7 @@ let build_rpc_directory node = (* Workers : Block_validator *) let dir = - RPC_directory.register0 dir Services.Workers.Block_validator.state + RPC_directory.register0 dir Shell_services.Workers.Block_validator.state (fun () () -> let w = Block_validator.running_worker () in RPC_answer.return @@ -486,7 +486,7 @@ let build_rpc_directory node = (* Workers : Peer validators *) let dir = - RPC_directory.register1 dir Services.Workers.Peer_validators.list + RPC_directory.register1 dir Shell_services.Workers.Peer_validators.list (fun net_id () () -> RPC_answer.return (List.filter_map @@ -496,7 +496,7 @@ let build_rpc_directory node = else None) (Peer_validator.running_workers ()))) in let dir = - RPC_directory.register2 dir Services.Workers.Peer_validators.state + RPC_directory.register2 dir Shell_services.Workers.Peer_validators.state (fun net_id peer_id () () -> let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in RPC_answer.return @@ -508,14 +508,14 @@ let build_rpc_directory node = (* Workers : Net validators *) let dir = - RPC_directory.register0 dir Services.Workers.Net_validators.list + RPC_directory.register0 dir Shell_services.Workers.Net_validators.list (fun () () -> RPC_answer.return (List.map (fun (id, w) -> (id, Net_validator.status w)) (Net_validator.running_workers ()))) in let dir = - RPC_directory.register1 dir Services.Workers.Net_validators.state + RPC_directory.register1 dir Shell_services.Workers.Net_validators.state (fun net_id () () -> let w = List.assoc net_id (Net_validator.running_workers ()) in RPC_answer.return diff --git a/src/lib_node_shell/tezos-node-shell.opam b/src/lib_node_shell/tezos-node-shell.opam index 0467071d1..288ba0a57 100644 --- a/src/lib_node_shell/tezos-node-shell.opam +++ b/src/lib_node_shell/tezos-node-shell.opam @@ -10,10 +10,10 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-storage" - "tezos-node-services" + "tezos-rpc-http" "tezos-p2p-services" "tezos-p2p" + "tezos-shell-services" "tezos-node-updater" ] build: [ diff --git a/src/lib_node_shell_base/tezos-node-shell-base.opam b/src/lib_node_shell_base/tezos-node-shell-base.opam deleted file mode 100644 index c8bfdf9bf..000000000 --- a/src/lib_node_shell_base/tezos-node-shell-base.opam +++ /dev/null @@ -1,23 +0,0 @@ -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+beta15" } - "base-bigarray" - "mtime" - "ocplib-resto-cohttp" - "tezos-base" - "tezos-p2p-services" -] -build: [ - [ "jbuilder" "build" "-p" name "-j" jobs ] -] -build-test: [ - [ "jbuilder" "runtest" "-p" name "-j" jobs ] -] diff --git a/src/lib_node_updater/jbuild b/src/lib_node_updater/jbuild index e433b96d9..1583f740c 100644 --- a/src/lib_node_updater/jbuild +++ b/src/lib_node_updater/jbuild @@ -9,7 +9,7 @@ tezos-storage tezos-rpc-http tezos-p2p-services - tezos-node-services + tezos-shell-services dynlink)) (flags (:standard -w -9+27-30-32-40@8 -safe-string @@ -19,7 +19,7 @@ -open Tezos_storage -open Tezos_rpc_http -open Tezos_p2p_services - -open Tezos_node_services)))) + -open Tezos_shell_services)))) (alias ((name runtest_indent) diff --git a/src/lib_node_updater/tezos-node-updater.opam b/src/lib_node_updater/tezos-node-updater.opam index f1a0215d3..65140d5a2 100644 --- a/src/lib_node_updater/tezos-node-updater.opam +++ b/src/lib_node_updater/tezos-node-updater.opam @@ -15,7 +15,7 @@ depends: [ "tezos-storage" "tezos-rpc-http" "tezos-p2p-services" - "tezos-node-services" + "tezos-shell-services" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_rpc_http/jbuild b/src/lib_rpc_http/jbuild index 8b970fba7..db8713afb 100644 --- a/src/lib_rpc_http/jbuild +++ b/src/lib_rpc_http/jbuild @@ -4,14 +4,12 @@ ((name tezos_rpc_http) (public_name tezos-rpc-http) (libraries (tezos-base - tezos-node-services ocplib-resto-directory ocplib-resto-cohttp)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_rpc - -open Tezos_node_services)))) + -open Tezos_rpc)))) (alias ((name runtest_indent) diff --git a/src/lib_rpc_http/tezos-rpc-http.opam b/src/lib_rpc_http/tezos-rpc-http.opam index ffcde779f..de173f4f6 100644 --- a/src/lib_rpc_http/tezos-rpc-http.opam +++ b/src/lib_rpc_http/tezos-rpc-http.opam @@ -10,7 +10,6 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-node-services" "ocplib-resto-directory" "ocplib-resto-cohttp" ] diff --git a/src/lib_node_shell_base/block_validator_errors.ml b/src/lib_shell_services/block_validator_errors.ml similarity index 100% rename from src/lib_node_shell_base/block_validator_errors.ml rename to src/lib_shell_services/block_validator_errors.ml diff --git a/src/lib_node_shell_base/block_validator_errors.mli b/src/lib_shell_services/block_validator_errors.mli similarity index 100% rename from src/lib_node_shell_base/block_validator_errors.mli rename to src/lib_shell_services/block_validator_errors.mli diff --git a/src/lib_node_shell_base/block_validator_worker_state.ml b/src/lib_shell_services/block_validator_worker_state.ml similarity index 100% rename from src/lib_node_shell_base/block_validator_worker_state.ml rename to src/lib_shell_services/block_validator_worker_state.ml diff --git a/src/lib_node_shell_base/block_validator_worker_state.mli b/src/lib_shell_services/block_validator_worker_state.mli similarity index 100% rename from src/lib_node_shell_base/block_validator_worker_state.mli rename to src/lib_shell_services/block_validator_worker_state.mli diff --git a/src/lib_node_shell_base/jbuild b/src/lib_shell_services/jbuild similarity index 60% rename from src/lib_node_shell_base/jbuild rename to src/lib_shell_services/jbuild index abb916874..c7abaa88b 100644 --- a/src/lib_node_shell_base/jbuild +++ b/src/lib_shell_services/jbuild @@ -1,11 +1,13 @@ (jbuild_version 1) (library - ((name tezos_node_shell_base) - (public_name tezos-node-shell-base) + ((name tezos_shell_services) + (public_name tezos-shell-services) (libraries (tezos-base tezos-p2p-services)) - (flags (:standard -open Tezos_base__TzPervasives + (flags (:standard -w -9+27-30-32-40@8 + -safe-string + -open Tezos_base__TzPervasives -open Tezos_p2p_services)))) (alias diff --git a/src/lib_node_shell_base/net_validator_worker_state.ml b/src/lib_shell_services/net_validator_worker_state.ml similarity index 100% rename from src/lib_node_shell_base/net_validator_worker_state.ml rename to src/lib_shell_services/net_validator_worker_state.ml diff --git a/src/lib_node_shell_base/net_validator_worker_state.mli b/src/lib_shell_services/net_validator_worker_state.mli similarity index 100% rename from src/lib_node_shell_base/net_validator_worker_state.mli rename to src/lib_shell_services/net_validator_worker_state.mli diff --git a/src/lib_node_shell_base/peer_validator_worker_state.ml b/src/lib_shell_services/peer_validator_worker_state.ml similarity index 100% rename from src/lib_node_shell_base/peer_validator_worker_state.ml rename to src/lib_shell_services/peer_validator_worker_state.ml diff --git a/src/lib_node_shell_base/peer_validator_worker_state.mli b/src/lib_shell_services/peer_validator_worker_state.mli similarity index 100% rename from src/lib_node_shell_base/peer_validator_worker_state.mli rename to src/lib_shell_services/peer_validator_worker_state.mli diff --git a/src/lib_node_shell_base/prevalidator_worker_state.ml b/src/lib_shell_services/prevalidator_worker_state.ml similarity index 100% rename from src/lib_node_shell_base/prevalidator_worker_state.ml rename to src/lib_shell_services/prevalidator_worker_state.ml diff --git a/src/lib_node_shell_base/prevalidator_worker_state.mli b/src/lib_shell_services/prevalidator_worker_state.mli similarity index 100% rename from src/lib_node_shell_base/prevalidator_worker_state.mli rename to src/lib_shell_services/prevalidator_worker_state.mli diff --git a/src/lib_node_services/node_rpc_services.ml b/src/lib_shell_services/shell_services.ml similarity index 99% rename from src/lib_node_services/node_rpc_services.ml rename to src/lib_shell_services/shell_services.ml index 9189de1e2..100a9346a 100644 --- a/src/lib_node_services/node_rpc_services.ml +++ b/src/lib_shell_services/shell_services.ml @@ -640,7 +640,6 @@ module Workers = struct end - let forge_block_header = RPC_service.post_service ~description: "Forge a block header" diff --git a/src/lib_node_services/node_rpc_services.mli b/src/lib_shell_services/shell_services.mli similarity index 100% rename from src/lib_node_services/node_rpc_services.mli rename to src/lib_shell_services/shell_services.mli diff --git a/src/lib_node_services/tezos-node-services.opam b/src/lib_shell_services/tezos-shell-services.opam similarity index 92% rename from src/lib_node_services/tezos-node-services.opam rename to src/lib_shell_services/tezos-shell-services.opam index 0cf858edc..428d8be2e 100644 --- a/src/lib_node_services/tezos-node-services.opam +++ b/src/lib_shell_services/tezos-shell-services.opam @@ -10,8 +10,6 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-p2p-services" - "ocplib-resto" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_node_shell_base/worker_types.ml b/src/lib_shell_services/worker_types.ml similarity index 100% rename from src/lib_node_shell_base/worker_types.ml rename to src/lib_shell_services/worker_types.ml diff --git a/src/lib_node_shell_base/worker_types.mli b/src/lib_shell_services/worker_types.mli similarity index 100% rename from src/lib_node_shell_base/worker_types.mli rename to src/lib_shell_services/worker_types.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml index 648a418ab..ffe7c9231 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml @@ -18,10 +18,10 @@ let handle_error (cctxt : #Client_commands.logger) = function let call_service0 cctxt s block = Client_rpcs.call_service0 cctxt - (s Node_rpc_services.Blocks.proto_path) block + (s Shell_services.Blocks.proto_path) block let call_service1 cctxt s block a1 = Client_rpcs.call_service1 cctxt - (s Node_rpc_services.Blocks.proto_path) block a1 + (s Shell_services.Blocks.proto_path) block a1 let call_error_service1 cctxt s block a1 = call_service1 cctxt s block a1 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) @@ -29,14 +29,14 @@ let call_error_service1 cctxt s block a1 = | Error _ as err -> Lwt.return err let call_service2 cctxt s block a1 a2 = Client_rpcs.call_service2 cctxt - (s Node_rpc_services.Blocks.proto_path) block a1 a2 + (s Shell_services.Blocks.proto_path) block a1 a2 let call_error_service2 cctxt s block a1 a2 = call_service2 cctxt s block a1 a2 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) | Ok (Ok v) -> return v | Error _ as err -> Lwt.return err -type block = Node_rpc_services.Blocks.block +type block = Shell_services.Blocks.block let header cctxt block = call_error_service1 cctxt Services.header block () diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli index 7fc5edfa2..bad173545 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli @@ -10,7 +10,7 @@ val string_of_errors: error list -> string val handle_error: Client_commands.full_context -> 'a tzresult -> 'a Lwt.t -type block = Node_rpc_services.Blocks.block +type block = Shell_services.Blocks.block val header: #Client_rpcs.ctxt -> block -> Block_header.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_client_alpha/jbuild b/src/proto_alpha/lib_client_alpha/jbuild index 29ba8ba36..f756d5002 100644 --- a/src/proto_alpha/lib_client_alpha/jbuild +++ b/src/proto_alpha/lib_client_alpha/jbuild @@ -6,7 +6,7 @@ (libraries (tezos-base tezos-embedded-protocol-alpha tezos-embedded-protocol-alpha.raw - tezos-node-services + tezos-shell-services tezos-client-base)) (library_flags (:standard -linkall)) (flags (:standard -w -9+27-30-32-40@8 @@ -14,7 +14,7 @@ -open Tezos_base__TzPervasives -open Tezos_embedded_protocol_environment_alpha -open Tezos_embedded_raw_protocol_alpha - -open Tezos_node_services + -open Tezos_shell_services -open Tezos_client_base -open Tezos_context)))) diff --git a/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam b/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam index 5d0008261..3a7af083a 100644 --- a/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam +++ b/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam @@ -11,7 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-base" "tezos-embedded-protocol-alpha" - "tezos-node-services" + "tezos-shell-services" "tezos-client-base" ] build: [ diff --git a/src/proto_demo/lib_client_demo/client_proto_rpcs.ml b/src/proto_demo/lib_client_demo/client_proto_rpcs.ml index c428e9da5..df5a6f58a 100644 --- a/src/proto_demo/lib_client_demo/client_proto_rpcs.ml +++ b/src/proto_demo/lib_client_demo/client_proto_rpcs.ml @@ -9,7 +9,7 @@ let call_service1 cctxt s block a1 = Client_rpcs.call_service1 cctxt - (s Node_rpc_services.Blocks.proto_path) block a1 + (s Shell_services.Blocks.proto_path) block a1 let call_error_service1 cctxt s block a1 = call_service1 cctxt s block a1 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) diff --git a/src/proto_demo/lib_client_demo/client_proto_rpcs.mli b/src/proto_demo/lib_client_demo/client_proto_rpcs.mli index dd0c9a4a6..20ea87152 100644 --- a/src/proto_demo/lib_client_demo/client_proto_rpcs.mli +++ b/src/proto_demo/lib_client_demo/client_proto_rpcs.mli @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Node_rpc_services +open Shell_services val echo: Client_rpcs.config -> diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.ml b/src/proto_genesis/lib_client_genesis/client_proto_main.ml index 1b891e943..838dd66b3 100644 --- a/src/proto_genesis/lib_client_genesis/client_proto_main.ml +++ b/src/proto_genesis/lib_client_genesis/client_proto_main.ml @@ -15,7 +15,7 @@ let protocol = let call_service1 rpc_config s block a1 = Client_rpcs.call_service1 rpc_config - (s Node_rpc_services.Blocks.proto_path) block a1 + (s Shell_services.Blocks.proto_path) block a1 let call_error_service1 rpc_config s block a1 = call_service1 rpc_config s block a1 >>= function diff --git a/src/proto_genesis/lib_client_genesis/jbuild b/src/proto_genesis/lib_client_genesis/jbuild index 8ba564eac..9d25b1a55 100644 --- a/src/proto_genesis/lib_client_genesis/jbuild +++ b/src/proto_genesis/lib_client_genesis/jbuild @@ -8,7 +8,7 @@ tezos-embedded-protocol-genesis.raw tezos-embedded-protocol-alpha.environment tezos-embedded-protocol-alpha.raw - tezos-node-services + tezos-shell-services tezos-client-base)) (library_flags (:standard -linkall)) (flags (:standard -w -9+27-30-32-40@8 @@ -16,7 +16,7 @@ -open Tezos_base__TzPervasives -open Tezos_embedded_protocol_environment_genesis -open Tezos_embedded_raw_protocol_genesis - -open Tezos_node_services + -open Tezos_shell_services -open Tezos_client_base)))) (alias diff --git a/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam b/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam index f19a57bae..7e5d18bf0 100644 --- a/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam +++ b/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam @@ -12,7 +12,7 @@ depends: [ "tezos-base" "tezos-embedded-protocol-genesis" "tezos-embedded-protocol-alpha" - "tezos-node-services" + "tezos-shell-services" "tezos-client-base" ] build: [ From 96fe5239c9be9fc2d97df15155aab09b9e550988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 19:46:41 +0100 Subject: [PATCH 07/27] Refactor: Rename `lib_node_shell` -> `lib_shell` --- src/bin_node/jbuild | 4 ++-- src/bin_node/tezos-node.opam | 5 +---- src/lib_protocol_compiler/jbuild_embedded_protocol_template | 2 +- src/lib_protocol_compiler/main_embedded_packer.ml | 2 +- src/{lib_node_shell => lib_shell}/block_locator_iterator.ml | 0 src/{lib_node_shell => lib_shell}/block_locator_iterator.mli | 0 src/{lib_node_shell => lib_shell}/block_validator.ml | 0 src/{lib_node_shell => lib_shell}/block_validator.mli | 0 src/{lib_node_shell => lib_shell}/bootstrap_pipeline.ml | 0 src/{lib_node_shell => lib_shell}/bootstrap_pipeline.mli | 0 src/{lib_node_shell => lib_shell}/chain.ml | 0 src/{lib_node_shell => lib_shell}/chain.mli | 0 src/{lib_node_shell => lib_shell}/chain_traversal.ml | 0 src/{lib_node_shell => lib_shell}/chain_traversal.mli | 0 src/{lib_node_shell => lib_shell}/distributed_db.ml | 0 src/{lib_node_shell => lib_shell}/distributed_db.mli | 0 src/{lib_node_shell => lib_shell}/distributed_db_functors.ml | 0 .../distributed_db_functors.mli | 0 src/{lib_node_shell => lib_shell}/distributed_db_message.ml | 0 src/{lib_node_shell => lib_shell}/distributed_db_message.mli | 0 src/{lib_node_shell => lib_shell}/distributed_db_metadata.ml | 0 .../distributed_db_metadata.mli | 0 src/{lib_node_shell => lib_shell}/jbuild | 4 ++-- src/{lib_node_shell => lib_shell}/net_validator.ml | 0 src/{lib_node_shell => lib_shell}/net_validator.mli | 0 src/{lib_node_shell => lib_shell}/node.ml | 0 src/{lib_node_shell => lib_shell}/node.mli | 0 src/{lib_node_shell => lib_shell}/node_rpc.ml | 0 src/{lib_node_shell => lib_shell}/node_rpc.mli | 0 src/{lib_node_shell => lib_shell}/peer_validator.ml | 0 src/{lib_node_shell => lib_shell}/peer_validator.mli | 0 src/{lib_node_shell => lib_shell}/prevalidation.ml | 0 src/{lib_node_shell => lib_shell}/prevalidation.mli | 0 src/{lib_node_shell => lib_shell}/prevalidator.ml | 0 src/{lib_node_shell => lib_shell}/prevalidator.mli | 0 src/{lib_node_shell => lib_shell}/protocol_validator.ml | 0 src/{lib_node_shell => lib_shell}/protocol_validator.mli | 0 src/{lib_node_shell => lib_shell}/state.ml | 0 src/{lib_node_shell => lib_shell}/state.mli | 0 .../tezos-node-shell.opam => lib_shell/tezos-shell.opam} | 0 src/{lib_node_shell => lib_shell}/validator.ml | 0 src/{lib_node_shell => lib_shell}/validator.mli | 0 src/{lib_node_shell => lib_shell}/worker.ml | 0 src/{lib_node_shell => lib_shell}/worker.mli | 0 .../lib_protocol_alpha/tezos-embedded-protocol-alpha.opam | 2 +- .../lib_protocol_demo/tezos-embedded-protocol-demo.opam | 2 +- .../tezos-embedded-protocol-genesis.opam | 2 +- test/shell/jbuild | 4 ++-- 48 files changed, 12 insertions(+), 15 deletions(-) rename src/{lib_node_shell => lib_shell}/block_locator_iterator.ml (100%) rename src/{lib_node_shell => lib_shell}/block_locator_iterator.mli (100%) rename src/{lib_node_shell => lib_shell}/block_validator.ml (100%) rename src/{lib_node_shell => lib_shell}/block_validator.mli (100%) rename src/{lib_node_shell => lib_shell}/bootstrap_pipeline.ml (100%) rename src/{lib_node_shell => lib_shell}/bootstrap_pipeline.mli (100%) rename src/{lib_node_shell => lib_shell}/chain.ml (100%) rename src/{lib_node_shell => lib_shell}/chain.mli (100%) rename src/{lib_node_shell => lib_shell}/chain_traversal.ml (100%) rename src/{lib_node_shell => lib_shell}/chain_traversal.mli (100%) rename src/{lib_node_shell => lib_shell}/distributed_db.ml (100%) rename src/{lib_node_shell => lib_shell}/distributed_db.mli (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_functors.ml (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_functors.mli (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_message.ml (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_message.mli (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_metadata.ml (100%) rename src/{lib_node_shell => lib_shell}/distributed_db_metadata.mli (100%) rename src/{lib_node_shell => lib_shell}/jbuild (92%) rename src/{lib_node_shell => lib_shell}/net_validator.ml (100%) rename src/{lib_node_shell => lib_shell}/net_validator.mli (100%) rename src/{lib_node_shell => lib_shell}/node.ml (100%) rename src/{lib_node_shell => lib_shell}/node.mli (100%) rename src/{lib_node_shell => lib_shell}/node_rpc.ml (100%) rename src/{lib_node_shell => lib_shell}/node_rpc.mli (100%) rename src/{lib_node_shell => lib_shell}/peer_validator.ml (100%) rename src/{lib_node_shell => lib_shell}/peer_validator.mli (100%) rename src/{lib_node_shell => lib_shell}/prevalidation.ml (100%) rename src/{lib_node_shell => lib_shell}/prevalidation.mli (100%) rename src/{lib_node_shell => lib_shell}/prevalidator.ml (100%) rename src/{lib_node_shell => lib_shell}/prevalidator.mli (100%) rename src/{lib_node_shell => lib_shell}/protocol_validator.ml (100%) rename src/{lib_node_shell => lib_shell}/protocol_validator.mli (100%) rename src/{lib_node_shell => lib_shell}/state.ml (100%) rename src/{lib_node_shell => lib_shell}/state.mli (100%) rename src/{lib_node_shell/tezos-node-shell.opam => lib_shell/tezos-shell.opam} (100%) rename src/{lib_node_shell => lib_shell}/validator.ml (100%) rename src/{lib_node_shell => lib_shell}/validator.mli (100%) rename src/{lib_node_shell => lib_shell}/worker.ml (100%) rename src/{lib_node_shell => lib_shell}/worker.mli (100%) diff --git a/src/bin_node/jbuild b/src/bin_node/jbuild index 84d05edc1..7f0ed9bc3 100644 --- a/src/bin_node/jbuild +++ b/src/bin_node/jbuild @@ -8,7 +8,7 @@ tezos-p2p-services tezos-p2p tezos-shell-services - tezos-node-shell + tezos-shell tezos-node-updater tezos-embedded-protocol-genesis tezos-embedded-protocol-demo @@ -22,7 +22,7 @@ -open Tezos_p2p_services -open Tezos_p2p -open Tezos_shell_services - -open Tezos_node_shell + -open Tezos_shell -open Tezos_node_updater -linkall)))) diff --git a/src/bin_node/tezos-node.opam b/src/bin_node/tezos-node.opam index 086c59147..0b505e88a 100644 --- a/src/bin_node/tezos-node.opam +++ b/src/bin_node/tezos-node.opam @@ -11,11 +11,8 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-base" "tezos-rpc-http" - "tezos-p2p-services" "tezos-p2p" - "tezos-shell-services" - "tezos-node-shell" - "tezos-node-updater" + "tezos-shell" "tezos-embedded-protocol-genesis" "tezos-embedded-protocol-demo" "tezos-embedded-protocol-alpha" diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index 08449bc9b..9542f8a53 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -56,7 +56,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| ((name tezos_embedded_protocol_%s) (public_name tezos-embedded-protocol-%s) (library_flags (:standard -linkall)) - (libraries (tezos_embedded_raw_protocol_%s tezos-node-shell)) + (libraries (tezos_embedded_raw_protocol_%s tezos-shell)) (modules (Registerer)))) |} version version version version version version version version diff --git a/src/lib_protocol_compiler/main_embedded_packer.ml b/src/lib_protocol_compiler/main_embedded_packer.ml index 5ff3afd26..0c115622f 100644 --- a/src/lib_protocol_compiler/main_embedded_packer.ml +++ b/src/lib_protocol_compiler/main_embedded_packer.ml @@ -26,7 +26,7 @@ end let () = Format.printf {| let () = - let module Ignored = Tezos_node_shell.State.Register_embedded_protocol + let module Ignored = Tezos_shell.State.Register_embedded_protocol (Tezos_embedded_protocol_environment_%s.Environment) (Tezos_embedded_raw_protocol_%s.Main) (Source) in diff --git a/src/lib_node_shell/block_locator_iterator.ml b/src/lib_shell/block_locator_iterator.ml similarity index 100% rename from src/lib_node_shell/block_locator_iterator.ml rename to src/lib_shell/block_locator_iterator.ml diff --git a/src/lib_node_shell/block_locator_iterator.mli b/src/lib_shell/block_locator_iterator.mli similarity index 100% rename from src/lib_node_shell/block_locator_iterator.mli rename to src/lib_shell/block_locator_iterator.mli diff --git a/src/lib_node_shell/block_validator.ml b/src/lib_shell/block_validator.ml similarity index 100% rename from src/lib_node_shell/block_validator.ml rename to src/lib_shell/block_validator.ml diff --git a/src/lib_node_shell/block_validator.mli b/src/lib_shell/block_validator.mli similarity index 100% rename from src/lib_node_shell/block_validator.mli rename to src/lib_shell/block_validator.mli diff --git a/src/lib_node_shell/bootstrap_pipeline.ml b/src/lib_shell/bootstrap_pipeline.ml similarity index 100% rename from src/lib_node_shell/bootstrap_pipeline.ml rename to src/lib_shell/bootstrap_pipeline.ml diff --git a/src/lib_node_shell/bootstrap_pipeline.mli b/src/lib_shell/bootstrap_pipeline.mli similarity index 100% rename from src/lib_node_shell/bootstrap_pipeline.mli rename to src/lib_shell/bootstrap_pipeline.mli diff --git a/src/lib_node_shell/chain.ml b/src/lib_shell/chain.ml similarity index 100% rename from src/lib_node_shell/chain.ml rename to src/lib_shell/chain.ml diff --git a/src/lib_node_shell/chain.mli b/src/lib_shell/chain.mli similarity index 100% rename from src/lib_node_shell/chain.mli rename to src/lib_shell/chain.mli diff --git a/src/lib_node_shell/chain_traversal.ml b/src/lib_shell/chain_traversal.ml similarity index 100% rename from src/lib_node_shell/chain_traversal.ml rename to src/lib_shell/chain_traversal.ml diff --git a/src/lib_node_shell/chain_traversal.mli b/src/lib_shell/chain_traversal.mli similarity index 100% rename from src/lib_node_shell/chain_traversal.mli rename to src/lib_shell/chain_traversal.mli diff --git a/src/lib_node_shell/distributed_db.ml b/src/lib_shell/distributed_db.ml similarity index 100% rename from src/lib_node_shell/distributed_db.ml rename to src/lib_shell/distributed_db.ml diff --git a/src/lib_node_shell/distributed_db.mli b/src/lib_shell/distributed_db.mli similarity index 100% rename from src/lib_node_shell/distributed_db.mli rename to src/lib_shell/distributed_db.mli diff --git a/src/lib_node_shell/distributed_db_functors.ml b/src/lib_shell/distributed_db_functors.ml similarity index 100% rename from src/lib_node_shell/distributed_db_functors.ml rename to src/lib_shell/distributed_db_functors.ml diff --git a/src/lib_node_shell/distributed_db_functors.mli b/src/lib_shell/distributed_db_functors.mli similarity index 100% rename from src/lib_node_shell/distributed_db_functors.mli rename to src/lib_shell/distributed_db_functors.mli diff --git a/src/lib_node_shell/distributed_db_message.ml b/src/lib_shell/distributed_db_message.ml similarity index 100% rename from src/lib_node_shell/distributed_db_message.ml rename to src/lib_shell/distributed_db_message.ml diff --git a/src/lib_node_shell/distributed_db_message.mli b/src/lib_shell/distributed_db_message.mli similarity index 100% rename from src/lib_node_shell/distributed_db_message.mli rename to src/lib_shell/distributed_db_message.mli diff --git a/src/lib_node_shell/distributed_db_metadata.ml b/src/lib_shell/distributed_db_metadata.ml similarity index 100% rename from src/lib_node_shell/distributed_db_metadata.ml rename to src/lib_shell/distributed_db_metadata.ml diff --git a/src/lib_node_shell/distributed_db_metadata.mli b/src/lib_shell/distributed_db_metadata.mli similarity index 100% rename from src/lib_node_shell/distributed_db_metadata.mli rename to src/lib_shell/distributed_db_metadata.mli diff --git a/src/lib_node_shell/jbuild b/src/lib_shell/jbuild similarity index 92% rename from src/lib_node_shell/jbuild rename to src/lib_shell/jbuild index 8b1d3dae8..0b9971ea2 100644 --- a/src/lib_node_shell/jbuild +++ b/src/lib_shell/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_node_shell) - (public_name tezos-node-shell) + ((name tezos_shell) + (public_name tezos-shell) (libraries (tezos-base tezos-storage tezos-rpc-http diff --git a/src/lib_node_shell/net_validator.ml b/src/lib_shell/net_validator.ml similarity index 100% rename from src/lib_node_shell/net_validator.ml rename to src/lib_shell/net_validator.ml diff --git a/src/lib_node_shell/net_validator.mli b/src/lib_shell/net_validator.mli similarity index 100% rename from src/lib_node_shell/net_validator.mli rename to src/lib_shell/net_validator.mli diff --git a/src/lib_node_shell/node.ml b/src/lib_shell/node.ml similarity index 100% rename from src/lib_node_shell/node.ml rename to src/lib_shell/node.ml diff --git a/src/lib_node_shell/node.mli b/src/lib_shell/node.mli similarity index 100% rename from src/lib_node_shell/node.mli rename to src/lib_shell/node.mli diff --git a/src/lib_node_shell/node_rpc.ml b/src/lib_shell/node_rpc.ml similarity index 100% rename from src/lib_node_shell/node_rpc.ml rename to src/lib_shell/node_rpc.ml diff --git a/src/lib_node_shell/node_rpc.mli b/src/lib_shell/node_rpc.mli similarity index 100% rename from src/lib_node_shell/node_rpc.mli rename to src/lib_shell/node_rpc.mli diff --git a/src/lib_node_shell/peer_validator.ml b/src/lib_shell/peer_validator.ml similarity index 100% rename from src/lib_node_shell/peer_validator.ml rename to src/lib_shell/peer_validator.ml diff --git a/src/lib_node_shell/peer_validator.mli b/src/lib_shell/peer_validator.mli similarity index 100% rename from src/lib_node_shell/peer_validator.mli rename to src/lib_shell/peer_validator.mli diff --git a/src/lib_node_shell/prevalidation.ml b/src/lib_shell/prevalidation.ml similarity index 100% rename from src/lib_node_shell/prevalidation.ml rename to src/lib_shell/prevalidation.ml diff --git a/src/lib_node_shell/prevalidation.mli b/src/lib_shell/prevalidation.mli similarity index 100% rename from src/lib_node_shell/prevalidation.mli rename to src/lib_shell/prevalidation.mli diff --git a/src/lib_node_shell/prevalidator.ml b/src/lib_shell/prevalidator.ml similarity index 100% rename from src/lib_node_shell/prevalidator.ml rename to src/lib_shell/prevalidator.ml diff --git a/src/lib_node_shell/prevalidator.mli b/src/lib_shell/prevalidator.mli similarity index 100% rename from src/lib_node_shell/prevalidator.mli rename to src/lib_shell/prevalidator.mli diff --git a/src/lib_node_shell/protocol_validator.ml b/src/lib_shell/protocol_validator.ml similarity index 100% rename from src/lib_node_shell/protocol_validator.ml rename to src/lib_shell/protocol_validator.ml diff --git a/src/lib_node_shell/protocol_validator.mli b/src/lib_shell/protocol_validator.mli similarity index 100% rename from src/lib_node_shell/protocol_validator.mli rename to src/lib_shell/protocol_validator.mli diff --git a/src/lib_node_shell/state.ml b/src/lib_shell/state.ml similarity index 100% rename from src/lib_node_shell/state.ml rename to src/lib_shell/state.ml diff --git a/src/lib_node_shell/state.mli b/src/lib_shell/state.mli similarity index 100% rename from src/lib_node_shell/state.mli rename to src/lib_shell/state.mli diff --git a/src/lib_node_shell/tezos-node-shell.opam b/src/lib_shell/tezos-shell.opam similarity index 100% rename from src/lib_node_shell/tezos-node-shell.opam rename to src/lib_shell/tezos-shell.opam diff --git a/src/lib_node_shell/validator.ml b/src/lib_shell/validator.ml similarity index 100% rename from src/lib_node_shell/validator.ml rename to src/lib_shell/validator.ml diff --git a/src/lib_node_shell/validator.mli b/src/lib_shell/validator.mli similarity index 100% rename from src/lib_node_shell/validator.mli rename to src/lib_shell/validator.mli diff --git a/src/lib_node_shell/worker.ml b/src/lib_shell/worker.ml similarity index 100% rename from src/lib_node_shell/worker.ml rename to src/lib_shell/worker.ml diff --git a/src/lib_node_shell/worker.mli b/src/lib_shell/worker.mli similarity index 100% rename from src/lib_node_shell/worker.mli rename to src/lib_shell/worker.mli diff --git a/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam b/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam index bf7535387..e2813e50f 100644 --- a/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam +++ b/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam @@ -11,7 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" "tezos-node-updater" - "tezos-node-shell" + "tezos-shell" ] build: [ [ "rm" "jbuild" "src/jbuild" ] diff --git a/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam b/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam index 938be65f2..764d7660f 100644 --- a/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam +++ b/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam @@ -11,7 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" "tezos-node-updater" - "tezos-node-shell" + "tezos-shell" ] build: [ [ "rm" "jbuild" "src/jbuild" ] diff --git a/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam b/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam index cab1bdd0d..50b09b38d 100644 --- a/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam +++ b/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam @@ -11,7 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" "tezos-node-updater" - "tezos-node-shell" + "tezos-shell" ] build: [ [ "rm" "jbuild" "src/jbuild" ] diff --git a/test/shell/jbuild b/test/shell/jbuild index 0542f65c5..24a772f4e 100644 --- a/test/shell/jbuild +++ b/test/shell/jbuild @@ -6,7 +6,7 @@ test_store)) (libraries (tezos-base tezos-storage - tezos-node-shell + tezos-shell tezos-embedded-protocol-demo tezos-embedded-protocol-alpha tezos-embedded-protocol-genesis @@ -15,7 +15,7 @@ -safe-string -open Tezos_base__TzPervasives -open Tezos_storage - -open Tezos_node_shell)))) + -open Tezos_shell)))) (alias ((name buildtest) From 96e493006c93dce415eb97a11ec5439b029da1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 22 Jan 2018 19:52:53 +0100 Subject: [PATCH 08/27] Refactor: Rename `lib_node_updater` -> `lib_protocol_updater` --- .gitlab-ci.yml | 4 ++-- src/bin_node/jbuild | 4 ++-- src/bin_node/tezos-node.opam | 1 + src/lib_client_base/jbuild | 4 ++-- src/lib_client_base/tezos-client-base.opam | 2 +- src/lib_protocol_compiler/jbuild_embedded_protocol_template | 4 ++-- src/{lib_node_updater => lib_protocol_updater}/jbuild | 4 ++-- src/{lib_node_updater => lib_protocol_updater}/register.ml | 0 src/{lib_node_updater => lib_protocol_updater}/register.mli | 0 .../tezos-protocol-updater.opam} | 0 .../tezos_protocol_environment.ml | 0 src/{lib_node_updater => lib_protocol_updater}/updater.ml | 0 src/{lib_node_updater => lib_protocol_updater}/updater.mli | 0 src/lib_shell/jbuild | 4 ++-- src/lib_shell/tezos-shell.opam | 2 +- .../lib_protocol_alpha/tezos-embedded-protocol-alpha.opam | 2 +- .../lib_protocol_demo/tezos-embedded-protocol-demo.opam | 2 +- .../lib_protocol_genesis/tezos-embedded-protocol-genesis.opam | 2 +- 18 files changed, 18 insertions(+), 17 deletions(-) rename src/{lib_node_updater => lib_protocol_updater}/jbuild (91%) rename src/{lib_node_updater => lib_protocol_updater}/register.ml (100%) rename src/{lib_node_updater => lib_protocol_updater}/register.mli (100%) rename src/{lib_node_updater/tezos-node-updater.opam => lib_protocol_updater/tezos-protocol-updater.opam} (100%) rename src/{lib_node_updater => lib_protocol_updater}/tezos_protocol_environment.ml (100%) rename src/{lib_node_updater => lib_protocol_updater}/updater.ml (100%) rename src/{lib_node_updater => lib_protocol_updater}/updater.mli (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79623e56f..d36efdd07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -283,10 +283,10 @@ opam:21:tezos-node-p2p: variables: package: tezos-node-p2p -opam:22:tezos-node-updater: +opam:22:tezos-protocol-updater: <<: *opam_definition variables: - package: tezos-node-updater + package: tezos-protocol-updater opam:23:tezos-node-shell: <<: *opam_definition diff --git a/src/bin_node/jbuild b/src/bin_node/jbuild index 7f0ed9bc3..d6967834b 100644 --- a/src/bin_node/jbuild +++ b/src/bin_node/jbuild @@ -9,7 +9,7 @@ tezos-p2p tezos-shell-services tezos-shell - tezos-node-updater + tezos-protocol-updater tezos-embedded-protocol-genesis tezos-embedded-protocol-demo tezos-embedded-protocol-alpha @@ -23,7 +23,7 @@ -open Tezos_p2p -open Tezos_shell_services -open Tezos_shell - -open Tezos_node_updater + -open Tezos_protocol_updater -linkall)))) (install diff --git a/src/bin_node/tezos-node.opam b/src/bin_node/tezos-node.opam index 0b505e88a..7d5229f62 100644 --- a/src/bin_node/tezos-node.opam +++ b/src/bin_node/tezos-node.opam @@ -13,6 +13,7 @@ depends: [ "tezos-rpc-http" "tezos-p2p" "tezos-shell" + "tezos-protocol-updater" "tezos-embedded-protocol-genesis" "tezos-embedded-protocol-demo" "tezos-embedded-protocol-alpha" diff --git a/src/lib_client_base/jbuild b/src/lib_client_base/jbuild index 234d75fa0..678325b3d 100644 --- a/src/lib_client_base/jbuild +++ b/src/lib_client_base/jbuild @@ -8,7 +8,7 @@ tezos-rpc-http tezos-p2p-services tezos-shell-services - tezos-node-updater + tezos-protocol-updater tezos-protocol-compiler)) (flags (:standard -w -9+27-30-32-40@8 -safe-string @@ -17,7 +17,7 @@ -open Tezos_rpc_http -open Tezos_p2p_services -open Tezos_shell_services - -open Tezos_node_updater)))) + -open Tezos_protocol_updater)))) (alias ((name runtest_indent) diff --git a/src/lib_client_base/tezos-client-base.opam b/src/lib_client_base/tezos-client-base.opam index 2bc8483d5..75709ea42 100644 --- a/src/lib_client_base/tezos-client-base.opam +++ b/src/lib_client_base/tezos-client-base.opam @@ -14,8 +14,8 @@ depends: [ "tezos-rpc-http" "tezos-p2p-services" "tezos-shell-services" - "tezos-node-updater" "tezos-protocol-compiler" + "tezos-protocol-updater" "tezos-embedded-protocol-genesis" "tezos-embedded-protocol-demo" "tezos-embedded-protocol-alpha" diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index 9542f8a53..fc9e1c44e 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -22,7 +22,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| ((targets (environment.ml)) (action (write-file ${@@} - "include Tezos_node_updater.Tezos_protocol_environment.Make(struct let name = \"%s\" end)()")))) + "include Tezos_protocol_updater.Tezos_protocol_environment.Make(struct let name = \"%s\" end)()")))) (rule ((targets (registerer.ml)) @@ -35,7 +35,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| ((name tezos_embedded_protocol_environment_%s) (public_name tezos-embedded-protocol-%s.environment) (library_flags (:standard -linkall)) - (libraries (tezos-node-updater)) + (libraries (tezos-protocol-updater)) (modules (Environment)))) (library diff --git a/src/lib_node_updater/jbuild b/src/lib_protocol_updater/jbuild similarity index 91% rename from src/lib_node_updater/jbuild rename to src/lib_protocol_updater/jbuild index 1583f740c..9223ecf99 100644 --- a/src/lib_node_updater/jbuild +++ b/src/lib_protocol_updater/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_node_updater) - (public_name tezos-node-updater) + ((name tezos_protocol_updater) + (public_name tezos-protocol-updater) (libraries (tezos-base tezos-micheline tezos-protocol-compiler diff --git a/src/lib_node_updater/register.ml b/src/lib_protocol_updater/register.ml similarity index 100% rename from src/lib_node_updater/register.ml rename to src/lib_protocol_updater/register.ml diff --git a/src/lib_node_updater/register.mli b/src/lib_protocol_updater/register.mli similarity index 100% rename from src/lib_node_updater/register.mli rename to src/lib_protocol_updater/register.mli diff --git a/src/lib_node_updater/tezos-node-updater.opam b/src/lib_protocol_updater/tezos-protocol-updater.opam similarity index 100% rename from src/lib_node_updater/tezos-node-updater.opam rename to src/lib_protocol_updater/tezos-protocol-updater.opam diff --git a/src/lib_node_updater/tezos_protocol_environment.ml b/src/lib_protocol_updater/tezos_protocol_environment.ml similarity index 100% rename from src/lib_node_updater/tezos_protocol_environment.ml rename to src/lib_protocol_updater/tezos_protocol_environment.ml diff --git a/src/lib_node_updater/updater.ml b/src/lib_protocol_updater/updater.ml similarity index 100% rename from src/lib_node_updater/updater.ml rename to src/lib_protocol_updater/updater.ml diff --git a/src/lib_node_updater/updater.mli b/src/lib_protocol_updater/updater.mli similarity index 100% rename from src/lib_node_updater/updater.mli rename to src/lib_protocol_updater/updater.mli diff --git a/src/lib_shell/jbuild b/src/lib_shell/jbuild index 0b9971ea2..070e150aa 100644 --- a/src/lib_shell/jbuild +++ b/src/lib_shell/jbuild @@ -9,7 +9,7 @@ tezos-p2p-services tezos-p2p tezos-shell-services - tezos-node-updater)) + tezos-protocol-updater)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives @@ -18,7 +18,7 @@ -open Tezos_p2p_services -open Tezos_p2p -open Tezos_shell_services - -open Tezos_node_updater)))) + -open Tezos_protocol_updater)))) (alias ((name runtest_indent) diff --git a/src/lib_shell/tezos-shell.opam b/src/lib_shell/tezos-shell.opam index 288ba0a57..6477573d6 100644 --- a/src/lib_shell/tezos-shell.opam +++ b/src/lib_shell/tezos-shell.opam @@ -14,7 +14,7 @@ depends: [ "tezos-p2p-services" "tezos-p2p" "tezos-shell-services" - "tezos-node-updater" + "tezos-protocol-updater" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam b/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam index e2813e50f..586454b96 100644 --- a/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam +++ b/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam @@ -10,7 +10,7 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" - "tezos-node-updater" + "tezos-protocol-updater" "tezos-shell" ] build: [ diff --git a/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam b/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam index 764d7660f..036ce1c52 100644 --- a/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam +++ b/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam @@ -10,7 +10,7 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" - "tezos-node-updater" + "tezos-protocol-updater" "tezos-shell" ] build: [ diff --git a/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam b/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam index 50b09b38d..77e01e354 100644 --- a/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam +++ b/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam @@ -10,7 +10,7 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-protocol-compiler" - "tezos-node-updater" + "tezos-protocol-updater" "tezos-shell" ] build: [ From b0466aceed92e421ea3721d94640ed02e035a5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 23 Jan 2018 14:53:49 +0100 Subject: [PATCH 09/27] Refactor: Fix `lib_protocol_updater` dependencies --- src/lib_protocol_updater/jbuild | 6 +----- src/lib_protocol_updater/tezos_protocol_environment.ml | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib_protocol_updater/jbuild b/src/lib_protocol_updater/jbuild index 9223ecf99..c23993b30 100644 --- a/src/lib_protocol_updater/jbuild +++ b/src/lib_protocol_updater/jbuild @@ -8,8 +8,6 @@ tezos-protocol-compiler tezos-storage tezos-rpc-http - tezos-p2p-services - tezos-shell-services dynlink)) (flags (:standard -w -9+27-30-32-40@8 -safe-string @@ -17,9 +15,7 @@ -open Tezos_micheline -open Tezos_protocol_compiler -open Tezos_storage - -open Tezos_rpc_http - -open Tezos_p2p_services - -open Tezos_shell_services)))) + -open Tezos_rpc_http)))) (alias ((name runtest_indent) diff --git a/src/lib_protocol_updater/tezos_protocol_environment.ml b/src/lib_protocol_updater/tezos_protocol_environment.ml index 08b83304f..9d7280f47 100644 --- a/src/lib_protocol_updater/tezos_protocol_environment.ml +++ b/src/lib_protocol_updater/tezos_protocol_environment.ml @@ -61,7 +61,7 @@ module Make(Param : sig val name: string end)() = struct module RPC_service = RPC_service module RPC_answer = RPC_answer module RPC_directory = RPC_directory - module Micheline = Tezos_micheline.Micheline + module Micheline = Micheline module Fitness = Fitness module Error_monad = struct type error_category = [ `Branch | `Temporary | `Permanent ] From c4420ac40e5762273e6c43fa3f67a487bcfbd8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 23 Jan 2018 15:11:55 +0100 Subject: [PATCH 10/27] Refactor: Move `Blake2B.Make` instanciation into `Tezos_base` --- src/{lib_crypto => lib_base}/block_hash.ml | 0 src/{lib_crypto => lib_base}/block_hash.mli | 2 +- src/{lib_crypto => lib_base}/context_hash.ml | 0 src/{lib_crypto => lib_base}/context_hash.mli | 2 +- src/{lib_crypto => lib_base}/net_id.ml | 2 ++ src/{lib_crypto => lib_base}/net_id.mli | 2 +- src/{lib_crypto => lib_base}/operation_hash.ml | 0 src/{lib_crypto => lib_base}/operation_hash.mli | 2 +- src/{lib_crypto => lib_base}/operation_list_hash.ml | 0 src/{lib_crypto => lib_base}/operation_list_hash.mli | 2 +- .../operation_list_list_hash.ml | 0 .../operation_list_list_hash.mli | 2 +- src/{lib_crypto => lib_base}/protocol_hash.ml | 0 src/{lib_crypto => lib_base}/protocol_hash.mli | 2 +- src/lib_base/tzPervasives.ml | 10 +++++++++- src/lib_base/tzPervasives.mli | 10 +++++++++- src/lib_protocol_compiler/main_embedded_packer.ml | 2 +- src/lib_protocol_updater/tezos_protocol_environment.ml | 7 +++++++ 18 files changed, 35 insertions(+), 10 deletions(-) rename src/{lib_crypto => lib_base}/block_hash.ml (100%) rename src/{lib_crypto => lib_base}/block_hash.mli (94%) rename src/{lib_crypto => lib_base}/context_hash.ml (100%) rename src/{lib_crypto => lib_base}/context_hash.mli (94%) rename src/{lib_crypto => lib_base}/net_id.ml (99%) rename src/{lib_crypto => lib_base}/net_id.mli (94%) rename src/{lib_crypto => lib_base}/operation_hash.ml (100%) rename src/{lib_crypto => lib_base}/operation_hash.mli (94%) rename src/{lib_crypto => lib_base}/operation_list_hash.ml (100%) rename src/{lib_crypto => lib_base}/operation_list_hash.mli (88%) rename src/{lib_crypto => lib_base}/operation_list_list_hash.ml (100%) rename src/{lib_crypto => lib_base}/operation_list_list_hash.mli (88%) rename src/{lib_crypto => lib_base}/protocol_hash.ml (100%) rename src/{lib_crypto => lib_base}/protocol_hash.mli (94%) diff --git a/src/lib_crypto/block_hash.ml b/src/lib_base/block_hash.ml similarity index 100% rename from src/lib_crypto/block_hash.ml rename to src/lib_base/block_hash.ml diff --git a/src/lib_crypto/block_hash.mli b/src/lib_base/block_hash.mli similarity index 94% rename from src/lib_crypto/block_hash.mli rename to src/lib_base/block_hash.mli index c38290500..b92abd52c 100644 --- a/src/lib_crypto/block_hash.mli +++ b/src/lib_base/block_hash.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -include S.INTERNAL_HASH +include Tezos_crypto.S.INTERNAL_HASH diff --git a/src/lib_crypto/context_hash.ml b/src/lib_base/context_hash.ml similarity index 100% rename from src/lib_crypto/context_hash.ml rename to src/lib_base/context_hash.ml diff --git a/src/lib_crypto/context_hash.mli b/src/lib_base/context_hash.mli similarity index 94% rename from src/lib_crypto/context_hash.mli rename to src/lib_base/context_hash.mli index c38290500..b92abd52c 100644 --- a/src/lib_crypto/context_hash.mli +++ b/src/lib_base/context_hash.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -include S.INTERNAL_HASH +include Tezos_crypto.S.INTERNAL_HASH diff --git a/src/lib_crypto/net_id.ml b/src/lib_base/net_id.ml similarity index 99% rename from src/lib_crypto/net_id.ml rename to src/lib_base/net_id.ml index 1173b9f17..232aa506f 100644 --- a/src/lib_crypto/net_id.ml +++ b/src/lib_base/net_id.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Error_monad + type t = string let name = "Net_id" diff --git a/src/lib_crypto/net_id.mli b/src/lib_base/net_id.mli similarity index 94% rename from src/lib_crypto/net_id.mli rename to src/lib_base/net_id.mli index 4a6c70353..488a13245 100644 --- a/src/lib_crypto/net_id.mli +++ b/src/lib_base/net_id.mli @@ -7,5 +7,5 @@ (* *) (**************************************************************************) -include S.INTERNAL_HASH +include Tezos_crypto.S.INTERNAL_HASH val of_block_hash: Block_hash.t -> t diff --git a/src/lib_crypto/operation_hash.ml b/src/lib_base/operation_hash.ml similarity index 100% rename from src/lib_crypto/operation_hash.ml rename to src/lib_base/operation_hash.ml diff --git a/src/lib_crypto/operation_hash.mli b/src/lib_base/operation_hash.mli similarity index 94% rename from src/lib_crypto/operation_hash.mli rename to src/lib_base/operation_hash.mli index c38290500..b92abd52c 100644 --- a/src/lib_crypto/operation_hash.mli +++ b/src/lib_base/operation_hash.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -include S.INTERNAL_HASH +include Tezos_crypto.S.INTERNAL_HASH diff --git a/src/lib_crypto/operation_list_hash.ml b/src/lib_base/operation_list_hash.ml similarity index 100% rename from src/lib_crypto/operation_list_hash.ml rename to src/lib_base/operation_list_hash.ml diff --git a/src/lib_crypto/operation_list_hash.mli b/src/lib_base/operation_list_hash.mli similarity index 88% rename from src/lib_crypto/operation_list_hash.mli rename to src/lib_base/operation_list_hash.mli index 9ad1c3510..d562b52cd 100644 --- a/src/lib_crypto/operation_list_hash.mli +++ b/src/lib_base/operation_list_hash.mli @@ -7,5 +7,5 @@ (* *) (**************************************************************************) -include S.INTERNAL_MERKLE_TREE with type elt = Operation_hash.t +include Tezos_crypto.S.INTERNAL_MERKLE_TREE with type elt = Operation_hash.t diff --git a/src/lib_crypto/operation_list_list_hash.ml b/src/lib_base/operation_list_list_hash.ml similarity index 100% rename from src/lib_crypto/operation_list_list_hash.ml rename to src/lib_base/operation_list_list_hash.ml diff --git a/src/lib_crypto/operation_list_list_hash.mli b/src/lib_base/operation_list_list_hash.mli similarity index 88% rename from src/lib_crypto/operation_list_list_hash.mli rename to src/lib_base/operation_list_list_hash.mli index c9f2c631e..f9c1c7a24 100644 --- a/src/lib_crypto/operation_list_list_hash.mli +++ b/src/lib_base/operation_list_list_hash.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -include S.INTERNAL_MERKLE_TREE with type elt = Operation_list_hash.t +include Tezos_crypto.S.INTERNAL_MERKLE_TREE with type elt = Operation_list_hash.t diff --git a/src/lib_crypto/protocol_hash.ml b/src/lib_base/protocol_hash.ml similarity index 100% rename from src/lib_crypto/protocol_hash.ml rename to src/lib_base/protocol_hash.ml diff --git a/src/lib_crypto/protocol_hash.mli b/src/lib_base/protocol_hash.mli similarity index 94% rename from src/lib_crypto/protocol_hash.mli rename to src/lib_base/protocol_hash.mli index c38290500..b92abd52c 100644 --- a/src/lib_crypto/protocol_hash.mli +++ b/src/lib_base/protocol_hash.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -include S.INTERNAL_HASH +include Tezos_crypto.S.INTERNAL_HASH diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index 3072cdf95..efdda403b 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -9,10 +9,10 @@ include Tezos_stdlib include Tezos_stdlib_lwt -include Tezos_crypto include Tezos_data_encoding include Tezos_error_monad include Tezos_rpc +include Tezos_crypto module List = struct include List @@ -30,6 +30,14 @@ module Block_header = Block_header module Operation = Operation module Protocol = Protocol +module Net_id = Net_id +module Block_hash = Block_hash +module Operation_hash = Operation_hash +module Operation_list_hash = Operation_list_hash +module Operation_list_list_hash = Operation_list_list_hash +module Context_hash = Context_hash +module Protocol_hash = Protocol_hash + module Test_network_status = Test_network_status module Preapply_result = Preapply_result diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index 3c2ac4704..64e023a39 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -10,9 +10,9 @@ include (module type of (struct include Tezos_stdlib end)) include (module type of (struct include Tezos_data_encoding end)) include (module type of (struct include Tezos_stdlib_lwt end)) -include (module type of (struct include Tezos_crypto end)) include (module type of (struct include Tezos_error_monad end)) include (module type of (struct include Tezos_rpc end)) +include (module type of (struct include Tezos_crypto end)) module List : sig include (module type of (struct include List end)) @@ -34,5 +34,13 @@ module Preapply_result = Preapply_result module Block_locator = Block_locator module Mempool = Mempool +module Net_id = Net_id +module Block_hash = Block_hash +module Operation_hash = Operation_hash +module Operation_list_hash = Operation_list_hash +module Operation_list_list_hash = Operation_list_list_hash +module Context_hash = Context_hash +module Protocol_hash = Protocol_hash + include (module type of (struct include Utils.Infix end)) include (module type of (struct include Error_monad end)) diff --git a/src/lib_protocol_compiler/main_embedded_packer.ml b/src/lib_protocol_compiler/main_embedded_packer.ml index 0c115622f..3c3294616 100644 --- a/src/lib_protocol_compiler/main_embedded_packer.ml +++ b/src/lib_protocol_compiler/main_embedded_packer.ml @@ -16,7 +16,7 @@ let () = Format.printf {| module Source = struct let hash = - Some (Tezos_crypto.Protocol_hash.of_b58check_exn %S) + Some (Tezos_base.Protocol_hash.of_b58check_exn %S) let sources = Tezos_base.Protocol.%a end @.|} diff --git a/src/lib_protocol_updater/tezos_protocol_environment.ml b/src/lib_protocol_updater/tezos_protocol_environment.ml index 9d7280f47..e07130166 100644 --- a/src/lib_protocol_updater/tezos_protocol_environment.ml +++ b/src/lib_protocol_updater/tezos_protocol_environment.ml @@ -43,6 +43,13 @@ module Make(Param : sig val name: string end)() = struct module Hash = struct include Tezos_crypto include Tezos_crypto.S + module Net_id = Net_id + module Block_hash = Block_hash + module Operation_hash = Operation_hash + module Operation_list_hash = Operation_list_hash + module Operation_list_list_hash = Operation_list_list_hash + module Context_hash = Context_hash + module Protocol_hash = Protocol_hash module Make_minimal_Blake2B = Blake2B.Make_minimal module Make_Blake2B = Blake2B.Make end From be9f0684782b7a7dc8f6e9a89cbc4ba09f8d936f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 24 Jan 2018 10:25:29 +0100 Subject: [PATCH 11/27] Refactor: More PRC types into `Tezos_base` --- src/lib_protocol_updater/jbuild | 4 +--- src/lib_protocol_updater/tezos-protocol-updater.opam | 3 --- src/{lib_rpc_http => lib_rpc}/RPC_answer.ml | 0 src/{lib_rpc_http => lib_rpc}/RPC_answer.mli | 0 src/{lib_rpc_http => lib_rpc}/RPC_directory.ml | 0 src/{lib_rpc_http => lib_rpc}/RPC_directory.mli | 0 src/lib_rpc/jbuild | 3 ++- src/lib_rpc/tezos-rpc.opam | 1 + src/lib_rpc_http/jbuild | 1 - 9 files changed, 4 insertions(+), 8 deletions(-) rename src/{lib_rpc_http => lib_rpc}/RPC_answer.ml (100%) rename src/{lib_rpc_http => lib_rpc}/RPC_answer.mli (100%) rename src/{lib_rpc_http => lib_rpc}/RPC_directory.ml (100%) rename src/{lib_rpc_http => lib_rpc}/RPC_directory.mli (100%) diff --git a/src/lib_protocol_updater/jbuild b/src/lib_protocol_updater/jbuild index c23993b30..785dc51a9 100644 --- a/src/lib_protocol_updater/jbuild +++ b/src/lib_protocol_updater/jbuild @@ -7,15 +7,13 @@ tezos-micheline tezos-protocol-compiler tezos-storage - tezos-rpc-http dynlink)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives -open Tezos_micheline -open Tezos_protocol_compiler - -open Tezos_storage - -open Tezos_rpc_http)))) + -open Tezos_storage)))) (alias ((name runtest_indent) diff --git a/src/lib_protocol_updater/tezos-protocol-updater.opam b/src/lib_protocol_updater/tezos-protocol-updater.opam index 65140d5a2..9a4a54471 100644 --- a/src/lib_protocol_updater/tezos-protocol-updater.opam +++ b/src/lib_protocol_updater/tezos-protocol-updater.opam @@ -13,9 +13,6 @@ depends: [ "tezos-micheline" "tezos-protocol-compiler" "tezos-storage" - "tezos-rpc-http" - "tezos-p2p-services" - "tezos-shell-services" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_rpc_http/RPC_answer.ml b/src/lib_rpc/RPC_answer.ml similarity index 100% rename from src/lib_rpc_http/RPC_answer.ml rename to src/lib_rpc/RPC_answer.ml diff --git a/src/lib_rpc_http/RPC_answer.mli b/src/lib_rpc/RPC_answer.mli similarity index 100% rename from src/lib_rpc_http/RPC_answer.mli rename to src/lib_rpc/RPC_answer.mli diff --git a/src/lib_rpc_http/RPC_directory.ml b/src/lib_rpc/RPC_directory.ml similarity index 100% rename from src/lib_rpc_http/RPC_directory.ml rename to src/lib_rpc/RPC_directory.ml diff --git a/src/lib_rpc_http/RPC_directory.mli b/src/lib_rpc/RPC_directory.mli similarity index 100% rename from src/lib_rpc_http/RPC_directory.mli rename to src/lib_rpc/RPC_directory.mli diff --git a/src/lib_rpc/jbuild b/src/lib_rpc/jbuild index 497f3795c..b5c505309 100644 --- a/src/lib_rpc/jbuild +++ b/src/lib_rpc/jbuild @@ -5,7 +5,8 @@ (public_name tezos-rpc) (libraries (tezos-data-encoding tezos-error-monad - ocplib-resto)) + ocplib-resto + ocplib-resto-directory)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_data_encoding diff --git a/src/lib_rpc/tezos-rpc.opam b/src/lib_rpc/tezos-rpc.opam index 8eb6aba45..d74a8f5c5 100644 --- a/src/lib_rpc/tezos-rpc.opam +++ b/src/lib_rpc/tezos-rpc.opam @@ -11,6 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-data-encoding" "ocplib-resto" + "ocplib-resto-directory" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_rpc_http/jbuild b/src/lib_rpc_http/jbuild index db8713afb..ff5a770e8 100644 --- a/src/lib_rpc_http/jbuild +++ b/src/lib_rpc_http/jbuild @@ -4,7 +4,6 @@ ((name tezos_rpc_http) (public_name tezos-rpc-http) (libraries (tezos-base - ocplib-resto-directory ocplib-resto-cohttp)) (flags (:standard -w -9+27-30-32-40@8 -safe-string From 7277c9889bac8f0eba8261ade1c6730ece3eb1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 24 Jan 2018 12:48:25 +0100 Subject: [PATCH 12/27] Refactor: Move/split `P2p_types` into `lib_base` --- .gitlab-ci.yml | 8 +- src/bin_attacker/attacker_minimal.ml | 2 +- src/bin_node/node_config_file.ml | 2 +- src/bin_node/node_config_file.mli | 6 +- src/bin_node/node_identity_command.ml | 8 +- src/bin_node/node_identity_file.ml | 4 +- src/bin_node/node_identity_file.mli | 4 +- src/bin_node/node_run_command.ml | 10 +- src/lib_base/p2p_addr.ml | 28 + src/lib_base/p2p_addr.mli | 13 + src/lib_base/p2p_connection.ml | 252 ++++++ src/lib_base/p2p_connection.mli | 107 +++ src/lib_base/p2p_connection_id.ml | 9 + src/lib_base/p2p_connection_id.mli | 11 + src/lib_base/p2p_id_point.ml | 0 src/lib_base/p2p_id_point.mli | 9 + src/lib_base/p2p_identity.ml | 77 ++ src/lib_base/p2p_identity.mli | 29 + src/lib_base/p2p_peer.ml | 339 +++++++++ src/lib_base/p2p_peer.mli | 184 +++++ src/lib_base/p2p_point.ml | 477 ++++++++++++ src/lib_base/p2p_point.mli | 207 +++++ src/lib_base/p2p_stat.ml | 64 ++ src/lib_base/p2p_stat.mli | 21 + src/lib_base/p2p_version.ml | 40 + src/lib_base/p2p_version.mli | 22 + src/lib_base/time.ml | 8 + src/lib_base/time.mli | 3 + src/lib_base/tzPervasives.ml | 8 + src/lib_base/tzPervasives.mli | 8 + src/lib_client_base/client_network.ml | 34 +- src/lib_client_base/client_node_rpcs.mli | 10 +- src/lib_p2p/p2p.ml | 215 +++--- src/lib_p2p/p2p.mli | 98 +-- src/lib_p2p/p2p_discovery.ml | 8 +- src/lib_p2p/p2p_discovery.mli | 2 +- src/lib_p2p/p2p_io_scheduler.ml | 3 +- src/lib_p2p/p2p_io_scheduler.mli | 6 +- src/lib_p2p/p2p_maintenance.ml | 35 +- src/lib_p2p/p2p_maintenance.mli | 2 +- .../{p2p_connection_pool.ml => p2p_pool.ml} | 377 +++++---- .../{p2p_connection_pool.mli => p2p_pool.mli} | 79 +- .../{p2p_connection.ml => p2p_socket.ml} | 48 +- .../{p2p_connection.mli => p2p_socket.mli} | 16 +- src/lib_p2p/p2p_welcome.ml | 4 +- src/lib_p2p/p2p_welcome.mli | 6 +- .../p2p_connection_pool_types.ml | 526 ------------- .../p2p_connection_pool_types.mli | 284 ------- src/lib_p2p_services/p2p_services.ml | 38 +- src/lib_p2p_services/p2p_services.mli | 42 +- src/lib_p2p_services/p2p_types.ml | 717 ------------------ src/lib_p2p_services/p2p_types.mli | 263 ------- src/lib_shell/block_validator.ml | 2 +- src/lib_shell/block_validator.mli | 4 +- src/lib_shell/bootstrap_pipeline.ml | 34 +- src/lib_shell/bootstrap_pipeline.mli | 4 +- src/lib_shell/distributed_db.ml | 58 +- src/lib_shell/distributed_db.mli | 22 +- src/lib_shell/distributed_db_functors.ml | 78 +- src/lib_shell/distributed_db_functors.mli | 20 +- src/lib_shell/distributed_db_message.ml | 2 +- src/lib_shell/net_validator.ml | 26 +- src/lib_shell/node.mli | 42 +- src/lib_shell/peer_validator.ml | 38 +- src/lib_shell/peer_validator.mli | 6 +- src/lib_shell/prevalidator.mli | 2 +- src/lib_shell/protocol_validator.mli | 6 +- .../block_validator_worker_state.ml | 6 +- .../block_validator_worker_state.mli | 2 +- .../net_validator_worker_state.ml | 12 +- .../net_validator_worker_state.mli | 4 +- .../prevalidator_worker_state.ml | 6 +- .../prevalidator_worker_state.mli | 2 +- src/lib_shell_services/shell_services.ml | 8 +- src/lib_shell_services/shell_services.mli | 4 +- test/p2p/jbuild | 20 +- test/p2p/test_p2p_io_scheduler.ml | 9 +- ...2p_connection_pool.ml => test_p2p_pool.ml} | 61 +- ...t_p2p_connection.ml => test_p2p_socket.ml} | 111 ++- 79 files changed, 2711 insertions(+), 2651 deletions(-) create mode 100644 src/lib_base/p2p_addr.ml create mode 100644 src/lib_base/p2p_addr.mli create mode 100644 src/lib_base/p2p_connection.ml create mode 100644 src/lib_base/p2p_connection.mli create mode 100644 src/lib_base/p2p_connection_id.ml create mode 100644 src/lib_base/p2p_connection_id.mli create mode 100644 src/lib_base/p2p_id_point.ml create mode 100644 src/lib_base/p2p_id_point.mli create mode 100644 src/lib_base/p2p_identity.ml create mode 100644 src/lib_base/p2p_identity.mli create mode 100644 src/lib_base/p2p_peer.ml create mode 100644 src/lib_base/p2p_peer.mli create mode 100644 src/lib_base/p2p_point.ml create mode 100644 src/lib_base/p2p_point.mli create mode 100644 src/lib_base/p2p_stat.ml create mode 100644 src/lib_base/p2p_stat.mli create mode 100644 src/lib_base/p2p_version.ml create mode 100644 src/lib_base/p2p_version.mli rename src/lib_p2p/{p2p_connection_pool.ml => p2p_pool.ml} (71%) rename src/lib_p2p/{p2p_connection_pool.mli => p2p_pool.mli} (81%) rename src/lib_p2p/{p2p_connection.ml => p2p_socket.ml} (92%) rename src/lib_p2p/{p2p_connection.mli => p2p_socket.mli} (93%) delete mode 100644 src/lib_p2p_services/p2p_connection_pool_types.ml delete mode 100644 src/lib_p2p_services/p2p_connection_pool_types.mli delete mode 100644 src/lib_p2p_services/p2p_types.ml delete mode 100644 src/lib_p2p_services/p2p_types.mli rename test/p2p/{test_p2p_connection_pool.ml => test_p2p_pool.ml} (82%) rename test/p2p/{test_p2p_connection.ml => test_p2p_socket.ml} (78%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d36efdd07..3c12e6983 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -111,15 +111,15 @@ test:p2p:io-scheduler: script: - jbuilder build @test/p2p/runtest_p2p_io_scheduler -test:p2p:connection: +test:p2p:socket: <<: *test_definition script: - - jbuilder build @test/p2p/runtest_p2p_connection + - jbuilder build @test/p2p/runtest_p2p_socket -test:p2p:connection-pool: +test:p2p:pool: <<: *test_definition script: - - jbuilder build @test/p2p/runtest_p2p_connection_pool + - jbuilder build @test/p2p/runtest_p2p_pool test:proto_alpha:transaction: <<: *test_definition diff --git a/src/bin_attacker/attacker_minimal.ml b/src/bin_attacker/attacker_minimal.ml index 5d90afa91..8aef25f9a 100644 --- a/src/bin_attacker/attacker_minimal.ml +++ b/src/bin_attacker/attacker_minimal.ml @@ -103,7 +103,7 @@ let ballot_forged period prop vote = operations = [ballot] }) in forge { net_id = network } op -let identity = P2p_types.Identity.generate Crypto_box.default_target +let identity = P2p_identity.generate Crypto_box.default_target (* connect to the network, run an action and then disconnect *) let try_action addr port action = diff --git a/src/bin_node/node_config_file.ml b/src/bin_node/node_config_file.ml index 40278de4c..ec0538999 100644 --- a/src/bin_node/node_config_file.ml +++ b/src/bin_node/node_config_file.ml @@ -529,7 +529,7 @@ let update return { data_dir ; net ; rpc ; log ; shell } let resolve_addr ?default_port ?(passive = false) peer = - let addr, port = P2p.Point.parse_addr_port peer in + let addr, port = P2p_point.Id.parse_addr_port peer in let node = if addr = "" || addr = "_" then "::" else addr and service = match port, default_port with diff --git a/src/bin_node/node_config_file.mli b/src/bin_node/node_config_file.mli index 287656c0e..b6e2b52ef 100644 --- a/src/bin_node/node_config_file.mli +++ b/src/bin_node/node_config_file.mli @@ -80,8 +80,8 @@ val to_string: t -> string val read: string -> t tzresult Lwt.t val write: string -> t -> unit tzresult Lwt.t -val resolve_listening_addrs: string -> (P2p_types.addr * int) list Lwt.t -val resolve_rpc_listening_addrs: string -> (P2p_types.addr * int) list Lwt.t -val resolve_bootstrap_addrs: string list -> (P2p_types.addr * int) list Lwt.t +val resolve_listening_addrs: string -> (P2p_addr.t * int) list Lwt.t +val resolve_rpc_listening_addrs: string -> (P2p_addr.t * int) list Lwt.t +val resolve_bootstrap_addrs: string list -> (P2p_addr.t * int) list Lwt.t val check: t -> unit Lwt.t diff --git a/src/bin_node/node_identity_command.ml b/src/bin_node/node_identity_command.ml index b5f0ffbe9..60e40f7dd 100644 --- a/src/bin_node/node_identity_command.ml +++ b/src/bin_node/node_identity_command.ml @@ -15,7 +15,7 @@ let identity_file data_dir = data_dir // Node_data_version.default_identity_file let show { Node_config_file.data_dir } = Node_identity_file.read (identity_file data_dir) >>=? fun id -> - Format.printf "Peer_id: %a.@." P2p_types.Peer_id.pp id.peer_id ; + Format.printf "Peer_id: %a.@." P2p_peer.Id.pp id.peer_id ; return () let generate { Node_config_file.data_dir ; net } = @@ -26,11 +26,11 @@ let generate { Node_config_file.data_dir ; net } = let target = Crypto_box.make_target net.expected_pow in Format.eprintf "Generating a new identity... (level: %.2f) " net.expected_pow ; let id = - P2p.Identity.generate_with_animation Format.err_formatter target in + P2p_identity.generate_with_animation Format.err_formatter target in Node_identity_file.write identity_file id >>=? fun () -> Format.eprintf "Stored the new identity (%a) into '%s'.@." - P2p.Peer_id.pp id.peer_id identity_file ; + P2p_peer.Id.pp id.peer_id identity_file ; return () let check { Node_config_file.data_dir ; net = { expected_pow } } = @@ -38,7 +38,7 @@ let check { Node_config_file.data_dir ; net = { expected_pow } } = ~expected_pow (identity_file data_dir) >>=? fun id -> Format.printf "Peer_id: %a. Proof of work is higher than %.2f.@." - P2p_types.Peer_id.pp id.peer_id expected_pow ; + P2p_peer.Id.pp id.peer_id expected_pow ; return () (** Main *) diff --git a/src/bin_node/node_identity_file.ml b/src/bin_node/node_identity_file.ml index 1294bd460..932f68034 100644 --- a/src/bin_node/node_identity_file.ml +++ b/src/bin_node/node_identity_file.ml @@ -47,7 +47,7 @@ let read ?expected_pow file = fail (No_identity_file file) | true -> Data_encoding_ezjsonm.read_file file >>=? fun json -> - let id = Data_encoding.Json.destruct P2p.Identity.encoding json in + let id = Data_encoding.Json.destruct P2p_identity.encoding json in match expected_pow with | None -> return id | Some expected -> @@ -81,4 +81,4 @@ let write file identity = else Node_data_version.ensure_data_dir (Filename.dirname file) >>=? fun () -> Data_encoding_ezjsonm.write_file file - (Data_encoding.Json.construct P2p.Identity.encoding identity) + (Data_encoding.Json.construct P2p_identity.encoding identity) diff --git a/src/bin_node/node_identity_file.mli b/src/bin_node/node_identity_file.mli index 7b770af08..62056b042 100644 --- a/src/bin_node/node_identity_file.mli +++ b/src/bin_node/node_identity_file.mli @@ -12,8 +12,8 @@ type error += Insufficient_proof_of_work of { expected: float } val read: ?expected_pow:float -> - string -> P2p.Identity.t tzresult Lwt.t + string -> P2p_identity.t tzresult Lwt.t type error += Existent_identity_file of string -val write: string -> P2p.Identity.t -> unit tzresult Lwt.t +val write: string -> P2p_identity.t -> unit tzresult Lwt.t diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index 4bd6d2c4d..6ee07e473 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -20,8 +20,8 @@ let genesis : State.Net.genesis = { "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im" ; } -type error += Non_private_sandbox of P2p_types.addr -type error += RPC_Port_already_in_use of P2p_types.addr +type error += Non_private_sandbox of P2p_addr.t +type error += RPC_Port_already_in_use of P2p_addr.t let () = register_error_kind @@ -36,7 +36,7 @@ let () = See `%s run --help` on how to change the listening address." Ipaddr.V6.pp_hum addr Sys.argv.(0) end - Data_encoding.(obj1 (req "addr" P2p_types.addr_encoding)) + Data_encoding.(obj1 (req "addr" P2p_addr.encoding)) (function Non_private_sandbox addr -> Some addr | _ -> None) (fun addr -> Non_private_sandbox addr); register_error_kind @@ -50,7 +50,7 @@ let () = Please choose another RPC port." Ipaddr.V6.pp_hum addr end - Data_encoding.(obj1 (req "addr" P2p_types.addr_encoding)) + Data_encoding.(obj1 (req "addr" P2p_addr.encoding)) (function RPC_Port_already_in_use addr -> Some addr | _ -> None) (fun addr -> RPC_Port_already_in_use addr) @@ -146,7 +146,7 @@ let init_node ?sandbox (config : Node_config_file.t) = Node_data_version.default_identity_file_name) >>=? fun identity -> lwt_log_notice "Peer's global id: %a" - P2p.Peer_id.pp identity.peer_id >>= fun () -> + P2p_peer.Id.pp identity.peer_id >>= fun () -> let p2p_config : P2p.config = { listening_addr ; listening_port ; diff --git a/src/lib_base/p2p_addr.ml b/src/lib_base/p2p_addr.ml new file mode 100644 index 000000000..880a29617 --- /dev/null +++ b/src/lib_base/p2p_addr.ml @@ -0,0 +1,28 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = Ipaddr.V6.t + +let encoding = + let open Data_encoding in + splitted + ~json:begin + conv + Ipaddr.V6.to_string + Ipaddr.V6.of_string_exn + string + end + ~binary:begin + conv + Ipaddr.V6.to_bytes + Ipaddr.V6.of_bytes_exn + string + end + +type port = int diff --git a/src/lib_base/p2p_addr.mli b/src/lib_base/p2p_addr.mli new file mode 100644 index 000000000..a3f996ad1 --- /dev/null +++ b/src/lib_base/p2p_addr.mli @@ -0,0 +1,13 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = Ipaddr.V6.t +type port = int + +val encoding : t Data_encoding.t diff --git a/src/lib_base/p2p_connection.ml b/src/lib_base/p2p_connection.ml new file mode 100644 index 000000000..f2bfad895 --- /dev/null +++ b/src/lib_base/p2p_connection.ml @@ -0,0 +1,252 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type peer_id = Crypto_box.Public_key_hash.t +let peer_id_encoding = Crypto_box.Public_key_hash.encoding +let peer_id_pp = Crypto_box.Public_key_hash.pp + +module Id = struct + + (* A net point (address x port). *) + type t = P2p_addr.t * P2p_addr.port option + let compare (a1, p1) (a2, p2) = + match Ipaddr.V6.compare a1 a2 with + | 0 -> Pervasives.compare p1 p2 + | x -> x + let equal p1 p2 = compare p1 p2 = 0 + let hash = Hashtbl.hash + let pp ppf (addr, port) = + match port with + | None -> + Format.fprintf ppf "[%a]:??" Ipaddr.V6.pp_hum addr + | Some port -> + Format.fprintf ppf "[%a]:%d" Ipaddr.V6.pp_hum addr port + let pp_opt ppf = function + | None -> Format.pp_print_string ppf "none" + | Some point -> pp ppf point + let to_string t = Format.asprintf "%a" pp t + + let is_local (addr, _) = Ipaddr.V6.is_private addr + let is_global (addr, _) = not @@ Ipaddr.V6.is_private addr + + let of_point (addr, port) = addr, Some port + let to_point = function + | _, None -> None + | addr, Some port -> Some (addr, port) + let to_point_exn = function + | _, None -> invalid_arg "to_point_exn" + | addr, Some port -> addr, port + + let encoding = + let open Data_encoding in + (obj2 + (req "addr" P2p_addr.encoding) + (opt "port" uint16)) + +end + +module Map = Map.Make (Id) +module Set = Set.Make (Id) +module Table = Hashtbl.Make (Id) + +module Info = struct + + type t = { + incoming : bool; + peer_id : peer_id; + id_point : Id.t; + remote_socket_port : P2p_addr.port; + versions : P2p_version.t list ; + } + + let encoding = + let open Data_encoding in + conv + (fun { incoming ; peer_id ; id_point ; remote_socket_port ; versions } -> + (incoming, peer_id, id_point, remote_socket_port, versions)) + (fun (incoming, peer_id, id_point, remote_socket_port, versions) -> + { incoming ; peer_id ; id_point ; remote_socket_port ; versions }) + (obj5 + (req "incoming" bool) + (req "peer_id" peer_id_encoding) + (req "id_point" Id.encoding) + (req "remote_socket_port" uint16) + (req "versions" (list P2p_version.encoding))) + + let pp ppf + { incoming ; id_point = (remote_addr, remote_port) ; + remote_socket_port ; peer_id ; versions } = + let version = List.hd versions in + let point = match remote_port with + | None -> remote_addr, remote_socket_port + | Some port -> remote_addr, port in + Format.fprintf ppf "%s %a %a (%a)" + (if incoming then "↘" else "↗") + peer_id_pp peer_id + P2p_point.Id.pp point + P2p_version.pp version + +end + +module Pool_event = struct + + (** Pool-level events *) + + type t = + + | Too_few_connections + | Too_many_connections + + | New_point of P2p_point.Id.t + | New_peer of peer_id + + | Gc_points + | Gc_peer_ids + + | Incoming_connection of P2p_point.Id.t + | Outgoing_connection of P2p_point.Id.t + | Authentication_failed of P2p_point.Id.t + | Accepting_request of P2p_point.Id.t * Id.t * peer_id + | Rejecting_request of P2p_point.Id.t * Id.t * peer_id + | Request_rejected of P2p_point.Id.t * (Id.t * peer_id) option + | Connection_established of Id.t * peer_id + + | Swap_request_received of { source : peer_id } + | Swap_ack_received of { source : peer_id } + | Swap_request_sent of { source : peer_id } + | Swap_ack_sent of { source : peer_id } + | Swap_request_ignored of { source : peer_id } + | Swap_success of { source : peer_id } + | Swap_failure of { source : peer_id } + + | Disconnection of peer_id + | External_disconnection of peer_id + + let encoding = + let open Data_encoding in + let branch_encoding name obj = + conv (fun x -> (), x) (fun ((), x) -> x) + (merge_objs + (obj1 (req "event" (constant name))) obj) in + union ~tag_size:`Uint8 [ + case (Tag 0) (branch_encoding "too_few_connections" empty) + (function Too_few_connections -> Some () | _ -> None) + (fun () -> Too_few_connections) ; + case (Tag 1) (branch_encoding "too_many_connections" empty) + (function Too_many_connections -> Some () | _ -> None) + (fun () -> Too_many_connections) ; + case (Tag 2) (branch_encoding "new_point" + (obj1 (req "point" P2p_point.Id.encoding))) + (function New_point p -> Some p | _ -> None) + (fun p -> New_point p) ; + case (Tag 3) (branch_encoding "new_peer" + (obj1 (req "peer_id" peer_id_encoding))) + (function New_peer p -> Some p | _ -> None) + (fun p -> New_peer p) ; + case (Tag 4) (branch_encoding "incoming_connection" + (obj1 (req "point" P2p_point.Id.encoding))) + (function Incoming_connection p -> Some p | _ -> None) + (fun p -> Incoming_connection p) ; + case (Tag 5) (branch_encoding "outgoing_connection" + (obj1 (req "point" P2p_point.Id.encoding))) + (function Outgoing_connection p -> Some p | _ -> None) + (fun p -> Outgoing_connection p) ; + case (Tag 6) (branch_encoding "authentication_failed" + (obj1 (req "point" P2p_point.Id.encoding))) + (function Authentication_failed p -> Some p | _ -> None) + (fun p -> Authentication_failed p) ; + case (Tag 7) (branch_encoding "accepting_request" + (obj3 + (req "point" P2p_point.Id.encoding) + (req "id_point" Id.encoding) + (req "peer_id" peer_id_encoding))) + (function Accepting_request (p, id_p, g) -> + Some (p, id_p, g) | _ -> None) + (fun (p, id_p, g) -> Accepting_request (p, id_p, g)) ; + case (Tag 8) (branch_encoding "rejecting_request" + (obj3 + (req "point" P2p_point.Id.encoding) + (req "id_point" Id.encoding) + (req "peer_id" peer_id_encoding))) + (function Rejecting_request (p, id_p, g) -> + Some (p, id_p, g) | _ -> None) + (fun (p, id_p, g) -> Rejecting_request (p, id_p, g)) ; + case (Tag 9) (branch_encoding "request_rejected" + (obj2 + (req "point" P2p_point.Id.encoding) + (opt "identity" + (tup2 Id.encoding peer_id_encoding)))) + (function Request_rejected (p, id) -> Some (p, id) | _ -> None) + (fun (p, id) -> Request_rejected (p, id)) ; + case (Tag 10) (branch_encoding "connection_established" + (obj2 + (req "id_point" Id.encoding) + (req "peer_id" peer_id_encoding))) + (function Connection_established (id_p, g) -> + Some (id_p, g) | _ -> None) + (fun (id_p, g) -> Connection_established (id_p, g)) ; + case (Tag 11) (branch_encoding "disconnection" + (obj1 (req "peer_id" peer_id_encoding))) + (function Disconnection g -> Some g | _ -> None) + (fun g -> Disconnection g) ; + case (Tag 12) (branch_encoding "external_disconnection" + (obj1 (req "peer_id" peer_id_encoding))) + (function External_disconnection g -> Some g | _ -> None) + (fun g -> External_disconnection g) ; + case (Tag 13) (branch_encoding "gc_points" empty) + (function Gc_points -> Some () | _ -> None) + (fun () -> Gc_points) ; + case (Tag 14) (branch_encoding "gc_peer_ids" empty) + (function Gc_peer_ids -> Some () | _ -> None) + (fun () -> Gc_peer_ids) ; + case (Tag 15) (branch_encoding "swap_request_received" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_request_received { source } -> Some source + | _ -> None) + (fun source -> Swap_request_received { source }) ; + case (Tag 16) (branch_encoding "swap_ack_received" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_ack_received { source } -> Some source + | _ -> None) + (fun source -> Swap_ack_received { source }) ; + case (Tag 17) (branch_encoding "swap_request_sent" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_request_sent { source } -> Some source + | _ -> None) + (fun source -> Swap_request_sent { source }) ; + case (Tag 18) (branch_encoding "swap_ack_sent" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_ack_sent { source } -> Some source + | _ -> None) + (fun source -> Swap_ack_sent { source }) ; + case (Tag 19) (branch_encoding "swap_request_ignored" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_request_ignored { source } -> Some source + | _ -> None) + (fun source -> Swap_request_ignored { source }) ; + case (Tag 20) (branch_encoding "swap_success" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_success { source } -> Some source + | _ -> None) + (fun source -> Swap_success { source }) ; + case (Tag 21) (branch_encoding "swap_failure" + (obj1 (req "source" peer_id_encoding))) + (function + | Swap_failure { source } -> Some source + | _ -> None) + (fun source -> Swap_failure { source }) ; + ] + +end diff --git a/src/lib_base/p2p_connection.mli b/src/lib_base/p2p_connection.mli new file mode 100644 index 000000000..772917cb8 --- /dev/null +++ b/src/lib_base/p2p_connection.mli @@ -0,0 +1,107 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type peer_id = Crypto_box.Public_key_hash.t +(* = P2p_peer.Id.t, but we should break cycles *) + +module Id : sig + + type t = P2p_addr.t * P2p_addr.port option + val compare : t -> t -> int + val equal : t -> t -> bool + val pp : Format.formatter -> t -> unit + val pp_opt : Format.formatter -> t option -> unit + val to_string : t -> string + val encoding : t Data_encoding.t + val is_local : t -> bool + val is_global : t -> bool + val of_point : P2p_point.Id.t -> t + val to_point : t -> P2p_point.Id.t option + val to_point_exn : t -> P2p_point.Id.t + +end + +module Map : Map.S with type key = Id.t +module Set : Set.S with type elt = Id.t +module Table : Hashtbl.S with type key = Id.t + +(** Information about a connection *) +module Info : sig + + type t = { + incoming : bool; + peer_id : peer_id; + id_point : Id.t; + remote_socket_port : P2p_addr.port; + versions : P2p_version.t list ; + } + + val pp : Format.formatter -> t -> unit + val encoding : t Data_encoding.t + +end + +module Pool_event : sig + + type t = + + | Too_few_connections + | Too_many_connections + + | New_point of P2p_point.Id.t + | New_peer of peer_id + + | Gc_points + (** Garbage collection of known point table has been triggered. *) + + | Gc_peer_ids + (** Garbage collection of known peer_ids table has been triggered. *) + + (* Connection-level events *) + + | Incoming_connection of P2p_point.Id.t + (** We accept(2)-ed an incoming connection *) + | Outgoing_connection of P2p_point.Id.t + (** We connect(2)-ed to a remote endpoint *) + | Authentication_failed of P2p_point.Id.t + (** Remote point failed authentication *) + + | Accepting_request of P2p_point.Id.t * Id.t * peer_id + (** We accepted a connection after authentifying the remote peer. *) + | Rejecting_request of P2p_point.Id.t * Id.t * peer_id + (** We rejected a connection after authentifying the remote peer. *) + | Request_rejected of P2p_point.Id.t * (Id.t * peer_id) option + (** The remote peer rejected our connection. *) + + | Connection_established of Id.t * peer_id + (** We succesfully established a authentified connection. *) + + | Swap_request_received of { source : peer_id } + (** A swap request has been received. *) + | Swap_ack_received of { source : peer_id } + (** A swap ack has been received *) + | Swap_request_sent of { source : peer_id } + (** A swap request has been sent *) + | Swap_ack_sent of { source : peer_id } + (** A swap ack has been sent *) + | Swap_request_ignored of { source : peer_id } + (** A swap request has been ignored *) + | Swap_success of { source : peer_id } + (** A swap operation has succeeded *) + | Swap_failure of { source : peer_id } + (** A swap operation has failed *) + + | Disconnection of peer_id + (** We decided to close the connection. *) + | External_disconnection of peer_id + (** The connection was closed for external reason. *) + + val encoding : t Data_encoding.t + +end diff --git a/src/lib_base/p2p_connection_id.ml b/src/lib_base/p2p_connection_id.ml new file mode 100644 index 000000000..769771c1b --- /dev/null +++ b/src/lib_base/p2p_connection_id.ml @@ -0,0 +1,9 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + diff --git a/src/lib_base/p2p_connection_id.mli b/src/lib_base/p2p_connection_id.mli new file mode 100644 index 000000000..cbaa05fe5 --- /dev/null +++ b/src/lib_base/p2p_connection_id.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** P2p_point representing a reachable socket address *) + diff --git a/src/lib_base/p2p_id_point.ml b/src/lib_base/p2p_id_point.ml new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib_base/p2p_id_point.mli b/src/lib_base/p2p_id_point.mli new file mode 100644 index 000000000..769771c1b --- /dev/null +++ b/src/lib_base/p2p_id_point.mli @@ -0,0 +1,9 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + diff --git a/src/lib_base/p2p_identity.ml b/src/lib_base/p2p_identity.ml new file mode 100644 index 000000000..d036ca669 --- /dev/null +++ b/src/lib_base/p2p_identity.ml @@ -0,0 +1,77 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = { + peer_id : P2p_peer.Id.t ; + public_key : Crypto_box.public_key ; + secret_key : Crypto_box.secret_key ; + proof_of_work_stamp : Crypto_box.nonce ; +} + +let encoding = + let open Data_encoding in + conv + (fun { public_key ; secret_key ; proof_of_work_stamp ; _ } -> + (public_key, secret_key, proof_of_work_stamp)) + (fun (public_key, secret_key, proof_of_work_stamp) -> + let peer_id = Tezos_crypto.Crypto_box.hash public_key in + { peer_id ; public_key ; secret_key ; proof_of_work_stamp }) + (obj3 + (req "public_key" Crypto_box.public_key_encoding) + (req "secret_key" Crypto_box.secret_key_encoding) + (req "proof_of_work_stamp" Crypto_box.nonce_encoding)) + +let generate ?max target = + let secret_key, public_key, peer_id = Crypto_box.random_keypair () in + let proof_of_work_stamp = + Crypto_box.generate_proof_of_work ?max public_key target in + { peer_id ; public_key ; secret_key ; proof_of_work_stamp } + +let animation = [| + "|.....|" ; + "|o....|" ; + "|oo...|" ; + "|ooo..|" ; + "|.ooo.|" ; + "|..ooo|" ; + "|...oo|" ; + "|....o|" ; + "|.....|" ; + "|.....|" ; + "|.....|" ; + "|.....|" ; +|] + +let init = String.make (String.length animation.(0)) '\ ' +let clean = String.make (String.length animation.(0)) '\b' +let animation = Array.map (fun x -> clean ^ x) animation +let animation_size = Array.length animation +let duration = 1200 / animation_size + +let generate_with_animation ppf target = + Format.fprintf ppf "%s%!" init ; + let count = ref 10000 in + let rec loop n = + let start = Mtime_clock.counter () in + Format.fprintf ppf "%s%!" animation.(n mod animation_size); + try generate ~max:!count target + with Not_found -> + let time = Mtime.Span.to_ms (Mtime_clock.count start) in + count := + if time <= 0. then + !count * 10 + else + !count * duration / int_of_float time ; + loop (n+1) + in + let id = loop 0 in + Format.fprintf ppf "%s%s\n%!" clean init ; + id + +let generate target = generate target diff --git a/src/lib_base/p2p_identity.mli b/src/lib_base/p2p_identity.mli new file mode 100644 index 000000000..9535ed84d --- /dev/null +++ b/src/lib_base/p2p_identity.mli @@ -0,0 +1,29 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = { + peer_id : P2p_peer.Id.t ; + public_key : Crypto_box.public_key ; + secret_key : Crypto_box.secret_key ; + proof_of_work_stamp : Crypto_box.nonce ; +} +(** Type of an identity, comprising a peer_id, a crypto keypair, and a + proof of work stamp with enough difficulty so that the network + accept this identity as genuine. *) + +val encoding : t Data_encoding.t + +val generate : Crypto_box.target -> t +(** [generate target] is a freshly minted identity whose proof of + work stamp difficulty is at least equal to [target]. *) + +val generate_with_animation : + Format.formatter -> Crypto_box.target -> t +(** [generate_with_animation ppf target] is a freshly minted identity + whose proof of work stamp difficulty is at least equal to [target]. *) diff --git a/src/lib_base/p2p_peer.ml b/src/lib_base/p2p_peer.ml new file mode 100644 index 000000000..3b23ad8c5 --- /dev/null +++ b/src/lib_base/p2p_peer.ml @@ -0,0 +1,339 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Error_monad + +module Id = Tezos_crypto.Crypto_box.Public_key_hash + +module Table = Id.Table +module Map = Id.Map +module Set = Id.Set + +module State = struct + + type t = + | Accepted + | Running + | Disconnected + + let pp_digram ppf = function + | Accepted -> Format.fprintf ppf "⚎" + | Running -> Format.fprintf ppf "⚌" + | Disconnected -> Format.fprintf ppf "⚏" + + let encoding = + let open Data_encoding in + string_enum [ + "accepted", Accepted ; + "running", Running ; + "disconnected", Disconnected ; + ] + +end + +module Info = struct + + type t = { + score : float ; + trusted : bool ; + state : State.t ; + id_point : P2p_connection.Id.t option ; + stat : P2p_stat.t ; + last_failed_connection : (P2p_connection.Id.t * Time.t) option ; + last_rejected_connection : (P2p_connection.Id.t * Time.t) option ; + last_established_connection : (P2p_connection.Id.t * Time.t) option ; + last_disconnection : (P2p_connection.Id.t * Time.t) option ; + last_seen : (P2p_connection.Id.t * Time.t) option ; + last_miss : (P2p_connection.Id.t * Time.t) option ; + } + + let encoding = + let open Data_encoding in + conv + (fun ( + { score ; trusted ; state ; id_point ; stat ; + last_failed_connection ; last_rejected_connection ; + last_established_connection ; last_disconnection ; + last_seen ; last_miss }) -> + ((score, trusted, state, id_point, stat), + (last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection, + last_seen, last_miss))) + (fun ((score, trusted, state, id_point, stat), + (last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection, + last_seen, last_miss)) -> + { score ; trusted ; state ; id_point ; stat ; + last_failed_connection ; last_rejected_connection ; + last_established_connection ; last_disconnection ; + last_seen ; last_miss }) + (merge_objs + (obj5 + (req "score" float) + (req "trusted" bool) + (req "state" State.encoding) + (opt "reachable_at" P2p_connection.Id.encoding) + (req "stat" P2p_stat.encoding)) + (obj6 + (opt "last_failed_connection" (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_rejected_connection" (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_established_connection" (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_disconnection" (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_seen" (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_miss" (tup2 P2p_connection.Id.encoding Time.encoding)))) + +end + +module Event = struct + + type kind = + | Accepting_request + | Rejecting_request + | Request_rejected + | Connection_established + | Disconnection + | External_disconnection + + let kind_encoding = + Data_encoding.string_enum [ + "incoming_request", Accepting_request ; + "rejecting_request", Rejecting_request ; + "request_rejected", Request_rejected ; + "connection_established", Connection_established ; + "disconnection", Disconnection ; + "external_disconnection", External_disconnection ; + ] + + type t = { + kind : kind ; + timestamp : Time.t ; + point : P2p_connection.Id.t ; + } + + let encoding = + let open Data_encoding in + conv + (fun { kind ; timestamp ; point = (addr, port) } -> + (kind, timestamp, addr, port)) + (fun (kind, timestamp, addr, port) -> + { kind ; timestamp ; point = (addr, port) }) + (obj4 + (req "kind" kind_encoding) + (req "timestamp" Time.encoding) + (req "addr" P2p_addr.encoding) + (opt "port" int16)) + +end + +module Pool_info = struct + + type 'data state = + | Accepted of { current_point: P2p_connection.Id.t ; + cancel: Lwt_canceler.t } + | Running of { data: 'data ; + current_point: P2p_connection.Id.t } + | Disconnected + + type ('conn, 'meta) t = { + peer_id : Id.t ; + created : Time.t ; + mutable state : 'conn state ; + mutable metadata : 'meta ; + mutable trusted : bool ; + mutable last_failed_connection : (P2p_connection.Id.t * Time.t) option ; + mutable last_rejected_connection : (P2p_connection.Id.t * Time.t) option ; + mutable last_established_connection : (P2p_connection.Id.t * Time.t) option ; + mutable last_disconnection : (P2p_connection.Id.t * Time.t) option ; + events : Event.t Ring.t ; + watchers : Event.t Lwt_watcher.input ; + } + type ('conn, 'meta) peer_info = ('conn, 'meta) t + + let compare gi1 gi2 = Id.compare gi1.peer_id gi2.peer_id + + let log_size = 100 + + let create ?(created = Time.now ()) ?(trusted = false) ~metadata peer_id = + { peer_id ; + created ; + state = Disconnected ; + metadata ; + trusted ; + last_failed_connection = None ; + last_rejected_connection = None ; + last_established_connection = None ; + last_disconnection = None ; + events = Ring.create log_size ; + watchers = Lwt_watcher.create_input () ; + } + + let encoding metadata_encoding = + let open Data_encoding in + conv + (fun { peer_id ; trusted ; metadata ; events ; created ; + last_failed_connection ; last_rejected_connection ; + last_established_connection ; last_disconnection ; _ } -> + (peer_id, created, trusted, metadata, Ring.elements events, + last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection)) + (fun (peer_id, created, trusted, metadata, event_list, + last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection) -> + let info = create ~trusted ~metadata peer_id in + let events = Ring.create log_size in + Ring.add_list info.events event_list ; + { state = Disconnected ; + trusted ; peer_id ; metadata ; created ; + last_failed_connection ; + last_rejected_connection ; + last_established_connection ; + last_disconnection ; + events ; + watchers = Lwt_watcher.create_input () ; + }) + (obj9 + (req "peer_id" Id.encoding) + (req "created" Time.encoding) + (dft "trusted" bool false) + (req "metadata" metadata_encoding) + (dft "events" (list Event.encoding) []) + (opt "last_failed_connection" + (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_rejected_connection" + (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_established_connection" + (tup2 P2p_connection.Id.encoding Time.encoding)) + (opt "last_disconnection" + (tup2 P2p_connection.Id.encoding Time.encoding))) + + let peer_id { peer_id ; _ } = peer_id + let created { created ; _ } = created + let metadata { metadata ; _ } = metadata + let set_metadata gi metadata = gi.metadata <- metadata + let trusted { trusted ; _ } = trusted + let set_trusted gi = gi.trusted <- true + let unset_trusted gi = gi.trusted <- false + let last_established_connection s = s.last_established_connection + let last_disconnection s = s.last_disconnection + let last_failed_connection s = s.last_failed_connection + let last_rejected_connection s = s.last_rejected_connection + + let last_seen s = + Time.recent + s.last_established_connection + (Time.recent s.last_rejected_connection s.last_disconnection) + let last_miss s = + Time.recent + s.last_failed_connection + (Time.recent s.last_rejected_connection s.last_disconnection) + + let log { events ; watchers ; _ } ?(timestamp = Time.now ()) point kind = + let event = { Event.kind ; timestamp ; point } in + Ring.add events event ; + Lwt_watcher.notify watchers event + + let log_incoming_rejection ?timestamp peer_info point = + log peer_info ?timestamp point Rejecting_request + + module File = struct + + let load path metadata_encoding = + let enc = Data_encoding.list (encoding metadata_encoding) in + if path <> "/dev/null" && Sys.file_exists path then + Data_encoding_ezjsonm.read_file path >>=? fun json -> + return (Data_encoding.Json.destruct enc json) + else + return [] + + let save path metadata_encoding peers = + let open Data_encoding in + Data_encoding_ezjsonm.write_file path @@ + Json.construct (list (encoding metadata_encoding)) peers + + end + +end + +module Pool_event = struct + include Event + let watch { Pool_info.watchers ; _ } = Lwt_watcher.create_stream watchers + let fold { Pool_info.events ; _ } ~init ~f = Ring.fold events ~init ~f +end + +module Pool_state = struct + + type 'data t = 'data Pool_info.state = + | Accepted of { current_point: P2p_connection.Id.t ; + cancel: Lwt_canceler.t } + | Running of { data: 'data ; + current_point: P2p_connection.Id.t } + | Disconnected + type 'data state = 'data t + + let pp ppf = function + | Accepted { current_point ; _ } -> + Format.fprintf ppf "accepted %a" P2p_connection.Id.pp current_point + | Running { current_point ; _ } -> + Format.fprintf ppf "running %a" P2p_connection.Id.pp current_point + | Disconnected -> + Format.fprintf ppf "disconnected" + + let get { Pool_info.state ; _ } = state + + let is_disconnected { Pool_info.state ; _ } = + match state with + | Disconnected -> true + | Accepted _ | Running _ -> false + + let set_accepted + ?(timestamp = Time.now ()) + peer_info current_point cancel = + assert begin + match peer_info.Pool_info.state with + | Accepted _ | Running _ -> false + | Disconnected -> true + end ; + peer_info.state <- Accepted { current_point ; cancel } ; + Pool_info.log peer_info ~timestamp current_point Accepting_request + + let set_running + ?(timestamp = Time.now ()) + peer_info point data = + assert begin + match peer_info.Pool_info.state with + | Disconnected -> true (* request to unknown peer_id. *) + | Running _ -> false + | Accepted { current_point ; _ } -> + P2p_connection.Id.equal point current_point + end ; + peer_info.state <- Running { data ; current_point = point } ; + peer_info.last_established_connection <- Some (point, timestamp) ; + Pool_info.log peer_info ~timestamp point Connection_established + + let set_disconnected + ?(timestamp = Time.now ()) ?(requested = false) peer_info = + let current_point, (event : Event.kind) = + match peer_info.Pool_info.state with + | Accepted { current_point ; _ } -> + peer_info.last_rejected_connection <- + Some (current_point, timestamp) ; + current_point, Request_rejected + | Running { current_point ; _ } -> + peer_info.last_disconnection <- + Some (current_point, timestamp) ; + current_point, + if requested then Disconnection else External_disconnection + | Disconnected -> assert false + in + peer_info.state <- Disconnected ; + Pool_info.log peer_info ~timestamp current_point event + + + +end diff --git a/src/lib_base/p2p_peer.mli b/src/lib_base/p2p_peer.mli new file mode 100644 index 000000000..c072f4012 --- /dev/null +++ b/src/lib_base/p2p_peer.mli @@ -0,0 +1,184 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Error_monad + +module Id = Tezos_crypto.Crypto_box.Public_key_hash + +module Map = Id.Map +module Set = Id.Set +module Table = Id.Table + +module State : sig + + type t = + | Accepted + | Running + | Disconnected + + val pp_digram : Format.formatter -> t -> unit + val encoding : t Data_encoding.t + +end + +module Info : sig + + type t = { + score : float ; + trusted : bool ; + state : State.t ; + id_point : P2p_connection.Id.t option ; + stat : P2p_stat.t ; + last_failed_connection : (P2p_connection.Id.t * Time.t) option ; + last_rejected_connection : (P2p_connection.Id.t * Time.t) option ; + last_established_connection : (P2p_connection.Id.t * Time.t) option ; + last_disconnection : (P2p_connection.Id.t * Time.t) option ; + last_seen : (P2p_connection.Id.t * Time.t) option ; + last_miss : (P2p_connection.Id.t * Time.t) option ; + } + + val encoding : t Data_encoding.t + +end + +(** P2p_peer.Id info: current and historical information about a peer_id *) + +module Pool_info : sig + + type ('conn, 'meta) t + type ('conn, 'meta) peer_info = ('conn, 'meta) t + + val compare : ('conn, 'meta) t -> ('conn, 'meta) t -> int + + val create : + ?created:Time.t -> + ?trusted:bool -> + metadata:'meta -> + Id.t -> ('conn, 'meta) peer_info + (** [create ~trusted ~meta peer_id] is a freshly minted peer_id info for + [peer_id]. *) + + val peer_id : ('conn, 'meta) peer_info -> Id.t + + val created : ('conn, 'meta) peer_info -> Time.t + val metadata : ('conn, 'meta) peer_info -> 'meta + val set_metadata : ('conn, 'meta) peer_info -> 'meta -> unit + + val trusted : ('conn, 'meta) peer_info -> bool + val set_trusted : ('conn, 'meta) peer_info -> unit + val unset_trusted : ('conn, 'meta) peer_info -> unit + + val last_failed_connection : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + val last_rejected_connection : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + val last_established_connection : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + val last_disconnection : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + + val last_seen : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + (** [last_seen gi] is the most recent of: + + * last established connection + * last rejected connection + * last disconnection + *) + + val last_miss : + ('conn, 'meta) peer_info -> (P2p_connection.Id.t * Time.t) option + (** [last_miss gi] is the most recent of: + + * last failed connection + * last rejected connection + * last disconnection + *) + + val log_incoming_rejection : + ?timestamp:Time.t -> + ('conn, 'meta) peer_info -> P2p_connection.Id.t -> unit + + module File : sig + val load : + string -> 'meta Data_encoding.t -> + ('conn, 'meta) peer_info list tzresult Lwt.t + val save : + string -> 'meta Data_encoding.t -> + ('conn, 'meta) peer_info list -> unit tzresult Lwt.t + end + +end + +module Pool_state : sig + + type 'conn t = + | Accepted of { current_point: P2p_connection.Id.t ; + cancel: Lwt_canceler.t } + (** We accepted a incoming connection, we greeted back and + we are waiting for an acknowledgement. *) + | Running of { data: 'conn ; + current_point: P2p_connection.Id.t } + (** Successfully authentificated connection, normal business. *) + | Disconnected + (** No connection established currently. *) + type 'conn state = 'conn t + + val pp : Format.formatter -> 'conn t -> unit + + val get : ('conn, 'meta) Pool_info.t -> 'conn state + + val is_disconnected : ('conn, 'meta) Pool_info.t -> bool + + val set_accepted : + ?timestamp:Time.t -> + ('conn, 'meta) Pool_info.t -> P2p_connection.Id.t -> Lwt_canceler.t -> unit + + val set_running : + ?timestamp:Time.t -> + ('conn, 'meta) Pool_info.t -> P2p_connection.Id.t -> 'conn -> unit + + val set_disconnected : + ?timestamp:Time.t -> + ?requested:bool -> + ('conn, 'meta) Pool_info.t -> unit + +end + +module Pool_event : sig + + type kind = + | Accepting_request + (** We accepted a connection after authentifying the remote peer. *) + | Rejecting_request + (** We rejected a connection after authentifying the remote peer. *) + | Request_rejected + (** The remote peer rejected our connection. *) + | Connection_established + (** We succesfully established a authentified connection. *) + | Disconnection + (** We decided to close the connection. *) + | External_disconnection + (** The connection was closed for external reason. *) + + type t = { + kind : kind ; + timestamp : Time.t ; + point : P2p_connection.Id.t ; + } + + val encoding : t Data_encoding.t + + val fold : + ('conn, 'meta) Pool_info.t -> init:'a -> f:('a -> t -> 'a) -> 'a + + val watch : + ('conn, 'meta) Pool_info.t -> t Lwt_stream.t * Lwt_watcher.stopper + +end diff --git a/src/lib_base/p2p_point.ml b/src/lib_base/p2p_point.ml new file mode 100644 index 000000000..d63969313 --- /dev/null +++ b/src/lib_base/p2p_point.ml @@ -0,0 +1,477 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type peer_id = Crypto_box.Public_key_hash.t +let peer_id_encoding = Crypto_box.Public_key_hash.encoding +let peer_id_pp = Crypto_box.Public_key_hash.pp +let peer_id_equal = Crypto_box.Public_key_hash.equal + +module Id = struct + + (* A net point (address x port). *) + type t = P2p_addr.t * P2p_addr.port + let compare (a1, p1) (a2, p2) = + match Ipaddr.V6.compare a1 a2 with + | 0 -> p1 - p2 + | x -> x + let equal p1 p2 = compare p1 p2 = 0 + let hash = Hashtbl.hash + let pp ppf (addr, port) = + match Ipaddr.v4_of_v6 addr with + | Some addr -> + Format.fprintf ppf "%a:%d" Ipaddr.V4.pp_hum addr port + | None -> + Format.fprintf ppf "[%a]:%d" Ipaddr.V6.pp_hum addr port + let pp_opt ppf = function + | None -> Format.pp_print_string ppf "none" + | Some point -> pp ppf point + + let is_local (addr, _) = Ipaddr.V6.is_private addr + let is_global (addr, _) = not @@ Ipaddr.V6.is_private addr + + let check_port port = + if TzString.mem_char port '[' || + TzString.mem_char port ']' || + TzString.mem_char port ':' then + invalid_arg "Utils.parse_addr_port (invalid character in port)" + + let parse_addr_port s = + let len = String.length s in + if len = 0 then + ("", "") + else if s.[0] = '[' then begin (* inline IPv6 *) + match String.rindex s ']' with + | exception Not_found -> + invalid_arg "Utils.parse_addr_port (missing ']')" + | pos -> + let addr = String.sub s 1 (pos - 1) in + let port = + if pos = len - 1 then + "" + else if s.[pos+1] <> ':' then + invalid_arg "Utils.parse_addr_port (unexpected char after ']')" + else + String.sub s (pos + 2) (len - pos - 2) in + check_port port ; + addr, port + end else begin + match String.rindex s ']' with + | _pos -> + invalid_arg "Utils.parse_addr_port (unexpected char ']')" + | exception Not_found -> + match String.index s ':' with + | exception _ -> s, "" + | pos -> + match String.index_from s (pos+1) ':' with + | exception _ -> + let addr = String.sub s 0 pos in + let port = String.sub s (pos + 1) (len - pos - 1) in + check_port port ; + addr, port + | _pos -> + invalid_arg "Utils.parse_addr_port: IPv6 addresses must be bracketed" + end + + let of_string_exn str = + let addr, port = parse_addr_port str in + let port = int_of_string port in + if port < 0 && port > 1 lsl 16 - 1 then + invalid_arg "port must be between 0 and 65535" ; + match Ipaddr.of_string_exn addr with + | V4 addr -> Ipaddr.v6_of_v4 addr, port + | V6 addr -> addr, port + + let of_string str = + try Ok (of_string_exn str) with + | Invalid_argument s -> Error s + | Failure s -> Error s + | _ -> Error "P2p_point.of_string" + + let to_string saddr = Format.asprintf "%a" pp saddr + + let encoding = + Data_encoding.conv to_string of_string_exn Data_encoding.string + +end + +module Map = Map.Make (Id) +module Set = Set.Make (Id) +module Table = Hashtbl.Make (Id) + +module State = struct + + type t = + | Requested + | Accepted of peer_id + | Running of peer_id + | Disconnected + + let of_peer_id = function + | Requested -> None + | Accepted pi -> Some pi + | Running pi -> Some pi + | Disconnected -> None + + let of_peerid_state state pi = + match state, pi with + | Requested, _ -> Requested + | Accepted _, Some pi -> Accepted pi + | Running _, Some pi -> Running pi + | Disconnected, _ -> Disconnected + | _ -> invalid_arg "state_of_state_peerid" + + let pp_digram ppf = function + | Requested -> Format.fprintf ppf "⚎" + | Accepted _ -> Format.fprintf ppf "⚍" + | Running _ -> Format.fprintf ppf "⚌" + | Disconnected -> Format.fprintf ppf "⚏" + + let encoding = + let open Data_encoding in + let branch_encoding name obj = + conv (fun x -> (), x) (fun ((), x) -> x) + (merge_objs + (obj1 (req "event_kind" (constant name))) obj) in + union ~tag_size:`Uint8 [ + case (Tag 0) (branch_encoding "requested" empty) + (function Requested -> Some () | _ -> None) + (fun () -> Requested) ; + case (Tag 1) (branch_encoding "accepted" + (obj1 (req "peer_id" peer_id_encoding))) + (function Accepted peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Accepted peer_id) ; + case (Tag 2) (branch_encoding "running" + (obj1 (req "peer_id" peer_id_encoding))) + (function Running peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Running peer_id) ; + case (Tag 3) (branch_encoding "disconnected" empty) + (function Disconnected -> Some () | _ -> None) + (fun () -> Disconnected) ; + ] + +end + +module Info = struct + + type t = { + trusted : bool ; + greylisted_until : Time.t ; + state : State.t ; + last_failed_connection : Time.t option ; + last_rejected_connection : (peer_id * Time.t) option ; + last_established_connection : (peer_id * Time.t) option ; + last_disconnection : (peer_id * Time.t) option ; + last_seen : (peer_id * Time.t) option ; + last_miss : Time.t option ; + } + + let encoding = + let open Data_encoding in + conv + (fun { trusted ; greylisted_until ; state ; + last_failed_connection ; last_rejected_connection ; + last_established_connection ; last_disconnection ; + last_seen ; last_miss } -> + let peer_id = State.of_peer_id state in + (trusted, greylisted_until, state, peer_id, + last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection, + last_seen, last_miss)) + (fun (trusted, greylisted_until, state, peer_id, + last_failed_connection, last_rejected_connection, + last_established_connection, last_disconnection, + last_seen, last_miss) -> + let state = State.of_peerid_state state peer_id in + { trusted ; greylisted_until ; state ; + last_failed_connection ; last_rejected_connection ; + last_established_connection ; last_disconnection ; + last_seen ; last_miss }) + (obj10 + (req "trusted" bool) + (dft "greylisted_until" Time.encoding Time.epoch) + (req "state" State.encoding) + (opt "peer_id" peer_id_encoding) + (opt "last_failed_connection" Time.encoding) + (opt "last_rejected_connection" (tup2 peer_id_encoding Time.encoding)) + (opt "last_established_connection" (tup2 peer_id_encoding Time.encoding)) + (opt "last_disconnection" (tup2 peer_id_encoding Time.encoding)) + (opt "last_seen" (tup2 peer_id_encoding Time.encoding)) + (opt "last_miss" Time.encoding)) + +end + +module Event = struct + + type kind = + | Outgoing_request + | Accepting_request of peer_id + | Rejecting_request of peer_id + | Request_rejected of peer_id option + | Connection_established of peer_id + | Disconnection of peer_id + | External_disconnection of peer_id + + let kind_encoding = + let open Data_encoding in + let branch_encoding name obj = + conv (fun x -> (), x) (fun ((), x) -> x) + (merge_objs + (obj1 (req "event_kind" (constant name))) obj) in + union ~tag_size:`Uint8 [ + case (Tag 0) (branch_encoding "outgoing_request" empty) + (function Outgoing_request -> Some () | _ -> None) + (fun () -> Outgoing_request) ; + case (Tag 1) (branch_encoding "accepting_request" + (obj1 (req "peer_id" peer_id_encoding))) + (function Accepting_request peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Accepting_request peer_id) ; + case (Tag 2) (branch_encoding "rejecting_request" + (obj1 (req "peer_id" peer_id_encoding))) + (function Rejecting_request peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Rejecting_request peer_id) ; + case (Tag 3) (branch_encoding "request_rejected" + (obj1 (opt "peer_id" peer_id_encoding))) + (function Request_rejected peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Request_rejected peer_id) ; + case (Tag 4) (branch_encoding "rejecting_request" + (obj1 (req "peer_id" peer_id_encoding))) + (function Connection_established peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Connection_established peer_id) ; + case (Tag 5) (branch_encoding "rejecting_request" + (obj1 (req "peer_id" peer_id_encoding))) + (function Disconnection peer_id -> Some peer_id | _ -> None) + (fun peer_id -> Disconnection peer_id) ; + case (Tag 6) (branch_encoding "rejecting_request" + (obj1 (req "peer_id" peer_id_encoding))) + (function External_disconnection peer_id -> Some peer_id | _ -> None) + (fun peer_id -> External_disconnection peer_id) ; + ] + + type t = { + kind : kind ; + timestamp : Time.t ; + } + + let encoding = + let open Data_encoding in + conv + (fun { kind ; timestamp ; } -> (kind, timestamp)) + (fun (kind, timestamp) -> { kind ; timestamp ; }) + (obj2 + (req "kind" kind_encoding) + (req "timestamp" Time.encoding)) +end + +module Pool_info = struct + + type 'data state = + | Requested of { cancel: Lwt_canceler.t } + | Accepted of { current_peer_id: peer_id ; + cancel: Lwt_canceler.t } + | Running of { data: 'data ; + current_peer_id: peer_id } + | Disconnected + + type greylisting_config = { + factor: float ; + initial_delay: int ; + disconnection_delay: int ; + } + + type 'data t = { + point : Id.t ; + mutable trusted : bool ; + mutable state : 'data state ; + mutable last_failed_connection : Time.t option ; + mutable last_rejected_connection : (peer_id * Time.t) option ; + mutable last_established_connection : (peer_id * Time.t) option ; + mutable last_disconnection : (peer_id * Time.t) option ; + greylisting : greylisting_config ; + mutable greylisting_delay : float ; + mutable greylisting_end : Time.t ; + events : Event.t Ring.t ; + watchers : Event.t Lwt_watcher.input ; + } + type 'data point_info = 'data t + + let compare pi1 pi2 = Id.compare pi1.point pi2.point + + let log_size = 100 + + let default_greylisting_config = { + factor = 1.2 ; + initial_delay = 1 ; + disconnection_delay = 60 ; + } + + let create + ?(trusted = false) + ?(greylisting_config = default_greylisting_config) addr port = { + point = (addr, port) ; + trusted ; + state = Disconnected ; + last_failed_connection = None ; + last_rejected_connection = None ; + last_established_connection = None ; + last_disconnection = None ; + events = Ring.create log_size ; + greylisting = greylisting_config ; + greylisting_delay = 1. ; + greylisting_end = Time.epoch ; + watchers = Lwt_watcher.create_input () ; + } + + let point s = s.point + let trusted s = s.trusted + let set_trusted gi = gi.trusted <- true + let unset_trusted gi = gi.trusted <- false + let last_established_connection s = s.last_established_connection + let last_disconnection s = s.last_disconnection + let last_failed_connection s = s.last_failed_connection + let last_rejected_connection s = s.last_rejected_connection + let greylisted ?(now = Time.now ()) s = + Time.compare now s.greylisting_end <= 0 + let greylisted_until s = s.greylisting_end + + let last_seen s = + Time.recent s.last_rejected_connection + (Time.recent s.last_established_connection s.last_disconnection) + let last_miss s = + match + s.last_failed_connection, + (Option.map ~f:(fun (_, time) -> time) @@ + Time.recent s.last_rejected_connection s.last_disconnection) with + | (None, None) -> None + | (None, (Some _ as a)) + | (Some _ as a, None) -> a + | (Some t1 as a1 , (Some t2 as a2)) -> + if Time.compare t1 t2 < 0 then a2 else a1 + + let log { events ; watchers ; _ } ?(timestamp = Time.now ()) kind = + let event = { Event.kind ; timestamp } in + Ring.add events event ; + Lwt_watcher.notify watchers event + + let log_incoming_rejection ?timestamp point_info peer_id = + log point_info ?timestamp (Rejecting_request peer_id) + +end + +module Pool_event = struct + + include Event + + let fold { Pool_info.events ; _ } ~init ~f = Ring.fold events ~init ~f + + let watch { Pool_info.watchers ; _ } = Lwt_watcher.create_stream watchers + +end + +module Pool_state = struct + + type 'data t = 'data Pool_info.state = + | Requested of { cancel: Lwt_canceler.t } + | Accepted of { current_peer_id: peer_id ; + cancel: Lwt_canceler.t } + | Running of { data: 'data ; + current_peer_id: peer_id } + | Disconnected + type 'data state = 'data t + + let pp ppf = function + | Requested _ -> + Format.fprintf ppf "requested" + | Accepted { current_peer_id ; _ } -> + Format.fprintf ppf "accepted %a" peer_id_pp current_peer_id + | Running { current_peer_id ; _ } -> + Format.fprintf ppf "running %a" peer_id_pp current_peer_id + | Disconnected -> + Format.fprintf ppf "disconnected" + + let get { Pool_info.state ; _ } = state + + let is_disconnected { Pool_info.state ; _ } = + match state with + | Disconnected -> true + | Requested _ | Accepted _ | Running _ -> false + + let set_requested ?timestamp point_info cancel = + assert begin + match point_info.Pool_info.state with + | Requested _ -> true + | Accepted _ | Running _ -> false + | Disconnected -> true + end ; + point_info.state <- Requested { cancel } ; + Pool_info.log point_info ?timestamp Outgoing_request + + let set_accepted + ?(timestamp = Time.now ()) + point_info current_peer_id cancel = + (* log_notice "SET_ACCEPTED %a@." P2p_point.pp point_info.point ; *) + assert begin + match point_info.Pool_info.state with + | Accepted _ | Running _ -> false + | Requested _ | Disconnected -> true + end ; + point_info.state <- Accepted { current_peer_id ; cancel } ; + Pool_info.log point_info ~timestamp (Accepting_request current_peer_id) + + let set_running + ?(timestamp = Time.now ()) + point_info peer_id data = + assert begin + match point_info.Pool_info.state with + | Disconnected -> true (* request to unknown peer_id. *) + | Running _ -> false + | Accepted { current_peer_id ; _ } -> peer_id_equal peer_id current_peer_id + | Requested _ -> true + end ; + point_info.state <- Running { data ; current_peer_id = peer_id } ; + point_info.last_established_connection <- Some (peer_id, timestamp) ; + Pool_info.log point_info ~timestamp (Connection_established peer_id) + + let set_greylisted timestamp point_info = + point_info.Pool_info.greylisting_end <- + Time.add + timestamp + (Int64.of_float point_info.Pool_info.greylisting_delay) ; + point_info.greylisting_delay <- + point_info.greylisting_delay *. point_info.greylisting.factor + + let set_disconnected + ?(timestamp = Time.now ()) ?(requested = false) point_info = + let event : Event.kind = + match point_info.Pool_info.state with + | Requested _ -> + set_greylisted timestamp point_info ; + point_info.last_failed_connection <- Some timestamp ; + Request_rejected None + | Accepted { current_peer_id ; _ } -> + set_greylisted timestamp point_info ; + point_info.last_rejected_connection <- + Some (current_peer_id, timestamp) ; + Request_rejected (Some current_peer_id) + | Running { current_peer_id ; _ } -> + point_info.greylisting_delay <- + float_of_int point_info.greylisting.initial_delay ; + point_info.greylisting_end <- + Time.add timestamp + (Int64.of_int point_info.greylisting.disconnection_delay) ; + point_info.last_disconnection <- Some (current_peer_id, timestamp) ; + if requested + then Disconnection current_peer_id + else External_disconnection current_peer_id + | Disconnected -> + assert false + in + point_info.state <- Disconnected ; + Pool_info.log point_info ~timestamp event + +end diff --git a/src/lib_base/p2p_point.mli b/src/lib_base/p2p_point.mli new file mode 100644 index 000000000..3187a1251 --- /dev/null +++ b/src/lib_base/p2p_point.mli @@ -0,0 +1,207 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type peer_id = Crypto_box.Public_key_hash.t +(* = P2p_peer.Id.t, but we should break cycles *) + +module Id : sig + + type t = P2p_addr.t * P2p_addr.port + val compare : t -> t -> int + + val pp : Format.formatter -> t -> unit + val pp_opt : Format.formatter -> t option -> unit + + val of_string_exn : string -> t + val of_string : string -> (t, string) result + val to_string : t -> string + val encoding : t Data_encoding.t + val is_local : t -> bool + val is_global : t -> bool + val parse_addr_port : string -> string * string + +end + +module Map : Map.S with type key = Id.t +module Set : Set.S with type elt = Id.t +module Table : Hashtbl.S with type key = Id.t + +module State : sig + + type t = + | Requested + | Accepted of peer_id + | Running of peer_id + | Disconnected + + val pp_digram : Format.formatter -> t -> unit + val encoding : t Data_encoding.t + + val of_peer_id : t -> peer_id option + val of_peerid_state : t -> peer_id option -> t + +end + +module Info : sig + + type t = { + trusted : bool ; + greylisted_until : Time.t ; + state : State.t ; + last_failed_connection : Time.t option ; + last_rejected_connection : (peer_id * Time.t) option ; + last_established_connection : (peer_id * Time.t) option ; + last_disconnection : (peer_id * Time.t) option ; + last_seen : (peer_id * Time.t) option ; + last_miss : Time.t option ; + } + + val encoding: t Data_encoding.t + +end + +module Pool_info : sig + + type 'conn t + type 'conn point_info = 'conn t + (** Type of info associated to a point. *) + + val compare : 'conn point_info -> 'conn point_info -> int + + type greylisting_config = { + factor: float ; + initial_delay: int ; + disconnection_delay: int ; + } + + val create : + ?trusted:bool -> + ?greylisting_config:greylisting_config -> + P2p_addr.t -> P2p_addr.port -> 'conn point_info + (** [create ~trusted addr port] is a freshly minted point_info. If + [trusted] is true, this point is considered trusted and will + be treated as such. *) + + val trusted : 'conn point_info -> bool + (** [trusted pi] is [true] iff [pi] has is trusted, + i.e. "whitelisted". *) + + val set_trusted : 'conn point_info -> unit + val unset_trusted : 'conn point_info -> unit + + val last_failed_connection : + 'conn point_info -> Time.t option + val last_rejected_connection : + 'conn point_info -> (peer_id * Time.t) option + val last_established_connection : + 'conn point_info -> (peer_id * Time.t) option + val last_disconnection : + 'conn point_info -> (peer_id * Time.t) option + + val last_seen : + 'conn point_info -> (peer_id * Time.t) option + (** [last_seen pi] is the most recent of: + + * last established connection + * last rejected connection + * last disconnection + *) + + val last_miss : + 'conn point_info -> Time.t option + (** [last_miss pi] is the most recent of: + + * last failed connection + * last rejected connection + * last disconnection + *) + + val greylisted : + ?now:Time.t -> 'conn point_info -> bool + + val greylisted_until : 'conn point_info -> Time.t + + val point : 'conn point_info -> Id.t + + val log_incoming_rejection : + ?timestamp:Time.t -> 'conn point_info -> peer_id -> unit + +end + +module Pool_state : sig + + type 'conn t = + | Requested of { cancel: Lwt_canceler.t } + (** We initiated a connection. *) + | Accepted of { current_peer_id: peer_id ; + cancel: Lwt_canceler.t } + (** We accepted a incoming connection. *) + | Running of { data: 'conn ; + current_peer_id: peer_id } + (** Successfully authentificated connection, normal business. *) + | Disconnected + (** No connection established currently. *) + type 'conn state = 'conn t + + val pp : Format.formatter -> 'conn t -> unit + + val get : 'conn Pool_info.t -> 'conn state + + val is_disconnected : 'conn Pool_info.t -> bool + + val set_requested : + ?timestamp:Time.t -> + 'conn Pool_info.t -> Lwt_canceler.t -> unit + + val set_accepted : + ?timestamp:Time.t -> + 'conn Pool_info.t -> peer_id -> Lwt_canceler.t -> unit + + val set_running : + ?timestamp:Time.t -> 'conn Pool_info.t -> peer_id -> 'conn -> unit + + val set_disconnected : + ?timestamp:Time.t -> ?requested:bool -> 'conn Pool_info.t -> unit + +end + +module Pool_event : sig + + type kind = + | Outgoing_request + (** We initiated a connection. *) + | Accepting_request of peer_id + (** We accepted a connection after authentifying the remote peer. *) + | Rejecting_request of peer_id + (** We rejected a connection after authentifying the remote peer. *) + | Request_rejected of peer_id option + (** The remote peer rejected our connection. *) + | Connection_established of peer_id + (** We succesfully established a authentified connection. *) + | Disconnection of peer_id + (** We decided to close the connection. *) + | External_disconnection of peer_id + (** The connection was closed for external reason. *) + + type t = { + kind : kind ; + timestamp : Time.t ; + } + + val encoding : t Data_encoding.t + + val fold : + 'conn Pool_info.t -> init:'a -> f:('a -> t -> 'a) -> 'a + + val watch : + 'conn Pool_info.t -> t Lwt_stream.t * Lwt_watcher.stopper + +end + + diff --git a/src/lib_base/p2p_stat.ml b/src/lib_base/p2p_stat.ml new file mode 100644 index 000000000..576eaca25 --- /dev/null +++ b/src/lib_base/p2p_stat.ml @@ -0,0 +1,64 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = { + total_sent : int64 ; + total_recv : int64 ; + current_inflow : int ; + current_outflow : int ; +} + +let empty = { + total_sent = 0L ; + total_recv = 0L ; + current_inflow = 0 ; + current_outflow = 0 ; +} + +let print_size ppf sz = + let ratio n = (float_of_int sz /. float_of_int (1 lsl n)) in + if sz < 1 lsl 10 then + Format.fprintf ppf "%d B" sz + else if sz < 1 lsl 20 then + Format.fprintf ppf "%.2f kiB" (ratio 10) + else + Format.fprintf ppf "%.2f MiB" (ratio 20) + +let print_size64 ppf sz = + let open Int64 in + let ratio n = (to_float sz /. float_of_int (1 lsl n)) in + if sz < shift_left 1L 10 then + Format.fprintf ppf "%Ld B" sz + else if sz < shift_left 1L 20 then + Format.fprintf ppf "%.2f kiB" (ratio 10) + else if sz < shift_left 1L 30 then + Format.fprintf ppf "%.2f MiB" (ratio 20) + else if sz < shift_left 1L 40 then + Format.fprintf ppf "%.2f GiB" (ratio 30) + else + Format.fprintf ppf "%.2f TiB" (ratio 40) + +let pp ppf stat = + Format.fprintf ppf + "↗ %a (%a/s) ↘ %a (%a/s)" + print_size64 stat.total_sent print_size stat.current_outflow + print_size64 stat.total_recv print_size stat.current_inflow + +let encoding = + let open Data_encoding in + conv + (fun { total_sent ; total_recv ; current_inflow ; current_outflow } -> + (total_sent, total_recv, current_inflow, current_outflow)) + (fun (total_sent, total_recv, current_inflow, current_outflow) -> + { total_sent ; total_recv ; current_inflow ; current_outflow }) + (obj4 + (req "total_sent" int64) + (req "total_recv" int64) + (req "current_inflow" int31) + (req "current_outflow" int31)) diff --git a/src/lib_base/p2p_stat.mli b/src/lib_base/p2p_stat.mli new file mode 100644 index 000000000..e4cfa3a96 --- /dev/null +++ b/src/lib_base/p2p_stat.mli @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Bandwidth usage statistics *) + +type t = { + total_sent : int64 ; + total_recv : int64 ; + current_inflow : int ; + current_outflow : int ; +} + +val empty : t +val pp : Format.formatter -> t -> unit +val encoding : t Data_encoding.t diff --git a/src/lib_base/p2p_version.ml b/src/lib_base/p2p_version.ml new file mode 100644 index 000000000..e026e93fc --- /dev/null +++ b/src/lib_base/p2p_version.ml @@ -0,0 +1,40 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = { + name : string ; + major : int ; + minor : int ; +} + +let pp ppf { name ; major ; minor } = + Format.fprintf ppf "%s.%d.%d" name major minor + +let encoding = + let open Data_encoding in + conv + (fun { name; major; minor } -> (name, major, minor)) + (fun (name, major, minor) -> { name; major; minor }) + (obj3 + (req "name" string) + (req "major" int8) + (req "minor" int8)) + +(* the common version for a pair of peers, if any, is the maximum one, + in lexicographic order *) +let common la lb = + let la = List.sort (fun l r -> compare r l) la in + let lb = List.sort (fun l r -> compare r l) lb in + let rec find = function + | [], _ | _, [] -> None + | ((a :: ta) as la), ((b :: tb) as lb) -> + if a = b then Some a + else if a < b then find (ta, lb) + else find (la, tb) + in find (la, lb) diff --git a/src/lib_base/p2p_version.mli b/src/lib_base/p2p_version.mli new file mode 100644 index 000000000..b6be2eaf8 --- /dev/null +++ b/src/lib_base/p2p_version.mli @@ -0,0 +1,22 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Protocol version *) + +type t = { + name : string ; + major : int ; + minor : int ; +} +(** Type of a protocol version. *) + +val pp : Format.formatter -> t -> unit +val encoding : t Data_encoding.t +val common : t list -> t list -> t option + diff --git a/src/lib_base/time.ml b/src/lib_base/time.ml index e4fcb01d3..f977e8982 100644 --- a/src/lib_base/time.ml +++ b/src/lib_base/time.ml @@ -24,6 +24,14 @@ module T = struct let incr_sign = res >= a in if sign = incr_sign then res else invalid_arg "Time.add" ;; + let recent a1 a2 = + match a1, a2 with + | (None, None) -> None + | (None, (Some _ as a)) + | (Some _ as a, None) -> a + | (Some (_, t1), Some (_, t2)) -> + if compare t1 t2 < 0 then a2 else a1 + let hash = to_int let (=) = equal let (<>) x y = compare x y <> 0 diff --git a/src/lib_base/time.mli b/src/lib_base/time.mli index faab7adfe..a87cec611 100644 --- a/src/lib_base/time.mli +++ b/src/lib_base/time.mli @@ -56,3 +56,6 @@ val timed_encoding : 'a Data_encoding.t -> 'a timed_data Data_encoding.t module Set : Set.S with type elt = t module Map : Map.S with type key = t module Table : Hashtbl.S with type key = t + +val recent : + ('a * t) option -> ('a * t) option -> ('a * t) option diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index efdda403b..dd5469a2d 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -44,5 +44,13 @@ module Preapply_result = Preapply_result module Block_locator = Block_locator module Mempool = Mempool +module P2p_addr = P2p_addr +module P2p_identity = P2p_identity +module P2p_peer = P2p_peer +module P2p_point = P2p_point +module P2p_connection = P2p_connection +module P2p_stat = P2p_stat +module P2p_version = P2p_version + include Utils.Infix include Error_monad diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index 64e023a39..60ea6f4dc 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -42,5 +42,13 @@ module Operation_list_list_hash = Operation_list_list_hash module Context_hash = Context_hash module Protocol_hash = Protocol_hash +module P2p_addr = P2p_addr +module P2p_identity = P2p_identity +module P2p_peer = P2p_peer +module P2p_point = P2p_point +module P2p_connection = P2p_connection +module P2p_stat = P2p_stat +module P2p_version = P2p_version + include (module type of (struct include Utils.Infix end)) include (module type of (struct include Error_monad end)) diff --git a/src/lib_client_base/client_network.ml b/src/lib_client_base/client_network.ml index bb4e04fdd..954176075 100644 --- a/src/lib_client_base/client_network.ml +++ b/src/lib_client_base/client_network.ml @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open P2p_types - let group = { Cli_entries.name = "network" ; title = "Commands for monitoring and controlling network state" } @@ -23,47 +21,47 @@ let commands () = [ Client_node_rpcs.Network.peers cctxt >>=? fun peers -> Client_node_rpcs.Network.points cctxt >>=? fun points -> cctxt#message "GLOBAL STATS" >>= fun () -> - cctxt#message " %a" Stat.pp stat >>= fun () -> + cctxt#message " %a" P2p_stat.pp stat >>= fun () -> cctxt#message "CONNECTIONS" >>= fun () -> let incoming, outgoing = - List.partition (fun c -> c.Connection_info.incoming) conns in + List.partition (fun c -> c.P2p_connection.Info.incoming) conns in Lwt_list.iter_s begin fun conn -> - cctxt#message " %a" Connection_info.pp conn + cctxt#message " %a" P2p_connection.Info.pp conn end incoming >>= fun () -> Lwt_list.iter_s begin fun conn -> - cctxt#message " %a" Connection_info.pp conn + cctxt#message " %a" P2p_connection.Info.pp conn end outgoing >>= fun () -> cctxt#message "KNOWN PEERS" >>= fun () -> Lwt_list.iter_s begin fun (p, pi) -> cctxt#message " %a %.0f %a %a %s" - Peer_state.pp_digram pi.Peer_info.state + P2p_peer.State.pp_digram pi.P2p_peer.Info.state pi.score - Peer_id.pp p - Stat.pp pi.stat + P2p_peer.Id.pp p + P2p_stat.pp pi.stat (if pi.trusted then "★" else " ") end peers >>= fun () -> cctxt#message "KNOWN POINTS" >>= fun () -> Lwt_list.iter_s begin fun (p, pi) -> - match pi.Point_info.state with + match pi.P2p_point.Info.state with | Running peer_id -> cctxt#message " %a %a %a %s" - Point_state.pp_digram pi.state - Point.pp p - Peer_id.pp peer_id + P2p_point.State.pp_digram pi.state + P2p_point.Id.pp p + P2p_peer.Id.pp peer_id (if pi.trusted then "★" else " ") | _ -> match pi.last_seen with | Some (peer_id, ts) -> cctxt#message " %a %a (last seen: %a %a) %s" - Point_state.pp_digram pi.state - Point.pp p - Peer_id.pp peer_id + P2p_point.State.pp_digram pi.state + P2p_point.Id.pp p + P2p_peer.Id.pp peer_id Time.pp_hum ts (if pi.trusted then "★" else " ") | None -> cctxt#message " %a %a %s" - Point_state.pp_digram pi.state - Point.pp p + P2p_point.State.pp_digram pi.state + P2p_point.Id.pp p (if pi.trusted then "★" else " ") end points >>= fun () -> return () diff --git a/src/lib_client_base/client_node_rpcs.mli b/src/lib_client_base/client_node_rpcs.mli index 994c77a3b..c9699fce6 100644 --- a/src/lib_client_base/client_node_rpcs.mli +++ b/src/lib_client_base/client_node_rpcs.mli @@ -155,19 +155,17 @@ val bootstrapped: module Network : sig - open P2p_types - val stat: - #Client_rpcs.ctxt -> Stat.t tzresult Lwt.t + #Client_rpcs.ctxt -> P2p_stat.t tzresult Lwt.t val connections: - #Client_rpcs.ctxt -> Connection_info.t list tzresult Lwt.t + #Client_rpcs.ctxt -> P2p_connection.Info.t list tzresult Lwt.t val peers: - #Client_rpcs.ctxt -> (Peer_id.t * P2p_types.Peer_info.t) list tzresult Lwt.t + #Client_rpcs.ctxt -> (P2p_peer.Id.t * P2p_peer.Info.t) list tzresult Lwt.t val points: - #Client_rpcs.ctxt -> (Point.t * P2p_types.Point_info.t) list tzresult Lwt.t + #Client_rpcs.ctxt -> (P2p_point.Id.t * P2p_point.Info.t) list tzresult Lwt.t end diff --git a/src/lib_p2p/p2p.ml b/src/lib_p2p/p2p.ml index 7a06d6c92..1c4c23484 100644 --- a/src/lib_p2p/p2p.ml +++ b/src/lib_p2p/p2p.ml @@ -7,17 +7,15 @@ (* *) (**************************************************************************) -include P2p_types - include Logging.Make(struct let name = "p2p" end) -type 'meta meta_config = 'meta P2p_connection_pool.meta_config = { +type 'meta meta_config = 'meta P2p_pool.meta_config = { encoding : 'meta Data_encoding.t; initial : 'meta; score : 'meta -> float } -type 'msg app_message_encoding = 'msg P2p_connection_pool.encoding = +type 'msg app_message_encoding = 'msg P2p_pool.encoding = Encoding : { tag: int ; encoding: 'a Data_encoding.t ; @@ -26,18 +24,18 @@ type 'msg app_message_encoding = 'msg P2p_connection_pool.encoding = max_length: int option ; } -> 'msg app_message_encoding -type 'msg message_config = 'msg P2p_connection_pool.message_config = { +type 'msg message_config = 'msg P2p_pool.message_config = { encoding : 'msg app_message_encoding list ; - versions : Version.t list; + versions : P2p_version.t list; } type config = { - listening_port : port option; - listening_addr : addr option; - trusted_points : Point.t list ; + listening_port : P2p_addr.port option; + listening_addr : P2p_addr.t option; + trusted_points : P2p_point.Id.t list ; peers_file : string ; closed_network : bool ; - identity : Identity.t ; + identity : P2p_identity.t ; proof_of_work_target : Crypto_box.target ; } @@ -87,7 +85,7 @@ let create_scheduler limits = let create_connection_pool config limits meta_cfg msg_cfg io_sched = let pool_cfg = { - P2p_connection_pool.identity = config.identity ; + P2p_pool.identity = config.identity ; proof_of_work_target = config.proof_of_work_target ; listening_port = config.listening_port ; trusted_points = config.trusted_points ; @@ -109,7 +107,7 @@ let create_connection_pool config limits meta_cfg msg_cfg io_sched = } in let pool = - P2p_connection_pool.create pool_cfg meta_cfg msg_cfg io_sched in + P2p_pool.create pool_cfg meta_cfg msg_cfg io_sched in pool let bounds ~min ~expected ~max = @@ -149,7 +147,7 @@ let may_create_welcome_worker config limits pool = port >>= fun w -> Lwt.return (Some w) -type ('msg, 'meta) connection = ('msg, 'meta) P2p_connection_pool.connection +type ('msg, 'meta) connection = ('msg, 'meta) P2p_pool.connection module Real = struct @@ -157,7 +155,7 @@ module Real = struct config: config ; limits: limits ; io_sched: P2p_io_scheduler.t ; - pool: ('msg, 'meta) P2p_connection_pool.t ; + pool: ('msg, 'meta) P2p_pool.t ; discoverer: P2p_discovery.t option ; maintenance: 'meta P2p_maintenance.t ; welcome: P2p_welcome.t option ; @@ -193,119 +191,119 @@ module Real = struct Lwt_utils.may ~f:P2p_welcome.shutdown net.welcome >>= fun () -> P2p_maintenance.shutdown net.maintenance >>= fun () -> Lwt_utils.may ~f:P2p_discovery.shutdown net.discoverer >>= fun () -> - P2p_connection_pool.destroy net.pool >>= fun () -> + P2p_pool.destroy net.pool >>= fun () -> P2p_io_scheduler.shutdown ~timeout:3.0 net.io_sched let connections { pool } () = - P2p_connection_pool.Connection.fold pool + P2p_pool.Connection.fold pool ~init:[] ~f:(fun _peer_id c acc -> c :: acc) let find_connection { pool } peer_id = - P2p_connection_pool.Connection.find_by_peer_id pool peer_id + P2p_pool.Connection.find_by_peer_id pool peer_id let disconnect ?wait conn = - P2p_connection_pool.disconnect ?wait conn + P2p_pool.disconnect ?wait conn let connection_info _net conn = - P2p_connection_pool.Connection.info conn + P2p_pool.Connection.info conn let connection_stat _net conn = - P2p_connection_pool.Connection.stat conn + P2p_pool.Connection.stat conn let global_stat { pool } () = - P2p_connection_pool.pool_stat pool + P2p_pool.pool_stat pool let set_metadata { pool } conn meta = - P2p_connection_pool.Peer_ids.set_metadata pool conn meta + P2p_pool.Peers.set_metadata pool conn meta let get_metadata { pool } conn = - P2p_connection_pool.Peer_ids.get_metadata pool conn + P2p_pool.Peers.get_metadata pool conn let recv _net conn = - P2p_connection_pool.read conn >>=? fun msg -> + P2p_pool.read conn >>=? fun msg -> lwt_debug "message read from %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) >>= fun () -> + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) >>= fun () -> return msg let rec recv_any net () = let pipes = - P2p_connection_pool.Connection.fold + P2p_pool.Connection.fold net.pool ~init:[] ~f:begin fun _peer_id conn acc -> - (P2p_connection_pool.is_readable conn >>= function + (P2p_pool.is_readable conn >>= function | Ok () -> Lwt.return (Some conn) | Error _ -> Lwt_utils.never_ending) :: acc end in Lwt.pick ( - ( P2p_connection_pool.Pool_event.wait_new_connection net.pool >>= fun () -> + ( P2p_pool.Pool_event.wait_new_connection net.pool >>= fun () -> Lwt.return_none ):: pipes) >>= function | None -> recv_any net () | Some conn -> - P2p_connection_pool.read conn >>= function + P2p_pool.read conn >>= function | Ok msg -> lwt_debug "message read from %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) >>= fun () -> + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) >>= fun () -> Lwt.return (conn, msg) | Error _ -> lwt_debug "error reading message from %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) >>= fun () -> + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) >>= fun () -> Lwt_unix.yield () >>= fun () -> recv_any net () let send _net conn m = - P2p_connection_pool.write conn m >>= function + P2p_pool.write conn m >>= function | Ok () -> lwt_debug "message sent to %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) >>= fun () -> + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) >>= fun () -> return () | Error err -> lwt_debug "error sending message from %a: %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) pp_print_error err >>= fun () -> Lwt.return (Error err) let try_send _net conn v = - match P2p_connection_pool.write_now conn v with + match P2p_pool.write_now conn v with | Ok v -> debug "message trysent to %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) ; + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) ; v | Error err -> debug "error trysending message to %a@ %a" - Connection_info.pp - (P2p_connection_pool.Connection.info conn) + P2p_connection.Info.pp + (P2p_pool.Connection.info conn) pp_print_error err ; false let broadcast { pool } msg = - P2p_connection_pool.write_all pool msg ; + P2p_pool.write_all pool msg ; debug "message broadcasted" let fold_connections { pool } ~init ~f = - P2p_connection_pool.Connection.fold pool ~init ~f + P2p_pool.Connection.fold pool ~init ~f let iter_connections { pool } f = - P2p_connection_pool.Connection.fold pool + P2p_pool.Connection.fold pool ~init:() ~f:(fun gid conn () -> f gid conn) let on_new_connection { pool } f = - P2p_connection_pool.on_new_connection pool f + P2p_pool.on_new_connection pool f let pool { pool } = pool end module Fake = struct - let id = Identity.generate (Crypto_box.make_target 0.) + let id = P2p_identity.generate (Crypto_box.make_target 0.) let empty_stat = { - Stat.total_sent = 0L ; + P2p_stat.total_sent = 0L ; total_recv = 0L ; current_inflow = 0 ; current_outflow = 0 ; } let connection_info = { - Connection_info.incoming = false ; + P2p_connection.Info.incoming = false ; peer_id = id.peer_id ; id_point = (Ipaddr.V6.unspecified, None) ; remote_socket_port = 0 ; @@ -315,28 +313,28 @@ module Fake = struct end type ('msg, 'meta) t = { - peer_id : Peer_id.t ; + peer_id : P2p_peer.Id.t ; maintain : unit -> unit Lwt.t ; roll : unit -> unit Lwt.t ; shutdown : unit -> unit Lwt.t ; connections : unit -> ('msg, 'meta) connection list ; - find_connection : Peer_id.t -> ('msg, 'meta) connection option ; + find_connection : P2p_peer.Id.t -> ('msg, 'meta) connection option ; disconnect : ?wait:bool -> ('msg, 'meta) connection -> unit Lwt.t ; - connection_info : ('msg, 'meta) connection -> Connection_info.t ; - connection_stat : ('msg, 'meta) connection -> Stat.t ; - global_stat : unit -> Stat.t ; - get_metadata : Peer_id.t -> 'meta ; - set_metadata : Peer_id.t -> 'meta -> unit ; + connection_info : ('msg, 'meta) connection -> P2p_connection.Info.t ; + connection_stat : ('msg, 'meta) connection -> P2p_stat.t ; + global_stat : unit -> P2p_stat.t ; + get_metadata : P2p_peer.Id.t -> 'meta ; + set_metadata : P2p_peer.Id.t -> 'meta -> unit ; recv : ('msg, 'meta) connection -> 'msg tzresult Lwt.t ; recv_any : unit -> (('msg, 'meta) connection * 'msg) Lwt.t ; send : ('msg, 'meta) connection -> 'msg -> unit tzresult Lwt.t ; try_send : ('msg, 'meta) connection -> 'msg -> bool ; broadcast : 'msg -> unit ; - pool : ('msg, 'meta) P2p_connection_pool.t option ; + pool : ('msg, 'meta) P2p_pool.t option ; fold_connections : - 'a. init:'a -> f:(Peer_id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> 'a ; - iter_connections : (Peer_id.t -> ('msg, 'meta) connection -> unit) -> unit ; - on_new_connection : (Peer_id.t -> ('msg, 'meta) connection -> unit) -> unit ; + 'a. init:'a -> f:(P2p_peer.Id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> 'a ; + iter_connections : (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) -> unit ; + on_new_connection : (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) -> unit ; } type ('msg, 'meta) net = ('msg, 'meta) t @@ -374,7 +372,7 @@ let check_limits = begin match c.binary_chunks_size with | None -> return () - | Some size -> P2p_connection.check_binary_chunks_size size + | Some size -> P2p_socket.check_binary_chunks_size size end >>=? fun () -> return () @@ -420,7 +418,7 @@ let faked_network meta_config = { set_metadata = (fun _ _ -> ()) ; recv = (fun _ -> Lwt_utils.never_ending) ; recv_any = (fun () -> Lwt_utils.never_ending) ; - send = (fun _ _ -> fail P2p_connection_pool.Connection_closed) ; + send = (fun _ _ -> fail P2p_pool.Connection_closed) ; try_send = (fun _ _ -> false) ; fold_connections = (fun ~init ~f:_ -> init) ; iter_connections = (fun _f -> ()) ; @@ -451,35 +449,33 @@ let iter_connections net = net.iter_connections let on_new_connection net = net.on_new_connection module Raw = struct - type 'a t = 'a P2p_connection_pool.Message.t = + type 'a t = 'a P2p_pool.Message.t = | Bootstrap - | Advertise of P2p_types.Point.t list - | Swap_request of Point.t * Peer_id.t - | Swap_ack of Point.t * Peer_id.t + | Advertise of P2p_point.Id.t list + | Swap_request of P2p_point.Id.t * P2p_peer.Id.t + | Swap_ack of P2p_point.Id.t * P2p_peer.Id.t | Message of 'a | Disconnect - let encoding = P2p_connection_pool.Message.encoding + let encoding = P2p_pool.Message.encoding end module RPC = struct let stat net = match net.pool with - | None -> Stat.empty - | Some pool -> P2p_connection_pool.pool_stat pool - - module Event = P2p_connection_pool.Log_event + | None -> P2p_stat.empty + | Some pool -> P2p_pool.pool_stat pool let watch net = match net.pool with | None -> Lwt_watcher.create_fake_stream () - | Some pool -> P2p_connection_pool.watch pool + | Some pool -> P2p_pool.watch pool let connect net point timeout = match net.pool with | None -> failwith "fake net" | Some pool -> - P2p_connection_pool.connect ~timeout pool point >>|? ignore + P2p_pool.connect ~timeout pool point >>|? ignore module Connection = struct let info net peer_id = @@ -487,46 +483,45 @@ module RPC = struct | None -> None | Some pool -> Option.map - (P2p_connection_pool.Connection.find_by_peer_id pool peer_id) - ~f:P2p_connection_pool.Connection.info + (P2p_pool.Connection.find_by_peer_id pool peer_id) + ~f:P2p_pool.Connection.info let kick net peer_id wait = match net.pool with | None -> Lwt.return_unit | Some pool -> - match P2p_connection_pool.Connection.find_by_peer_id pool peer_id with + match P2p_pool.Connection.find_by_peer_id pool peer_id with | None -> Lwt.return_unit - | Some conn -> P2p_connection_pool.disconnect ~wait conn + | Some conn -> P2p_pool.disconnect ~wait conn let list net = match net.pool with | None -> [] | Some pool -> - P2p_connection_pool.Connection.fold + P2p_pool.Connection.fold pool ~init:[] ~f:begin fun _peer_id c acc -> - P2p_connection_pool.Connection.info c :: acc + P2p_pool.Connection.info c :: acc end let count net = match net.pool with | None -> 0 - | Some pool -> P2p_connection_pool.active_connections pool + | Some pool -> P2p_pool.active_connections pool end module Point = struct - open P2p_types.Point_info - open P2p_types.Point_state + open P2p_point.Info + open P2p_point.State let info_of_point_info i = - let open P2p_connection_pool_types in - let state = match Point_info.State.get i with + let state = match P2p_point.Pool_state.get i with | Requested _ -> Requested | Accepted { current_peer_id ; _ } -> Accepted current_peer_id | Running { current_peer_id ; _ } -> Running current_peer_id | Disconnected -> Disconnected in - Point_info.{ + P2p_point.Pool_info.{ trusted = trusted i ; state ; greylisted_until = greylisted_until i ; @@ -543,21 +538,19 @@ module RPC = struct | None -> None | Some pool -> Option.map - (P2p_connection_pool.Points.info pool point) + (P2p_pool.Points.info pool point) ~f:info_of_point_info - module Event = P2p_connection_pool_types.Point_info.Event - let events ?(max=max_int) ?(rev=false) net point = match net.pool with | None -> [] | Some pool -> Option.unopt_map - (P2p_connection_pool.Points.info pool point) + (P2p_pool.Points.info pool point) ~default:[] ~f:begin fun pi -> let evts = - P2p_connection_pool_types.Point_info.fold_events + P2p_point.Pool_event.fold pi ~init:[] ~f:(fun a e -> e :: a) in (if rev then List.rev_sub else List.sub) evts max end @@ -566,15 +559,15 @@ module RPC = struct match net.pool with | None -> raise Not_found | Some pool -> - match P2p_connection_pool.Points.info pool point with + match P2p_pool.Points.info pool point with | None -> raise Not_found - | Some pi -> P2p_connection_pool_types.Point_info.watch pi + | Some pi -> P2p_point.Pool_event.watch pi let list ?(restrict=[]) net = match net.pool with | None -> [] | Some pool -> - P2p_connection_pool.Points.fold_known + P2p_pool.Points.fold_known pool ~init:[] ~f:begin fun point i a -> let info = info_of_point_info i in @@ -588,24 +581,22 @@ module RPC = struct module Peer_id = struct - open P2p_types.Peer_info - open P2p_types.Peer_state + open P2p_peer.Info + open P2p_peer.State let info_of_peer_info pool i = - let open P2p_connection_pool in - let open P2p_connection_pool_types in - let state, id_point = match Peer_info.State.get i with + let state, id_point = match P2p_peer.Pool_state.get i with | Accepted { current_point } -> Accepted, Some current_point | Running { current_point } -> Running, Some current_point | Disconnected -> Disconnected, None in - let peer_id = Peer_info.peer_id i in - let score = Peer_ids.get_score pool peer_id in + let peer_id = P2p_peer.Pool_info.peer_id i in + let score = P2p_pool.Peers.get_score pool peer_id in let stat = - match P2p_connection_pool.Connection.find_by_peer_id pool peer_id with - | None -> Stat.empty - | Some conn -> P2p_connection_pool.Connection.stat conn - in Peer_info.{ + match P2p_pool.Connection.find_by_peer_id pool peer_id with + | None -> P2p_stat.empty + | Some conn -> P2p_pool.Connection.stat conn + in P2p_peer.Pool_info.{ score ; trusted = trusted i ; state ; @@ -623,7 +614,7 @@ module RPC = struct match net.pool with | None -> None | Some pool -> begin - match P2p_connection_pool.Peer_ids.info pool peer_id with + match P2p_pool.Peers.info pool peer_id with | Some info -> Some (info_of_peer_info pool info) | None -> None end @@ -633,10 +624,10 @@ module RPC = struct | None -> [] | Some pool -> Option.unopt_map - (P2p_connection_pool.Peer_ids.info pool peer_id) + (P2p_pool.Peers.info pool peer_id) ~default:[] ~f:begin fun gi -> - let evts = P2p_connection_pool_types.Peer_info.fold_events gi + let evts = P2p_peer.Pool_event.fold gi ~init:[] ~f:(fun a e -> e :: a) in (if rev then List.rev_sub else List.sub) evts max end @@ -645,15 +636,15 @@ module RPC = struct match net.pool with | None -> raise Not_found | Some pool -> - match P2p_connection_pool.Peer_ids.info pool peer_id with + match P2p_pool.Peers.info pool peer_id with | None -> raise Not_found - | Some gi -> P2p_connection_pool_types.Peer_info.watch gi + | Some gi -> P2p_peer.Pool_event.watch gi let list ?(restrict=[]) net = match net.pool with | None -> [] | Some pool -> - P2p_connection_pool.Peer_ids.fold_known pool + P2p_pool.Peers.fold_known pool ~init:[] ~f:begin fun peer_id i a -> let info = info_of_peer_info pool i in diff --git a/src/lib_p2p/p2p.mli b/src/lib_p2p/p2p.mli index 4fa640700..12cc2c9f5 100644 --- a/src/lib_p2p/p2p.mli +++ b/src/lib_p2p/p2p.mli @@ -9,28 +9,6 @@ (** Tezos Shell Net - Low level API for the Gossip network *) -(** A peer connection address *) -type addr = Ipaddr.V6.t - -(** A peer connection port *) -type port = int - -(** A p2p protocol version *) -module Version = P2p_types.Version - -(** A global identifier for a peer, a.k.a. an identity *) -module Peer_id = P2p_types.Peer_id - -module Identity = P2p_types.Identity - -module Point = P2p_types.Point - -module Id_point = P2p_types.Id_point - -module Connection_info = P2p_types.Connection_info - -module Stat = P2p_types.Stat - type 'meta meta_config = { encoding : 'meta Data_encoding.t; initial : 'meta; @@ -47,21 +25,21 @@ type 'msg app_message_encoding = Encoding : { type 'msg message_config = { encoding : 'msg app_message_encoding list ; - versions : Version.t list; + versions : P2p_version.t list; } (** Network configuration *) type config = { - listening_port : port option; + listening_port : P2p_addr.port option; (** Tells if incoming connections accepted, precising the TCP port on which the peer can be reached *) - listening_addr : addr option; + listening_addr : P2p_addr.t option; (** When incoming connections are accepted, precising on which IP adddress the node listen (default: [[::]]). *) - trusted_points : Point.t list ; + trusted_points : P2p_point.Id.t list ; (** List of hard-coded known peers to bootstrap the network from. *) peers_file : string ; @@ -72,7 +50,7 @@ type config = { (** If [true], the only accepted connections are from peers whose addresses are in [trusted_peers]. *) - identity : Identity.t ; + identity : P2p_identity.t ; (** Cryptographic identity of the peer. *) proof_of_work_target : Crypto_box.target ; @@ -148,7 +126,7 @@ val create : 'meta meta_config -> 'msg message_config -> ('msg, 'meta) net tzresult Lwt.t (** Return one's peer_id *) -val peer_id : ('msg, 'meta) net -> Peer_id.t +val peer_id : ('msg, 'meta) net -> P2p_peer.Id.t (** A maintenance operation : try and reach the ideal number of peers *) val maintain : ('msg, 'meta) net -> unit Lwt.t @@ -166,23 +144,23 @@ type ('msg, 'meta) connection val connections : ('msg, 'meta) net -> ('msg, 'meta) connection list (** Return the active peer with identity [peer_id] *) -val find_connection : ('msg, 'meta) net -> Peer_id.t -> ('msg, 'meta) connection option +val find_connection : ('msg, 'meta) net -> P2p_peer.Id.t -> ('msg, 'meta) connection option (** Access the info of an active peer, if available *) val connection_info : - ('msg, 'meta) net -> ('msg, 'meta) connection -> Connection_info.t + ('msg, 'meta) net -> ('msg, 'meta) connection -> P2p_connection.Info.t val connection_stat : - ('msg, 'meta) net -> ('msg, 'meta) connection -> Stat.t + ('msg, 'meta) net -> ('msg, 'meta) connection -> P2p_stat.t (** Cleanly closes a connection. *) val disconnect : ('msg, 'meta) net -> ?wait:bool -> ('msg, 'meta) connection -> unit Lwt.t -val global_stat : ('msg, 'meta) net -> Stat.t +val global_stat : ('msg, 'meta) net -> P2p_stat.t (** Accessors for meta information about a global identifier *) -val get_metadata : ('msg, 'meta) net -> Peer_id.t -> 'meta -val set_metadata : ('msg, 'meta) net -> Peer_id.t -> 'meta -> unit +val get_metadata : ('msg, 'meta) net -> P2p_peer.Id.t -> 'meta +val set_metadata : ('msg, 'meta) net -> P2p_peer.Id.t -> 'meta -> unit (** Wait for a message from a given connection. *) val recv : @@ -207,56 +185,56 @@ val broadcast : ('msg, 'meta) net -> 'msg -> unit module RPC : sig - val stat : ('msg, 'meta) net -> Stat.t + val stat : ('msg, 'meta) net -> P2p_stat.t val watch : ('msg, 'meta) net -> - P2p_types.Connection_pool_log_event.t Lwt_stream.t * Lwt_watcher.stopper - val connect : ('msg, 'meta) net -> Point.t -> float -> unit tzresult Lwt.t + P2p_connection.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper + val connect : ('msg, 'meta) net -> P2p_point.Id.t -> float -> unit tzresult Lwt.t module Connection : sig - val info : ('msg, 'meta) net -> Peer_id.t -> Connection_info.t option - val kick : ('msg, 'meta) net -> Peer_id.t -> bool -> unit Lwt.t - val list : ('msg, 'meta) net -> Connection_info.t list + val info : ('msg, 'meta) net -> P2p_peer.Id.t -> P2p_connection.Info.t option + val kick : ('msg, 'meta) net -> P2p_peer.Id.t -> bool -> unit Lwt.t + val list : ('msg, 'meta) net -> P2p_connection.Info.t list val count : ('msg, 'meta) net -> int end module Point : sig val info : - ('msg, 'meta) net -> Point.t -> P2p_types.Point_info.t option + ('msg, 'meta) net -> P2p_point.Id.t -> P2p_point.Info.t option val list : - ?restrict: P2p_types.Point_state.t list -> - ('msg, 'meta) net -> (Point.t * P2p_types.Point_info.t) list + ?restrict: P2p_point.State.t list -> + ('msg, 'meta) net -> (P2p_point.Id.t * P2p_point.Info.t) list val events : - ?max:int -> ?rev:bool -> ('msg, 'meta) net -> Point.t -> - P2p_connection_pool_types.Point_info.Event.t list + ?max:int -> ?rev:bool -> ('msg, 'meta) net -> P2p_point.Id.t -> + P2p_point.Pool_event.t list val watch : - ('msg, 'meta) net -> Point.t -> - P2p_connection_pool_types.Point_info.Event.t Lwt_stream.t * Lwt_watcher.stopper + ('msg, 'meta) net -> P2p_point.Id.t -> + P2p_point.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper end module Peer_id : sig val info : - ('msg, 'meta) net -> Peer_id.t -> P2p_types.Peer_info.t option + ('msg, 'meta) net -> P2p_peer.Id.t -> P2p_peer.Info.t option val list : - ?restrict: P2p_types.Peer_state.t list -> - ('msg, 'meta) net -> (Peer_id.t * P2p_types.Peer_info.t) list + ?restrict: P2p_peer.State.t list -> + ('msg, 'meta) net -> (P2p_peer.Id.t * P2p_peer.Info.t) list val events : ?max: int -> ?rev: bool -> - ('msg, 'meta) net -> Peer_id.t -> - P2p_connection_pool_types.Peer_info.Event.t list + ('msg, 'meta) net -> P2p_peer.Id.t -> + P2p_peer.Pool_event.t list val watch : - ('msg, 'meta) net -> Peer_id.t -> - P2p_connection_pool_types.Peer_info.Event.t Lwt_stream.t * Lwt_watcher.stopper + ('msg, 'meta) net -> P2p_peer.Id.t -> + P2p_peer.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper end @@ -264,24 +242,24 @@ end val fold_connections : ('msg, 'meta) net -> - init:'a -> f:(Peer_id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> 'a + init:'a -> f:(P2p_peer.Id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> 'a val iter_connections : ('msg, 'meta) net -> - (Peer_id.t -> ('msg, 'meta) connection -> unit) -> unit + (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) -> unit val on_new_connection : ('msg, 'meta) net -> - (Peer_id.t -> ('msg, 'meta) connection -> unit) -> unit + (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) -> unit (**/**) module Raw : sig type 'a t = | Bootstrap - | Advertise of P2p_types.Point.t list - | Swap_request of Point.t * Peer_id.t - | Swap_ack of Point.t * Peer_id.t + | Advertise of P2p_point.Id.t list + | Swap_request of P2p_point.Id.t * P2p_peer.Id.t + | Swap_ack of P2p_point.Id.t * P2p_peer.Id.t | Message of 'a | Disconnect val encoding: 'msg app_message_encoding list -> 'msg t Data_encoding.t diff --git a/src/lib_p2p/p2p_discovery.ml b/src/lib_p2p/p2p_discovery.ml index e25ab53ab..190e5341b 100644 --- a/src/lib_p2p/p2p_discovery.ml +++ b/src/lib_p2p/p2p_discovery.ml @@ -20,7 +20,7 @@ let inet_addr = Unix.inet_addr_of_string "ff0e::54:455a:3053" module Message = struct let encoding = - Data_encoding.(tup3 (Fixed.string 10) Peer_id.encoding int16) + Data_encoding.(tup3 (Fixed.string 10) P2p_peer.Id.encoding int16) let length = Data_encoding.Binary.fixed_length_exn encoding @@ -40,7 +40,7 @@ let sender sock saddr my_peer_id inco_port cancelation restart = Lwt.return_unit) (fun exn -> lwt_debug "(%a) error broadcasting a discovery request: %a" - Peer_id.pp my_peer_id Error_monad.pp (Exn exn)) >>= fun () -> + P2p_peer.Id.pp my_peer_id Error_monad.pp (Exn exn)) >>= fun () -> Lwt.pick [ (Lwt_unix.sleep delay >>= fun () -> Lwt.return (Some (delay, n + 1))) ; (cancelation () >>= fun () -> Lwt.return_none) ; @@ -100,7 +100,7 @@ module Answerer = struct Lwt.catch (fun () -> Lwt_utils.worker - (Format.asprintf "(%a) discovery answerer" Peer_id.pp my_peer_id) + (Format.asprintf "(%a) discovery answerer" P2p_peer.Id.pp my_peer_id) (fun () -> answerer fd my_peer_id cancelation callback) cancel) (fun exn -> @@ -118,7 +118,7 @@ let discovery_sender = Discovery.sender fd saddr my_peer_id inco_port cancelation restart_discovery in Lwt_utils.worker - (Format.asprintf "(%a) discovery sender" Peer_id.pp my_peer_id) + (Format.asprintf "(%a) discovery sender" P2p_peer.Id.pp my_peer_id) sender cancel) (fun exn -> lwt_log_error "Discovery sender not started: %a" diff --git a/src/lib_p2p/p2p_discovery.mli b/src/lib_p2p/p2p_discovery.mli index 05b7d5f9f..6c3c9193c 100644 --- a/src/lib_p2p/p2p_discovery.mli +++ b/src/lib_p2p/p2p_discovery.mli @@ -8,6 +8,6 @@ (**************************************************************************) type t -val create : ('msg, 'meta) P2p_connection_pool.pool -> t +val create : ('msg, 'meta) P2p_pool.t -> t val restart : t -> unit val shutdown : t -> unit Lwt.t diff --git a/src/lib_p2p/p2p_io_scheduler.ml b/src/lib_p2p/p2p_io_scheduler.ml index 8b08312bc..48980ccb9 100644 --- a/src/lib_p2p/p2p_io_scheduler.ml +++ b/src/lib_p2p/p2p_io_scheduler.ml @@ -17,7 +17,6 @@ let () = if Sys.os_type <> "Win32" then Sys.(set_signal sigpipe Signal_ignore) -open P2p_types include Logging.Make (struct let name = "p2p.io-scheduler" end) module Inttbl = Hashtbl.Make(struct @@ -457,7 +456,7 @@ let read_full conn ?pos ?len buf = loop pos len let convert ~ws ~rs = - { Stat.total_sent = ws.Moving_average.total ; + { P2p_stat.total_sent = ws.Moving_average.total ; total_recv = rs.Moving_average.total ; current_outflow = ws.average ; current_inflow = rs.average ; diff --git a/src/lib_p2p/p2p_io_scheduler.mli b/src/lib_p2p/p2p_io_scheduler.mli index c590d6d61..f45c0f1c1 100644 --- a/src/lib_p2p/p2p_io_scheduler.mli +++ b/src/lib_p2p/p2p_io_scheduler.mli @@ -23,8 +23,6 @@ num_connections). *) -open P2p_types - type connection (** Type of a connection. *) @@ -71,11 +69,11 @@ val read_full: connection -> ?pos:int -> ?len:int -> MBytes.t -> unit tzresult Lwt.t (** Like [read], but blits exactly [len] bytes in [buf]. *) -val stat: connection -> Stat.t +val stat: connection -> P2p_stat.t (** [stat conn] is a snapshot of current bandwidth usage for [conn]. *) -val global_stat: t -> Stat.t +val global_stat: t -> P2p_stat.t (** [global_stat sched] is a snapshot of [sched]'s bandwidth usage (sum of [stat conn] for each [conn] in [sched]). *) diff --git a/src/lib_p2p/p2p_maintenance.ml b/src/lib_p2p/p2p_maintenance.ml index 088f835ad..2541e8dcf 100644 --- a/src/lib_p2p/p2p_maintenance.ml +++ b/src/lib_p2p/p2p_maintenance.ml @@ -7,9 +7,6 @@ (* *) (**************************************************************************) -open P2p_types -open P2p_connection_pool_types - include Logging.Make (struct let name = "p2p.maintenance" end) type bounds = { @@ -19,7 +16,7 @@ type bounds = { max_threshold: int ; } -type 'meta pool = Pool : ('msg, 'meta) P2p_connection_pool.t -> 'meta pool +type 'meta pool = Pool : ('msg, 'meta) P2p_pool.t -> 'meta pool type 'meta t = { canceler: Lwt_canceler.t ; @@ -41,7 +38,7 @@ let connectable st start_time expected = let now = Time.now () in let module Bounded_point_info = List.Bounded(struct - type t = (Time.t option * Point.t) + type t = (Time.t option * P2p_point.Id.t) let compare (t1, _) (t2, _) = match t1, t2 with | None, None -> 0 @@ -50,13 +47,13 @@ let connectable st start_time expected = | Some t1, Some t2 -> Time.compare t2 t1 end) in let acc = Bounded_point_info.create expected in - P2p_connection_pool.Points.fold_known pool ~init:() + P2p_pool.Points.fold_known pool ~init:() ~f:begin fun point pi () -> - match Point_info.State.get pi with + match P2p_point.Pool_state.get pi with | Disconnected -> begin - match Point_info.last_miss pi with + match P2p_point.Pool_info.last_miss pi with | Some last when Time.(start_time < last) - || Point_info.greylisted ~now pi -> () + || P2p_point.Pool_info.greylisted ~now pi -> () | last -> Bounded_point_info.insert (last, point) acc end @@ -83,7 +80,7 @@ let rec try_to_contact else List.fold_left (fun acc point -> - P2p_connection_pool.connect + P2p_pool.connect ~timeout:st.connection_timeout pool point >>= function | Ok _ -> acc >|= succ | Error _ -> acc) @@ -96,7 +93,7 @@ let rec try_to_contact of connections is between `min_threshold` and `max_threshold`. *) let rec maintain st = let Pool pool = st.pool in - let n_connected = P2p_connection_pool.active_connections pool in + let n_connected = P2p_pool.active_connections pool in if n_connected < st.bounds.min_threshold then too_few_connections st n_connected else if st.bounds.max_threshold < n_connected then @@ -121,10 +118,10 @@ and too_few_connections st n_connected = (* not enough contacts, ask the pals of our pals, discover the local network and then wait *) Option.iter ~f:P2p_discovery.restart st.disco ; - P2p_connection_pool.broadcast_bootstrap_msg pool ; + P2p_pool.broadcast_bootstrap_msg pool ; Lwt_utils.protect ~canceler:st.canceler begin fun () -> Lwt.pick [ - P2p_connection_pool.Pool_event.wait_new_peer pool ; + P2p_pool.Pool_event.wait_new_peer pool ; Lwt_unix.sleep 5.0 (* TODO exponential back-off ?? or wait for the existence of a non grey-listed peer ?? *) @@ -138,11 +135,11 @@ and too_many_connections st n_connected = (* too many connections, start the russian roulette *) let to_kill = n_connected - st.bounds.max_target in lwt_debug "Too many connections, will kill %d" to_kill >>= fun () -> - snd @@ P2p_connection_pool.Connection.fold pool + snd @@ P2p_pool.Connection.fold pool ~init:(to_kill, Lwt.return_unit) ~f:(fun _ conn (i, t) -> if i = 0 then (0, t) - else (i - 1, t >>= fun () -> P2p_connection_pool.disconnect conn)) + else (i - 1, t >>= fun () -> P2p_pool.disconnect conn)) >>= fun () -> maintain st @@ -153,17 +150,17 @@ let rec worker_loop st = Lwt.pick [ Lwt_unix.sleep 120. ; (* every two minutes *) Lwt_condition.wait st.please_maintain ; (* when asked *) - P2p_connection_pool.Pool_event.wait_too_few_connections pool ; (* limits *) - P2p_connection_pool.Pool_event.wait_too_many_connections pool + P2p_pool.Pool_event.wait_too_few_connections pool ; (* limits *) + P2p_pool.Pool_event.wait_too_many_connections pool ] >>= fun () -> return () end >>=? fun () -> - let n_connected = P2p_connection_pool.active_connections pool in + let n_connected = P2p_pool.active_connections pool in if n_connected < st.bounds.min_threshold || st.bounds.max_threshold < n_connected then maintain st else begin - P2p_connection_pool.send_swap_request pool ; + P2p_pool.send_swap_request pool ; return () end end >>= function diff --git a/src/lib_p2p/p2p_maintenance.mli b/src/lib_p2p/p2p_maintenance.mli index 35b7b2289..300d85929 100644 --- a/src/lib_p2p/p2p_maintenance.mli +++ b/src/lib_p2p/p2p_maintenance.mli @@ -36,7 +36,7 @@ type 'meta t val run: connection_timeout:float -> bounds -> - ('msg, 'meta) P2p_connection_pool.t -> + ('msg, 'meta) P2p_pool.t -> P2p_discovery.t option -> 'meta t diff --git a/src/lib_p2p/p2p_connection_pool.ml b/src/lib_p2p/p2p_pool.ml similarity index 71% rename from src/lib_p2p/p2p_connection_pool.ml rename to src/lib_p2p/p2p_pool.ml index c4c769b20..04a417b1c 100644 --- a/src/lib_p2p/p2p_connection_pool.ml +++ b/src/lib_p2p/p2p_pool.ml @@ -15,9 +15,6 @@ (* TODO allow to track "requested peer_ids" when we reconnect to a point. *) -open P2p_types -open P2p_connection_pool_types - include Logging.Make (struct let name = "p2p.connection-pool" end) type 'msg encoding = Encoding : { @@ -32,9 +29,9 @@ module Message = struct type 'msg t = | Bootstrap - | Advertise of Point.t list - | Swap_request of Point.t * Peer_id.t - | Swap_ack of Point.t * Peer_id.t + | Advertise of P2p_point.Id.t list + | Swap_request of P2p_point.Id.t * P2p_peer.Id.t + | Swap_ack of P2p_point.Id.t * P2p_peer.Id.t | Message of 'msg | Disconnect @@ -48,15 +45,15 @@ module Message = struct case (Tag 0x02) null (function Bootstrap -> Some () | _ -> None) (fun () -> Bootstrap); - case (Tag 0x03) (Variable.list Point.encoding) + case (Tag 0x03) (Variable.list P2p_point.Id.encoding) (function Advertise points -> Some points | _ -> None) (fun points -> Advertise points); - case (Tag 0x04) (tup2 Point.encoding Peer_id.encoding) + case (Tag 0x04) (tup2 P2p_point.Id.encoding P2p_peer.Id.encoding) (function | Swap_request (point, peer_id) -> Some (point, peer_id) | _ -> None) (fun (point, peer_id) -> Swap_request (point, peer_id)) ; - case (Tag 0x05) (tup2 Point.encoding Peer_id.encoding) + case (Tag 0x05) (tup2 P2p_point.Id.encoding P2p_peer.Id.encoding) (function | Swap_ack (point, peer_id) -> Some (point, peer_id) | _ -> None) @@ -74,16 +71,16 @@ end module Answerer = struct type 'msg callback = { - bootstrap: unit -> Point.t list Lwt.t ; - advertise: Point.t list -> unit Lwt.t ; + bootstrap: unit -> P2p_point.Id.t list Lwt.t ; + advertise: P2p_point.Id.t list -> unit Lwt.t ; message: int -> 'msg -> unit Lwt.t ; - swap_request: Point.t -> Peer_id.t -> unit Lwt.t ; - swap_ack: Point.t -> Peer_id.t -> unit Lwt.t ; + swap_request: P2p_point.Id.t -> P2p_peer.Id.t -> unit Lwt.t ; + swap_ack: P2p_point.Id.t -> P2p_peer.Id.t -> unit Lwt.t ; } type 'msg t = { canceler: Lwt_canceler.t ; - conn: 'msg Message.t P2p_connection.t ; + conn: 'msg Message.t P2p_socket.t ; callback: 'msg callback ; mutable worker: unit Lwt.t ; } @@ -91,14 +88,14 @@ module Answerer = struct let rec worker_loop st = Lwt_unix.yield () >>= fun () -> Lwt_utils.protect ~canceler:st.canceler begin fun () -> - P2p_connection.read st.conn + P2p_socket.read st.conn end >>= function | Ok (_, Bootstrap) -> begin st.callback.bootstrap () >>= function | [] -> worker_loop st | points -> - match P2p_connection.write_now st.conn (Advertise points) with + match P2p_socket.write_now st.conn (Advertise points) with | Ok _sent -> (* if not sent then ?? TODO count dropped message ?? *) worker_loop st @@ -121,7 +118,7 @@ module Answerer = struct | Ok (_, Disconnect) | Error [P2p_io_scheduler.Connection_closed] -> Lwt_canceler.cancel st.canceler >>= fun () -> Lwt.return_unit - | Error [P2p_connection.Decoding_error] -> + | Error [P2p_socket.Decoding_error] -> (* TODO: Penalize peer... *) Lwt_canceler.cancel st.canceler >>= fun () -> Lwt.return_unit @@ -150,18 +147,16 @@ module Answerer = struct end -module Log_event = Connection_pool_log_event - type config = { - identity : Identity.t ; + identity : P2p_identity.t ; proof_of_work_target : Crypto_box.target ; - trusted_points : Point.t list ; + trusted_points : P2p_point.Id.t list ; peers_file : string ; closed_network : bool ; - listening_port : port option ; + listening_port : P2p_addr.port option ; min_connections : int ; max_connections : int ; max_incoming_connections : int ; @@ -189,27 +184,27 @@ type 'meta meta_config = { type 'msg message_config = { encoding : 'msg encoding list ; - versions : P2p_types.Version.t list; + versions : P2p_version.t list; } type ('msg, 'meta) t = { config : config ; meta_config : 'meta meta_config ; message_config : 'msg message_config ; - my_id_points : unit Point.Table.t ; + my_id_points : unit P2p_point.Table.t ; known_peer_ids : - (('msg, 'meta) connection, 'meta) Peer_info.t Peer_id.Table.t ; + (('msg, 'meta) connection, 'meta) P2p_peer.Pool_info.t P2p_peer.Table.t ; connected_peer_ids : - (('msg, 'meta) connection, 'meta) Peer_info.t Peer_id.Table.t ; - known_points : ('msg, 'meta) connection Point_info.t Point.Table.t ; - connected_points : ('msg, 'meta) connection Point_info.t Point.Table.t ; - incoming : Lwt_canceler.t Point.Table.t ; + (('msg, 'meta) connection, 'meta) P2p_peer.Pool_info.t P2p_peer.Table.t ; + known_points : ('msg, 'meta) connection P2p_point.Pool_info.t P2p_point.Table.t ; + connected_points : ('msg, 'meta) connection P2p_point.Pool_info.t P2p_point.Table.t ; + incoming : Lwt_canceler.t P2p_point.Table.t ; io_sched : P2p_io_scheduler.t ; encoding : 'msg Message.t Data_encoding.t ; events : events ; - watcher : Log_event.t Lwt_watcher.input ; + watcher : P2p_connection.Pool_event.t Lwt_watcher.input ; mutable new_connection_hook : - (Peer_id.t -> ('msg, 'meta) connection -> unit) list ; + (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) list ; mutable latest_accepted_swap : Time.t ; mutable latest_succesfull_swap : Time.t ; } @@ -224,11 +219,11 @@ and events = { and ('msg, 'meta) connection = { canceler : Lwt_canceler.t ; messages : (int * 'msg) Lwt_pipe.t ; - conn : 'msg Message.t P2p_connection.t ; - peer_info : (('msg, 'meta) connection, 'meta) Peer_info.t ; - point_info : ('msg, 'meta) connection Point_info.t option ; + conn : 'msg Message.t P2p_socket.t ; + peer_info : (('msg, 'meta) connection, 'meta) P2p_peer.Pool_info.t ; + point_info : ('msg, 'meta) connection P2p_point.Pool_info.t option ; answerer : 'msg Answerer.t Lazy.t ; - mutable last_sent_swap_request : (Time.t * Peer_id.t) option ; + mutable last_sent_swap_request : (Time.t * P2p_peer.Id.t) option ; mutable wait_close : bool ; } @@ -248,8 +243,8 @@ end let watch { watcher } = Lwt_watcher.create_stream watcher let log { watcher } event = Lwt_watcher.notify watcher event -module GcPointSet = List.Bounded(struct - type t = Time.t * Point.t +module Gc_point_set = List.Bounded(struct + type t = Time.t * P2p_point.Id.t let compare (x, _) (y, _) = - (Time.compare x y) end) @@ -258,37 +253,37 @@ let gc_points ({ config = { max_known_points } ; known_points } as pool) = | None -> () | Some (_, target) -> let now = Time.now () in (* TODO: maybe time of discovery? *) - let table = GcPointSet.create target in - Point.Table.iter (fun p point_info -> - if Point_info.State.is_disconnected point_info then + let table = Gc_point_set.create target in + P2p_point.Table.iter (fun p point_info -> + if P2p_point.Pool_state.is_disconnected point_info then let time = - match Point_info.last_miss point_info with + match P2p_point.Pool_info.last_miss point_info with | None -> now | Some t -> t in - GcPointSet.insert (time, p) table + Gc_point_set.insert (time, p) table ) known_points ; - let to_remove = GcPointSet.get table in + let to_remove = Gc_point_set.get table in ListLabels.iter to_remove ~f:begin fun (_, p) -> - Point.Table.remove known_points p + P2p_point.Table.remove known_points p end ; log pool Gc_points let register_point pool ?trusted _source_peer_id (addr, port as point) = - match Point.Table.find pool.known_points point with + match P2p_point.Table.find pool.known_points point with | exception Not_found -> - let point_info = Point_info.create ?trusted addr port in + let point_info = P2p_point.Pool_info.create ?trusted addr port in Option.iter pool.config.max_known_points ~f:begin fun (max, _) -> - if Point.Table.length pool.known_points >= max then gc_points pool + if P2p_point.Table.length pool.known_points >= max then gc_points pool end ; - Point.Table.add pool.known_points point point_info ; + P2p_point.Table.add pool.known_points point point_info ; log pool (New_point point) ; point_info | point_info -> point_info let may_register_my_id_point pool = function - | [P2p_connection.Myself (addr, Some port)] -> - Point.Table.add pool.my_id_points (addr, port) () ; - Point.Table.remove pool.known_points (addr, port) + | [P2p_socket.Myself (addr, Some port)] -> + P2p_point.Table.add pool.my_id_points (addr, port) () ; + P2p_point.Table.remove pool.known_points (addr, port) | _ -> () @@ -299,8 +294,8 @@ let may_register_my_id_point pool = function case of a flood attack, the newly added infos will probably belong to peer_ids with the same (low) score and removing the most recent ones ensure that older (and probably legit) peer_id infos are kept. *) -module GcPeer_idSet = List.Bounded(struct - type t = float * Time.t * Peer_id.t +module Gc_peer_set = List.Bounded(struct + type t = float * Time.t * P2p_peer.Id.t let compare (s, t, _) (s', t', _) = let score_cmp = Pervasives.compare s s' in if score_cmp = 0 then Time.compare t t' else - score_cmp @@ -312,27 +307,27 @@ let gc_peer_ids ({ meta_config = { score } ; match max_known_peer_ids with | None -> () | Some (_, target) -> - let table = GcPeer_idSet.create target in - Peer_id.Table.iter (fun peer_id peer_info -> - let created = Peer_info.created peer_info in - let score = score @@ Peer_info.metadata peer_info in - GcPeer_idSet.insert (score, created, peer_id) table + let table = Gc_peer_set.create target in + P2p_peer.Table.iter (fun peer_id peer_info -> + let created = P2p_peer.Pool_info.created peer_info in + let score = score @@ P2p_peer.Pool_info.metadata peer_info in + Gc_peer_set.insert (score, created, peer_id) table ) known_peer_ids ; - let to_remove = GcPeer_idSet.get table in + let to_remove = Gc_peer_set.get table in ListLabels.iter to_remove ~f:begin fun (_, _, peer_id) -> - Peer_id.Table.remove known_peer_ids peer_id + P2p_peer.Table.remove known_peer_ids peer_id end ; log pool Gc_peer_ids let register_peer pool peer_id = - match Peer_id.Table.find pool.known_peer_ids peer_id with + match P2p_peer.Table.find pool.known_peer_ids peer_id with | exception Not_found -> Lwt_condition.broadcast pool.events.new_peer () ; - let peer = Peer_info.create peer_id ~metadata:pool.meta_config.initial in + let peer = P2p_peer.Pool_info.create peer_id ~metadata:pool.meta_config.initial in Option.iter pool.config.max_known_peer_ids ~f:begin fun (max, _) -> - if Peer_id.Table.length pool.known_peer_ids >= max then gc_peer_ids pool + if P2p_peer.Table.length pool.known_peer_ids >= max then gc_peer_ids pool end ; - Peer_id.Table.add pool.known_peer_ids peer_id peer ; + P2p_peer.Table.add pool.known_peer_ids peer_id peer ; log pool (New_peer peer_id) ; peer | peer -> peer @@ -344,7 +339,7 @@ let read { messages ; conn } = Lwt.catch (fun () -> Lwt_pipe.pop messages >>= fun (s, msg) -> lwt_debug "%d bytes message popped from queue %a\027[0m" - s Connection_info.pp (P2p_connection.info conn) >>= fun () -> + s P2p_connection.Info.pp (P2p_socket.info conn) >>= fun () -> return msg) (fun _ (* Closed *) -> fail P2p_io_scheduler.Connection_closed) @@ -354,111 +349,111 @@ let is_readable { messages } = (fun _ (* Closed *) -> fail P2p_io_scheduler.Connection_closed) let write { conn } msg = - P2p_connection.write conn (Message msg) + P2p_socket.write conn (Message msg) let write_sync { conn } msg = - P2p_connection.write_sync conn (Message msg) + P2p_socket.write_sync conn (Message msg) let raw_write_sync { conn } buf = - P2p_connection.raw_write_sync conn buf + P2p_socket.raw_write_sync conn buf let write_now { conn } msg = - P2p_connection.write_now conn (Message msg) + P2p_socket.write_now conn (Message msg) let write_all pool msg = - Peer_id.Table.iter + P2p_peer.Table.iter (fun _peer_id peer_info -> - match Peer_info.State.get peer_info with + match P2p_peer.Pool_state.get peer_info with | Running { data = conn } -> ignore (write_now conn msg : bool tzresult ) | _ -> ()) pool.connected_peer_ids let broadcast_bootstrap_msg pool = - Peer_id.Table.iter + P2p_peer.Table.iter (fun _peer_id peer_info -> - match Peer_info.State.get peer_info with + match P2p_peer.Pool_state.get peer_info with | Running { data = { conn } } -> - ignore (P2p_connection.write_now conn Bootstrap : bool tzresult ) + ignore (P2p_socket.write_now conn Bootstrap : bool tzresult ) | _ -> ()) pool.connected_peer_ids (***************************************************************************) -module Peer_ids = struct +module Peers = struct - type ('msg, 'meta) info = (('msg, 'meta) connection, 'meta) Peer_info.t + type ('msg, 'meta) info = (('msg, 'meta) connection, 'meta) P2p_peer.Pool_info.t let info { known_peer_ids } point = - try Some (Peer_id.Table.find known_peer_ids point) + try Some (P2p_peer.Table.find known_peer_ids point) with Not_found -> None let get_metadata pool peer_id = - try Peer_info.metadata (Peer_id.Table.find pool.known_peer_ids peer_id) + try P2p_peer.Pool_info.metadata (P2p_peer.Table.find pool.known_peer_ids peer_id) with Not_found -> pool.meta_config.initial let get_score pool peer_id = pool.meta_config.score (get_metadata pool peer_id) let set_metadata pool peer_id data = - Peer_info.set_metadata (register_peer pool peer_id) data + P2p_peer.Pool_info.set_metadata (register_peer pool peer_id) data let get_trusted pool peer_id = - try Peer_info.trusted (Peer_id.Table.find pool.known_peer_ids peer_id) + try P2p_peer.Pool_info.trusted (P2p_peer.Table.find pool.known_peer_ids peer_id) with Not_found -> false let set_trusted pool peer_id = - try Peer_info.set_trusted (register_peer pool peer_id) + try P2p_peer.Pool_info.set_trusted (register_peer pool peer_id) with Not_found -> () let unset_trusted pool peer_id = - try Peer_info.unset_trusted (Peer_id.Table.find pool.known_peer_ids peer_id) + try P2p_peer.Pool_info.unset_trusted (P2p_peer.Table.find pool.known_peer_ids peer_id) with Not_found -> () let fold_known pool ~init ~f = - Peer_id.Table.fold f pool.known_peer_ids init + P2p_peer.Table.fold f pool.known_peer_ids init let fold_connected pool ~init ~f = - Peer_id.Table.fold f pool.connected_peer_ids init + P2p_peer.Table.fold f pool.connected_peer_ids init end module Points = struct - type ('msg, 'meta) info = ('msg, 'meta) connection Point_info.t + type ('msg, 'meta) info = ('msg, 'meta) connection P2p_point.Pool_info.t let info { known_points } point = - try Some (Point.Table.find known_points point) + try Some (P2p_point.Table.find known_points point) with Not_found -> None let get_trusted pool point = - try Point_info.trusted (Point.Table.find pool.known_points point) + try P2p_point.Pool_info.trusted (P2p_point.Table.find pool.known_points point) with Not_found -> false let set_trusted pool point = try - Point_info.set_trusted + P2p_point.Pool_info.set_trusted (register_point pool pool.config.identity.peer_id point) with Not_found -> () let unset_trusted pool peer_id = - try Point_info.unset_trusted (Point.Table.find pool.known_points peer_id) + try P2p_point.Pool_info.unset_trusted (P2p_point.Table.find pool.known_points peer_id) with Not_found -> () let fold_known pool ~init ~f = - Point.Table.fold f pool.known_points init + P2p_point.Table.fold f pool.known_points init let fold_connected pool ~init ~f = - Point.Table.fold f pool.connected_points init + P2p_point.Table.fold f pool.connected_points init end module Connection = struct let fold pool ~init ~f = - Peer_ids.fold_connected pool ~init ~f:begin fun peer_id peer_info acc -> - match Peer_info.State.get peer_info with + Peers.fold_connected pool ~init ~f:begin fun peer_id peer_info acc -> + match P2p_peer.Pool_state.get peer_info with | Running { data } -> f peer_id data acc | _ -> acc end @@ -471,7 +466,7 @@ module Connection = struct fold pool ~init:[] ~f:begin fun _peer conn acc -> match different_than with | Some excluded_conn - when P2p_connection.equal conn.conn excluded_conn.conn -> acc + when P2p_socket.equal conn.conn excluded_conn.conn -> acc | Some _ | None -> conn :: acc end in match candidates with @@ -484,9 +479,9 @@ module Connection = struct fold pool ~init:[] ~f:begin fun _peer conn acc -> match different_than with | Some excluded_conn - when P2p_connection.equal conn.conn excluded_conn.conn -> acc + when P2p_socket.equal conn.conn excluded_conn.conn -> acc | Some _ | None -> - let ci = P2p_connection.info conn.conn in + let ci = P2p_socket.info conn.conn in match ci.id_point with | _, None -> acc | addr, Some port -> ((addr, port), ci.peer_id, conn) :: acc @@ -497,18 +492,18 @@ module Connection = struct Some (List.nth candidates (Random.int @@ List.length candidates)) let stat { conn } = - P2p_connection.stat conn + P2p_socket.stat conn let score { meta_config = { score }} meta = score meta let info { conn } = - P2p_connection.info conn + P2p_socket.info conn let find_by_peer_id pool peer_id = Option.apply - (Peer_ids.info pool peer_id) + (Peers.info pool peer_id) ~f:(fun p -> - match Peer_info.State.get p with + match P2p_peer.Pool_state.get p with | Running { data } -> Some data | _ -> None) @@ -516,7 +511,7 @@ module Connection = struct Option.apply (Points.info pool point) ~f:(fun p -> - match Point_info.State.get p with + match P2p_point.Pool_state.get p with | Running { data } -> Some data | _ -> None) @@ -528,7 +523,7 @@ let pool_stat { io_sched } = (***************************************************************************) -type error += Rejected of Peer_id.t +type error += Rejected of P2p_peer.Id.t type error += Pending_connection type error += Connected type error += Connection_closed = P2p_io_scheduler.Connection_closed @@ -537,13 +532,13 @@ type error += Closed_network type error += Too_many_connections let fail_unless_disconnected_point point_info = - match Point_info.State.get point_info with + match P2p_point.Pool_state.get point_info with | Disconnected -> return () | Requested _ | Accepted _ -> fail Pending_connection | Running _ -> fail Connected let fail_unless_disconnected_peer_id peer_info = - match Peer_info.State.get peer_info with + match P2p_peer.Pool_state.get peer_info with | Disconnected -> return () | Accepted _ -> fail Pending_connection | Running _ -> fail Connected @@ -551,10 +546,10 @@ let fail_unless_disconnected_peer_id peer_info = let compare_known_point_info p1 p2 = (* The most-recently disconnected peers are greater. *) (* Then come long-standing connected peers. *) - let disconnected1 = Point_info.State.is_disconnected p1 - and disconnected2 = Point_info.State.is_disconnected p2 in + let disconnected1 = P2p_point.Pool_state.is_disconnected p1 + and disconnected2 = P2p_point.Pool_state.is_disconnected p2 in let compare_last_seen p1 p2 = - match Point_info.last_seen p1, Point_info.last_seen p2 with + match P2p_point.Pool_info.last_seen p1, P2p_point.Pool_info.last_seen p2 with | None, None -> Random.int 2 * 2 - 1 (* HACK... *) | Some _, None -> 1 | None, Some _ -> -1 @@ -576,40 +571,40 @@ let rec connect ~timeout pool point = Lwt_utils.with_timeout ~canceler timeout begin fun canceler -> let point_info = register_point pool pool.config.identity.peer_id point in - let addr, port as point = Point_info.point point_info in + let addr, port as point = P2p_point.Pool_info.point point_info in fail_unless - (not pool.config.closed_network || Point_info.trusted point_info) + (not pool.config.closed_network || P2p_point.Pool_info.trusted point_info) Closed_network >>=? fun () -> fail_unless_disconnected_point point_info >>=? fun () -> - Point_info.State.set_requested point_info canceler ; + P2p_point.Pool_state.set_requested point_info canceler ; let fd = Lwt_unix.socket PF_INET6 SOCK_STREAM 0 in let uaddr = Lwt_unix.ADDR_INET (Ipaddr_unix.V6.to_inet_addr addr, port) in - lwt_debug "connect: %a" Point.pp point >>= fun () -> + lwt_debug "connect: %a" P2p_point.Id.pp point >>= fun () -> Lwt_utils.protect ~canceler begin fun () -> log pool (Outgoing_connection point) ; Lwt_unix.connect fd uaddr >>= fun () -> return () end ~on_error: begin fun err -> - lwt_debug "connect: %a -> disconnect" Point.pp point >>= fun () -> - Point_info.State.set_disconnected point_info ; + lwt_debug "connect: %a -> disconnect" P2p_point.Id.pp point >>= fun () -> + P2p_point.Pool_state.set_disconnected point_info ; Lwt_utils.safe_close fd >>= fun () -> match err with | [Exn (Unix.Unix_error (Unix.ECONNREFUSED, _, _))] -> fail Connection_refused | err -> Lwt.return (Error err) end >>=? fun () -> - lwt_debug "connect: %a -> authenticate" Point.pp point >>= fun () -> + lwt_debug "connect: %a -> authenticate" P2p_point.Id.pp point >>= fun () -> authenticate pool ~point_info canceler fd point end and authenticate pool ?point_info canceler fd point = let incoming = point_info = None in lwt_debug "authenticate: %a%s" - Point.pp point + P2p_point.Id.pp point (if incoming then " incoming" else "") >>= fun () -> Lwt_utils.protect ~canceler begin fun () -> - P2p_connection.authenticate + P2p_socket.authenticate ~proof_of_work_target:pool.config.proof_of_work_target ~incoming (P2p_io_scheduler.register pool.io_sched fd) point ?listening_port:pool.config.listening_port @@ -620,31 +615,31 @@ and authenticate pool ?point_info canceler fd point = | [ Lwt_utils.Canceled ] -> (* Currently only on time out *) lwt_debug "authenticate: %a%s -> canceled" - Point.pp point + P2p_point.Id.pp point (if incoming then " incoming" else "") | err -> (* Authentication incorrect! *) lwt_debug "@[authenticate: %a%s -> failed@ %a@]" - Point.pp point + P2p_point.Id.pp point (if incoming then " incoming" else "") pp_print_error err end >>= fun () -> may_register_my_id_point pool err ; log pool (Authentication_failed point) ; if incoming then - Point.Table.remove pool.incoming point + P2p_point.Table.remove pool.incoming point else - Option.iter ~f:Point_info.State.set_disconnected point_info ; + Option.iter ~f:P2p_point.Pool_state.set_disconnected point_info ; Lwt.return (Error err) end >>=? fun (info, auth_fd) -> (* Authentication correct! *) lwt_debug "authenticate: %a -> auth %a" - Point.pp point - Connection_info.pp info >>= fun () -> + P2p_point.Id.pp point + P2p_connection.Info.pp info >>= fun () -> let remote_point_info = match info.id_point with | addr, Some port - when not (Point.Table.mem pool.my_id_points (addr, port)) -> + when not (P2p_point.Table.mem pool.my_id_points (addr, port)) -> Some (register_point pool info.peer_id (addr, port)) | _ -> None in let connection_point_info = @@ -653,22 +648,22 @@ and authenticate pool ?point_info canceler fd point = | Some _ as point_info, _ | _, (Some _ as point_info) -> point_info in let peer_info = register_peer pool info.peer_id in let acceptable_versions = - Version.common info.versions pool.message_config.versions + P2p_version.common info.versions pool.message_config.versions in let acceptable_point = Option.unopt_map connection_point_info ~default:(not pool.config.closed_network) ~f:begin fun connection_point_info -> - match Point_info.State.get connection_point_info with + match P2p_point.Pool_state.get connection_point_info with | Requested _ -> not incoming | Disconnected -> not pool.config.closed_network - || Point_info.trusted connection_point_info + || P2p_point.Pool_info.trusted connection_point_info | Accepted _ | Running _ -> false end in let acceptable_peer_id = - match Peer_info.State.get peer_info with + match P2p_peer.Pool_state.get peer_info with | Accepted _ -> (* TODO: in some circumstances cancel and accept... *) false @@ -676,41 +671,41 @@ and authenticate pool ?point_info canceler fd point = | Disconnected -> true in if incoming then - Point.Table.remove pool.incoming point ; + P2p_point.Table.remove pool.incoming point ; match acceptable_versions with | Some version when acceptable_peer_id && acceptable_point -> begin log pool (Accepting_request (point, info.id_point, info.peer_id)) ; Option.iter connection_point_info ~f:(fun point_info -> - Point_info.State.set_accepted point_info info.peer_id canceler) ; - Peer_info.State.set_accepted peer_info info.id_point canceler ; + P2p_point.Pool_state.set_accepted point_info info.peer_id canceler) ; + P2p_peer.Pool_state.set_accepted peer_info info.id_point canceler ; lwt_debug "authenticate: %a -> accept %a" - Point.pp point - Connection_info.pp info >>= fun () -> + P2p_point.Id.pp point + P2p_connection.Info.pp info >>= fun () -> Lwt_utils.protect ~canceler begin fun () -> - P2p_connection.accept + P2p_socket.accept ?incoming_message_queue_size:pool.config.incoming_message_queue_size ?outgoing_message_queue_size:pool.config.outgoing_message_queue_size ?binary_chunks_size:pool.config.binary_chunks_size auth_fd pool.encoding >>= fun conn -> lwt_debug "authenticate: %a -> Connected %a" - Point.pp point - Connection_info.pp info >>= fun () -> + P2p_point.Id.pp point + P2p_connection.Info.pp info >>= fun () -> Lwt.return conn end ~on_error: begin fun err -> if incoming then log pool (Request_rejected (point, Some (info.id_point, info.peer_id))) ; lwt_debug "authenticate: %a -> rejected %a" - Point.pp point - Connection_info.pp info >>= fun () -> + P2p_point.Id.pp point + P2p_connection.Info.pp info >>= fun () -> Option.iter connection_point_info - ~f:Point_info.State.set_disconnected ; - Peer_info.State.set_disconnected peer_info ; + ~f:P2p_point.Pool_state.set_disconnected ; + P2p_peer.Pool_state.set_disconnected peer_info ; Lwt.return (Error err) end >>=? fun conn -> let id_point = - match info.id_point, Option.map ~f:Point_info.point point_info with + match info.id_point, Option.map ~f:P2p_point.Pool_info.point point_info with | (addr, _), Some (_, port) -> addr, Some port | id_point, None -> id_point in return @@ -721,19 +716,19 @@ and authenticate pool ?point_info canceler fd point = | _ -> begin log pool (Rejecting_request (point, info.id_point, info.peer_id)) ; lwt_debug "authenticate: %a -> kick %a point: %B peer_id: %B" - Point.pp point - Connection_info.pp info + P2p_point.Id.pp point + P2p_connection.Info.pp info acceptable_point acceptable_peer_id >>= fun () -> - P2p_connection.kick auth_fd >>= fun () -> + P2p_socket.kick auth_fd >>= fun () -> if not incoming then begin - Option.iter ~f:Point_info.State.set_disconnected point_info ; - (* FIXME Peer_info.State.set_disconnected ~requested:true peer_info ; *) + Option.iter ~f:P2p_point.Pool_state.set_disconnected point_info ; + (* FIXME P2p_peer.Pool_state.set_disconnected ~requested:true peer_info ; *) end ; fail (Rejected info.peer_id) end and create_connection pool p2p_conn id_point point_info peer_info _version = - let peer_id = Peer_info.peer_id peer_info in + let peer_id = P2p_peer.Pool_info.peer_id peer_info in let canceler = Lwt_canceler.create () in let size = Option.map pool.config.incoming_app_message_queue_size @@ -759,30 +754,30 @@ and create_connection pool p2p_conn id_point point_info peer_info _version = last_sent_swap_request = None } in ignore (Lazy.force answerer) ; Option.iter point_info ~f:begin fun point_info -> - let point = Point_info.point point_info in - Point_info.State.set_running point_info peer_id conn ; - Point.Table.add pool.connected_points point point_info ; + let point = P2p_point.Pool_info.point point_info in + P2p_point.Pool_state.set_running point_info peer_id conn ; + P2p_point.Table.add pool.connected_points point point_info ; end ; log pool (Connection_established (id_point, peer_id)) ; - Peer_info.State.set_running peer_info id_point conn ; - Peer_id.Table.add pool.connected_peer_ids peer_id peer_info ; + P2p_peer.Pool_state.set_running peer_info id_point conn ; + P2p_peer.Table.add pool.connected_peer_ids peer_id peer_info ; Lwt_condition.broadcast pool.events.new_connection () ; Lwt_canceler.on_cancel canceler begin fun () -> lwt_debug "Disconnect: %a (%a)" - Peer_id.pp peer_id Id_point.pp id_point >>= fun () -> - Option.iter ~f:Point_info.State.set_disconnected point_info ; + P2p_peer.Id.pp peer_id P2p_connection.Id.pp id_point >>= fun () -> + Option.iter ~f:P2p_point.Pool_state.set_disconnected point_info ; log pool (Disconnection peer_id) ; - Peer_info.State.set_disconnected peer_info ; + P2p_peer.Pool_state.set_disconnected peer_info ; Option.iter point_info ~f:begin fun point_info -> - Point.Table.remove pool.connected_points (Point_info.point point_info) ; + P2p_point.Table.remove pool.connected_points (P2p_point.Pool_info.point point_info) ; end ; - Peer_id.Table.remove pool.connected_peer_ids peer_id ; + P2p_peer.Table.remove pool.connected_peer_ids peer_id ; if pool.config.max_connections <= active_connections pool then begin Lwt_condition.broadcast pool.events.too_many_connections () ; log pool Too_many_connections ; end ; Lwt_pipe.close messages ; - P2p_connection.close ~wait:conn.wait_close conn.conn + P2p_socket.close ~wait:conn.wait_close conn.conn end ; List.iter (fun f -> f peer_id conn) pool.new_connection_hook ; if active_connections pool < pool.config.min_connections then begin @@ -796,31 +791,31 @@ and disconnect ?(wait = false) conn = Answerer.shutdown (Lazy.force conn.answerer) and register_new_points pool conn = - let source_peer_id = Peer_info.peer_id conn.peer_info in + let source_peer_id = P2p_peer.Pool_info.peer_id conn.peer_info in fun points -> List.iter (register_new_point pool source_peer_id) points ; Lwt.return_unit and register_new_point pool _source_peer_id point = - if not (Point.Table.mem pool.my_id_points point) then + if not (P2p_point.Table.mem pool.my_id_points point) then ignore (register_point pool _source_peer_id point) and list_known_points pool _conn () = let knowns = - Point.Table.fold + P2p_point.Table.fold (fun _ point_info acc -> point_info :: acc) pool.known_points [] in let best_knowns = List.take_n ~compare:compare_known_point_info 50 knowns in - Lwt.return (List.map Point_info.point best_knowns) + Lwt.return (List.map P2p_point.Pool_info.point best_knowns) -and active_connections pool = Peer_id.Table.length pool.connected_peer_ids +and active_connections pool = P2p_peer.Table.length pool.connected_peer_ids and swap_request pool conn new_point _new_peer_id = - let source_peer_id = Peer_info.peer_id conn.peer_info in + let source_peer_id = P2p_peer.Pool_info.peer_id conn.peer_info in log pool (Swap_request_received { source = source_peer_id }) ; lwt_log_info - "Swap request received from %a" Peer_id.pp source_peer_id >>= fun () -> + "Swap request received from %a" P2p_peer.Id.pp source_peer_id >>= fun () -> (* Ignore if already connected to peer or already swapped less than seconds ago. *) let now = Time.now () in @@ -830,16 +825,16 @@ and swap_request pool conn new_point _new_peer_id = (Time.max pool.latest_succesfull_swap pool.latest_accepted_swap) in let new_point_info = register_point pool source_peer_id new_point in if span_since_last_swap < int_of_float pool.config.swap_linger - || not (Point_info.State.is_disconnected new_point_info) then begin + || not (P2p_point.Pool_state.is_disconnected new_point_info) then begin log pool (Swap_request_ignored { source = source_peer_id }) ; - lwt_log_info "Ignoring swap request from %a" Peer_id.pp source_peer_id + lwt_log_info "Ignoring swap request from %a" P2p_peer.Id.pp source_peer_id end else begin match Connection.random_lowid pool with | None -> lwt_log_info - "No swap candidate for %a" Peer_id.pp source_peer_id + "No swap candidate for %a" P2p_peer.Id.pp source_peer_id | Some (proposed_point, proposed_peer_id, _proposed_conn) -> - match P2p_connection.write_now + match P2p_socket.write_now conn.conn (Swap_ack (proposed_point, proposed_peer_id)) with | Ok true -> log pool (Swap_ack_sent { source = source_peer_id }) ; @@ -854,10 +849,10 @@ and swap_request pool conn new_point _new_peer_id = end and swap_ack pool conn new_point _new_peer_id = - let source_peer_id = Peer_info.peer_id conn.peer_info in + let source_peer_id = P2p_peer.Pool_info.peer_id conn.peer_info in log pool (Swap_ack_received { source = source_peer_id }) ; lwt_log_info - "Swap ack received from %a" Peer_id.pp source_peer_id >>= fun () -> + "Swap ack received from %a" P2p_peer.Id.pp source_peer_id >>= fun () -> match conn.last_sent_swap_request with | None -> Lwt.return_unit (* ignore *) | Some (_time, proposed_peer_id) -> @@ -869,13 +864,13 @@ and swap_ack pool conn new_point _new_peer_id = Lwt.return_unit and swap pool conn current_peer_id new_point = - let source_peer_id = Peer_info.peer_id conn.peer_info in + let source_peer_id = P2p_peer.Pool_info.peer_id conn.peer_info in pool.latest_accepted_swap <- Time.now () ; connect ~timeout:10. pool new_point >>= function | Ok _new_conn -> begin pool.latest_succesfull_swap <- Time.now () ; log pool (Swap_success { source = source_peer_id }) ; - lwt_log_info "Swap to %a succeeded" Point.pp new_point >>= fun () -> + lwt_log_info "Swap to %a succeeded" P2p_point.Id.pp new_point >>= fun () -> match Connection.find_by_peer_id pool current_peer_id with | None -> Lwt.return_unit | Some conn -> @@ -888,20 +883,20 @@ and swap pool conn current_peer_id new_point = match err with | [ Lwt_utils.Timeout ] -> lwt_debug "Swap to %a was interupted: %a" - Point.pp new_point pp_print_error err + P2p_point.Id.pp new_point pp_print_error err | _ -> lwt_log_error "Swap to %a failed: %a" - Point.pp new_point pp_print_error err + P2p_point.Id.pp new_point pp_print_error err end let accept pool fd point = log pool (Incoming_connection point) ; - if pool.config.max_incoming_connections <= Point.Table.length pool.incoming + if pool.config.max_incoming_connections <= P2p_point.Table.length pool.incoming || pool.config.max_connections <= active_connections pool then Lwt.async (fun () -> Lwt_utils.safe_close fd) else let canceler = Lwt_canceler.create () in - Point.Table.add pool.incoming point canceler ; + P2p_point.Table.add pool.incoming point canceler ; Lwt.async begin fun () -> Lwt_utils.with_timeout ~canceler pool.config.authentification_timeout @@ -919,7 +914,7 @@ let send_swap_request pool = log pool (Swap_request_sent { source = recipient_peer_id }) ; recipient.last_sent_swap_request <- Some (Time.now (), proposed_peer_id) ; - ignore (P2p_connection.write_now recipient.conn + ignore (P2p_socket.write_now recipient.conn (Swap_request (proposed_point, proposed_peer_id))) (***************************************************************************) @@ -933,12 +928,12 @@ let create config meta_config message_config io_sched = } in let pool = { config ; meta_config ; message_config ; - my_id_points = Point.Table.create 7 ; - known_peer_ids = Peer_id.Table.create 53 ; - connected_peer_ids = Peer_id.Table.create 53 ; - known_points = Point.Table.create 53 ; - connected_points = Point.Table.create 53 ; - incoming = Point.Table.create 53 ; + my_id_points = P2p_point.Table.create 7 ; + known_peer_ids = P2p_peer.Table.create 53 ; + connected_peer_ids = P2p_peer.Table.create 53 ; + known_points = P2p_point.Table.create 53 ; + connected_points = P2p_point.Table.create 53 ; + incoming = P2p_point.Table.create 53 ; io_sched ; encoding = Message.encoding message_config.encoding ; events ; @@ -948,12 +943,12 @@ let create config meta_config message_config io_sched = latest_succesfull_swap = Time.epoch ; } in List.iter (Points.set_trusted pool) config.trusted_points ; - Peer_info.File.load config.peers_file meta_config.encoding >>= function + P2p_peer.Pool_info.File.load config.peers_file meta_config.encoding >>= function | Ok peer_ids -> List.iter (fun peer_info -> - let peer_id = Peer_info.peer_id peer_info in - Peer_id.Table.add pool.known_peer_ids peer_id peer_info) + let peer_id = P2p_peer.Pool_info.peer_id peer_info in + P2p_peer.Table.add pool.known_peer_ids peer_id peer_info) peer_ids ; Lwt.return pool | Error err -> @@ -962,23 +957,23 @@ let create config meta_config message_config io_sched = Lwt.return pool let destroy pool = - Point.Table.fold (fun _point point_info acc -> - match Point_info.State.get point_info with + P2p_point.Table.fold (fun _point point_info acc -> + match P2p_point.Pool_state.get point_info with | Requested { cancel } | Accepted { cancel } -> Lwt_canceler.cancel cancel >>= fun () -> acc | Running { data = conn } -> disconnect conn >>= fun () -> acc | Disconnected -> acc) pool.known_points @@ - Peer_id.Table.fold (fun _peer_id peer_info acc -> - match Peer_info.State.get peer_info with + P2p_peer.Table.fold (fun _peer_id peer_info acc -> + match P2p_peer.Pool_state.get peer_info with | Accepted { cancel } -> Lwt_canceler.cancel cancel >>= fun () -> acc | Running { data = conn } -> disconnect conn >>= fun () -> acc | Disconnected -> acc) pool.known_peer_ids @@ - Point.Table.fold (fun _point canceler acc -> + P2p_point.Table.fold (fun _point canceler acc -> Lwt_canceler.cancel canceler >>= fun () -> acc) pool.incoming Lwt.return_unit diff --git a/src/lib_p2p/p2p_connection_pool.mli b/src/lib_p2p/p2p_pool.mli similarity index 81% rename from src/lib_p2p/p2p_connection_pool.mli rename to src/lib_p2p/p2p_pool.mli index e24084763..2f33715e5 100644 --- a/src/lib_p2p/p2p_connection_pool.mli +++ b/src/lib_p2p/p2p_pool.mli @@ -22,9 +22,6 @@ worker and thus never propagated above. *) -open P2p_types -open P2p_connection_pool_types - type 'msg encoding = Encoding : { tag: int ; encoding: 'a Data_encoding.t ; @@ -43,13 +40,13 @@ type ('msg, 'meta) pool = ('msg, 'meta) t type config = { - identity : Identity.t ; + identity : P2p_identity.t ; (** Our identity. *) proof_of_work_target : Crypto_box.target ; (** The proof of work target we require from peers. *) - trusted_points : Point.t list ; + trusted_points : P2p_point.Id.t list ; (** List of hard-coded known peers to bootstrap the network from. *) peers_file : string ; @@ -60,7 +57,7 @@ type config = { (** If [true], the only accepted connections are from peers whose addresses are in [trusted_peers]. *) - listening_port : port option ; + listening_port : P2p_addr.port option ; (** If provided, it will be passed to [P2p_connection.authenticate] when we authenticate against a new peer. *) @@ -126,7 +123,7 @@ type 'meta meta_config = { type 'msg message_config = { encoding : 'msg encoding list ; - versions : P2p_types.Version.t list; + versions : P2p_version.t list; } val create: @@ -146,7 +143,7 @@ val active_connections: ('msg, 'meta) pool -> int (** [active_connections pool] is the number of connections inside [pool]. *) -val pool_stat: ('msg, 'meta) pool -> Stat.t +val pool_stat: ('msg, 'meta) pool -> P2p_stat.t (** [pool_stat pool] is a snapshot of current bandwidth usage for the entire [pool]. *) @@ -186,19 +183,19 @@ type ('msg, 'meta) connection type error += Pending_connection type error += Connected type error += Connection_refused -type error += Rejected of Peer_id.t +type error += Rejected of P2p_peer.Id.t type error += Too_many_connections type error += Closed_network val connect: timeout:float -> - ('msg, 'meta) pool -> Point.t -> + ('msg, 'meta) pool -> P2p_point.Id.t -> ('msg, 'meta) connection tzresult Lwt.t (** [connect ~timeout pool point] tries to add a connection to [point] in [pool] in less than [timeout] seconds. *) val accept: - ('msg, 'meta) pool -> Lwt_unix.file_descr -> Point.t -> unit + ('msg, 'meta) pool -> Lwt_unix.file_descr -> P2p_point.Id.t -> unit (** [accept pool fd point] instructs [pool] to start the process of accepting a connection from [fd]. Used by [P2p]. *) @@ -209,32 +206,32 @@ val disconnect: module Connection : sig - val info: ('msg, 'meta) connection -> Connection_info.t + val info: ('msg, 'meta) connection -> P2p_connection.Info.t - val stat: ('msg, 'meta) connection -> Stat.t + val stat: ('msg, 'meta) connection -> P2p_stat.t (** [stat conn] is a snapshot of current bandwidth usage for [conn]. *) val fold: ('msg, 'meta) pool -> init:'a -> - f:(Peer_id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> + f:(P2p_peer.Id.t -> ('msg, 'meta) connection -> 'a -> 'a) -> 'a val list: - ('msg, 'meta) pool -> (Peer_id.t * ('msg, 'meta) connection) list + ('msg, 'meta) pool -> (P2p_peer.Id.t * ('msg, 'meta) connection) list val find_by_point: - ('msg, 'meta) pool -> Point.t -> ('msg, 'meta) connection option + ('msg, 'meta) pool -> P2p_point.Id.t -> ('msg, 'meta) connection option val find_by_peer_id: - ('msg, 'meta) pool -> Peer_id.t -> ('msg, 'meta) connection option + ('msg, 'meta) pool -> P2p_peer.Id.t -> ('msg, 'meta) connection option end val on_new_connection: ('msg, 'meta) pool -> - (Peer_id.t -> ('msg, 'meta) connection -> unit) -> unit + (P2p_peer.Id.t -> ('msg, 'meta) connection -> unit) -> unit (** {1 I/O on connections} *) @@ -277,31 +274,31 @@ val broadcast_bootstrap_msg: ('msg, 'meta) pool -> unit (** {1 Functions on [Peer_id]} *) -module Peer_ids : sig +module Peers : sig - type ('msg, 'meta) info = (('msg, 'meta) connection, 'meta) Peer_info.t + type ('msg, 'meta) info = (('msg, 'meta) connection, 'meta) P2p_peer.Pool_info.t val info: - ('msg, 'meta) pool -> Peer_id.t -> ('msg, 'meta) info option + ('msg, 'meta) pool -> P2p_peer.Id.t -> ('msg, 'meta) info option - val get_metadata: ('msg, 'meta) pool -> Peer_id.t -> 'meta - val set_metadata: ('msg, 'meta) pool -> Peer_id.t -> 'meta -> unit - val get_score: ('msg, 'meta) pool -> Peer_id.t -> float + val get_metadata: ('msg, 'meta) pool -> P2p_peer.Id.t -> 'meta + val set_metadata: ('msg, 'meta) pool -> P2p_peer.Id.t -> 'meta -> unit + val get_score: ('msg, 'meta) pool -> P2p_peer.Id.t -> float - val get_trusted: ('msg, 'meta) pool -> Peer_id.t -> bool - val set_trusted: ('msg, 'meta) pool -> Peer_id.t -> unit - val unset_trusted: ('msg, 'meta) pool -> Peer_id.t -> unit + val get_trusted: ('msg, 'meta) pool -> P2p_peer.Id.t -> bool + val set_trusted: ('msg, 'meta) pool -> P2p_peer.Id.t -> unit + val unset_trusted: ('msg, 'meta) pool -> P2p_peer.Id.t -> unit val fold_known: ('msg, 'meta) pool -> init:'a -> - f:(Peer_id.t -> ('msg, 'meta) info -> 'a -> 'a) -> + f:(P2p_peer.Id.t -> ('msg, 'meta) info -> 'a -> 'a) -> 'a val fold_connected: ('msg, 'meta) pool -> init:'a -> - f:(Peer_id.t -> ('msg, 'meta) info -> 'a -> 'a) -> + f:(P2p_peer.Id.t -> ('msg, 'meta) info -> 'a -> 'a) -> 'a end @@ -310,32 +307,30 @@ end module Points : sig - type ('msg, 'meta) info = ('msg, 'meta) connection Point_info.t + type ('msg, 'meta) info = ('msg, 'meta) connection P2p_point.Pool_info.t val info: - ('msg, 'meta) pool -> Point.t -> ('msg, 'meta) info option + ('msg, 'meta) pool -> P2p_point.Id.t -> ('msg, 'meta) info option - val get_trusted: ('msg, 'meta) pool -> Point.t -> bool - val set_trusted: ('msg, 'meta) pool -> Point.t -> unit - val unset_trusted: ('msg, 'meta) pool -> Point.t -> unit + val get_trusted: ('msg, 'meta) pool -> P2p_point.Id.t -> bool + val set_trusted: ('msg, 'meta) pool -> P2p_point.Id.t -> unit + val unset_trusted: ('msg, 'meta) pool -> P2p_point.Id.t -> unit val fold_known: ('msg, 'meta) pool -> init:'a -> - f:(Point.t -> ('msg, 'meta) info -> 'a -> 'a) -> + f:(P2p_point.Id.t -> ('msg, 'meta) info -> 'a -> 'a) -> 'a val fold_connected: ('msg, 'meta) pool -> init:'a -> - f:(Point.t -> ('msg, 'meta) info -> 'a -> 'a) -> + f:(P2p_point.Id.t -> ('msg, 'meta) info -> 'a -> 'a) -> 'a end -module Log_event = Connection_pool_log_event - -val watch: ('msg, 'meta) pool -> Log_event.t Lwt_stream.t * Lwt_watcher.stopper +val watch: ('msg, 'meta) pool -> P2p_connection.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper (** [watch pool] is a [stream, close] a [stream] of events and a [close] function for this stream. *) @@ -345,9 +340,9 @@ module Message : sig type 'msg t = | Bootstrap - | Advertise of Point.t list - | Swap_request of Point.t * Peer_id.t - | Swap_ack of Point.t * Peer_id.t + | Advertise of P2p_point.Id.t list + | Swap_request of P2p_point.Id.t * P2p_peer.Id.t + | Swap_ack of P2p_point.Id.t * P2p_peer.Id.t | Message of 'msg | Disconnect diff --git a/src/lib_p2p/p2p_connection.ml b/src/lib_p2p/p2p_socket.ml similarity index 92% rename from src/lib_p2p/p2p_connection.ml rename to src/lib_p2p/p2p_socket.ml index 08b315ecb..202d94739 100644 --- a/src/lib_p2p/p2p_connection.ml +++ b/src/lib_p2p/p2p_socket.ml @@ -19,8 +19,6 @@ infinitly. This would avoid the real peer to talk with us. And this might also have an influence on its "score". *) -open P2p_types - include Logging.Make(struct let name = "p2p.connection" end) type error += Decipher_error @@ -28,8 +26,8 @@ type error += Invalid_message_size type error += Encoding_error type error += Rejected type error += Decoding_error -type error += Myself of Id_point.t -type error += Not_enough_proof_of_work of Peer_id.t +type error += Myself of P2p_connection.Id.t +type error += Not_enough_proof_of_work of P2p_peer.Id.t type error += Invalid_auth type error += Invalid_chunks_size of { value: int ; min: int ; max: int } @@ -94,7 +92,7 @@ module Connection_message = struct type t = { port : int option ; - versions : Version.t list ; + versions : P2p_version.t list ; public_key : Crypto_box.public_key ; proof_of_work_stamp : Crypto_box.nonce ; message_nonce : Crypto_box.nonce ; @@ -118,7 +116,7 @@ module Connection_message = struct (req "pubkey" Crypto_box.public_key_encoding) (req "proof_of_work_stamp" Crypto_box.nonce_encoding) (req "message_nonce" Crypto_box.nonce_encoding) - (req "versions" (Variable.list Version.encoding))) + (req "versions" (Variable.list P2p_version.encoding))) let write fd message = let encoded_message_len = @@ -172,7 +170,7 @@ module Ack = struct end type authenticated_fd = - P2p_io_scheduler.connection * Connection_info.t * Crypto.data + P2p_io_scheduler.connection * P2p_connection.Info.t * Crypto.data let kick (fd, _ , cryptobox_data) = Ack.write fd cryptobox_data Nack >>= fun _ -> @@ -187,9 +185,9 @@ let authenticate ~incoming fd (remote_addr, remote_socket_port as point) ?listening_port identity supported_versions = let local_nonce = Crypto_box.random_nonce () in - lwt_debug "Sending authenfication to %a" Point.pp point >>= fun () -> + lwt_debug "Sending authenfication to %a" P2p_point.Id.pp point >>= fun () -> Connection_message.write fd - { public_key = identity.Identity.public_key ; + { public_key = identity.P2p_identity.public_key ; proof_of_work_stamp = identity.proof_of_work_stamp ; message_nonce = local_nonce ; port = listening_port ; @@ -200,16 +198,16 @@ let authenticate let id_point = remote_addr, remote_listening_port in let remote_peer_id = Crypto_box.hash msg.public_key in fail_unless - (remote_peer_id <> identity.Identity.peer_id) + (remote_peer_id <> identity.P2p_identity.peer_id) (Myself id_point) >>=? fun () -> fail_unless (Crypto_box.check_proof_of_work msg.public_key msg.proof_of_work_stamp proof_of_work_target) (Not_enough_proof_of_work remote_peer_id) >>=? fun () -> let channel_key = - Crypto_box.precompute identity.Identity.secret_key msg.public_key in + Crypto_box.precompute identity.P2p_identity.secret_key msg.public_key in let info = - { Connection_info.peer_id = remote_peer_id ; + { P2p_connection.Info.peer_id = remote_peer_id ; versions = msg.versions ; incoming ; id_point ; remote_socket_port ;} in let cryptobox_data = @@ -219,7 +217,7 @@ let authenticate type connection = { id : int ; - info : Connection_info.t ; + info : P2p_connection.Info.t ; fd : P2p_io_scheduler.connection ; cryptobox_data : Crypto.data ; } @@ -254,7 +252,7 @@ module Reader = struct end >>=? fun buf -> lwt_debug "reading %d bytes from %a" - (MBytes.length buf) Connection_info.pp st.conn.info >>= fun () -> + (MBytes.length buf) P2p_connection.Info.pp st.conn.info >>= fun () -> loop (decode_next_buf buf) in loop (Data_encoding.Binary.read_stream_of_bytes ~init:init_mbytes st.encoding) @@ -282,7 +280,7 @@ module Reader = struct Lwt.return_unit | Error [Lwt_utils.Canceled | Exn Lwt_pipe.Closed] -> lwt_debug "connection closed to %a" - Connection_info.pp st.conn.info >>= fun () -> + P2p_connection.Info.pp st.conn.info >>= fun () -> Lwt.return_unit | Error _ as err -> Lwt_pipe.safe_push_now st.messages err ; @@ -335,7 +333,7 @@ module Writer = struct Crypto.write_chunk st.conn.fd st.conn.cryptobox_data buf end >>=? fun () -> lwt_debug "writing %d bytes to %a" - (MBytes.length buf) Connection_info.pp st.conn.info >>= fun () -> + (MBytes.length buf) P2p_connection.Info.pp st.conn.info >>= fun () -> loop l in loop buf @@ -350,12 +348,12 @@ module Writer = struct end >>= function | Error [Lwt_utils.Canceled | Exn Lwt_pipe.Closed] -> lwt_debug "connection closed to %a" - Connection_info.pp st.conn.info >>= fun () -> + P2p_connection.Info.pp st.conn.info >>= fun () -> Lwt.return_unit | Error err -> lwt_log_error "@[error writing to %a@ %a@]" - Connection_info.pp st.conn.info pp_print_error err >>= fun () -> + P2p_connection.Info.pp st.conn.info pp_print_error err >>= fun () -> Lwt_canceler.cancel st.canceler >>= fun () -> Lwt.return_unit | Ok (buf, wakener) -> @@ -372,17 +370,17 @@ module Writer = struct match err with | [ Lwt_utils.Canceled | Exn Lwt_pipe.Closed ] -> lwt_debug "connection closed to %a" - Connection_info.pp st.conn.info >>= fun () -> + P2p_connection.Info.pp st.conn.info >>= fun () -> Lwt.return_unit | [ P2p_io_scheduler.Connection_closed ] -> lwt_debug "connection closed to %a" - Connection_info.pp st.conn.info >>= fun () -> + P2p_connection.Info.pp st.conn.info >>= fun () -> Lwt_canceler.cancel st.canceler >>= fun () -> Lwt.return_unit | err -> lwt_log_error "@[error writing to %a@ %a@]" - Connection_info.pp st.conn.info + P2p_connection.Info.pp st.conn.info pp_print_error err >>= fun () -> Lwt_canceler.cancel st.canceler >>= fun () -> Lwt.return_unit @@ -447,7 +445,7 @@ type 'msg t = { let equal { conn = { id = id1 } } { conn = { id = id2 } } = id1 = id2 -let pp ppf { conn } = Connection_info.pp ppf conn.info +let pp ppf { conn } = P2p_connection.Info.pp ppf conn.info let info { conn } = conn.info let accept @@ -497,7 +495,7 @@ let pp_json encoding ppf msg = let write { writer ; conn } msg = catch_closed_pipe begin fun () -> debug "Sending message to %a: %a" - P2p_types.Peer_id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; + P2p_peer.Id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; Lwt.return (Writer.encode_message writer msg) >>=? fun buf -> Lwt_pipe.push writer.messages (buf, None) >>= return end @@ -506,7 +504,7 @@ let write_sync { writer ; conn } msg = catch_closed_pipe begin fun () -> let waiter, wakener = Lwt.wait () in debug "Sending message to %a: %a" - P2p_types.Peer_id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; + P2p_peer.Id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; Lwt.return (Writer.encode_message writer msg) >>=? fun buf -> Lwt_pipe.push writer.messages (buf, Some wakener) >>= fun () -> waiter @@ -514,7 +512,7 @@ let write_sync { writer ; conn } msg = let write_now { writer ; conn } msg = debug "Try sending message to %a: %a" - P2p_types.Peer_id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; + P2p_peer.Id.pp_short conn.info.peer_id (pp_json writer.encoding) msg ; Writer.encode_message writer msg >>? fun buf -> try Ok (Lwt_pipe.push_now writer.messages (buf, None)) with Lwt_pipe.Closed -> Error [P2p_io_scheduler.Connection_closed] diff --git a/src/lib_p2p/p2p_connection.mli b/src/lib_p2p/p2p_socket.mli similarity index 93% rename from src/lib_p2p/p2p_connection.mli rename to src/lib_p2p/p2p_socket.mli index ffa9379de..37b297831 100644 --- a/src/lib_p2p/p2p_connection.mli +++ b/src/lib_p2p/p2p_socket.mli @@ -15,8 +15,6 @@ limited by providing corresponding arguments to [accept]. *) -open P2p_types - (** {1 Types} *) type error += Decipher_error @@ -24,8 +22,8 @@ type error += Invalid_message_size type error += Encoding_error type error += Decoding_error type error += Rejected -type error += Myself of Id_point.t -type error += Not_enough_proof_of_work of Peer_id.t +type error += Myself of P2p_connection.Id.t +type error += Not_enough_proof_of_work of P2p_peer.Id.t type error += Invalid_auth type error += Invalid_chunks_size of { value: int ; min: int ; max: int } @@ -40,17 +38,17 @@ type 'msg t val equal: 'mst t -> 'msg t -> bool val pp: Format.formatter -> 'msg t -> unit -val info: 'msg t -> Connection_info.t +val info: 'msg t -> P2p_connection.Info.t (** {1 Low-level functions (do not use directly)} *) val authenticate: proof_of_work_target:Crypto_box.target -> incoming:bool -> - P2p_io_scheduler.connection -> Point.t -> + P2p_io_scheduler.connection -> P2p_point.Id.t -> ?listening_port: int -> - Identity.t -> Version.t list -> - (Connection_info.t * authenticated_fd) tzresult Lwt.t + P2p_identity.t -> P2p_version.t list -> + (P2p_connection.Info.t * authenticated_fd) tzresult Lwt.t (** (Low-level) (Cancelable) Authentication function of a remote peer. Used in [P2p_connection_pool], to promote a [P2P_io_scheduler.connection] into an [authenticated_fd] (auth @@ -112,7 +110,7 @@ val read_now: 'msg t -> (int * 'msg) tzresult option is not empty, [None] if it is empty, or fails with a correponding error otherwise. *) -val stat: 'msg t -> Stat.t +val stat: 'msg t -> P2p_stat.t (** [stat conn] is a snapshot of current bandwidth usage for [conn]. *) diff --git a/src/lib_p2p/p2p_welcome.ml b/src/lib_p2p/p2p_welcome.ml index 8a3c311d6..fefe210ad 100644 --- a/src/lib_p2p/p2p_welcome.ml +++ b/src/lib_p2p/p2p_welcome.ml @@ -9,7 +9,7 @@ include Logging.Make (struct let name = "p2p.welcome" end) -type pool = Pool : ('msg, 'meta) P2p_connection_pool.t -> pool +type pool = Pool : ('msg, 'meta) P2p_pool.t -> pool type t = { socket: Lwt_unix.file_descr ; @@ -30,7 +30,7 @@ let rec worker_loop st = | Lwt_unix.ADDR_UNIX _ -> assert false | Lwt_unix.ADDR_INET (addr, port) -> (Ipaddr_unix.V6.of_inet_addr_exn addr, port) in - P2p_connection_pool.accept pool fd point ; + P2p_pool.accept pool fd point ; worker_loop st | Error [Lwt_utils.Canceled] -> Lwt.return_unit diff --git a/src/lib_p2p/p2p_welcome.mli b/src/lib_p2p/p2p_welcome.mli index e325046a7..1a0403b3a 100644 --- a/src/lib_p2p/p2p_welcome.mli +++ b/src/lib_p2p/p2p_welcome.mli @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open P2p_types - (** Welcome worker. Accept incoming connections and add them to its connection pool. *) @@ -18,8 +16,8 @@ type t val run: backlog:int -> - ('msg, 'meta) P2p_connection_pool.t -> - ?addr:addr -> port -> t Lwt.t + ('msg, 'meta) P2p_pool.t -> + ?addr:P2p_addr.t -> P2p_addr.port -> t Lwt.t (** [run ~backlog ~addr pool port] returns a running welcome worker feeding [pool] listening at [(addr, port)]. [backlog] is the argument passed to [Lwt_unix.accept]. *) diff --git a/src/lib_p2p_services/p2p_connection_pool_types.ml b/src/lib_p2p_services/p2p_connection_pool_types.ml deleted file mode 100644 index 929513e99..000000000 --- a/src/lib_p2p_services/p2p_connection_pool_types.ml +++ /dev/null @@ -1,526 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -open P2p_types - -module Point_info = struct - - type 'data state = - | Requested of { cancel: Lwt_canceler.t } - | Accepted of { current_peer_id: Peer_id.t ; - cancel: Lwt_canceler.t } - | Running of { data: 'data ; - current_peer_id: Peer_id.t } - | Disconnected - - module Event = struct - - type kind = - | Outgoing_request - | Accepting_request of Peer_id.t - | Rejecting_request of Peer_id.t - | Request_rejected of Peer_id.t option - | Connection_established of Peer_id.t - | Disconnection of Peer_id.t - | External_disconnection of Peer_id.t - - let kind_encoding = - let open Data_encoding in - let branch_encoding name obj = - conv (fun x -> (), x) (fun ((), x) -> x) - (merge_objs - (obj1 (req "event_kind" (constant name))) obj) in - union ~tag_size:`Uint8 [ - case (Tag 0) (branch_encoding "outgoing_request" empty) - (function Outgoing_request -> Some () | _ -> None) - (fun () -> Outgoing_request) ; - case (Tag 1) (branch_encoding "accepting_request" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Accepting_request peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Accepting_request peer_id) ; - case (Tag 2) (branch_encoding "rejecting_request" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Rejecting_request peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Rejecting_request peer_id) ; - case (Tag 3) (branch_encoding "request_rejected" - (obj1 (opt "peer_id" Peer_id.encoding))) - (function Request_rejected peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Request_rejected peer_id) ; - case (Tag 4) (branch_encoding "rejecting_request" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Connection_established peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Connection_established peer_id) ; - case (Tag 5) (branch_encoding "rejecting_request" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Disconnection peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Disconnection peer_id) ; - case (Tag 6) (branch_encoding "rejecting_request" - (obj1 (req "peer_id" Peer_id.encoding))) - (function External_disconnection peer_id -> Some peer_id | _ -> None) - (fun peer_id -> External_disconnection peer_id) ; - ] - - type t = { - kind : kind ; - timestamp : Time.t ; - } - - let encoding = - let open Data_encoding in - conv - (fun { kind ; timestamp ; } -> (kind, timestamp)) - (fun (kind, timestamp) -> { kind ; timestamp ; }) - (obj2 - (req "kind" kind_encoding) - (req "timestamp" Time.encoding)) - end - - type greylisting_config = { - factor: float ; - initial_delay: int ; - disconnection_delay: int ; - } - - type 'data t = { - point : Point.t ; - mutable trusted : bool ; - mutable state : 'data state ; - mutable last_failed_connection : Time.t option ; - mutable last_rejected_connection : (Peer_id.t * Time.t) option ; - mutable last_established_connection : (Peer_id.t * Time.t) option ; - mutable last_disconnection : (Peer_id.t * Time.t) option ; - greylisting : greylisting_config ; - mutable greylisting_delay : float ; - mutable greylisting_end : Time.t ; - events : Event.t Ring.t ; - watchers : Event.t Lwt_watcher.input ; - } - type 'data point_info = 'data t - - let compare pi1 pi2 = Point.compare pi1.point pi2.point - - let log_size = 100 - - let default_greylisting_config = { - factor = 1.2 ; - initial_delay = 1 ; - disconnection_delay = 60 ; - } - - let create - ?(trusted = false) - ?(greylisting_config = default_greylisting_config) addr port = { - point = (addr, port) ; - trusted ; - state = Disconnected ; - last_failed_connection = None ; - last_rejected_connection = None ; - last_established_connection = None ; - last_disconnection = None ; - events = Ring.create log_size ; - greylisting = greylisting_config ; - greylisting_delay = 1. ; - greylisting_end = Time.epoch ; - watchers = Lwt_watcher.create_input () ; - } - - let point s = s.point - let trusted s = s.trusted - let set_trusted gi = gi.trusted <- true - let unset_trusted gi = gi.trusted <- false - let last_established_connection s = s.last_established_connection - let last_disconnection s = s.last_disconnection - let last_failed_connection s = s.last_failed_connection - let last_rejected_connection s = s.last_rejected_connection - let greylisted ?(now = Time.now ()) s = - Time.compare now s.greylisting_end <= 0 - let greylisted_until s = s.greylisting_end - - let recent a1 a2 = - match a1, a2 with - | (None, None) -> None - | (None, (Some _ as a)) - | (Some _ as a, None) -> a - | (Some (_, t1), Some (_, t2)) -> - if Time.compare t1 t2 < 0 then a2 else a1 - let last_seen s = - recent s.last_rejected_connection - (recent s.last_established_connection s.last_disconnection) - let last_miss s = - match - s.last_failed_connection, - (Option.map ~f:(fun (_, time) -> time) @@ - recent s.last_rejected_connection s.last_disconnection) with - | (None, None) -> None - | (None, (Some _ as a)) - | (Some _ as a, None) -> a - | (Some t1 as a1 , (Some t2 as a2)) -> - if Time.compare t1 t2 < 0 then a2 else a1 - - let fold_events { events ; _ } ~init ~f = Ring.fold events ~init ~f - - let watch { watchers ; _ } = Lwt_watcher.create_stream watchers - - let log { events ; watchers ; _ } ?(timestamp = Time.now ()) kind = - let event = { Event.kind ; timestamp } in - Ring.add events event ; - Lwt_watcher.notify watchers event - - let log_incoming_rejection ?timestamp point_info peer_id = - log point_info ?timestamp (Rejecting_request peer_id) - - module State = struct - - type 'data t = 'data state = - | Requested of { cancel: Lwt_canceler.t } - | Accepted of { current_peer_id: Peer_id.t ; - cancel: Lwt_canceler.t } - | Running of { data: 'data ; - current_peer_id: Peer_id.t } - | Disconnected - type 'data state = 'data t - - let pp ppf = function - | Requested _ -> - Format.fprintf ppf "requested" - | Accepted { current_peer_id ; _ } -> - Format.fprintf ppf "accepted %a" Peer_id.pp current_peer_id - | Running { current_peer_id ; _ } -> - Format.fprintf ppf "running %a" Peer_id.pp current_peer_id - | Disconnected -> - Format.fprintf ppf "disconnected" - - let get { state ; _ } = state - - let is_disconnected { state ; _ } = - match state with - | Disconnected -> true - | Requested _ | Accepted _ | Running _ -> false - - let set_requested ?timestamp point_info cancel = - assert begin - match point_info.state with - | Requested _ -> true - | Accepted _ | Running _ -> false - | Disconnected -> true - end ; - point_info.state <- Requested { cancel } ; - log point_info ?timestamp Outgoing_request - - let set_accepted - ?(timestamp = Time.now ()) - point_info current_peer_id cancel = - (* log_notice "SET_ACCEPTED %a@." Point.pp point_info.point ; *) - assert begin - match point_info.state with - | Accepted _ | Running _ -> false - | Requested _ | Disconnected -> true - end ; - point_info.state <- Accepted { current_peer_id ; cancel } ; - log point_info ~timestamp (Accepting_request current_peer_id) - - let set_running - ?(timestamp = Time.now ()) - point_info peer_id data = - assert begin - match point_info.state with - | Disconnected -> true (* request to unknown peer_id. *) - | Running _ -> false - | Accepted { current_peer_id ; _ } -> Peer_id.equal peer_id current_peer_id - | Requested _ -> true - end ; - point_info.state <- Running { data ; current_peer_id = peer_id } ; - point_info.last_established_connection <- Some (peer_id, timestamp) ; - log point_info ~timestamp (Connection_established peer_id) - - let set_greylisted timestamp point_info = - point_info.greylisting_end <- - Time.add - timestamp - (Int64.of_float point_info.greylisting_delay) ; - point_info.greylisting_delay <- - point_info.greylisting_delay *. point_info.greylisting.factor - - let set_disconnected - ?(timestamp = Time.now ()) ?(requested = false) point_info = - let event : Event.kind = - match point_info.state with - | Requested _ -> - set_greylisted timestamp point_info ; - point_info.last_failed_connection <- Some timestamp ; - Request_rejected None - | Accepted { current_peer_id ; _ } -> - set_greylisted timestamp point_info ; - point_info.last_rejected_connection <- - Some (current_peer_id, timestamp) ; - Request_rejected (Some current_peer_id) - | Running { current_peer_id ; _ } -> - point_info.greylisting_delay <- - float_of_int point_info.greylisting.initial_delay ; - point_info.greylisting_end <- - Time.add timestamp - (Int64.of_int point_info.greylisting.disconnection_delay) ; - point_info.last_disconnection <- Some (current_peer_id, timestamp) ; - if requested - then Disconnection current_peer_id - else External_disconnection current_peer_id - | Disconnected -> - assert false - in - point_info.state <- Disconnected ; - log point_info ~timestamp event - - end - -end - -module Peer_info = struct - - type 'data state = - | Accepted of { current_point: Id_point.t ; - cancel: Lwt_canceler.t } - | Running of { data: 'data ; - current_point: Id_point.t } - | Disconnected - - module Event = struct - - type kind = - | Accepting_request - | Rejecting_request - | Request_rejected - | Connection_established - | Disconnection - | External_disconnection - - let kind_encoding = - Data_encoding.string_enum [ - "incoming_request", Accepting_request ; - "rejecting_request", Rejecting_request ; - "request_rejected", Request_rejected ; - "connection_established", Connection_established ; - "disconnection", Disconnection ; - "external_disconnection", External_disconnection ; - ] - - type t = { - kind : kind ; - timestamp : Time.t ; - point : Id_point.t ; - } - - let encoding = - let open Data_encoding in - conv - (fun { kind ; timestamp ; point = (addr, port) } -> - (kind, timestamp, addr, port)) - (fun (kind, timestamp, addr, port) -> - { kind ; timestamp ; point = (addr, port) }) - (obj4 - (req "kind" kind_encoding) - (req "timestamp" Time.encoding) - (req "addr" P2p_types.addr_encoding) - (opt "port" int16)) - - end - - type ('conn, 'meta) t = { - peer_id : Peer_id.t ; - created : Time.t ; - mutable state : 'conn state ; - mutable metadata : 'meta ; - mutable trusted : bool ; - mutable last_failed_connection : (Id_point.t * Time.t) option ; - mutable last_rejected_connection : (Id_point.t * Time.t) option ; - mutable last_established_connection : (Id_point.t * Time.t) option ; - mutable last_disconnection : (Id_point.t * Time.t) option ; - events : Event.t Ring.t ; - watchers : Event.t Lwt_watcher.input ; - } - type ('conn, 'meta) peer_info = ('conn, 'meta) t - - let compare gi1 gi2 = Peer_id.compare gi1.peer_id gi2.peer_id - - let log_size = 100 - - let create ?(created = Time.now ()) ?(trusted = false) ~metadata peer_id = - { peer_id ; - created ; - state = Disconnected ; - metadata ; - trusted ; - last_failed_connection = None ; - last_rejected_connection = None ; - last_established_connection = None ; - last_disconnection = None ; - events = Ring.create log_size ; - watchers = Lwt_watcher.create_input () ; - } - - let encoding metadata_encoding = - let open Data_encoding in - conv - (fun { peer_id ; trusted ; metadata ; events ; created ; - last_failed_connection ; last_rejected_connection ; - last_established_connection ; last_disconnection ; _ } -> - (peer_id, created, trusted, metadata, Ring.elements events, - last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection)) - (fun (peer_id, created, trusted, metadata, event_list, - last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection) -> - let info = create ~trusted ~metadata peer_id in - let events = Ring.create log_size in - Ring.add_list info.events event_list ; - { state = Disconnected ; - trusted ; peer_id ; metadata ; created ; - last_failed_connection ; - last_rejected_connection ; - last_established_connection ; - last_disconnection ; - events ; - watchers = Lwt_watcher.create_input () ; - }) - (obj9 - (req "peer_id" Peer_id.encoding) - (req "created" Time.encoding) - (dft "trusted" bool false) - (req "metadata" metadata_encoding) - (dft "events" (list Event.encoding) []) - (opt "last_failed_connection" - (tup2 Id_point.encoding Time.encoding)) - (opt "last_rejected_connection" - (tup2 Id_point.encoding Time.encoding)) - (opt "last_established_connection" - (tup2 Id_point.encoding Time.encoding)) - (opt "last_disconnection" - (tup2 Id_point.encoding Time.encoding))) - - let peer_id { peer_id ; _ } = peer_id - let created { created ; _ } = created - let metadata { metadata ; _ } = metadata - let set_metadata gi metadata = gi.metadata <- metadata - let trusted { trusted ; _ } = trusted - let set_trusted gi = gi.trusted <- true - let unset_trusted gi = gi.trusted <- false - let fold_events { events ; _ } ~init ~f = Ring.fold events ~init ~f - - let last_established_connection s = s.last_established_connection - let last_disconnection s = s.last_disconnection - let last_failed_connection s = s.last_failed_connection - let last_rejected_connection s = s.last_rejected_connection - - let recent = Point_info.recent - let last_seen s = - recent - s.last_established_connection - (recent s.last_rejected_connection s.last_disconnection) - let last_miss s = - recent - s.last_failed_connection - (recent s.last_rejected_connection s.last_disconnection) - - let log { events ; watchers ; _ } ?(timestamp = Time.now ()) point kind = - let event = { Event.kind ; timestamp ; point } in - Ring.add events event ; - Lwt_watcher.notify watchers event - - let watch { watchers ; _ } = Lwt_watcher.create_stream watchers - - let log_incoming_rejection ?timestamp peer_info point = - log peer_info ?timestamp point Rejecting_request - - module State = struct - - type 'data t = 'data state = - | Accepted of { current_point: Id_point.t ; - cancel: Lwt_canceler.t } - | Running of { data: 'data ; - current_point: Id_point.t } - | Disconnected - type 'data state = 'data t - - let pp ppf = function - | Accepted { current_point ; _ } -> - Format.fprintf ppf "accepted %a" Id_point.pp current_point - | Running { current_point ; _ } -> - Format.fprintf ppf "running %a" Id_point.pp current_point - | Disconnected -> - Format.fprintf ppf "disconnected" - - let get { state ; _ } = state - - let is_disconnected { state ; _ } = - match state with - | Disconnected -> true - | Accepted _ | Running _ -> false - - let set_accepted - ?(timestamp = Time.now ()) - peer_info current_point cancel = - assert begin - match peer_info.state with - | Accepted _ | Running _ -> false - | Disconnected -> true - end ; - peer_info.state <- Accepted { current_point ; cancel } ; - log peer_info ~timestamp current_point Accepting_request - - let set_running - ?(timestamp = Time.now ()) - peer_info point data = - assert begin - match peer_info.state with - | Disconnected -> true (* request to unknown peer_id. *) - | Running _ -> false - | Accepted { current_point ; _ } -> - Id_point.equal point current_point - end ; - peer_info.state <- Running { data ; current_point = point } ; - peer_info.last_established_connection <- Some (point, timestamp) ; - log peer_info ~timestamp point Connection_established - - let set_disconnected - ?(timestamp = Time.now ()) ?(requested = false) peer_info = - let current_point, (event : Event.kind) = - match peer_info.state with - | Accepted { current_point ; _ } -> - peer_info.last_rejected_connection <- - Some (current_point, timestamp) ; - current_point, Request_rejected - | Running { current_point ; _ } -> - peer_info.last_disconnection <- - Some (current_point, timestamp) ; - current_point, - if requested then Disconnection else External_disconnection - | Disconnected -> assert false - in - peer_info.state <- Disconnected ; - log peer_info ~timestamp current_point event - - end - - module File = struct - - let load path metadata_encoding = - let enc = Data_encoding.list (encoding metadata_encoding) in - if path <> "/dev/null" && Sys.file_exists path then - Data_encoding_ezjsonm.read_file path >>=? fun json -> - return (Data_encoding.Json.destruct enc json) - else - return [] - - let save path metadata_encoding peers = - let open Data_encoding in - Data_encoding_ezjsonm.write_file path @@ - Json.construct (list (encoding metadata_encoding)) peers - - end - -end diff --git a/src/lib_p2p_services/p2p_connection_pool_types.mli b/src/lib_p2p_services/p2p_connection_pool_types.mli deleted file mode 100644 index 489bc69de..000000000 --- a/src/lib_p2p_services/p2p_connection_pool_types.mli +++ /dev/null @@ -1,284 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -open P2p_types - -module Point_info : sig - - type 'conn t - type 'conn point_info = 'conn t - (** Type of info associated to a point. *) - - val compare : 'conn point_info -> 'conn point_info -> int - - type greylisting_config = { - factor: float ; - initial_delay: int ; - disconnection_delay: int ; - } - - val create : - ?trusted:bool -> - ?greylisting_config:greylisting_config -> - addr -> port -> 'conn point_info - (** [create ~trusted addr port] is a freshly minted point_info. If - [trusted] is true, this point is considered trusted and will - be treated as such. *) - - val trusted : 'conn point_info -> bool - (** [trusted pi] is [true] iff [pi] has is trusted, - i.e. "whitelisted". *) - - val set_trusted : 'conn point_info -> unit - val unset_trusted : 'conn point_info -> unit - - val last_failed_connection : - 'conn point_info -> Time.t option - val last_rejected_connection : - 'conn point_info -> (Peer_id.t * Time.t) option - val last_established_connection : - 'conn point_info -> (Peer_id.t * Time.t) option - val last_disconnection : - 'conn point_info -> (Peer_id.t * Time.t) option - - val last_seen : - 'conn point_info -> (Peer_id.t * Time.t) option - (** [last_seen pi] is the most recent of: - - * last established connection - * last rejected connection - * last disconnection - *) - - val last_miss : - 'conn point_info -> Time.t option - (** [last_miss pi] is the most recent of: - - * last failed connection - * last rejected connection - * last disconnection - *) - - val greylisted : - ?now:Time.t -> 'conn point_info -> bool - - val greylisted_until : 'conn point_info -> Time.t - - val point : 'conn point_info -> Point.t - - module State : sig - - type 'conn t = - | Requested of { cancel: Lwt_canceler.t } - (** We initiated a connection. *) - | Accepted of { current_peer_id: Peer_id.t ; - cancel: Lwt_canceler.t } - (** We accepted a incoming connection. *) - | Running of { data: 'conn ; - current_peer_id: Peer_id.t } - (** Successfully authentificated connection, normal business. *) - | Disconnected - (** No connection established currently. *) - type 'conn state = 'conn t - - val pp : Format.formatter -> 'conn t -> unit - - val get : 'conn point_info -> 'conn state - - val is_disconnected : 'conn point_info -> bool - - val set_requested : - ?timestamp:Time.t -> - 'conn point_info -> Lwt_canceler.t -> unit - - val set_accepted : - ?timestamp:Time.t -> - 'conn point_info -> Peer_id.t -> Lwt_canceler.t -> unit - - val set_running : - ?timestamp:Time.t -> 'conn point_info -> Peer_id.t -> 'conn -> unit - - val set_disconnected : - ?timestamp:Time.t -> ?requested:bool -> 'conn point_info -> unit - - end - - module Event : sig - - type kind = - | Outgoing_request - (** We initiated a connection. *) - | Accepting_request of Peer_id.t - (** We accepted a connection after authentifying the remote peer. *) - | Rejecting_request of Peer_id.t - (** We rejected a connection after authentifying the remote peer. *) - | Request_rejected of Peer_id.t option - (** The remote peer rejected our connection. *) - | Connection_established of Peer_id.t - (** We succesfully established a authentified connection. *) - | Disconnection of Peer_id.t - (** We decided to close the connection. *) - | External_disconnection of Peer_id.t - (** The connection was closed for external reason. *) - - type t = { - kind : kind ; - timestamp : Time.t ; - } - - val encoding : t Data_encoding.t - - end - - val fold_events : - 'conn point_info -> init:'a -> f:('a -> Event.t -> 'a) -> 'a - - val watch : - 'conn point_info -> Event.t Lwt_stream.t * Lwt_watcher.stopper - - val log_incoming_rejection : - ?timestamp:Time.t -> 'conn point_info -> Peer_id.t -> unit - -end - - -(** Peer_id info: current and historical information about a peer_id *) - -module Peer_info : sig - - type ('conn, 'meta) t - type ('conn, 'meta) peer_info = ('conn, 'meta) t - - val compare : ('conn, 'meta) t -> ('conn, 'meta) t -> int - - val create : - ?created:Time.t -> - ?trusted:bool -> - metadata:'meta -> - Peer_id.t -> ('conn, 'meta) peer_info - (** [create ~trusted ~meta peer_id] is a freshly minted peer_id info for - [peer_id]. *) - - val peer_id : ('conn, 'meta) peer_info -> Peer_id.t - - val created : ('conn, 'meta) peer_info -> Time.t - val metadata : ('conn, 'meta) peer_info -> 'meta - val set_metadata : ('conn, 'meta) peer_info -> 'meta -> unit - - val trusted : ('conn, 'meta) peer_info -> bool - val set_trusted : ('conn, 'meta) peer_info -> unit - val unset_trusted : ('conn, 'meta) peer_info -> unit - - val last_failed_connection : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - val last_rejected_connection : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - val last_established_connection : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - val last_disconnection : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - - val last_seen : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - (** [last_seen gi] is the most recent of: - - * last established connection - * last rejected connection - * last disconnection - *) - - val last_miss : - ('conn, 'meta) peer_info -> (Id_point.t * Time.t) option - (** [last_miss gi] is the most recent of: - - * last failed connection - * last rejected connection - * last disconnection - *) - - module State : sig - - type 'conn t = - | Accepted of { current_point: Id_point.t ; - cancel: Lwt_canceler.t } - (** We accepted a incoming connection, we greeted back and - we are waiting for an acknowledgement. *) - | Running of { data: 'conn ; - current_point: Id_point.t } - (** Successfully authentificated connection, normal business. *) - | Disconnected - (** No connection established currently. *) - type 'conn state = 'conn t - - val pp : Format.formatter -> 'conn t -> unit - - val get : ('conn, 'meta) peer_info -> 'conn state - - val is_disconnected : ('conn, 'meta) peer_info -> bool - - val set_accepted : - ?timestamp:Time.t -> - ('conn, 'meta) peer_info -> Id_point.t -> Lwt_canceler.t -> unit - - val set_running : - ?timestamp:Time.t -> - ('conn, 'meta) peer_info -> Id_point.t -> 'conn -> unit - - val set_disconnected : - ?timestamp:Time.t -> - ?requested:bool -> - ('conn, 'meta) peer_info -> unit - - end - - module Event : sig - - type kind = - | Accepting_request - (** We accepted a connection after authentifying the remote peer. *) - | Rejecting_request - (** We rejected a connection after authentifying the remote peer. *) - | Request_rejected - (** The remote peer rejected our connection. *) - | Connection_established - (** We succesfully established a authentified connection. *) - | Disconnection - (** We decided to close the connection. *) - | External_disconnection - (** The connection was closed for external reason. *) - - type t = { - kind : kind ; - timestamp : Time.t ; - point : Id_point.t ; - } - - val encoding : t Data_encoding.t - end - - val fold_events : - ('conn, 'meta) peer_info -> init:'a -> f:('a -> Event.t -> 'a) -> 'a - - val watch : - ('conn, 'meta) peer_info -> Event.t Lwt_stream.t * Lwt_watcher.stopper - - val log_incoming_rejection : - ?timestamp:Time.t -> - ('conn, 'meta) peer_info -> Id_point.t -> unit - - module File : sig - val load : - string -> 'meta Data_encoding.t -> - ('conn, 'meta) peer_info list tzresult Lwt.t - val save : - string -> 'meta Data_encoding.t -> - ('conn, 'meta) peer_info list -> unit tzresult Lwt.t - end - -end diff --git a/src/lib_p2p_services/p2p_services.ml b/src/lib_p2p_services/p2p_services.ml index 08907c4df..d3b1e943c 100644 --- a/src/lib_p2p_services/p2p_services.ml +++ b/src/lib_p2p_services/p2p_services.ml @@ -7,17 +7,15 @@ (* *) (**************************************************************************) -open P2p_types - -let (peer_id_arg : P2p_types.Peer_id.t RPC_arg.arg) = +let (peer_id_arg : P2p_peer.Id.t RPC_arg.arg) = Crypto_box.Public_key_hash.rpc_arg let point_arg = RPC_arg.make ~name:"point" ~descr:"A network point (ipv4:port or [ipv6]:port)." - ~destruct:Point.of_string - ~construct:Point.to_string + ~destruct:P2p_point.Id.of_string + ~construct:P2p_point.Id.to_string () let versions = @@ -25,7 +23,7 @@ let versions = ~description:"Supported network layer versions." ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: (Data_encoding.list P2p_types.Version.encoding) + ~output: (Data_encoding.list P2p_version.encoding) ~error: Data_encoding.empty RPC_path.(root / "network" / "versions") @@ -34,7 +32,7 @@ let stat = ~description:"Global network bandwidth statistics in B/s." ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: P2p_types.Stat.encoding + ~output: P2p_stat.encoding ~error: Data_encoding.empty RPC_path.(root / "network" / "stat") @@ -43,7 +41,7 @@ let events = ~description:"Stream of all network events" ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: P2p_types.Connection_pool_log_event.encoding + ~output: P2p_connection.Pool_event.encoding ~error: Data_encoding.empty RPC_path.(root / "network" / "log") @@ -65,7 +63,7 @@ module Connection = struct ~description:"List the running P2P connection." ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: (Data_encoding.list P2p_types.Connection_info.encoding) + ~output: (Data_encoding.list P2p_connection.Info.encoding) ~error: Data_encoding.empty RPC_path.(root / "network" / "connection") @@ -73,7 +71,7 @@ module Connection = struct RPC_service.post_service ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: (Data_encoding.option P2p_types.Connection_info.encoding) + ~output: (Data_encoding.option P2p_connection.Info.encoding) ~error: Data_encoding.empty ~description:"Details about the current P2P connection to the given peer." RPC_path.(root / "network" / "connection" /: peer_id_arg) @@ -95,7 +93,7 @@ module Point = struct RPC_service.post_service ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: (Data_encoding.option P2p_types.Point_info.encoding) + ~output: (Data_encoding.option P2p_point.Info.encoding) ~error: Data_encoding.empty ~description: "Details about a given `IP:addr`." RPC_path.(root / "network" / "point" /: point_arg) @@ -105,7 +103,7 @@ module Point = struct ~query: RPC_query.empty ~input: monitor_encoding ~output: (Data_encoding.list - P2p_connection_pool_types.Point_info.Event.encoding) + P2p_point.Pool_event.encoding) ~error: Data_encoding.empty ~description: "Monitor network events related to an `IP:addr`." RPC_path.(root / "network" / "point" /: point_arg / "log") @@ -113,14 +111,14 @@ module Point = struct let list = let filter = let open Data_encoding in - obj1 (dft "filter" (list P2p_types.Point_state.encoding) []) in + obj1 (dft "filter" (list P2p_point.State.encoding) []) in RPC_service.post_service ~query: RPC_query.empty ~input: filter ~output: Data_encoding.(list (tup2 - P2p_types.Point.encoding - P2p_types.Point_info.encoding)) + P2p_point.Id.encoding + P2p_point.Info.encoding)) ~error: Data_encoding.empty ~description:"List the pool of known `IP:port` \ used for establishing P2P connections ." @@ -134,7 +132,7 @@ module Peer_id = struct RPC_service.post_service ~query: RPC_query.empty ~input: Data_encoding.empty - ~output: (Data_encoding.option P2p_types.Peer_info.encoding) + ~output: (Data_encoding.option P2p_peer.Info.encoding) ~error: Data_encoding.empty ~description:"Details about a given peer." RPC_path.(root / "network" / "peer_id" /: peer_id_arg) @@ -144,7 +142,7 @@ module Peer_id = struct ~query: RPC_query.empty ~input: monitor_encoding ~output: (Data_encoding.list - P2p_connection_pool_types.Peer_info.Event.encoding) + P2p_peer.Pool_event.encoding) ~error: Data_encoding.empty ~description:"Monitor network events related to a given peer." RPC_path.(root / "network" / "peer_id" /: peer_id_arg / "log") @@ -152,14 +150,14 @@ module Peer_id = struct let list = let filter = let open Data_encoding in - obj1 (dft "filter" (list P2p_types.Peer_state.encoding) []) in + obj1 (dft "filter" (list P2p_peer.State.encoding) []) in RPC_service.post_service ~query: RPC_query.empty ~input: filter ~output: Data_encoding.(list (tup2 - P2p_types.Peer_id.encoding - P2p_types.Peer_info.encoding)) + P2p_peer.Id.encoding + P2p_peer.Info.encoding)) ~error: Data_encoding.empty ~description:"List the peers the node ever met." RPC_path.(root / "network" / "peer_id") diff --git a/src/lib_p2p_services/p2p_services.mli b/src/lib_p2p_services/p2p_services.mli index 719640c47..63d3a8cea 100644 --- a/src/lib_p2p_services/p2p_services.mli +++ b/src/lib_p2p_services/p2p_services.mli @@ -7,26 +7,24 @@ (* *) (**************************************************************************) -open P2p_types - val stat : ([ `POST ], unit, unit, unit, unit, - Stat.t, unit) RPC_service.t + P2p_stat.t, unit) RPC_service.t val versions : ([ `POST ], unit, unit, unit, unit, - Version.t list, unit) RPC_service.t + P2p_version.t list, unit) RPC_service.t val events : ([ `POST ], unit, unit, unit, unit, - Connection_pool_log_event.t, unit) RPC_service.t + P2p_connection.Pool_event.t, unit) RPC_service.t val connect : ([ `POST ], unit, - unit * Point.t, unit, float, + unit * P2p_point.Id.t, unit, float, unit tzresult, unit) RPC_service.t module Connection : sig @@ -34,16 +32,16 @@ module Connection : sig val list : ([ `POST ], unit, unit, unit, unit, - Connection_info.t list, unit) RPC_service.t + P2p_connection.Info.t list, unit) RPC_service.t val info : ([ `POST ], unit, - unit * Peer_id.t, unit, unit, - Connection_info.t option, unit) RPC_service.t + unit * P2p_peer.Id.t, unit, unit, + P2p_connection.Info.t option, unit) RPC_service.t val kick : ([ `POST ], unit, - unit * Peer_id.t, unit, bool, + unit * P2p_peer.Id.t, unit, bool, unit, unit) RPC_service.t end @@ -51,33 +49,33 @@ end module Point : sig val list : ([ `POST ], unit, - unit, unit, Point_state.t list, - (Point.t * Point_info.t) list, unit) RPC_service.t + unit, unit, P2p_point.State.t list, + (P2p_point.Id.t * P2p_point.Info.t) list, unit) RPC_service.t val info : ([ `POST ], unit, - unit * Point.t, unit, unit, - Point_info.t option, unit) RPC_service.t + unit * P2p_point.Id.t, unit, unit, + P2p_point.Info.t option, unit) RPC_service.t val events : ([ `POST ], unit, - unit * Point.t, unit, bool, - P2p_connection_pool_types.Point_info.Event.t list, unit) RPC_service.t + unit * P2p_point.Id.t, unit, bool, + P2p_point.Pool_event.t list, unit) RPC_service.t end module Peer_id : sig val list : ([ `POST ], unit, - unit, unit, Peer_state.t list, - (Peer_id.t * Peer_info.t) list, unit) RPC_service.t + unit, unit, P2p_peer.State.t list, + (P2p_peer.Id.t * P2p_peer.Info.t) list, unit) RPC_service.t val info : ([ `POST ], unit, - unit * Peer_id.t, unit, unit, - Peer_info.t option, unit) RPC_service.t + unit * P2p_peer.Id.t, unit, unit, + P2p_peer.Info.t option, unit) RPC_service.t val events : ([ `POST ], unit, - unit * Peer_id.t, unit, bool, - P2p_connection_pool_types.Peer_info.Event.t list, unit) RPC_service.t + unit * P2p_peer.Id.t, unit, bool, + P2p_peer.Pool_event.t list, unit) RPC_service.t end diff --git a/src/lib_p2p_services/p2p_types.ml b/src/lib_p2p_services/p2p_types.ml deleted file mode 100644 index a39f9a6f8..000000000 --- a/src/lib_p2p_services/p2p_types.ml +++ /dev/null @@ -1,717 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module Version = struct - type t = { - name : string ; - major : int ; - minor : int ; - } - - let pp ppf { name ; major ; minor } = - Format.fprintf ppf "%s.%d.%d" name major minor - - let encoding = - let open Data_encoding in - conv - (fun { name; major; minor } -> (name, major, minor)) - (fun (name, major, minor) -> { name; major; minor }) - (obj3 - (req "name" string) - (req "major" int8) - (req "minor" int8)) - - (* the common version for a pair of peers, if any, is the maximum one, - in lexicographic order *) - let common la lb = - let la = List.sort (fun l r -> compare r l) la in - let lb = List.sort (fun l r -> compare r l) lb in - let rec find = function - | [], _ | _, [] -> None - | ((a :: ta) as la), ((b :: tb) as lb) -> - if a = b then Some a - else if a < b then find (ta, lb) - else find (la, tb) - in find (la, lb) -end - -module Stat = struct - - type t = { - total_sent : int64 ; - total_recv : int64 ; - current_inflow : int ; - current_outflow : int ; - } - - let empty = { - total_sent = 0L ; - total_recv = 0L ; - current_inflow = 0 ; - current_outflow = 0 ; - } - - let print_size ppf sz = - let ratio n = (float_of_int sz /. float_of_int (1 lsl n)) in - if sz < 1 lsl 10 then - Format.fprintf ppf "%d B" sz - else if sz < 1 lsl 20 then - Format.fprintf ppf "%.2f kiB" (ratio 10) - else - Format.fprintf ppf "%.2f MiB" (ratio 20) - - let print_size64 ppf sz = - let open Int64 in - let ratio n = (to_float sz /. float_of_int (1 lsl n)) in - if sz < shift_left 1L 10 then - Format.fprintf ppf "%Ld B" sz - else if sz < shift_left 1L 20 then - Format.fprintf ppf "%.2f kiB" (ratio 10) - else if sz < shift_left 1L 30 then - Format.fprintf ppf "%.2f MiB" (ratio 20) - else if sz < shift_left 1L 40 then - Format.fprintf ppf "%.2f GiB" (ratio 30) - else - Format.fprintf ppf "%.2f TiB" (ratio 40) - - let pp ppf stat = - Format.fprintf ppf - "↗ %a (%a/s) ↘ %a (%a/s)" - print_size64 stat.total_sent print_size stat.current_outflow - print_size64 stat.total_recv print_size stat.current_inflow - - let encoding = - let open Data_encoding in - conv - (fun { total_sent ; total_recv ; current_inflow ; current_outflow } -> - (total_sent, total_recv, current_inflow, current_outflow)) - (fun (total_sent, total_recv, current_inflow, current_outflow) -> - { total_sent ; total_recv ; current_inflow ; current_outflow }) - (obj4 - (req "total_sent" int64) - (req "total_recv" int64) - (req "current_inflow" int31) - (req "current_outflow" int31)) -end - -(* public types *) -type addr = Ipaddr.V6.t - -let addr_encoding = - let open Data_encoding in - splitted - ~json:begin - conv - Ipaddr.V6.to_string - Ipaddr.V6.of_string_exn - string - end - ~binary:begin - conv - Ipaddr.V6.to_bytes - Ipaddr.V6.of_bytes_exn - string - end - -type port = int - - -module Id_point = struct - - module T = struct - - (* A net point (address x port). *) - type t = addr * port option - let compare (a1, p1) (a2, p2) = - match Ipaddr.V6.compare a1 a2 with - | 0 -> Pervasives.compare p1 p2 - | x -> x - let equal p1 p2 = compare p1 p2 = 0 - let hash = Hashtbl.hash - let pp ppf (addr, port) = - match port with - | None -> - Format.fprintf ppf "[%a]:??" Ipaddr.V6.pp_hum addr - | Some port -> - Format.fprintf ppf "[%a]:%d" Ipaddr.V6.pp_hum addr port - let pp_opt ppf = function - | None -> Format.pp_print_string ppf "none" - | Some point -> pp ppf point - let to_string t = Format.asprintf "%a" pp t - - let is_local (addr, _) = Ipaddr.V6.is_private addr - let is_global (addr, _) = not @@ Ipaddr.V6.is_private addr - - let of_point (addr, port) = addr, Some port - let to_point = function - | _, None -> None - | addr, Some port -> Some (addr, port) - let to_point_exn = function - | _, None -> invalid_arg "to_point_exn" - | addr, Some port -> addr, port - - let encoding = - let open Data_encoding in - (obj2 - (req "addr" addr_encoding) - (opt "port" uint16)) - - end - - include T - - module Map = Map.Make (T) - module Set = Set.Make (T) - module Table = Hashtbl.Make (T) - -end - -module Peer_id = Crypto_box.Public_key_hash - -module Peer_state = struct - - type t = - | Accepted - | Running - | Disconnected - - let pp_digram ppf = function - | Accepted -> Format.fprintf ppf "⚎" - | Running -> Format.fprintf ppf "⚌" - | Disconnected -> Format.fprintf ppf "⚏" - - let encoding = - let open Data_encoding in - string_enum [ - "accepted", Accepted ; - "running", Running ; - "disconnected", Disconnected ; - ] - -end - -module Peer_info = struct - - type t = { - score : float ; - trusted : bool ; - state : Peer_state.t ; - id_point : Id_point.t option ; - stat : Stat.t ; - last_failed_connection : (Id_point.t * Time.t) option ; - last_rejected_connection : (Id_point.t * Time.t) option ; - last_established_connection : (Id_point.t * Time.t) option ; - last_disconnection : (Id_point.t * Time.t) option ; - last_seen : (Id_point.t * Time.t) option ; - last_miss : (Id_point.t * Time.t) option ; - } - - let encoding = - let open Data_encoding in - conv - (fun ( - { score ; trusted ; state ; id_point ; stat ; - last_failed_connection ; last_rejected_connection ; - last_established_connection ; last_disconnection ; - last_seen ; last_miss }) -> - ((score, trusted, state, id_point, stat), - (last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection, - last_seen, last_miss))) - (fun ((score, trusted, state, id_point, stat), - (last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection, - last_seen, last_miss)) -> - { score ; trusted ; state ; id_point ; stat ; - last_failed_connection ; last_rejected_connection ; - last_established_connection ; last_disconnection ; - last_seen ; last_miss }) - (merge_objs - (obj5 - (req "score" float) - (req "trusted" bool) - (req "state" Peer_state.encoding) - (opt "reachable_at" Id_point.encoding) - (req "stat" Stat.encoding)) - (obj6 - (opt "last_failed_connection" (tup2 Id_point.encoding Time.encoding)) - (opt "last_rejected_connection" (tup2 Id_point.encoding Time.encoding)) - (opt "last_established_connection" (tup2 Id_point.encoding Time.encoding)) - (opt "last_disconnection" (tup2 Id_point.encoding Time.encoding)) - (opt "last_seen" (tup2 Id_point.encoding Time.encoding)) - (opt "last_miss" (tup2 Id_point.encoding Time.encoding)))) - -end - -module Point = struct - - module T = struct - - (* A net point (address x port). *) - type t = addr * port - let compare (a1, p1) (a2, p2) = - match Ipaddr.V6.compare a1 a2 with - | 0 -> p1 - p2 - | x -> x - let equal p1 p2 = compare p1 p2 = 0 - let hash = Hashtbl.hash - let pp ppf (addr, port) = - match Ipaddr.v4_of_v6 addr with - | Some addr -> - Format.fprintf ppf "%a:%d" Ipaddr.V4.pp_hum addr port - | None -> - Format.fprintf ppf "[%a]:%d" Ipaddr.V6.pp_hum addr port - let pp_opt ppf = function - | None -> Format.pp_print_string ppf "none" - | Some point -> pp ppf point - - let is_local (addr, _) = Ipaddr.V6.is_private addr - let is_global (addr, _) = not @@ Ipaddr.V6.is_private addr - - let check_port port = - if TzString.mem_char port '[' || - TzString.mem_char port ']' || - TzString.mem_char port ':' then - invalid_arg "Utils.parse_addr_port (invalid character in port)" - - let parse_addr_port s = - let len = String.length s in - if len = 0 then - ("", "") - else if s.[0] = '[' then begin (* inline IPv6 *) - match String.rindex s ']' with - | exception Not_found -> - invalid_arg "Utils.parse_addr_port (missing ']')" - | pos -> - let addr = String.sub s 1 (pos - 1) in - let port = - if pos = len - 1 then - "" - else if s.[pos+1] <> ':' then - invalid_arg "Utils.parse_addr_port (unexpected char after ']')" - else - String.sub s (pos + 2) (len - pos - 2) in - check_port port ; - addr, port - end else begin - match String.rindex s ']' with - | _pos -> - invalid_arg "Utils.parse_addr_port (unexpected char ']')" - | exception Not_found -> - match String.index s ':' with - | exception _ -> s, "" - | pos -> - match String.index_from s (pos+1) ':' with - | exception _ -> - let addr = String.sub s 0 pos in - let port = String.sub s (pos + 1) (len - pos - 1) in - check_port port ; - addr, port - | _pos -> - invalid_arg "Utils.parse_addr_port: IPv6 addresses must be bracketed" - end - - let of_string_exn str = - let addr, port = parse_addr_port str in - let port = int_of_string port in - if port < 0 && port > 1 lsl 16 - 1 then - invalid_arg "port must be between 0 and 65535" ; - match Ipaddr.of_string_exn addr with - | V4 addr -> Ipaddr.v6_of_v4 addr, port - | V6 addr -> addr, port - - let of_string str = - try Ok (of_string_exn str) with - | Invalid_argument s -> Error s - | Failure s -> Error s - | _ -> Error "Point.of_string" - - let to_string saddr = Format.asprintf "%a" pp saddr - - let encoding = - Data_encoding.conv to_string of_string_exn Data_encoding.string - - end - - include T - - module Map = Map.Make (T) - module Set = Set.Make (T) - module Table = Hashtbl.Make (T) - -end - -module Point_state = struct - - type t = - | Requested - | Accepted of Peer_id.t - | Running of Peer_id.t - | Disconnected - - let of_peer_id = function - | Requested -> None - | Accepted pi -> Some pi - | Running pi -> Some pi - | Disconnected -> None - - let of_peerid_state state pi = - match state, pi with - | Requested, _ -> Requested - | Accepted _, Some pi -> Accepted pi - | Running _, Some pi -> Running pi - | Disconnected, _ -> Disconnected - | _ -> invalid_arg "state_of_state_peerid" - - let pp_digram ppf = function - | Requested -> Format.fprintf ppf "⚎" - | Accepted _ -> Format.fprintf ppf "⚍" - | Running _ -> Format.fprintf ppf "⚌" - | Disconnected -> Format.fprintf ppf "⚏" - - let encoding = - let open Data_encoding in - let branch_encoding name obj = - conv (fun x -> (), x) (fun ((), x) -> x) - (merge_objs - (obj1 (req "event_kind" (constant name))) obj) in - union ~tag_size:`Uint8 [ - case (Tag 0) (branch_encoding "requested" empty) - (function Requested -> Some () | _ -> None) - (fun () -> Requested) ; - case (Tag 1) (branch_encoding "accepted" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Accepted peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Accepted peer_id) ; - case (Tag 2) (branch_encoding "running" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Running peer_id -> Some peer_id | _ -> None) - (fun peer_id -> Running peer_id) ; - case (Tag 3) (branch_encoding "disconnected" empty) - (function Disconnected -> Some () | _ -> None) - (fun () -> Disconnected) ; - ] - -end - -module Point_info = struct - - type t = { - trusted : bool ; - greylisted_until : Time.t ; - state : Point_state.t ; - last_failed_connection : Time.t option ; - last_rejected_connection : (Peer_id.t * Time.t) option ; - last_established_connection : (Peer_id.t * Time.t) option ; - last_disconnection : (Peer_id.t * Time.t) option ; - last_seen : (Peer_id.t * Time.t) option ; - last_miss : Time.t option ; - } - - let encoding = - let open Data_encoding in - conv - (fun { trusted ; greylisted_until ; state ; - last_failed_connection ; last_rejected_connection ; - last_established_connection ; last_disconnection ; - last_seen ; last_miss } -> - let peer_id = Point_state.of_peer_id state in - (trusted, greylisted_until, state, peer_id, - last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection, - last_seen, last_miss)) - (fun (trusted, greylisted_until, state, peer_id, - last_failed_connection, last_rejected_connection, - last_established_connection, last_disconnection, - last_seen, last_miss) -> - let state = Point_state.of_peerid_state state peer_id in - { trusted ; greylisted_until ; state ; - last_failed_connection ; last_rejected_connection ; - last_established_connection ; last_disconnection ; - last_seen ; last_miss }) - (obj10 - (req "trusted" bool) - (dft "greylisted_until" Time.encoding Time.epoch) - (req "state" Point_state.encoding) - (opt "peer_id" Peer_id.encoding) - (opt "last_failed_connection" Time.encoding) - (opt "last_rejected_connection" (tup2 Peer_id.encoding Time.encoding)) - (opt "last_established_connection" (tup2 Peer_id.encoding Time.encoding)) - (opt "last_disconnection" (tup2 Peer_id.encoding Time.encoding)) - (opt "last_seen" (tup2 Peer_id.encoding Time.encoding)) - (opt "last_miss" Time.encoding)) - -end - - -module Identity = struct - - type t = { - peer_id : Peer_id.t ; - public_key : Crypto_box.public_key ; - secret_key : Crypto_box.secret_key ; - proof_of_work_stamp : Crypto_box.nonce ; - } - - let encoding = - let open Data_encoding in - conv - (fun { public_key ; secret_key ; proof_of_work_stamp ; _ } -> - (public_key, secret_key, proof_of_work_stamp)) - (fun (public_key, secret_key, proof_of_work_stamp) -> - let peer_id = Crypto_box.hash public_key in - { peer_id ; public_key ; secret_key ; proof_of_work_stamp }) - (obj3 - (req "public_key" Crypto_box.public_key_encoding) - (req "secret_key" Crypto_box.secret_key_encoding) - (req "proof_of_work_stamp" Crypto_box.nonce_encoding)) - - let generate ?max target = - let secret_key, public_key, peer_id = Crypto_box.random_keypair () in - let proof_of_work_stamp = - Crypto_box.generate_proof_of_work ?max public_key target in - { peer_id ; public_key ; secret_key ; proof_of_work_stamp } - - let animation = [| - "|.....|" ; - "|o....|" ; - "|oo...|" ; - "|ooo..|" ; - "|.ooo.|" ; - "|..ooo|" ; - "|...oo|" ; - "|....o|" ; - "|.....|" ; - "|.....|" ; - "|.....|" ; - "|.....|" ; - |] - - let init = String.make (String.length animation.(0)) '\ ' - let clean = String.make (String.length animation.(0)) '\b' - let animation = Array.map (fun x -> clean ^ x) animation - let animation_size = Array.length animation - let duration = 1200 / animation_size - - let generate_with_animation ppf target = - Format.fprintf ppf "%s%!" init ; - let count = ref 10000 in - let rec loop n = - let start = Mtime_clock.counter () in - Format.fprintf ppf "%s%!" animation.(n mod animation_size); - try generate ~max:!count target - with Not_found -> - let time = Mtime.Span.to_ms (Mtime_clock.count start) in - count := - if time <= 0. then - !count * 10 - else - !count * duration / int_of_float time ; - loop (n+1) - in - let id = loop 0 in - Format.fprintf ppf "%s%s\n%!" clean init ; - id - - let generate target = generate target - -end - -module Connection_info = struct - - type t = { - incoming : bool; - peer_id : Peer_id.t; - id_point : Id_point.t; - remote_socket_port : port; - versions : Version.t list ; - } - - let encoding = - let open Data_encoding in - conv - (fun { incoming ; peer_id ; id_point ; remote_socket_port ; versions } -> - (incoming, peer_id, id_point, remote_socket_port, versions)) - (fun (incoming, peer_id, id_point, remote_socket_port, versions) -> - { incoming ; peer_id ; id_point ; remote_socket_port ; versions }) - (obj5 - (req "incoming" bool) - (req "peer_id" Peer_id.encoding) - (req "id_point" Id_point.encoding) - (req "remote_socket_port" uint16) - (req "versions" (list Version.encoding))) - - let pp ppf - { incoming ; id_point = (remote_addr, remote_port) ; - remote_socket_port ; peer_id ; versions } = - let version = List.hd versions in - let point = match remote_port with - | None -> remote_addr, remote_socket_port - | Some port -> remote_addr, port in - Format.fprintf ppf "%s %a %a (%a)" - (if incoming then "↘" else "↗") - Peer_id.pp peer_id - Point.pp point - Version.pp version -end - -module Connection_pool_log_event = struct - - type t = - - | Too_few_connections - | Too_many_connections - - | New_point of Point.t - | New_peer of Peer_id.t - - | Gc_points - | Gc_peer_ids - - | Incoming_connection of Point.t - | Outgoing_connection of Point.t - | Authentication_failed of Point.t - | Accepting_request of Point.t * Id_point.t * Peer_id.t - | Rejecting_request of Point.t * Id_point.t * Peer_id.t - | Request_rejected of Point.t * (Id_point.t * Peer_id.t) option - | Connection_established of Id_point.t * Peer_id.t - - | Swap_request_received of { source : Peer_id.t } - | Swap_ack_received of { source : Peer_id.t } - | Swap_request_sent of { source : Peer_id.t } - | Swap_ack_sent of { source : Peer_id.t } - | Swap_request_ignored of { source : Peer_id.t } - | Swap_success of { source : Peer_id.t } - | Swap_failure of { source : Peer_id.t } - - | Disconnection of Peer_id.t - | External_disconnection of Peer_id.t - - let encoding = - let open Data_encoding in - let branch_encoding name obj = - conv (fun x -> (), x) (fun ((), x) -> x) - (merge_objs - (obj1 (req "event" (constant name))) obj) in - union ~tag_size:`Uint8 [ - case (Tag 0) (branch_encoding "too_few_connections" empty) - (function Too_few_connections -> Some () | _ -> None) - (fun () -> Too_few_connections) ; - case (Tag 1) (branch_encoding "too_many_connections" empty) - (function Too_many_connections -> Some () | _ -> None) - (fun () -> Too_many_connections) ; - case (Tag 2) (branch_encoding "new_point" - (obj1 (req "point" Point.encoding))) - (function New_point p -> Some p | _ -> None) - (fun p -> New_point p) ; - case (Tag 3) (branch_encoding "new_peer" - (obj1 (req "peer_id" Peer_id.encoding))) - (function New_peer p -> Some p | _ -> None) - (fun p -> New_peer p) ; - case (Tag 4) (branch_encoding "incoming_connection" - (obj1 (req "point" Point.encoding))) - (function Incoming_connection p -> Some p | _ -> None) - (fun p -> Incoming_connection p) ; - case (Tag 5) (branch_encoding "outgoing_connection" - (obj1 (req "point" Point.encoding))) - (function Outgoing_connection p -> Some p | _ -> None) - (fun p -> Outgoing_connection p) ; - case (Tag 6) (branch_encoding "authentication_failed" - (obj1 (req "point" Point.encoding))) - (function Authentication_failed p -> Some p | _ -> None) - (fun p -> Authentication_failed p) ; - case (Tag 7) (branch_encoding "accepting_request" - (obj3 - (req "point" Point.encoding) - (req "id_point" Id_point.encoding) - (req "peer_id" Peer_id.encoding))) - (function Accepting_request (p, id_p, g) -> - Some (p, id_p, g) | _ -> None) - (fun (p, id_p, g) -> Accepting_request (p, id_p, g)) ; - case (Tag 8) (branch_encoding "rejecting_request" - (obj3 - (req "point" Point.encoding) - (req "id_point" Id_point.encoding) - (req "peer_id" Peer_id.encoding))) - (function Rejecting_request (p, id_p, g) -> - Some (p, id_p, g) | _ -> None) - (fun (p, id_p, g) -> Rejecting_request (p, id_p, g)) ; - case (Tag 9) (branch_encoding "request_rejected" - (obj2 - (req "point" Point.encoding) - (opt "identity" - (tup2 Id_point.encoding Peer_id.encoding)))) - (function Request_rejected (p, id) -> Some (p, id) | _ -> None) - (fun (p, id) -> Request_rejected (p, id)) ; - case (Tag 10) (branch_encoding "connection_established" - (obj2 - (req "id_point" Id_point.encoding) - (req "peer_id" Peer_id.encoding))) - (function Connection_established (id_p, g) -> - Some (id_p, g) | _ -> None) - (fun (id_p, g) -> Connection_established (id_p, g)) ; - case (Tag 11) (branch_encoding "disconnection" - (obj1 (req "peer_id" Peer_id.encoding))) - (function Disconnection g -> Some g | _ -> None) - (fun g -> Disconnection g) ; - case (Tag 12) (branch_encoding "external_disconnection" - (obj1 (req "peer_id" Peer_id.encoding))) - (function External_disconnection g -> Some g | _ -> None) - (fun g -> External_disconnection g) ; - case (Tag 13) (branch_encoding "gc_points" empty) - (function Gc_points -> Some () | _ -> None) - (fun () -> Gc_points) ; - case (Tag 14) (branch_encoding "gc_peer_ids" empty) - (function Gc_peer_ids -> Some () | _ -> None) - (fun () -> Gc_peer_ids) ; - case (Tag 15) (branch_encoding "swap_request_received" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_request_received { source } -> Some source - | _ -> None) - (fun source -> Swap_request_received { source }) ; - case (Tag 16) (branch_encoding "swap_ack_received" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_ack_received { source } -> Some source - | _ -> None) - (fun source -> Swap_ack_received { source }) ; - case (Tag 17) (branch_encoding "swap_request_sent" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_request_sent { source } -> Some source - | _ -> None) - (fun source -> Swap_request_sent { source }) ; - case (Tag 18) (branch_encoding "swap_ack_sent" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_ack_sent { source } -> Some source - | _ -> None) - (fun source -> Swap_ack_sent { source }) ; - case (Tag 19) (branch_encoding "swap_request_ignored" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_request_ignored { source } -> Some source - | _ -> None) - (fun source -> Swap_request_ignored { source }) ; - case (Tag 20) (branch_encoding "swap_success" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_success { source } -> Some source - | _ -> None) - (fun source -> Swap_success { source }) ; - case (Tag 21) (branch_encoding "swap_failure" - (obj1 (req "source" Peer_id.encoding))) - (function - | Swap_failure { source } -> Some source - | _ -> None) - (fun source -> Swap_failure { source }) ; - ] - -end diff --git a/src/lib_p2p_services/p2p_types.mli b/src/lib_p2p_services/p2p_types.mli deleted file mode 100644 index a529c598c..000000000 --- a/src/lib_p2p_services/p2p_types.mli +++ /dev/null @@ -1,263 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -(** Protocol version *) - -module Version : sig - type t = { - name : string ; - major : int ; - minor : int ; - } - (** Type of a protocol version. *) - - val pp : Format.formatter -> t -> unit - val encoding : t Data_encoding.t - val common : t list -> t list -> t option -end - - -(** Peer_id, i.e. persistent peer identifier *) - -module Peer_id : Tezos_crypto.S.INTERNAL_HASH - with type t = Crypto_box.Public_key_hash.t - -type addr = Ipaddr.V6.t -type port = int - -val addr_encoding : addr Data_encoding.t - -(** Point, i.e. socket address *) - -module Point : sig - - type t = addr * port - val compare : t -> t -> int - - val pp : Format.formatter -> t -> unit - val pp_opt : Format.formatter -> t option -> unit - - val of_string_exn : string -> t - val of_string : string -> (t, string) result - val to_string : t -> string - val encoding : t Data_encoding.t - val is_local : t -> bool - val is_global : t -> bool - val parse_addr_port : string -> string * string - - module Map : Map.S with type key = t - module Set : Set.S with type elt = t - module Table : Hashtbl.S with type key = t - -end - -(** Point representing a reachable socket address *) - -module Id_point : sig - type t = addr * port option - val compare : t -> t -> int - val equal : t -> t -> bool - val pp : Format.formatter -> t -> unit - val pp_opt : Format.formatter -> t option -> unit - val to_string : t -> string - val encoding : t Data_encoding.t - val is_local : t -> bool - val is_global : t -> bool - val of_point : Point.t -> t - val to_point : t -> Point.t option - val to_point_exn : t -> Point.t - module Map : Map.S with type key = t - module Set : Set.S with type elt = t - module Table : Hashtbl.S with type key = t -end - - -(** Identity *) - -module Identity : sig - type t = { - peer_id : Peer_id.t ; - public_key : Crypto_box.public_key ; - secret_key : Crypto_box.secret_key ; - proof_of_work_stamp : Crypto_box.nonce ; - } - (** Type of an identity, comprising a peer_id, a crypto keypair, and a - proof of work stamp with enough difficulty so that the network - accept this identity as genuine. *) - - val encoding : t Data_encoding.t - - val generate : Crypto_box.target -> t - (** [generate target] is a freshly minted identity whose proof of - work stamp difficulty is at least equal to [target]. *) - - val generate_with_animation : - Format.formatter -> Crypto_box.target -> t - (** [generate_with_animation ppf target] is a freshly minted identity - whose proof of work stamp difficulty is at least equal to [target]. *) - -end - - -(** Bandwidth usage statistics *) - -module Stat : sig - - type t = { - total_sent : int64 ; - total_recv : int64 ; - current_inflow : int ; - current_outflow : int ; - } - - val empty : t - val pp : Format.formatter -> t -> unit - val encoding : t Data_encoding.t -end - -(** Information about a connection *) - -module Connection_info : sig - - type t = { - incoming : bool; - peer_id : Peer_id.t; - id_point : Id_point.t; - remote_socket_port : port; - versions : Version.t list ; - } - - val pp : Format.formatter -> t -> unit - val encoding : t Data_encoding.t - -end - -(** Pool-level events *) - -module Connection_pool_log_event : sig - - type t = - - | Too_few_connections - | Too_many_connections - - | New_point of Point.t - | New_peer of Peer_id.t - - | Gc_points - (** Garbage collection of known point table has been triggered. *) - - | Gc_peer_ids - (** Garbage collection of known peer_ids table has been triggered. *) - - (* Connection-level events *) - - | Incoming_connection of Point.t - (** We accept(2)-ed an incoming connection *) - | Outgoing_connection of Point.t - (** We connect(2)-ed to a remote endpoint *) - | Authentication_failed of Point.t - (** Remote point failed authentication *) - - | Accepting_request of Point.t * Id_point.t * Peer_id.t - (** We accepted a connection after authentifying the remote peer. *) - | Rejecting_request of Point.t * Id_point.t * Peer_id.t - (** We rejected a connection after authentifying the remote peer. *) - | Request_rejected of Point.t * (Id_point.t * Peer_id.t) option - (** The remote peer rejected our connection. *) - - | Connection_established of Id_point.t * Peer_id.t - (** We succesfully established a authentified connection. *) - - | Swap_request_received of { source : Peer_id.t } - (** A swap request has been received. *) - | Swap_ack_received of { source : Peer_id.t } - (** A swap ack has been received *) - | Swap_request_sent of { source : Peer_id.t } - (** A swap request has been sent *) - | Swap_ack_sent of { source : Peer_id.t } - (** A swap ack has been sent *) - | Swap_request_ignored of { source : Peer_id.t } - (** A swap request has been ignored *) - | Swap_success of { source : Peer_id.t } - (** A swap operation has succeeded *) - | Swap_failure of { source : Peer_id.t } - (** A swap operation has failed *) - - | Disconnection of Peer_id.t - (** We decided to close the connection. *) - | External_disconnection of Peer_id.t - (** The connection was closed for external reason. *) - - val encoding : t Data_encoding.t - -end - -module Point_state : sig - - type t = - | Requested - | Accepted of Peer_id.t - | Running of Peer_id.t - | Disconnected - - val pp_digram : Format.formatter -> t -> unit - val encoding : t Data_encoding.t - -end - -module Point_info : sig - - type t = { - trusted : bool ; - greylisted_until : Time.t ; - state : Point_state.t ; - last_failed_connection : Time.t option ; - last_rejected_connection : (Peer_id.t * Time.t) option ; - last_established_connection : (Peer_id.t * Time.t) option ; - last_disconnection : (Peer_id.t * Time.t) option ; - last_seen : (Peer_id.t * Time.t) option ; - last_miss : Time.t option ; - } - - val encoding : t Data_encoding.t - -end - -module Peer_state : sig - - type t = - | Accepted - | Running - | Disconnected - - val pp_digram : Format.formatter -> t -> unit - val encoding : t Data_encoding.t - -end - -module Peer_info : sig - - type t = { - score : float ; - trusted : bool ; - state : Peer_state.t ; - id_point : Id_point.t option ; - stat : Stat.t ; - last_failed_connection : (Id_point.t * Time.t) option ; - last_rejected_connection : (Id_point.t * Time.t) option ; - last_established_connection : (Id_point.t * Time.t) option ; - last_disconnection : (Id_point.t * Time.t) option ; - last_seen : (Id_point.t * Time.t) option ; - last_miss : (Id_point.t * Time.t) option ; - } - val encoding : t Data_encoding.t - -end - diff --git a/src/lib_shell/block_validator.ml b/src/lib_shell/block_validator.ml index c448b608d..f8f1a4792 100644 --- a/src/lib_shell/block_validator.ml +++ b/src/lib_shell/block_validator.ml @@ -40,7 +40,7 @@ module Request = struct net_db: Distributed_db.net_db ; notify_new_block: State.Block.t -> unit ; canceler: Lwt_canceler.t option ; - peer: P2p.Peer_id.t option ; + peer: P2p_peer.Id.t option ; hash: Block_hash.t ; header: Block_header.t ; operations: Operation.t list list ; diff --git a/src/lib_shell/block_validator.mli b/src/lib_shell/block_validator.mli index 484039f87..399ef110c 100644 --- a/src/lib_shell/block_validator.mli +++ b/src/lib_shell/block_validator.mli @@ -22,7 +22,7 @@ val create: val validate: t -> ?canceler:Lwt_canceler.t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?notify_new_block:(State.Block.t -> unit) -> Distributed_db.net_db -> Block_hash.t -> Block_header.t -> Operation.t list list -> @@ -30,7 +30,7 @@ val validate: val fetch_and_compile_protocol: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> Protocol_hash.t -> State.Registred_protocol.t tzresult Lwt.t diff --git a/src/lib_shell/bootstrap_pipeline.ml b/src/lib_shell/bootstrap_pipeline.ml index 80effe5c9..5db7edc82 100644 --- a/src/lib_shell/bootstrap_pipeline.ml +++ b/src/lib_shell/bootstrap_pipeline.ml @@ -9,7 +9,7 @@ include Logging.Make(struct let name = "node.validator.bootstrap_pipeline" end) -type error += Invalid_locator of P2p.Peer_id.t * Block_locator.t +type error += Invalid_locator of P2p_peer.Id.t * Block_locator.t type t = { canceler: Lwt_canceler.t ; @@ -18,7 +18,7 @@ type t = { mutable headers_fetch_worker: unit Lwt.t ; mutable operations_fetch_worker: unit Lwt.t ; mutable validation_worker: unit Lwt.t ; - peer_id: P2p.Peer_id.t ; + peer_id: P2p_peer.Id.t ; net_db: Distributed_db.net_db ; locator: Block_locator.t ; block_validator: Block_validator.t ; @@ -37,24 +37,24 @@ let fetch_step pipeline (step : Block_locator_iterator.step) = Block_hash.pp_short step.predecessor step.step (if step.strict_step then "" else " max") - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> let rec fetch_loop acc hash cpt = Lwt_unix.yield () >>= fun () -> if cpt < 0 then lwt_log_info "invalid step from peer %a (too long)." - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> fail (Invalid_locator (pipeline.peer_id, pipeline.locator)) else if Block_hash.equal hash step.predecessor then if step.strict_step && cpt <> 0 then lwt_log_info "invalid step from peer %a (too short)." - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> fail (Invalid_locator (pipeline.peer_id, pipeline.locator)) else return acc else lwt_debug "fetching block header %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_utils.protect ~canceler:pipeline.canceler begin fun () -> Distributed_db.Block_header.fetch ~timeout:pipeline.block_header_timeout @@ -63,7 +63,7 @@ let fetch_step pipeline (step : Block_locator_iterator.step) = end >>=? fun header -> lwt_debug "fetched block header %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> fetch_loop ((hash, header) :: acc) header.shell.predecessor (cpt - 1) in fetch_loop [] step.block step.step >>=? fun headers -> @@ -84,7 +84,7 @@ let headers_fetch_worker_loop pipeline = end >>= function | Ok () -> lwt_log_info "fetched all step from peer %a." - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_pipe.close pipeline.fetched_headers ; Lwt.return_unit | Error [Exn Lwt.Canceled | Lwt_utils.Canceled | Exn Lwt_pipe.Closed] -> @@ -92,7 +92,7 @@ let headers_fetch_worker_loop pipeline = | Error [ Distributed_db.Block_header.Timeout bh ] -> lwt_log_info "request for header %a from peer %a timed out." Block_hash.pp_short bh - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_canceler.cancel pipeline.canceler >>= fun () -> Lwt.return_unit | Error err -> @@ -110,7 +110,7 @@ let rec operations_fetch_worker_loop pipeline = end >>=? fun (hash, header) -> lwt_log_info "fetching operations of block %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> map_p (fun i -> Lwt_utils.protect ~canceler:pipeline.canceler begin fun () -> @@ -122,7 +122,7 @@ let rec operations_fetch_worker_loop pipeline = (0 -- (header.shell.validation_passes - 1)) >>=? fun operations -> lwt_log_info "fetched operations of block %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_utils.protect ~canceler:pipeline.canceler begin fun () -> Lwt_pipe.push pipeline.fetched_blocks (hash, header, operations) >>= return @@ -136,7 +136,7 @@ let rec operations_fetch_worker_loop pipeline = | Error [ Distributed_db.Operations.Timeout (bh, n) ] -> lwt_log_info "request for operations %a:%d from peer %a timed out." Block_hash.pp_short bh n - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_canceler.cancel pipeline.canceler >>= fun () -> Lwt.return_unit | Error err -> @@ -154,7 +154,7 @@ let rec validation_worker_loop pipeline = end >>=? fun (hash, header, operations) -> lwt_log_info "requesting validation for block %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> Lwt_utils.protect ~canceler:pipeline.canceler begin fun () -> Block_validator.validate ~canceler:pipeline.canceler @@ -164,7 +164,7 @@ let rec validation_worker_loop pipeline = end >>=? fun _block -> lwt_log_info "validated block %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pipeline.peer_id >>= fun () -> + P2p_peer.Id.pp_short pipeline.peer_id >>= fun () -> return () end >>= function | Ok () -> validation_worker_loop pipeline @@ -214,19 +214,19 @@ let create pipeline.headers_fetch_worker <- Lwt_utils.worker (Format.asprintf "bootstrap_pipeline-headers_fetch.%a.%a" - P2p.Peer_id.pp_short peer_id Block_hash.pp_short hash) + P2p_peer.Id.pp_short peer_id Block_hash.pp_short hash) ~run:(fun () -> headers_fetch_worker_loop pipeline) ~cancel:(fun () -> Lwt_canceler.cancel pipeline.canceler) ; pipeline.operations_fetch_worker <- Lwt_utils.worker (Format.asprintf "bootstrap_pipeline-operations_fetch.%a.%a" - P2p.Peer_id.pp_short peer_id Block_hash.pp_short hash) + P2p_peer.Id.pp_short peer_id Block_hash.pp_short hash) ~run:(fun () -> operations_fetch_worker_loop pipeline) ~cancel:(fun () -> Lwt_canceler.cancel pipeline.canceler) ; pipeline.validation_worker <- Lwt_utils.worker (Format.asprintf "bootstrap_pipeline-validation.%a.%a" - P2p.Peer_id.pp_short peer_id Block_hash.pp_short hash) + P2p_peer.Id.pp_short peer_id Block_hash.pp_short hash) ~run:(fun () -> validation_worker_loop pipeline) ~cancel:(fun () -> Lwt_canceler.cancel pipeline.canceler) ; pipeline diff --git a/src/lib_shell/bootstrap_pipeline.mli b/src/lib_shell/bootstrap_pipeline.mli index c6877e173..c9bb0c27e 100644 --- a/src/lib_shell/bootstrap_pipeline.mli +++ b/src/lib_shell/bootstrap_pipeline.mli @@ -9,14 +9,14 @@ type t -type error += Invalid_locator of P2p.Peer_id.t * Block_locator.t +type error += Invalid_locator of P2p_peer.Id.t * Block_locator.t val create: ?notify_new_block: (State.Block.t -> unit) -> block_header_timeout:float -> block_operations_timeout: float -> Block_validator.t -> - P2p.Peer_id.t -> Distributed_db.net_db -> + P2p_peer.Id.t -> Distributed_db.net_db -> Block_locator.t -> t val wait: t -> unit tzresult Lwt.t diff --git a/src/lib_shell/distributed_db.ml b/src/lib_shell/distributed_db.ml index cb8c1db76..58ece1e64 100644 --- a/src/lib_shell/distributed_db.ml +++ b/src/lib_shell/distributed_db.ml @@ -15,8 +15,8 @@ type connection = (Message.t, Metadata.t) P2p.connection type 'a request_param = { data: 'a ; - active: unit -> P2p.Peer_id.Set.t ; - send: P2p.Peer_id.t -> Message.t -> unit ; + active: unit -> P2p_peer.Set.t ; + send: P2p_peer.Id.t -> Message.t -> unit ; } module Make_raw @@ -292,15 +292,15 @@ module Raw_protocol = type callback = { notify_branch: - P2p.Peer_id.t -> Block_locator.t -> unit ; + P2p_peer.Id.t -> Block_locator.t -> unit ; notify_head: - P2p.Peer_id.t -> Block_header.t -> Mempool.t -> unit ; - disconnection: P2p.Peer_id.t -> unit ; + P2p_peer.Id.t -> Block_header.t -> Mempool.t -> unit ; + disconnection: P2p_peer.Id.t -> unit ; } type db = { p2p: p2p ; - p2p_readers: p2p_reader P2p.Peer_id.Table.t ; + p2p_readers: p2p_reader P2p_peer.Table.t ; disk: State.t ; active_nets: net_db Net_id.Table.t ; protocol_db: Raw_protocol.t ; @@ -316,12 +316,12 @@ and net_db = { operation_hashes_db: Raw_operation_hashes.t ; operations_db: Raw_operations.t ; mutable callback: callback ; - active_peers: P2p.Peer_id.Set.t ref ; - active_connections: p2p_reader P2p.Peer_id.Table.t ; + active_peers: P2p_peer.Set.t ref ; + active_connections: p2p_reader P2p_peer.Table.t ; } and p2p_reader = { - gid: P2p.Peer_id.t ; + gid: P2p_peer.Id.t ; conn: connection ; peer_active_nets: net_db Net_id.Table.t ; canceler: Lwt_canceler.t ; @@ -418,8 +418,8 @@ module P2p_reader = struct match Net_id.Table.find global_db.active_nets net_id with | net_db -> net_db.active_peers := - P2p.Peer_id.Set.add state.gid !(net_db.active_peers) ; - P2p.Peer_id.Table.add net_db.active_connections + P2p_peer.Set.add state.gid !(net_db.active_peers) ; + P2p_peer.Table.add net_db.active_connections state.gid state ; Net_id.Table.add state.peer_active_nets net_id net_db ; f net_db @@ -430,8 +430,8 @@ module P2p_reader = struct let deactivate state net_db = net_db.callback.disconnection state.gid ; net_db.active_peers := - P2p.Peer_id.Set.remove state.gid !(net_db.active_peers) ; - P2p.Peer_id.Table.remove net_db.active_connections state.gid + P2p_peer.Set.remove state.gid !(net_db.active_peers) ; + P2p_peer.Table.remove net_db.active_connections state.gid let may_handle state net_id f = match Net_id.Table.find state.peer_active_nets net_id with @@ -456,7 +456,7 @@ module P2p_reader = struct let open Logging in lwt_debug "Read message from %a: %a" - P2p.Peer_id.pp_short state.gid Message.pp_json msg >>= fun () -> + P2p_peer.Id.pp_short state.gid Message.pp_json msg >>= fun () -> match msg with @@ -639,7 +639,7 @@ module P2p_reader = struct Net_id.Table.iter (fun _ -> deactivate state) state.peer_active_nets ; - P2p.Peer_id.Table.remove global_db.p2p_readers state.gid ; + P2p_peer.Table.remove global_db.p2p_readers state.gid ; Lwt.return_unit let run db gid conn = @@ -657,10 +657,10 @@ module P2p_reader = struct state.worker <- Lwt_utils.worker (Format.asprintf "db_network_reader.%a" - P2p.Peer_id.pp_short gid) + P2p_peer.Id.pp_short gid) ~run:(fun () -> worker_loop db state) ~cancel:(fun () -> Lwt_canceler.cancel canceler) ; - P2p.Peer_id.Table.add db.p2p_readers gid state + P2p_peer.Table.add db.p2p_readers gid state let shutdown s = Lwt_canceler.cancel s.canceler >>= fun () -> @@ -671,9 +671,9 @@ end let active_peer_ids p2p () = List.fold_left (fun acc conn -> - let { P2p.Connection_info.peer_id } = P2p.connection_info p2p conn in - P2p.Peer_id.Set.add peer_id acc) - P2p.Peer_id.Set.empty + let { P2p_connection.Info.peer_id } = P2p.connection_info p2p conn in + P2p_peer.Set.add peer_id acc) + P2p_peer.Set.empty (P2p.connections p2p) let raw_try_send p2p peer_id msg = @@ -689,7 +689,7 @@ let create disk p2p = } in let protocol_db = Raw_protocol.create global_request disk in let active_nets = Net_id.Table.create 17 in - let p2p_readers = P2p.Peer_id.Table.create 17 in + let p2p_readers = P2p_peer.Table.create 17 in let block_input = Lwt_watcher.create_input () in let operation_input = Lwt_watcher.create_input () in let db = @@ -704,7 +704,7 @@ let activate ({ p2p ; active_nets } as global_db) net_state = let net_id = State.Net.id net_state in match Net_id.Table.find active_nets net_id with | exception Not_found -> - let active_peers = ref P2p.Peer_id.Set.empty in + let active_peers = ref P2p_peer.Set.empty in let p2p_request = { data = () ; active = (fun () -> !active_peers) ; @@ -724,7 +724,7 @@ let activate ({ p2p ; active_nets } as global_db) net_state = global_db ; operation_db ; block_header_db ; operation_hashes_db ; operations_db ; net_state ; callback = noop_callback ; active_peers ; - active_connections = P2p.Peer_id.Table.create 53 ; + active_connections = P2p_peer.Table.create 53 ; } in P2p.iter_connections p2p (fun _peer_id conn -> Lwt.async begin fun () -> @@ -742,7 +742,7 @@ let deactivate net_db = let { active_nets ; p2p } = net_db.global_db in let net_id = State.Net.id net_db.net_state in Net_id.Table.remove active_nets net_id ; - P2p.Peer_id.Table.iter + P2p_peer.Table.iter (fun _peer_id reader -> P2p_reader.deactivate reader net_db ; Lwt.async begin fun () -> @@ -764,7 +764,7 @@ let disconnect { global_db = { p2p } } peer_id = | Some conn -> P2p.disconnect p2p conn let shutdown { p2p ; p2p_readers ; active_nets } = - P2p.Peer_id.Table.fold + P2p_peer.Table.fold (fun _peer_id reader acc -> P2p_reader.shutdown reader >>= fun () -> acc) p2p_readers @@ -829,12 +829,12 @@ module type DISTRIBUTED_DB = sig type error += Timeout of key val fetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> value tzresult Lwt.t val prefetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> unit type error += Canceled of key @@ -913,14 +913,14 @@ end let broadcast net_db msg = - P2p.Peer_id.Table.iter + P2p_peer.Table.iter (fun _peer_id state -> ignore (P2p.try_send net_db.global_db.p2p state.conn msg)) net_db.active_connections let try_send net_db peer_id msg = try - let conn = P2p.Peer_id.Table.find net_db.active_connections peer_id in + let conn = P2p_peer.Table.find net_db.active_connections peer_id in ignore (P2p.try_send net_db.global_db.p2p conn.conn msg : bool) with Not_found -> () diff --git a/src/lib_shell/distributed_db.mli b/src/lib_shell/distributed_db.mli index 1f99b701d..dc21a8ee4 100644 --- a/src/lib_shell/distributed_db.mli +++ b/src/lib_shell/distributed_db.mli @@ -40,9 +40,9 @@ val get_net: t -> Net_id.t -> net_db option val deactivate: net_db -> unit Lwt.t type callback = { - notify_branch: P2p.Peer_id.t -> Block_locator.t -> unit ; - notify_head: P2p.Peer_id.t -> Block_header.t -> Mempool.t -> unit ; - disconnection: P2p.Peer_id.t -> unit ; + notify_branch: P2p_peer.Id.t -> Block_locator.t -> unit ; + notify_head: P2p_peer.Id.t -> Block_header.t -> Mempool.t -> unit ; + disconnection: P2p_peer.Id.t -> unit ; } (** Register all the possible callback from the distributed DB to the @@ -50,7 +50,7 @@ type callback = { val set_callback: net_db -> callback -> unit (** Kick a given peer. *) -val disconnect: net_db -> P2p.Peer_id.t -> unit Lwt.t +val disconnect: net_db -> P2p_peer.Id.t -> unit Lwt.t (** Various accessors. *) val net_state: net_db -> State.Net.t @@ -63,12 +63,12 @@ module Request : sig (** Send to a given peer, or to all known active peers for the network, a friendly request "Hey, what's your current branch ?". The expected answer is a `Block_locator.t.`. *) - val current_branch: net_db -> ?peer:P2p.Peer_id.t -> unit -> unit + val current_branch: net_db -> ?peer:P2p_peer.Id.t -> unit -> unit (** Send to a given peer, or to all known active peers for the given network, a friendly request "Hey, what's your current branch ?". The expected answer is a `Block_locator.t.`. *) - val current_head: net_db -> ?peer:P2p.Peer_id.t -> unit -> unit + val current_head: net_db -> ?peer:P2p_peer.Id.t -> unit -> unit end @@ -77,13 +77,13 @@ module Advertise : sig (** Notify a given peer, or all known active peers for the network, of a new head and possibly of new operations. *) val current_head: - net_db -> ?peer:P2p.Peer_id.t -> + net_db -> ?peer:P2p_peer.Id.t -> ?mempool:Mempool.t -> State.Block.t -> unit (** Notify a given peer, or all known active peers for the network, of a new head and its sparse history. *) val current_branch: - net_db -> ?peer:P2p.Peer_id.t -> + net_db -> ?peer:P2p_peer.Id.t -> Block_locator.t -> unit Lwt.t end @@ -145,7 +145,7 @@ module type DISTRIBUTED_DB = sig peer (at each retry). *) val fetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> value tzresult Lwt.t @@ -153,7 +153,7 @@ module type DISTRIBUTED_DB = sig stored in the local index when received. *) val prefetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> unit @@ -257,6 +257,6 @@ val commit_protocol: module Raw : sig val encoding: Message.t P2p.Raw.t Data_encoding.t - val supported_versions: P2p_types.Version.t list + val supported_versions: P2p_version.t list end diff --git a/src/lib_shell/distributed_db_functors.ml b/src/lib_shell/distributed_db_functors.ml index e4e752e7c..f7050a1cf 100644 --- a/src/lib_shell/distributed_db_functors.ml +++ b/src/lib_shell/distributed_db_functors.ml @@ -26,13 +26,13 @@ module type DISTRIBUTED_DB = sig val prefetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> unit val fetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> value tzresult Lwt.t @@ -68,12 +68,12 @@ end module type SCHEDULER_EVENTS = sig type t type key - val request: t -> P2p.Peer_id.t option -> key -> unit - val notify: t -> P2p.Peer_id.t -> key -> unit + val request: t -> P2p_peer.Id.t option -> key -> unit + val notify: t -> P2p_peer.Id.t -> key -> unit val notify_cancelation: t -> key -> unit - val notify_unrequested: t -> P2p.Peer_id.t -> key -> unit - val notify_duplicate: t -> P2p.Peer_id.t -> key -> unit - val notify_invalid: t -> P2p.Peer_id.t -> key -> unit + val notify_unrequested: t -> P2p_peer.Id.t -> key -> unit + val notify_duplicate: t -> P2p_peer.Id.t -> key -> unit + val notify_invalid: t -> P2p_peer.Id.t -> key -> unit end module type PRECHECK = sig @@ -103,7 +103,7 @@ module Make_table val create: ?global_input:(key * value) Lwt_watcher.input -> Scheduler.t -> Disk_table.store -> t - val notify: t -> P2p.Peer_id.t -> key -> Precheck.notified_value -> unit Lwt.t + val notify: t -> P2p_peer.Id.t -> key -> Precheck.notified_value -> unit Lwt.t end = struct @@ -306,8 +306,8 @@ end module type REQUEST = sig type key type param - val active : param -> P2p.Peer_id.Set.t - val send : param -> P2p.Peer_id.t -> key list -> unit + val active : param -> P2p_peer.Set.t + val send : param -> P2p_peer.Id.t -> key list -> unit end module Make_request_scheduler @@ -343,24 +343,24 @@ end = struct } and status = { - peers: P2p.Peer_id.Set.t ; + peers: P2p_peer.Set.t ; next_request: float ; delay: float ; } and event = - | Request of P2p.Peer_id.t option * key - | Notify of P2p.Peer_id.t * key + | Request of P2p_peer.Id.t option * key + | Notify of P2p_peer.Id.t * key | Notify_cancelation of key - | Notify_invalid of P2p.Peer_id.t * key - | Notify_duplicate of P2p.Peer_id.t * key - | Notify_unrequested of P2p.Peer_id.t * key + | Notify_invalid of P2p_peer.Id.t * key + | Notify_duplicate of P2p_peer.Id.t * key + | Notify_unrequested of P2p_peer.Id.t * key let request t p k = assert (Lwt_pipe.push_now t.queue (Request (p, k))) let notify t p k = debug "push received %a from %a" - Hash.pp k P2p.Peer_id.pp_short p ; + Hash.pp k P2p_peer.Id.pp_short p ; assert (Lwt_pipe.push_now t.queue (Notify (p, k))) let notify_cancelation t k = debug "push cancelation %a" @@ -368,15 +368,15 @@ end = struct assert (Lwt_pipe.push_now t.queue (Notify_cancelation k)) let notify_invalid t p k = debug "push received invalid %a from %a" - Hash.pp k P2p.Peer_id.pp_short p ; + Hash.pp k P2p_peer.Id.pp_short p ; assert (Lwt_pipe.push_now t.queue (Notify_invalid (p, k))) let notify_duplicate t p k = debug "push received duplicate %a from %a" - Hash.pp k P2p.Peer_id.pp_short p ; + Hash.pp k P2p_peer.Id.pp_short p ; assert (Lwt_pipe.push_now t.queue (Notify_duplicate (p, k))) let notify_unrequested t p k = debug "push received unrequested %a from %a" - Hash.pp k P2p.Peer_id.pp_short p ; + Hash.pp k P2p_peer.Id.pp_short p ; assert (Lwt_pipe.push_now t.queue (Notify_unrequested (p, k))) let compute_timeout state = @@ -399,7 +399,7 @@ end = struct let may_pp_peer ppf = function | None -> () - | Some peer -> P2p.Peer_id.pp_short ppf peer + | Some peer -> P2p_peer.Id.pp_short ppf peer (* TODO should depend on the ressource kind... *) let initial_delay = 0.1 @@ -413,7 +413,7 @@ end = struct let peers = match peer with | None -> data.peers - | Some peer -> P2p.Peer_id.Set.add peer data.peers in + | Some peer -> P2p_peer.Set.add peer data.peers in Table.replace state.pending key { delay = initial_delay ; next_request = min data.next_request (now +. initial_delay) ; @@ -425,8 +425,8 @@ end = struct with Not_found -> let peers = match peer with - | None -> P2p.Peer_id.Set.empty - | Some peer -> P2p.Peer_id.Set.singleton peer in + | None -> P2p_peer.Set.empty + | Some peer -> P2p_peer.Set.singleton peer in Table.add state.pending key { peers ; next_request = now ; @@ -439,7 +439,7 @@ end = struct | Notify (peer, key) -> Table.remove state.pending key ; lwt_debug "received %a from %a" - Hash.pp key P2p.Peer_id.pp_short peer >>= fun () -> + Hash.pp key P2p_peer.Id.pp_short peer >>= fun () -> Lwt.return_unit | Notify_cancelation key -> Table.remove state.pending key ; @@ -448,17 +448,17 @@ end = struct Lwt.return_unit | Notify_invalid (peer, key) -> lwt_debug "received invalid %a from %a" - Hash.pp key P2p.Peer_id.pp_short peer >>= fun () -> + Hash.pp key P2p_peer.Id.pp_short peer >>= fun () -> (* TODO *) Lwt.return_unit | Notify_unrequested (peer, key) -> lwt_debug "received unrequested %a from %a" - Hash.pp key P2p.Peer_id.pp_short peer >>= fun () -> + Hash.pp key P2p_peer.Id.pp_short peer >>= fun () -> (* TODO *) Lwt.return_unit | Notify_duplicate (peer, key) -> lwt_debug "received duplicate %a from %a" - Hash.pp key P2p.Peer_id.pp_short peer >>= fun () -> + Hash.pp key P2p_peer.Id.pp_short peer >>= fun () -> (* TODO *) Lwt.return_unit @@ -487,14 +487,14 @@ end = struct acc else let remaining_peers = - P2p.Peer_id.Set.inter peers active_peers in - if P2p.Peer_id.Set.is_empty remaining_peers && - not (P2p.Peer_id.Set.is_empty peers) then + P2p_peer.Set.inter peers active_peers in + if P2p_peer.Set.is_empty remaining_peers && + not (P2p_peer.Set.is_empty peers) then ( Table.remove state.pending key ; acc ) else let requested_peer = - P2p.Peer_id.random_set_elt - (if P2p.Peer_id.Set.is_empty remaining_peers + P2p_peer.Id.random_set_elt + (if P2p_peer.Set.is_empty remaining_peers then active_peers else remaining_peers) in let next = { peers = remaining_peers ; @@ -502,16 +502,16 @@ end = struct delay = delay *. 1.2 } in Table.replace state.pending key next ; let requests = - try key :: P2p_types.Peer_id.Map.find requested_peer acc + try key :: P2p_peer.Map.find requested_peer acc with Not_found -> [key] in - P2p_types.Peer_id.Map.add requested_peer requests acc) - state.pending P2p_types.Peer_id.Map.empty in - P2p_types.Peer_id.Map.iter (Request.send state.param) requests ; - P2p_types.Peer_id.Map.fold begin fun peer request acc -> + P2p_peer.Map.add requested_peer requests acc) + state.pending P2p_peer.Map.empty in + P2p_peer.Map.iter (Request.send state.param) requests ; + P2p_peer.Map.fold begin fun peer request acc -> acc >>= fun () -> Lwt_list.iter_s (fun key -> lwt_debug "requested %a from %a" - Hash.pp key P2p.Peer_id.pp_short peer) + Hash.pp key P2p_peer.Id.pp_short peer) request end requests Lwt.return_unit >>= fun () -> worker_loop state diff --git a/src/lib_shell/distributed_db_functors.mli b/src/lib_shell/distributed_db_functors.mli index ed05dcd24..8e273ce55 100644 --- a/src/lib_shell/distributed_db_functors.mli +++ b/src/lib_shell/distributed_db_functors.mli @@ -29,13 +29,13 @@ module type DISTRIBUTED_DB = sig val prefetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> unit val fetch: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> key -> param -> value tzresult Lwt.t @@ -72,12 +72,12 @@ end module type SCHEDULER_EVENTS = sig type t type key - val request: t -> P2p.Peer_id.t option -> key -> unit - val notify: t -> P2p.Peer_id.t -> key -> unit + val request: t -> P2p_peer.Id.t option -> key -> unit + val notify: t -> P2p_peer.Id.t -> key -> unit val notify_cancelation: t -> key -> unit - val notify_unrequested: t -> P2p.Peer_id.t -> key -> unit - val notify_duplicate: t -> P2p.Peer_id.t -> key -> unit - val notify_invalid: t -> P2p.Peer_id.t -> key -> unit + val notify_unrequested: t -> P2p_peer.Id.t -> key -> unit + val notify_duplicate: t -> P2p_peer.Id.t -> key -> unit + val notify_invalid: t -> P2p_peer.Id.t -> key -> unit end module type PRECHECK = sig @@ -107,15 +107,15 @@ module Make_table val create: ?global_input:(key * value) Lwt_watcher.input -> Scheduler.t -> Disk_table.store -> t - val notify: t -> P2p.Peer_id.t -> key -> Precheck.notified_value -> unit Lwt.t + val notify: t -> P2p_peer.Id.t -> key -> Precheck.notified_value -> unit Lwt.t end module type REQUEST = sig type key type param - val active : param -> P2p.Peer_id.Set.t - val send : param -> P2p.Peer_id.t -> key list -> unit + val active : param -> P2p_peer.Set.t + val send : param -> P2p_peer.Id.t -> key list -> unit end module Make_request_scheduler diff --git a/src/lib_shell/distributed_db_message.ml b/src/lib_shell/distributed_db_message.ml index fd729f4f8..2a463eedb 100644 --- a/src/lib_shell/distributed_db_message.ml +++ b/src/lib_shell/distributed_db_message.ml @@ -169,7 +169,7 @@ let encoding = ] let versions = - let open P2p.Version in + let open P2p_version in [ { name = "TEZOS" ; major = 0 ; minor = 27 ; diff --git a/src/lib_shell/net_validator.ml b/src/lib_shell/net_validator.ml index 61e300ba8..e6a408cad 100644 --- a/src/lib_shell/net_validator.ml +++ b/src/lib_shell/net_validator.ml @@ -57,17 +57,17 @@ module Types = struct mutable child: (state * (unit -> unit Lwt.t (* shutdown *))) option ; prevalidator: Prevalidator.t ; - active_peers: Peer_validator.t Lwt.t P2p.Peer_id.Table.t ; - bootstrapped_peers: unit P2p.Peer_id.Table.t ; + active_peers: Peer_validator.t Lwt.t P2p_peer.Table.t ; + bootstrapped_peers: unit P2p_peer.Table.t ; } let view (state : state) _ : view = let { bootstrapped ; active_peers ; bootstrapped_peers } = state in { bootstrapped ; active_peers = - P2p.Peer_id.Table.fold (fun id _ l -> id :: l) active_peers [] ; + P2p_peer.Table.fold (fun id _ l -> id :: l) active_peers [] ; bootstrapped_peers = - P2p.Peer_id.Table.fold (fun id _ l -> id :: l) bootstrapped_peers [] } + P2p_peer.Table.fold (fun id _ l -> id :: l) bootstrapped_peers [] } end module Worker = Worker.Make (Name) (Event) (Request) (Types) @@ -99,7 +99,7 @@ let notify_new_block w block = let may_toggle_bootstrapped_network w = let nv = Worker.state w in if not nv.bootstrapped && - P2p.Peer_id.Table.length nv.bootstrapped_peers >= nv.parameters.limits.bootstrap_threshold + P2p_peer.Table.length nv.bootstrapped_peers >= nv.parameters.limits.bootstrap_threshold then begin nv.bootstrapped <- true ; Lwt.wakeup_later nv.bootstrapped_wakener () ; @@ -107,24 +107,24 @@ let may_toggle_bootstrapped_network w = let may_activate_peer_validator w peer_id = let nv = Worker.state w in - try P2p.Peer_id.Table.find nv.active_peers peer_id + try P2p_peer.Table.find nv.active_peers peer_id with Not_found -> let pv = Peer_validator.create ~notify_new_block:(notify_new_block w) ~notify_bootstrapped: begin fun () -> - P2p.Peer_id.Table.add nv.bootstrapped_peers peer_id () ; + P2p_peer.Table.add nv.bootstrapped_peers peer_id () ; may_toggle_bootstrapped_network w end ~notify_termination: begin fun _pv -> - P2p.Peer_id.Table.remove nv.active_peers peer_id ; - P2p.Peer_id.Table.remove nv.bootstrapped_peers peer_id ; + P2p_peer.Table.remove nv.active_peers peer_id ; + P2p_peer.Table.remove nv.bootstrapped_peers peer_id ; end nv.parameters.peer_validator_limits nv.parameters.block_validator nv.parameters.net_db peer_id in - P2p.Peer_id.Table.add nv.active_peers peer_id pv ; + P2p_peer.Table.add nv.active_peers peer_id pv ; pv let may_switch_test_network w spawn_child block = @@ -260,7 +260,7 @@ let on_close w = Lwt.join (Prevalidator.shutdown nv.prevalidator :: Lwt_utils.may ~f:(fun (_, shutdown) -> shutdown ()) nv.child :: - P2p.Peer_id.Table.fold + P2p_peer.Table.fold (fun _ pv acc -> (pv >>= Peer_validator.shutdown) :: acc) nv.active_peers []) >>= fun () -> Lwt.return_unit @@ -280,9 +280,9 @@ let on_launch w _ parameters = bootstrapped_waiter ; bootstrapped = (parameters.limits.bootstrap_threshold <= 0) ; active_peers = - P2p.Peer_id.Table.create 50 ; (* TODO use `2 * max_connection` *) + P2p_peer.Table.create 50 ; (* TODO use `2 * max_connection` *) bootstrapped_peers = - P2p.Peer_id.Table.create 50 ; (* TODO use `2 * max_connection` *) + P2p_peer.Table.create 50 ; (* TODO use `2 * max_connection` *) child = None ; prevalidator } in if nv.bootstrapped then Lwt.wakeup_later bootstrapped_wakener () ; diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index 60e253587..c7f170ed0 100644 --- a/src/lib_shell/node.mli +++ b/src/lib_shell/node.mli @@ -129,58 +129,56 @@ module RPC : sig module Network : sig - open P2p_types - - val stat : t -> Stat.t + val stat : t -> P2p_stat.t val watch : t -> - P2p_types.Connection_pool_log_event.t Lwt_stream.t * Lwt_watcher.stopper - val connect : t -> Point.t -> float -> unit tzresult Lwt.t + P2p_connection.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper + val connect : t -> P2p_point.Id.t -> float -> unit tzresult Lwt.t module Connection : sig - val info : t -> Peer_id.t -> Connection_info.t option - val kick : t -> Peer_id.t -> bool -> unit Lwt.t - val list : t -> Connection_info.t list + val info : t -> P2p_peer.Id.t -> P2p_connection.Info.t option + val kick : t -> P2p_peer.Id.t -> bool -> unit Lwt.t + val list : t -> P2p_connection.Info.t list val count : t -> int end module Point : sig val info : - t -> Point.t -> P2p_types.Point_info.t option + t -> P2p_point.Id.t -> P2p_point.Info.t option val list : - ?restrict: P2p_types.Point_state.t list -> - t -> (Point.t * P2p_types.Point_info.t) list + ?restrict: P2p_point.State.t list -> + t -> (P2p_point.Id.t * P2p_point.Info.t) list val events : - ?max:int -> ?rev:bool -> t -> Point.t -> - P2p_connection_pool_types.Point_info.Event.t list + ?max:int -> ?rev:bool -> t -> P2p_point.Id.t -> + P2p_point.Pool_event.t list val watch : - t -> Point.t -> - P2p_connection_pool_types.Point_info.Event.t Lwt_stream.t * Lwt_watcher.stopper + t -> P2p_point.Id.t -> + P2p_point.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper end module Peer_id : sig val info : - t -> Peer_id.t -> P2p_types.Peer_info.t option + t -> P2p_peer.Id.t -> P2p_peer.Info.t option val list : - ?restrict: P2p_types.Peer_state.t list -> - t -> (Peer_id.t * P2p_types.Peer_info.t) list + ?restrict: P2p_peer.State.t list -> + t -> (P2p_peer.Id.t * P2p_peer.Info.t) list val events : ?max: int -> ?rev: bool -> - t -> Peer_id.t -> - P2p_connection_pool_types.Peer_info.Event.t list + t -> P2p_peer.Id.t -> + P2p_peer.Pool_event.t list val watch : - t -> Peer_id.t -> - P2p_connection_pool_types.Peer_info.Event.t Lwt_stream.t * Lwt_watcher.stopper + t -> P2p_peer.Id.t -> + P2p_peer.Pool_event.t Lwt_stream.t * Lwt_watcher.stopper end diff --git a/src/lib_shell/peer_validator.ml b/src/lib_shell/peer_validator.ml index 49ea64c02..b490e3735 100644 --- a/src/lib_shell/peer_validator.ml +++ b/src/lib_shell/peer_validator.ml @@ -12,13 +12,13 @@ open Peer_validator_worker_state module Name = struct - type t = Net_id.t * P2p.Peer_id.t + type t = Net_id.t * P2p_peer.Id.t let encoding = - Data_encoding.tup2 Net_id.encoding P2p.Peer_id.encoding + Data_encoding.tup2 Net_id.encoding P2p_peer.Id.encoding let base = [ "peer_validator" ] let pp ppf (net, peer) = Format.fprintf ppf "%a:%a" - Net_id.pp_short net P2p.Peer_id.pp_short peer + Net_id.pp_short net P2p_peer.Id.pp_short peer end module Request = struct @@ -57,7 +57,7 @@ module Types = struct } type state = { - peer_id: P2p.Peer_id.t ; + peer_id: P2p_peer.Id.t ; parameters : parameters ; mutable bootstrapped: bool ; mutable last_validated_head: Block_header.t ; @@ -96,7 +96,7 @@ let bootstrap_new_branch w _ancestor _head unknown_prefix = let len = Block_locator_iterator.estimated_length unknown_prefix in debug w "validating new branch from peer %a (approx. %d blocks)" - P2p.Peer_id.pp_short pv.peer_id len ; + P2p_peer.Id.pp_short pv.peer_id len ; let pipeline = Bootstrap_pipeline.create ~notify_new_block:pv.parameters.notify_new_block @@ -116,7 +116,7 @@ let bootstrap_new_branch w _ancestor _head unknown_prefix = set_bootstrapped pv ; debug w "done validating new branch from peer %a." - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; return () let validate_new_head w hash (header : Block_header.t) = @@ -127,14 +127,14 @@ let validate_new_head w hash (header : Block_header.t) = debug w "missing predecessor for new head %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; Distributed_db.Request.current_branch pv.parameters.net_db ~peer:pv.peer_id () ; return () | true -> debug w "fetching operations for new head %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; map_p (fun i -> Worker.protect w begin fun () -> @@ -147,7 +147,7 @@ let validate_new_head w hash (header : Block_header.t) = debug w "requesting validation for new head %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; Block_validator.validate ~notify_new_block:pv.parameters.notify_new_block pv.parameters.block_validator pv.parameters.net_db @@ -155,7 +155,7 @@ let validate_new_head w hash (header : Block_header.t) = debug w "end of validation for new head %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; set_bootstrapped pv ; return () @@ -170,7 +170,7 @@ let only_if_fitness_increases w distant_header cont = debug w "ignoring head %a with non increasing fitness from peer: %a." Block_hash.pp_short (Block_header.hash distant_header) - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; (* Don't download a branch that cannot beat the current head. *) return () end else cont () @@ -185,7 +185,7 @@ let may_validate_new_head w hash header = debug w "ignoring previously validated block %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; set_bootstrapped pv ; pv.last_validated_head <- header ; return () @@ -193,7 +193,7 @@ let may_validate_new_head w hash header = debug w "ignoring known invalid block %a from peer %a" Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; fail Known_invalid end | false -> @@ -210,7 +210,7 @@ let may_validate_new_branch w distant_hash locator = debug w "ignoring branch %a without common ancestor from peer: %a." Block_hash.pp_short distant_hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; fail Unknown_ancestor | Some (ancestor, unknown_prefix) -> bootstrap_new_branch w ancestor distant_header unknown_prefix @@ -218,7 +218,7 @@ let may_validate_new_branch w distant_hash locator = let on_no_request w = let pv = Worker.state w in debug w "no new head from peer %a for %g seconds." - P2p.Peer_id.pp_short pv.peer_id + P2p_peer.Id.pp_short pv.peer_id pv.parameters.limits.new_head_request_timeout ; Distributed_db.Request.current_head pv.parameters.net_db ~peer:pv.peer_id () ; return () @@ -230,13 +230,13 @@ let on_request (type a) w (req : a Request.t) : a tzresult Lwt.t = debug w "processing new head %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; may_validate_new_head w hash header | Request.New_branch (hash, locator) -> (* TODO penalize empty locator... ?? *) debug w "processing new branch %a from peer %a." Block_hash.pp_short hash - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; may_validate_new_branch w hash locator let on_completion w r _ st = @@ -252,7 +252,7 @@ let on_error w r st errs = (* TODO ban the peer_id... *) debug w "Terminating the validation worker for peer %a (kickban)." - P2p.Peer_id.pp_short pv.peer_id ; + P2p_peer.Id.pp_short pv.peer_id ; debug w "%a" Error_monad.pp_print_error errors ; Worker.trigger_shutdown w ; Worker.record_event w (Event.Request (r, st, Some errs)) ; @@ -269,7 +269,7 @@ let on_error w r st errs = debug w "Terminating the validation worker for peer %a \ (missing protocol %a)." - P2p.Peer_id.pp_short pv.peer_id + P2p_peer.Id.pp_short pv.peer_id Protocol_hash.pp_short protocol ; Worker.record_event w (Event.Request (r, st, Some errs)) ; Lwt.return (Error errs) diff --git a/src/lib_shell/peer_validator.mli b/src/lib_shell/peer_validator.mli index 3fdfb9cd5..9048e75ed 100644 --- a/src/lib_shell/peer_validator.mli +++ b/src/lib_shell/peer_validator.mli @@ -17,7 +17,7 @@ type limits = { worker_limits: Worker_types.limits } -val peer_id: t -> P2p.Peer_id.t +val peer_id: t -> P2p_peer.Id.t val bootstrapped: t -> bool val current_head: t -> Block_header.t @@ -27,13 +27,13 @@ val create: ?notify_termination: (unit -> unit) -> limits -> Block_validator.t -> - Distributed_db.net_db -> P2p.Peer_id.t -> t Lwt.t + Distributed_db.net_db -> P2p_peer.Id.t -> t Lwt.t val shutdown: t -> unit Lwt.t val notify_branch: t -> Block_locator.t -> unit val notify_head: t -> Block_header.t -> unit -val running_workers: unit -> ((Net_id.t * P2p.Peer_id.t) * t) list +val running_workers: unit -> ((Net_id.t * P2p_peer.Id.t) * t) list val status: t -> Worker_types.worker_status val current_request : t -> (Time.t * Time.t * Peer_validator_worker_state.Request.view) option diff --git a/src/lib_shell/prevalidator.mli b/src/lib_shell/prevalidator.mli index a9dd5a465..beb0f00c5 100644 --- a/src/lib_shell/prevalidator.mli +++ b/src/lib_shell/prevalidator.mli @@ -40,7 +40,7 @@ type error += Closed of Net_id.t val create: limits -> Distributed_db.net_db -> t Lwt.t val shutdown: t -> unit Lwt.t -val notify_operations: t -> P2p.Peer_id.t -> Mempool.t -> unit +val notify_operations: t -> P2p_peer.Id.t -> Mempool.t -> unit val inject_operation: t -> Operation.t -> unit tzresult Lwt.t val flush: t -> Block_hash.t -> unit tzresult Lwt.t val timestamp: t -> Time.t diff --git a/src/lib_shell/protocol_validator.mli b/src/lib_shell/protocol_validator.mli index f0f9ac8b9..03135ebc2 100644 --- a/src/lib_shell/protocol_validator.mli +++ b/src/lib_shell/protocol_validator.mli @@ -28,19 +28,19 @@ val shutdown: t -> unit Lwt.t val fetch_and_compile_protocol: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> Protocol_hash.t -> State.Registred_protocol.t tzresult Lwt.t val fetch_and_compile_protocols: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> State.Block.t -> unit tzresult Lwt.t val prefetch_and_compile_protocols: t -> - ?peer:P2p.Peer_id.t -> + ?peer:P2p_peer.Id.t -> ?timeout:float -> State.Block.t -> unit diff --git a/src/lib_shell_services/block_validator_worker_state.ml b/src/lib_shell_services/block_validator_worker_state.ml index 6bcb79e1a..43cf8f34c 100644 --- a/src/lib_shell_services/block_validator_worker_state.ml +++ b/src/lib_shell_services/block_validator_worker_state.ml @@ -11,7 +11,7 @@ module Request = struct type view = { net_id : Net_id.t ; block : Block_hash.t ; - peer : P2p_types.Peer_id.t option ; + peer : P2p_peer.Id.t option ; } let encoding = let open Data_encoding in @@ -21,7 +21,7 @@ module Request = struct (obj3 (req "block" Block_hash.encoding) (req "net_id" Net_id.encoding) - (opt "peer" P2p_types.Peer_id.encoding)) + (opt "peer" P2p_peer.Id.encoding)) let pp ppf { net_id ; block ; peer } = Format.fprintf ppf "Validation of %a (net: %a)" @@ -31,7 +31,7 @@ module Request = struct | None -> () | Some peer -> Format.fprintf ppf "from peer %a" - P2p_types.Peer_id.pp_short peer + P2p_peer.Id.pp_short peer end module Event = struct diff --git a/src/lib_shell_services/block_validator_worker_state.mli b/src/lib_shell_services/block_validator_worker_state.mli index e297cce04..20e7a727c 100644 --- a/src/lib_shell_services/block_validator_worker_state.mli +++ b/src/lib_shell_services/block_validator_worker_state.mli @@ -11,7 +11,7 @@ module Request : sig type view = { net_id : Net_id.t ; block : Block_hash.t ; - peer: P2p_types.Peer_id.t option ; + peer: P2p_peer.Id.t option ; } val encoding : view Data_encoding.encoding val pp : Format.formatter -> view -> unit diff --git a/src/lib_shell_services/net_validator_worker_state.ml b/src/lib_shell_services/net_validator_worker_state.ml index de9eca1dd..27ba18691 100644 --- a/src/lib_shell_services/net_validator_worker_state.ml +++ b/src/lib_shell_services/net_validator_worker_state.ml @@ -89,8 +89,8 @@ end module Worker_state = struct type view = - { active_peers : P2p_types.Peer_id.t list ; - bootstrapped_peers : P2p_types.Peer_id.t list ; + { active_peers : P2p_peer.Id.t list ; + bootstrapped_peers : P2p_peer.Id.t list ; bootstrapped : bool } let encoding = let open Data_encoding in @@ -101,8 +101,8 @@ module Worker_state = struct { bootstrapped ; bootstrapped_peers ; active_peers }) (obj3 (req "bootstrapped" bool) - (req "bootstrapped_peers" (list P2p_types.Peer_id.encoding)) - (req "active_peers" (list P2p_types.Peer_id.encoding))) + (req "bootstrapped_peers" (list P2p_peer.Id.encoding)) + (req "active_peers" (list P2p_peer.Id.encoding))) let pp ppf { bootstrapped ; bootstrapped_peers ; active_peers } = Format.fprintf ppf @@ -110,8 +110,8 @@ module Worker_state = struct @[Active peers:%a@]@,\ @[Bootstrapped peers:%a@]@]" (if bootstrapped then "" else " not yet") - (fun ppf -> List.iter (Format.fprintf ppf "@,- %a" P2p_types.Peer_id.pp)) + (fun ppf -> List.iter (Format.fprintf ppf "@,- %a" P2p_peer.Id.pp)) active_peers - (fun ppf -> List.iter (Format.fprintf ppf "@,- %a" P2p_types.Peer_id.pp)) + (fun ppf -> List.iter (Format.fprintf ppf "@,- %a" P2p_peer.Id.pp)) bootstrapped_peers end diff --git a/src/lib_shell_services/net_validator_worker_state.mli b/src/lib_shell_services/net_validator_worker_state.mli index f3c58b9f7..995c0a522 100644 --- a/src/lib_shell_services/net_validator_worker_state.mli +++ b/src/lib_shell_services/net_validator_worker_state.mli @@ -32,8 +32,8 @@ end module Worker_state : sig type view = - { active_peers : P2p_types.Peer_id.t list ; - bootstrapped_peers : P2p_types.Peer_id.t list ; + { active_peers : P2p_peer.Id.t list ; + bootstrapped_peers : P2p_peer.Id.t list ; bootstrapped : bool } val encoding : view Data_encoding.encoding val pp : Format.formatter -> view -> unit diff --git a/src/lib_shell_services/prevalidator_worker_state.ml b/src/lib_shell_services/prevalidator_worker_state.ml index acaacf1a5..e2ddb748e 100644 --- a/src/lib_shell_services/prevalidator_worker_state.ml +++ b/src/lib_shell_services/prevalidator_worker_state.ml @@ -10,7 +10,7 @@ module Request = struct type 'a t = | Flush : Block_hash.t -> unit t - | Notify : P2p_types.Peer_id.t * Mempool.t -> unit t + | Notify : P2p_peer.Id.t * Mempool.t -> unit t | Inject : Operation.t -> unit tzresult t | Arrived : Operation_hash.t * Operation.t -> unit t | Advertise : unit t @@ -30,7 +30,7 @@ module Request = struct case (Tag 1) (obj3 (req "request" (constant "notify")) - (req "peer" P2p_types.Peer_id.encoding) + (req "peer" P2p_peer.Id.encoding) (req "mempool" Mempool.encoding)) (function View (Notify (peer, mempool)) -> Some ((), peer, mempool) | _ -> None) (fun ((), peer, mempool) -> View (Notify (peer, mempool))) ; @@ -58,7 +58,7 @@ module Request = struct Block_hash.pp hash | Notify (id, { Mempool.known_valid ; pending }) -> Format.fprintf ppf "@[notified by %a of operations" - P2p_types.Peer_id.pp id ; + P2p_peer.Id.pp id ; List.iter (fun oph -> Format.fprintf ppf "@,%a (applied)" diff --git a/src/lib_shell_services/prevalidator_worker_state.mli b/src/lib_shell_services/prevalidator_worker_state.mli index 1365baea8..274033527 100644 --- a/src/lib_shell_services/prevalidator_worker_state.mli +++ b/src/lib_shell_services/prevalidator_worker_state.mli @@ -10,7 +10,7 @@ module Request : sig type 'a t = | Flush : Block_hash.t -> unit t - | Notify : P2p_types.Peer_id.t * Mempool.t -> unit t + | Notify : P2p_peer.Id.t * Mempool.t -> unit t | Inject : Operation.t -> unit tzresult t | Arrived : Operation_hash.t * Operation.t -> unit t | Advertise : unit t diff --git a/src/lib_shell_services/shell_services.ml b/src/lib_shell_services/shell_services.ml index 100a9346a..a613feb5c 100644 --- a/src/lib_shell_services/shell_services.ml +++ b/src/lib_shell_services/shell_services.ml @@ -558,14 +558,14 @@ module Workers = struct ~construct:Net_id.to_b58check () - let (peer_id_arg : P2p_types.Peer_id.t RPC_arg.t) = + let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) = RPC_arg.make ~name:"peer_id" ~descr:"The peer identifier of whom the prevalidator is responsible." ~destruct:(fun s -> try - Ok (P2p_types.Peer_id.of_b58check_exn s) + Ok (P2p_peer.Id.of_b58check_exn s) with Failure msg -> Error msg) - ~construct:P2p_types.Peer_id.to_b58check + ~construct:P2p_peer.Id.to_b58check () let list = @@ -577,7 +577,7 @@ module Workers = struct ~output: (list (obj2 - (req "peer_id" P2p_types.Peer_id.encoding) + (req "peer_id" P2p_peer.Id.encoding) (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) RPC_path.(root / "workers" / "peer_validators" /: net_id_arg) diff --git a/src/lib_shell_services/shell_services.mli b/src/lib_shell_services/shell_services.mli index 1b553f194..6c4fd6c4d 100644 --- a/src/lib_shell_services/shell_services.mli +++ b/src/lib_shell_services/shell_services.mli @@ -201,11 +201,11 @@ module Workers : sig val list : ([ `POST ], unit, unit * Net_id.t, unit, unit, - (P2p_types.Peer_id.t * Worker_types.worker_status) list, unit) RPC_service.t + (P2p_peer.Id.t * Worker_types.worker_status) list, unit) RPC_service.t val state : ([ `POST ], unit, - (unit * Net_id.t) * P2p_types.Peer_id.t, unit, unit, + (unit * Net_id.t) * P2p_peer.Id.t, unit, unit, (Request.view, Event.t) Worker_types.full_status, unit) RPC_service.t diff --git a/test/p2p/jbuild b/test/p2p/jbuild index 8eadbb74d..4bb45b8cf 100644 --- a/test/p2p/jbuild +++ b/test/p2p/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (executables - ((names (test_p2p_connection - test_p2p_connection_pool + ((names (test_p2p_socket + test_p2p_pool test_p2p_io_scheduler)) (libraries (tezos-base tezos-p2p-services @@ -18,17 +18,17 @@ (alias ((name buildtest) - (deps (test_p2p_connection.exe - test_p2p_connection_pool.exe + (deps (test_p2p_socket.exe + test_p2p_pool.exe test_p2p_io_scheduler.exe)))) (alias - ((name runtest_p2p_connection) - (action (run ${exe:test_p2p_connection.exe} -v)))) + ((name runtest_p2p_socket) + (action (run ${exe:test_p2p_socket.exe} -v)))) (alias - ((name runtest_p2p_connection_pool) - (action (run ${exe:test_p2p_connection_pool.exe} --clients 10 --repeat 5 -v)))) + ((name runtest_p2p_pool) + (action (run ${exe:test_p2p_pool.exe} --clients 10 --repeat 5 -v)))) (alias ((name runtest_p2p_io_scheduler) @@ -40,8 +40,8 @@ (alias ((name runtest) - (deps ((alias runtest_p2p_connection) - (alias runtest_p2p_connection_pool) + (deps ((alias runtest_p2p_socket) + (alias runtest_p2p_pool) (alias runtest_p2p_io_scheduler))))) (alias diff --git a/test/p2p/test_p2p_io_scheduler.ml b/test/p2p/test_p2p_io_scheduler.ml index 42173c753..7c8a8928f 100644 --- a/test/p2p/test_p2p_io_scheduler.ml +++ b/test/p2p/test_p2p_io_scheduler.ml @@ -7,7 +7,6 @@ (* *) (**************************************************************************) -open P2p_types include Logging.Make (struct let name = "test-p2p-io-scheduler" end) exception Error of error list @@ -89,18 +88,18 @@ let server ~read_buffer_size () in Moving_average.on_update begin fun () -> - log_notice "Stat: %a" Stat.pp (P2p_io_scheduler.global_stat sched) ; + log_notice "Stat: %a" P2p_stat.pp (P2p_io_scheduler.global_stat sched) ; if display_client_stat then P2p_io_scheduler.iter_connection sched (fun id conn -> - log_notice " client(%d) %a" id Stat.pp (P2p_io_scheduler.stat conn)) ; + log_notice " client(%d) %a" id P2p_stat.pp (P2p_io_scheduler.stat conn)) ; end ; (* Accept and read message until the connection is closed. *) accept_n main_socket n >>=? fun conns -> let conns = List.map (P2p_io_scheduler.register sched) conns in Lwt.join (List.map receive conns) >>= fun () -> iter_p P2p_io_scheduler.close conns >>=? fun () -> - log_notice "OK %a" Stat.pp (P2p_io_scheduler.global_stat sched) ; + log_notice "OK %a" P2p_stat.pp (P2p_io_scheduler.global_stat sched) ; return () let max_size ?max_upload_speed () = @@ -131,7 +130,7 @@ let client ?max_upload_speed ?write_queue_size addr port time _n = Lwt_unix.sleep time >>= return ] >>=? fun () -> P2p_io_scheduler.close conn >>=? fun () -> let stat = P2p_io_scheduler.stat conn in - lwt_log_notice "Client OK %a" Stat.pp stat >>= fun () -> + lwt_log_notice "Client OK %a" P2p_stat.pp stat >>= fun () -> return () let run diff --git a/test/p2p/test_p2p_connection_pool.ml b/test/p2p/test_p2p_pool.ml similarity index 82% rename from test/p2p/test_p2p_connection_pool.ml rename to test/p2p/test_p2p_pool.ml index 3b1dbc8ea..d078c8309 100644 --- a/test/p2p/test_p2p_connection_pool.ml +++ b/test/p2p/test_p2p_pool.ml @@ -7,16 +7,15 @@ (* *) (**************************************************************************) -open P2p_types include Logging.Make (struct let name = "test.p2p.connection-pool" end) type message = | Ping -let msg_config : message P2p_connection_pool.message_config = { +let msg_config : message P2p_pool.message_config = { encoding = [ - P2p_connection_pool.Encoding { + P2p_pool.Encoding { tag = 0x10 ; encoding = Data_encoding.empty ; wrap = (function () -> Ping) ; @@ -24,12 +23,12 @@ let msg_config : message P2p_connection_pool.message_config = { max_length = None ; } ; ] ; - versions = Version.[ { name = "TEST" ; major = 0 ; minor = 0 } ] ; + versions = P2p_version.[ { name = "TEST" ; major = 0 ; minor = 0 } ] ; } type metadata = unit -let meta_config : metadata P2p_connection_pool.meta_config = { +let meta_config : metadata P2p_pool.meta_config = { encoding = Data_encoding.empty ; initial = () ; score = fun () -> 0. ; @@ -59,9 +58,9 @@ let sync_nodes nodes = let detach_node f points n = let (addr, port), points = List.select n points in let proof_of_work_target = Crypto_box.make_target 0. in - let identity = Identity.generate proof_of_work_target in + let identity = P2p_identity.generate proof_of_work_target in let nb_points = List.length points in - let config = P2p_connection_pool.{ + let config = P2p_pool.{ identity ; proof_of_work_target ; trusted_points = points ; @@ -83,10 +82,10 @@ let detach_node f points n = binary_chunks_size = None } in Process.detach - ~prefix:(Format.asprintf "%a: " Peer_id.pp_short identity.peer_id) + ~prefix:(Format.asprintf "%a: " P2p_peer.Id.pp_short identity.peer_id) begin fun channel -> let sched = P2p_io_scheduler.create ~read_buffer_size:(1 lsl 12) () in - P2p_connection_pool.create + P2p_pool.create config meta_config msg_config sched >>= fun pool -> P2p_welcome.run ~backlog:10 pool ~addr port >>= fun welcome -> lwt_log_info "Node ready (port: %d)" port >>= fun () -> @@ -94,7 +93,7 @@ let detach_node f points n = f channel pool points >>=? fun () -> lwt_log_info "Shutting down..." >>= fun () -> P2p_welcome.shutdown welcome >>= fun () -> - P2p_connection_pool.destroy pool >>= fun () -> + P2p_pool.destroy pool >>= fun () -> P2p_io_scheduler.shutdown sched >>= fun () -> lwt_log_info "Bye." >>= fun () -> return () @@ -112,34 +111,34 @@ type error += Connect | Write | Read module Simple = struct let rec connect ~timeout pool point = - lwt_log_info "Connect to %a" Point.pp point >>= fun () -> - P2p_connection_pool.connect pool point ~timeout >>= function - | Error [P2p_connection_pool.Connected] -> begin - match P2p_connection_pool.Connection.find_by_point pool point with + lwt_log_info "Connect to %a" P2p_point.Id.pp point >>= fun () -> + P2p_pool.connect pool point ~timeout >>= function + | Error [P2p_pool.Connected] -> begin + match P2p_pool.Connection.find_by_point pool point with | Some conn -> return conn | None -> failwith "Woops..." end - | Error ([ P2p_connection_pool.Connection_refused - | P2p_connection_pool.Pending_connection - | P2p_connection.Rejected + | Error ([ P2p_pool.Connection_refused + | P2p_pool.Pending_connection + | P2p_socket.Rejected | Lwt_utils.Canceled | Lwt_utils.Timeout - | P2p_connection_pool.Rejected _ as err ]) -> + | P2p_pool.Rejected _ as err ]) -> lwt_log_info "Connection to %a failed (%a)" - Point.pp point + P2p_point.Id.pp point (fun ppf err -> match err with - | P2p_connection_pool.Connection_refused -> + | P2p_pool.Connection_refused -> Format.fprintf ppf "connection refused" - | P2p_connection_pool.Pending_connection -> + | P2p_pool.Pending_connection -> Format.fprintf ppf "pending connection" - | P2p_connection.Rejected -> + | P2p_socket.Rejected -> Format.fprintf ppf "rejected" | Lwt_utils.Canceled -> Format.fprintf ppf "canceled" | Lwt_utils.Timeout -> Format.fprintf ppf "timeout" - | P2p_connection_pool.Rejected peer -> - Format.fprintf ppf "rejected (%a)" Peer_id.pp peer + | P2p_pool.Rejected peer -> + Format.fprintf ppf "rejected (%a)" P2p_peer.Id.pp peer | _ -> assert false) err >>= fun () -> Lwt_unix.sleep (0.5 +. Random.float 2.) >>= fun () -> connect ~timeout pool point @@ -151,18 +150,18 @@ module Simple = struct let write_all conns msg = iter_p (fun conn -> - trace Write @@ P2p_connection_pool.write_sync conn msg) + trace Write @@ P2p_pool.write_sync conn msg) conns let read_all conns = iter_p (fun conn -> - trace Read @@ P2p_connection_pool.read conn >>=? fun Ping -> + trace Read @@ P2p_pool.read conn >>=? fun Ping -> return ()) conns let close_all conns = - Lwt_list.iter_p P2p_connection_pool.disconnect conns + Lwt_list.iter_p P2p_pool.disconnect conns let node channel pool points = connect_all ~timeout:2. pool points >>=? fun conns -> @@ -187,10 +186,10 @@ module Random_connections = struct let rec connect_random pool total rem point n = Lwt_unix.sleep (0.2 +. Random.float 1.0) >>= fun () -> (trace Connect @@ Simple.connect ~timeout:2. pool point) >>=? fun conn -> - (trace Write @@ P2p_connection_pool.write conn Ping) >>= fun _ -> - (trace Read @@ P2p_connection_pool.read conn) >>=? fun Ping -> + (trace Write @@ P2p_pool.write conn Ping) >>= fun _ -> + (trace Read @@ P2p_pool.read conn) >>=? fun Ping -> Lwt_unix.sleep (0.2 +. Random.float 1.0) >>= fun () -> - P2p_connection_pool.disconnect conn >>= fun () -> + P2p_pool.disconnect conn >>= fun () -> begin decr rem ; if !rem mod total = 0 then @@ -231,7 +230,7 @@ module Garbled = struct let bad_msg = MBytes.of_string (String.make 16 '\000') in iter_p (fun conn -> - trace Write @@ P2p_connection_pool.raw_write_sync conn bad_msg) + trace Write @@ P2p_pool.raw_write_sync conn bad_msg) conns let node ch pool points = diff --git a/test/p2p/test_p2p_connection.ml b/test/p2p/test_p2p_socket.ml similarity index 78% rename from test/p2p/test_p2p_connection.ml rename to test/p2p/test_p2p_socket.ml index f2f802462..d7323d805 100644 --- a/test/p2p/test_p2p_connection.ml +++ b/test/p2p/test_p2p_socket.ml @@ -10,20 +10,19 @@ (* TODO Use Kaputt on the client side and remove `assert` from the server. *) -open P2p_types include Logging.Make (struct let name = "test.p2p.connection" end) let default_addr = Ipaddr.V6.localhost let proof_of_work_target = Crypto_box.make_target 16. -let id1 = Identity.generate proof_of_work_target -let id2 = Identity.generate proof_of_work_target +let id1 = P2p_identity.generate proof_of_work_target +let id2 = P2p_identity.generate proof_of_work_target let id0 = (* Luckilly, this will be an insuficient proof of work! *) - Identity.generate (Crypto_box.make_target 0.) + P2p_identity.generate (Crypto_box.make_target 0.) -let versions = Version.[{ name = "TEST" ; minor = 0 ; major = 0 }] +let versions = P2p_version.[{ name = "TEST" ; minor = 0 ; major = 0 }] let random_bytes len = let msg = MBytes.create len in @@ -104,7 +103,7 @@ let raw_accept sched main_socket = let accept sched main_socket = raw_accept sched main_socket >>= fun (fd, point) -> - P2p_connection.authenticate + P2p_socket.authenticate ~proof_of_work_target ~incoming:true fd point id1 versions @@ -118,11 +117,11 @@ let raw_connect sched addr port = let connect sched addr port id = raw_connect sched addr port >>= fun fd -> - P2p_connection.authenticate + P2p_socket.authenticate ~proof_of_work_target ~incoming:false fd (addr, port) id versions >>=? fun (info, auth_fd) -> _assert (not info.incoming) __LOC__ "" >>=? fun () -> - _assert (Peer_id.compare info.peer_id id1.peer_id = 0) + _assert (P2p_peer.Id.compare info.peer_id id1.peer_id = 0) __LOC__ "" >>=? fun () -> return auth_fd @@ -134,7 +133,7 @@ let is_connection_closed = function false let is_decoding_error = function - | Error [P2p_connection.Decoding_error] -> true + | Error [P2p_socket.Decoding_error] -> true | Ok _ -> false | Error err -> log_notice "Error: %a" pp_print_error err ; @@ -167,7 +166,7 @@ module Kick = struct let encoding = Data_encoding.bytes let is_rejected = function - | Error [P2p_connection.Rejected] -> true + | Error [P2p_socket.Rejected] -> true | Ok _ -> false | Error err -> log_notice "Error: %a" pp_print_error err ; @@ -176,14 +175,14 @@ module Kick = struct let server _ch sched socket = accept sched socket >>=? fun (info, auth_fd) -> _assert (info.incoming) __LOC__ "" >>=? fun () -> - _assert (Peer_id.compare info.peer_id id2.peer_id = 0) + _assert (P2p_peer.Id.compare info.peer_id id2.peer_id = 0) __LOC__ "" >>=? fun () -> - P2p_connection.kick auth_fd >>= fun () -> + P2p_socket.kick auth_fd >>= fun () -> return () let client _ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>= fun conn -> + P2p_socket.accept auth_fd encoding >>= fun conn -> _assert (is_rejected conn) __LOC__ "" >>=? fun () -> return () @@ -197,13 +196,13 @@ module Kicked = struct let server _ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>= fun conn -> + P2p_socket.accept auth_fd encoding >>= fun conn -> _assert (Kick.is_rejected conn) __LOC__ "" >>=? fun () -> return () let client _ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.kick auth_fd >>= fun () -> + P2p_socket.kick auth_fd >>= fun () -> return () let run _dir = run_nodes client server @@ -219,22 +218,22 @@ module Simple_message = struct let server ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.write_sync conn simple_msg >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg2 msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let client ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg2 >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.write_sync conn simple_msg2 >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server @@ -250,24 +249,24 @@ module Chunked_message = struct let server ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept + P2p_socket.accept ~binary_chunks_size:21 auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.write_sync conn simple_msg >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg2 msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let client ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept + P2p_socket.accept ~binary_chunks_size:21 auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg2 >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.write_sync conn simple_msg2 >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server @@ -283,22 +282,22 @@ module Oversized_message = struct let server ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.write_sync conn simple_msg >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg2 msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let client ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.write_sync conn simple_msg2 >>=? fun () -> - P2p_connection.read conn >>=? fun (_msg_size, msg) -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.write_sync conn simple_msg2 >>=? fun () -> + P2p_socket.read conn >>=? fun (_msg_size, msg) -> _assert (MBytes.compare simple_msg msg = 0) __LOC__ "" >>=? fun () -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server @@ -313,18 +312,18 @@ module Close_on_read = struct let server ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> sync ch >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let client ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> sync ch >>=? fun () -> - P2p_connection.read conn >>= fun err -> + P2p_socket.read conn >>= fun err -> _assert (is_connection_closed err) __LOC__ "" >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server @@ -339,19 +338,19 @@ module Close_on_write = struct let server ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.close conn >>= fun _stat -> sync ch >>=? fun ()-> return () let client ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> sync ch >>=? fun ()-> Lwt_unix.sleep 0.1 >>= fun () -> - P2p_connection.write_sync conn simple_msg >>= fun err -> + P2p_socket.write_sync conn simple_msg >>= fun err -> _assert (is_connection_closed err) __LOC__ "" >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server @@ -376,19 +375,19 @@ module Garbled_data = struct let server _ch sched socket = accept sched socket >>=? fun (_info, auth_fd) -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.raw_write_sync conn garbled_msg >>=? fun () -> - P2p_connection.read conn >>= fun err -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.raw_write_sync conn garbled_msg >>=? fun () -> + P2p_socket.read conn >>= fun err -> _assert (is_connection_closed err) __LOC__ "" >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let client _ch sched addr port = connect sched addr port id2 >>=? fun auth_fd -> - P2p_connection.accept auth_fd encoding >>=? fun conn -> - P2p_connection.read conn >>= fun err -> + P2p_socket.accept auth_fd encoding >>=? fun conn -> + P2p_socket.read conn >>= fun err -> _assert (is_decoding_error err) __LOC__ "" >>=? fun () -> - P2p_connection.close conn >>= fun _stat -> + P2p_socket.close conn >>= fun _stat -> return () let run _dir = run_nodes client server From 1d5b4c1e3b25cbe11380a6ee6529f3bc879eaee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Fri, 26 Jan 2018 13:07:49 +0100 Subject: [PATCH 13/27] Refactor: merge `lib_p2p_services` into `lib_shell_services` Also split the module `Shell_services` in smaller modules. --- src/bin_node/jbuild | 10 +- src/lib_client_base/client_admin.ml | 2 +- src/lib_client_base/client_commands.ml | 2 +- src/lib_client_base/client_commands.mli | 6 +- src/lib_client_base/client_config.ml | 6 +- src/lib_client_base/client_debug.ml | 6 +- src/lib_client_base/client_node_rpcs.ml | 61 +- src/lib_client_base/client_node_rpcs.mli | 2 +- src/lib_client_base/client_rpcs.ml | 2 +- src/lib_client_base/client_rpcs.mli | 2 +- src/lib_client_base/jbuild | 4 +- src/lib_client_base/tezos-client-base.opam | 3 +- src/lib_p2p/jbuild | 6 +- src/lib_p2p/tezos-p2p.opam | 1 - src/lib_p2p_services/jbuild | 12 - src/lib_p2p_services/tezos-p2p-services.opam | 19 - src/lib_shell/jbuild | 2 - src/lib_shell/node.ml | 4 +- src/lib_shell/node.mli | 4 +- src/lib_shell/node_rpc.ml | 94 ++- src/lib_shell/tezos-shell.opam | 1 - src/lib_shell_services/block_services.ml | 436 ++++++++++++ src/lib_shell_services/block_services.mli | 140 ++++ src/lib_shell_services/jbuild | 6 +- .../p2p_services.ml | 0 .../p2p_services.mli | 0 src/lib_shell_services/protocol_services.ml | 52 ++ src/lib_shell_services/protocol_services.mli | 23 + src/lib_shell_services/shell_services.ml | 631 ------------------ src/lib_shell_services/shell_services.mli | 223 ------- src/lib_shell_services/worker_services.ml | 163 +++++ src/lib_shell_services/worker_services.mli | 71 ++ .../lib_client_alpha/client_proto_rpcs.ml | 8 +- .../lib_client_alpha/client_proto_rpcs.mli | 2 +- .../lib_client_demo/client_proto_rpcs.ml | 2 +- .../lib_client_genesis/client_proto_main.ml | 2 +- test/p2p/jbuild | 2 - 37 files changed, 996 insertions(+), 1014 deletions(-) delete mode 100644 src/lib_p2p_services/jbuild delete mode 100644 src/lib_p2p_services/tezos-p2p-services.opam create mode 100644 src/lib_shell_services/block_services.ml create mode 100644 src/lib_shell_services/block_services.mli rename src/{lib_p2p_services => lib_shell_services}/p2p_services.ml (100%) rename src/{lib_p2p_services => lib_shell_services}/p2p_services.mli (100%) create mode 100644 src/lib_shell_services/protocol_services.ml create mode 100644 src/lib_shell_services/protocol_services.mli create mode 100644 src/lib_shell_services/worker_services.ml create mode 100644 src/lib_shell_services/worker_services.mli diff --git a/src/bin_node/jbuild b/src/bin_node/jbuild index d6967834b..8cafc4369 100644 --- a/src/bin_node/jbuild +++ b/src/bin_node/jbuild @@ -4,10 +4,9 @@ ((name main) (public_name tezos-node) (libraries (tezos-base - tezos-rpc-http - tezos-p2p-services - tezos-p2p tezos-shell-services + tezos-rpc-http + tezos-p2p tezos-shell tezos-protocol-updater tezos-embedded-protocol-genesis @@ -18,10 +17,9 @@ (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_rpc_http - -open Tezos_p2p_services - -open Tezos_p2p -open Tezos_shell_services + -open Tezos_rpc_http + -open Tezos_p2p -open Tezos_shell -open Tezos_protocol_updater -linkall)))) diff --git a/src/lib_client_base/client_admin.ml b/src/lib_client_base/client_admin.ml index d9b905e73..0b12315a5 100644 --- a/src/lib_client_base/client_admin.ml +++ b/src/lib_client_base/client_admin.ml @@ -18,6 +18,6 @@ let commands () = @@ Block_hash.param ~name:"block" ~desc:"block to remove from invalid list" @@ stop) (fun () block (cctxt : Client_commands.full_context) -> - Client_rpcs.call_err_service0 cctxt Node_rpc_services.Blocks.unmark_invalid block >>=? fun () -> + Client_rpcs.call_err_service0 cctxt Block_services.unmark_invalid block >>=? fun () -> cctxt#message "Block %a no longer marked invalid" Block_hash.pp block >>= return) ; ] diff --git a/src/lib_client_base/client_commands.ml b/src/lib_client_base/client_commands.ml index 305484caa..39d82b39a 100644 --- a/src/lib_client_base/client_commands.ml +++ b/src/lib_client_base/client_commands.ml @@ -44,7 +44,7 @@ class type wallet = object end class type block = object - method block : Shell_services.Blocks.block + method block : Block_services.block end class type logging_wallet = object diff --git a/src/lib_client_base/client_commands.mli b/src/lib_client_base/client_commands.mli index 740a8c7ef..ead142c48 100644 --- a/src/lib_client_base/client_commands.mli +++ b/src/lib_client_base/client_commands.mli @@ -28,7 +28,7 @@ class type wallet = object end class type block = object - method block : Shell_services.Blocks.block + method block : Block_services.block end class type logging_wallet = object @@ -56,7 +56,7 @@ end val make_context : ?base_dir:string -> - ?block:Shell_services.Blocks.block -> + ?block:Block_services.block -> ?rpc_config:Client_rpcs.config -> (string -> string -> unit Lwt.t) -> full_context (** [make_context ?config log_fun] builds a context whose logging @@ -81,4 +81,4 @@ val get_versions: unit -> (Protocol_hash.t * (command list)) list val force_switch : (bool, full_context) Cli_entries.arg val default_base_dir : string -val default_block : Shell_services.Blocks.block +val default_block : Block_services.block diff --git a/src/lib_client_base/client_config.ml b/src/lib_client_base/client_config.ml index f5cf391ea..168d5ddcf 100644 --- a/src/lib_client_base/client_config.ml +++ b/src/lib_client_base/client_config.ml @@ -103,7 +103,7 @@ module Cfg_file = struct end type cli_args = { - block: Shell_services.Blocks.block ; + block: Block_services.block ; protocol: Protocol_hash.t option ; print_timings: bool ; log_requests: bool ; @@ -124,7 +124,7 @@ let string_parameter : (string, Client_commands.full_context) parameter = let block_parameter = parameter - (fun _ block -> match Shell_services.Blocks.parse_block block with + (fun _ block -> match Block_services.parse_block block with | Error _ -> fail (Invalid_block_argument block) | Ok block -> return block) @@ -161,7 +161,7 @@ let block_arg = default_arg ~parameter:"-block" ~doc:"The block on which to apply contextual commands." - ~default:(Shell_services.Blocks.to_string default_cli_args.block) + ~default:(Block_services.to_string default_cli_args.block) block_parameter let protocol_arg = arg diff --git a/src/lib_client_base/client_debug.ml b/src/lib_client_base/client_debug.ml index 41c5c71b1..1f4cfc1b5 100644 --- a/src/lib_client_base/client_debug.ml +++ b/src/lib_client_base/client_debug.ml @@ -10,7 +10,7 @@ (* Commands used to debug the node/alphanet *) let pp_block ppf - { Shell_services.Blocks.hash ; net_id ; level ; + { Block_services.hash ; net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness ; data ; operations ; protocol ; test_network } = @@ -62,7 +62,7 @@ let registered_protocols ppf = (Client_commands.get_versions ()) let print_heads ppf cctxt = - Client_rpcs.call_service0 cctxt Shell_services.Blocks.list + Client_rpcs.call_service0 cctxt Block_services.list { include_ops = true ; length = Some 1 ; heads = None ; @@ -82,7 +82,7 @@ let print_heads ppf cctxt = let print_rejected ppf cctxt = Client_rpcs.call_service0 cctxt - Shell_services.Blocks.list_invalid () >>=? fun invalid -> + Block_services.list_invalid () >>=? fun invalid -> return @@ Format.pp_print_list (fun ppf (hash, level, errors) -> diff --git a/src/lib_client_base/client_node_rpcs.ml b/src/lib_client_base/client_node_rpcs.ml index 0cf10f552..0fe2d5c8c 100644 --- a/src/lib_client_base/client_node_rpcs.ml +++ b/src/lib_client_base/client_node_rpcs.ml @@ -10,37 +10,36 @@ (* Tezos Command line interface - RPC Calls *) open Client_rpcs -module Services = Shell_services let errors (rpc : #Client_rpcs.ctxt) = call_service0 rpc RPC_error.service () let forge_block_header rpc header = - call_service0 rpc Services.forge_block_header header + call_service0 rpc Shell_services.forge_block_header header let inject_block cctxt ?(async = false) ?(force = false) ?net_id raw operations = - call_err_service0 cctxt Services.inject_block + call_err_service0 cctxt Shell_services.inject_block { raw ; blocking = not async ; force ; net_id ; operations } let inject_operation cctxt ?(async = false) ?net_id operation = - call_err_service0 cctxt Services.inject_operation + call_err_service0 cctxt Shell_services.inject_operation (operation, not async, net_id) let inject_protocol cctxt ?(async = false) ?force protocol = - call_err_service0 cctxt Services.inject_protocol + call_err_service0 cctxt Shell_services.inject_protocol (protocol, not async, force) let bootstrapped cctxt = - call_streamed_service0 cctxt Services.bootstrapped () + call_streamed_service0 cctxt Shell_services.bootstrapped () let complete cctxt ?block prefix = match block with | None -> - call_service1 cctxt Services.complete prefix () + call_service1 cctxt Shell_services.complete prefix () | Some block -> - call_service2 cctxt Services.Blocks.complete block prefix () + call_service2 cctxt Block_services.complete block prefix () let describe cctxt ?(recurse = true) path = Client_rpcs.call_service cctxt @@ -49,9 +48,9 @@ let describe cctxt ?(recurse = true) path = module Blocks = struct - type block = Services.Blocks.block + type block = Block_services.block - type block_info = Services.Blocks.block_info = { + type block_info = Block_services.block_info = { hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; @@ -67,57 +66,57 @@ module Blocks = struct protocol: Protocol_hash.t ; test_network: Test_network_status.t; } - type preapply_param = Services.Blocks.preapply_param = { + type preapply_param = Block_services.preapply_param = { timestamp: Time.t ; proto_header: MBytes.t ; operations: Operation.t list list ; sort_operations: bool ; } - type preapply_result = Services.Blocks.preapply_result = { + type preapply_result = Block_services.preapply_result = { shell_header: Block_header.shell_header ; operations: error Preapply_result.t list ; } let net_id cctxt h = - call_service1 cctxt Services.Blocks.net_id h () + call_service1 cctxt Block_services.net_id h () let level cctxt h = - call_service1 cctxt Services.Blocks.level h () + call_service1 cctxt Block_services.level h () let predecessor cctxt h = - call_service1 cctxt Services.Blocks.predecessor h () + call_service1 cctxt Block_services.predecessor h () let predecessors cctxt h l = - call_service1 cctxt Services.Blocks.predecessors h l + call_service1 cctxt Block_services.predecessors h l let hash cctxt h = - call_service1 cctxt Services.Blocks.hash h () + call_service1 cctxt Block_services.hash h () let timestamp cctxt h = - call_service1 cctxt Services.Blocks.timestamp h () + call_service1 cctxt Block_services.timestamp h () let fitness cctxt h = - call_service1 cctxt Services.Blocks.fitness h () + call_service1 cctxt Block_services.fitness h () let operations cctxt ?(contents = false) h = - call_service1 cctxt Services.Blocks.operations h + call_service1 cctxt Block_services.operations h { contents ; monitor = false } let protocol cctxt h = - call_service1 cctxt Services.Blocks.protocol h () + call_service1 cctxt Block_services.protocol h () let test_network cctxt h = - call_service1 cctxt Services.Blocks.test_network h () + call_service1 cctxt Block_services.test_network h () let preapply cctxt h ?(timestamp = Time.now ()) ?(sort = false) ~proto_header operations = call_err_service1 - cctxt Services.Blocks.preapply h + cctxt Block_services.preapply h { timestamp ; proto_header ; sort_operations = sort ; operations } let pending_operations cctxt block = - call_service1 cctxt Services.Blocks.pending_operations block () + call_service1 cctxt Block_services.pending_operations block () let info cctxt ?(include_ops = true) h = - call_service1 cctxt Services.Blocks.info h include_ops + call_service1 cctxt Block_services.info h include_ops let complete cctxt block prefix = - call_service2 cctxt Services.Blocks.complete block prefix () + call_service2 cctxt Block_services.complete block prefix () let list cctxt ?(include_ops = false) ?length ?heads ?delay ?min_date ?min_heads () = - call_service0 cctxt Services.Blocks.list + call_service0 cctxt Block_services.list { include_ops ; length ; heads ; monitor = Some false ; delay ; min_date ; min_heads } let monitor cctxt ?(include_ops = false) ?length ?heads ?delay ?min_date ?min_heads () = - call_streamed_service0 cctxt Services.Blocks.list + call_streamed_service0 cctxt Block_services.list { include_ops ; length ; heads ; monitor = Some true ; delay ; min_date ; min_heads } @@ -126,7 +125,7 @@ end module Operations = struct let monitor cctxt ?(contents = false) () = - call_streamed_service1 cctxt Services.Blocks.operations + call_streamed_service1 cctxt Block_services.operations `Prevalidation { contents ; monitor = true } @@ -135,11 +134,11 @@ end module Protocols = struct let contents cctxt hash = - call_service1 cctxt Services.Protocols.contents hash () + call_service1 cctxt Protocol_services.contents hash () let list cctxt ?contents () = call_service0 - cctxt Services.Protocols.list + cctxt Protocol_services.list { contents; monitor = Some false } end diff --git a/src/lib_client_base/client_node_rpcs.mli b/src/lib_client_base/client_node_rpcs.mli index c9699fce6..5bfa56cdc 100644 --- a/src/lib_client_base/client_node_rpcs.mli +++ b/src/lib_client_base/client_node_rpcs.mli @@ -40,7 +40,7 @@ val inject_protocol: module Blocks : sig - type block = Shell_services.Blocks.block + type block = Block_services.block val net_id: #Client_rpcs.ctxt -> diff --git a/src/lib_client_base/client_rpcs.ml b/src/lib_client_base/client_rpcs.ml index 472ea84f4..963a1f0dc 100644 --- a/src/lib_client_base/client_rpcs.ml +++ b/src/lib_client_base/client_rpcs.ml @@ -130,7 +130,7 @@ let call_err_service1 ctxt service a1 body = let call_err_service2 ctxt service a1 a2 body = call_err_service ctxt service (((), a1), a2) () body -type block = Shell_services.Blocks.block +type block = Block_services.block let last_baked_block = function | `Prevalidation -> `Head 0 diff --git a/src/lib_client_base/client_rpcs.mli b/src/lib_client_base/client_rpcs.mli index b8f251b1c..705cab06e 100644 --- a/src/lib_client_base/client_rpcs.mli +++ b/src/lib_client_base/client_rpcs.mli @@ -106,7 +106,7 @@ val call_err_service2: 'o tzresult, 'e) RPC_service.t -> 'a -> 'b -> 'i -> 'o tzresult Lwt.t -type block = Shell_services.Blocks.block +type block = Block_services.block val last_baked_block: block -> [> diff --git a/src/lib_client_base/jbuild b/src/lib_client_base/jbuild index 678325b3d..066301e2d 100644 --- a/src/lib_client_base/jbuild +++ b/src/lib_client_base/jbuild @@ -4,10 +4,9 @@ ((name tezos_client_base) (public_name tezos-client-base) (libraries (tezos-base + tezos-shell-services tezos-storage tezos-rpc-http - tezos-p2p-services - tezos-shell-services tezos-protocol-updater tezos-protocol-compiler)) (flags (:standard -w -9+27-30-32-40@8 @@ -15,7 +14,6 @@ -open Tezos_base__TzPervasives -open Tezos_storage -open Tezos_rpc_http - -open Tezos_p2p_services -open Tezos_shell_services -open Tezos_protocol_updater)))) diff --git a/src/lib_client_base/tezos-client-base.opam b/src/lib_client_base/tezos-client-base.opam index 75709ea42..ead7bf3d2 100644 --- a/src/lib_client_base/tezos-client-base.opam +++ b/src/lib_client_base/tezos-client-base.opam @@ -10,10 +10,9 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" + "tezos-shell-services" "tezos-storage" "tezos-rpc-http" - "tezos-p2p-services" - "tezos-shell-services" "tezos-protocol-compiler" "tezos-protocol-updater" "tezos-embedded-protocol-genesis" diff --git a/src/lib_p2p/jbuild b/src/lib_p2p/jbuild index 79bbd456b..6df9db223 100644 --- a/src/lib_p2p/jbuild +++ b/src/lib_p2p/jbuild @@ -3,12 +3,10 @@ (library ((name tezos_p2p) (public_name tezos-p2p) - (libraries (tezos-base - tezos-p2p-services)) + (libraries (tezos-base)) (flags (:standard -w -9+27-30-32-40@8 -safe-string - -open Tezos_base__TzPervasives - -open Tezos_p2p_services)))) + -open Tezos_base__TzPervasives)))) (alias ((name runtest_indent) diff --git a/src/lib_p2p/tezos-p2p.opam b/src/lib_p2p/tezos-p2p.opam index 9f16483f5..428d8be2e 100644 --- a/src/lib_p2p/tezos-p2p.opam +++ b/src/lib_p2p/tezos-p2p.opam @@ -10,7 +10,6 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-p2p-services" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_p2p_services/jbuild b/src/lib_p2p_services/jbuild deleted file mode 100644 index 087691f0e..000000000 --- a/src/lib_p2p_services/jbuild +++ /dev/null @@ -1,12 +0,0 @@ -(jbuild_version 1) - -(library - ((name tezos_p2p_services) - (public_name tezos-p2p-services) - (libraries (tezos-base)) - (flags (:standard -open Tezos_base__TzPervasives -safe-string)))) - -(alias - ((name runtest_indent) - (deps ((glob_files *.ml) (glob_files *.mli))) - (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_p2p_services/tezos-p2p-services.opam b/src/lib_p2p_services/tezos-p2p-services.opam deleted file mode 100644 index 428d8be2e..000000000 --- a/src/lib_p2p_services/tezos-p2p-services.opam +++ /dev/null @@ -1,19 +0,0 @@ -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+beta15" } - "tezos-base" -] -build: [ - [ "jbuilder" "build" "-p" name "-j" jobs ] -] -build-test: [ - [ "jbuilder" "runtest" "-p" name "-j" jobs ] -] diff --git a/src/lib_shell/jbuild b/src/lib_shell/jbuild index 070e150aa..0bcab1dfd 100644 --- a/src/lib_shell/jbuild +++ b/src/lib_shell/jbuild @@ -6,7 +6,6 @@ (libraries (tezos-base tezos-storage tezos-rpc-http - tezos-p2p-services tezos-p2p tezos-shell-services tezos-protocol-updater)) @@ -15,7 +14,6 @@ -open Tezos_base__TzPervasives -open Tezos_storage -open Tezos_rpc_http - -open Tezos_p2p_services -open Tezos_p2p -open Tezos_shell_services -open Tezos_protocol_updater)))) diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 7539081f2..70d687ed5 100644 --- a/src/lib_shell/node.ml +++ b/src/lib_shell/node.ml @@ -159,8 +159,8 @@ let shutdown node = node.shutdown () module RPC = struct - type block = Shell_services.Blocks.block - type block_info = Shell_services.Blocks.block_info = { + type block = Block_services.block + type block_info = Block_services.block_info = { hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index c7f170ed0..ed8e79b10 100644 --- a/src/lib_shell/node.mli +++ b/src/lib_shell/node.mli @@ -49,8 +49,8 @@ val create: module RPC : sig - type block = Shell_services.Blocks.block - type block_info = Shell_services.Blocks.block_info + type block = Block_services.block + type block_info = Block_services.block_info val inject_block: t -> ?force:bool -> ?net_id:Net_id.t -> diff --git a/src/lib_shell/node_rpc.ml b/src/lib_shell/node_rpc.ml index 8a488df10..3249f9756 100644 --- a/src/lib_shell/node_rpc.ml +++ b/src/lib_shell/node_rpc.ml @@ -9,9 +9,7 @@ open Logging.RPC -module Services = Shell_services - -let filter_bi operations (bi: Services.Blocks.block_info) = +let filter_bi operations (bi: Block_services.block_info) = let bi = if operations then bi else { bi with operations = None } in bi @@ -44,65 +42,65 @@ let register_bi_dir node dir = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return (filter_bi include_ops bi) in RPC_directory.register1 dir - Services.Blocks.info implementation in + Block_services.info implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.hash in RPC_directory.register1 dir - Services.Blocks.hash + Block_services.hash implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.net_id in RPC_directory.register1 dir - Services.Blocks.net_id implementation in + Block_services.net_id implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.level in RPC_directory.register1 dir - Services.Blocks.level implementation in + Block_services.level implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.predecessor in RPC_directory.register1 dir - Services.Blocks.predecessor implementation in + Block_services.predecessor implementation in let dir = let implementation b () len = Node.RPC.block_info node b >>= fun bi -> Node.RPC.predecessors node len bi.hash >>= fun hashes -> RPC_answer.return hashes in RPC_directory.register1 dir - Services.Blocks.predecessors implementation in + Block_services.predecessors implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.fitness in RPC_directory.register1 dir - Services.Blocks.fitness implementation in + Block_services.fitness implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.timestamp in RPC_directory.register1 dir - Services.Blocks.timestamp implementation in + Block_services.timestamp implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.protocol in RPC_directory.register1 dir - Services.Blocks.protocol implementation in + Block_services.protocol implementation in let dir = let implementation b () () = Node.RPC.block_info node b >>= fun bi -> RPC_answer.return bi.test_network in RPC_directory.register1 dir - Services.Blocks.test_network implementation in + Block_services.test_network implementation in let dir = - let implementation b () { Shell_services.Blocks.contents ; monitor } = + let implementation b () { Block_services.contents ; monitor } = match b with | `Prevalidation when monitor -> monitor_operations node contents @@ -117,36 +115,36 @@ let register_bi_dir node dir = List.map (List.map (fun h -> h, None)) hashes in RPC_directory.register1 dir - Services.Blocks.operations implementation in + Block_services.operations implementation in let dir = let implementation b () () = Node.RPC.pending_operations node b >>= fun res -> RPC_answer.return res in RPC_directory.register1 dir - Services.Blocks.pending_operations + Block_services.pending_operations implementation in let dir = let implementation b () - { Services.Blocks.operations ; sort_operations ; + { Block_services.operations ; sort_operations ; timestamp ; proto_header} = Node.RPC.preapply node b ~timestamp ~proto_header ~sort_operations operations >>= function | Ok (shell_header, operations) -> RPC_answer.return - (Ok { Services.Blocks.shell_header ; operations }) + (Ok { Block_services.shell_header ; operations }) | Error _ as err -> RPC_answer.return err in RPC_directory.register1 dir - Services.Blocks.preapply implementation in + Block_services.preapply implementation in dir let ops_dir _node = let ops_dir = RPC_directory.empty in ops_dir -let rec insert_future_block (bi: Services.Blocks.block_info) = function +let rec insert_future_block (bi: Block_services.block_info) = function | [] -> [bi] - | ({timestamp} as head: Services.Blocks.block_info) :: tail as all -> + | ({timestamp} as head: Block_services.block_info) :: tail as all -> if Time.compare bi.timestamp timestamp < 0 then bi :: all else @@ -201,7 +199,7 @@ let create_delayed_stream | `Block None -> lwt_debug "WWW worker_loop None" >>= fun () -> Lwt.return_unit - | `Block (Some (bi : Services.Blocks.block_info)) -> + | `Block (Some (bi : Block_services.block_info)) -> lwt_debug "WWW worker_loop Some" >>= fun () -> begin if not filtering @@ -242,7 +240,7 @@ let create_delayed_stream let list_blocks node () - { Services.Blocks.include_ops ; length ; heads ; monitor ; delay ; + { Block_services.include_ops ; length ; heads ; monitor ; delay ; min_date; min_heads} = let len = match length with None -> 1 | Some x -> x in let monitor = match monitor with None -> false | Some x -> x in @@ -285,12 +283,12 @@ let list_blocks let sorted_infos = List.sort (fun - (bi1: Services.Blocks.block_info) - (bi2: Services.Blocks.block_info) -> + (bi1: Block_services.block_info) + (bi2: Block_services.block_info) -> ~- (Fitness.compare bi1.fitness bi2.fitness)) heads_info in List.map - (fun ({ hash } : Services.Blocks.block_info) -> hash) + (fun ({ hash } : Block_services.block_info) -> hash) sorted_infos | Some heads -> let known_block h = @@ -337,7 +335,7 @@ let unmark_invalid node () block = Node.RPC.unmark_invalid node block >>= fun x -> RPC_answer.return x -let list_protocols node () {Services.Protocols.monitor; contents} = +let list_protocols node () { Protocol_services.monitor ; contents } = let monitor = match monitor with None -> false | Some x -> x in let include_contents = match contents with None -> false | Some x -> x in Node.RPC.protocols node >>= fun protocols -> @@ -376,13 +374,13 @@ let get_protocols node hash () () = let build_rpc_directory node = let dir = RPC_directory.empty in let dir = - RPC_directory.register0 dir Services.Blocks.list + RPC_directory.register0 dir Block_services.list (list_blocks node) in let dir = - RPC_directory.register0 dir Services.Blocks.list_invalid + RPC_directory.register0 dir Block_services.list_invalid (list_invalid node) in let dir = - RPC_directory.register0 dir Services.Blocks.unmark_invalid + RPC_directory.register0 dir Block_services.unmark_invalid (unmark_invalid node) in let dir = register_bi_dir node dir in let dir = @@ -395,19 +393,19 @@ let build_rpc_directory node = RPC_directory.register_dynamic_directory1 ~descr: "All the RPCs which are specific to the protocol version." - dir Services.Blocks.proto_path implementation in + dir Block_services.proto_path implementation in let dir = - RPC_directory.register0 dir Services.Protocols.list + RPC_directory.register0 dir Protocol_services.list (list_protocols node) in let dir = - RPC_directory.register1 dir Services.Protocols.contents + RPC_directory.register1 dir Protocol_services.contents (get_protocols node) in let dir = let implementation () header = let res = Data_encoding.Binary.to_bytes Block_header.encoding header in RPC_answer.return res in - RPC_directory.register0 dir Services.forge_block_header + RPC_directory.register0 dir Shell_services.forge_block_header implementation in let dir = let implementation () @@ -418,7 +416,7 @@ let build_rpc_directory node = raw operations >>=? fun (hash, wait) -> (if blocking then wait else return ()) >>=? fun () -> return hash end >>= RPC_answer.return in - RPC_directory.register0 dir Services.inject_block implementation in + RPC_directory.register0 dir Shell_services.inject_block implementation in let dir = let implementation () (contents, blocking, net_id) = Node.RPC.inject_operation @@ -426,43 +424,43 @@ let build_rpc_directory node = begin (if blocking then wait else return ()) >>=? fun () -> return hash end >>= RPC_answer.return in - RPC_directory.register0 dir Services.inject_operation implementation in + RPC_directory.register0 dir Shell_services.inject_operation implementation in let dir = let implementation () (proto, blocking, force) = Node.RPC.inject_protocol ?force node proto >>= fun (hash, wait) -> begin (if blocking then wait else return ()) >>=? fun () -> return hash end >>= RPC_answer.return in - RPC_directory.register0 dir Services.inject_protocol implementation in + RPC_directory.register0 dir Shell_services.inject_protocol implementation in let dir = let implementation () () = RPC_answer.return_stream (Node.RPC.bootstrapped node) in - RPC_directory.register0 dir Services.bootstrapped implementation in + RPC_directory.register0 dir Shell_services.bootstrapped implementation in let dir = let implementation () () = RPC_answer.return Data_encoding.Json.(schema Error_monad.error_encoding) in RPC_directory.register0 dir RPC_error.service implementation in let dir = - RPC_directory.register1 dir Services.complete + RPC_directory.register1 dir Shell_services.complete (fun s () () -> Node.RPC.complete node s >>= RPC_answer.return) in let dir = - RPC_directory.register2 dir Services.Blocks.complete + RPC_directory.register2 dir Block_services.complete (fun block s () () -> Node.RPC.complete node ~block s >>= RPC_answer.return) in (* Workers : Prevalidators *) let dir = - RPC_directory.register0 dir Shell_services.Workers.Prevalidators.list + RPC_directory.register0 dir Worker_services.Prevalidators.list (fun () () -> RPC_answer.return (List.map (fun (id, w) -> (id, Prevalidator.status w)) (Prevalidator.running_workers ()))) in let dir = - RPC_directory.register1 dir Shell_services.Workers.Prevalidators.state + RPC_directory.register1 dir Worker_services.Prevalidators.state (fun net_id () () -> let w = List.assoc net_id (Prevalidator.running_workers ()) in RPC_answer.return @@ -474,7 +472,7 @@ let build_rpc_directory node = (* Workers : Block_validator *) let dir = - RPC_directory.register0 dir Shell_services.Workers.Block_validator.state + RPC_directory.register0 dir Worker_services.Block_validator.state (fun () () -> let w = Block_validator.running_worker () in RPC_answer.return @@ -486,7 +484,7 @@ let build_rpc_directory node = (* Workers : Peer validators *) let dir = - RPC_directory.register1 dir Shell_services.Workers.Peer_validators.list + RPC_directory.register1 dir Worker_services.Peer_validators.list (fun net_id () () -> RPC_answer.return (List.filter_map @@ -496,7 +494,7 @@ let build_rpc_directory node = else None) (Peer_validator.running_workers ()))) in let dir = - RPC_directory.register2 dir Shell_services.Workers.Peer_validators.state + RPC_directory.register2 dir Worker_services.Peer_validators.state (fun net_id peer_id () () -> let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in RPC_answer.return @@ -508,14 +506,14 @@ let build_rpc_directory node = (* Workers : Net validators *) let dir = - RPC_directory.register0 dir Shell_services.Workers.Net_validators.list + RPC_directory.register0 dir Worker_services.Net_validators.list (fun () () -> RPC_answer.return (List.map (fun (id, w) -> (id, Net_validator.status w)) (Net_validator.running_workers ()))) in let dir = - RPC_directory.register1 dir Shell_services.Workers.Net_validators.state + RPC_directory.register1 dir Worker_services.Net_validators.state (fun net_id () () -> let w = List.assoc net_id (Net_validator.running_workers ()) in RPC_answer.return @@ -616,5 +614,5 @@ let build_rpc_directory node = Node.RPC.Network.Point.events node point |> RPC_answer.return in RPC_directory.register1 dir P2p_services.Point.events implementation in let dir = - RPC_directory.register_describe_directory_service dir Services.describe in + RPC_directory.register_describe_directory_service dir Shell_services.describe in dir diff --git a/src/lib_shell/tezos-shell.opam b/src/lib_shell/tezos-shell.opam index 6477573d6..4ef166cfa 100644 --- a/src/lib_shell/tezos-shell.opam +++ b/src/lib_shell/tezos-shell.opam @@ -11,7 +11,6 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-base" "tezos-rpc-http" - "tezos-p2p-services" "tezos-p2p" "tezos-shell-services" "tezos-protocol-updater" diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml new file mode 100644 index 000000000..3131dabe4 --- /dev/null +++ b/src/lib_shell_services/block_services.ml @@ -0,0 +1,436 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Data_encoding + +type block = [ + | `Genesis + | `Head of int | `Prevalidation + | `Test_head of int | `Test_prevalidation + | `Hash of Block_hash.t +] + +type block_info = { + hash: Block_hash.t ; + net_id: Net_id.t ; + level: Int32.t ; + proto_level: int ; (* uint8 *) + predecessor: Block_hash.t ; + timestamp: Time.t ; + validation_passes: int ; (* uint8 *) + operations_hash: Operation_list_list_hash.t ; + fitness: MBytes.t list ; + context: Context_hash.t ; + data: MBytes.t ; + operations: (Operation_hash.t * Operation.t) list list option ; + protocol: Protocol_hash.t ; + test_network: Test_network_status.t ; +} + +let block_info_encoding = + let operation_encoding = + merge_objs + (obj1 (req "hash" Operation_hash.encoding)) + Operation.encoding in + conv + (fun { hash ; net_id ; level ; proto_level ; predecessor ; + fitness ; timestamp ; protocol ; + validation_passes ; operations_hash ; context ; data ; + operations ; test_network } -> + ((hash, net_id, operations, protocol, test_network), + { Block_header.shell = + { level ; proto_level ; predecessor ; + timestamp ; validation_passes ; operations_hash ; fitness ; + context } ; + proto = data })) + (fun ((hash, net_id, operations, protocol, test_network), + { Block_header.shell = + { level ; proto_level ; predecessor ; + timestamp ; validation_passes ; operations_hash ; fitness ; + context } ; + proto = data }) -> + { hash ; net_id ; level ; proto_level ; predecessor ; + fitness ; timestamp ; protocol ; + validation_passes ; operations_hash ; context ; data ; + operations ; test_network }) + (dynamic_size + (merge_objs + (obj5 + (req "hash" Block_hash.encoding) + (req "net_id" Net_id.encoding) + (opt "operations" (dynamic_size (list (dynamic_size (list (dynamic_size operation_encoding)))))) + (req "protocol" Protocol_hash.encoding) + (dft "test_network" + Test_network_status.encoding Not_running)) + Block_header.encoding)) + +let parse_block s = + try + match String.split '~' s with + | ["genesis"] -> Ok `Genesis + | ["head"] -> Ok (`Head 0) + | ["prevalidation"] -> Ok `Prevalidation + | ["test_head"] -> Ok (`Test_head 0) + | ["test_prevalidation"] -> Ok `Test_prevalidation + | ["head"; n] -> Ok (`Head (int_of_string n)) + | ["test_head"; n] -> Ok (`Test_head (int_of_string n)) + | [h] -> Ok (`Hash (Block_hash.of_b58check_exn h)) + | _ -> raise Exit + with _ -> Error "Cannot parse block identifier." + +let to_string = function + | `Genesis -> "genesis" + | `Head 0 -> "head" + | `Head n -> Printf.sprintf "head~%d" n + | `Prevalidation -> "prevalidation" + | `Test_head 0 -> "test_head" + | `Test_head n -> Printf.sprintf "test_head~%d" n + | `Test_prevalidation -> "test_prevalidation" + | `Hash h -> Block_hash.to_b58check h + +let blocks_arg = + let name = "block_id" in + let descr = + "A block identifier. This is either a block hash in hexadecimal \ + notation or a one the predefined aliases: \ + 'genesis', 'head', 'prevalidation', \ + 'test_head' or 'test_prevalidation'. One might alse use 'head~N' + to 'test_head~N', where N is an integer to denotes the Nth predecessors + of 'head' or 'test_head'." in + let construct = to_string in + let destruct = parse_block in + RPC_arg.make ~name ~descr ~construct ~destruct () + +let block_path : (unit, unit * block) RPC_path.path = + RPC_path.(root / "blocks" /: blocks_arg ) + +let info = + RPC_service.post_service + ~description:"All the information about a block." + ~query: RPC_query.empty + ~input: (obj1 (dft "operations" bool true)) + ~output: block_info_encoding + ~error: Data_encoding.empty + block_path + +let net_id = + RPC_service.post_service + ~description:"Returns the net of the chain in which the block belongs." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "net_id" Net_id.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "net_id") + +let level = + RPC_service.post_service + ~description:"Returns the block's level." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "level" int32)) + ~error: Data_encoding.empty + RPC_path.(block_path / "level") + +let predecessor = + RPC_service.post_service + ~description:"Returns the previous block's id." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "predecessor" Block_hash.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "predecessor") + +let predecessors = + RPC_service.post_service + ~description: + "...." + ~query: RPC_query.empty + ~input: (obj1 (req "length" Data_encoding.uint16)) + ~output: (obj1 + (req "blocks" (Data_encoding.list Block_hash.encoding))) + ~error: Data_encoding.empty + RPC_path.(block_path / "predecessors") + +let hash = + RPC_service.post_service + ~description:"Returns the block's id." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "hash" Block_hash.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "hash") + +let fitness = + RPC_service.post_service + ~description:"Returns the block's fitness." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "fitness" Fitness.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "fitness") + +let context = + RPC_service.post_service + ~description:"Returns the hash of the resulting context." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "context" Context_hash.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "context") + +let timestamp = + RPC_service.post_service + ~description:"Returns the block's timestamp." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "timestamp" Time.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "timestamp") + +type operations_param = { + contents: bool ; + monitor: bool ; +} + +let operations_param_encoding = + let open Data_encoding in + conv + (fun { contents ; monitor } -> (contents, monitor)) + (fun (contents, monitor) -> { contents ; monitor }) + (obj2 + (dft "contents" bool false) + (dft "monitor" bool false)) + +let operations = + RPC_service.post_service + ~description:"List the block operations." + ~query: RPC_query.empty + ~input: operations_param_encoding + ~output: (obj1 + (req "operations" + (list (list + (obj2 + (req "hash" Operation_hash.encoding) + (opt "contents" + (dynamic_size Operation.encoding))))))) + ~error: Data_encoding.empty + RPC_path.(block_path / "operations") + +let protocol = + RPC_service.post_service + ~description:"List the block protocol." + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "protocol" Protocol_hash.encoding)) + ~error: Data_encoding.empty + RPC_path.(block_path / "protocol") + +let test_network = + RPC_service.post_service + ~description:"Returns the status of the associated test network." + ~query: RPC_query.empty + ~input: empty + ~output: Test_network_status.encoding + ~error: Data_encoding.empty + RPC_path.(block_path / "test_network") + +let pending_operations = + let operation_encoding = + merge_objs + (obj1 (req "hash" Operation_hash.encoding)) + Operation.encoding in + (* TODO: branch_delayed/... *) + RPC_service.post_service + ~description: + "List the not-yet-prevalidated operations." + ~query: RPC_query.empty + ~input: empty + ~output: + (conv + (fun (preapplied, unprocessed) -> + ({ preapplied with + Preapply_result.refused = Operation_hash.Map.empty }, + Operation_hash.Map.bindings unprocessed)) + (fun (preapplied, unprocessed) -> + (preapplied, + List.fold_right + (fun (h, op) m -> Operation_hash.Map.add h op m) + unprocessed Operation_hash.Map.empty)) + (merge_objs + (dynamic_size + (Preapply_result.encoding RPC_error.encoding)) + (obj1 (req "unprocessed" (list (dynamic_size operation_encoding)))))) + ~error: Data_encoding.empty + RPC_path.(block_path / "pending_operations") + +let proto_path = + RPC_path.(block_path / "proto") + +type preapply_param = { + timestamp: Time.t ; + proto_header: MBytes.t ; + operations: Operation.t list list ; + sort_operations: bool ; +} + +let preapply_param_encoding = + (conv + (fun { timestamp ; proto_header ; operations ; sort_operations } -> + (timestamp, proto_header, operations, sort_operations)) + (fun (timestamp, proto_header, operations, sort_operations) -> + { timestamp ; proto_header ; operations ; sort_operations }) + (obj4 + (req "timestamp" Time.encoding) + (req "proto_header" bytes) + (req "operations" (list (dynamic_size (list (dynamic_size Operation.encoding))))) + (dft "sort_operations" bool false))) + +type preapply_result = { + shell_header: Block_header.shell_header ; + operations: error Preapply_result.t list ; +} + +let preapply_result_encoding = + (conv + (fun { shell_header ; operations } -> + (shell_header, operations)) + (fun (shell_header, operations) -> + { shell_header ; operations }) + (obj2 + (req "shell_header" Block_header.shell_header_encoding) + (req "operations" + (list (Preapply_result.encoding RPC_error.encoding))))) + +let preapply = + RPC_service.post_service + ~description: + "Simulate the validation of a block that would contain \ + the given operations and return the resulting fitness." + ~query: RPC_query.empty + ~input: preapply_param_encoding + ~output: (RPC_error.wrap preapply_result_encoding) + ~error: Data_encoding.empty + RPC_path.(block_path / "preapply") + +let complete = + let prefix_arg = + let destruct s = Ok s + and construct s = s in + RPC_arg.make ~name:"prefix" ~destruct ~construct () in + RPC_service.post_service + ~description: "Try to complete a prefix of a Base58Check-encoded data. \ + This RPC is actually able to complete hashes of \ + block, operations, public_keys and contracts." + ~query: RPC_query.empty + ~input: empty + ~output: (list string) + ~error: Data_encoding.empty + RPC_path.(block_path / "complete" /: prefix_arg ) + +type list_param = { + include_ops: bool ; + length: int option ; + heads: Block_hash.t list option ; + monitor: bool option ; + delay: int option ; + min_date: Time.t option; + min_heads: int option; +} +let list_param_encoding = + conv + (fun { include_ops ; length ; heads ; monitor ; + delay ; min_date ; min_heads } -> + (include_ops, length, heads, monitor, delay, min_date, min_heads)) + (fun (include_ops, length, heads, monitor, + delay, min_date, min_heads) -> + { include_ops ; length ; heads ; monitor ; + delay ; min_date ; min_heads }) + (obj7 + (dft "include_ops" + (Data_encoding.describe + ~description: + "Whether the resulting block informations should include the \ + list of operations' hashes. Default false." + bool) false) + (opt "length" + (Data_encoding.describe + ~description: + "The requested number of predecessors to returns (per \ + requested head)." + int31)) + (opt "heads" + (Data_encoding.describe + ~description: + "An empty argument requests blocks from the current heads. \ + A non empty list allow to request specific fragment \ + of the chain." + (list Block_hash.encoding))) + (opt "monitor" + (Data_encoding.describe + ~description: + "When true, the socket is \"kept alive\" after the first \ + answer and new heads are streamed when discovered." + bool)) + (opt "delay" + (Data_encoding.describe + ~description: + "By default only the blocks that were validated by the node \ + are considered. \ + When this optional argument is 0, only blocks with a \ + timestamp in the past are considered. Other values allows to \ + adjust the current time." + int31)) + (opt "min_date" + (Data_encoding.describe + ~description: "When `min_date` is provided, heads with a \ + timestamp before `min_date` are filtered ouf" + Time.encoding)) + (opt "min_heads" + (Data_encoding.describe + ~description:"When `min_date` is provided, returns at least \ + `min_heads` even when their timestamp is before \ + `min_date`." + int31))) + +let list = + RPC_service.post_service + ~description: + "Lists known heads of the blockchain sorted with decreasing fitness. \ + Optional arguments allows to returns the list of predecessors for \ + known heads or the list of predecessors for a given list of blocks." + ~query: RPC_query.empty + ~input: list_param_encoding + ~output: (obj1 (req "blocks" (list (list block_info_encoding)))) + ~error: Data_encoding.empty + RPC_path.(root / "blocks") + +let list_invalid = + RPC_service.post_service + ~description: + "Lists blocks that have been declared invalid along with the errors\ + that led to them being declared invalid" + ~query: RPC_query.empty + ~input:empty + ~output:(Data_encoding.list + (obj3 + (req "block" Block_hash.encoding) + (req "level" int32) + (req "errors" RPC_error.encoding))) + ~error: Data_encoding.empty + RPC_path.(root / "invalid_blocks") + +let unmark_invalid = + RPC_service.post_service + ~description: + "Unmark an invalid block" + ~query: RPC_query.empty + ~input:Data_encoding.(obj1 (req "block" Block_hash.encoding)) + ~output:(RPC_error.wrap Data_encoding.empty) + ~error: Data_encoding.empty + RPC_path.(root / "unmark_invalid") diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli new file mode 100644 index 000000000..c4957854e --- /dev/null +++ b/src/lib_shell_services/block_services.mli @@ -0,0 +1,140 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type block = [ + | `Genesis + | `Head of int | `Prevalidation + | `Test_head of int | `Test_prevalidation + | `Hash of Block_hash.t +] +val blocks_arg : block RPC_arg.arg + +val parse_block: string -> (block, string) result +val to_string: block -> string + +type block_info = { + hash: Block_hash.t ; + net_id: Net_id.t ; + level: Int32.t ; + proto_level: int ; (* uint8 *) + predecessor: Block_hash.t ; + timestamp: Time.t ; + validation_passes: int ; (* uint8 *) + operations_hash: Operation_list_list_hash.t ; + fitness: MBytes.t list ; + context: Context_hash.t ; + data: MBytes.t ; + operations: (Operation_hash.t * Operation.t) list list option ; + protocol: Protocol_hash.t ; + test_network: Test_network_status.t ; +} + +val info: + ([ `POST ], unit, + unit * block, unit, bool, + block_info, unit) RPC_service.t +val net_id: + ([ `POST ], unit, + unit * block, unit, unit, + Net_id.t, unit) RPC_service.t +val level: + ([ `POST ], unit, + unit * block, unit, unit, + Int32.t, unit) RPC_service.t +val predecessor: + ([ `POST ], unit, + unit * block, unit, unit, + Block_hash.t, unit) RPC_service.t +val predecessors: + ([ `POST ], unit, + unit * block , unit, int, + Block_hash.t list, unit) RPC_service.t +val hash: + ([ `POST ], unit, + unit * block, unit, unit, + Block_hash.t, unit) RPC_service.t +val timestamp: + ([ `POST ], unit, + unit * block, unit, unit, + Time.t, unit) RPC_service.t +val fitness: + ([ `POST ], unit, + unit * block, unit, unit, + MBytes.t list, unit) RPC_service.t +val context: + ([ `POST ], unit, + unit * block, unit, unit, + Context_hash.t, unit) RPC_service.t + +type operations_param = { + contents: bool ; + monitor: bool ; +} +val operations: + ([ `POST ], unit, + unit * block, unit, operations_param, + (Operation_hash.t * Operation.t option) list list, unit) RPC_service.t + +val protocol: + ([ `POST ], unit, + unit * block, unit, unit, + Protocol_hash.t, unit) RPC_service.t +val test_network: + ([ `POST ], unit, + unit * block, unit, unit, + Test_network_status.t, unit) RPC_service.t +val pending_operations: + ([ `POST ], unit, + unit * block, unit, unit, + error Preapply_result.t * Operation.t Operation_hash.Map.t, unit) RPC_service.t + +type list_param = { + include_ops: bool ; + length: int option ; + heads: Block_hash.t list option ; + monitor: bool option ; + delay: int option ; + min_date: Time.t option; + min_heads: int option; +} +val list: + ([ `POST ], unit, + unit, unit, list_param, + block_info list list, unit) RPC_service.t + +val list_invalid: + ([ `POST ], unit, + unit, unit, unit, + (Block_hash.t * int32 * error list) list, unit) RPC_service.t + +val unmark_invalid: + ([ `POST ], unit, unit, unit, Block_hash.t, unit tzresult, unit) RPC_service.t + +type preapply_param = { + timestamp: Time.t ; + proto_header: MBytes.t ; + operations: Operation.t list list ; + sort_operations: bool ; +} + +type preapply_result = { + shell_header: Block_header.shell_header ; + operations: error Preapply_result.t list ; +} +val preapply: + ([ `POST ], unit, + unit * block, unit, preapply_param, + preapply_result tzresult, unit) RPC_service.t + +val complete: + ([ `POST ], unit, + (unit * block) * string, unit, unit, + string list, unit) RPC_service.t + +val proto_path: (unit, unit * block) RPC_path.path diff --git a/src/lib_shell_services/jbuild b/src/lib_shell_services/jbuild index c7abaa88b..213006f60 100644 --- a/src/lib_shell_services/jbuild +++ b/src/lib_shell_services/jbuild @@ -3,12 +3,10 @@ (library ((name tezos_shell_services) (public_name tezos-shell-services) - (libraries (tezos-base - tezos-p2p-services)) + (libraries (tezos-base)) (flags (:standard -w -9+27-30-32-40@8 -safe-string - -open Tezos_base__TzPervasives - -open Tezos_p2p_services)))) + -open Tezos_base__TzPervasives)))) (alias ((name runtest_indent) diff --git a/src/lib_p2p_services/p2p_services.ml b/src/lib_shell_services/p2p_services.ml similarity index 100% rename from src/lib_p2p_services/p2p_services.ml rename to src/lib_shell_services/p2p_services.ml diff --git a/src/lib_p2p_services/p2p_services.mli b/src/lib_shell_services/p2p_services.mli similarity index 100% rename from src/lib_p2p_services/p2p_services.mli rename to src/lib_shell_services/p2p_services.mli diff --git a/src/lib_shell_services/protocol_services.ml b/src/lib_shell_services/protocol_services.ml new file mode 100644 index 000000000..1e8392891 --- /dev/null +++ b/src/lib_shell_services/protocol_services.ml @@ -0,0 +1,52 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Data_encoding + +let protocols_arg = Protocol_hash.rpc_arg + +let contents = + RPC_service.post_service + ~query: RPC_query.empty + ~input: empty + ~output: + (obj1 (req "data" + (describe ~title: "Tezos protocol" + (Protocol.encoding)))) + ~error: Data_encoding.empty + RPC_path.(root / "protocols" /: protocols_arg) + +type list_param = { + contents: bool option ; + monitor: bool option ; +} + +let list_param_encoding = + conv + (fun {contents; monitor} -> (contents, monitor)) + (fun (contents, monitor) -> {contents; monitor}) + (obj2 + (opt "contents" bool) + (opt "monitor" bool)) + +let list = + RPC_service.post_service + ~query: RPC_query.empty + ~input: list_param_encoding + ~output: + (obj1 + (req "protocols" + (list + (obj2 + (req "hash" Protocol_hash.encoding) + (opt "contents" + (dynamic_size Protocol.encoding))) + ))) + ~error: Data_encoding.empty + RPC_path.(root / "protocols") diff --git a/src/lib_shell_services/protocol_services.mli b/src/lib_shell_services/protocol_services.mli new file mode 100644 index 000000000..5b2207971 --- /dev/null +++ b/src/lib_shell_services/protocol_services.mli @@ -0,0 +1,23 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +val contents: + ([ `POST ], unit, + unit * Protocol_hash.t, unit, unit, + Protocol.t, unit) RPC_service.t + +type list_param = { + contents: bool option ; + monitor: bool option ; +} + +val list: + ([ `POST ], unit, + unit, unit, list_param, + (Protocol_hash.t * Protocol.t option) list, unit) RPC_service.t diff --git a/src/lib_shell_services/shell_services.ml b/src/lib_shell_services/shell_services.ml index a613feb5c..7d8bc8686 100644 --- a/src/lib_shell_services/shell_services.ml +++ b/src/lib_shell_services/shell_services.ml @@ -9,637 +9,6 @@ open Data_encoding -module Blocks = struct - - type block = [ - | `Genesis - | `Head of int | `Prevalidation - | `Test_head of int | `Test_prevalidation - | `Hash of Block_hash.t - ] - - type block_info = { - hash: Block_hash.t ; - net_id: Net_id.t ; - level: Int32.t ; - proto_level: int ; (* uint8 *) - predecessor: Block_hash.t ; - timestamp: Time.t ; - validation_passes: int ; (* uint8 *) - operations_hash: Operation_list_list_hash.t ; - fitness: MBytes.t list ; - context: Context_hash.t ; - data: MBytes.t ; - operations: (Operation_hash.t * Operation.t) list list option ; - protocol: Protocol_hash.t ; - test_network: Test_network_status.t ; - } - - let block_info_encoding = - let operation_encoding = - merge_objs - (obj1 (req "hash" Operation_hash.encoding)) - Operation.encoding in - conv - (fun { hash ; net_id ; level ; proto_level ; predecessor ; - fitness ; timestamp ; protocol ; - validation_passes ; operations_hash ; context ; data ; - operations ; test_network } -> - ((hash, net_id, operations, protocol, test_network), - { Block_header.shell = - { level ; proto_level ; predecessor ; - timestamp ; validation_passes ; operations_hash ; fitness ; - context } ; - proto = data })) - (fun ((hash, net_id, operations, protocol, test_network), - { Block_header.shell = - { level ; proto_level ; predecessor ; - timestamp ; validation_passes ; operations_hash ; fitness ; - context } ; - proto = data }) -> - { hash ; net_id ; level ; proto_level ; predecessor ; - fitness ; timestamp ; protocol ; - validation_passes ; operations_hash ; context ; data ; - operations ; test_network }) - (dynamic_size - (merge_objs - (obj5 - (req "hash" Block_hash.encoding) - (req "net_id" Net_id.encoding) - (opt "operations" (dynamic_size (list (dynamic_size (list (dynamic_size operation_encoding)))))) - (req "protocol" Protocol_hash.encoding) - (dft "test_network" - Test_network_status.encoding Not_running)) - Block_header.encoding)) - - let parse_block s = - try - match String.split '~' s with - | ["genesis"] -> Ok `Genesis - | ["head"] -> Ok (`Head 0) - | ["prevalidation"] -> Ok `Prevalidation - | ["test_head"] -> Ok (`Test_head 0) - | ["test_prevalidation"] -> Ok `Test_prevalidation - | ["head"; n] -> Ok (`Head (int_of_string n)) - | ["test_head"; n] -> Ok (`Test_head (int_of_string n)) - | [h] -> Ok (`Hash (Block_hash.of_b58check_exn h)) - | _ -> raise Exit - with _ -> Error "Cannot parse block identifier." - - let to_string = function - | `Genesis -> "genesis" - | `Head 0 -> "head" - | `Head n -> Printf.sprintf "head~%d" n - | `Prevalidation -> "prevalidation" - | `Test_head 0 -> "test_head" - | `Test_head n -> Printf.sprintf "test_head~%d" n - | `Test_prevalidation -> "test_prevalidation" - | `Hash h -> Block_hash.to_b58check h - - let blocks_arg = - let name = "block_id" in - let descr = - "A block identifier. This is either a block hash in hexadecimal \ - notation or a one the predefined aliases: \ - 'genesis', 'head', 'prevalidation', \ - 'test_head' or 'test_prevalidation'. One might alse use 'head~N' - to 'test_head~N', where N is an integer to denotes the Nth predecessors - of 'head' or 'test_head'." in - let construct = to_string in - let destruct = parse_block in - RPC_arg.make ~name ~descr ~construct ~destruct () - - let block_path : (unit, unit * block) RPC_path.path = - RPC_path.(root / "blocks" /: blocks_arg ) - - let info = - RPC_service.post_service - ~description:"All the information about a block." - ~query: RPC_query.empty - ~input: (obj1 (dft "operations" bool true)) - ~output: block_info_encoding - ~error: Data_encoding.empty - block_path - - let net_id = - RPC_service.post_service - ~description:"Returns the net of the chain in which the block belongs." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "net_id" Net_id.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "net_id") - - let level = - RPC_service.post_service - ~description:"Returns the block's level." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "level" int32)) - ~error: Data_encoding.empty - RPC_path.(block_path / "level") - - let predecessor = - RPC_service.post_service - ~description:"Returns the previous block's id." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "predecessor" Block_hash.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "predecessor") - - let predecessors = - RPC_service.post_service - ~description: - "...." - ~query: RPC_query.empty - ~input: (obj1 (req "length" Data_encoding.uint16)) - ~output: (obj1 - (req "blocks" (Data_encoding.list Block_hash.encoding))) - ~error: Data_encoding.empty - RPC_path.(block_path / "predecessors") - - let hash = - RPC_service.post_service - ~description:"Returns the block's id." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "hash" Block_hash.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "hash") - - let fitness = - RPC_service.post_service - ~description:"Returns the block's fitness." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "fitness" Fitness.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "fitness") - - let context = - RPC_service.post_service - ~description:"Returns the hash of the resulting context." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "context" Context_hash.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "context") - - let timestamp = - RPC_service.post_service - ~description:"Returns the block's timestamp." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "timestamp" Time.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "timestamp") - - type operations_param = { - contents: bool ; - monitor: bool ; - } - - let operations_param_encoding = - let open Data_encoding in - conv - (fun { contents ; monitor } -> (contents, monitor)) - (fun (contents, monitor) -> { contents ; monitor }) - (obj2 - (dft "contents" bool false) - (dft "monitor" bool false)) - - let operations = - RPC_service.post_service - ~description:"List the block operations." - ~query: RPC_query.empty - ~input: operations_param_encoding - ~output: (obj1 - (req "operations" - (list (list - (obj2 - (req "hash" Operation_hash.encoding) - (opt "contents" - (dynamic_size Operation.encoding))))))) - ~error: Data_encoding.empty - RPC_path.(block_path / "operations") - - let protocol = - RPC_service.post_service - ~description:"List the block protocol." - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "protocol" Protocol_hash.encoding)) - ~error: Data_encoding.empty - RPC_path.(block_path / "protocol") - - let test_network = - RPC_service.post_service - ~description:"Returns the status of the associated test network." - ~query: RPC_query.empty - ~input: empty - ~output: Test_network_status.encoding - ~error: Data_encoding.empty - RPC_path.(block_path / "test_network") - - let pending_operations = - let operation_encoding = - merge_objs - (obj1 (req "hash" Operation_hash.encoding)) - Operation.encoding in - (* TODO: branch_delayed/... *) - RPC_service.post_service - ~description: - "List the not-yet-prevalidated operations." - ~query: RPC_query.empty - ~input: empty - ~output: - (conv - (fun (preapplied, unprocessed) -> - ({ preapplied with - Preapply_result.refused = Operation_hash.Map.empty }, - Operation_hash.Map.bindings unprocessed)) - (fun (preapplied, unprocessed) -> - (preapplied, - List.fold_right - (fun (h, op) m -> Operation_hash.Map.add h op m) - unprocessed Operation_hash.Map.empty)) - (merge_objs - (dynamic_size - (Preapply_result.encoding RPC_error.encoding)) - (obj1 (req "unprocessed" (list (dynamic_size operation_encoding)))))) - ~error: Data_encoding.empty - RPC_path.(block_path / "pending_operations") - - let proto_path = - RPC_path.(block_path / "proto") - - type preapply_param = { - timestamp: Time.t ; - proto_header: MBytes.t ; - operations: Operation.t list list ; - sort_operations: bool ; - } - - let preapply_param_encoding = - (conv - (fun { timestamp ; proto_header ; operations ; sort_operations } -> - (timestamp, proto_header, operations, sort_operations)) - (fun (timestamp, proto_header, operations, sort_operations) -> - { timestamp ; proto_header ; operations ; sort_operations }) - (obj4 - (req "timestamp" Time.encoding) - (req "proto_header" bytes) - (req "operations" (list (dynamic_size (list (dynamic_size Operation.encoding))))) - (dft "sort_operations" bool false))) - - type preapply_result = { - shell_header: Block_header.shell_header ; - operations: error Preapply_result.t list ; - } - - let preapply_result_encoding = - (conv - (fun { shell_header ; operations } -> - (shell_header, operations)) - (fun (shell_header, operations) -> - { shell_header ; operations }) - (obj2 - (req "shell_header" Block_header.shell_header_encoding) - (req "operations" - (list (Preapply_result.encoding RPC_error.encoding))))) - - let preapply = - RPC_service.post_service - ~description: - "Simulate the validation of a block that would contain \ - the given operations and return the resulting fitness." - ~query: RPC_query.empty - ~input: preapply_param_encoding - ~output: (RPC_error.wrap preapply_result_encoding) - ~error: Data_encoding.empty - RPC_path.(block_path / "preapply") - - let complete = - let prefix_arg = - let destruct s = Ok s - and construct s = s in - RPC_arg.make ~name:"prefix" ~destruct ~construct () in - RPC_service.post_service - ~description: "Try to complete a prefix of a Base58Check-encoded data. \ - This RPC is actually able to complete hashes of \ - block, operations, public_keys and contracts." - ~query: RPC_query.empty - ~input: empty - ~output: (list string) - ~error: Data_encoding.empty - RPC_path.(block_path / "complete" /: prefix_arg ) - - type list_param = { - include_ops: bool ; - length: int option ; - heads: Block_hash.t list option ; - monitor: bool option ; - delay: int option ; - min_date: Time.t option; - min_heads: int option; - } - let list_param_encoding = - conv - (fun { include_ops ; length ; heads ; monitor ; - delay ; min_date ; min_heads } -> - (include_ops, length, heads, monitor, delay, min_date, min_heads)) - (fun (include_ops, length, heads, monitor, - delay, min_date, min_heads) -> - { include_ops ; length ; heads ; monitor ; - delay ; min_date ; min_heads }) - (obj7 - (dft "include_ops" - (Data_encoding.describe - ~description: - "Whether the resulting block informations should include the \ - list of operations' hashes. Default false." - bool) false) - (opt "length" - (Data_encoding.describe - ~description: - "The requested number of predecessors to returns (per \ - requested head)." - int31)) - (opt "heads" - (Data_encoding.describe - ~description: - "An empty argument requests blocks from the current heads. \ - A non empty list allow to request specific fragment \ - of the chain." - (list Block_hash.encoding))) - (opt "monitor" - (Data_encoding.describe - ~description: - "When true, the socket is \"kept alive\" after the first \ - answer and new heads are streamed when discovered." - bool)) - (opt "delay" - (Data_encoding.describe - ~description: - "By default only the blocks that were validated by the node \ - are considered. \ - When this optional argument is 0, only blocks with a \ - timestamp in the past are considered. Other values allows to \ - adjust the current time." - int31)) - (opt "min_date" - (Data_encoding.describe - ~description: "When `min_date` is provided, heads with a \ - timestamp before `min_date` are filtered ouf" - Time.encoding)) - (opt "min_heads" - (Data_encoding.describe - ~description:"When `min_date` is provided, returns at least \ - `min_heads` even when their timestamp is before \ - `min_date`." - int31))) - - let list = - RPC_service.post_service - ~description: - "Lists known heads of the blockchain sorted with decreasing fitness. \ - Optional arguments allows to returns the list of predecessors for \ - known heads or the list of predecessors for a given list of blocks." - ~query: RPC_query.empty - ~input: list_param_encoding - ~output: (obj1 (req "blocks" (list (list block_info_encoding)))) - ~error: Data_encoding.empty - RPC_path.(root / "blocks") - - let list_invalid = - RPC_service.post_service - ~description: - "Lists blocks that have been declared invalid along with the errors\ - that led to them being declared invalid" - ~query: RPC_query.empty - ~input:empty - ~output:(Data_encoding.list - (obj3 - (req "block" Block_hash.encoding) - (req "level" int32) - (req "errors" RPC_error.encoding))) - ~error: Data_encoding.empty - RPC_path.(root / "invalid_blocks") - - let unmark_invalid = - RPC_service.post_service - ~description: - "Unmark an invalid block" - ~query: RPC_query.empty - ~input:Data_encoding.(obj1 (req "block" Block_hash.encoding)) - ~output:(Error.wrap Data_encoding.empty) - ~error: Data_encoding.empty - RPC_path.(root / "unmark_invalid") - -end - -module Protocols = struct - - let protocols_arg = Protocol_hash.rpc_arg - - let contents = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: - (obj1 (req "data" - (describe ~title: "Tezos protocol" - (Protocol.encoding)))) - ~error: Data_encoding.empty - RPC_path.(root / "protocols" /: protocols_arg) - - type list_param = { - contents: bool option ; - monitor: bool option ; - } - - let list_param_encoding = - conv - (fun {contents; monitor} -> (contents, monitor)) - (fun (contents, monitor) -> {contents; monitor}) - (obj2 - (opt "contents" bool) - (opt "monitor" bool)) - - let list = - RPC_service.post_service - ~query: RPC_query.empty - ~input: list_param_encoding - ~output: - (obj1 - (req "protocols" - (list - (obj2 - (req "hash" Protocol_hash.encoding) - (opt "contents" - (dynamic_size Protocol.encoding))) - ))) - ~error: Data_encoding.empty - RPC_path.(root / "protocols") - -end - -module Workers = struct - - module Prevalidators = struct - - let (net_id_arg : Net_id.t RPC_arg.t) = - RPC_arg.make - ~name:"net_id" - ~descr:"The network identifier of whom the prevalidator is responsible." - ~destruct:(fun s -> try - Ok (Net_id.of_b58check_exn s) - with Failure msg -> Error msg) - ~construct:Net_id.to_b58check - () - - let list = - RPC_service.post_service - ~description:"Lists the Prevalidator workers and their status." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (list - (obj2 - (req "net_id" Net_id.encoding) - (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) - RPC_path.(root / "workers" / "prevalidators") - - let state = - let open Data_encoding in - RPC_service.post_service - ~description:"Introspect the state of a prevalidator worker." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (Worker_types.full_status_encoding - Prevalidator_worker_state.Request.encoding - (Prevalidator_worker_state.Event.encoding RPC_error.encoding) - RPC_error.encoding) - RPC_path.(root / "workers" / "prevalidators" /: net_id_arg ) - - end - - module Block_validator = struct - - let state = - let open Data_encoding in - RPC_service.post_service - ~description:"Introspect the state of the block_validator worker." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (Worker_types.full_status_encoding - Block_validator_worker_state.Request.encoding - (Block_validator_worker_state.Event.encoding RPC_error.encoding) - RPC_error.encoding) - RPC_path.(root / "workers" / "block_validator") - - end - - module Peer_validators = struct - - let (net_id_arg : Net_id.t RPC_arg.t) = - RPC_arg.make - ~name:"net_id" - ~descr:"The network identifier the peer validator is associated to." - ~destruct:(fun s -> try - Ok (Net_id.of_b58check_exn s) - with Failure msg -> Error msg) - ~construct:Net_id.to_b58check - () - - let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) = - RPC_arg.make - ~name:"peer_id" - ~descr:"The peer identifier of whom the prevalidator is responsible." - ~destruct:(fun s -> try - Ok (P2p_peer.Id.of_b58check_exn s) - with Failure msg -> Error msg) - ~construct:P2p_peer.Id.to_b58check - () - - let list = - RPC_service.post_service - ~description:"Lists the peer validator workers and their status." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (list - (obj2 - (req "peer_id" P2p_peer.Id.encoding) - (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) - RPC_path.(root / "workers" / "peer_validators" /: net_id_arg) - - let state = - let open Data_encoding in - RPC_service.post_service - ~description:"Introspect the state of a peer validator worker." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (Worker_types.full_status_encoding - Peer_validator_worker_state.Request.encoding - (Peer_validator_worker_state.Event.encoding RPC_error.encoding) - RPC_error.encoding) - RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg) - - end - - module Net_validators = struct - - let (net_id_arg : Net_id.t RPC_arg.t) = - RPC_arg.make - ~name:"net_id" - ~descr:"The network identifier of whom the net validator is responsible." - ~destruct:(fun s -> try - Ok (Net_id.of_b58check_exn s) - with Failure msg -> Error msg) - ~construct:Net_id.to_b58check - () - - let list = - RPC_service.post_service - ~description:"Lists the net validator workers and their status." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (list - (obj2 - (req "net_id" Net_id.encoding) - (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) - RPC_path.(root / "workers" / "net_validators") - - let state = - let open Data_encoding in - RPC_service.post_service - ~description:"Introspect the state of a net validator worker." - ~query: RPC_query.empty - ~error: Data_encoding.empty - ~input: empty - ~output: - (Worker_types.full_status_encoding - Net_validator_worker_state.Request.encoding - (Net_validator_worker_state.Event.encoding RPC_error.encoding) - RPC_error.encoding) - RPC_path.(root / "workers" / "net_validators" /: net_id_arg ) - - end - -end - let forge_block_header = RPC_service.post_service ~description: "Forge a block header" diff --git a/src/lib_shell_services/shell_services.mli b/src/lib_shell_services/shell_services.mli index 6c4fd6c4d..2489f6e19 100644 --- a/src/lib_shell_services/shell_services.mli +++ b/src/lib_shell_services/shell_services.mli @@ -7,229 +7,6 @@ (* *) (**************************************************************************) -module Blocks : sig - - type block = [ - | `Genesis - | `Head of int | `Prevalidation - | `Test_head of int | `Test_prevalidation - | `Hash of Block_hash.t - ] - val blocks_arg : block RPC_arg.arg - - val parse_block: string -> (block, string) result - val to_string: block -> string - - type block_info = { - hash: Block_hash.t ; - net_id: Net_id.t ; - level: Int32.t ; - proto_level: int ; (* uint8 *) - predecessor: Block_hash.t ; - timestamp: Time.t ; - validation_passes: int ; (* uint8 *) - operations_hash: Operation_list_list_hash.t ; - fitness: MBytes.t list ; - context: Context_hash.t ; - data: MBytes.t ; - operations: (Operation_hash.t * Operation.t) list list option ; - protocol: Protocol_hash.t ; - test_network: Test_network_status.t ; - } - - val info: - ([ `POST ], unit, - unit * block, unit, bool, - block_info, unit) RPC_service.t - val net_id: - ([ `POST ], unit, - unit * block, unit, unit, - Net_id.t, unit) RPC_service.t - val level: - ([ `POST ], unit, - unit * block, unit, unit, - Int32.t, unit) RPC_service.t - val predecessor: - ([ `POST ], unit, - unit * block, unit, unit, - Block_hash.t, unit) RPC_service.t - val predecessors: - ([ `POST ], unit, - unit * block , unit, int, - Block_hash.t list, unit) RPC_service.t - val hash: - ([ `POST ], unit, - unit * block, unit, unit, - Block_hash.t, unit) RPC_service.t - val timestamp: - ([ `POST ], unit, - unit * block, unit, unit, - Time.t, unit) RPC_service.t - val fitness: - ([ `POST ], unit, - unit * block, unit, unit, - MBytes.t list, unit) RPC_service.t - val context: - ([ `POST ], unit, - unit * block, unit, unit, - Context_hash.t, unit) RPC_service.t - - type operations_param = { - contents: bool ; - monitor: bool ; - } - val operations: - ([ `POST ], unit, - unit * block, unit, operations_param, - (Operation_hash.t * Operation.t option) list list, unit) RPC_service.t - - val protocol: - ([ `POST ], unit, - unit * block, unit, unit, - Protocol_hash.t, unit) RPC_service.t - val test_network: - ([ `POST ], unit, - unit * block, unit, unit, - Test_network_status.t, unit) RPC_service.t - val pending_operations: - ([ `POST ], unit, - unit * block, unit, unit, - error Preapply_result.t * Operation.t Operation_hash.Map.t, unit) RPC_service.t - - type list_param = { - include_ops: bool ; - length: int option ; - heads: Block_hash.t list option ; - monitor: bool option ; - delay: int option ; - min_date: Time.t option; - min_heads: int option; - } - val list: - ([ `POST ], unit, - unit, unit, list_param, - block_info list list, unit) RPC_service.t - - val list_invalid: - ([ `POST ], unit, - unit, unit, unit, - (Block_hash.t * int32 * error list) list, unit) RPC_service.t - - val unmark_invalid: - ([ `POST ], unit, unit, unit, Block_hash.t, unit tzresult, unit) RPC_service.t - - type preapply_param = { - timestamp: Time.t ; - proto_header: MBytes.t ; - operations: Operation.t list list ; - sort_operations: bool ; - } - - type preapply_result = { - shell_header: Block_header.shell_header ; - operations: error Preapply_result.t list ; - } - val preapply: - ([ `POST ], unit, - unit * block, unit, preapply_param, - preapply_result tzresult, unit) RPC_service.t - - val complete: - ([ `POST ], unit, - (unit * block) * string, unit, unit, - string list, unit) RPC_service.t - - val proto_path: (unit, unit * block) RPC_path.path - - -end - -module Protocols : sig - - val contents: - ([ `POST ], unit, - unit * Protocol_hash.t, unit, unit, - Protocol.t, unit) RPC_service.t - - type list_param = { - contents: bool option ; - monitor: bool option ; - } - - val list: - ([ `POST ], unit, - unit, unit, list_param, - (Protocol_hash.t * Protocol.t option) list, unit) RPC_service.t - -end - -module Workers : sig - - module Prevalidators : sig - - open Prevalidator_worker_state - - val list : - ([ `POST ], unit, - unit, unit, unit, - (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t - - val state : - ([ `POST ], unit, - unit * Net_id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t - - end - - module Block_validator : sig - - open Block_validator_worker_state - - val state : - ([ `POST ], unit, - unit, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t - - end - - module Peer_validators : sig - - open Peer_validator_worker_state - - val list : - ([ `POST ], unit, - unit * Net_id.t, unit, unit, - (P2p_peer.Id.t * Worker_types.worker_status) list, unit) RPC_service.t - - val state : - ([ `POST ], unit, - (unit * Net_id.t) * P2p_peer.Id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t - - end - - module Net_validators : sig - - open Net_validator_worker_state - - val list : - ([ `POST ], unit, - unit, unit, unit, - (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t - - val state : - ([ `POST ], unit, - unit * Net_id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t - - end - -end - val forge_block_header: ([ `POST ], unit, unit, unit, Block_header.t, diff --git a/src/lib_shell_services/worker_services.ml b/src/lib_shell_services/worker_services.ml new file mode 100644 index 000000000..5302027b6 --- /dev/null +++ b/src/lib_shell_services/worker_services.ml @@ -0,0 +1,163 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Data_encoding + +module Prevalidators = struct + + let (net_id_arg : Net_id.t RPC_arg.t) = + RPC_arg.make + ~name:"net_id" + ~descr:"The network identifier of whom the prevalidator is responsible." + ~destruct:(fun s -> try + Ok (Net_id.of_b58check_exn s) + with Failure msg -> Error msg) + ~construct:Net_id.to_b58check + () + + let list = + RPC_service.post_service + ~description:"Lists the Prevalidator workers and their status." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (list + (obj2 + (req "net_id" Net_id.encoding) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) + RPC_path.(root / "workers" / "prevalidators") + + let state = + let open Data_encoding in + RPC_service.post_service + ~description:"Introspect the state of a prevalidator worker." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (Worker_types.full_status_encoding + Prevalidator_worker_state.Request.encoding + (Prevalidator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) + RPC_path.(root / "workers" / "prevalidators" /: net_id_arg ) + +end + +module Block_validator = struct + + let state = + let open Data_encoding in + RPC_service.post_service + ~description:"Introspect the state of the block_validator worker." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (Worker_types.full_status_encoding + Block_validator_worker_state.Request.encoding + (Block_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) + RPC_path.(root / "workers" / "block_validator") + +end + +module Peer_validators = struct + + let (net_id_arg : Net_id.t RPC_arg.t) = + RPC_arg.make + ~name:"net_id" + ~descr:"The network identifier the peer validator is associated to." + ~destruct:(fun s -> try + Ok (Net_id.of_b58check_exn s) + with Failure msg -> Error msg) + ~construct:Net_id.to_b58check + () + + let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) = + RPC_arg.make + ~name:"peer_id" + ~descr:"The peer identifier of whom the prevalidator is responsible." + ~destruct:(fun s -> try + Ok (P2p_peer.Id.of_b58check_exn s) + with Failure msg -> Error msg) + ~construct:P2p_peer.Id.to_b58check + () + + let list = + RPC_service.post_service + ~description:"Lists the peer validator workers and their status." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (list + (obj2 + (req "peer_id" P2p_peer.Id.encoding) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) + RPC_path.(root / "workers" / "peer_validators" /: net_id_arg) + + let state = + let open Data_encoding in + RPC_service.post_service + ~description:"Introspect the state of a peer validator worker." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (Worker_types.full_status_encoding + Peer_validator_worker_state.Request.encoding + (Peer_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) + RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg) + +end + +module Net_validators = struct + + let (net_id_arg : Net_id.t RPC_arg.t) = + RPC_arg.make + ~name:"net_id" + ~descr:"The network identifier of whom the net validator is responsible." + ~destruct:(fun s -> try + Ok (Net_id.of_b58check_exn s) + with Failure msg -> Error msg) + ~construct:Net_id.to_b58check + () + + let list = + RPC_service.post_service + ~description:"Lists the net validator workers and their status." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (list + (obj2 + (req "net_id" Net_id.encoding) + (req "status" (Worker_types.worker_status_encoding RPC_error.encoding)))) + RPC_path.(root / "workers" / "net_validators") + + let state = + let open Data_encoding in + RPC_service.post_service + ~description:"Introspect the state of a net validator worker." + ~query: RPC_query.empty + ~error: Data_encoding.empty + ~input: empty + ~output: + (Worker_types.full_status_encoding + Net_validator_worker_state.Request.encoding + (Net_validator_worker_state.Event.encoding RPC_error.encoding) + RPC_error.encoding) + RPC_path.(root / "workers" / "net_validators" /: net_id_arg ) + +end + +end diff --git a/src/lib_shell_services/worker_services.mli b/src/lib_shell_services/worker_services.mli new file mode 100644 index 000000000..3b4a8fc6e --- /dev/null +++ b/src/lib_shell_services/worker_services.mli @@ -0,0 +1,71 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Prevalidators : sig + + open Prevalidator_worker_state + + val list : + ([ `POST ], unit, + unit, unit, unit, + (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t + + val state : + ([ `POST ], unit, + unit * Net_id.t, unit, unit, + (Request.view, Event.t) Worker_types.full_status, unit) + RPC_service.t + +end + +module Block_validator : sig + + open Block_validator_worker_state + + val state : + ([ `POST ], unit, + unit, unit, unit, + (Request.view, Event.t) Worker_types.full_status, unit) + RPC_service.t + +end + +module Peer_validators : sig + + open Peer_validator_worker_state + + val list : + ([ `POST ], unit, + unit * Net_id.t, unit, unit, + (P2p_peer.Id.t * Worker_types.worker_status) list, unit) RPC_service.t + + val state : + ([ `POST ], unit, + (unit * Net_id.t) * P2p_peer.Id.t, unit, unit, + (Request.view, Event.t) Worker_types.full_status, unit) + RPC_service.t + +end + +module Net_validators : sig + + open Net_validator_worker_state + + val list : + ([ `POST ], unit, + unit, unit, unit, + (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t + + val state : + ([ `POST ], unit, + unit * Net_id.t, unit, unit, + (Request.view, Event.t) Worker_types.full_status, unit) + RPC_service.t + +end diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml index ffe7c9231..e8d839589 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml @@ -18,10 +18,10 @@ let handle_error (cctxt : #Client_commands.logger) = function let call_service0 cctxt s block = Client_rpcs.call_service0 cctxt - (s Shell_services.Blocks.proto_path) block + (s Block_services.proto_path) block let call_service1 cctxt s block a1 = Client_rpcs.call_service1 cctxt - (s Shell_services.Blocks.proto_path) block a1 + (s Block_services.proto_path) block a1 let call_error_service1 cctxt s block a1 = call_service1 cctxt s block a1 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) @@ -29,14 +29,14 @@ let call_error_service1 cctxt s block a1 = | Error _ as err -> Lwt.return err let call_service2 cctxt s block a1 a2 = Client_rpcs.call_service2 cctxt - (s Shell_services.Blocks.proto_path) block a1 a2 + (s Block_services.proto_path) block a1 a2 let call_error_service2 cctxt s block a1 a2 = call_service2 cctxt s block a1 a2 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) | Ok (Ok v) -> return v | Error _ as err -> Lwt.return err -type block = Shell_services.Blocks.block +type block = Block_services.block let header cctxt block = call_error_service1 cctxt Services.header block () diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli index bad173545..270325520 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli @@ -10,7 +10,7 @@ val string_of_errors: error list -> string val handle_error: Client_commands.full_context -> 'a tzresult -> 'a Lwt.t -type block = Shell_services.Blocks.block +type block = Block_services.block val header: #Client_rpcs.ctxt -> block -> Block_header.t tzresult Lwt.t diff --git a/src/proto_demo/lib_client_demo/client_proto_rpcs.ml b/src/proto_demo/lib_client_demo/client_proto_rpcs.ml index df5a6f58a..dedea2430 100644 --- a/src/proto_demo/lib_client_demo/client_proto_rpcs.ml +++ b/src/proto_demo/lib_client_demo/client_proto_rpcs.ml @@ -9,7 +9,7 @@ let call_service1 cctxt s block a1 = Client_rpcs.call_service1 cctxt - (s Shell_services.Blocks.proto_path) block a1 + (s Block_services.proto_path) block a1 let call_error_service1 cctxt s block a1 = call_service1 cctxt s block a1 >>= function | Ok (Error _ as err) -> Lwt.return (Environment.wrap_error err) diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.ml b/src/proto_genesis/lib_client_genesis/client_proto_main.ml index 838dd66b3..2f06fd9de 100644 --- a/src/proto_genesis/lib_client_genesis/client_proto_main.ml +++ b/src/proto_genesis/lib_client_genesis/client_proto_main.ml @@ -15,7 +15,7 @@ let protocol = let call_service1 rpc_config s block a1 = Client_rpcs.call_service1 rpc_config - (s Shell_services.Blocks.proto_path) block a1 + (s Block_services.proto_path) block a1 let call_error_service1 rpc_config s block a1 = call_service1 rpc_config s block a1 >>= function diff --git a/test/p2p/jbuild b/test/p2p/jbuild index 4bb45b8cf..25b8bf1f7 100644 --- a/test/p2p/jbuild +++ b/test/p2p/jbuild @@ -5,7 +5,6 @@ test_p2p_pool test_p2p_io_scheduler)) (libraries (tezos-base - tezos-p2p-services tezos-p2p lwt.unix test_lib)) @@ -13,7 +12,6 @@ -linkall -safe-string -open Tezos_base__TzPervasives - -open Tezos_p2p_services -open Tezos_p2p)))) (alias From e66417992757ad7b0a67398945cae17090aeb019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 23 Jan 2018 13:51:36 +0100 Subject: [PATCH 14/27] Refactor: CI: check opam packages --- .gitlab-ci.yml | 159 +++++++++++++++++++----------------- scripts/check_opam_test.sh | 36 ++++++++ scripts/update_opam_test.sh | 30 +++++++ src/lib_rpc/tezos-rpc.opam | 1 + 4 files changed, 151 insertions(+), 75 deletions(-) create mode 100755 scripts/check_opam_test.sh create mode 100755 scripts/update_opam_test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c12e6983..379422267 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,6 +91,11 @@ build: dependencies: - build +test:opam: + <<: *test_definition + script: + - ./scripts/check_opam_test.sh "$CI_PROJECT_DIR/$CI_CONFIG_PATH" + test:ocp-indent: <<: *test_definition script: @@ -178,180 +183,184 @@ test:proto:sandbox: tags: - gitlab-org +##BEGIN_OPAM## +opam:00:tezos-stdlib: + <<: *opam_definition + variables: + package: tezos-stdlib + opam:01:ocplib-resto: <<: *opam_definition variables: package: ocplib-resto -opam:02:ocplib-resto-directory: - <<: *opam_definition - variables: - package: ocplib-resto-directory - -opam:03:ocplib-resto-cohttp: - <<: *opam_definition - variables: - package: ocplib-resto-cohttp - -opam:04:ocplib-resto-json: - <<: *opam_definition - variables: - package: ocplib-resto-json - -opam:05:ocplib-ezresto: - <<: *opam_definition - variables: - package: ocplib-ezresto - -opam:06:ocplib-ezresto-directory: - <<: *opam_definition - variables: - package: ocplib-ezresto-directory - -opam:07:tezos-stdlib: - <<: *opam_definition - variables: - package: tezos-stdlib - -opam:08:tezos-data-encoding: +opam:02:tezos-data-encoding: <<: *opam_definition variables: package: tezos-data-encoding -opam:09:tezos-error-monad: +opam:03:ocplib-resto-directory: + <<: *opam_definition + variables: + package: ocplib-resto-directory + +opam:04:tezos-error-monad: <<: *opam_definition variables: package: tezos-error-monad -opam:10:tezos-stdlib-lwt: +opam:05:tezos-rpc: + <<: *opam_definition + variables: + package: tezos-rpc + +opam:06:tezos-stdlib-lwt: <<: *opam_definition variables: package: tezos-stdlib-lwt -opam:11:tezos-crypto: +opam:07:tezos-crypto: <<: *opam_definition variables: package: tezos-crypto -opam:12:tezos-base: +opam:08:tezos-base: <<: *opam_definition variables: package: tezos-base -opam:13:tezos-node-p2p-base: - <<: *opam_definition - variables: - package: tezos-node-p2p-base - -opam:14:tezos-node-services: - <<: *opam_definition - variables: - package: tezos-node-services - -opam:15:tezos-protocol-environment-sigs: +opam:09:tezos-protocol-environment-sigs: <<: *opam_definition variables: package: tezos-protocol-environment-sigs -opam:16:irmin-leveldb: +opam:10:irmin-leveldb: <<: *opam_definition variables: package: irmin-leveldb -opam:17:tezos-micheline: +opam:11:tezos-micheline: <<: *opam_definition variables: package: tezos-micheline -opam:18:tezos-rpc-http: - <<: *opam_definition - variables: - package: tezos-rpc-http - -opam:19:tezos-protocol-compiler: +opam:12:tezos-protocol-compiler: <<: *opam_definition variables: package: tezos-protocol-compiler -opam:20:tezos-storage: +opam:13:tezos-storage: <<: *opam_definition variables: package: tezos-storage -opam:21:tezos-node-p2p: +opam:14:ocplib-resto-cohttp: <<: *opam_definition variables: - package: tezos-node-p2p + package: ocplib-resto-cohttp -opam:22:tezos-protocol-updater: +opam:15:tezos-p2p: + <<: *opam_definition + variables: + package: tezos-p2p + +opam:16:tezos-protocol-updater: <<: *opam_definition variables: package: tezos-protocol-updater -opam:23:tezos-node-shell: +opam:17:tezos-rpc-http: <<: *opam_definition variables: - package: tezos-node-shell + package: tezos-rpc-http -opam:24:tezos-embedded-protocol-alpha: +opam:18:tezos-shell-services: + <<: *opam_definition + variables: + package: tezos-shell-services + +opam:19:tezos-shell: + <<: *opam_definition + variables: + package: tezos-shell + +opam:20:tezos-embedded-protocol-alpha: <<: *opam_definition variables: package: tezos-embedded-protocol-alpha -opam:25:tezos-embedded-protocol-demo: +opam:21:tezos-embedded-protocol-demo: <<: *opam_definition variables: package: tezos-embedded-protocol-demo -opam:26:tezos-embedded-protocol-genesis: +opam:22:tezos-embedded-protocol-genesis: <<: *opam_definition variables: package: tezos-embedded-protocol-genesis -opam:27:tezos-client-base: +opam:23:tezos-client-base: <<: *opam_definition variables: package: tezos-client-base -opam:28:tezos-embedded-client-alpha: +opam:24:ocplib-resto-json: + <<: *opam_definition + variables: + package: ocplib-resto-json + +opam:25:tezos-embedded-client-alpha: <<: *opam_definition variables: package: tezos-embedded-client-alpha -opam:29:tezos-embedded-client-genesis: +opam:26:tezos-embedded-client-genesis: <<: *opam_definition variables: package: tezos-embedded-client-genesis -opam:30:tezos-protocol-demo: +opam:27:ocplib-ezresto: <<: *opam_definition variables: - package: tezos-protocol-demo + package: ocplib-ezresto -opam:31:tezos-client: +opam:28:tezos-client: <<: *opam_definition variables: package: tezos-client -opam:32:tezos-node: +opam:29:tezos-node: <<: *opam_definition variables: package: tezos-node -opam:33:tezos-protocol-alpha: +opam:30:ocplib-ezresto-directory: <<: *opam_definition variables: - package: tezos-protocol-alpha + package: ocplib-ezresto-directory -opam:34:tezos-protocol-genesis: +opam:31:tezos-test: + <<: *opam_definition + variables: + package: tezos-test + +opam:32:tezos-protocol-genesis: <<: *opam_definition variables: package: tezos-protocol-genesis -opam:35:tezos-test: +opam:33:tezos-protocol-demo: <<: *opam_definition variables: - package: tezos-test + package: tezos-protocol-demo + +opam:34:tezos-protocol-alpha: + <<: *opam_definition + variables: + package: tezos-protocol-alpha + + +##END_OPAM## ## Publishing (small) docker images with tezos binaries diff --git a/scripts/check_opam_test.sh b/scripts/check_opam_test.sh new file mode 100755 index 000000000..bd55a8b4c --- /dev/null +++ b/scripts/check_opam_test.sh @@ -0,0 +1,36 @@ +#! /bin/sh + +set -e + +script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" +src_dir="$(dirname "$script_dir")" + +opams=$(find "$src_dir" -name \*.opam -print) + +yml="${1:-$src_dir/.gitlab-ci.yml}" + +missing= +for opam in $opams; do + file=$(basename $opam) + package=${file%.opam} + if ! grep -qe "opam:..:$package:\$" "$yml"; then + missing=yes + echo "Missing test for package '$package'." + fi +done + +tested=$(grep -e '^opam:..:tezos-.*:$' "$yml" | cut -d: -f3) +for package in $tested; do + found=$(find "$src_dir" -name $package.opam | wc -l 2>&1) + if [ $found != 1 ] ; then + missing=yes + echo "Test for unknown package '$package'." + fi +done + +if ! [ -z "$missing" ]; then + echo + echo "You should update .gitlab-ci.yml by running: ./scripts/update_opam_test.sh" + echo + exit 1 +fi diff --git a/scripts/update_opam_test.sh b/scripts/update_opam_test.sh new file mode 100755 index 000000000..09499b8ae --- /dev/null +++ b/scripts/update_opam_test.sh @@ -0,0 +1,30 @@ +#! /bin/sh + +set -e + +script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" +src_dir="$(dirname "$script_dir")" + +. "$script_dir/opam-pin.sh" + +tmp=$(mktemp) + +sed -z 's/^\(.*##BEGIN_OPAM##\n\).*\(\n##END_OPAM##.*\)$/\1/' "$src_dir/.gitlab-ci.yml" > $tmp + +cpt=0 +for package in $packages; do + num=$(printf "%02d" $cpt) + cpt=$((cpt+1)) + cat >> $tmp <> $tmp + +mv $tmp "$src_dir/.gitlab-ci.yml" + diff --git a/src/lib_rpc/tezos-rpc.opam b/src/lib_rpc/tezos-rpc.opam index d74a8f5c5..8f7b34e13 100644 --- a/src/lib_rpc/tezos-rpc.opam +++ b/src/lib_rpc/tezos-rpc.opam @@ -9,6 +9,7 @@ license: "unreleased" depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } + "tezos-error-monad" "tezos-data-encoding" "ocplib-resto" "ocplib-resto-directory" From 0c2acd2d4834ec93c9c416de4c011a4626302ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Thu, 25 Jan 2018 11:32:51 +0100 Subject: [PATCH 15/27] RPC: simplify `Worker.EVENT` --- src/lib_shell/worker.ml | 2 +- src/lib_shell/worker.mli | 2 +- src/lib_shell_services/block_validator_worker_state.ml | 4 ++-- .../block_validator_worker_state.mli | 2 +- src/lib_shell_services/net_validator_worker_state.ml | 4 ++-- src/lib_shell_services/net_validator_worker_state.mli | 2 +- src/lib_shell_services/peer_validator_worker_state.ml | 4 ++-- src/lib_shell_services/peer_validator_worker_state.mli | 2 +- src/lib_shell_services/prevalidator_worker_state.ml | 4 ++-- src/lib_shell_services/prevalidator_worker_state.mli | 2 +- src/lib_shell_services/worker_services.ml | 10 ++++------ 11 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/lib_shell/worker.ml b/src/lib_shell/worker.ml index d333c4459..3dfd5ee42 100644 --- a/src/lib_shell/worker.ml +++ b/src/lib_shell/worker.ml @@ -18,7 +18,7 @@ module type EVENT = sig type t val level : t -> Logging.level - val encoding : error list Data_encoding.t -> t Data_encoding.t + val encoding : t Data_encoding.t val pp : Format.formatter -> t -> unit end diff --git a/src/lib_shell/worker.mli b/src/lib_shell/worker.mli index 580dd5d35..5ee9a1991 100644 --- a/src/lib_shell/worker.mli +++ b/src/lib_shell/worker.mli @@ -44,7 +44,7 @@ module type EVENT = sig val level : t -> Logging.level (** Serializer for the introspection RPCs *) - val encoding : error list Data_encoding.t -> t Data_encoding.t + val encoding : t Data_encoding.t (** Pretty printer, also used for logging *) val pp : Format.formatter -> t -> unit diff --git a/src/lib_shell_services/block_validator_worker_state.ml b/src/lib_shell_services/block_validator_worker_state.ml index 43cf8f34c..217c987df 100644 --- a/src/lib_shell_services/block_validator_worker_state.ml +++ b/src/lib_shell_services/block_validator_worker_state.ml @@ -46,7 +46,7 @@ module Event = struct | Validation_success _ | Validation_failure _ -> Logging.Notice - let encoding error_encoding = + let encoding = let open Data_encoding in union [ case (Tag 0) @@ -63,7 +63,7 @@ module Event = struct (obj3 (req "failed_validation" Request.encoding) (req "status" Worker_types.request_status_encoding) - (dft "errors" error_encoding [])) + (dft "errors" RPC_error.encoding [])) (function Validation_failure (r, s, err) -> Some (r, s, err) | _ -> None) (fun (r, s, err) -> Validation_failure (r, s, err)) ] diff --git a/src/lib_shell_services/block_validator_worker_state.mli b/src/lib_shell_services/block_validator_worker_state.mli index 20e7a727c..b98da8a3e 100644 --- a/src/lib_shell_services/block_validator_worker_state.mli +++ b/src/lib_shell_services/block_validator_worker_state.mli @@ -23,7 +23,7 @@ module Event : sig | Validation_failure of Request.view * Worker_types.request_status * error list | Debug of string val level : t -> Logging.level - val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding + val encoding : t Data_encoding.encoding val pp : Format.formatter -> t -> unit end diff --git a/src/lib_shell_services/net_validator_worker_state.ml b/src/lib_shell_services/net_validator_worker_state.ml index 27ba18691..651b43da0 100644 --- a/src/lib_shell_services/net_validator_worker_state.ml +++ b/src/lib_shell_services/net_validator_worker_state.ml @@ -35,7 +35,7 @@ module Event = struct end | Could_not_switch_testnet _ -> Logging.Error - let encoding error_encoding = + let encoding = let open Data_encoding in union [ case (Tag 0) @@ -54,7 +54,7 @@ module Event = struct (fun (request, request_status, update, fitness) -> Processed_block { request ; request_status ; update ; fitness }) ; case (Tag 1) - error_encoding + RPC_error.encoding (function | Could_not_switch_testnet err -> Some err | _ -> None) diff --git a/src/lib_shell_services/net_validator_worker_state.mli b/src/lib_shell_services/net_validator_worker_state.mli index 995c0a522..95d8c270a 100644 --- a/src/lib_shell_services/net_validator_worker_state.mli +++ b/src/lib_shell_services/net_validator_worker_state.mli @@ -26,7 +26,7 @@ module Event : sig fitness : Fitness.t } | Could_not_switch_testnet of error list val level : t -> Logging.level - val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding + val encoding : t Data_encoding.encoding val pp : Format.formatter -> t -> unit end diff --git a/src/lib_shell_services/peer_validator_worker_state.ml b/src/lib_shell_services/peer_validator_worker_state.ml index 6ef40f1b9..94eefe95d 100644 --- a/src/lib_shell_services/peer_validator_worker_state.ml +++ b/src/lib_shell_services/peer_validator_worker_state.ml @@ -47,7 +47,7 @@ module Event = struct | Debug _ -> Logging.Info | Request _ -> Logging.Notice - let encoding error_encoding = + let encoding = let open Data_encoding in union [ case (Tag 0) @@ -62,7 +62,7 @@ module Event = struct (fun (req, t) -> Request (req, t, None)) ; case (Tag 2) (obj3 - (req "error" error_encoding) + (req "error" RPC_error.encoding) (req "failed_request" Request.encoding) (req "status" Worker_types.request_status_encoding)) (function Request (req, t, Some errs) -> Some (errs, req, t) | _ -> None) diff --git a/src/lib_shell_services/peer_validator_worker_state.mli b/src/lib_shell_services/peer_validator_worker_state.mli index e1790c192..a2eaef6d2 100644 --- a/src/lib_shell_services/peer_validator_worker_state.mli +++ b/src/lib_shell_services/peer_validator_worker_state.mli @@ -20,7 +20,7 @@ module Event : sig | Request of (Request.view * Worker_types.request_status * error list option) | Debug of string val level : t -> Logging.level - val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding + val encoding : t Data_encoding.encoding val pp : Format.formatter -> t -> unit end diff --git a/src/lib_shell_services/prevalidator_worker_state.ml b/src/lib_shell_services/prevalidator_worker_state.ml index e2ddb748e..e3b7925cf 100644 --- a/src/lib_shell_services/prevalidator_worker_state.ml +++ b/src/lib_shell_services/prevalidator_worker_state.ml @@ -95,7 +95,7 @@ module Event = struct | Request (View (Arrived _), _, _) -> Logging.Debug | Request (View Advertise, _, _) -> Logging.Debug - let encoding error_encoding = + let encoding = let open Data_encoding in union [ case (Tag 0) @@ -110,7 +110,7 @@ module Event = struct (fun (req, t) -> Request (req, t, None)) ; case (Tag 2) (obj3 - (req "error" error_encoding) + (req "error" RPC_error.encoding) (req "failed_request" Request.encoding) (req "status" Worker_types.request_status_encoding)) (function Request (req, t, Some errs) -> Some (errs, req, t) | _ -> None) diff --git a/src/lib_shell_services/prevalidator_worker_state.mli b/src/lib_shell_services/prevalidator_worker_state.mli index 274033527..5e92800cc 100644 --- a/src/lib_shell_services/prevalidator_worker_state.mli +++ b/src/lib_shell_services/prevalidator_worker_state.mli @@ -25,7 +25,7 @@ module Event : sig | Request of (Request.view * Worker_types.request_status * error list option) | Debug of string val level : t -> Logging.level - val encoding : error list Data_encoding.t -> t Data_encoding.t + val encoding : t Data_encoding.t val pp : Format.formatter -> t -> unit end diff --git a/src/lib_shell_services/worker_services.ml b/src/lib_shell_services/worker_services.ml index 5302027b6..87a742ac6 100644 --- a/src/lib_shell_services/worker_services.ml +++ b/src/lib_shell_services/worker_services.ml @@ -44,7 +44,7 @@ module Prevalidators = struct ~output: (Worker_types.full_status_encoding Prevalidator_worker_state.Request.encoding - (Prevalidator_worker_state.Event.encoding RPC_error.encoding) + Prevalidator_worker_state.Event.encoding RPC_error.encoding) RPC_path.(root / "workers" / "prevalidators" /: net_id_arg ) @@ -62,7 +62,7 @@ module Block_validator = struct ~output: (Worker_types.full_status_encoding Block_validator_worker_state.Request.encoding - (Block_validator_worker_state.Event.encoding RPC_error.encoding) + Block_validator_worker_state.Event.encoding RPC_error.encoding) RPC_path.(root / "workers" / "block_validator") @@ -113,7 +113,7 @@ module Peer_validators = struct ~output: (Worker_types.full_status_encoding Peer_validator_worker_state.Request.encoding - (Peer_validator_worker_state.Event.encoding RPC_error.encoding) + Peer_validator_worker_state.Event.encoding RPC_error.encoding) RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg) @@ -154,10 +154,8 @@ module Net_validators = struct ~output: (Worker_types.full_status_encoding Net_validator_worker_state.Request.encoding - (Net_validator_worker_state.Event.encoding RPC_error.encoding) + Net_validator_worker_state.Event.encoding RPC_error.encoding) RPC_path.(root / "workers" / "net_validators" /: net_id_arg ) end - -end From acc0c5c512dc5b19c876f6e205c749eeec950bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 29 Jan 2018 01:03:24 +0100 Subject: [PATCH 16/27] Compiler: allow not to generate `Registerer` --- src/lib_protocol_compiler/native.ml | 34 +++++++++++++++++---------- src/lib_protocol_updater/register.ml | 8 ------- src/lib_protocol_updater/register.mli | 9 ------- src/lib_protocol_updater/updater.ml | 2 +- 4 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 src/lib_protocol_updater/register.ml delete mode 100644 src/lib_protocol_updater/register.mli diff --git a/src/lib_protocol_compiler/native.ml b/src/lib_protocol_compiler/native.ml index f368ac048..1ec917e9c 100644 --- a/src/lib_protocol_compiler/native.ml +++ b/src/lib_protocol_compiler/native.ml @@ -198,9 +198,11 @@ let main () = Random.self_init () ; let anonymous = ref [] and static = ref false + and register = ref false and build_dir = ref None in let args_spec = [ "-static", Arg.Set static, " Only build the static library (no .cmxs)"; + "-register", Arg.Set register, " Generete the `Registerer` module"; "-bin-annot", Arg.Set Clflags.binary_annotations, " (see ocamlopt)" ; "-g", Arg.Set Clflags.debug, " (see ocamlopt)" ; "-build-dir", Arg.String (fun s -> build_dir := Some s), @@ -253,21 +255,27 @@ let main () = load_embeded_cmis tezos_protocol_env ; let packed_protocol_object = compile_ml ~for_pack functor_file in - load_embeded_cmis register_env ; - load_cmi_from_file proto_cmi ; - - (* Compiler the 'registering module' *) - let register_file = Filename.dirname functor_file // "register.ml" in - create_file register_file - (Printf.sprintf - "module Name = struct let name = %S end\n\ - \ let () = Tezos_protocol_compiler__Registerer.register Name.name (module %s.Make)" - (Protocol_hash.to_b58check hash) - functor_unit) ; - let register_object = compile_ml ~for_pack register_file in + let register_objects = + if not !register then + [] + else begin + load_embeded_cmis register_env ; + load_cmi_from_file proto_cmi ; + (* Compiler the 'registering module' *) + let register_file = Filename.dirname functor_file // "register.ml" in + create_file register_file + (Printf.sprintf + "module Name = struct let name = %S end\n\ + \ let () = Tezos_protocol_compiler__Registerer.register Name.name (module %s.Make)" + (Protocol_hash.to_b58check hash) + functor_unit) ; + let register_object = compile_ml ~for_pack register_file in + [ register_object ] + end + in let resulting_object = - pack_objects output [ packed_protocol_object ; register_object ] in + pack_objects output (packed_protocol_object :: register_objects) in (* Create the final [cmxs] *) if not !static then begin diff --git a/src/lib_protocol_updater/register.ml b/src/lib_protocol_updater/register.ml deleted file mode 100644 index fe0a9923e..000000000 --- a/src/lib_protocol_updater/register.ml +++ /dev/null @@ -1,8 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) diff --git a/src/lib_protocol_updater/register.mli b/src/lib_protocol_updater/register.mli deleted file mode 100644 index 769771c1b..000000000 --- a/src/lib_protocol_updater/register.mli +++ /dev/null @@ -1,9 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - diff --git a/src/lib_protocol_updater/updater.ml b/src/lib_protocol_updater/updater.ml index 8e4804a18..f70cc0e46 100644 --- a/src/lib_protocol_updater/updater.ml +++ b/src/lib_protocol_updater/updater.ml @@ -57,7 +57,7 @@ let do_compile hash p = Protocol.write_dir source_dir ~hash p >>= fun () -> let compiler_command = (Sys.executable_name, - Array.of_list [compiler_name; plugin_file; source_dir]) in + Array.of_list [compiler_name; "-register"; plugin_file; source_dir]) in let fd = Unix.(openfile log_file [O_WRONLY; O_CREAT; O_TRUNC] 0o644) in let pi = Lwt_process.exec From c75756bd6ddb11c066e4302ae3b17ffc17754aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 29 Jan 2018 01:06:47 +0100 Subject: [PATCH 17/27] Refactor: introduce `lib_client_environment` This allow to use the functorised version of the protocol in the client. --- Makefile | 5 + src/lib_base/protocol_environment.ml | 104 ++++++++++++++++++ src/lib_client_base/jbuild | 9 +- src/lib_client_environment/environment.ml | 34 ++++++ src/lib_client_environment/fake_context.ml | 24 ++++ src/lib_client_environment/fake_updater.ml | 72 ++++++++++++ src/lib_client_environment/jbuild | 17 +++ .../tezos-client-environment.opam | 20 ++++ .../tezos_protocol_environment.ml | 91 +-------------- .../lib_client_alpha/client_baking_blocks.ml | 3 + .../lib_client_alpha/client_baking_blocks.mli | 3 + .../lib_client_alpha/client_baking_daemon.mli | 3 + .../client_baking_endorsement.ml | 3 + .../client_baking_endorsement.mli | 3 + .../lib_client_alpha/client_baking_forge.ml | 3 + .../lib_client_alpha/client_baking_forge.mli | 3 + .../lib_client_alpha/client_baking_lib.ml | 3 + .../lib_client_alpha/client_baking_lib.mli | 5 +- .../client_baking_operations.ml | 3 + .../client_baking_operations.mli | 3 + .../client_baking_revelation.ml | 1 + .../client_baking_revelation.mli | 3 + .../lib_client_alpha/client_proto_args.ml | 2 + .../lib_client_alpha/client_proto_args.mli | 3 + .../lib_client_alpha/client_proto_context.ml | 2 + .../lib_client_alpha/client_proto_context.mli | 2 + .../client_proto_context_commands.ml | 2 + .../client_proto_contracts.ml | 3 + .../client_proto_contracts.mli | 3 + .../client_proto_contracts_commands.ml | 11 ++ .../lib_client_alpha/client_proto_nonces.ml | 3 + .../lib_client_alpha/client_proto_nonces.mli | 3 + .../lib_client_alpha/client_proto_programs.ml | 2 + .../client_proto_programs.mli | 2 + .../lib_client_alpha/client_proto_rpcs.ml | 3 + .../lib_client_alpha/client_proto_rpcs.mli | 3 + src/proto_alpha/lib_client_alpha/jbuild | 9 +- .../lib_client_alpha/michelson_v1_emacs.ml | 1 + .../lib_client_alpha/michelson_v1_emacs.mli | 3 + .../michelson_v1_error_reporter.ml | 2 + .../lib_client_alpha/michelson_v1_parser.ml | 1 + .../lib_client_alpha/michelson_v1_parser.mli | 3 + .../lib_client_alpha/michelson_v1_printer.ml | 1 + .../lib_client_alpha/michelson_v1_printer.mli | 2 + .../lib_client_alpha/proto_alpha.ml | 12 ++ src/proto_demo/lib_client_demo/proto_demo.ml | 12 ++ .../lib_client_genesis/client_proto_main.ml | 4 +- .../lib_client_genesis/client_proto_main.mli | 2 +- src/proto_genesis/lib_client_genesis/jbuild | 11 +- .../lib_client_genesis/proto_genesis.ml | 12 ++ .../tezos-embedded-client-genesis.opam | 5 +- test/proto_alpha/jbuild | 5 +- test/proto_alpha/proto_alpha_helpers.ml | 3 +- test/proto_alpha/proto_alpha_helpers.mli | 3 +- test/proto_alpha/test_endorsement.ml | 6 +- test/proto_alpha/test_michelson_parser.ml | 1 + test/proto_alpha/test_origination.ml | 2 + test/proto_alpha/test_transaction.ml | 2 + test/proto_alpha/test_vote.ml | 2 + 59 files changed, 440 insertions(+), 123 deletions(-) create mode 100644 src/lib_base/protocol_environment.ml create mode 100644 src/lib_client_environment/environment.ml create mode 100644 src/lib_client_environment/fake_context.ml create mode 100644 src/lib_client_environment/fake_updater.ml create mode 100644 src/lib_client_environment/jbuild create mode 100644 src/lib_client_environment/tezos-client-environment.opam create mode 100644 src/proto_alpha/lib_client_alpha/proto_alpha.ml create mode 100644 src/proto_demo/lib_client_demo/proto_demo.ml create mode 100644 src/proto_genesis/lib_client_genesis/proto_genesis.ml diff --git a/Makefile b/Makefile index d7447efb7..e780ca95c 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ all: @cp _build/default/src/bin_client/admin_main.exe tezos-admin-client @cp _build/default/src/lib_protocol_compiler/main.exe tezos-protocol-compiler +%.pkg: + @jbuilder build --dev $(patsubst %.opam,%.install, \ + $(shell find -name tezos-$*.opam)) + doc-html: @jbuilder build @doc ${DEV} @mkdir -p $$(pwd)/docs/_build/api/odoc @@ -40,3 +44,4 @@ clean: @-make -C docs clean .PHONY: all test build-deps docker-image clean + diff --git a/src/lib_base/protocol_environment.ml b/src/lib_base/protocol_environment.ml new file mode 100644 index 000000000..15a6f6a58 --- /dev/null +++ b/src/lib_base/protocol_environment.ml @@ -0,0 +1,104 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Error_monad + +module Make(Param : sig val name: string end)() = struct + + include Pervasives + module Pervasives = Pervasives + module Compare = Compare + module Array = Array + module List = List + module Bytes = struct + include Bytes + include EndianBytes.BigEndian + module LE = EndianBytes.LittleEndian + end + module String = struct + include String + include EndianString.BigEndian + module LE = EndianString.LittleEndian + end + module Set = Set + module Map = Map + module Int32 = Int32 + module Int64 = Int64 + module Nativeint = Nativeint + module Buffer = Buffer + module Format = Format + module Z = Z + module Lwt_sequence = Lwt_sequence + module Lwt = Lwt + module Lwt_list = Lwt_list + module MBytes = MBytes + module Uri = Uri + module Data_encoding = Data_encoding + module Time = Time + module Ed25519 = Ed25519 + module Hash = struct + include Tezos_crypto + include Tezos_crypto.S + module Net_id = Net_id + module Block_hash = Block_hash + module Operation_hash = Operation_hash + module Operation_list_hash = Operation_list_hash + module Operation_list_list_hash = Operation_list_list_hash + module Context_hash = Context_hash + module Protocol_hash = Protocol_hash + module Make_minimal_Blake2B = Blake2B.Make_minimal + module Make_Blake2B = Blake2B.Make + end + module Blake2B = Blake2B + module Tezos_data = struct + module type DATA = S.T + module type HASHABLE_DATA = S.HASHABLE + module Fitness = Fitness + module Operation = Operation + module Block_header = Block_header + module Protocol = Protocol + end + module RPC_arg = RPC_arg + module RPC_path = RPC_path + module RPC_query = RPC_query + module RPC_service = RPC_service + module RPC_answer = RPC_answer + module RPC_directory = RPC_directory + module Fitness = Fitness + module Error_monad = struct + type error_category = [ `Branch | `Temporary | `Permanent ] + include Error_monad.Make() + end + module Logging = Logging.Make(Param) + + type error += Ecoproto_error of Error_monad.error list + + let () = + let id = Format.asprintf "Ecoproto.%s" Param.name in + register_wrapped_error_kind + (fun ecoerrors -> Error_monad.classify_errors ecoerrors) + ~id ~title:"Error returned by the protocol" + ~description:"Wrapped error for the economic protocol." + ~pp:(fun ppf -> + Format.fprintf ppf + "@[Economic error:@ %a@]" + (Format.pp_print_list Error_monad.pp)) + Data_encoding.(obj1 (req "ecoproto" + (list Error_monad.error_encoding))) + (function Ecoproto_error ecoerrors -> Some ecoerrors + | _ -> None ) + (function ecoerrors -> Ecoproto_error ecoerrors) + + let wrap_error = function + | Ok _ as ok -> ok + | Error errors -> Error [Ecoproto_error errors] + + module Option = Option + +end diff --git a/src/lib_client_base/jbuild b/src/lib_client_base/jbuild index 066301e2d..c9c070d37 100644 --- a/src/lib_client_base/jbuild +++ b/src/lib_client_base/jbuild @@ -5,17 +5,12 @@ (public_name tezos-client-base) (libraries (tezos-base tezos-shell-services - tezos-storage - tezos-rpc-http - tezos-protocol-updater - tezos-protocol-compiler)) + tezos-rpc-http)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_storage -open Tezos_rpc_http - -open Tezos_shell_services - -open Tezos_protocol_updater)))) + -open Tezos_shell_services)))) (alias ((name runtest_indent) diff --git a/src/lib_client_environment/environment.ml b/src/lib_client_environment/environment.ml new file mode 100644 index 000000000..3279ef8bf --- /dev/null +++ b/src/lib_client_environment/environment.ml @@ -0,0 +1,34 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Make(Param : sig val name: string end)() = struct + + include Tezos_base.Protocol_environment.Make(Param)() + + module Micheline = Micheline + module Updater = struct + include Fake_updater.Make(Fake_context) + module type PROTOCOL = + RAW_PROTOCOL with type error := Error_monad.error + and type 'a tzresult := 'a Error_monad.tzresult + end + module Base58 = struct + include Base58 + let simple_encode enc s = simple_encode enc s + let simple_decode enc s = simple_decode enc s + include Make(struct type context = Fake_context.t end) + let decode s = decode s + end + module Context = struct + include Fake_context + let register_resolver = Base58.register_resolver + let complete ctxt s = Base58.complete ctxt s + end + +end diff --git a/src/lib_client_environment/fake_context.ml b/src/lib_client_environment/fake_context.ml new file mode 100644 index 000000000..88f5a6a8c --- /dev/null +++ b/src/lib_client_environment/fake_context.ml @@ -0,0 +1,24 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t + +type key = string list +type value = MBytes.t +let mem _ _ = assert false +let dir_mem _ _ = assert false +let get _ _ = assert false +let set _ _ _ = assert false +let del _ _ = assert false +let remove_rec _ _ = assert false +let fold _ _ ~init:_ ~f:_ = assert false +let keys _ _ = assert false +let fold_keys _ _ ~init:_ ~f:_ = assert false +let register_resolver _ _ = () +let complete _ _ = assert false diff --git a/src/lib_client_environment/fake_updater.ml b/src/lib_client_environment/fake_updater.ml new file mode 100644 index 000000000..31a3d635b --- /dev/null +++ b/src/lib_client_environment/fake_updater.ml @@ -0,0 +1,72 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Make(Context : sig type t end) = struct + + type validation_result = { + context: Context.t ; + fitness: Fitness.t ; + message: string option ; + max_operation_data_length: int ; + max_number_of_operations: int list ; + max_operations_ttl: int ; + } + + type rpc_context = { + block_hash: Block_hash.t ; + block_header: Block_header.t ; + operation_hashes: unit -> Operation_hash.t list list Lwt.t ; + operations: unit -> Operation.t list list Lwt.t ; + context: Context.t ; + } + + module type RAW_PROTOCOL = sig + type error = .. + type 'a tzresult = ('a, error list) result + val max_block_length: int + type operation + val parse_operation: + Operation_hash.t -> Operation.t -> operation tzresult + val compare_operations: operation -> operation -> int + type validation_state + val current_context: validation_state -> Context.t tzresult Lwt.t + val precheck_block: + ancestor_context: Context.t -> + ancestor_timestamp: Time.t -> + Block_header.t -> + unit tzresult Lwt.t + val begin_application: + predecessor_context: Context.t -> + predecessor_timestamp: Time.t -> + predecessor_fitness: Fitness.t -> + Block_header.t -> + validation_state tzresult Lwt.t + val begin_construction: + predecessor_context: Context.t -> + predecessor_timestamp: Time.t -> + predecessor_level: Int32.t -> + predecessor_fitness: Fitness.t -> + predecessor: Block_hash.t -> + timestamp: Time.t -> + ?proto_header: MBytes.t -> + unit -> validation_state tzresult Lwt.t + val apply_operation: + validation_state -> operation -> validation_state tzresult Lwt.t + val finalize_block: + validation_state -> validation_result tzresult Lwt.t + val rpc_services: rpc_context RPC_directory.t + val configure_sandbox: + Context.t -> Data_encoding.json option -> Context.t tzresult Lwt.t + end + + let compile _ _ = assert false + let activate _ _ = assert false + let fork_test_network _ ~protocol:_ ~expiration:_ = assert false + +end diff --git a/src/lib_client_environment/jbuild b/src/lib_client_environment/jbuild new file mode 100644 index 000000000..846c512b7 --- /dev/null +++ b/src/lib_client_environment/jbuild @@ -0,0 +1,17 @@ +(jbuild_version 1) + +(library + ((name tezos_client_environment) + (public_name tezos-client-environment) + (libraries (tezos-base + tezos-protocol-environment-sigs + tezos-micheline)) + (flags (:standard -w -9+27-30-32-40@8 + -safe-string + -open Tezos_base__TzPervasives + -open Tezos_micheline)))) + +(alias + ((name runtest_indent) + (deps ((glob_files *.ml) (glob_files *.mli))) + (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_client_environment/tezos-client-environment.opam b/src/lib_client_environment/tezos-client-environment.opam new file mode 100644 index 000000000..6d795dd44 --- /dev/null +++ b/src/lib_client_environment/tezos-client-environment.opam @@ -0,0 +1,20 @@ +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+beta15" } + "tezos-base" + "tezos-micheline" +] +build: [ + [ "jbuilder" "build" "-p" name "-j" jobs ] +] +build-test: [ + [ "jbuilder" "runtest" "-p" name "-j" jobs ] +] diff --git a/src/lib_protocol_updater/tezos_protocol_environment.ml b/src/lib_protocol_updater/tezos_protocol_environment.ml index e07130166..68066766a 100644 --- a/src/lib_protocol_updater/tezos_protocol_environment.ml +++ b/src/lib_protocol_updater/tezos_protocol_environment.ml @@ -9,78 +9,15 @@ module Make(Param : sig val name: string end)() = struct - include Pervasives - module Pervasives = Pervasives - module Compare = Compare - module Array = Array - module List = List - module Bytes = struct - include Bytes - include EndianBytes.BigEndian - module LE = EndianBytes.LittleEndian - end - module String = struct - include String - include EndianString.BigEndian - module LE = EndianString.LittleEndian - end - module Set = Set - module Map = Map - module Int32 = Int32 - module Int64 = Int64 - module Nativeint = Nativeint - module Buffer = Buffer - module Format = Format - module Z = Z - module Lwt_sequence = Lwt_sequence - module Lwt = Lwt - module Lwt_list = Lwt_list - module MBytes = MBytes - module Uri = Uri - module Data_encoding = Data_encoding - module Time = Time - module Ed25519 = Ed25519 - module Hash = struct - include Tezos_crypto - include Tezos_crypto.S - module Net_id = Net_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Make_minimal_Blake2B = Blake2B.Make_minimal - module Make_Blake2B = Blake2B.Make - end - module Blake2B = Blake2B - module Tezos_data = struct - module type DATA = Tezos_base.S.T - module type HASHABLE_DATA = Tezos_base.S.HASHABLE - module Fitness = Fitness - module Operation = Operation - module Block_header = Block_header - module Protocol = Protocol - end - module RPC_arg = RPC_arg - module RPC_path = RPC_path - module RPC_query = RPC_query - module RPC_service = RPC_service - module RPC_answer = RPC_answer - module RPC_directory = RPC_directory + include Tezos_base.Protocol_environment.Make(Param)() + module Micheline = Micheline - module Fitness = Fitness - module Error_monad = struct - type error_category = [ `Branch | `Temporary | `Permanent ] - include Error_monad.Make() - end module Updater = struct include Updater module type PROTOCOL = RAW_PROTOCOL with type error := Error_monad.error and type 'a tzresult := 'a Error_monad.tzresult end - module Logging = Logging.Make(Param) module Base58 = struct include Base58 let simple_encode enc s = simple_encode enc s @@ -94,28 +31,4 @@ module Make(Param : sig val name: string end)() = struct let complete ctxt s = Base58.complete ctxt s end - type error += Ecoproto_error of Error_monad.error list - - let () = - let id = Format.asprintf "Ecoproto.%s" Param.name in - register_wrapped_error_kind - (fun ecoerrors -> Error_monad.classify_errors ecoerrors) - ~id ~title:"Error returned by the protocol" - ~description:"Wrapped error for the economic protocol." - ~pp:(fun ppf -> - Format.fprintf ppf - "@[Economic error:@ %a@]" - (Format.pp_print_list Error_monad.pp)) - Data_encoding.(obj1 (req "ecoproto" - (list Error_monad.error_encoding))) - (function Ecoproto_error ecoerrors -> Some ecoerrors - | _ -> None ) - (function ecoerrors -> Ecoproto_error ecoerrors) - - let wrap_error = function - | Ok _ as ok -> ok - | Error errors -> Error [Ecoproto_error errors] - - module Option = Option - end diff --git a/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml b/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml index 1c697e752..e0b6f1ab7 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + type block_info = { hash: Block_hash.t ; net_id: Net_id.t ; diff --git a/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli b/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli index db499e69a..b96390f53 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + type block_info = { hash: Block_hash.t ; net_id: Net_id.t ; diff --git a/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli b/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli index 7c6277ae4..2c4c9109b 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val run: Client_commands.full_context -> ?max_priority: int -> diff --git a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml index 416080470..abe28f2dc 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + open Logging.Client.Endorsement module State : sig diff --git a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli index 3d6089a7c..2b436c503 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val forge_endorsement: Client_commands.full_context -> Client_proto_rpcs.block -> diff --git a/src/proto_alpha/lib_client_alpha/client_baking_forge.ml b/src/proto_alpha/lib_client_alpha/client_baking_forge.ml index 9c9a32c81..34937cd25 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_forge.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_forge.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + open Logging.Client.Baking let generate_proof_of_work_nonce () = diff --git a/src/proto_alpha/lib_client_alpha/client_baking_forge.mli b/src/proto_alpha/lib_client_alpha/client_baking_forge.mli index edc2c7837..fcb2a25e4 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_forge.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_forge.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val generate_seed_nonce: unit -> Nonce.t (** [generate_seed_nonce ()] is a random nonce that is typically used in block headers. When baking, bakers generate random nonces whose diff --git a/src/proto_alpha/lib_client_alpha/client_baking_lib.ml b/src/proto_alpha/lib_client_alpha/client_baking_lib.ml index e85af57bc..6c1806692 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_lib.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_lib.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + let bake_block (cctxt : Client_commands.full_context) block ?force ?max_priority ?(free_baking=false) ?src_sk delegate = begin diff --git a/src/proto_alpha/lib_client_alpha/client_baking_lib.mli b/src/proto_alpha/lib_client_alpha/client_baking_lib.mli index f4dcffb2b..4e28fd023 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_lib.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_lib.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + (** Mine a block *) val bake_block: Client_commands.full_context -> @@ -48,7 +51,7 @@ val run_daemon: Client_commands.full_context -> ?max_priority:int -> endorsement_delay:int -> - ('a * Tezos_embedded_raw_protocol_alpha.Tezos_context.public_key_hash) list -> + ('a * public_key_hash) list -> endorsement:bool -> baking:bool -> denunciation:bool -> diff --git a/src/proto_alpha/lib_client_alpha/client_baking_operations.ml b/src/proto_alpha/lib_client_alpha/client_baking_operations.ml index 4320a5fe0..02307959b 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_operations.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_operations.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + type operation = { hash: Operation_hash.t ; content: Operation.t option diff --git a/src/proto_alpha/lib_client_alpha/client_baking_operations.mli b/src/proto_alpha/lib_client_alpha/client_baking_operations.mli index e1aa91f09..605e95cb9 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_operations.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_operations.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + type operation = { hash: Operation_hash.t ; content: Operation.t option ; diff --git a/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml b/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml index e9421da3f..ca977f40d 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml +++ b/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Proto_alpha open Tezos_context let inject_seed_nonce_revelation rpc_config block ?async nonces = diff --git a/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli b/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli index a11990629..ad8e70871 100644 --- a/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli +++ b/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val inject_seed_nonce_revelation: #Client_rpcs.ctxt -> Client_proto_rpcs.block -> diff --git a/src/proto_alpha/lib_client_alpha/client_proto_args.ml b/src/proto_alpha/lib_client_alpha/client_proto_args.ml index 54e9863ff..03bd57efd 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_args.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_args.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Cli_entries type error += Bad_tez_arg of string * string (* Arg_name * value *) diff --git a/src/proto_alpha/lib_client_alpha/client_proto_args.mli b/src/proto_alpha/lib_client_alpha/client_proto_args.mli index 8182b9b58..4bebca379 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_args.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_args.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val tez_sym: string open Cli_entries diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context.ml b/src/proto_alpha/lib_client_alpha/client_proto_context.ml index 36a04aa60..83b7c8b2c 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_context.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_context.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline open Client_proto_contracts open Client_keys diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context.mli b/src/proto_alpha/lib_client_alpha/client_proto_context.mli index a4c331d20..1db1ef725 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_context.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_context.mli @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Environment val list_contract_labels : diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml b/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml index bd595dbd3..c2e2a849c 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline open Client_proto_context open Client_proto_contracts diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml b/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml index 6bee4e755..c509982ed 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + module ContractEntity = struct type t = Contract.t let encoding = Contract.encoding diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli b/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli index 97b0db443..bfbbd7968 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + module RawContractAlias : Client_aliases.Alias with type t = Contract.t diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml b/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml index 0d0c64573..021b9cb6f 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml @@ -1,3 +1,14 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +open Proto_alpha +open Tezos_context open Client_proto_contracts let group = diff --git a/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml b/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml index c6d9fbb38..5b5cdaf1b 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + (* TODO locking... *) type t = (Block_hash.t * Nonce.t) list diff --git a/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli b/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli index 738c3b47d..9e35073a7 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val mem: #Client_commands.wallet -> Block_hash.t -> bool tzresult Lwt.t diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs.ml b/src/proto_alpha/lib_client_alpha/client_proto_programs.ml index af23b3ee6..c292a1112 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_programs.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_programs.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline open Michelson_v1_printer diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs.mli b/src/proto_alpha/lib_client_alpha/client_proto_programs.mli index 14e531329..2055efdd0 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_programs.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_programs.mli @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline module Program : Client_aliases.Alias diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml index e8d839589..e7eeba941 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + let string_of_errors exns = Format.asprintf " @[%a@]" pp_print_error exns diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli index 270325520..7bbd73d59 100644 --- a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli +++ b/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val string_of_errors: error list -> string val handle_error: Client_commands.full_context -> 'a tzresult -> 'a Lwt.t diff --git a/src/proto_alpha/lib_client_alpha/jbuild b/src/proto_alpha/lib_client_alpha/jbuild index f756d5002..43d64d56a 100644 --- a/src/proto_alpha/lib_client_alpha/jbuild +++ b/src/proto_alpha/lib_client_alpha/jbuild @@ -4,19 +4,16 @@ ((name tezos_embedded_client_alpha) (public_name tezos-embedded-client-alpha) (libraries (tezos-base - tezos-embedded-protocol-alpha - tezos-embedded-protocol-alpha.raw + tezos-protocol-alpha + tezos-client-environment tezos-shell-services tezos-client-base)) (library_flags (:standard -linkall)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_embedded_protocol_environment_alpha - -open Tezos_embedded_raw_protocol_alpha -open Tezos_shell_services - -open Tezos_client_base - -open Tezos_context)))) + -open Tezos_client_base)))) (alias ((name runtest_indent) diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml index 4a4b943a0..c7acfcd6d 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Proto_alpha open Tezos_micheline open Micheline diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli index 685982615..caf52ddb6 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + val print_expr : Format.formatter -> Script.expr -> diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml index 7961aab34..6b64f4d6e 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline open Script_typed_ir open Script_ir_translator diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml index cc82affa8..e2651c292 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Proto_alpha open Tezos_micheline open Micheline_parser open Micheline diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli index 900cb501d..bfb86b0a9 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli @@ -7,6 +7,9 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context + open Tezos_micheline (** The result of parsing and expanding a Michelson V1 script or data. *) diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml index 9ac3fee68..85d59e3c2 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Proto_alpha open Tezos_micheline open Micheline open Micheline_printer diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli index f1bbbdeef..e2f0473c8 100644 --- a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli +++ b/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Tezos_micheline val print_expr : diff --git a/src/proto_alpha/lib_client_alpha/proto_alpha.ml b/src/proto_alpha/lib_client_alpha/proto_alpha.ml new file mode 100644 index 000000000..3c424168f --- /dev/null +++ b/src/proto_alpha/lib_client_alpha/proto_alpha.ml @@ -0,0 +1,12 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Name = struct let name = "alpha" end +module Environment = Tezos_client_environment.Environment.Make(Name)() +include Tezos_protocol_alpha.Functor.Make(Environment) diff --git a/src/proto_demo/lib_client_demo/proto_demo.ml b/src/proto_demo/lib_client_demo/proto_demo.ml new file mode 100644 index 000000000..51364d14e --- /dev/null +++ b/src/proto_demo/lib_client_demo/proto_demo.ml @@ -0,0 +1,12 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Name = struct let name = "demo" end +module Environment = Tezos_client_environment.Environment.Make(Name)() +include Tezos_protocol_demo.Functor.Make(Environment) diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.ml b/src/proto_genesis/lib_client_genesis/client_proto_main.ml index 2f06fd9de..86ac03e4e 100644 --- a/src/proto_genesis/lib_client_genesis/client_proto_main.ml +++ b/src/proto_genesis/lib_client_genesis/client_proto_main.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Tezos_embedded_raw_protocol_genesis +open Proto_genesis let protocol = Protocol_hash.of_b58check_exn @@ -75,7 +75,7 @@ let commands () = @@ stop) begin fun timestamp hash fitness validation_passes seckey (cctxt : Client_commands.full_context) -> let fitness = - Tezos_embedded_raw_protocol_alpha.Fitness_repr.from_int64 fitness in + Tezos_embedded_client_alpha.Proto_alpha.Fitness_repr.from_int64 fitness in bake cctxt ?timestamp cctxt#block (Activate { protocol = hash ; validation_passes ; fitness }) seckey >>=? fun hash -> diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.mli b/src/proto_genesis/lib_client_genesis/client_proto_main.mli index 9a13c3a7b..28050b7ec 100644 --- a/src/proto_genesis/lib_client_genesis/client_proto_main.mli +++ b/src/proto_genesis/lib_client_genesis/client_proto_main.mli @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Tezos_embedded_raw_protocol_genesis +open Proto_genesis val bake: #Client_rpcs.ctxt -> diff --git a/src/proto_genesis/lib_client_genesis/jbuild b/src/proto_genesis/lib_client_genesis/jbuild index 9d25b1a55..df0594e91 100644 --- a/src/proto_genesis/lib_client_genesis/jbuild +++ b/src/proto_genesis/lib_client_genesis/jbuild @@ -4,18 +4,15 @@ ((name tezos_embedded_client_genesis) (public_name tezos-embedded-client-genesis) (libraries (tezos-base - tezos-embedded-protocol-genesis - tezos-embedded-protocol-genesis.raw - tezos-embedded-protocol-alpha.environment - tezos-embedded-protocol-alpha.raw tezos-shell-services - tezos-client-base)) + tezos-client-base + tezos-client-environment + tezos-embedded-client-alpha + tezos-protocol-genesis)) (library_flags (:standard -linkall)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives - -open Tezos_embedded_protocol_environment_genesis - -open Tezos_embedded_raw_protocol_genesis -open Tezos_shell_services -open Tezos_client_base)))) diff --git a/src/proto_genesis/lib_client_genesis/proto_genesis.ml b/src/proto_genesis/lib_client_genesis/proto_genesis.ml new file mode 100644 index 000000000..38e52e123 --- /dev/null +++ b/src/proto_genesis/lib_client_genesis/proto_genesis.ml @@ -0,0 +1,12 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +module Name = struct let name = "genesis" end +module Environment = Tezos_client_environment.Environment.Make(Name)() +include Tezos_protocol_genesis.Functor.Make(Environment) diff --git a/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam b/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam index 7e5d18bf0..e95e0a103 100644 --- a/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam +++ b/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam @@ -10,10 +10,11 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-embedded-protocol-genesis" - "tezos-embedded-protocol-alpha" + "tezos-protocol-genesis" + "tezos-protocol-alpha" "tezos-shell-services" "tezos-client-base" + "tezos-client-environment" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/test/proto_alpha/jbuild b/test/proto_alpha/jbuild index cd911d4af..82ca1134b 100644 --- a/test/proto_alpha/jbuild +++ b/test/proto_alpha/jbuild @@ -15,12 +15,9 @@ (flags (:standard -w -9-32 -safe-string -open Tezos_base__TzPervasives -open Tezos_rpc_http - -open Tezos_embedded_protocol_environment_alpha - -open Tezos_embedded_raw_protocol_alpha -open Tezos_client_base -open Tezos_embedded_client_genesis - -open Tezos_embedded_client_alpha - -open Tezos_context)))) + -open Tezos_embedded_client_alpha)))) (alias ((name buildtest) diff --git a/test/proto_alpha/proto_alpha_helpers.ml b/test/proto_alpha/proto_alpha_helpers.ml index 19ab8bf26..94c918881 100644 --- a/test/proto_alpha/proto_alpha_helpers.ml +++ b/test/proto_alpha/proto_alpha_helpers.ml @@ -7,7 +7,8 @@ (* *) (**************************************************************************) -module Ed25519 = Environment.Ed25519 +open Proto_alpha +open Tezos_context let (//) = Filename.concat diff --git a/test/proto_alpha/proto_alpha_helpers.mli b/test/proto_alpha/proto_alpha_helpers.mli index 644ae6dcd..821505add 100644 --- a/test/proto_alpha/proto_alpha_helpers.mli +++ b/test/proto_alpha/proto_alpha_helpers.mli @@ -7,7 +7,8 @@ (* *) (**************************************************************************) -module Ed25519 = Environment.Ed25519 +open Proto_alpha +open Tezos_context val init : ?sandbox:string -> diff --git a/test/proto_alpha/test_endorsement.ml b/test/proto_alpha/test_endorsement.ml index 79c73478e..23e09936d 100644 --- a/test/proto_alpha/test_endorsement.ml +++ b/test/proto_alpha/test_endorsement.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context module Helpers = Proto_alpha_helpers module Assert = Helpers.Assert @@ -42,10 +44,10 @@ let test_double_endorsement contract block = (* FIXME: Baking.Invalid_signature is unclassified *) let test_invalid_signature block = let public_key = - Environment.Ed25519.Public_key.of_b58check_exn + Ed25519.Public_key.of_b58check_exn "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" in let secret_key = - Environment.Ed25519.Secret_key.of_b58check_exn + Ed25519.Secret_key.of_b58check_exn "edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh" in let account = Helpers.Account.create ~keys:(secret_key, public_key) "WRONG SIGNATURE" in diff --git a/test/proto_alpha/test_michelson_parser.ml b/test/proto_alpha/test_michelson_parser.ml index 7823e259b..1401a7eff 100644 --- a/test/proto_alpha/test_michelson_parser.ml +++ b/test/proto_alpha/test_michelson_parser.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Proto_alpha module Helpers = Proto_alpha_helpers module Assert = Helpers.Assert diff --git a/test/proto_alpha/test_origination.ml b/test/proto_alpha/test_origination.ml index c628812d0..e7a05b2ce 100644 --- a/test/proto_alpha/test_origination.ml +++ b/test/proto_alpha/test_origination.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context module Helpers = Proto_alpha_helpers module Assert = Helpers.Assert diff --git a/test/proto_alpha/test_transaction.ml b/test/proto_alpha/test_transaction.ml index 9e9c34529..a541b0c86 100644 --- a/test/proto_alpha/test_transaction.ml +++ b/test/proto_alpha/test_transaction.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context module Helpers = Proto_alpha_helpers module Assert = Helpers.Assert diff --git a/test/proto_alpha/test_vote.ml b/test/proto_alpha/test_vote.ml index 45ae0cad6..d68ffa5d6 100644 --- a/test/proto_alpha/test_vote.ml +++ b/test/proto_alpha/test_vote.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Proto_alpha +open Tezos_context open Proto_alpha_helpers let demo_protocol = From fda8b4ee5f479e9b05d987f3280210bef4974f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 29 Jan 2018 01:08:26 +0100 Subject: [PATCH 18/27] Refactor: rename `prota_alpha/lib_proto` --- src/proto_alpha/{lib_client_alpha => lib_client}/alpha.ml | 0 src/proto_alpha/{lib_client_alpha => lib_client}/alpha.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_blocks.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_blocks.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_daemon.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_daemon.mli | 0 .../client_baking_denunciation.ml | 0 .../client_baking_denunciation.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_endorsement.ml | 0 .../client_baking_endorsement.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_forge.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_forge.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_lib.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_lib.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_main.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_main.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_operations.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_operations.mli | 0 .../{lib_client_alpha => lib_client}/client_baking_revelation.ml | 0 .../{lib_client_alpha => lib_client}/client_baking_revelation.mli | 0 .../{lib_client_alpha => lib_client}/client_proto_args.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_args.mli | 0 .../{lib_client_alpha => lib_client}/client_proto_context.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_context.mli | 0 .../client_proto_context_commands.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_contracts.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_contracts.mli | 0 .../client_proto_contracts_commands.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_main.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_main.mli | 0 .../{lib_client_alpha => lib_client}/client_proto_nonces.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_nonces.mli | 0 .../{lib_client_alpha => lib_client}/client_proto_programs.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_programs.mli | 0 .../client_proto_programs_commands.ml | 0 .../client_proto_programs_commands.mli | 0 .../{lib_client_alpha => lib_client}/client_proto_rpcs.ml | 0 .../{lib_client_alpha => lib_client}/client_proto_rpcs.mli | 0 src/proto_alpha/{lib_client_alpha => lib_client}/jbuild | 0 .../{lib_client_alpha => lib_client}/michelson_macros.ml | 0 .../{lib_client_alpha => lib_client}/michelson_macros.mli | 0 .../{lib_client_alpha => lib_client}/michelson_v1_emacs.ml | 0 .../{lib_client_alpha => lib_client}/michelson_v1_emacs.mli | 0 .../michelson_v1_error_reporter.ml | 0 .../michelson_v1_error_reporter.mli | 0 .../{lib_client_alpha => lib_client}/michelson_v1_parser.ml | 0 .../{lib_client_alpha => lib_client}/michelson_v1_parser.mli | 0 .../{lib_client_alpha => lib_client}/michelson_v1_printer.ml | 0 .../{lib_client_alpha => lib_client}/michelson_v1_printer.mli | 0 src/proto_alpha/{lib_client_alpha => lib_client}/proto_alpha.ml | 0 .../tezos-embedded-client-alpha.opam | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/jbuild | 0 .../{lib_protocol_alpha => lib_protocol}/src/TEZOS_PROTOCOL | 0 .../{lib_protocol_alpha => lib_protocol}/src/amendment.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/amendment.mli | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/apply.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/baking.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/baking.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/block_header_repr.ml | 0 .../src/block_header_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/bootstrap_storage.ml | 0 .../src/bootstrap_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/constants_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/contract_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/contract_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/contract_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/contract_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/cycle_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/cycle_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/fitness_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/fitness_storage.ml | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/gas.ml | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/gas.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/init_storage.ml | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/jbuild | 0 .../{lib_protocol_alpha => lib_protocol}/src/level_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/level_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/level_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/level_storage.mli | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/main.ml | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/main.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/manager_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/manager_repr.mli | 0 .../src/michelson_v1_primitives.ml | 0 .../src/michelson_v1_primitives.mli | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/misc.ml | 0 src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/misc.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/nonce_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/nonce_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/operation_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/operation_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/period_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/period_repr.mli | 0 .../src/public_key_storage.ml | 0 .../src/public_key_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/qty_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/raw_context.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/raw_context.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/raw_level_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/raw_level_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/reward_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/reward_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/roll_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/roll_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/roll_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/roll_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/script_int_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/script_int_repr.mli | 0 .../src/script_interpreter.ml | 0 .../src/script_interpreter.mli | 0 .../src/script_ir_translator.ml | 0 .../src/script_ir_translator.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/script_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/script_repr.mli | 0 .../src/script_timestamp_repr.ml | 0 .../src/script_timestamp_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/script_typed_ir.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/seed_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/seed_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/seed_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/seed_storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/services.ml | 0 .../src/services_registration.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/storage.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/storage_functors.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/storage_functors.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/storage_sigs.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/tez_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/tez_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/tezos_context.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/tezos_context.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/tezos_hash.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/time_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/time_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/vote_repr.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/vote_repr.mli | 0 .../{lib_protocol_alpha => lib_protocol}/src/vote_storage.ml | 0 .../{lib_protocol_alpha => lib_protocol}/src/vote_storage.mli | 0 .../src/voting_period_repr.ml | 0 .../src/voting_period_repr.mli | 0 .../tezos-embedded-protocol-alpha.opam | 0 .../tezos-protocol-alpha.opam | 0 .../{lib_client_demo => lib_client}/client_proto_main.ml | 0 .../{lib_client_demo => lib_client}/client_proto_main.mli | 0 .../{lib_client_demo => lib_client}/client_proto_rpcs.ml | 0 .../{lib_client_demo => lib_client}/client_proto_rpcs.mli | 0 src/proto_demo/{lib_client_demo => lib_client}/proto_demo.ml | 0 src/proto_demo/{lib_protocol_demo => lib_protocol}/jbuild | 0 .../{lib_protocol_demo => lib_protocol}/src/TEZOS_PROTOCOL | 0 src/proto_demo/{lib_protocol_demo => lib_protocol}/src/error.ml | 0 src/proto_demo/{lib_protocol_demo => lib_protocol}/src/jbuild | 0 src/proto_demo/{lib_protocol_demo => lib_protocol}/src/main.ml | 0 .../{lib_protocol_demo => lib_protocol}/src/services.ml | 0 .../tezos-embedded-protocol-demo.opam | 0 .../{lib_protocol_demo => lib_protocol}/tezos-protocol-demo.opam | 0 .../{lib_client_genesis => lib_client}/client_proto_main.ml | 0 .../{lib_client_genesis => lib_client}/client_proto_main.mli | 0 src/proto_genesis/{lib_client_genesis => lib_client}/jbuild | 0 .../{lib_client_genesis => lib_client}/proto_genesis.ml | 0 .../tezos-embedded-client-genesis.opam | 0 src/proto_genesis/{lib_protocol_genesis => lib_protocol}/jbuild | 0 .../{lib_protocol_genesis => lib_protocol}/src/TEZOS_PROTOCOL | 0 .../{lib_protocol_genesis => lib_protocol}/src/data.ml | 0 .../{lib_protocol_genesis => lib_protocol}/src/jbuild | 0 .../{lib_protocol_genesis => lib_protocol}/src/main.ml | 0 .../{lib_protocol_genesis => lib_protocol}/src/services.ml | 0 .../tezos-embedded-protocol-genesis.opam | 0 .../tezos-protocol-genesis.opam | 0 169 files changed, 0 insertions(+), 0 deletions(-) rename src/proto_alpha/{lib_client_alpha => lib_client}/alpha.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/alpha.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_blocks.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_blocks.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_daemon.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_daemon.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_denunciation.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_denunciation.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_endorsement.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_endorsement.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_forge.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_forge.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_lib.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_lib.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_main.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_main.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_operations.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_operations.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_revelation.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_baking_revelation.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_args.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_args.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_context.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_context.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_context_commands.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_contracts.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_contracts.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_contracts_commands.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_main.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_main.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_nonces.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_nonces.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_programs.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_programs.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_programs_commands.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_programs_commands.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_rpcs.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/client_proto_rpcs.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/jbuild (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_macros.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_macros.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_emacs.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_emacs.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_error_reporter.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_error_reporter.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_parser.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_parser.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_printer.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/michelson_v1_printer.mli (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/proto_alpha.ml (100%) rename src/proto_alpha/{lib_client_alpha => lib_client}/tezos-embedded-client-alpha.opam (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/jbuild (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/TEZOS_PROTOCOL (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/amendment.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/amendment.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/apply.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/baking.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/baking.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/block_header_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/block_header_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/bootstrap_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/bootstrap_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/constants_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/contract_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/contract_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/contract_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/contract_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/cycle_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/cycle_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/fitness_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/fitness_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/gas.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/gas.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/init_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/jbuild (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/level_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/level_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/level_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/level_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/main.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/main.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/manager_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/manager_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/michelson_v1_primitives.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/michelson_v1_primitives.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/misc.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/misc.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/nonce_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/nonce_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/operation_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/operation_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/period_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/period_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/public_key_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/public_key_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/qty_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/raw_context.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/raw_context.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/raw_level_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/raw_level_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/reward_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/reward_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/roll_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/roll_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/roll_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/roll_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_int_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_int_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_interpreter.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_interpreter.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_ir_translator.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_ir_translator.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_timestamp_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_timestamp_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/script_typed_ir.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/seed_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/seed_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/seed_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/seed_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/services.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/services_registration.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/storage_functors.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/storage_functors.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/storage_sigs.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/tez_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/tez_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/tezos_context.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/tezos_context.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/tezos_hash.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/time_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/time_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/vote_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/vote_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/vote_storage.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/vote_storage.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/voting_period_repr.ml (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/src/voting_period_repr.mli (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/tezos-embedded-protocol-alpha.opam (100%) rename src/proto_alpha/{lib_protocol_alpha => lib_protocol}/tezos-protocol-alpha.opam (100%) rename src/proto_demo/{lib_client_demo => lib_client}/client_proto_main.ml (100%) rename src/proto_demo/{lib_client_demo => lib_client}/client_proto_main.mli (100%) rename src/proto_demo/{lib_client_demo => lib_client}/client_proto_rpcs.ml (100%) rename src/proto_demo/{lib_client_demo => lib_client}/client_proto_rpcs.mli (100%) rename src/proto_demo/{lib_client_demo => lib_client}/proto_demo.ml (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/jbuild (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/src/TEZOS_PROTOCOL (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/src/error.ml (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/src/jbuild (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/src/main.ml (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/src/services.ml (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/tezos-embedded-protocol-demo.opam (100%) rename src/proto_demo/{lib_protocol_demo => lib_protocol}/tezos-protocol-demo.opam (100%) rename src/proto_genesis/{lib_client_genesis => lib_client}/client_proto_main.ml (100%) rename src/proto_genesis/{lib_client_genesis => lib_client}/client_proto_main.mli (100%) rename src/proto_genesis/{lib_client_genesis => lib_client}/jbuild (100%) rename src/proto_genesis/{lib_client_genesis => lib_client}/proto_genesis.ml (100%) rename src/proto_genesis/{lib_client_genesis => lib_client}/tezos-embedded-client-genesis.opam (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/jbuild (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/src/TEZOS_PROTOCOL (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/src/data.ml (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/src/jbuild (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/src/main.ml (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/src/services.ml (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/tezos-embedded-protocol-genesis.opam (100%) rename src/proto_genesis/{lib_protocol_genesis => lib_protocol}/tezos-protocol-genesis.opam (100%) diff --git a/src/proto_alpha/lib_client_alpha/alpha.ml b/src/proto_alpha/lib_client/alpha.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/alpha.ml rename to src/proto_alpha/lib_client/alpha.ml diff --git a/src/proto_alpha/lib_client_alpha/alpha.mli b/src/proto_alpha/lib_client/alpha.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/alpha.mli rename to src/proto_alpha/lib_client/alpha.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_blocks.ml b/src/proto_alpha/lib_client/client_baking_blocks.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_blocks.ml rename to src/proto_alpha/lib_client/client_baking_blocks.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_blocks.mli b/src/proto_alpha/lib_client/client_baking_blocks.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_blocks.mli rename to src/proto_alpha/lib_client/client_baking_blocks.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_daemon.ml b/src/proto_alpha/lib_client/client_baking_daemon.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_daemon.ml rename to src/proto_alpha/lib_client/client_baking_daemon.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_daemon.mli b/src/proto_alpha/lib_client/client_baking_daemon.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_daemon.mli rename to src/proto_alpha/lib_client/client_baking_daemon.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_denunciation.ml b/src/proto_alpha/lib_client/client_baking_denunciation.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_denunciation.ml rename to src/proto_alpha/lib_client/client_baking_denunciation.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_denunciation.mli b/src/proto_alpha/lib_client/client_baking_denunciation.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_denunciation.mli rename to src/proto_alpha/lib_client/client_baking_denunciation.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml b/src/proto_alpha/lib_client/client_baking_endorsement.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_endorsement.ml rename to src/proto_alpha/lib_client/client_baking_endorsement.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli b/src/proto_alpha/lib_client/client_baking_endorsement.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_endorsement.mli rename to src/proto_alpha/lib_client/client_baking_endorsement.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_forge.ml b/src/proto_alpha/lib_client/client_baking_forge.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_forge.ml rename to src/proto_alpha/lib_client/client_baking_forge.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_forge.mli b/src/proto_alpha/lib_client/client_baking_forge.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_forge.mli rename to src/proto_alpha/lib_client/client_baking_forge.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_lib.ml b/src/proto_alpha/lib_client/client_baking_lib.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_lib.ml rename to src/proto_alpha/lib_client/client_baking_lib.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_lib.mli b/src/proto_alpha/lib_client/client_baking_lib.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_lib.mli rename to src/proto_alpha/lib_client/client_baking_lib.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_main.ml b/src/proto_alpha/lib_client/client_baking_main.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_main.ml rename to src/proto_alpha/lib_client/client_baking_main.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_main.mli b/src/proto_alpha/lib_client/client_baking_main.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_main.mli rename to src/proto_alpha/lib_client/client_baking_main.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_operations.ml b/src/proto_alpha/lib_client/client_baking_operations.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_operations.ml rename to src/proto_alpha/lib_client/client_baking_operations.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_operations.mli b/src/proto_alpha/lib_client/client_baking_operations.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_operations.mli rename to src/proto_alpha/lib_client/client_baking_operations.mli diff --git a/src/proto_alpha/lib_client_alpha/client_baking_revelation.ml b/src/proto_alpha/lib_client/client_baking_revelation.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_revelation.ml rename to src/proto_alpha/lib_client/client_baking_revelation.ml diff --git a/src/proto_alpha/lib_client_alpha/client_baking_revelation.mli b/src/proto_alpha/lib_client/client_baking_revelation.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_baking_revelation.mli rename to src/proto_alpha/lib_client/client_baking_revelation.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_args.ml rename to src/proto_alpha/lib_client/client_proto_args.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_args.mli b/src/proto_alpha/lib_client/client_proto_args.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_args.mli rename to src/proto_alpha/lib_client/client_proto_args.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_context.ml rename to src/proto_alpha/lib_client/client_proto_context.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_context.mli rename to src/proto_alpha/lib_client/client_proto_context.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml b/src/proto_alpha/lib_client/client_proto_context_commands.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_context_commands.ml rename to src/proto_alpha/lib_client/client_proto_context_commands.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_contracts.ml rename to src/proto_alpha/lib_client/client_proto_contracts.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts.mli b/src/proto_alpha/lib_client/client_proto_contracts.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_contracts.mli rename to src/proto_alpha/lib_client/client_proto_contracts.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml b/src/proto_alpha/lib_client/client_proto_contracts_commands.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_contracts_commands.ml rename to src/proto_alpha/lib_client/client_proto_contracts_commands.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_main.ml b/src/proto_alpha/lib_client/client_proto_main.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_main.ml rename to src/proto_alpha/lib_client/client_proto_main.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_main.mli b/src/proto_alpha/lib_client/client_proto_main.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_main.mli rename to src/proto_alpha/lib_client/client_proto_main.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_nonces.ml b/src/proto_alpha/lib_client/client_proto_nonces.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_nonces.ml rename to src/proto_alpha/lib_client/client_proto_nonces.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_nonces.mli b/src/proto_alpha/lib_client/client_proto_nonces.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_nonces.mli rename to src/proto_alpha/lib_client/client_proto_nonces.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs.ml b/src/proto_alpha/lib_client/client_proto_programs.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_programs.ml rename to src/proto_alpha/lib_client/client_proto_programs.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs.mli b/src/proto_alpha/lib_client/client_proto_programs.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_programs.mli rename to src/proto_alpha/lib_client/client_proto_programs.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs_commands.ml b/src/proto_alpha/lib_client/client_proto_programs_commands.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_programs_commands.ml rename to src/proto_alpha/lib_client/client_proto_programs_commands.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_programs_commands.mli b/src/proto_alpha/lib_client/client_proto_programs_commands.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_programs_commands.mli rename to src/proto_alpha/lib_client/client_proto_programs_commands.mli diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml b/src/proto_alpha/lib_client/client_proto_rpcs.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_rpcs.ml rename to src/proto_alpha/lib_client/client_proto_rpcs.ml diff --git a/src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli b/src/proto_alpha/lib_client/client_proto_rpcs.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/client_proto_rpcs.mli rename to src/proto_alpha/lib_client/client_proto_rpcs.mli diff --git a/src/proto_alpha/lib_client_alpha/jbuild b/src/proto_alpha/lib_client/jbuild similarity index 100% rename from src/proto_alpha/lib_client_alpha/jbuild rename to src/proto_alpha/lib_client/jbuild diff --git a/src/proto_alpha/lib_client_alpha/michelson_macros.ml b/src/proto_alpha/lib_client/michelson_macros.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_macros.ml rename to src/proto_alpha/lib_client/michelson_macros.ml diff --git a/src/proto_alpha/lib_client_alpha/michelson_macros.mli b/src/proto_alpha/lib_client/michelson_macros.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_macros.mli rename to src/proto_alpha/lib_client/michelson_macros.mli diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml b/src/proto_alpha/lib_client/michelson_v1_emacs.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_emacs.ml rename to src/proto_alpha/lib_client/michelson_v1_emacs.ml diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli b/src/proto_alpha/lib_client/michelson_v1_emacs.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_emacs.mli rename to src/proto_alpha/lib_client/michelson_v1_emacs.mli diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml b/src/proto_alpha/lib_client/michelson_v1_error_reporter.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.ml rename to src/proto_alpha/lib_client/michelson_v1_error_reporter.ml diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.mli b/src/proto_alpha/lib_client/michelson_v1_error_reporter.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_error_reporter.mli rename to src/proto_alpha/lib_client/michelson_v1_error_reporter.mli diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml b/src/proto_alpha/lib_client/michelson_v1_parser.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_parser.ml rename to src/proto_alpha/lib_client/michelson_v1_parser.ml diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli b/src/proto_alpha/lib_client/michelson_v1_parser.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_parser.mli rename to src/proto_alpha/lib_client/michelson_v1_parser.mli diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml b/src/proto_alpha/lib_client/michelson_v1_printer.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_printer.ml rename to src/proto_alpha/lib_client/michelson_v1_printer.ml diff --git a/src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli b/src/proto_alpha/lib_client/michelson_v1_printer.mli similarity index 100% rename from src/proto_alpha/lib_client_alpha/michelson_v1_printer.mli rename to src/proto_alpha/lib_client/michelson_v1_printer.mli diff --git a/src/proto_alpha/lib_client_alpha/proto_alpha.ml b/src/proto_alpha/lib_client/proto_alpha.ml similarity index 100% rename from src/proto_alpha/lib_client_alpha/proto_alpha.ml rename to src/proto_alpha/lib_client/proto_alpha.ml diff --git a/src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam b/src/proto_alpha/lib_client/tezos-embedded-client-alpha.opam similarity index 100% rename from src/proto_alpha/lib_client_alpha/tezos-embedded-client-alpha.opam rename to src/proto_alpha/lib_client/tezos-embedded-client-alpha.opam diff --git a/src/proto_alpha/lib_protocol_alpha/jbuild b/src/proto_alpha/lib_protocol/jbuild similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/jbuild rename to src/proto_alpha/lib_protocol/jbuild diff --git a/src/proto_alpha/lib_protocol_alpha/src/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/TEZOS_PROTOCOL rename to src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL diff --git a/src/proto_alpha/lib_protocol_alpha/src/amendment.ml b/src/proto_alpha/lib_protocol/src/amendment.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/amendment.ml rename to src/proto_alpha/lib_protocol/src/amendment.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/amendment.mli b/src/proto_alpha/lib_protocol/src/amendment.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/amendment.mli rename to src/proto_alpha/lib_protocol/src/amendment.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/apply.ml rename to src/proto_alpha/lib_protocol/src/apply.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/baking.ml b/src/proto_alpha/lib_protocol/src/baking.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/baking.ml rename to src/proto_alpha/lib_protocol/src/baking.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/baking.mli b/src/proto_alpha/lib_protocol/src/baking.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/baking.mli rename to src/proto_alpha/lib_protocol/src/baking.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/block_header_repr.ml b/src/proto_alpha/lib_protocol/src/block_header_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/block_header_repr.ml rename to src/proto_alpha/lib_protocol/src/block_header_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/block_header_repr.mli b/src/proto_alpha/lib_protocol/src/block_header_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/block_header_repr.mli rename to src/proto_alpha/lib_protocol/src/block_header_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.ml rename to src/proto_alpha/lib_protocol/src/bootstrap_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.mli b/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/bootstrap_storage.mli rename to src/proto_alpha/lib_protocol/src/bootstrap_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/constants_repr.ml rename to src/proto_alpha/lib_protocol/src/constants_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/contract_repr.ml b/src/proto_alpha/lib_protocol/src/contract_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/contract_repr.ml rename to src/proto_alpha/lib_protocol/src/contract_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/contract_repr.mli b/src/proto_alpha/lib_protocol/src/contract_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/contract_repr.mli rename to src/proto_alpha/lib_protocol/src/contract_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/contract_storage.ml b/src/proto_alpha/lib_protocol/src/contract_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/contract_storage.ml rename to src/proto_alpha/lib_protocol/src/contract_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/contract_storage.mli b/src/proto_alpha/lib_protocol/src/contract_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/contract_storage.mli rename to src/proto_alpha/lib_protocol/src/contract_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/cycle_repr.ml b/src/proto_alpha/lib_protocol/src/cycle_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/cycle_repr.ml rename to src/proto_alpha/lib_protocol/src/cycle_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/cycle_repr.mli b/src/proto_alpha/lib_protocol/src/cycle_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/cycle_repr.mli rename to src/proto_alpha/lib_protocol/src/cycle_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/fitness_repr.ml b/src/proto_alpha/lib_protocol/src/fitness_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/fitness_repr.ml rename to src/proto_alpha/lib_protocol/src/fitness_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/fitness_storage.ml b/src/proto_alpha/lib_protocol/src/fitness_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/fitness_storage.ml rename to src/proto_alpha/lib_protocol/src/fitness_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/gas.ml b/src/proto_alpha/lib_protocol/src/gas.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/gas.ml rename to src/proto_alpha/lib_protocol/src/gas.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/gas.mli b/src/proto_alpha/lib_protocol/src/gas.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/gas.mli rename to src/proto_alpha/lib_protocol/src/gas.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/init_storage.ml b/src/proto_alpha/lib_protocol/src/init_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/init_storage.ml rename to src/proto_alpha/lib_protocol/src/init_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/jbuild b/src/proto_alpha/lib_protocol/src/jbuild similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/jbuild rename to src/proto_alpha/lib_protocol/src/jbuild diff --git a/src/proto_alpha/lib_protocol_alpha/src/level_repr.ml b/src/proto_alpha/lib_protocol/src/level_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/level_repr.ml rename to src/proto_alpha/lib_protocol/src/level_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/level_repr.mli b/src/proto_alpha/lib_protocol/src/level_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/level_repr.mli rename to src/proto_alpha/lib_protocol/src/level_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/level_storage.ml b/src/proto_alpha/lib_protocol/src/level_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/level_storage.ml rename to src/proto_alpha/lib_protocol/src/level_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/level_storage.mli b/src/proto_alpha/lib_protocol/src/level_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/level_storage.mli rename to src/proto_alpha/lib_protocol/src/level_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/main.ml b/src/proto_alpha/lib_protocol/src/main.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/main.ml rename to src/proto_alpha/lib_protocol/src/main.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/main.mli b/src/proto_alpha/lib_protocol/src/main.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/main.mli rename to src/proto_alpha/lib_protocol/src/main.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/manager_repr.ml b/src/proto_alpha/lib_protocol/src/manager_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/manager_repr.ml rename to src/proto_alpha/lib_protocol/src/manager_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/manager_repr.mli b/src/proto_alpha/lib_protocol/src/manager_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/manager_repr.mli rename to src/proto_alpha/lib_protocol/src/manager_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.ml rename to src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/michelson_v1_primitives.mli rename to src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/misc.ml b/src/proto_alpha/lib_protocol/src/misc.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/misc.ml rename to src/proto_alpha/lib_protocol/src/misc.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/misc.mli b/src/proto_alpha/lib_protocol/src/misc.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/misc.mli rename to src/proto_alpha/lib_protocol/src/misc.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/nonce_storage.ml b/src/proto_alpha/lib_protocol/src/nonce_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/nonce_storage.ml rename to src/proto_alpha/lib_protocol/src/nonce_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/nonce_storage.mli b/src/proto_alpha/lib_protocol/src/nonce_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/nonce_storage.mli rename to src/proto_alpha/lib_protocol/src/nonce_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/operation_repr.ml b/src/proto_alpha/lib_protocol/src/operation_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/operation_repr.ml rename to src/proto_alpha/lib_protocol/src/operation_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/operation_repr.mli b/src/proto_alpha/lib_protocol/src/operation_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/operation_repr.mli rename to src/proto_alpha/lib_protocol/src/operation_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/period_repr.ml b/src/proto_alpha/lib_protocol/src/period_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/period_repr.ml rename to src/proto_alpha/lib_protocol/src/period_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/period_repr.mli b/src/proto_alpha/lib_protocol/src/period_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/period_repr.mli rename to src/proto_alpha/lib_protocol/src/period_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/public_key_storage.ml b/src/proto_alpha/lib_protocol/src/public_key_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/public_key_storage.ml rename to src/proto_alpha/lib_protocol/src/public_key_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/public_key_storage.mli b/src/proto_alpha/lib_protocol/src/public_key_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/public_key_storage.mli rename to src/proto_alpha/lib_protocol/src/public_key_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/qty_repr.ml b/src/proto_alpha/lib_protocol/src/qty_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/qty_repr.ml rename to src/proto_alpha/lib_protocol/src/qty_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/raw_context.ml b/src/proto_alpha/lib_protocol/src/raw_context.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/raw_context.ml rename to src/proto_alpha/lib_protocol/src/raw_context.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/raw_context.mli b/src/proto_alpha/lib_protocol/src/raw_context.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/raw_context.mli rename to src/proto_alpha/lib_protocol/src/raw_context.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.ml b/src/proto_alpha/lib_protocol/src/raw_level_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.ml rename to src/proto_alpha/lib_protocol/src/raw_level_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.mli b/src/proto_alpha/lib_protocol/src/raw_level_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/raw_level_repr.mli rename to src/proto_alpha/lib_protocol/src/raw_level_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/reward_storage.ml b/src/proto_alpha/lib_protocol/src/reward_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/reward_storage.ml rename to src/proto_alpha/lib_protocol/src/reward_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/reward_storage.mli b/src/proto_alpha/lib_protocol/src/reward_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/reward_storage.mli rename to src/proto_alpha/lib_protocol/src/reward_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/roll_repr.ml b/src/proto_alpha/lib_protocol/src/roll_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/roll_repr.ml rename to src/proto_alpha/lib_protocol/src/roll_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/roll_repr.mli b/src/proto_alpha/lib_protocol/src/roll_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/roll_repr.mli rename to src/proto_alpha/lib_protocol/src/roll_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/roll_storage.ml b/src/proto_alpha/lib_protocol/src/roll_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/roll_storage.ml rename to src/proto_alpha/lib_protocol/src/roll_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/roll_storage.mli b/src/proto_alpha/lib_protocol/src/roll_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/roll_storage.mli rename to src/proto_alpha/lib_protocol/src/roll_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_int_repr.ml b/src/proto_alpha/lib_protocol/src/script_int_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_int_repr.ml rename to src/proto_alpha/lib_protocol/src/script_int_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_int_repr.mli b/src/proto_alpha/lib_protocol/src/script_int_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_int_repr.mli rename to src/proto_alpha/lib_protocol/src/script_int_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_interpreter.ml b/src/proto_alpha/lib_protocol/src/script_interpreter.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_interpreter.ml rename to src/proto_alpha/lib_protocol/src/script_interpreter.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_interpreter.mli b/src/proto_alpha/lib_protocol/src/script_interpreter.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_interpreter.mli rename to src/proto_alpha/lib_protocol/src/script_interpreter.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.ml rename to src/proto_alpha/lib_protocol/src/script_ir_translator.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.mli b/src/proto_alpha/lib_protocol/src/script_ir_translator.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_ir_translator.mli rename to src/proto_alpha/lib_protocol/src/script_ir_translator.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_repr.ml b/src/proto_alpha/lib_protocol/src/script_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_repr.ml rename to src/proto_alpha/lib_protocol/src/script_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_repr.mli b/src/proto_alpha/lib_protocol/src/script_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_repr.mli rename to src/proto_alpha/lib_protocol/src/script_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.ml b/src/proto_alpha/lib_protocol/src/script_timestamp_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.ml rename to src/proto_alpha/lib_protocol/src/script_timestamp_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.mli b/src/proto_alpha/lib_protocol/src/script_timestamp_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_timestamp_repr.mli rename to src/proto_alpha/lib_protocol/src/script_timestamp_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/script_typed_ir.ml b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/script_typed_ir.ml rename to src/proto_alpha/lib_protocol/src/script_typed_ir.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/seed_repr.ml b/src/proto_alpha/lib_protocol/src/seed_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/seed_repr.ml rename to src/proto_alpha/lib_protocol/src/seed_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/seed_repr.mli b/src/proto_alpha/lib_protocol/src/seed_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/seed_repr.mli rename to src/proto_alpha/lib_protocol/src/seed_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/seed_storage.ml b/src/proto_alpha/lib_protocol/src/seed_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/seed_storage.ml rename to src/proto_alpha/lib_protocol/src/seed_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/seed_storage.mli b/src/proto_alpha/lib_protocol/src/seed_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/seed_storage.mli rename to src/proto_alpha/lib_protocol/src/seed_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/services.ml b/src/proto_alpha/lib_protocol/src/services.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/services.ml rename to src/proto_alpha/lib_protocol/src/services.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/services_registration.ml b/src/proto_alpha/lib_protocol/src/services_registration.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/services_registration.ml rename to src/proto_alpha/lib_protocol/src/services_registration.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/storage.ml b/src/proto_alpha/lib_protocol/src/storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/storage.ml rename to src/proto_alpha/lib_protocol/src/storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/storage.mli b/src/proto_alpha/lib_protocol/src/storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/storage.mli rename to src/proto_alpha/lib_protocol/src/storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/storage_functors.ml b/src/proto_alpha/lib_protocol/src/storage_functors.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/storage_functors.ml rename to src/proto_alpha/lib_protocol/src/storage_functors.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/storage_functors.mli b/src/proto_alpha/lib_protocol/src/storage_functors.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/storage_functors.mli rename to src/proto_alpha/lib_protocol/src/storage_functors.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/storage_sigs.ml b/src/proto_alpha/lib_protocol/src/storage_sigs.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/storage_sigs.ml rename to src/proto_alpha/lib_protocol/src/storage_sigs.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/tez_repr.ml b/src/proto_alpha/lib_protocol/src/tez_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/tez_repr.ml rename to src/proto_alpha/lib_protocol/src/tez_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/tez_repr.mli b/src/proto_alpha/lib_protocol/src/tez_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/tez_repr.mli rename to src/proto_alpha/lib_protocol/src/tez_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/tezos_context.ml b/src/proto_alpha/lib_protocol/src/tezos_context.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/tezos_context.ml rename to src/proto_alpha/lib_protocol/src/tezos_context.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/tezos_context.mli b/src/proto_alpha/lib_protocol/src/tezos_context.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/tezos_context.mli rename to src/proto_alpha/lib_protocol/src/tezos_context.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/tezos_hash.ml b/src/proto_alpha/lib_protocol/src/tezos_hash.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/tezos_hash.ml rename to src/proto_alpha/lib_protocol/src/tezos_hash.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/time_repr.ml b/src/proto_alpha/lib_protocol/src/time_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/time_repr.ml rename to src/proto_alpha/lib_protocol/src/time_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/time_repr.mli b/src/proto_alpha/lib_protocol/src/time_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/time_repr.mli rename to src/proto_alpha/lib_protocol/src/time_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/vote_repr.ml b/src/proto_alpha/lib_protocol/src/vote_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/vote_repr.ml rename to src/proto_alpha/lib_protocol/src/vote_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/vote_repr.mli b/src/proto_alpha/lib_protocol/src/vote_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/vote_repr.mli rename to src/proto_alpha/lib_protocol/src/vote_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/vote_storage.ml b/src/proto_alpha/lib_protocol/src/vote_storage.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/vote_storage.ml rename to src/proto_alpha/lib_protocol/src/vote_storage.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/vote_storage.mli b/src/proto_alpha/lib_protocol/src/vote_storage.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/vote_storage.mli rename to src/proto_alpha/lib_protocol/src/vote_storage.mli diff --git a/src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.ml b/src/proto_alpha/lib_protocol/src/voting_period_repr.ml similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.ml rename to src/proto_alpha/lib_protocol/src/voting_period_repr.ml diff --git a/src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.mli b/src/proto_alpha/lib_protocol/src/voting_period_repr.mli similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/src/voting_period_repr.mli rename to src/proto_alpha/lib_protocol/src/voting_period_repr.mli diff --git a/src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam b/src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/tezos-embedded-protocol-alpha.opam rename to src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam diff --git a/src/proto_alpha/lib_protocol_alpha/tezos-protocol-alpha.opam b/src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam similarity index 100% rename from src/proto_alpha/lib_protocol_alpha/tezos-protocol-alpha.opam rename to src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam diff --git a/src/proto_demo/lib_client_demo/client_proto_main.ml b/src/proto_demo/lib_client/client_proto_main.ml similarity index 100% rename from src/proto_demo/lib_client_demo/client_proto_main.ml rename to src/proto_demo/lib_client/client_proto_main.ml diff --git a/src/proto_demo/lib_client_demo/client_proto_main.mli b/src/proto_demo/lib_client/client_proto_main.mli similarity index 100% rename from src/proto_demo/lib_client_demo/client_proto_main.mli rename to src/proto_demo/lib_client/client_proto_main.mli diff --git a/src/proto_demo/lib_client_demo/client_proto_rpcs.ml b/src/proto_demo/lib_client/client_proto_rpcs.ml similarity index 100% rename from src/proto_demo/lib_client_demo/client_proto_rpcs.ml rename to src/proto_demo/lib_client/client_proto_rpcs.ml diff --git a/src/proto_demo/lib_client_demo/client_proto_rpcs.mli b/src/proto_demo/lib_client/client_proto_rpcs.mli similarity index 100% rename from src/proto_demo/lib_client_demo/client_proto_rpcs.mli rename to src/proto_demo/lib_client/client_proto_rpcs.mli diff --git a/src/proto_demo/lib_client_demo/proto_demo.ml b/src/proto_demo/lib_client/proto_demo.ml similarity index 100% rename from src/proto_demo/lib_client_demo/proto_demo.ml rename to src/proto_demo/lib_client/proto_demo.ml diff --git a/src/proto_demo/lib_protocol_demo/jbuild b/src/proto_demo/lib_protocol/jbuild similarity index 100% rename from src/proto_demo/lib_protocol_demo/jbuild rename to src/proto_demo/lib_protocol/jbuild diff --git a/src/proto_demo/lib_protocol_demo/src/TEZOS_PROTOCOL b/src/proto_demo/lib_protocol/src/TEZOS_PROTOCOL similarity index 100% rename from src/proto_demo/lib_protocol_demo/src/TEZOS_PROTOCOL rename to src/proto_demo/lib_protocol/src/TEZOS_PROTOCOL diff --git a/src/proto_demo/lib_protocol_demo/src/error.ml b/src/proto_demo/lib_protocol/src/error.ml similarity index 100% rename from src/proto_demo/lib_protocol_demo/src/error.ml rename to src/proto_demo/lib_protocol/src/error.ml diff --git a/src/proto_demo/lib_protocol_demo/src/jbuild b/src/proto_demo/lib_protocol/src/jbuild similarity index 100% rename from src/proto_demo/lib_protocol_demo/src/jbuild rename to src/proto_demo/lib_protocol/src/jbuild diff --git a/src/proto_demo/lib_protocol_demo/src/main.ml b/src/proto_demo/lib_protocol/src/main.ml similarity index 100% rename from src/proto_demo/lib_protocol_demo/src/main.ml rename to src/proto_demo/lib_protocol/src/main.ml diff --git a/src/proto_demo/lib_protocol_demo/src/services.ml b/src/proto_demo/lib_protocol/src/services.ml similarity index 100% rename from src/proto_demo/lib_protocol_demo/src/services.ml rename to src/proto_demo/lib_protocol/src/services.ml diff --git a/src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam b/src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam similarity index 100% rename from src/proto_demo/lib_protocol_demo/tezos-embedded-protocol-demo.opam rename to src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam diff --git a/src/proto_demo/lib_protocol_demo/tezos-protocol-demo.opam b/src/proto_demo/lib_protocol/tezos-protocol-demo.opam similarity index 100% rename from src/proto_demo/lib_protocol_demo/tezos-protocol-demo.opam rename to src/proto_demo/lib_protocol/tezos-protocol-demo.opam diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.ml b/src/proto_genesis/lib_client/client_proto_main.ml similarity index 100% rename from src/proto_genesis/lib_client_genesis/client_proto_main.ml rename to src/proto_genesis/lib_client/client_proto_main.ml diff --git a/src/proto_genesis/lib_client_genesis/client_proto_main.mli b/src/proto_genesis/lib_client/client_proto_main.mli similarity index 100% rename from src/proto_genesis/lib_client_genesis/client_proto_main.mli rename to src/proto_genesis/lib_client/client_proto_main.mli diff --git a/src/proto_genesis/lib_client_genesis/jbuild b/src/proto_genesis/lib_client/jbuild similarity index 100% rename from src/proto_genesis/lib_client_genesis/jbuild rename to src/proto_genesis/lib_client/jbuild diff --git a/src/proto_genesis/lib_client_genesis/proto_genesis.ml b/src/proto_genesis/lib_client/proto_genesis.ml similarity index 100% rename from src/proto_genesis/lib_client_genesis/proto_genesis.ml rename to src/proto_genesis/lib_client/proto_genesis.ml diff --git a/src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam b/src/proto_genesis/lib_client/tezos-embedded-client-genesis.opam similarity index 100% rename from src/proto_genesis/lib_client_genesis/tezos-embedded-client-genesis.opam rename to src/proto_genesis/lib_client/tezos-embedded-client-genesis.opam diff --git a/src/proto_genesis/lib_protocol_genesis/jbuild b/src/proto_genesis/lib_protocol/jbuild similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/jbuild rename to src/proto_genesis/lib_protocol/jbuild diff --git a/src/proto_genesis/lib_protocol_genesis/src/TEZOS_PROTOCOL b/src/proto_genesis/lib_protocol/src/TEZOS_PROTOCOL similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/src/TEZOS_PROTOCOL rename to src/proto_genesis/lib_protocol/src/TEZOS_PROTOCOL diff --git a/src/proto_genesis/lib_protocol_genesis/src/data.ml b/src/proto_genesis/lib_protocol/src/data.ml similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/src/data.ml rename to src/proto_genesis/lib_protocol/src/data.ml diff --git a/src/proto_genesis/lib_protocol_genesis/src/jbuild b/src/proto_genesis/lib_protocol/src/jbuild similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/src/jbuild rename to src/proto_genesis/lib_protocol/src/jbuild diff --git a/src/proto_genesis/lib_protocol_genesis/src/main.ml b/src/proto_genesis/lib_protocol/src/main.ml similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/src/main.ml rename to src/proto_genesis/lib_protocol/src/main.ml diff --git a/src/proto_genesis/lib_protocol_genesis/src/services.ml b/src/proto_genesis/lib_protocol/src/services.ml similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/src/services.ml rename to src/proto_genesis/lib_protocol/src/services.ml diff --git a/src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam b/src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/tezos-embedded-protocol-genesis.opam rename to src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam diff --git a/src/proto_genesis/lib_protocol_genesis/tezos-protocol-genesis.opam b/src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam similarity index 100% rename from src/proto_genesis/lib_protocol_genesis/tezos-protocol-genesis.opam rename to src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam From 70a4fbac3a18ebad62e4b90c1bd937d0aa78fbb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 29 Jan 2018 01:16:58 +0100 Subject: [PATCH 19/27] Refactor: rename package `tezos-embedded-client-*` -> `tezos-client-*` --- src/bin_client/jbuild | 4 ++-- src/bin_client/tezos-client.opam | 4 ++-- .../jbuild_embedded_protocol_template | 4 ++-- src/lib_protocol_compiler/jbuild_protocol_template | 6 +++--- src/proto_alpha/lib_client/jbuild | 4 ++-- ...embedded-client-alpha.opam => tezos-client-alpha.opam} | 0 src/proto_genesis/lib_client/client_proto_main.ml | 2 +- src/proto_genesis/lib_client/jbuild | 6 +++--- ...dded-client-genesis.opam => tezos-client-genesis.opam} | 4 ++-- test/proto_alpha/jbuild | 8 ++++---- test/proto_alpha/proto_alpha_helpers.ml | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) rename src/proto_alpha/lib_client/{tezos-embedded-client-alpha.opam => tezos-client-alpha.opam} (100%) rename src/proto_genesis/lib_client/{tezos-embedded-client-genesis.opam => tezos-client-genesis.opam} (95%) diff --git a/src/bin_client/jbuild b/src/bin_client/jbuild index f4222063d..789e5425a 100644 --- a/src/bin_client/jbuild +++ b/src/bin_client/jbuild @@ -6,8 +6,8 @@ (libraries (tezos-base tezos-rpc-http tezos-client-base - tezos-embedded-client-genesis - tezos-embedded-client-alpha)) + tezos-client-genesis + tezos-client-alpha)) (flags (:standard -w -9+27-30-32-40@8 -safe-string -open Tezos_base__TzPervasives diff --git a/src/bin_client/tezos-client.opam b/src/bin_client/tezos-client.opam index 21eff4929..6bdc013b9 100644 --- a/src/bin_client/tezos-client.opam +++ b/src/bin_client/tezos-client.opam @@ -10,9 +10,9 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-embedded-client-genesis" - "tezos-embedded-client-alpha" "tezos-client-base" + "tezos-client-genesis" + "tezos-client-alpha" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index fc9e1c44e..3e5ae8cbf 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -1,7 +1,7 @@ (* -*- tuareg -*- *) -let prefix = "lib_protocol_" -let dirname = Filename.basename @@ Filename.dirname @@ Sys.getcwd () +let prefix = "proto_" +let dirname = Filename.basename @@ Filename.dirname @@ Filename.dirname @@ Sys.getcwd () let predefined_version = None (* to be substituted in opam packages *) diff --git a/src/lib_protocol_compiler/jbuild_protocol_template b/src/lib_protocol_compiler/jbuild_protocol_template index b80125bbb..907154d92 100644 --- a/src/lib_protocol_compiler/jbuild_protocol_template +++ b/src/lib_protocol_compiler/jbuild_protocol_template @@ -11,8 +11,8 @@ #require "unix" -let prefix = "lib_protocol_" -let dirname = Filename.basename @@ Sys.getcwd () +let prefix = "proto_" +let dirname = Filename.basename @@ Filename.dirname @@ Sys.getcwd () let predefined_version = None (* to be substituted in opam packages *) @@ -28,7 +28,7 @@ let version = let path = match predefined_version with - | None -> "src/proto_" ^ version ^ "/lib_protocol_" ^ version + | None -> "src/proto_" ^ version ^ "/lib_protocol" | Some _ -> "." let sources = diff --git a/src/proto_alpha/lib_client/jbuild b/src/proto_alpha/lib_client/jbuild index 43d64d56a..1275f14f0 100644 --- a/src/proto_alpha/lib_client/jbuild +++ b/src/proto_alpha/lib_client/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_embedded_client_alpha) - (public_name tezos-embedded-client-alpha) + ((name tezos_client_alpha) + (public_name tezos-client-alpha) (libraries (tezos-base tezos-protocol-alpha tezos-client-environment diff --git a/src/proto_alpha/lib_client/tezos-embedded-client-alpha.opam b/src/proto_alpha/lib_client/tezos-client-alpha.opam similarity index 100% rename from src/proto_alpha/lib_client/tezos-embedded-client-alpha.opam rename to src/proto_alpha/lib_client/tezos-client-alpha.opam diff --git a/src/proto_genesis/lib_client/client_proto_main.ml b/src/proto_genesis/lib_client/client_proto_main.ml index 86ac03e4e..025692588 100644 --- a/src/proto_genesis/lib_client/client_proto_main.ml +++ b/src/proto_genesis/lib_client/client_proto_main.ml @@ -75,7 +75,7 @@ let commands () = @@ stop) begin fun timestamp hash fitness validation_passes seckey (cctxt : Client_commands.full_context) -> let fitness = - Tezos_embedded_client_alpha.Proto_alpha.Fitness_repr.from_int64 fitness in + Tezos_client_alpha.Proto_alpha.Fitness_repr.from_int64 fitness in bake cctxt ?timestamp cctxt#block (Activate { protocol = hash ; validation_passes ; fitness }) seckey >>=? fun hash -> diff --git a/src/proto_genesis/lib_client/jbuild b/src/proto_genesis/lib_client/jbuild index df0594e91..99235ca6a 100644 --- a/src/proto_genesis/lib_client/jbuild +++ b/src/proto_genesis/lib_client/jbuild @@ -1,13 +1,13 @@ (jbuild_version 1) (library - ((name tezos_embedded_client_genesis) - (public_name tezos-embedded-client-genesis) + ((name tezos_client_genesis) + (public_name tezos-client-genesis) (libraries (tezos-base tezos-shell-services tezos-client-base tezos-client-environment - tezos-embedded-client-alpha + tezos-client-alpha tezos-protocol-genesis)) (library_flags (:standard -linkall)) (flags (:standard -w -9+27-30-32-40@8 diff --git a/src/proto_genesis/lib_client/tezos-embedded-client-genesis.opam b/src/proto_genesis/lib_client/tezos-client-genesis.opam similarity index 95% rename from src/proto_genesis/lib_client/tezos-embedded-client-genesis.opam rename to src/proto_genesis/lib_client/tezos-client-genesis.opam index e95e0a103..0edf22148 100644 --- a/src/proto_genesis/lib_client/tezos-embedded-client-genesis.opam +++ b/src/proto_genesis/lib_client/tezos-client-genesis.opam @@ -10,11 +10,11 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-protocol-genesis" - "tezos-protocol-alpha" "tezos-shell-services" "tezos-client-base" "tezos-client-environment" + "tezos-client-alpha" + "tezos-protocol-genesis" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] diff --git a/test/proto_alpha/jbuild b/test/proto_alpha/jbuild index 82ca1134b..40fe0e48c 100644 --- a/test/proto_alpha/jbuild +++ b/test/proto_alpha/jbuild @@ -9,15 +9,15 @@ (libraries (tezos-base tezos-rpc-http tezos-client-base - tezos-embedded-client-genesis - tezos-embedded-client-alpha + tezos-client-genesis + tezos-client-alpha test_lib)) (flags (:standard -w -9-32 -safe-string -open Tezos_base__TzPervasives -open Tezos_rpc_http -open Tezos_client_base - -open Tezos_embedded_client_genesis - -open Tezos_embedded_client_alpha)))) + -open Tezos_client_genesis + -open Tezos_client_alpha)))) (alias ((name buildtest) diff --git a/test/proto_alpha/proto_alpha_helpers.ml b/test/proto_alpha/proto_alpha_helpers.ml index 94c918881..3af85c104 100644 --- a/test/proto_alpha/proto_alpha_helpers.ml +++ b/test/proto_alpha/proto_alpha_helpers.ml @@ -40,7 +40,7 @@ let dictator_sk = let activate_alpha () = let fitness = Fitness_repr.from_int64 0L in - Tezos_embedded_client_genesis.Client_proto_main.bake + Tezos_client_genesis.Client_proto_main.bake (new Client_rpcs.http_ctxt !rpc_config) (`Head 0) (Activate { protocol = Client_proto_main.protocol ; validation_passes = 1 ; fitness }) From db57afa4d154e97a9919d99a44f01655f895ab7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 29 Jan 2018 01:26:41 +0100 Subject: [PATCH 20/27] Refactor: update OPAM packages in CI --- .gitlab-ci.yml | 85 +++++++++++++++++++++++++------------------------- Makefile | 1 + 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 379422267..7bb362d30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,8 +46,6 @@ prepare:opam: build_deps: <<: *dind_definition stage: build_deps - except: - - master@tezos/tezos script: ## Building dependencies... - ./scripts/ci/create_docker_image.build_deps.sh @@ -304,57 +302,62 @@ opam:23:tezos-client-base: variables: package: tezos-client-base -opam:24:ocplib-resto-json: +opam:24:tezos-client-alpha: <<: *opam_definition variables: - package: ocplib-resto-json + package: tezos-client-alpha -opam:25:tezos-embedded-client-alpha: +opam:25:tezos-client-environment: <<: *opam_definition variables: - package: tezos-embedded-client-alpha + package: tezos-client-environment -opam:26:tezos-embedded-client-genesis: - <<: *opam_definition - variables: - package: tezos-embedded-client-genesis - -opam:27:ocplib-ezresto: - <<: *opam_definition - variables: - package: ocplib-ezresto - -opam:28:tezos-client: - <<: *opam_definition - variables: - package: tezos-client - -opam:29:tezos-node: - <<: *opam_definition - variables: - package: tezos-node - -opam:30:ocplib-ezresto-directory: - <<: *opam_definition - variables: - package: ocplib-ezresto-directory - -opam:31:tezos-test: - <<: *opam_definition - variables: - package: tezos-test - -opam:32:tezos-protocol-genesis: +opam:26:tezos-protocol-genesis: <<: *opam_definition variables: package: tezos-protocol-genesis -opam:33:tezos-protocol-demo: +opam:27:ocplib-resto-json: + <<: *opam_definition + variables: + package: ocplib-resto-json + +opam:28:tezos-client-genesis: + <<: *opam_definition + variables: + package: tezos-client-genesis + +opam:29:ocplib-ezresto: + <<: *opam_definition + variables: + package: ocplib-ezresto + +opam:30:tezos-client: + <<: *opam_definition + variables: + package: tezos-client + +opam:31:tezos-node: + <<: *opam_definition + variables: + package: tezos-node + +opam:32:ocplib-ezresto-directory: + <<: *opam_definition + variables: + package: ocplib-ezresto-directory + +opam:33:tezos-test: + <<: *opam_definition + variables: + package: tezos-test + +opam:34:tezos-protocol-demo: <<: *opam_definition variables: package: tezos-protocol-demo -opam:34:tezos-protocol-alpha: +opam:35:tezos-protocol-alpha: <<: *opam_definition variables: package: tezos-protocol-alpha @@ -375,10 +378,6 @@ publish:docker:minimal: - if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then ./scripts/apply_patch.sh "${CI_COMMIT_REF_NAME}" ; fi - - ./scripts/ci/create_docker_image.build_deps.sh - "${build_deps_image}" "${CI_COMMIT_SHA}" - "${opam_image}:alpine-${alpine_version}_ocaml-${ocaml_version}" - "yes" - ./scripts/ci/create_docker_image.build.sh "tezos_build" "${CI_COMMIT_REF_NAME}" "${build_deps_image}:${CI_COMMIT_SHA}" diff --git a/Makefile b/Makefile index e780ca95c..54ad48e3f 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ build-test: test: @jbuilder runtest ${DEV} + @./scripts/check_opam_test.sh test-indent: @jbuilder build @runtest_indent ${DEV} From 04465e3ac63723106a94d2e95d85e51d99568a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 11:08:56 +0100 Subject: [PATCH 21/27] Proto_sigs: split the deprecated module `Tezos_data` --- src/lib_base/protocol_environment.ml | 14 +- .../jbuild_embedded_protocol_template | 3 +- src/lib_protocol_compiler/packer.ml | 1 - src/lib_protocol_environment_sigs/jbuild | 6 +- .../sigs_packer/sigs_packer.ml | 1 - .../v1/block_header.mli | 33 +++++ .../v1/fitness.mli | 10 +- .../v1/operation.mli | 25 ++++ .../v1/protocol.mli | 31 +++++ src/lib_protocol_environment_sigs/v1/s.mli | 46 +++++++ .../v1/tezos_data.mli | 123 ------------------ src/lib_protocol_updater/updater.ml | 8 +- src/lib_protocol_updater/updater.mli | 8 +- .../lib_protocol/src/block_header_repr.ml | 8 +- .../lib_protocol/src/block_header_repr.mli | 4 +- .../lib_protocol/src/operation_repr.ml | 2 + .../lib_protocol/src/operation_repr.mli | 2 + .../lib_protocol/src/services_registration.ml | 2 +- .../lib_protocol/src/tezos_context.mli | 6 +- 19 files changed, 172 insertions(+), 161 deletions(-) create mode 100644 src/lib_protocol_environment_sigs/v1/block_header.mli create mode 100644 src/lib_protocol_environment_sigs/v1/operation.mli create mode 100644 src/lib_protocol_environment_sigs/v1/protocol.mli create mode 100644 src/lib_protocol_environment_sigs/v1/s.mli diff --git a/src/lib_base/protocol_environment.ml b/src/lib_base/protocol_environment.ml index 15a6f6a58..dfcfffaf1 100644 --- a/src/lib_base/protocol_environment.ml +++ b/src/lib_base/protocol_environment.ml @@ -56,21 +56,17 @@ module Make(Param : sig val name: string end)() = struct module Make_Blake2B = Blake2B.Make end module Blake2B = Blake2B - module Tezos_data = struct - module type DATA = S.T - module type HASHABLE_DATA = S.HASHABLE - module Fitness = Fitness - module Operation = Operation - module Block_header = Block_header - module Protocol = Protocol - end + module S = S + module Fitness = Fitness + module Operation = Operation + module Block_header = Block_header + module Protocol = Protocol module RPC_arg = RPC_arg module RPC_path = RPC_path module RPC_query = RPC_query module RPC_service = RPC_service module RPC_answer = RPC_answer module RPC_directory = RPC_directory - module Fitness = Fitness module Error_monad = struct type error_category = [ `Branch | `Temporary | `Permanent ] include Error_monad.Make() diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index 3e5ae8cbf..bfd5a87c4 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -48,8 +48,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| -warn-error -a+8 -open Tezos_embedded_protocol_environment_%s__Environment -open Error_monad - -open Hash - -open Tezos_data)) + -open Hash)) (modules (:standard \ Environment Registerer)))) (library diff --git a/src/lib_protocol_compiler/packer.ml b/src/lib_protocol_compiler/packer.ml index 858b4498b..cfa56ec72 100644 --- a/src/lib_protocol_compiler/packer.ml +++ b/src/lib_protocol_compiler/packer.ml @@ -45,7 +45,6 @@ let opened_modules = [ "Error_monad" ; "Hash" ; "Logging" ; - "Tezos_data" ; ] let dump oc files = diff --git a/src/lib_protocol_environment_sigs/jbuild b/src/lib_protocol_environment_sigs/jbuild index 710815932..599dd9de3 100644 --- a/src/lib_protocol_environment_sigs/jbuild +++ b/src/lib_protocol_environment_sigs/jbuild @@ -45,8 +45,12 @@ v1/ed25519.mli ;; Tezos specifics + v1/s.mli v1/micheline.mli - v1/tezos_data.mli + v1/block_header.mli + v1/fitness.mli + v1/operation.mli + v1/protocol.mli v1/context.mli v1/updater.mli diff --git a/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml b/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml index eb1d9750e..3e9ca9069 100644 --- a/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml +++ b/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml @@ -25,7 +25,6 @@ let opened_modules = [ "Pervasives" ; "Error_monad" ; "Hash" ; - "Tezos_data" ; ] let include_mli oc file = diff --git a/src/lib_protocol_environment_sigs/v1/block_header.mli b/src/lib_protocol_environment_sigs/v1/block_header.mli new file mode 100644 index 000000000..395345b8a --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/block_header.mli @@ -0,0 +1,33 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type shell_header = { + level: Int32.t ; + (** The number of preceding block in this chain, i.e. the genesis + has level 0. *) + proto_level: int ; + (** The number of preceding protocol change in the chain (modulo 256), + i.e the genesis has proto_level 0. *) + predecessor: Block_hash.t ; + timestamp: Time.t ; + validation_passes: int ; + operations_hash: Operation_list_list_hash.t ; + fitness: MBytes.t list ; + context: Context_hash.t ; +} + +val shell_header_encoding: shell_header Data_encoding.t + +type t = { + shell: shell_header ; + proto: MBytes.t ; +} + +include S.HASHABLE with type t := t + and type hash := Block_hash.t diff --git a/src/lib_protocol_environment_sigs/v1/fitness.mli b/src/lib_protocol_environment_sigs/v1/fitness.mli index 6734fbd4e..042fb64d2 100644 --- a/src/lib_protocol_environment_sigs/v1/fitness.mli +++ b/src/lib_protocol_environment_sigs/v1/fitness.mli @@ -7,10 +7,6 @@ (* *) (**************************************************************************) -type fitness = MBytes.t list - -val compare: fitness -> fitness -> int -val pp: Format.formatter -> fitness -> unit -val to_string: fitness -> string - -val encoding: fitness Data_encoding.t +(** The fitness of a block is defined as a list of bytes, + compared in a lexicographical order (longer list are greater). *) +include S.T with type t = MBytes.t list diff --git a/src/lib_protocol_environment_sigs/v1/operation.mli b/src/lib_protocol_environment_sigs/v1/operation.mli new file mode 100644 index 000000000..3c45c6b3c --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/operation.mli @@ -0,0 +1,25 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Tezos operations. *) + +type shell_header = { + branch: Block_hash.t ; + (** The operation is only valid in a branch containing the + block [branch]. *) +} +val shell_header_encoding: shell_header Data_encoding.t + +type t = { + shell: shell_header ; + proto: MBytes.t ; +} + +include S.HASHABLE with type t := t + and type hash := Operation_hash.t diff --git a/src/lib_protocol_environment_sigs/v1/protocol.mli b/src/lib_protocol_environment_sigs/v1/protocol.mli new file mode 100644 index 000000000..6b266b248 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/protocol.mli @@ -0,0 +1,31 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +type t = { + expected_env: env_version ; + components: component list ; +} + +(** An OCaml source component of a protocol implementation. *) +and component = { + (* The OCaml module name. *) + name : string ; + (* The OCaml interface source code *) + interface : string option ; + (* The OCaml source code *) + implementation : string ; +} + +and env_version = V1 + +val component_encoding: component Data_encoding.t +val env_version_encoding: env_version Data_encoding.t + +include S.HASHABLE with type t := t + and type hash := Protocol_hash.t diff --git a/src/lib_protocol_environment_sigs/v1/s.mli b/src/lib_protocol_environment_sigs/v1/s.mli new file mode 100644 index 000000000..f05fc3a88 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/s.mli @@ -0,0 +1,46 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Generic interface for a datatype with comparison, pretty-printer + and serialization functions. *) +module type T = sig + + type t + + val compare: t -> t -> int + val equal: t -> t -> bool + + val (=): t -> t -> bool + val (<>): t -> t -> bool + val (<): t -> t -> bool + val (<=): t -> t -> bool + val (>=): t -> t -> bool + val (>): t -> t -> bool + val min: t -> t -> t + val max: t -> t -> t + + val pp: Format.formatter -> t -> unit + + val encoding: t Data_encoding.t + val to_bytes: t -> MBytes.t + val of_bytes: MBytes.t -> t option + +end + +(** Generic interface for a datatype with comparison, pretty-printer, + serialization functions and a hashing function. *) +module type HASHABLE = sig + + include T + + type hash + val hash: t -> hash + val hash_raw: MBytes.t -> hash + +end diff --git a/src/lib_protocol_environment_sigs/v1/tezos_data.mli b/src/lib_protocol_environment_sigs/v1/tezos_data.mli index f632f3d90..6ec18bc60 100644 --- a/src/lib_protocol_environment_sigs/v1/tezos_data.mli +++ b/src/lib_protocol_environment_sigs/v1/tezos_data.mli @@ -1,128 +1,5 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -(** Tezos Protocol Environment - Basic data structures *) - -(** Generic interface for a datatype with comparison, pretty-printer - and serialization functions. *) -module type DATA = sig - - type t - - val compare: t -> t -> int - val equal: t -> t -> bool - - val (=): t -> t -> bool - val (<>): t -> t -> bool - val (<): t -> t -> bool - val (<=): t -> t -> bool - val (>=): t -> t -> bool - val (>): t -> t -> bool - val min: t -> t -> t - val max: t -> t -> t - - val pp: Format.formatter -> t -> unit - - val encoding: t Data_encoding.t - val to_bytes: t -> MBytes.t - val of_bytes: MBytes.t -> t option - -end - -(** Generic interface for a datatype with comparison, pretty-printer, - serialization functions and a hashing function. *) -module type HASHABLE_DATA = sig - - include DATA - - type hash - val hash: t -> hash - val hash_raw: MBytes.t -> hash - -end - -(** The fitness of a block is defined as a list of bytes, - compared in a lexicographical order (longer list are greater). *) -module Fitness : DATA with type t = MBytes.t list - -(** Tezos operations. *) -module Operation : sig - - type shell_header = { - branch: Block_hash.t ; - (** The operation is only valid in a branch containing the - block [branch]. *) - } - val shell_header_encoding: shell_header Data_encoding.t - - type t = { - shell: shell_header ; - proto: MBytes.t ; - } - - include HASHABLE_DATA with type t := t - and type hash := Operation_hash.t - -end - -module Block_header : sig - - type shell_header = { - level: Int32.t ; - (** The number of preceding block in this chain, i.e. the genesis - has level 0. *) - proto_level: int ; - (** The number of preceding protocol change in the chain (modulo 256), - i.e the genesis has proto_level 0. *) - predecessor: Block_hash.t ; - timestamp: Time.t ; - validation_passes: int ; - operations_hash: Operation_list_list_hash.t ; - fitness: MBytes.t list ; - context: Context_hash.t ; - } - - val shell_header_encoding: shell_header Data_encoding.t - - type t = { - shell: shell_header ; - proto: MBytes.t ; - } - - include HASHABLE_DATA with type t := t - and type hash := Block_hash.t - -end module Protocol : sig - type t = { - expected_env: env_version ; - components: component list ; - } - - (** An OCaml source component of a protocol implementation. *) - and component = { - (* The OCaml module name. *) - name : string ; - (* The OCaml interface source code *) - interface : string option ; - (* The OCaml source code *) - implementation : string ; - } - - and env_version = V1 - - val component_encoding: component Data_encoding.t - val env_version_encoding: env_version Data_encoding.t - - include HASHABLE_DATA with type t := t - and type hash := Protocol_hash.t end diff --git a/src/lib_protocol_updater/updater.ml b/src/lib_protocol_updater/updater.ml index f70cc0e46..21adf6a5a 100644 --- a/src/lib_protocol_updater/updater.ml +++ b/src/lib_protocol_updater/updater.ml @@ -105,10 +105,10 @@ module Node_protocol_environment_sigs = struct and type Context.t = Context.t and type Time.t = Time.t and type MBytes.t = MBytes.t - and type Tezos_data.Operation.shell_header = Operation.shell_header - and type Tezos_data.Operation.t = Operation.t - and type Tezos_data.Block_header.shell_header = Block_header.shell_header - and type Tezos_data.Block_header.t = Block_header.t + and type Operation.shell_header = Operation.shell_header + and type Operation.t = Operation.t + and type Block_header.shell_header = Block_header.shell_header + and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a RPC_directory.t and type Updater.validation_result = validation_result and type Updater.rpc_context = rpc_context diff --git a/src/lib_protocol_updater/updater.mli b/src/lib_protocol_updater/updater.mli index 3a9398f4f..30491da58 100644 --- a/src/lib_protocol_updater/updater.mli +++ b/src/lib_protocol_updater/updater.mli @@ -95,10 +95,10 @@ module Node_protocol_environment_sigs : sig and type Context.t = Context.t and type Time.t = Time.t and type MBytes.t = MBytes.t - and type Tezos_data.Operation.shell_header = Operation.shell_header - and type Tezos_data.Operation.t = Operation.t - and type Tezos_data.Block_header.shell_header = Block_header.shell_header - and type Tezos_data.Block_header.t = Block_header.t + and type Operation.shell_header = Operation.shell_header + and type Operation.t = Operation.t + and type Block_header.shell_header = Block_header.shell_header + and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a RPC_directory.t and type Updater.validation_result = validation_result and type Updater.rpc_context = rpc_context diff --git a/src/proto_alpha/lib_protocol/src/block_header_repr.ml b/src/proto_alpha/lib_protocol/src/block_header_repr.ml index 439cbe2a6..f9be91667 100644 --- a/src/proto_alpha/lib_protocol/src/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/src/block_header_repr.ml @@ -26,11 +26,11 @@ and proto_header = { type block_header = t -type raw = Tezos_data.Block_header.t -type shell_header = Tezos_data.Block_header.shell_header +type raw = Block_header.t +type shell_header = Block_header.shell_header -let raw_encoding = Tezos_data.Block_header.encoding -let shell_header_encoding = Tezos_data.Block_header.shell_header_encoding +let raw_encoding = Block_header.encoding +let shell_header_encoding = Block_header.shell_header_encoding let proto_header_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/src/block_header_repr.mli b/src/proto_alpha/lib_protocol/src/block_header_repr.mli index 964ed7fb5..eab364253 100644 --- a/src/proto_alpha/lib_protocol/src/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/src/block_header_repr.mli @@ -24,8 +24,8 @@ and proto_header = { type block_header = t -type raw = Tezos_data.Block_header.t -type shell_header = Tezos_data.Block_header.shell_header +type raw = Block_header.t +type shell_header = Block_header.shell_header val encoding: block_header Data_encoding.encoding val raw_encoding: raw Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/src/operation_repr.ml b/src/proto_alpha/lib_protocol/src/operation_repr.ml index e875241da..a374fea33 100644 --- a/src/proto_alpha/lib_protocol/src/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/src/operation_repr.ml @@ -413,3 +413,5 @@ let parse_proto bytes = | None -> fail Cannot_parse_operation include Encoding + +let hash_raw = Operation.hash diff --git a/src/proto_alpha/lib_protocol/src/operation_repr.mli b/src/proto_alpha/lib_protocol/src/operation_repr.mli index 690720c5d..98cdc56a3 100644 --- a/src/proto_alpha/lib_protocol/src/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/src/operation_repr.mli @@ -92,6 +92,8 @@ type error += Cannot_parse_operation (* `Branch *) val encoding: operation Data_encoding.t +val hash_raw: raw -> Operation_hash.t + val parse: Operation_hash.t -> Operation.t -> operation tzresult diff --git a/src/proto_alpha/lib_protocol/src/services_registration.ml b/src/proto_alpha/lib_protocol/src/services_registration.ml index 2cb325e4d..5b80b938e 100644 --- a/src/proto_alpha/lib_protocol/src/services_registration.ml +++ b/src/proto_alpha/lib_protocol/src/services_registration.ml @@ -533,7 +533,7 @@ let parse_operations ctxt () (operations, check) = map_s begin fun raw -> begin Lwt.return - (Operation.parse (Tezos_data.Operation.hash raw) raw) >>=? fun op -> + (Operation.parse (Operation.hash_raw raw) raw) >>=? fun op -> begin match check with | Some true -> check_signature ctxt op.signature op.shell op.contents | Some false | None -> return () diff --git a/src/proto_alpha/lib_protocol/src/tezos_context.mli b/src/proto_alpha/lib_protocol/src/tezos_context.mli index 16b6cbd32..407e37d5b 100644 --- a/src/proto_alpha/lib_protocol/src/tezos_context.mli +++ b/src/proto_alpha/lib_protocol/src/tezos_context.mli @@ -605,6 +605,8 @@ module Operation : sig type t = operation val encoding: operation Data_encoding.t + val hash_raw: raw -> Operation_hash.t + type error += Cannot_parse_operation (* `Branch *) val parse: Operation_hash.t -> Operation.t -> operation tzresult @@ -641,8 +643,8 @@ module Block_header : sig type block_header = t - type raw = Tezos_data.Block_header.t - type shell_header = Tezos_data.Block_header.shell_header + type raw = Block_header.t + type shell_header = Block_header.shell_header val hash: block_header -> Block_hash.t val hash_raw: raw -> Block_hash.t From f2de3ffa3e45441ae2a84469c5595ccb7d017fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 11:25:14 +0100 Subject: [PATCH 22/27] Proto_sigs: split the deprecated module `Hash` --- src/lib_base/protocol_environment.ml | 20 +-- src/lib_crypto/blake2B.ml | 17 ++- src/lib_crypto/blake2B.mli | 23 ++- src/lib_crypto/s.ml | 17 --- .../jbuild_embedded_protocol_template | 3 +- src/lib_protocol_compiler/packer.ml | 1 - src/lib_protocol_environment_sigs/jbuild | 9 +- .../sigs_packer/sigs_packer.ml | 1 - .../v1/blake2B.mli | 19 ++- .../v1/block_hash.mli | 11 ++ .../v1/context_hash.mli | 11 ++ .../v1/ed25519.mli | 2 +- src/lib_protocol_environment_sigs/v1/hash.mli | 137 ------------------ .../v1/operation_hash.mli | 11 ++ .../v1/operation_list_hash.mli | 12 ++ .../v1/operation_list_list_hash.mli | 11 ++ .../v1/protocol_hash.mli | 11 ++ src/lib_protocol_environment_sigs/v1/s.mli | 87 +++++++++++ src/lib_protocol_updater/updater.ml | 11 +- src/lib_protocol_updater/updater.mli | 11 +- 20 files changed, 234 insertions(+), 191 deletions(-) create mode 100644 src/lib_protocol_environment_sigs/v1/block_hash.mli create mode 100644 src/lib_protocol_environment_sigs/v1/context_hash.mli delete mode 100644 src/lib_protocol_environment_sigs/v1/hash.mli create mode 100644 src/lib_protocol_environment_sigs/v1/operation_hash.mli create mode 100644 src/lib_protocol_environment_sigs/v1/operation_list_hash.mli create mode 100644 src/lib_protocol_environment_sigs/v1/operation_list_list_hash.mli create mode 100644 src/lib_protocol_environment_sigs/v1/protocol_hash.mli diff --git a/src/lib_base/protocol_environment.ml b/src/lib_base/protocol_environment.ml index dfcfffaf1..1e8cdf459 100644 --- a/src/lib_base/protocol_environment.ml +++ b/src/lib_base/protocol_environment.ml @@ -42,21 +42,17 @@ module Make(Param : sig val name: string end)() = struct module Data_encoding = Data_encoding module Time = Time module Ed25519 = Ed25519 - module Hash = struct - include Tezos_crypto + module S = struct include Tezos_crypto.S - module Net_id = Net_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Make_minimal_Blake2B = Blake2B.Make_minimal - module Make_Blake2B = Blake2B.Make + include S end + module Block_hash = Block_hash + module Operation_hash = Operation_hash + module Operation_list_hash = Operation_list_hash + module Operation_list_list_hash = Operation_list_list_hash + module Context_hash = Context_hash + module Protocol_hash = Protocol_hash module Blake2B = Blake2B - module S = S module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_crypto/blake2B.ml b/src/lib_crypto/blake2B.ml index 0cbf665d3..45317aedc 100644 --- a/src/lib_crypto/blake2B.ml +++ b/src/lib_crypto/blake2B.ml @@ -20,7 +20,18 @@ let () = (*-- Type specific Hash builder ---------------------------------------------*) -module Make_minimal (K : S.Name) = struct +module type Name = sig + val name : string + val title : string + val size : int option +end + +module type PrefixedName = sig + include Name + val b58check_prefix : string +end + +module Make_minimal (K : Name) = struct type t = Sodium.Generichash.hash @@ -133,7 +144,7 @@ module Make (R : sig of_raw: (string -> 'a option) -> wrap: ('a -> Base58.data) -> 'a Base58.encoding - end) (K : S.PrefixedName) = struct + end) (K : PrefixedName) = struct include Make_minimal(K) @@ -353,7 +364,7 @@ module Make_merkle_tree wrap: ('a -> Base58.data) -> 'a Base58.encoding end) - (K : S.PrefixedName) + (K : PrefixedName) (Contents: sig type t val to_bytes: t -> MBytes.t diff --git a/src/lib_crypto/blake2B.mli b/src/lib_crypto/blake2B.mli index 0ab75be05..c356731e7 100644 --- a/src/lib_crypto/blake2B.mli +++ b/src/lib_crypto/blake2B.mli @@ -13,8 +13,25 @@ include S.INTERNAL_MINIMAL_HASH +(** {2 Building Hashes} *******************************************************) + +(** The parameters for creating a new Hash type using + {!Make_Blake2B}. Both {!name} and {!title} are only informative, + used in error messages and serializers. *) + +module type Name = sig + val name : string + val title : string + val size : int option +end + +module type PrefixedName = sig + include Name + val b58check_prefix : string +end + (** Builds a new Hash type using Blake2B. *) -module Make_minimal (Name : S.Name) : S.INTERNAL_MINIMAL_HASH +module Make_minimal (Name : Name) : S.INTERNAL_MINIMAL_HASH module Make (Register : sig val register_encoding: @@ -25,7 +42,7 @@ module Make wrap: ('a -> Base58.data) -> 'a Base58.encoding end) - (Name : S.PrefixedName) : S.INTERNAL_HASH + (Name : PrefixedName) : S.INTERNAL_HASH (**/**) @@ -39,7 +56,7 @@ module Make_merkle_tree wrap: ('a -> Base58.data) -> 'a Base58.encoding end) - (K : S.PrefixedName) + (K : PrefixedName) (Contents: sig type t val to_bytes: t -> MBytes.t diff --git a/src/lib_crypto/s.ml b/src/lib_crypto/s.ml index 4375077fa..87f60a804 100644 --- a/src/lib_crypto/s.ml +++ b/src/lib_crypto/s.ml @@ -126,20 +126,3 @@ module type MERKLE_TREE = sig val check_path: path -> elt -> t * int val path_encoding: path Data_encoding.t end - -(** {2 Building Hashes} *******************************************************) - -(** The parameters for creating a new Hash type using - {!Make_Blake2B}. Both {!name} and {!title} are only informative, - used in error messages and serializers. *) - -module type Name = sig - val name : string - val title : string - val size : int option -end - -module type PrefixedName = sig - include Name - val b58check_prefix : string -end diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index bfd5a87c4..07e90de31 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -47,8 +47,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| -w +a-4-6-7-9-29-32-40..42-44-45-48 -warn-error -a+8 -open Tezos_embedded_protocol_environment_%s__Environment - -open Error_monad - -open Hash)) + -open Error_monad)) (modules (:standard \ Environment Registerer)))) (library diff --git a/src/lib_protocol_compiler/packer.ml b/src/lib_protocol_compiler/packer.ml index cfa56ec72..0526e2e4b 100644 --- a/src/lib_protocol_compiler/packer.ml +++ b/src/lib_protocol_compiler/packer.ml @@ -43,7 +43,6 @@ let opened_modules = [ "Tezos_protocol_environment" ; "Pervasives" ; "Error_monad" ; - "Hash" ; "Logging" ; ] diff --git a/src/lib_protocol_environment_sigs/jbuild b/src/lib_protocol_environment_sigs/jbuild index 599dd9de3..4367a5a92 100644 --- a/src/lib_protocol_environment_sigs/jbuild +++ b/src/lib_protocol_environment_sigs/jbuild @@ -40,12 +40,17 @@ v1/RPC_directory.mli v1/base58.mli - v1/hash.mli + v1/s.mli v1/blake2B.mli v1/ed25519.mli + v1/block_hash.mli + v1/operation_hash.mli + v1/operation_list_hash.mli + v1/operation_list_list_hash.mli + v1/protocol_hash.mli + v1/context_hash.mli ;; Tezos specifics - v1/s.mli v1/micheline.mli v1/block_header.mli v1/fitness.mli diff --git a/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml b/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml index 3e9ca9069..6bf57ecf6 100644 --- a/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml +++ b/src/lib_protocol_environment_sigs/sigs_packer/sigs_packer.ml @@ -24,7 +24,6 @@ let dump_file oc file = let opened_modules = [ "Pervasives" ; "Error_monad" ; - "Hash" ; ] let include_mli oc file = diff --git a/src/lib_protocol_environment_sigs/v1/blake2B.mli b/src/lib_protocol_environment_sigs/v1/blake2B.mli index b199b0083..e8663b085 100644 --- a/src/lib_protocol_environment_sigs/v1/blake2B.mli +++ b/src/lib_protocol_environment_sigs/v1/blake2B.mli @@ -9,7 +9,22 @@ (** Builds a new Hash type using Blake2B. *) -module Make_minimal (Name : Hash.Name) : Hash.MINIMAL_HASH +(** The parameters for creating a new Hash type using + {!Make_Blake2B}. Both {!name} and {!title} are only informative, + used in error messages and serializers. *) + +module type Name = sig + val name : string + val title : string + val size : int option +end + +module type PrefixedName = sig + include Name + val b58check_prefix : string +end + +module Make_minimal (Name : Name) : S.MINIMAL_HASH module Make (Register : sig val register_encoding: @@ -20,5 +35,5 @@ module Make wrap: ('a -> Base58.data) -> 'a Base58.encoding end) - (Name : Hash.PrefixedName) : HASH + (Name : PrefixedName) : S.HASH diff --git a/src/lib_protocol_environment_sigs/v1/block_hash.mli b/src/lib_protocol_environment_sigs/v1/block_hash.mli new file mode 100644 index 000000000..944be4d37 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/block_hash.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Blocks hashes / IDs. *) +include S.HASH diff --git a/src/lib_protocol_environment_sigs/v1/context_hash.mli b/src/lib_protocol_environment_sigs/v1/context_hash.mli new file mode 100644 index 000000000..361c70320 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/context_hash.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Commited context hashes / IDs. *) +include S.HASH diff --git a/src/lib_protocol_environment_sigs/v1/ed25519.mli b/src/lib_protocol_environment_sigs/v1/ed25519.mli index b15cbe1b0..340533077 100644 --- a/src/lib_protocol_environment_sigs/v1/ed25519.mli +++ b/src/lib_protocol_environment_sigs/v1/ed25519.mli @@ -11,7 +11,7 @@ (** {2 Hashed public keys for user ID} ***************************************) -module Public_key_hash : Hash.HASH +module Public_key_hash : S.HASH (** {2 Signature} ************************************************************) diff --git a/src/lib_protocol_environment_sigs/v1/hash.mli b/src/lib_protocol_environment_sigs/v1/hash.mli deleted file mode 100644 index eec3f662a..000000000 --- a/src/lib_protocol_environment_sigs/v1/hash.mli +++ /dev/null @@ -1,137 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2017. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -(** Tezos - Manipulation and creation of hashes *) - -(** {2 Hash Types} ************************************************************) - -(** The signature of an abstract hash type, as produced by functor - {!Make_SHA256}. The {!t} type is abstracted for separating the - various kinds of hashes in the system at typing time. Each type is - equipped with functions to use it as is of as keys in the database - or in memory sets and maps. *) - -module type MINIMAL_HASH = sig - - type t - - val name: string - val title: string - - val hash_bytes: MBytes.t list -> t - val hash_string: string list -> t - val size: int (* in bytes *) - val compare: t -> t -> int - val equal: t -> t -> bool - - val to_hex: t -> string - val of_hex: string -> t option - val of_hex_exn: string -> t - - val to_string: t -> string - val of_string: string -> t option - val of_string_exn: string -> t - - val to_bytes: t -> MBytes.t - val of_bytes: MBytes.t -> t option - val of_bytes_exn: MBytes.t -> t - - val read: MBytes.t -> int -> t - val write: MBytes.t -> int -> t -> unit - - val to_path: t -> string list -> string list - val of_path: string list -> t option - val of_path_exn: string list -> t - - val prefix_path: string -> string list - val path_length: int - -end - -module type HASH = sig - - include MINIMAL_HASH - - val of_b58check_exn: string -> t - val of_b58check_opt: string -> t option - val to_b58check: t -> string - val to_short_b58check: t -> string - val encoding: t Data_encoding.t - val pp: Format.formatter -> t -> unit - val pp_short: Format.formatter -> t -> unit - type Base58.data += Hash of t - val b58check_encoding: t Base58.encoding - - val rpc_arg: t RPC_arg.t - - module Set : sig - include Set.S with type elt = t - val encoding: t Data_encoding.t - end - - module Map : sig - include Map.S with type key = t - val encoding: 'a Data_encoding.t -> 'a t Data_encoding.t - end - -end - -module type MERKLE_TREE = sig - type elt - include HASH - val compute: elt list -> t - val empty: t - type path = - | Left of path * t - | Right of t * path - | Op - val compute_path: elt list -> int -> path - val check_path: path -> elt -> t * int - val path_encoding: path Data_encoding.t -end - -(** {2 Building Hashes} *******************************************************) - -(** The parameters for creating a new Hash type using - {!Make_Blake2B}. Both {!name} and {!title} are only informative, - used in error messages and serializers. *) - -module type Name = sig - val name : string - val title : string - val size : int option -end - -module type PrefixedName = sig - include Name - val b58check_prefix : string -end - -(** {2 Predefined Hashes } ****************************************************) - -(** Blocks hashes / IDs. *) -module Block_hash : HASH - -(** Operations hashes / IDs. *) -module Operation_hash : HASH - -(** List of operations hashes / IDs. *) -module Operation_list_hash : - MERKLE_TREE with type elt = Operation_hash.t - -module Operation_list_list_hash : - MERKLE_TREE with type elt = Operation_list_hash.t - -(** Protocol versions / source hashes. *) -module Protocol_hash : HASH - -(** Commited conntext. *) -module Context_hash : HASH - -module Net_id : HASH diff --git a/src/lib_protocol_environment_sigs/v1/operation_hash.mli b/src/lib_protocol_environment_sigs/v1/operation_hash.mli new file mode 100644 index 000000000..27ec05c9c --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/operation_hash.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Operations hashes / IDs. *) +include S.HASH diff --git a/src/lib_protocol_environment_sigs/v1/operation_list_hash.mli b/src/lib_protocol_environment_sigs/v1/operation_list_hash.mli new file mode 100644 index 000000000..2e276432d --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/operation_list_hash.mli @@ -0,0 +1,12 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Blocks hashes / IDs. *) +include S.MERKLE_TREE with type elt = Operation_hash.t + diff --git a/src/lib_protocol_environment_sigs/v1/operation_list_list_hash.mli b/src/lib_protocol_environment_sigs/v1/operation_list_list_hash.mli new file mode 100644 index 000000000..66e74b5a2 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/operation_list_list_hash.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Blocks hashes / IDs. *) +include S.MERKLE_TREE with type elt = Operation_list_hash.t diff --git a/src/lib_protocol_environment_sigs/v1/protocol_hash.mli b/src/lib_protocol_environment_sigs/v1/protocol_hash.mli new file mode 100644 index 000000000..b2dd10af1 --- /dev/null +++ b/src/lib_protocol_environment_sigs/v1/protocol_hash.mli @@ -0,0 +1,11 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2017. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Protocol hashes / IDs. *) +include S.HASH diff --git a/src/lib_protocol_environment_sigs/v1/s.mli b/src/lib_protocol_environment_sigs/v1/s.mli index f05fc3a88..340535ac8 100644 --- a/src/lib_protocol_environment_sigs/v1/s.mli +++ b/src/lib_protocol_environment_sigs/v1/s.mli @@ -44,3 +44,90 @@ module type HASHABLE = sig val hash_raw: MBytes.t -> hash end + +(** {2 Hash Types} ************************************************************) + +(** The signature of an abstract hash type, as produced by functor + {!Make_SHA256}. The {!t} type is abstracted for separating the + various kinds of hashes in the system at typing time. Each type is + equipped with functions to use it as is of as keys in the database + or in memory sets and maps. *) + +module type MINIMAL_HASH = sig + + type t + + val name: string + val title: string + + val hash_bytes: MBytes.t list -> t + val hash_string: string list -> t + val size: int (* in bytes *) + val compare: t -> t -> int + val equal: t -> t -> bool + + val to_hex: t -> string + val of_hex: string -> t option + val of_hex_exn: string -> t + + val to_string: t -> string + val of_string: string -> t option + val of_string_exn: string -> t + + val to_bytes: t -> MBytes.t + val of_bytes: MBytes.t -> t option + val of_bytes_exn: MBytes.t -> t + + val read: MBytes.t -> int -> t + val write: MBytes.t -> int -> t -> unit + + val to_path: t -> string list -> string list + val of_path: string list -> t option + val of_path_exn: string list -> t + + val prefix_path: string -> string list + val path_length: int + +end + +module type HASH = sig + + include MINIMAL_HASH + + val of_b58check_exn: string -> t + val of_b58check_opt: string -> t option + val to_b58check: t -> string + val to_short_b58check: t -> string + val encoding: t Data_encoding.t + val pp: Format.formatter -> t -> unit + val pp_short: Format.formatter -> t -> unit + type Base58.data += Hash of t + val b58check_encoding: t Base58.encoding + + val rpc_arg: t RPC_arg.t + + module Set : sig + include Set.S with type elt = t + val encoding: t Data_encoding.t + end + + module Map : sig + include Map.S with type key = t + val encoding: 'a Data_encoding.t -> 'a t Data_encoding.t + end + +end + +module type MERKLE_TREE = sig + type elt + include HASH + val compute: elt list -> t + val empty: t + type path = + | Left of path * t + | Right of t * path + | Op + val compute_path: elt list -> int -> path + val check_path: path -> elt -> t * int + val path_encoding: path Data_encoding.t +end diff --git a/src/lib_protocol_updater/updater.ml b/src/lib_protocol_updater/updater.ml index 21adf6a5a..c1b8a1f40 100644 --- a/src/lib_protocol_updater/updater.ml +++ b/src/lib_protocol_updater/updater.ml @@ -97,11 +97,12 @@ module Node_protocol_environment_sigs = struct and type 'a Data_encoding.t = 'a Data_encoding.t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Hash.Net_id.t = Net_id.t - and type Hash.Block_hash.t = Block_hash.t - and type Hash.Operation_hash.t = Operation_hash.t - and type Hash.Operation_list_list_hash.t = Operation_list_list_hash.t - and type Hash.Context_hash.t = Context_hash.t + and type Block_hash.t = Block_hash.t + and type Operation_hash.t = Operation_hash.t + and type Operation_list_hash.t = Operation_list_hash.t + and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Context_hash.t = Context_hash.t + and type Protocol_hash.t = Protocol_hash.t and type Context.t = Context.t and type Time.t = Time.t and type MBytes.t = MBytes.t diff --git a/src/lib_protocol_updater/updater.mli b/src/lib_protocol_updater/updater.mli index 30491da58..770b6a3df 100644 --- a/src/lib_protocol_updater/updater.mli +++ b/src/lib_protocol_updater/updater.mli @@ -87,11 +87,12 @@ module Node_protocol_environment_sigs : sig and type 'a Data_encoding.t = 'a Data_encoding.t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Hash.Net_id.t = Net_id.t - and type Hash.Block_hash.t = Block_hash.t - and type Hash.Operation_hash.t = Operation_hash.t - and type Hash.Operation_list_list_hash.t = Operation_list_list_hash.t - and type Hash.Context_hash.t = Context_hash.t + and type Block_hash.t = Block_hash.t + and type Operation_hash.t = Operation_hash.t + and type Operation_list_hash.t = Operation_list_hash.t + and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Context_hash.t = Context_hash.t + and type Protocol_hash.t = Protocol_hash.t and type Context.t = Context.t and type Time.t = Time.t and type MBytes.t = MBytes.t From ca29c92442a48cb70f4c91046b0e9cceda5ded20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 11:45:38 +0100 Subject: [PATCH 23/27] Refactor: move `tezos-micheline` below `tezos-base` --- src/lib_base/jbuild | 2 ++ src/lib_base/protocol_environment.ml | 1 + src/lib_base/tezos-base.opam | 2 ++ src/lib_base/tzPervasives.ml | 1 + src/lib_client_environment/environment.ml | 1 - src/lib_micheline/jbuild | 6 ++++-- src/lib_micheline/micheline_parser.ml | 1 + src/lib_micheline/tezos-micheline.opam | 3 ++- src/lib_protocol_updater/tezos_protocol_environment.ml | 1 - 9 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib_base/jbuild b/src/lib_base/jbuild index 49a4a0340..2a166a9a0 100644 --- a/src/lib_base/jbuild +++ b/src/lib_base/jbuild @@ -9,6 +9,7 @@ -open Tezos_data_encoding -open Tezos_error_monad -open Tezos_rpc + -open Tezos_micheline -safe-string)) (libraries (tezos-stdlib tezos-stdlib-lwt @@ -16,6 +17,7 @@ tezos-data-encoding tezos-error-monad tezos-rpc + tezos-micheline calendar ezjsonm mtime.clock.os)))) diff --git a/src/lib_base/protocol_environment.ml b/src/lib_base/protocol_environment.ml index 1e8cdf459..dd5789507 100644 --- a/src/lib_base/protocol_environment.ml +++ b/src/lib_base/protocol_environment.ml @@ -67,6 +67,7 @@ module Make(Param : sig val name: string end)() = struct type error_category = [ `Branch | `Temporary | `Permanent ] include Error_monad.Make() end + module Micheline = Micheline module Logging = Logging.Make(Param) type error += Ecoproto_error of Error_monad.error list diff --git a/src/lib_base/tezos-base.opam b/src/lib_base/tezos-base.opam index 36283ce7a..f1869338c 100644 --- a/src/lib_base/tezos-base.opam +++ b/src/lib_base/tezos-base.opam @@ -14,6 +14,8 @@ depends: [ "tezos-crypto" "tezos-data-encoding" "tezos-error-monad" + "tezos-micheline" + "tezos-rpc" "ezjsonm" { >= "0.5.0" } "calendar" "mtime" { >= "1.0.0" } diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index dd5469a2d..a5ca5655f 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -13,6 +13,7 @@ include Tezos_data_encoding include Tezos_error_monad include Tezos_rpc include Tezos_crypto +include Tezos_micheline module List = struct include List diff --git a/src/lib_client_environment/environment.ml b/src/lib_client_environment/environment.ml index 3279ef8bf..2c49555f7 100644 --- a/src/lib_client_environment/environment.ml +++ b/src/lib_client_environment/environment.ml @@ -11,7 +11,6 @@ module Make(Param : sig val name: string end)() = struct include Tezos_base.Protocol_environment.Make(Param)() - module Micheline = Micheline module Updater = struct include Fake_updater.Make(Fake_context) module type PROTOCOL = diff --git a/src/lib_micheline/jbuild b/src/lib_micheline/jbuild index 3b00b3da7..a5fafae89 100644 --- a/src/lib_micheline/jbuild +++ b/src/lib_micheline/jbuild @@ -8,11 +8,13 @@ ;; External uutf ;; Internal - tezos-base + tezos-error-monad + tezos-data-encoding )) (flags (:standard -w -9+27-30-32-40@8 -safe-string - -open Tezos_base__TzPervasives)))) + -open Tezos_error_monad + -open Tezos_data_encoding)))) (alias ((name runtest_indent) diff --git a/src/lib_micheline/micheline_parser.ml b/src/lib_micheline/micheline_parser.ml index dfaa29b85..7fe58cacf 100644 --- a/src/lib_micheline/micheline_parser.ml +++ b/src/lib_micheline/micheline_parser.ml @@ -7,6 +7,7 @@ (* *) (**************************************************************************) +open Error_monad open Micheline type 'a parsing_result = 'a * error list diff --git a/src/lib_micheline/tezos-micheline.opam b/src/lib_micheline/tezos-micheline.opam index a0a1c65de..fabcc2047 100644 --- a/src/lib_micheline/tezos-micheline.opam +++ b/src/lib_micheline/tezos-micheline.opam @@ -9,7 +9,8 @@ license: "unreleased" depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } - "tezos-base" + "tezos-data-encoding" + "tezos-error-monad" "uutf" ] build: [ diff --git a/src/lib_protocol_updater/tezos_protocol_environment.ml b/src/lib_protocol_updater/tezos_protocol_environment.ml index 68066766a..58de9b40f 100644 --- a/src/lib_protocol_updater/tezos_protocol_environment.ml +++ b/src/lib_protocol_updater/tezos_protocol_environment.ml @@ -11,7 +11,6 @@ module Make(Param : sig val name: string end)() = struct include Tezos_base.Protocol_environment.Make(Param)() - module Micheline = Micheline module Updater = struct include Updater module type PROTOCOL = From 657e214e8384cede0d20f182176aafe19d8d8828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 11:53:49 +0100 Subject: [PATCH 24/27] Refactor: rename `tezos-client-environment` into `tezos-protocol-environment-client` --- .gitlab-ci.yml | 4 ++-- .../fake.ml} | 0 .../fake_context.ml | 0 .../fake_updater.ml | 0 .../jbuild | 4 ++-- .../tezos-protocol-environment-client.opam} | 0 src/proto_alpha/lib_client/jbuild | 2 +- src/proto_alpha/lib_client/proto_alpha.ml | 2 +- src/proto_alpha/lib_client/tezos-client-alpha.opam | 3 ++- src/proto_genesis/lib_client/jbuild | 2 +- src/proto_genesis/lib_client/proto_genesis.ml | 2 +- src/proto_genesis/lib_client/tezos-client-genesis.opam | 2 +- 12 files changed, 11 insertions(+), 10 deletions(-) rename src/{lib_client_environment/environment.ml => lib_protocol_environment_client/fake.ml} (100%) rename src/{lib_client_environment => lib_protocol_environment_client}/fake_context.ml (100%) rename src/{lib_client_environment => lib_protocol_environment_client}/fake_updater.ml (100%) rename src/{lib_client_environment => lib_protocol_environment_client}/jbuild (82%) rename src/{lib_client_environment/tezos-client-environment.opam => lib_protocol_environment_client/tezos-protocol-environment-client.opam} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7bb362d30..02ec37916 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -307,10 +307,10 @@ opam:24:tezos-client-alpha: variables: package: tezos-client-alpha -opam:25:tezos-client-environment: +opam:25:tezos-protocol-environment-client: <<: *opam_definition variables: - package: tezos-client-environment + package: tezos-protocol-environment-client opam:26:tezos-protocol-genesis: <<: *opam_definition diff --git a/src/lib_client_environment/environment.ml b/src/lib_protocol_environment_client/fake.ml similarity index 100% rename from src/lib_client_environment/environment.ml rename to src/lib_protocol_environment_client/fake.ml diff --git a/src/lib_client_environment/fake_context.ml b/src/lib_protocol_environment_client/fake_context.ml similarity index 100% rename from src/lib_client_environment/fake_context.ml rename to src/lib_protocol_environment_client/fake_context.ml diff --git a/src/lib_client_environment/fake_updater.ml b/src/lib_protocol_environment_client/fake_updater.ml similarity index 100% rename from src/lib_client_environment/fake_updater.ml rename to src/lib_protocol_environment_client/fake_updater.ml diff --git a/src/lib_client_environment/jbuild b/src/lib_protocol_environment_client/jbuild similarity index 82% rename from src/lib_client_environment/jbuild rename to src/lib_protocol_environment_client/jbuild index 846c512b7..aaf7a0d62 100644 --- a/src/lib_client_environment/jbuild +++ b/src/lib_protocol_environment_client/jbuild @@ -1,8 +1,8 @@ (jbuild_version 1) (library - ((name tezos_client_environment) - (public_name tezos-client-environment) + ((name tezos_protocol_environment_client) + (public_name tezos-protocol-environment-client) (libraries (tezos-base tezos-protocol-environment-sigs tezos-micheline)) diff --git a/src/lib_client_environment/tezos-client-environment.opam b/src/lib_protocol_environment_client/tezos-protocol-environment-client.opam similarity index 100% rename from src/lib_client_environment/tezos-client-environment.opam rename to src/lib_protocol_environment_client/tezos-protocol-environment-client.opam diff --git a/src/proto_alpha/lib_client/jbuild b/src/proto_alpha/lib_client/jbuild index 1275f14f0..5fe7d777e 100644 --- a/src/proto_alpha/lib_client/jbuild +++ b/src/proto_alpha/lib_client/jbuild @@ -5,7 +5,7 @@ (public_name tezos-client-alpha) (libraries (tezos-base tezos-protocol-alpha - tezos-client-environment + tezos-protocol-environment-client tezos-shell-services tezos-client-base)) (library_flags (:standard -linkall)) diff --git a/src/proto_alpha/lib_client/proto_alpha.ml b/src/proto_alpha/lib_client/proto_alpha.ml index 3c424168f..834d427a8 100644 --- a/src/proto_alpha/lib_client/proto_alpha.ml +++ b/src/proto_alpha/lib_client/proto_alpha.ml @@ -8,5 +8,5 @@ (**************************************************************************) module Name = struct let name = "alpha" end -module Environment = Tezos_client_environment.Environment.Make(Name)() +module Environment = Tezos_protocol_environment_client.Fake.Make(Name)() include Tezos_protocol_alpha.Functor.Make(Environment) diff --git a/src/proto_alpha/lib_client/tezos-client-alpha.opam b/src/proto_alpha/lib_client/tezos-client-alpha.opam index 3a7af083a..7bbe4715a 100644 --- a/src/proto_alpha/lib_client/tezos-client-alpha.opam +++ b/src/proto_alpha/lib_client/tezos-client-alpha.opam @@ -10,7 +10,8 @@ depends: [ "ocamlfind" { build } "jbuilder" { build & >= "1.0+beta15" } "tezos-base" - "tezos-embedded-protocol-alpha" + "tezos-protocol-environment-client" + "tezos-protocol-alpha" "tezos-shell-services" "tezos-client-base" ] diff --git a/src/proto_genesis/lib_client/jbuild b/src/proto_genesis/lib_client/jbuild index 99235ca6a..cda296533 100644 --- a/src/proto_genesis/lib_client/jbuild +++ b/src/proto_genesis/lib_client/jbuild @@ -6,7 +6,7 @@ (libraries (tezos-base tezos-shell-services tezos-client-base - tezos-client-environment + tezos-protocol-environment-client tezos-client-alpha tezos-protocol-genesis)) (library_flags (:standard -linkall)) diff --git a/src/proto_genesis/lib_client/proto_genesis.ml b/src/proto_genesis/lib_client/proto_genesis.ml index 38e52e123..74a5b6950 100644 --- a/src/proto_genesis/lib_client/proto_genesis.ml +++ b/src/proto_genesis/lib_client/proto_genesis.ml @@ -8,5 +8,5 @@ (**************************************************************************) module Name = struct let name = "genesis" end -module Environment = Tezos_client_environment.Environment.Make(Name)() +module Environment = Tezos_protocol_environment_client.Fake.Make(Name)() include Tezos_protocol_genesis.Functor.Make(Environment) diff --git a/src/proto_genesis/lib_client/tezos-client-genesis.opam b/src/proto_genesis/lib_client/tezos-client-genesis.opam index 0edf22148..cceaeedf0 100644 --- a/src/proto_genesis/lib_client/tezos-client-genesis.opam +++ b/src/proto_genesis/lib_client/tezos-client-genesis.opam @@ -12,7 +12,7 @@ depends: [ "tezos-base" "tezos-shell-services" "tezos-client-base" - "tezos-client-environment" + "tezos-protocol-environment-client" "tezos-client-alpha" "tezos-protocol-genesis" ] From 4b142184fa99bb8fc32b230f3743122f13c2269a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 12:23:38 +0100 Subject: [PATCH 25/27] opam: fix `tezos-client-base` dependencies --- src/lib_client_base/tezos-client-base.opam | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/lib_client_base/tezos-client-base.opam b/src/lib_client_base/tezos-client-base.opam index ead7bf3d2..7417b7d12 100644 --- a/src/lib_client_base/tezos-client-base.opam +++ b/src/lib_client_base/tezos-client-base.opam @@ -13,11 +13,6 @@ depends: [ "tezos-shell-services" "tezos-storage" "tezos-rpc-http" - "tezos-protocol-compiler" - "tezos-protocol-updater" - "tezos-embedded-protocol-genesis" - "tezos-embedded-protocol-demo" - "tezos-embedded-protocol-alpha" "cmdliner" ] build: [ From 8dcc5cefb56029210950e4f5ede69fdac0179013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 30 Jan 2018 12:36:32 +0100 Subject: [PATCH 26/27] jbuild: fix installation of `tezos-protocol-alpha` --- src/lib_protocol_compiler/jbuild_protocol_template | 7 ++++++- .../tezos-protocol-environment-client.opam | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib_protocol_compiler/jbuild_protocol_template b/src/lib_protocol_compiler/jbuild_protocol_template index 907154d92..be5dbff3e 100644 --- a/src/lib_protocol_compiler/jbuild_protocol_template +++ b/src/lib_protocol_compiler/jbuild_protocol_template @@ -76,6 +76,11 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| (modes (native)) (modules (Tezos_protocol_%s_dummy)))) +(install + ((section lib) + (files ("tezos_protocol_%s.cmx" "tezos_protocol_%s.cmi")) + (package tezos-protocol-%s))) + (alias ((name runtest_sandbox) (deps (tezos_protocol_%s.cmx)))) @@ -88,6 +93,6 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| |} version version version version version version version version path - version version version + version version version version version version Format.(pp_print_list (fun ppf -> Format.fprintf ppf "%S")) sources diff --git a/src/lib_protocol_environment_client/tezos-protocol-environment-client.opam b/src/lib_protocol_environment_client/tezos-protocol-environment-client.opam index 6d795dd44..732317837 100644 --- a/src/lib_protocol_environment_client/tezos-protocol-environment-client.opam +++ b/src/lib_protocol_environment_client/tezos-protocol-environment-client.opam @@ -11,6 +11,7 @@ depends: [ "jbuilder" { build & >= "1.0+beta15" } "tezos-base" "tezos-micheline" + "tezos-protocol-environment-sigs" ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ] From 1ec1f501a4ab9e41fa3defed6113fdbcf188c0b4 Mon Sep 17 00:00:00 2001 From: Milo Davis Date: Tue, 30 Jan 2018 17:31:44 -0500 Subject: [PATCH 27/27] Alphanet: fixes assert_endorser in alphanet script --- scripts/alphanet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh index 44fa65420..71264ae08 100755 --- a/scripts/alphanet.sh +++ b/scripts/alphanet.sh @@ -300,7 +300,7 @@ check_endorser() { } assert_endorser() { - if ! check_baker; then + if ! check_endorser; then echo -e "\033[31mEndorser is not running!\033[0m" exit 0 fi