From 5106dd6661db6b1bdfd99ef252d799466b784ff1 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Fri, 20 May 2022 10:44:05 +0200 Subject: [PATCH 01/12] feat(dekuIntegration): add sign_payload and key --- lib/node/client.ml | 14 ++++++++------ lib/node/client.mli | 10 +++++----- lib/node/dune | 2 +- lib/node/failure_detector.ml | 1 + lib/node/message.ml | 5 +++-- lib/node/message.mli | 5 +++-- lib/node/node.ml | 4 ++-- lib/node/node.mli | 2 ++ lib/node/server.ml | 4 ++-- test/commons.ml | 2 +- test/failure_detector_prop.ml | 2 +- test/failure_detector_tests.ml | 4 ++-- test/node_tests.ml | 14 +++++++------- 13 files changed, 38 insertions(+), 31 deletions(-) diff --git a/lib/node/client.ml b/lib/node/client.ml index cecfa89..cce19ab 100644 --- a/lib/node/client.ml +++ b/lib/node/client.ml @@ -17,7 +17,7 @@ let peer_from { address; peers; _ } = let add_peer node (peer : Peer.t) = Base.Hashtbl.add node.peers ~key:peer.address ~data:peer -let create_request node recipient payload = +let create_request node recipient sign_payload key payload = Mutex.with_lock !node.current_request_id (fun id -> id := !id + 1; Lwt.return @@ -29,9 +29,10 @@ let create_request node recipient payload = sender = !node.address; recipient; payload; + payload_signature = sign_payload payload key ; }) -let create_response node request payload = +let create_response node request sign_payload key payload = Message. { category = Message.Response; @@ -40,6 +41,7 @@ let create_response node request payload = sender = !node.address; recipient = request.sender; payload; + payload_signature = sign_payload payload key ; } let send_to node message = @@ -75,12 +77,12 @@ let recv_next node = Mutex.unlock !node.socket; Lwt.return message -let request node request recipient = - let%lwt message = create_request node recipient request in +let request node request sign_payload (key : bytes option) recipient = + let%lwt message = create_request node recipient sign_payload key request in let%lwt () = send_to node message in let condition_var = Lwt_condition.create () in Hashtbl.add !node.request_table message.id condition_var; Lwt_condition.wait condition_var -let broadcast_request node req recipients = - List.map (request node req) recipients +let broadcast_request node req recipients sign_payload (key : bytes option) = + List.map (request node req sign_payload key) recipients diff --git a/lib/node/client.mli b/lib/node/client.mli index 1068e2d..65783b5 100644 --- a/lib/node/client.mli +++ b/lib/node/client.mli @@ -16,12 +16,12 @@ val add_peer : node -> Peer.t -> [`Duplicate | `Ok] (** [create_request node recipient payload] creates a [Message.t] of the {i Request category} addressed to {i recipient} containing {i payload}. *) -val create_request : node ref -> Address.t -> bytes -> Message.t Lwt.t +val create_request : node ref -> Address.t -> (bytes -> bytes option -> bytes option) -> bytes option -> bytes-> Message.t Lwt.t (** [create_response node request payload] creates a [Message.t] of the {i Response category} that responds to {i request} whose content is {i payload}. *) -val create_response : node ref -> Message.t -> bytes -> Message.t - +val create_response : node ref -> Message.t -> (bytes -> bytes option -> bytes option) -> bytes option -> bytes -> Message.t + (** Sends a message via datagram from the given [Types.node] to a specified peer within the [Message.t]. Construct a message with one of the [create_*] functions to then feed to this function. *) @@ -34,9 +34,9 @@ val recv_next : node ref -> Message.t Lwt.t returns a promise holding the response from the peer. This function blocks the current thread of execution until a response arrives. *) -val request : node ref -> bytes -> Address.t -> Message.t Lwt.t +val request : node ref -> bytes -> (bytes -> bytes option -> bytes option) -> bytes option -> Address.t -> Message.t Lwt.t (** Broadcasts a request containing the given payload to a list of recipients and collects the responses in a list of [Message.t Lwt.t]. *) val broadcast_request : - node ref -> bytes -> Address.t list -> Message.t Lwt.t list + node ref -> bytes -> Address.t list -> (bytes -> bytes option -> bytes option) -> bytes option -> Message.t Lwt.t list diff --git a/lib/node/dune b/lib/node/dune index b91407a..8da2ca6 100644 --- a/lib/node/dune +++ b/lib/node/dune @@ -3,4 +3,4 @@ (public_name pollinate.node) (libraries bin_prot lwt lwt.unix pollinate.common) (preprocess - (pps ppx_bin_prot lwt_ppx))) + (pps ppx_bin_prot lwt_ppx ppx_deriving.eq ppx_deriving.ord))) diff --git a/lib/node/failure_detector.ml b/lib/node/failure_detector.ml index 0db1061..6d4e5d3 100644 --- a/lib/node/failure_detector.ml +++ b/lib/node/failure_detector.ml @@ -91,6 +91,7 @@ let create_message node message (recipient : Peer.t) = sender = Client.address_of !node; recipient = recipient.address; payload = Encoding.pack bin_writer_message message; + payload_signature = None; } let send_message message node (recipient : Peer.t) = diff --git a/lib/node/message.ml b/lib/node/message.ml index 961d686..502abb1 100644 --- a/lib/node/message.ml +++ b/lib/node/message.ml @@ -7,7 +7,7 @@ type category = | Response | Failure_detection | Custom of string -[@@deriving bin_io] +[@@deriving bin_io, eq, ord] type t = { category : category; @@ -16,5 +16,6 @@ type t = { sender : Address.t; recipient : Address.t; payload : bytes; + payload_signature : bytes option; } -[@@deriving bin_io] +[@@deriving bin_io, eq, ord] diff --git a/lib/node/message.mli b/lib/node/message.mli index 4068b67..a03c5ae 100644 --- a/lib/node/message.mli +++ b/lib/node/message.mli @@ -16,7 +16,7 @@ type category = | Response | Failure_detection | Custom of string -[@@deriving bin_io] +[@@deriving bin_io, eq, ord] (** Messages received from [peers] which are stored in the node's inbox. *) @@ -27,5 +27,6 @@ type t = { sender : Address.t; recipient : Address.t; payload : bytes; + payload_signature : bytes option; } -[@@deriving bin_io] +[@@deriving bin_io, eq, ord] diff --git a/lib/node/node.ml b/lib/node/node.ml index ad939c0..495b309 100644 --- a/lib/node/node.ml +++ b/lib/node/node.ml @@ -6,7 +6,7 @@ module Client = Client module Failure_detector = Failure_detector module Inbox = Inbox -let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) +let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) ~sign_payload ~key (address, port) = let open Util in let%lwt socket = Net.create_socket port in @@ -34,5 +34,5 @@ let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) }; peers; } in - Server.run node preprocess msg_handler; + Server.run node preprocess msg_handler sign_payload key; Lwt.return node diff --git a/lib/node/node.mli b/lib/node/node.mli index 3f425b7..0a35290 100644 --- a/lib/node/node.mli +++ b/lib/node/node.mli @@ -16,5 +16,7 @@ val init : ?preprocess:(Message.t -> Message.t) -> msg_handler:(Message.t -> bytes) -> ?init_peers:Address.t list -> + sign_payload:(bytes -> bytes option -> bytes option) -> + key: bytes option -> string * int -> Types.node ref Lwt.t diff --git a/lib/node/server.ml b/lib/node/server.ml index e5dcaec..ab8dc5a 100644 --- a/lib/node/server.ml +++ b/lib/node/server.ml @@ -21,7 +21,7 @@ let handle_response request_table res = 4. Grab the next request if it exists and send it to the message handler along with the node's state 5. Send the encoded response from the message handler to the requester *) -let run node router msg_handler = +let run node router msg_handler (sign_payload : bytes -> bytes option -> bytes option) (key : bytes option) = let rec server () = let%lwt message = Client.recv_next node in let%lwt () = route node router message in @@ -42,7 +42,7 @@ let run node router msg_handler = match request with | Some request -> let response = - request |> msg_handler |> Client.create_response node request in + request |> msg_handler |> Client.create_response node request sign_payload key in let%lwt () = Client.send_to node response in Lwt.return () | None -> Lwt.return () in diff --git a/test/commons.ml b/test/commons.ml index 887ebb3..87a4e52 100644 --- a/test/commons.ml +++ b/test/commons.ml @@ -19,7 +19,7 @@ module Commons = struct let msg_handler request = let open Messages in - let open Message in + let open Pollinate.Node.Message in let request = Encoding.unpack bin_read_request request.payload in let response = match request with diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index fe0177b..0b1d283 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -6,7 +6,7 @@ module SUT = Pollinate.Node.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3002)) let knuth_shuffle_size = diff --git a/test/failure_detector_tests.ml b/test/failure_detector_tests.ml index bc82743..fa315c7 100644 --- a/test/failure_detector_tests.ml +++ b/test/failure_detector_tests.ml @@ -6,11 +6,11 @@ module SUT = Pollinate.Node.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3003)) let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3004)) let peer_b = Client.peer_from !node_b diff --git a/test/node_tests.ml b/test/node_tests.ml index c7e4574..bd284f0 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -8,14 +8,14 @@ module Node_tests = struct (* Initializes two nodes and the related two peers *) let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3000)) let peer_a = Client.peer_from !node_a let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3001)) let peer_b = Client.peer_from !node_b @@ -27,11 +27,11 @@ module Node_tests = struct let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = res_from_b; _ } = - Client.request node_a get peer_b.address in + Client.request node_a get (fun _p _k -> None) None peer_b.address in let res_from_b = Encoding.unpack bin_read_response res_from_b in let%lwt { payload = res_from_a; _ } = - Client.request node_b get peer_a.address in + Client.request node_b get (fun _p _k -> None) None peer_a.address in let res_from_a = Encoding.unpack bin_read_response res_from_a in let res_from_b, res_from_a = @@ -47,12 +47,12 @@ module Node_tests = struct Encoding.pack bin_writer_message (Request (Insert "something")) in let%lwt { payload = res_a; _ } = - Client.request node_a insert_req peer_b.address in + Client.request node_a insert_req (fun _p _k -> None) None peer_b.address in let res_a = Encoding.unpack bin_read_response res_a in let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = b_state; _ } = - Client.request node_a get peer_b.address in + Client.request node_a get (fun _p _k -> None) None peer_b.address in let b_state = Encoding.unpack bin_read_response b_state in let res_a, b_state = @@ -66,7 +66,7 @@ module Node_tests = struct let open Messages in let ping = Encoding.pack bin_writer_message (Request Ping) in - let%lwt { payload = pong; _ } = Client.request node_a ping peer_b.address in + let%lwt { payload = pong; _ } = Client.request node_a ping (fun _p _k -> None) None peer_b.address in let pong = Encoding.unpack bin_read_response pong in let pong = From bbe64b20cfdd805275bc40b0731591da4c5d59e4 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Fri, 20 May 2022 10:53:27 +0200 Subject: [PATCH 02/12] feat(dekuIntegration): format --- lib/node/client.ml | 4 ++-- lib/node/client.mli | 33 ++++++++++++++++++++++++++++----- lib/node/node.ml | 4 ++-- lib/node/node.mli | 2 +- lib/node/server.ml | 8 ++++++-- test/failure_detector_prop.ml | 5 +++-- test/failure_detector_tests.ml | 10 ++++++---- test/node_tests.ml | 8 +++++--- 8 files changed, 53 insertions(+), 21 deletions(-) diff --git a/lib/node/client.ml b/lib/node/client.ml index cce19ab..9d5ccb0 100644 --- a/lib/node/client.ml +++ b/lib/node/client.ml @@ -29,7 +29,7 @@ let create_request node recipient sign_payload key payload = sender = !node.address; recipient; payload; - payload_signature = sign_payload payload key ; + payload_signature = sign_payload payload key; }) let create_response node request sign_payload key payload = @@ -41,7 +41,7 @@ let create_response node request sign_payload key payload = sender = !node.address; recipient = request.sender; payload; - payload_signature = sign_payload payload key ; + payload_signature = sign_payload payload key; } let send_to node message = diff --git a/lib/node/client.mli b/lib/node/client.mli index 65783b5..2e019f2 100644 --- a/lib/node/client.mli +++ b/lib/node/client.mli @@ -16,12 +16,24 @@ val add_peer : node -> Peer.t -> [`Duplicate | `Ok] (** [create_request node recipient payload] creates a [Message.t] of the {i Request category} addressed to {i recipient} containing {i payload}. *) -val create_request : node ref -> Address.t -> (bytes -> bytes option -> bytes option) -> bytes option -> bytes-> Message.t Lwt.t +val create_request : + node ref -> + Address.t -> + (bytes -> bytes option -> bytes option) -> + bytes option -> + bytes -> + Message.t Lwt.t (** [create_response node request payload] creates a [Message.t] of the {i Response category} that responds to {i request} whose content is {i payload}. *) -val create_response : node ref -> Message.t -> (bytes -> bytes option -> bytes option) -> bytes option -> bytes -> Message.t - +val create_response : + node ref -> + Message.t -> + (bytes -> bytes option -> bytes option) -> + bytes option -> + bytes -> + Message.t + (** Sends a message via datagram from the given [Types.node] to a specified peer within the [Message.t]. Construct a message with one of the [create_*] functions to then feed to this function. *) @@ -34,9 +46,20 @@ val recv_next : node ref -> Message.t Lwt.t returns a promise holding the response from the peer. This function blocks the current thread of execution until a response arrives. *) -val request : node ref -> bytes -> (bytes -> bytes option -> bytes option) -> bytes option -> Address.t -> Message.t Lwt.t +val request : + node ref -> + bytes -> + (bytes -> bytes option -> bytes option) -> + bytes option -> + Address.t -> + Message.t Lwt.t (** Broadcasts a request containing the given payload to a list of recipients and collects the responses in a list of [Message.t Lwt.t]. *) val broadcast_request : - node ref -> bytes -> Address.t list -> (bytes -> bytes option -> bytes option) -> bytes option -> Message.t Lwt.t list + node ref -> + bytes -> + Address.t list -> + (bytes -> bytes option -> bytes option) -> + bytes option -> + Message.t Lwt.t list diff --git a/lib/node/node.ml b/lib/node/node.ml index 495b309..44b0ee2 100644 --- a/lib/node/node.ml +++ b/lib/node/node.ml @@ -6,8 +6,8 @@ module Client = Client module Failure_detector = Failure_detector module Inbox = Inbox -let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) ~sign_payload ~key - (address, port) = +let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) + ~sign_payload ~key (address, port) = let open Util in let%lwt socket = Net.create_socket port in let peers = diff --git a/lib/node/node.mli b/lib/node/node.mli index 0a35290..bd867b7 100644 --- a/lib/node/node.mli +++ b/lib/node/node.mli @@ -17,6 +17,6 @@ val init : msg_handler:(Message.t -> bytes) -> ?init_peers:Address.t list -> sign_payload:(bytes -> bytes option -> bytes option) -> - key: bytes option -> + key:bytes option -> string * int -> Types.node ref Lwt.t diff --git a/lib/node/server.ml b/lib/node/server.ml index ab8dc5a..37d0fae 100644 --- a/lib/node/server.ml +++ b/lib/node/server.ml @@ -21,7 +21,9 @@ let handle_response request_table res = 4. Grab the next request if it exists and send it to the message handler along with the node's state 5. Send the encoded response from the message handler to the requester *) -let run node router msg_handler (sign_payload : bytes -> bytes option -> bytes option) (key : bytes option) = +let run node router msg_handler + (sign_payload : bytes -> bytes option -> bytes option) (key : bytes option) + = let rec server () = let%lwt message = Client.recv_next node in let%lwt () = route node router message in @@ -42,7 +44,9 @@ let run node router msg_handler (sign_payload : bytes -> bytes option -> bytes o match request with | Some request -> let response = - request |> msg_handler |> Client.create_response node request sign_payload key in + request + |> msg_handler + |> Client.create_response node request sign_payload key in let%lwt () = Client.send_to node response in Lwt.return () | None -> Lwt.return () in diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index 0b1d283..548d33c 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -6,8 +6,9 @@ module SUT = Pollinate.Node.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None - ("127.0.0.1", 3002)) + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + ~sign_payload:(fun _p _k -> None) + ~key:None ("127.0.0.1", 3002)) let knuth_shuffle_size = QCheck2.Test.make ~count:1000 diff --git a/test/failure_detector_tests.ml b/test/failure_detector_tests.ml index fa315c7..583aadd 100644 --- a/test/failure_detector_tests.ml +++ b/test/failure_detector_tests.ml @@ -6,12 +6,14 @@ module SUT = Pollinate.Node.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None - ("127.0.0.1", 3003)) + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + ~sign_payload:(fun _p _k -> None) + ~key:None ("127.0.0.1", 3003)) let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None - ("127.0.0.1", 3004)) + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + ~sign_payload:(fun _p _k -> None) + ~key:None ("127.0.0.1", 3004)) let peer_b = Client.peer_from !node_b diff --git a/test/node_tests.ml b/test/node_tests.ml index bd284f0..df3ad17 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -8,14 +8,16 @@ module Node_tests = struct (* Initializes two nodes and the related two peers *) let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None - ("127.0.0.1", 3000)) + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + ~sign_payload:(fun _p _k -> None) + ~key:None ("127.0.0.1", 3000)) let peer_a = Client.peer_from !node_a let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None + (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3001)) let peer_b = Client.peer_from !node_b From 7cf72452008aca1ba9916c7cc7c9091897cdf83c Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Fri, 20 May 2022 14:09:10 +0200 Subject: [PATCH 03/12] feat(dekuIntegration): format, again --- test/failure_detector_prop.ml | 1 - test/node_tests.ml | 21 ++++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index 548d33c..ed07c03 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -1,7 +1,6 @@ open QCheck2.Gen open Pollinate.Peer open Commons - module SUT = Pollinate.Node.Failure_detector let node_a = diff --git a/test/node_tests.ml b/test/node_tests.ml index df3ad17..0714322 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -17,8 +17,8 @@ module Node_tests = struct let node_b = Lwt_main.run (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) ~key:None - ("127.0.0.1", 3001)) + ~sign_payload:(fun _p _k -> None) + ~key:None ("127.0.0.1", 3001)) let peer_b = Client.peer_from !node_b @@ -27,57 +27,48 @@ module Node_tests = struct let trade_messages () = let open Messages in let get = Encoding.pack bin_writer_message (Request Get) in - let%lwt { payload = res_from_b; _ } = Client.request node_a get (fun _p _k -> None) None peer_b.address in let res_from_b = Encoding.unpack bin_read_response res_from_b in - let%lwt { payload = res_from_a; _ } = Client.request node_b get (fun _p _k -> None) None peer_a.address in let res_from_a = Encoding.unpack bin_read_response res_from_a in - let res_from_b, res_from_a = match (res_from_b, res_from_a) with | Success ok1, Success ok2 -> (ok1, ok2) | _ -> failwith "Incorrect response" in - Lwt.return (res_from_b, res_from_a) let test_insert () = let open Messages in let insert_req = Encoding.pack bin_writer_message (Request (Insert "something")) in - let%lwt { payload = res_a; _ } = - Client.request node_a insert_req (fun _p _k -> None) None peer_b.address in + Client.request node_a insert_req (fun _p _k -> None) None peer_b.address + in let res_a = Encoding.unpack bin_read_response res_a in - let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = b_state; _ } = Client.request node_a get (fun _p _k -> None) None peer_b.address in let b_state = Encoding.unpack bin_read_response b_state in - let res_a, b_state = match (res_a, b_state) with | Success ok1, Success ok2 -> (ok1, ok2) | _ -> failwith "Incorrect response" in - Lwt.return (res_a, b_state) let ping_pong () = let open Messages in let ping = Encoding.pack bin_writer_message (Request Ping) in - - let%lwt { payload = pong; _ } = Client.request node_a ping (fun _p _k -> None) None peer_b.address in + let%lwt { payload = pong; _ } = + Client.request node_a ping (fun _p _k -> None) None peer_b.address in let pong = Encoding.unpack bin_read_response pong in - let pong = match pong with | Pong -> show_response Pong | _ -> failwith (Printf.sprintf "Incorrect response: %s" (show_response pong)) in - Lwt.return pong end From fcbe887c36321f17f269274ec0ad532c48b7dbad Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Mon, 23 May 2022 10:05:58 +0200 Subject: [PATCH 04/12] feat(dekuIntegration): some beautiful --- lib/node/client.ml | 12 ++++++------ lib/node/client.mli | 18 +++++++++--------- lib/node/server.ml | 2 +- test/node_tests.ml | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/node/client.ml b/lib/node/client.ml index 9d5ccb0..f150246 100644 --- a/lib/node/client.ml +++ b/lib/node/client.ml @@ -17,7 +17,7 @@ let peer_from { address; peers; _ } = let add_peer node (peer : Peer.t) = Base.Hashtbl.add node.peers ~key:peer.address ~data:peer -let create_request node recipient sign_payload key payload = +let create_request node recipient ~sign_payload:sign_payload ~key:key payload = Mutex.with_lock !node.current_request_id (fun id -> id := !id + 1; Lwt.return @@ -32,7 +32,7 @@ let create_request node recipient sign_payload key payload = payload_signature = sign_payload payload key; }) -let create_response node request sign_payload key payload = +let create_response node request ~sign_payload:sign_payload ~key:key payload = Message. { category = Message.Response; @@ -77,12 +77,12 @@ let recv_next node = Mutex.unlock !node.socket; Lwt.return message -let request node request sign_payload (key : bytes option) recipient = - let%lwt message = create_request node recipient sign_payload key request in +let request node ~sign_payload:sign_payload ~key:(key : bytes option) request recipient = + let%lwt message = create_request node recipient ~sign_payload:sign_payload ~key:key request in let%lwt () = send_to node message in let condition_var = Lwt_condition.create () in Hashtbl.add !node.request_table message.id condition_var; Lwt_condition.wait condition_var -let broadcast_request node req recipients sign_payload (key : bytes option) = - List.map (request node req sign_payload key) recipients +let broadcast_request node recipients ~sign_payload:sign_payload ~key:(key : bytes option) req = + List.map (request node ~sign_payload:sign_payload ~key:key req) recipients diff --git a/lib/node/client.mli b/lib/node/client.mli index 2e019f2..f1d2026 100644 --- a/lib/node/client.mli +++ b/lib/node/client.mli @@ -19,8 +19,8 @@ addressed to {i recipient} containing {i payload}. *) val create_request : node ref -> Address.t -> - (bytes -> bytes option -> bytes option) -> - bytes option -> + sign_payload:(bytes -> bytes option -> bytes option) -> + key:bytes option -> bytes -> Message.t Lwt.t @@ -29,8 +29,8 @@ that responds to {i request} whose content is {i payload}. *) val create_response : node ref -> Message.t -> - (bytes -> bytes option -> bytes option) -> - bytes option -> + sign_payload:(bytes -> bytes option -> bytes option) -> + key:bytes option -> bytes -> Message.t @@ -48,9 +48,9 @@ function blocks the current thread of execution until a response arrives. *) val request : node ref -> + sign_payload:(bytes -> bytes option -> bytes option) -> + key:bytes option -> bytes -> - (bytes -> bytes option -> bytes option) -> - bytes option -> Address.t -> Message.t Lwt.t @@ -58,8 +58,8 @@ val request : of recipients and collects the responses in a list of [Message.t Lwt.t]. *) val broadcast_request : node ref -> - bytes -> Address.t list -> - (bytes -> bytes option -> bytes option) -> - bytes option -> + sign_payload:(bytes -> bytes option -> bytes option) -> + key:bytes option -> + bytes -> Message.t Lwt.t list diff --git a/lib/node/server.ml b/lib/node/server.ml index 37d0fae..f5320ea 100644 --- a/lib/node/server.ml +++ b/lib/node/server.ml @@ -46,7 +46,7 @@ let run node router msg_handler let response = request |> msg_handler - |> Client.create_response node request sign_payload key in + |> Client.create_response node request ~sign_payload:sign_payload ~key:key in let%lwt () = Client.send_to node response in Lwt.return () | None -> Lwt.return () in diff --git a/test/node_tests.ml b/test/node_tests.ml index 0714322..a085ab8 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -28,10 +28,10 @@ module Node_tests = struct let open Messages in let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = res_from_b; _ } = - Client.request node_a get (fun _p _k -> None) None peer_b.address in + Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None get peer_b.address in let res_from_b = Encoding.unpack bin_read_response res_from_b in let%lwt { payload = res_from_a; _ } = - Client.request node_b get (fun _p _k -> None) None peer_a.address in + Client.request node_b ~sign_payload:(fun _p _k -> None) ~key:None get peer_a.address in let res_from_a = Encoding.unpack bin_read_response res_from_a in let res_from_b, res_from_a = match (res_from_b, res_from_a) with @@ -44,12 +44,12 @@ module Node_tests = struct let insert_req = Encoding.pack bin_writer_message (Request (Insert "something")) in let%lwt { payload = res_a; _ } = - Client.request node_a insert_req (fun _p _k -> None) None peer_b.address + Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None insert_req peer_b.address in let res_a = Encoding.unpack bin_read_response res_a in let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = b_state; _ } = - Client.request node_a get (fun _p _k -> None) None peer_b.address in + Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None get peer_b.address in let b_state = Encoding.unpack bin_read_response b_state in let res_a, b_state = match (res_a, b_state) with @@ -61,7 +61,7 @@ module Node_tests = struct let open Messages in let ping = Encoding.pack bin_writer_message (Request Ping) in let%lwt { payload = pong; _ } = - Client.request node_a ping (fun _p _k -> None) None peer_b.address in + Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None ping peer_b.address in let pong = Encoding.unpack bin_read_response pong in let pong = match pong with From d22fef03998ba734bdba065daaec7f122f4bed9e Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Tue, 24 May 2022 11:31:12 +0200 Subject: [PATCH 05/12] feat(dekuIntegration): naming conflicts in Deku --- lib/dune | 2 +- lib/node/dune | 4 ++-- lib/pollinate.ml | 2 +- test/commons.ml | 4 ++-- test/failure_detector_prop.ml | 5 +++-- test/failure_detector_tests.ml | 8 ++++---- test/node_tests.ml | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/dune b/lib/dune index f5c1898..71009f1 100644 --- a/lib/dune +++ b/lib/dune @@ -1,4 +1,4 @@ (library (name pollinate) (public_name pollinate) - (libraries pollinate.common pollinate.node)) + (libraries pollinate.common pollinate.pnode)) diff --git a/lib/node/dune b/lib/node/dune index 8da2ca6..81f450b 100644 --- a/lib/node/dune +++ b/lib/node/dune @@ -1,6 +1,6 @@ (library - (name node) - (public_name pollinate.node) + (name pnode) + (public_name pollinate.pnode) (libraries bin_prot lwt lwt.unix pollinate.common) (preprocess (pps ppx_bin_prot lwt_ppx ppx_deriving.eq ppx_deriving.ord))) diff --git a/lib/pollinate.ml b/lib/pollinate.ml index 84d1900..ab4d85a 100644 --- a/lib/pollinate.ml +++ b/lib/pollinate.ml @@ -1,4 +1,4 @@ module Address = Common.Address module Util = Common.Util module Peer = Common.Peer -module Node = Node +module PNode = Pnode diff --git a/test/commons.ml b/test/commons.ml index 87a4e52..6937a9a 100644 --- a/test/commons.ml +++ b/test/commons.ml @@ -1,6 +1,6 @@ (** Utils function shared by the different tests modules *) module Commons = struct - open Pollinate.Node + open Pollinate.PNode open Pollinate.Util open Messages @@ -19,7 +19,7 @@ module Commons = struct let msg_handler request = let open Messages in - let open Pollinate.Node.Message in + let open Pollinate.PNode.Message in let request = Encoding.unpack bin_read_request request.payload in let response = match request with diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index ed07c03..069e900 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -1,7 +1,8 @@ open QCheck2.Gen open Pollinate.Peer +open Pollinate.PNode open Commons -module SUT = Pollinate.Node.Failure_detector +module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run @@ -20,7 +21,7 @@ let update_peer = ~name:"update_neighbor_status successfully update neighbor status" (pair Generators.peer_gen Generators.peer_status_gen) (fun (neighbor, neighbor_status) -> - let _ = add_neighbor (Pollinate.Node.Client.peer_from !node_a) neighbor in + let _ = add_neighbor (Pollinate.PNode.Client.peer_from !node_a) neighbor in let _ = SUT.update_peer_status node_a neighbor neighbor_status in neighbor.status = neighbor_status) diff --git a/test/failure_detector_tests.ml b/test/failure_detector_tests.ml index 583aadd..8ab6b64 100644 --- a/test/failure_detector_tests.ml +++ b/test/failure_detector_tests.ml @@ -1,8 +1,8 @@ open Commons -open Pollinate.Node +open Pollinate.PNode open Lwt.Infix -module SUT = Pollinate.Node.Failure_detector +module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run @@ -21,7 +21,7 @@ let failure_detection () = let open Common.Peer in let open Client in let _ = add_peer !node_a peer_b in - let _ = Pollinate.Node.Client.peer_from !node_a in + let _ = Pollinate.PNode.Client.peer_from !node_a in let _ = SUT.update_peer_status node_a peer_b Suspicious in (* Need to wait for the timeout to be reached An other way to do, would be to change the `last_suspicious_status` of the peer *) let%lwt _ = Lwt_unix.sleep 9.1 in @@ -30,7 +30,7 @@ let failure_detection () = let failure_detection_nothing_on_alive () = let open Common.Peer in - let _ = add_neighbor (Pollinate.Node.Client.peer_from !node_a) peer_b in + let _ = add_neighbor (Pollinate.PNode.Client.peer_from !node_a) peer_b in let _ = SUT.update_peer_status node_a peer_b Alive in let%lwt _ = SUT.failure_detection node_a in Lwt.return (Base.Hashtbl.length !node_a.peers = 1) diff --git a/test/node_tests.ml b/test/node_tests.ml index a085ab8..bd2c11a 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -1,5 +1,5 @@ open Lwt.Infix -open Pollinate.Node +open Pollinate.PNode open Pollinate.Util open Commons open Messages From f44db78f0ae98d91f50f38dc61df33f0e09a0f53 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Tue, 24 May 2022 11:34:29 +0200 Subject: [PATCH 06/12] feat(dekuIntegration): naming conflicts in Deku, bis --- lib/node/{node.ml => pnode.ml} | 0 lib/node/{node.mli => pnode.mli} | 0 test/failure_detector_prop.ml | 3 +-- test/failure_detector_tests.ml | 4 ++-- test/node_tests.ml | 4 ++-- 5 files changed, 5 insertions(+), 6 deletions(-) rename lib/node/{node.ml => pnode.ml} (100%) rename lib/node/{node.mli => pnode.mli} (100%) diff --git a/lib/node/node.ml b/lib/node/pnode.ml similarity index 100% rename from lib/node/node.ml rename to lib/node/pnode.ml diff --git a/lib/node/node.mli b/lib/node/pnode.mli similarity index 100% rename from lib/node/node.mli rename to lib/node/pnode.mli diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index 069e900..fe5b1ca 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -1,12 +1,11 @@ open QCheck2.Gen open Pollinate.Peer -open Pollinate.PNode open Commons module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3002)) diff --git a/test/failure_detector_tests.ml b/test/failure_detector_tests.ml index 8ab6b64..3bfb222 100644 --- a/test/failure_detector_tests.ml +++ b/test/failure_detector_tests.ml @@ -6,12 +6,12 @@ module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3003)) let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3004)) diff --git a/test/node_tests.ml b/test/node_tests.ml index bd2c11a..100249f 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -8,7 +8,7 @@ module Node_tests = struct (* Initializes two nodes and the related two peers *) let node_a = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3000)) @@ -16,7 +16,7 @@ module Node_tests = struct let node_b = Lwt_main.run - (Node.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3001)) From 8d34a2ee8cc9da9b9fd909b418b0b97709b30f65 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Tue, 24 May 2022 11:37:32 +0200 Subject: [PATCH 07/12] feat(dekuIntegration): naming conflicts in Deku, ter --- lib/{node => pnode}/client.ml | 0 lib/{node => pnode}/client.mli | 0 lib/{node => pnode}/dune | 0 lib/{node => pnode}/failure_detector.ml | 0 lib/{node => pnode}/failure_detector.mli | 0 lib/{node => pnode}/inbox.ml | 0 lib/{node => pnode}/inbox.mli | 0 lib/{node => pnode}/message.ml | 0 lib/{node => pnode}/message.mli | 0 lib/{node => pnode}/pnode.ml | 0 lib/{node => pnode}/pnode.mli | 0 lib/{node => pnode}/server.ml | 0 lib/{node => pnode}/types.ml | 0 lib/{node => pnode}/types.mli | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename lib/{node => pnode}/client.ml (100%) rename lib/{node => pnode}/client.mli (100%) rename lib/{node => pnode}/dune (100%) rename lib/{node => pnode}/failure_detector.ml (100%) rename lib/{node => pnode}/failure_detector.mli (100%) rename lib/{node => pnode}/inbox.ml (100%) rename lib/{node => pnode}/inbox.mli (100%) rename lib/{node => pnode}/message.ml (100%) rename lib/{node => pnode}/message.mli (100%) rename lib/{node => pnode}/pnode.ml (100%) rename lib/{node => pnode}/pnode.mli (100%) rename lib/{node => pnode}/server.ml (100%) rename lib/{node => pnode}/types.ml (100%) rename lib/{node => pnode}/types.mli (100%) diff --git a/lib/node/client.ml b/lib/pnode/client.ml similarity index 100% rename from lib/node/client.ml rename to lib/pnode/client.ml diff --git a/lib/node/client.mli b/lib/pnode/client.mli similarity index 100% rename from lib/node/client.mli rename to lib/pnode/client.mli diff --git a/lib/node/dune b/lib/pnode/dune similarity index 100% rename from lib/node/dune rename to lib/pnode/dune diff --git a/lib/node/failure_detector.ml b/lib/pnode/failure_detector.ml similarity index 100% rename from lib/node/failure_detector.ml rename to lib/pnode/failure_detector.ml diff --git a/lib/node/failure_detector.mli b/lib/pnode/failure_detector.mli similarity index 100% rename from lib/node/failure_detector.mli rename to lib/pnode/failure_detector.mli diff --git a/lib/node/inbox.ml b/lib/pnode/inbox.ml similarity index 100% rename from lib/node/inbox.ml rename to lib/pnode/inbox.ml diff --git a/lib/node/inbox.mli b/lib/pnode/inbox.mli similarity index 100% rename from lib/node/inbox.mli rename to lib/pnode/inbox.mli diff --git a/lib/node/message.ml b/lib/pnode/message.ml similarity index 100% rename from lib/node/message.ml rename to lib/pnode/message.ml diff --git a/lib/node/message.mli b/lib/pnode/message.mli similarity index 100% rename from lib/node/message.mli rename to lib/pnode/message.mli diff --git a/lib/node/pnode.ml b/lib/pnode/pnode.ml similarity index 100% rename from lib/node/pnode.ml rename to lib/pnode/pnode.ml diff --git a/lib/node/pnode.mli b/lib/pnode/pnode.mli similarity index 100% rename from lib/node/pnode.mli rename to lib/pnode/pnode.mli diff --git a/lib/node/server.ml b/lib/pnode/server.ml similarity index 100% rename from lib/node/server.ml rename to lib/pnode/server.ml diff --git a/lib/node/types.ml b/lib/pnode/types.ml similarity index 100% rename from lib/node/types.ml rename to lib/pnode/types.ml diff --git a/lib/node/types.mli b/lib/pnode/types.mli similarity index 100% rename from lib/node/types.mli rename to lib/pnode/types.mli From 5319f68354e06abb29c3d57fd636564e4a9ae904 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Mon, 30 May 2022 12:03:55 +0200 Subject: [PATCH 08/12] fix format --- lib/pnode/client.ml | 12 ++++++------ lib/pnode/server.ml | 2 +- test/node_tests.ml | 27 +++++++++++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/pnode/client.ml b/lib/pnode/client.ml index f150246..ac346fe 100644 --- a/lib/pnode/client.ml +++ b/lib/pnode/client.ml @@ -17,7 +17,7 @@ let peer_from { address; peers; _ } = let add_peer node (peer : Peer.t) = Base.Hashtbl.add node.peers ~key:peer.address ~data:peer -let create_request node recipient ~sign_payload:sign_payload ~key:key payload = +let create_request node recipient ~sign_payload ~key payload = Mutex.with_lock !node.current_request_id (fun id -> id := !id + 1; Lwt.return @@ -32,7 +32,7 @@ let create_request node recipient ~sign_payload:sign_payload ~key:key payload = payload_signature = sign_payload payload key; }) -let create_response node request ~sign_payload:sign_payload ~key:key payload = +let create_response node request ~sign_payload ~key payload = Message. { category = Message.Response; @@ -77,12 +77,12 @@ let recv_next node = Mutex.unlock !node.socket; Lwt.return message -let request node ~sign_payload:sign_payload ~key:(key : bytes option) request recipient = - let%lwt message = create_request node recipient ~sign_payload:sign_payload ~key:key request in +let request node ~sign_payload ~(key : bytes option) request recipient = + let%lwt message = create_request node recipient ~sign_payload ~key request in let%lwt () = send_to node message in let condition_var = Lwt_condition.create () in Hashtbl.add !node.request_table message.id condition_var; Lwt_condition.wait condition_var -let broadcast_request node recipients ~sign_payload:sign_payload ~key:(key : bytes option) req = - List.map (request node ~sign_payload:sign_payload ~key:key req) recipients +let broadcast_request node recipients ~sign_payload ~(key : bytes option) req = + List.map (request node ~sign_payload ~key req) recipients diff --git a/lib/pnode/server.ml b/lib/pnode/server.ml index f5320ea..c28d387 100644 --- a/lib/pnode/server.ml +++ b/lib/pnode/server.ml @@ -46,7 +46,7 @@ let run node router msg_handler let response = request |> msg_handler - |> Client.create_response node request ~sign_payload:sign_payload ~key:key in + |> Client.create_response node request ~sign_payload ~key in let%lwt () = Client.send_to node response in Lwt.return () | None -> Lwt.return () in diff --git a/test/node_tests.ml b/test/node_tests.ml index 100249f..3aa028c 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -8,7 +8,8 @@ module Node_tests = struct (* Initializes two nodes and the related two peers *) let node_a = Lwt_main.run - (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess + ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3000)) @@ -16,7 +17,8 @@ module Node_tests = struct let node_b = Lwt_main.run - (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler + (Pnode.init ~preprocess:Commons.preprocess + ~msg_handler:Commons.msg_handler ~sign_payload:(fun _p _k -> None) ~key:None ("127.0.0.1", 3001)) @@ -28,10 +30,14 @@ module Node_tests = struct let open Messages in let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = res_from_b; _ } = - Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None get peer_b.address in + Client.request node_a + ~sign_payload:(fun _p _k -> None) + ~key:None get peer_b.address in let res_from_b = Encoding.unpack bin_read_response res_from_b in let%lwt { payload = res_from_a; _ } = - Client.request node_b ~sign_payload:(fun _p _k -> None) ~key:None get peer_a.address in + Client.request node_b + ~sign_payload:(fun _p _k -> None) + ~key:None get peer_a.address in let res_from_a = Encoding.unpack bin_read_response res_from_a in let res_from_b, res_from_a = match (res_from_b, res_from_a) with @@ -44,12 +50,15 @@ module Node_tests = struct let insert_req = Encoding.pack bin_writer_message (Request (Insert "something")) in let%lwt { payload = res_a; _ } = - Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None insert_req peer_b.address - in + Client.request node_a + ~sign_payload:(fun _p _k -> None) + ~key:None insert_req peer_b.address in let res_a = Encoding.unpack bin_read_response res_a in let get = Encoding.pack bin_writer_message (Request Get) in let%lwt { payload = b_state; _ } = - Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None get peer_b.address in + Client.request node_a + ~sign_payload:(fun _p _k -> None) + ~key:None get peer_b.address in let b_state = Encoding.unpack bin_read_response b_state in let res_a, b_state = match (res_a, b_state) with @@ -61,7 +70,9 @@ module Node_tests = struct let open Messages in let ping = Encoding.pack bin_writer_message (Request Ping) in let%lwt { payload = pong; _ } = - Client.request node_a ~sign_payload:(fun _p _k -> None) ~key:None ping peer_b.address in + Client.request node_a + ~sign_payload:(fun _p _k -> None) + ~key:None ping peer_b.address in let pong = Encoding.unpack bin_read_response pong in let pong = match pong with From 69db5b4ebe5d91dc689bd006bfbe1b5e2208b568 Mon Sep 17 00:00:00 2001 From: gsebil08 Date: Mon, 30 May 2022 13:56:57 +0000 Subject: [PATCH 09/12] dependencies with esy? --- esy.lock/index.json | 171 +++++++++++++----- esy.lock/opam/{cppo.1.6.8 => cppo.1.6.9}/opam | 40 ++-- .../opam | 48 +++-- esy.lock/opam/num.1.4/opam | 12 +- esy.lock/opam/odoc.2.1.0/opam | 60 ++++++ esy.lock/opam/{re.1.10.3 => re.1.10.4}/opam | 14 +- .../{spawn.v0.15.0 => spawn.v0.15.1}/opam | 8 +- esy.lock/opam/tyxml.4.5.0/opam | 42 +++++ .../package.json | 3 + 9 files changed, 296 insertions(+), 102 deletions(-) rename esy.lock/opam/{cppo.1.6.8 => cppo.1.6.9}/opam (58%) rename esy.lock/opam/{easy-format.1.3.2 => easy-format.1.3.3}/opam (68%) create mode 100644 esy.lock/opam/odoc.2.1.0/opam rename esy.lock/opam/{re.1.10.3 => re.1.10.4}/opam (66%) rename esy.lock/opam/{spawn.v0.15.0 => spawn.v0.15.1}/opam (79%) create mode 100644 esy.lock/opam/tyxml.4.5.0/opam create mode 100644 esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json diff --git a/esy.lock/index.json b/esy.lock/index.json index a07cce0..3ccee46 100644 --- a/esy.lock/index.json +++ b/esy.lock/index.json @@ -1,5 +1,5 @@ { - "checksum": "ffe903d165082ab60be24550d1dae31b", + "checksum": "9d770610ebf28d090c00e576f71d8236", "root": "pollinate@link-dev:./package.json", "node": { "pollinate@link-dev:./package.json": { @@ -19,6 +19,7 @@ "@opam/ppx_deriving@opam:5.2.1@089e5dd3", "@opam/ppx_compare@opam:v0.14.0@fbd22977", "@opam/ppx_bin_prot@opam:v0.14.0@4a83bcd2", + "@opam/odoc@opam:2.1.0@d39daa6f", "@opam/lwt_ppx@opam:2.0.3@125707d0", "@opam/lwt@opam:5.5.0@30354e4c", "@opam/dune@opam:2.9.3@f57a6d69", "@opam/bin_prot@opam:v0.14.0@2d7601e9" @@ -64,13 +65,13 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@1ea9f987", - "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.8@7e48217d", + "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.3@5d74d95b", + "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.9@db929a12", "@opam/biniou@opam:1.2.1@420bda02", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@1ea9f987", + "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.3@5d74d95b", "@opam/dune@opam:2.9.3@f57a6d69", "@opam/biniou@opam:1.2.1@420bda02" ] }, @@ -183,6 +184,34 @@ ], "devDependencies": [ "ocaml@4.13.1000@d41d8cd9" ] }, + "@opam/tyxml@opam:4.5.0@0a609297": { + "id": "@opam/tyxml@opam:4.5.0@0a609297", + "name": "@opam/tyxml", + "version": "opam:4.5.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/c6/c69accef5df4dd89d38f6aa0baad01e8fda4e9e98bb7dad61bec1452c5716068#sha256:c69accef5df4dd89d38f6aa0baad01e8fda4e9e98bb7dad61bec1452c5716068", + "archive:https://github.com/ocsigen/tyxml/releases/download/4.5.0/tyxml-4.5.0.tbz#sha256:c69accef5df4dd89d38f6aa0baad01e8fda4e9e98bb7dad61bec1452c5716068" + ], + "opam": { + "name": "tyxml", + "version": "4.5.0", + "path": "esy.lock/opam/tyxml.4.5.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/seq@opam:base@d8d7de1d", "@opam/re@opam:1.10.4@c4910ba6", + "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/seq@opam:base@d8d7de1d", "@opam/re@opam:1.10.4@c4910ba6", + "@opam/dune@opam:2.9.3@f57a6d69" + ] + }, "@opam/topkg@opam:1.0.5@0aa59f51": { "id": "@opam/topkg@opam:1.0.5@0aa59f51", "name": "@opam/topkg", @@ -301,20 +330,20 @@ "@opam/base@opam:v0.14.3@b3ddb868" ] }, - "@opam/spawn@opam:v0.15.0@4a27a4cb": { - "id": "@opam/spawn@opam:v0.15.0@4a27a4cb", + "@opam/spawn@opam:v0.15.1@85e9d6f1": { + "id": "@opam/spawn@opam:v0.15.1@85e9d6f1", "name": "@opam/spawn", - "version": "opam:v0.15.0", + "version": "opam:v0.15.1", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/31/310fb2a50ac7f64c738182cbabd9d27c1aeae1a08107fe14da8d35a87cbb57c7#sha256:310fb2a50ac7f64c738182cbabd9d27c1aeae1a08107fe14da8d35a87cbb57c7", - "archive:https://github.com/janestreet/spawn/archive/v0.15.0.tar.gz#sha256:310fb2a50ac7f64c738182cbabd9d27c1aeae1a08107fe14da8d35a87cbb57c7" + "archive:https://opam.ocaml.org/cache/sha256/9a/9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50#sha256:9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50", + "archive:https://github.com/janestreet/spawn/archive/v0.15.1.tar.gz#sha256:9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50" ], "opam": { "name": "spawn", - "version": "v0.15.0", - "path": "esy.lock/opam/spawn.v0.15.0" + "version": "v0.15.1", + "path": "esy.lock/opam/spawn.v0.15.1" } }, "overrides": [], @@ -370,12 +399,12 @@ "overrides": [], "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/sexplib0@opam:v0.14.0@155c136c", - "@opam/parsexp@opam:v0.14.2@1d15b9d2", "@opam/num@opam:1.4@15ff926d", + "@opam/parsexp@opam:v0.14.2@1d15b9d2", "@opam/num@opam:1.4@54b259a0", "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/sexplib0@opam:v0.14.0@155c136c", - "@opam/parsexp@opam:v0.14.2@1d15b9d2", "@opam/num@opam:1.4@15ff926d", + "@opam/parsexp@opam:v0.14.2@1d15b9d2", "@opam/num@opam:1.4@54b259a0", "@opam/dune@opam:2.9.3@f57a6d69" ] }, @@ -448,20 +477,20 @@ "ocaml@4.13.1000@d41d8cd9", "@opam/dune@opam:2.9.3@f57a6d69" ] }, - "@opam/re@opam:1.10.3@0585c65d": { - "id": "@opam/re@opam:1.10.3@0585c65d", + "@opam/re@opam:1.10.4@c4910ba6": { + "id": "@opam/re@opam:1.10.4@c4910ba6", "name": "@opam/re", - "version": "opam:1.10.3", + "version": "opam:1.10.4", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/84/846546967f3fe31765935dd40a6460a9424337ecce7b12727fcba49480790ebb#sha256:846546967f3fe31765935dd40a6460a9424337ecce7b12727fcba49480790ebb", - "archive:https://github.com/ocaml/ocaml-re/releases/download/1.10.3/re-1.10.3.tbz#sha256:846546967f3fe31765935dd40a6460a9424337ecce7b12727fcba49480790ebb" + "archive:https://opam.ocaml.org/cache/sha256/83/83eb3e4300aa9b1dc7820749010f4362ea83524742130524d78c20ce99ca747c#sha256:83eb3e4300aa9b1dc7820749010f4362ea83524742130524d78c20ce99ca747c", + "archive:https://github.com/ocaml/ocaml-re/releases/download/1.10.4/re-1.10.4.tbz#sha256:83eb3e4300aa9b1dc7820749010f4362ea83524742130524d78c20ce99ca747c" ], "opam": { "name": "re", - "version": "1.10.3", - "path": "esy.lock/opam/re.1.10.3" + "version": "1.10.4", + "path": "esy.lock/opam/re.1.10.4" } }, "overrides": [], @@ -943,7 +972,7 @@ "@opam/ppxlib@opam:0.25.0@8553d2e8", "@opam/ppx_derivers@opam:1.2.1@e2cbad12", "@opam/ocamlfind@opam:1.9.3@781b30f3", - "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.8@7e48217d", + "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.9@db929a12", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ @@ -1279,6 +1308,43 @@ "@opam/dune@opam:2.9.3@f57a6d69", "@opam/astring@opam:0.8.5@1300cee8" ] }, + "@opam/odoc@opam:2.1.0@d39daa6f": { + "id": "@opam/odoc@opam:2.1.0@d39daa6f", + "name": "@opam/odoc", + "version": "opam:2.1.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/65/65a2523a50ee368164f1f24f75866a6a36cdb0d00039c3006ec824351d4e4967#sha256:65a2523a50ee368164f1f24f75866a6a36cdb0d00039c3006ec824351d4e4967", + "archive:https://github.com/ocaml/odoc/releases/download/2.1.0/odoc-2.1.0.tbz#sha256:65a2523a50ee368164f1f24f75866a6a36cdb0d00039c3006ec824351d4e4967" + ], + "opam": { + "name": "odoc", + "version": "2.1.0", + "path": "esy.lock/opam/odoc.2.1.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.13.1000@d41d8cd9", "@opam/tyxml@opam:4.5.0@0a609297", + "@opam/result@opam:1.5@1c6a6533", + "@opam/odoc-parser@opam:1.0.0@b1029bdf", + "@opam/fpath@opam:0.7.3@674d8125", "@opam/fmt@opam:0.9.0@87213963", + "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.9@db929a12", + "@opam/cmdliner@opam:1.1.1@03763729", + "@opam/astring@opam:0.8.5@1300cee8", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.13.1000@d41d8cd9", "@opam/tyxml@opam:4.5.0@0a609297", + "@opam/result@opam:1.5@1c6a6533", + "@opam/odoc-parser@opam:1.0.0@b1029bdf", + "@opam/fpath@opam:0.7.3@674d8125", "@opam/fmt@opam:0.9.0@87213963", + "@opam/dune@opam:2.9.3@f57a6d69", + "@opam/cmdliner@opam:1.1.1@03763729", + "@opam/astring@opam:0.8.5@1300cee8" + ] + }, "@opam/octavius@opam:1.2.2@2205cc65": { "id": "@opam/octavius@opam:1.2.2@2205cc65", "name": "@opam/octavius", @@ -1323,7 +1389,7 @@ "overrides": [], "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/dune@opam:2.9.3@f57a6d69", - "@opam/cppo@opam:1.6.8@7e48217d", + "@opam/cppo@opam:1.6.9@db929a12", "@opam/base-bytes@opam:base@19d0c2ff", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], @@ -1410,7 +1476,7 @@ "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", "@opam/uuseg@opam:14.0.0@7d21466b", - "@opam/stdio@opam:v0.14.0@a5affb43", "@opam/re@opam:1.10.3@0585c65d", + "@opam/stdio@opam:v0.14.0@a5affb43", "@opam/re@opam:1.10.4@c4910ba6", "@opam/odoc-parser@opam:1.0.0@b1029bdf", "@opam/ocp-indent@opam:1.8.1@e32a3c50", "@opam/ocaml-version@opam:3.4.0@b6cd49e1", @@ -1429,7 +1495,7 @@ "devDependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", "@opam/uuseg@opam:14.0.0@7d21466b", - "@opam/stdio@opam:v0.14.0@a5affb43", "@opam/re@opam:1.10.3@0585c65d", + "@opam/stdio@opam:v0.14.0@a5affb43", "@opam/re@opam:1.10.4@c4910ba6", "@opam/odoc-parser@opam:1.0.0@b1029bdf", "@opam/ocp-indent@opam:1.8.1@e32a3c50", "@opam/ocaml-version@opam:3.4.0@b6cd49e1", @@ -1597,8 +1663,8 @@ "overrides": [], "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@69d87312", - "@opam/spawn@opam:v0.15.0@4a27a4cb", - "@opam/result@opam:1.5@1c6a6533", "@opam/re@opam:1.10.3@0585c65d", + "@opam/spawn@opam:v0.15.1@85e9d6f1", + "@opam/result@opam:1.5@1c6a6533", "@opam/re@opam:1.10.4@c4910ba6", "@opam/ppx_yojson_conv_lib@opam:v0.15.0@773058a7", "@opam/pp@opam:1.1.2@89ad03b5", "@opam/ocamlformat-rpc-lib@opam:0.19.0@125cf11d", @@ -1608,8 +1674,8 @@ ], "devDependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@69d87312", - "@opam/spawn@opam:v0.15.0@4a27a4cb", - "@opam/result@opam:1.5@1c6a6533", "@opam/re@opam:1.10.3@0585c65d", + "@opam/spawn@opam:v0.15.1@85e9d6f1", + "@opam/result@opam:1.5@1c6a6533", "@opam/re@opam:1.10.4@c4910ba6", "@opam/ppx_yojson_conv_lib@opam:v0.15.0@773058a7", "@opam/pp@opam:1.1.2@89ad03b5", "@opam/ocamlformat-rpc-lib@opam:0.19.0@125cf11d", @@ -1642,8 +1708,8 @@ "ocaml@4.13.1000@d41d8cd9", "@opam/dune@opam:2.9.3@f57a6d69" ] }, - "@opam/num@opam:1.4@15ff926d": { - "id": "@opam/num@opam:1.4@15ff926d", + "@opam/num@opam:1.4@54b259a0": { + "id": "@opam/num@opam:1.4@54b259a0", "name": "@opam/num", "version": "opam:1.4", "source": { @@ -1826,7 +1892,7 @@ "@opam/ocaml-syntax-shims@opam:1.0.0@9f361fbb", "@opam/mmap@opam:1.2.0@b0f60a84", "@opam/dune-configurator@opam:2.9.3@174e411b", - "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.8@7e48217d", + "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cppo@opam:1.6.9@db929a12", "@opam/base-unix@opam:base@87d0b2eb", "@opam/base-threads@opam:base@36803084", "@esy-ocaml/substs@0.0.1@d41d8cd9" @@ -2054,23 +2120,28 @@ ], "devDependencies": [ "@opam/dune@opam:2.9.3@f57a6d69" ] }, - "@opam/easy-format@opam:1.3.2@1ea9f987": { - "id": "@opam/easy-format@opam:1.3.2@1ea9f987", + "@opam/easy-format@opam:1.3.3@5d74d95b": { + "id": "@opam/easy-format@opam:1.3.3@5d74d95b", "name": "@opam/easy-format", - "version": "opam:1.3.2", + "version": "opam:1.3.3", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/34/3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926", - "archive:https://github.com/mjambon/easy-format/releases/download/1.3.2/easy-format-1.3.2.tbz#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926" + "archive:https://opam.ocaml.org/cache/sha256/ea/eafccae911c26ca23e4ddacee3eaa54654d20f973b8680f84b708cef43adc416#sha256:eafccae911c26ca23e4ddacee3eaa54654d20f973b8680f84b708cef43adc416", + "archive:https://github.com/mjambon/easy-format/releases/download/1.3.3/easy-format-1.3.3.tbz#sha256:eafccae911c26ca23e4ddacee3eaa54654d20f973b8680f84b708cef43adc416" ], "opam": { "name": "easy-format", - "version": "1.3.2", - "path": "esy.lock/opam/easy-format.1.3.2" + "version": "1.3.3", + "path": "esy.lock/opam/easy-format.1.3.3" } }, - "overrides": [], + "overrides": [ + { + "opamoverride": + "esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override" + } + ], "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9" @@ -2180,20 +2251,20 @@ "ocaml@4.13.1000@d41d8cd9", "@opam/dune@opam:2.9.3@f57a6d69" ] }, - "@opam/cppo@opam:1.6.8@7e48217d": { - "id": "@opam/cppo@opam:1.6.8@7e48217d", + "@opam/cppo@opam:1.6.9@db929a12": { + "id": "@opam/cppo@opam:1.6.9@db929a12", "name": "@opam/cppo", - "version": "opam:1.6.8", + "version": "opam:1.6.9", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/fe/fed401197d86f9089e89f6cbdf1d660d#md5:fed401197d86f9089e89f6cbdf1d660d", - "archive:https://github.com/ocaml-community/cppo/archive/v1.6.8.tar.gz#md5:fed401197d86f9089e89f6cbdf1d660d" + "archive:https://opam.ocaml.org/cache/md5/d2/d23ffe85ac7dc8f0afd1ddf622770d09#md5:d23ffe85ac7dc8f0afd1ddf622770d09", + "archive:https://github.com/ocaml-community/cppo/archive/v1.6.9.tar.gz#md5:d23ffe85ac7dc8f0afd1ddf622770d09" ], "opam": { "name": "cppo", - "version": "1.6.8", - "path": "esy.lock/opam/cppo.1.6.8" + "version": "1.6.9", + "path": "esy.lock/opam/cppo.1.6.9" } }, "overrides": [], @@ -2283,11 +2354,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@1ea9f987", + "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.3@5d74d95b", "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@1ea9f987", + "ocaml@4.13.1000@d41d8cd9", "@opam/easy-format@opam:1.3.3@5d74d95b", "@opam/dune@opam:2.9.3@f57a6d69" ] }, @@ -2515,7 +2586,7 @@ "dependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", "@opam/stdlib-shims@opam:0.3.0@72c7bc98", - "@opam/re@opam:1.10.3@0585c65d", + "@opam/re@opam:1.10.4@c4910ba6", "@opam/ocaml-syntax-shims@opam:1.0.0@9f361fbb", "@opam/fmt@opam:0.9.0@87213963", "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cmdliner@opam:1.1.1@03763729", @@ -2525,7 +2596,7 @@ "devDependencies": [ "ocaml@4.13.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", "@opam/stdlib-shims@opam:0.3.0@72c7bc98", - "@opam/re@opam:1.10.3@0585c65d", + "@opam/re@opam:1.10.4@c4910ba6", "@opam/ocaml-syntax-shims@opam:1.0.0@9f361fbb", "@opam/fmt@opam:0.9.0@87213963", "@opam/dune@opam:2.9.3@f57a6d69", "@opam/cmdliner@opam:1.1.1@03763729", diff --git a/esy.lock/opam/cppo.1.6.8/opam b/esy.lock/opam/cppo.1.6.9/opam similarity index 58% rename from esy.lock/opam/cppo.1.6.8/opam rename to esy.lock/opam/cppo.1.6.9/opam index c9d7f68..9c51ec6 100644 --- a/esy.lock/opam/cppo.1.6.8/opam +++ b/esy.lock/opam/cppo.1.6.9/opam @@ -1,37 +1,39 @@ opam-version: "2.0" -maintainer: "martin@mjambon.com" +synopsis: "Code preprocessor like cpp for OCaml" +description: """\ +Cppo is an equivalent of the C preprocessor for OCaml programs. +It allows the definition of simple macros and file inclusion. + +Cppo is: + +* more OCaml-friendly than cpp +* easy to learn without consulting a manual +* reasonably fast +* simple to install and to maintain""" +maintainer: [ + "Martin Jambon " "Yishuai Li " +] authors: "Martin Jambon" license: "BSD-3-Clause" homepage: "https://github.com/ocaml-community/cppo" -doc: "https://ocaml-community.github.io/cppo/" +doc: "https://ocaml-community.github.io/cppo" bug-reports: "https://github.com/ocaml-community/cppo/issues" depends: [ "ocaml" {>= "4.02.3"} - "dune" {>= "1.0"} + "dune" {>= "1.10"} "base-unix" ] build: [ ["dune" "subst"] {dev} ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} ] dev-repo: "git+https://github.com/ocaml-community/cppo.git" -synopsis: "Code preprocessor like cpp for OCaml" -description: """ -Cppo is an equivalent of the C preprocessor for OCaml programs. -It allows the definition of simple macros and file inclusion. - -Cppo is: - -* more OCaml-friendly than cpp -* easy to learn without consulting a manual -* reasonably fast -* simple to install and to maintain -""" url { - src: "https://github.com/ocaml-community/cppo/archive/v1.6.8.tar.gz" + src: "https://github.com/ocaml-community/cppo/archive/v1.6.9.tar.gz" checksum: [ - "md5=fed401197d86f9089e89f6cbdf1d660d" - "sha512=069bbe0ef09c03b0dc4b5795f909c3ef872fe99c6f1e6704a0fa97594b1570b3579226ec67fe11d696ccc349a4585055bbaf07c65eff423aa45af28abf38c858" + "md5=d23ffe85ac7dc8f0afd1ddf622770d09" + "sha512=26ff5a7b7f38c460661974b23ca190f0feae3a99f1974e0fd12ccf08745bd7d91b7bc168c70a5385b837bfff9530e0e4e41cf269f23dd8cf16ca658008244b44" ] -} +} \ No newline at end of file diff --git a/esy.lock/opam/easy-format.1.3.2/opam b/esy.lock/opam/easy-format.1.3.3/opam similarity index 68% rename from esy.lock/opam/easy-format.1.3.2/opam rename to esy.lock/opam/easy-format.1.3.3/opam index f55c2c8..5926060 100644 --- a/esy.lock/opam/easy-format.1.3.2/opam +++ b/esy.lock/opam/easy-format.1.3.3/opam @@ -1,17 +1,4 @@ opam-version: "2.0" -build: [ - ["dune" "subst"] {dev} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} - ["dune" "build" "-p" name "@doc"] {with-doc} -] -maintainer: ["martin@mjambon.com" "rudi.grinberg@gmail.com"] -authors: ["Martin Jambon"] -bug-reports: "https://github.com/mjambon/easy-format/issues" -homepage: "https://github.com/mjambon/easy-format" -doc: "https://mjambon.github.io/easy-format/" -license: "BSD-3-Clause" -dev-repo: "git+https://github.com/mjambon/easy-format.git" synopsis: "High-level and functional interface to the Format module of the OCaml standard library" description: """ @@ -32,15 +19,40 @@ nodes: Atoms represent any text that is guaranteed to be printed as-is. Lists can model any sequence of items such as arrays of data or lists of definitions that are labelled with something like "int main", "let x =" or "x:".""" +maintainer: ["martin@mjambon.com" "rudi.grinberg@gmail.com"] +authors: ["Martin Jambon"] +license: "BSD-3-Clause" +homepage: "https://github.com/mjambon/easy-format" +doc: "https://mjambon.github.io/easy-format/" +bug-reports: "https://github.com/mjambon/easy-format/issues" depends: [ - "dune" {>= "1.10"} - "ocaml" {>= "4.02.3"} + "dune" {>= "2.9"} + "ocaml" {>= "4.08"} + "odoc" {with-doc} ] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "--promote-install-files=false" + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "install" "-p" name "--create-install-files" name] +] +dev-repo: "git+https://github.com/mjambon/easy-format.git" url { src: - "https://github.com/mjambon/easy-format/releases/download/1.3.2/easy-format-1.3.2.tbz" + "https://github.com/mjambon/easy-format/releases/download/1.3.3/easy-format-1.3.3.tbz" checksum: [ - "sha256=3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926" - "sha512=e39377a2ff020ceb9ac29e8515a89d9bdbc91dfcfa871c4e3baafa56753fac2896768e5d9822a050dc1e2ade43c8967afb69391a386c0a8ecd4e1f774e236135" + "sha256=eafccae911c26ca23e4ddacee3eaa54654d20f973b8680f84b708cef43adc416" + "sha512=611b3124f6a0ec6406b7bda8018a94c9c4a9da9d22495a5c34a6312bf7f0f0607a9529b276f7039ce3f3b15a955dac413d6d1229a55d5ac291302a3ddd5807e5" ] } +x-commit-hash: "56c57e69ef067d1cc4e31029d31e77e55b46be95" diff --git a/esy.lock/opam/num.1.4/opam b/esy.lock/opam/num.1.4/opam index 0e39879..253f84e 100644 --- a/esy.lock/opam/num.1.4/opam +++ b/esy.lock/opam/num.1.4/opam @@ -13,9 +13,13 @@ depends: [ conflicts: ["base-num"] build: make install: [ - make - "install" {!ocaml:preinstalled} - "findlib-install" {ocaml:preinstalled} + ["ocamlfind" "remove" "num"] + ["ocamlfind" "remove" "num-top"] + [ + make + "install" {!ocaml:preinstalled} + "findlib-install" {ocaml:preinstalled} + ] ] dev-repo: "git+https://github.com/ocaml/num.git" url { @@ -24,4 +28,4 @@ url { "md5=cda2b727e116a0b6a9c03902cc4b2415" "sha512=0cc9be8ad95704bb683b4bf6698bada1ee9a40dc05924b72adc7b969685c33eeb68ccf174cc09f6a228c48c18fe94af06f28bebc086a24973a066da620db8e6f" ] -} \ No newline at end of file +} diff --git a/esy.lock/opam/odoc.2.1.0/opam b/esy.lock/opam/odoc.2.1.0/opam new file mode 100644 index 0000000..6b1df40 --- /dev/null +++ b/esy.lock/opam/odoc.2.1.0/opam @@ -0,0 +1,60 @@ +opam-version: "2.0" +homepage: "http://github.com/ocaml/odoc" +doc: "https://ocaml.github.io/odoc/" +bug-reports: "https://github.com/ocaml/odoc/issues" +license: "ISC" + +authors: [ + "Thomas Refis " + "David Sheets " + "Leo White " + "Anton Bachin " + "Jon Ludlam " + "Jules Aguillon " + "Lubega Simon " +] +maintainer: "Jon Ludlam " +dev-repo: "git+https://github.com/ocaml/odoc.git" + +synopsis: "OCaml documentation generator" +description: """ +Odoc is a documentation generator for OCaml. It reads doc comments, +delimited with `(** ... *)`, and outputs HTML. +""" + +depends: [ + "odoc-parser" {>= "0.9.0"} + "astring" + "cmdliner" {>= "1.0.0"} + "cppo" {build & >= "1.1.0"} + "dune" {>= "2.9.1"} + "fpath" + "ocaml" {>= "4.02.0"} + "result" + "tyxml" {>= "4.3.0"} + "fmt" + + "ocamlfind" {with-test} + "yojson" {with-test} + ("ocaml" {< "4.04.1" & with-test} | "sexplib0" {with-test}) + "conf-jq" {with-test} + + "ppx_expect" {with-test} + "bos" {with-test} + + "bisect_ppx" {dev & > "2.5.0"} + ("ocaml" {< "4.03.0" & dev} | "mdx" {dev}) +] + +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] +] +url { + src: "https://github.com/ocaml/odoc/releases/download/2.1.0/odoc-2.1.0.tbz" + checksum: [ + "sha256=65a2523a50ee368164f1f24f75866a6a36cdb0d00039c3006ec824351d4e4967" + "sha512=cf4d7e884b94a9b9c4bcb62d4423d7289d7bbbf2642c5eacf9577b76eb835cf6ecc79d2384d36d174d2e9d8f758b5082c0c4bf8f66b5c6db4e9805dc3fc9ee1a" + ] +} +x-commit-hash: "d654ee2a4ff3e1465dcf92b882c26de71f7a9986" diff --git a/esy.lock/opam/re.1.10.3/opam b/esy.lock/opam/re.1.10.4/opam similarity index 66% rename from esy.lock/opam/re.1.10.3/opam rename to esy.lock/opam/re.1.10.4/opam index c65d450..9dad661 100644 --- a/esy.lock/opam/re.1.10.3/opam +++ b/esy.lock/opam/re.1.10.4/opam @@ -8,19 +8,19 @@ authors: [ "Rudi Grinberg" "Gabriel Radanne" ] -license: "LGPL-2.0 with OCaml linking exception" +license: "LGPL-2.0-or-later WITH OCaml-LGPL-linking-exception" homepage: "https://github.com/ocaml/ocaml-re" bug-reports: "https://github.com/ocaml/ocaml-re/issues" dev-repo: "git+https://github.com/ocaml/ocaml-re.git" build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ - "ocaml" {>= "4.02"} + "ocaml" {>= "4.03"} "dune" {>= "2.0"} "ounit" {with-test} "seq" @@ -37,10 +37,10 @@ Pure OCaml regular expressions with: """ url { src: - "https://github.com/ocaml/ocaml-re/releases/download/1.10.3/re-1.10.3.tbz" + "https://github.com/ocaml/ocaml-re/releases/download/1.10.4/re-1.10.4.tbz" checksum: [ - "sha256=846546967f3fe31765935dd40a6460a9424337ecce7b12727fcba49480790ebb" - "sha512=d02103b7b8b8d8bc797341dcc933554745427f3c1b51b54b4ac9ff81badfd68c94726c57548b08e00ca99f3e09741b54b6500e97c19fc0e8fcefd6dfbe71da7f" + "sha256=83eb3e4300aa9b1dc7820749010f4362ea83524742130524d78c20ce99ca747c" + "sha512=92b05cf92c389fa8c753f2acca837b15dd05a4a2e8e2bec7a269d2e14c35b1a786d394258376648f80b4b99250ba1900cfe68230b8385aeac153149d9ce56099" ] } -x-commit-hash: "c5d5df80e128c3d7646b7d8b1322012c5fcc35f3" +x-commit-hash: "e9a4cecb8294c1839db18b1d0c30e755ec85ed5e" diff --git a/esy.lock/opam/spawn.v0.15.0/opam b/esy.lock/opam/spawn.v0.15.1/opam similarity index 79% rename from esy.lock/opam/spawn.v0.15.0/opam rename to esy.lock/opam/spawn.v0.15.1/opam index d8d1578..5be3a99 100644 --- a/esy.lock/opam/spawn.v0.15.0/opam +++ b/esy.lock/opam/spawn.v0.15.1/opam @@ -45,12 +45,12 @@ build: [ ] ] dev-repo: "git+https://github.com/janestreet/spawn.git" -x-commit-hash: "b5a25cab2f53a5ee9e10a7b8a96506cc61ce1198" +x-commit-hash: "13d279ebfa8c40d4bafe18cddfdff0de54b4eaff" url { src: - "https://github.com/janestreet/spawn/archive/v0.15.0.tar.gz" + "https://github.com/janestreet/spawn/archive/v0.15.1.tar.gz" checksum: [ - "sha256=310fb2a50ac7f64c738182cbabd9d27c1aeae1a08107fe14da8d35a87cbb57c7" - "sha512=3a775b57a73efee6adbc30b32fa779f27d11c7008a46f90fdb9da6288533e2d83fc49dbcd770c087f2e4560c5586ff72a9a2985d8929955773cc10d83f126013" + "sha256=9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50" + "sha512=efdb31d5ec5ea36d0bc80224d4ee04e46ce3428d1662870e6cebece92bc313d6eebee378802c0c059dd6e0cafea515308c31b7dfaf04a098eb4566583c1e9ed4" ] } diff --git a/esy.lock/opam/tyxml.4.5.0/opam b/esy.lock/opam/tyxml.4.5.0/opam new file mode 100644 index 0000000..22c7760 --- /dev/null +++ b/esy.lock/opam/tyxml.4.5.0/opam @@ -0,0 +1,42 @@ +opam-version: "2.0" +synopsis: "A library for building correct HTML and SVG documents" +description: + "TyXML provides a set of convenient combinators that uses the OCaml type system to ensure the validity of the generated documents. TyXML can be used with any representation of HTML and SVG: the textual one, provided directly by this package, or DOM trees (`js_of_ocaml-tyxml`) virtual DOM (`virtual-dom`) and reactive or replicated trees (`eliom`). You can also create your own representation and use it to instantiate a new set of combinators." +maintainer: ["dev@ocsigen.org"] +authors: ["The ocsigen team"] +license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocsigen/tyxml" +doc: "https://ocsigen.org/tyxml/latest/manual/intro" +bug-reports: "https://github.com/ocsigen/tyxml/issues" +depends: [ + "dune" {>= "2.0"} + "ocaml" {>= "4.02"} + "alcotest" {with-test} + "re" {>= "1.5.0"} + "seq" + "uutf" {>= "1.0.0"} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocsigen/tyxml.git" +x-commit-hash: "ef431a4bceaefb2d9248e79092e6c1a1a9420095" +url { + src: + "https://github.com/ocsigen/tyxml/releases/download/4.5.0/tyxml-4.5.0.tbz" + checksum: [ + "sha256=c69accef5df4dd89d38f6aa0baad01e8fda4e9e98bb7dad61bec1452c5716068" + "sha512=772535441b09c393d53c27152e65f404a0a541aa0cea1bda899a8d751ab64d1729237e583618c3ff33d75e3865d53503d1ea413c6bbc8c68c413347efd1709b3" + ] +} diff --git a/esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json b/esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json new file mode 100644 index 0000000..f9bd9e0 --- /dev/null +++ b/esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json @@ -0,0 +1,3 @@ +{ + "build": "dune build -p easy-format" +} From 7335a604a9679cf04c820c1007a0359e23240970 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Mon, 30 May 2022 18:25:04 +0200 Subject: [PATCH 10/12] total rework of payload_signature --- lib/pnode/client.ml | 16 ++++++++-------- lib/pnode/client.mli | 16 ++++------------ lib/pnode/pnode.ml | 5 ++--- lib/pnode/pnode.mli | 4 +--- lib/pnode/server.ml | 9 +++------ test/commons.ml | 2 +- test/failure_detector_prop.ml | 3 +-- test/failure_detector_tests.ml | 6 ++---- test/node_tests.ml | 34 +++++++++++----------------------- 9 files changed, 33 insertions(+), 62 deletions(-) diff --git a/lib/pnode/client.ml b/lib/pnode/client.ml index ac346fe..aed29de 100644 --- a/lib/pnode/client.ml +++ b/lib/pnode/client.ml @@ -17,7 +17,7 @@ let peer_from { address; peers; _ } = let add_peer node (peer : Peer.t) = Base.Hashtbl.add node.peers ~key:peer.address ~data:peer -let create_request node recipient ~sign_payload ~key payload = +let create_request node recipient (payload, payload_signature) = Mutex.with_lock !node.current_request_id (fun id -> id := !id + 1; Lwt.return @@ -29,10 +29,10 @@ let create_request node recipient ~sign_payload ~key payload = sender = !node.address; recipient; payload; - payload_signature = sign_payload payload key; + payload_signature; }) -let create_response node request ~sign_payload ~key payload = +let create_response node request (payload, payload_signature) = Message. { category = Message.Response; @@ -41,7 +41,7 @@ let create_response node request ~sign_payload ~key payload = sender = !node.address; recipient = request.sender; payload; - payload_signature = sign_payload payload key; + payload_signature; } let send_to node message = @@ -77,12 +77,12 @@ let recv_next node = Mutex.unlock !node.socket; Lwt.return message -let request node ~sign_payload ~(key : bytes option) request recipient = - let%lwt message = create_request node recipient ~sign_payload ~key request in +let request node (request, payload_signature) recipient = + let%lwt message = create_request node recipient (request, payload_signature) in let%lwt () = send_to node message in let condition_var = Lwt_condition.create () in Hashtbl.add !node.request_table message.id condition_var; Lwt_condition.wait condition_var -let broadcast_request node recipients ~sign_payload ~(key : bytes option) req = - List.map (request node ~sign_payload ~key req) recipients +let broadcast_request node recipients (req, payload_signature) = + List.map (request node (req, payload_signature)) recipients diff --git a/lib/pnode/client.mli b/lib/pnode/client.mli index f1d2026..c9379fe 100644 --- a/lib/pnode/client.mli +++ b/lib/pnode/client.mli @@ -19,9 +19,7 @@ addressed to {i recipient} containing {i payload}. *) val create_request : node ref -> Address.t -> - sign_payload:(bytes -> bytes option -> bytes option) -> - key:bytes option -> - bytes -> + bytes * bytes option -> Message.t Lwt.t (** [create_response node request payload] creates a [Message.t] of the {i Response category} @@ -29,9 +27,7 @@ that responds to {i request} whose content is {i payload}. *) val create_response : node ref -> Message.t -> - sign_payload:(bytes -> bytes option -> bytes option) -> - key:bytes option -> - bytes -> + bytes * bytes option -> Message.t (** Sends a message via datagram from the given [Types.node] @@ -48,9 +44,7 @@ function blocks the current thread of execution until a response arrives. *) val request : node ref -> - sign_payload:(bytes -> bytes option -> bytes option) -> - key:bytes option -> - bytes -> + bytes * bytes option -> Address.t -> Message.t Lwt.t @@ -59,7 +53,5 @@ of recipients and collects the responses in a list of [Message.t Lwt.t]. *) val broadcast_request : node ref -> Address.t list -> - sign_payload:(bytes -> bytes option -> bytes option) -> - key:bytes option -> - bytes -> + bytes * bytes option -> Message.t Lwt.t list diff --git a/lib/pnode/pnode.ml b/lib/pnode/pnode.ml index 44b0ee2..81ebc78 100644 --- a/lib/pnode/pnode.ml +++ b/lib/pnode/pnode.ml @@ -6,8 +6,7 @@ module Client = Client module Failure_detector = Failure_detector module Inbox = Inbox -let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) - ~sign_payload ~key (address, port) = +let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) (address, port) = let open Util in let%lwt socket = Net.create_socket port in let peers = @@ -34,5 +33,5 @@ let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) }; peers; } in - Server.run node preprocess msg_handler sign_payload key; + Server.run node preprocess msg_handler; Lwt.return node diff --git a/lib/pnode/pnode.mli b/lib/pnode/pnode.mli index bd867b7..f973aa9 100644 --- a/lib/pnode/pnode.mli +++ b/lib/pnode/pnode.mli @@ -14,9 +14,7 @@ to initialize a server that runs asynchronously. Returns a reference to the node. *) val init : ?preprocess:(Message.t -> Message.t) -> - msg_handler:(Message.t -> bytes) -> + msg_handler:(Message.t -> bytes * bytes option) -> ?init_peers:Address.t list -> - sign_payload:(bytes -> bytes option -> bytes option) -> - key:bytes option -> string * int -> Types.node ref Lwt.t diff --git a/lib/pnode/server.ml b/lib/pnode/server.ml index c28d387..97e22b8 100644 --- a/lib/pnode/server.ml +++ b/lib/pnode/server.ml @@ -21,8 +21,7 @@ let handle_response request_table res = 4. Grab the next request if it exists and send it to the message handler along with the node's state 5. Send the encoded response from the message handler to the requester *) -let run node router msg_handler - (sign_payload : bytes -> bytes option -> bytes option) (key : bytes option) +let run node router (msg_handler: Message.t -> bytes * bytes option) = let rec server () = let%lwt message = Client.recv_next node in @@ -43,10 +42,8 @@ let run node router msg_handler let%lwt () = match request with | Some request -> - let response = - request - |> msg_handler - |> Client.create_response node request ~sign_payload ~key in + let res : bytes * bytes option = msg_handler request in + let response = Client.create_response node request res in let%lwt () = Client.send_to node response in Lwt.return () | None -> Lwt.return () in diff --git a/test/commons.ml b/test/commons.ml index 6937a9a..a5ca36e 100644 --- a/test/commons.ml +++ b/test/commons.ml @@ -26,5 +26,5 @@ module Commons = struct | Ping -> Pong | Get -> Success "Ok" | Insert _ -> Success "Successfully added value to state" in - Encoding.pack bin_writer_message (Response response) + (Encoding.pack bin_writer_message (Response response), None) end diff --git a/test/failure_detector_prop.ml b/test/failure_detector_prop.ml index fe5b1ca..aa3e3cb 100644 --- a/test/failure_detector_prop.ml +++ b/test/failure_detector_prop.ml @@ -6,8 +6,7 @@ module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) - ~key:None ("127.0.0.1", 3002)) + ("127.0.0.1", 3002)) let knuth_shuffle_size = QCheck2.Test.make ~count:1000 diff --git a/test/failure_detector_tests.ml b/test/failure_detector_tests.ml index 3bfb222..a239511 100644 --- a/test/failure_detector_tests.ml +++ b/test/failure_detector_tests.ml @@ -7,13 +7,11 @@ module SUT = Pollinate.PNode.Failure_detector let node_a = Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) - ~key:None ("127.0.0.1", 3003)) + ("127.0.0.1", 3003)) let node_b = Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) - ~key:None ("127.0.0.1", 3004)) + ("127.0.0.1", 3004)) let peer_b = Client.peer_from !node_b diff --git a/test/node_tests.ml b/test/node_tests.ml index 3aa028c..84232dd 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -10,8 +10,7 @@ module Node_tests = struct Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) - ~key:None ("127.0.0.1", 3000)) + ("127.0.0.1", 3000)) let peer_a = Client.peer_from !node_a @@ -19,8 +18,7 @@ module Node_tests = struct Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess ~msg_handler:Commons.msg_handler - ~sign_payload:(fun _p _k -> None) - ~key:None ("127.0.0.1", 3001)) + ("127.0.0.1", 3001)) let peer_b = Client.peer_from !node_b @@ -28,16 +26,12 @@ module Node_tests = struct of the other, returning the first element in the response of each *) let trade_messages () = let open Messages in - let get = Encoding.pack bin_writer_message (Request Get) in + let get = (Encoding.pack bin_writer_message (Request Get), None) in let%lwt { payload = res_from_b; _ } = - Client.request node_a - ~sign_payload:(fun _p _k -> None) - ~key:None get peer_b.address in + Client.request node_a get peer_b.address in let res_from_b = Encoding.unpack bin_read_response res_from_b in let%lwt { payload = res_from_a; _ } = - Client.request node_b - ~sign_payload:(fun _p _k -> None) - ~key:None get peer_a.address in + Client.request node_b get peer_a.address in let res_from_a = Encoding.unpack bin_read_response res_from_a in let res_from_b, res_from_a = match (res_from_b, res_from_a) with @@ -48,17 +42,13 @@ module Node_tests = struct let test_insert () = let open Messages in let insert_req = - Encoding.pack bin_writer_message (Request (Insert "something")) in + (Encoding.pack bin_writer_message (Request (Insert "something")), None) in let%lwt { payload = res_a; _ } = - Client.request node_a - ~sign_payload:(fun _p _k -> None) - ~key:None insert_req peer_b.address in + Client.request node_a insert_req peer_b.address in let res_a = Encoding.unpack bin_read_response res_a in - let get = Encoding.pack bin_writer_message (Request Get) in + let get = (Encoding.pack bin_writer_message (Request Get), None) in let%lwt { payload = b_state; _ } = - Client.request node_a - ~sign_payload:(fun _p _k -> None) - ~key:None get peer_b.address in + Client.request node_a get peer_b.address in let b_state = Encoding.unpack bin_read_response b_state in let res_a, b_state = match (res_a, b_state) with @@ -68,11 +58,9 @@ module Node_tests = struct let ping_pong () = let open Messages in - let ping = Encoding.pack bin_writer_message (Request Ping) in + let ping = (Encoding.pack bin_writer_message (Request Ping), None) in let%lwt { payload = pong; _ } = - Client.request node_a - ~sign_payload:(fun _p _k -> None) - ~key:None ping peer_b.address in + Client.request node_a ping peer_b.address in let pong = Encoding.unpack bin_read_response pong in let pong = match pong with From fa90c321f0b22780e3bde9c1f6e9e2d006c6eb70 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Tue, 31 May 2022 10:12:13 +0200 Subject: [PATCH 11/12] fix format --- lib/pnode/client.mli | 22 ++++------------------ lib/pnode/pnode.ml | 3 ++- lib/pnode/server.ml | 3 +-- test/node_tests.ml | 12 +++++------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/lib/pnode/client.mli b/lib/pnode/client.mli index c9379fe..a587e36 100644 --- a/lib/pnode/client.mli +++ b/lib/pnode/client.mli @@ -17,18 +17,11 @@ val add_peer : node -> Peer.t -> [`Duplicate | `Ok] (** [create_request node recipient payload] creates a [Message.t] of the {i Request category} addressed to {i recipient} containing {i payload}. *) val create_request : - node ref -> - Address.t -> - bytes * bytes option -> - Message.t Lwt.t + node ref -> Address.t -> bytes * bytes option -> Message.t Lwt.t (** [create_response node request payload] creates a [Message.t] of the {i Response category} that responds to {i request} whose content is {i payload}. *) -val create_response : - node ref -> - Message.t -> - bytes * bytes option -> - Message.t +val create_response : node ref -> Message.t -> bytes * bytes option -> Message.t (** Sends a message via datagram from the given [Types.node] to a specified peer within the [Message.t]. Construct a message with one of the @@ -42,16 +35,9 @@ val recv_next : node ref -> Message.t Lwt.t returns a promise holding the response from the peer. This function blocks the current thread of execution until a response arrives. *) -val request : - node ref -> - bytes * bytes option -> - Address.t -> - Message.t Lwt.t +val request : node ref -> bytes * bytes option -> Address.t -> Message.t Lwt.t (** Broadcasts a request containing the given payload to a list of recipients and collects the responses in a list of [Message.t Lwt.t]. *) val broadcast_request : - node ref -> - Address.t list -> - bytes * bytes option -> - Message.t Lwt.t list + node ref -> Address.t list -> bytes * bytes option -> Message.t Lwt.t list diff --git a/lib/pnode/pnode.ml b/lib/pnode/pnode.ml index 81ebc78..ad939c0 100644 --- a/lib/pnode/pnode.ml +++ b/lib/pnode/pnode.ml @@ -6,7 +6,8 @@ module Client = Client module Failure_detector = Failure_detector module Inbox = Inbox -let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) (address, port) = +let init ?(preprocess = fun m -> m) ~msg_handler ?(init_peers = []) + (address, port) = let open Util in let%lwt socket = Net.create_socket port in let peers = diff --git a/lib/pnode/server.ml b/lib/pnode/server.ml index 97e22b8..4dcf9c5 100644 --- a/lib/pnode/server.ml +++ b/lib/pnode/server.ml @@ -21,8 +21,7 @@ let handle_response request_table res = 4. Grab the next request if it exists and send it to the message handler along with the node's state 5. Send the encoded response from the message handler to the requester *) -let run node router (msg_handler: Message.t -> bytes * bytes option) - = +let run node router (msg_handler : Message.t -> bytes * bytes option) = let rec server () = let%lwt message = Client.recv_next node in let%lwt () = route node router message in diff --git a/test/node_tests.ml b/test/node_tests.ml index 84232dd..9ed70ae 100644 --- a/test/node_tests.ml +++ b/test/node_tests.ml @@ -9,16 +9,14 @@ module Node_tests = struct let node_a = Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess - ~msg_handler:Commons.msg_handler - ("127.0.0.1", 3000)) + ~msg_handler:Commons.msg_handler ("127.0.0.1", 3000)) let peer_a = Client.peer_from !node_a let node_b = Lwt_main.run (Pnode.init ~preprocess:Commons.preprocess - ~msg_handler:Commons.msg_handler - ("127.0.0.1", 3001)) + ~msg_handler:Commons.msg_handler ("127.0.0.1", 3001)) let peer_b = Client.peer_from !node_b @@ -42,7 +40,8 @@ module Node_tests = struct let test_insert () = let open Messages in let insert_req = - (Encoding.pack bin_writer_message (Request (Insert "something")), None) in + (Encoding.pack bin_writer_message (Request (Insert "something")), None) + in let%lwt { payload = res_a; _ } = Client.request node_a insert_req peer_b.address in let res_a = Encoding.unpack bin_read_response res_a in @@ -59,8 +58,7 @@ module Node_tests = struct let ping_pong () = let open Messages in let ping = (Encoding.pack bin_writer_message (Request Ping), None) in - let%lwt { payload = pong; _ } = - Client.request node_a ping peer_b.address in + let%lwt { payload = pong; _ } = Client.request node_a ping peer_b.address in let pong = Encoding.unpack bin_read_response pong in let pong = match pong with From 644d59bf5c949e76f3ae999d3535264138c89f67 Mon Sep 17 00:00:00 2001 From: Gauthier SEBILLE Date: Thu, 2 Jun 2022 14:17:30 +0200 Subject: [PATCH 12/12] woupsi --- lib/pnode/server.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pnode/server.ml b/lib/pnode/server.ml index 036ece9..e8463b2 100644 --- a/lib/pnode/server.ml +++ b/lib/pnode/server.ml @@ -122,5 +122,5 @@ let rec run node preprocessor msg_handler = (* Step 3 *) let%lwt () = Networking.disseminate node in (* Step 4 *) - let%lwt () = Lwt_unix.sleep 0.1 in + let%lwt () = Lwt_unix.sleep 0.001 in run node preprocessor msg_handler