Jbuilder: use --dev option

This commit is contained in:
Milo Davis 2017-11-13 14:29:28 +01:00 committed by Grégoire
parent 6a38f76956
commit 32a466556e
99 changed files with 210 additions and 295 deletions

View File

@ -1,15 +1,15 @@
all: all:
@jbuilder build tezos.install @jbuilder build tezos.install --dev
@cp _build/default/src/node_main.exe tezos-node @cp _build/default/src/node_main.exe tezos-node
@cp _build/default/src/client_main.exe tezos-client @cp _build/default/src/client_main.exe tezos-client
@cp _build/default/src/compiler_main.exe tezos-protocol-compiler @cp _build/default/src/compiler_main.exe tezos-protocol-compiler
doc-html: doc-html:
@jbuilder build @doc @jbuilder build @doc --dev
build-test: build-test:
@jbuilder build @buildtest @jbuilder build @buildtest --dev
test: test:
@jbuilder runtest @jbuilder runtest

View File

@ -16,7 +16,6 @@ open Json_schema
(*-- Assisted, schema directed input fill in --------------------------------*) (*-- Assisted, schema directed input fill in --------------------------------*)
exception Erroneous_construct
exception Unsupported_construct exception Unsupported_construct
type input = { type input = {
@ -132,7 +131,7 @@ let editor_fill_in schema =
random_fill_in schema >>= function random_fill_in schema >>= function
| Error msg -> Lwt.return (Error msg) | Error msg -> Lwt.return (Error msg)
| Ok json -> | Ok json ->
Lwt_io.(with_file Output tmp (fun fp -> Lwt_io.(with_file ~mode:Output tmp (fun fp ->
write_line fp (Data_encoding_ezjsonm.to_string json))) >>= fun () -> write_line fp (Data_encoding_ezjsonm.to_string json))) >>= fun () ->
edit () edit ()
and edit () = and edit () =
@ -160,7 +159,7 @@ let editor_fill_in schema =
Lwt.return (Error msg) Lwt.return (Error msg)
and reread () = and reread () =
(* finally reread the file *) (* finally reread the file *)
Lwt_io.(with_file Input tmp (fun fp -> read fp)) >>= fun text -> Lwt_io.(with_file ~mode:Input tmp (fun fp -> read fp)) >>= fun text ->
match Data_encoding_ezjsonm.from_string text with match Data_encoding_ezjsonm.from_string text with
| Ok r -> Lwt.return (Ok r) | Ok r -> Lwt.return (Ok r)
| Error msg -> Lwt.return (Error (Printf.sprintf "bad input: %s" msg)) | Error msg -> Lwt.return (Error (Printf.sprintf "bad input: %s" msg))
@ -350,7 +349,6 @@ let call_with_json url json (cctxt: Client_commands.context) =
"Failed to parse the provided json: %s\n%!" "Failed to parse the provided json: %s\n%!"
err err
| Ok json -> | Ok json ->
let open RPC.Description in
Client_rpcs.get_json cctxt.rpc_config `POST args json >>=? fun json -> Client_rpcs.get_json cctxt.rpc_config `POST args json >>=? fun json ->
cctxt.message "%a" cctxt.message "%a"
Json_repr.(pp (module Ezjsonm)) json >>= fun () -> Json_repr.(pp (module Ezjsonm)) json >>= fun () ->

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
open Client_commands open Client_commands
open Client_config
let unique_switch = let unique_switch =
Cli_entries.switch Cli_entries.switch

View File

@ -162,7 +162,7 @@ let alias_keys cctxt name =
let rec find_key = function let rec find_key = function
| [] -> return None | [] -> return None
| (key_name, pkh) :: tl -> | (key_name, pkh) :: tl ->
if String.(key_name = name) if key_name = name
then then
Public_key.find_opt cctxt name >>=? fun pkm -> Public_key.find_opt cctxt name >>=? fun pkm ->
Secret_key.find_opt cctxt name >>=? fun pks -> Secret_key.find_opt cctxt name >>=? fun pks ->

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
open Client_commands open Client_commands
open Logging.Client.Baking
let run cctxt ?max_priority ~delay ?min_date delegates ~endorsement ~denunciation ~baking = let run cctxt ?max_priority ~delay ?min_date delegates ~endorsement ~denunciation ~baking =
(* TODO really detach... *) (* TODO really detach... *)

View File

@ -9,7 +9,6 @@
open Logging.Client.Endorsement open Logging.Client.Endorsement
open Client_commands open Client_commands
open Cli_entries
module Ed25519 = Environment.Ed25519 module Ed25519 = Environment.Ed25519

View File

@ -20,7 +20,7 @@ let generate_seed_nonce () =
| Error _ -> assert false | Error _ -> assert false
| Ok nonce -> nonce | Ok nonce -> nonce
let rec forge_block_header let forge_block_header
cctxt block delegate_sk shell priority seed_nonce_hash = cctxt block delegate_sk shell priority seed_nonce_hash =
Client_proto_rpcs.Constants.stamp_threshold Client_proto_rpcs.Constants.stamp_threshold
cctxt block >>=? fun stamp_threshold -> cctxt block >>=? fun stamp_threshold ->
@ -620,6 +620,3 @@ let create
lwt_log_info "Starting baking daemon" >>= fun () -> lwt_log_info "Starting baking daemon" >>= fun () ->
worker_loop () >>= fun () -> worker_loop () >>= fun () ->
return () return ()
(* FIXME bug in ocamldep ?? *)
open Level

View File

@ -7,9 +7,7 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Cli_entries
open Client_commands open Client_commands
open Client_proto_contracts
let mine_block cctxt block let mine_block cctxt block
?force ?max_priority ?(free_baking=false) ?src_sk delegate = ?force ?max_priority ?(free_baking=false) ?src_sk delegate =

View File

@ -9,8 +9,6 @@
module Ed25519 = Environment.Ed25519 module Ed25519 = Environment.Ed25519
open Operation
type operation = { type operation = {
hash: Operation_hash.t ; hash: Operation_hash.t ;
content: Operation.t option content: Operation.t option

View File

@ -7,7 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Cli_entries
open Tezos_context open Tezos_context
let inject_seed_nonce_revelation rpc_config block ?force ?async nonces = let inject_seed_nonce_revelation rpc_config block ?force ?async nonces =
@ -22,8 +21,6 @@ let inject_seed_nonce_revelation rpc_config block ?force ?async nonces =
Client_node_rpcs.inject_operation rpc_config ?force ?async bytes >>=? fun oph -> Client_node_rpcs.inject_operation rpc_config ?force ?async bytes >>=? fun oph ->
return oph return oph
type Error_monad.error += Bad_revelation
let forge_seed_nonce_revelation let forge_seed_nonce_revelation
(cctxt: Client_commands.context) (cctxt: Client_commands.context)
block ?(force = false) nonces = block ?(force = false) nonces =

View File

@ -115,8 +115,8 @@ let tez_arg ~default ~parameter ~doc =
let tez_param ~name ~desc next = let tez_param ~name ~desc next =
Cli_entries.param Cli_entries.param
name ~name
(desc ^ " in \xEA\x9C\xA9\n" ^ tez_format) ~desc:(desc ^ " in \xEA\x9C\xA9\n" ^ tez_format)
(tez_parameter name) (tez_parameter name)
next next

View File

@ -134,7 +134,6 @@ let get_manager cctxt block source =
| None -> Client_proto_rpcs.Context.Contract.manager cctxt block source | None -> Client_proto_rpcs.Context.Contract.manager cctxt block source
let get_delegate cctxt block source = let get_delegate cctxt block source =
let open Client_keys in
match Contract.is_default source with match Contract.is_default source with
| Some hash -> return hash | Some hash -> return hash
| None -> | None ->

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Cli_entries
(* TODO locking... *) (* TODO locking... *)
type t = (Block_hash.t * Nonce.t) list type t = (Block_hash.t * Nonce.t) list

View File

@ -101,7 +101,6 @@ let commands () =
data_parameter data_parameter
@@ stop) @@ stop)
(fun (trace_stack, amount, no_print_source) program storage input cctxt -> (fun (trace_stack, amount, no_print_source) program storage input cctxt ->
let open Data_encoding in
let print_errors errs = let print_errors errs =
cctxt.warning "%a" cctxt.warning "%a"
(Michelson_v1_error_reporter.report_errors (Michelson_v1_error_reporter.report_errors
@ -147,7 +146,6 @@ let commands () =
@@ Program.source_param @@ Program.source_param
@@ stop) @@ stop)
(fun (show_types, emacs_mode, no_print_source) program cctxt -> (fun (show_types, emacs_mode, no_print_source) program cctxt ->
let open Data_encoding in
Client_proto_rpcs.Helpers.typecheck_code Client_proto_rpcs.Helpers.typecheck_code
cctxt.rpc_config cctxt.config.block program.expanded >>= fun res -> cctxt.rpc_config cctxt.config.block program.expanded >>= fun res ->
if emacs_mode then if emacs_mode then
@ -191,7 +189,6 @@ let commands () =
data_parameter data_parameter
@@ stop) @@ stop)
(fun no_print_source data exp_ty cctxt -> (fun no_print_source data exp_ty cctxt ->
let open Data_encoding in
Client_proto_rpcs.Helpers.typecheck_data cctxt.Client_commands.rpc_config Client_proto_rpcs.Helpers.typecheck_data cctxt.Client_commands.rpc_config
cctxt.config.block (data.expanded, exp_ty.expanded) >>= function cctxt.config.block (data.expanded, exp_ty.expanded) >>= function
| Ok () -> | Ok () ->
@ -214,7 +211,6 @@ let commands () =
data_parameter data_parameter
@@ stop) @@ stop)
(fun () data cctxt -> (fun () data cctxt ->
let open Data_encoding in
Client_proto_rpcs.Helpers.hash_data cctxt.Client_commands.rpc_config Client_proto_rpcs.Helpers.hash_data cctxt.Client_commands.rpc_config
cctxt.config.block (data.expanded) >>= function cctxt.config.block (data.expanded) >>= function
| Ok hash -> | Ok hash ->
@ -237,7 +233,6 @@ let commands () =
@@ Client_keys.Secret_key.alias_param @@ Client_keys.Secret_key.alias_param
@@ stop) @@ stop)
(fun () data (_, key) cctxt -> (fun () data (_, key) cctxt ->
let open Data_encoding in
Client_proto_rpcs.Helpers.hash_data cctxt.rpc_config Client_proto_rpcs.Helpers.hash_data cctxt.rpc_config
cctxt.config.block (data.expanded) >>= function cctxt.config.block (data.expanded) >>= function
| Ok hash -> | Ok hash ->

View File

@ -185,8 +185,6 @@ module Helpers = struct
module Forge = struct module Forge = struct
open Operation
module Manager = struct module Manager = struct
let operations cctxt let operations cctxt
block ~net_id ~branch ~source ?sourcePubKey ~counter ~fee operations = block ~net_id ~branch ~source ?sourcePubKey ~counter ~fee operations =

View File

@ -2,11 +2,13 @@
(library (library
((name client_embedded_alpha) ((name client_embedded_alpha)
(public_name tezos.client.embedded.alpha)
(libraries (tezos_embedded_protocol_alpha (libraries (tezos_embedded_protocol_alpha
tezos_embedded_raw_protocol_alpha tezos_embedded_raw_protocol_alpha
client_lib)) client_lib))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Micheline
type 'l node = ('l, string) Micheline.node type 'l node = ('l, string) Micheline.node
val expand : 'l node -> 'l node val expand : 'l node -> 'l node

View File

@ -17,7 +17,7 @@ let print_ty (type t) ppf (annot, (ty : t ty)) =
|> Micheline.strip_locations |> Micheline.strip_locations
|> Michelson_v1_printer.print_expr_unwrapped ppf |> Michelson_v1_printer.print_expr_unwrapped ppf
let rec print_stack_ty (type t) ?(depth = max_int) ppf (s : t stack_ty) = let print_stack_ty (type t) ?(depth = max_int) ppf (s : t stack_ty) =
let rec loop let rec loop
: type t. int -> Format.formatter -> t stack_ty -> unit : type t. int -> Format.formatter -> t stack_ty -> unit
= fun depth ppf -> function = fun depth ppf -> function

View File

@ -59,7 +59,7 @@ let parse_toplevel ?check source =
| [ ast ] -> ast | [ ast ] -> ast
| asts -> | asts ->
let start = min_point asts and stop = max_point asts in let start = min_point asts and stop = max_point asts in
Seq (Michelson_macros.{ start ; stop }, asts, None) in Seq ({ start ; stop }, asts, None) in
expand_all source ast expand_all source ast
let parse_expression ?check source = let parse_expression ?check source =

View File

@ -9,23 +9,21 @@
(** The result of parsing and expanding a Michelson V1 script or data. *) (** The result of parsing and expanding a Michelson V1 script or data. *)
type parsed = type parsed =
{ source : {
source : string ;
(** The original source code. *) (** The original source code. *)
string ; unexpanded : string Micheline.canonical ;
unexpanded :
(** Original expression with macros. *) (** Original expression with macros. *)
string Micheline.canonical ; expanded : Script.expr ;
expanded :
(** Expression with macros fully expanded. *) (** Expression with macros fully expanded. *)
Script.expr ;
expansion_table : expansion_table :
(int * (Micheline_parser.location * int list)) list ;
(** Associates unexpanded nodes to their parsing locations and (** Associates unexpanded nodes to their parsing locations and
the nodes expanded from it in the expanded expression. *) the nodes expanded from it in the expanded expression. *)
(int * (Micheline_parser.location * int list)) list ; unexpansion_table : (int * int) list ;
unexpansion_table :
(** Associates an expanded node to its source in the unexpanded (** Associates an expanded node to its source in the unexpanded
expression. *) expression. *)
(int * int) list } }
val parse_toplevel : ?check:bool -> string -> parsed tzresult val parse_toplevel : ?check:bool -> string -> parsed tzresult
val parse_expression : ?check:bool -> string -> parsed tzresult val parse_expression : ?check:bool -> string -> parsed tzresult

View File

@ -2,12 +2,14 @@
(library (library
((name client_embedded_genesis) ((name client_embedded_genesis)
(public_name tezos.client.embedded.genesis)
(libraries (tezos_embedded_raw_protocol_genesis (libraries (tezos_embedded_raw_protocol_genesis
tezos_embedded_protocol_genesis tezos_embedded_protocol_genesis
tezos_protocol_environment_alpha tezos_protocol_environment_alpha
client_lib)) client_lib))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -10,7 +10,8 @@
node_db node_db
node_updater node_updater
tezos_protocol_compiler)) tezos_protocol_compiler))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -9,7 +9,6 @@
(* Tezos Command line interface - Main Program *) (* Tezos Command line interface - Main Program *)
open Lwt.Infix
open Client_commands open Client_commands
open Error_monad open Error_monad

View File

@ -21,7 +21,8 @@
ocplib-endian ocplib-endian
ocplib-ocamlres ocplib-ocamlres
unix)) unix))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-opaque -opaque
-open Error_monad -open Error_monad
-open Hash -open Hash

View File

@ -53,7 +53,6 @@ let preloaded_cmis : (string, Env.Persistent_signature.t) Hashtbl.t =
(* Set hook *) (* Set hook *)
let () = let () =
let open Env.Persistent_signature in
Env.Persistent_signature.load := Env.Persistent_signature.load :=
(fun ~unit_name -> (fun ~unit_name ->
try Some (Hashtbl.find preloaded_cmis (String.capitalize_ascii unit_name)) try Some (Hashtbl.find preloaded_cmis (String.capitalize_ascii unit_name))
@ -154,12 +153,12 @@ let hash_file file =
let buf = BytesLabels.create buflen in let buf = BytesLabels.create buflen in
let fd = Unix.openfile file [Unix.O_RDONLY] 0o600 in let fd = Unix.openfile file [Unix.O_RDONLY] 0o600 in
let state = init ~size:32 () in let state = init ~size:32 () in
let rec loop () = let loop () =
match Unix.read fd buf 0 buflen with match Unix.read fd buf 0 buflen with
| 0 -> () | 0 -> ()
| nb_read -> | nb_read ->
Bytes.update state @@ Bytes.update state @@
if nb_read = buflen then buf else BytesLabels.sub buf 0 nb_read if nb_read = buflen then buf else BytesLabels.sub buf ~pos:0 ~len:nb_read
in in
loop () ; loop () ;
Unix.close fd ; Unix.close fd ;

View File

@ -52,5 +52,5 @@
(library (library
((name tezos_protocol_environment_sigs) ((name tezos_protocol_environment_sigs)
(public_name tezos.protocol_environment.sigs) (public_name tezos.protocol_environment.sigs)
(flags (:standard -nopervasives)) (flags (:standard -safe-string -w -9-32 -nopervasives))
(modules ("V1")))) (modules ("V1"))))

View File

@ -2,5 +2,6 @@
(executable (executable
((name sigs_packer) ((name sigs_packer)
(public_name tezos-protocol-environment-sigs-packer))) (public_name tezos-protocol-environment-sigs-packer)
(flags (:standard -w -9-32 -safe-string))))

View File

@ -14,7 +14,7 @@ let dump_file oc file =
let rec loop () = let rec loop () =
let len = input ic buf 0 buflen in let len = input ic buf 0 buflen in
if len <> 0 then begin if len <> 0 then begin
Printf.fprintf oc "%s" (if len = buflen then buf else Bytes.sub buf 0 len) ; Printf.fprintf oc "%s" (Bytes.to_string (if len = buflen then buf else Bytes.sub buf 0 len)) ;
loop () loop ()
end end
in in
@ -32,15 +32,15 @@ let include_mli oc file =
let unit = let unit =
String.capitalize_ascii String.capitalize_ascii
(Filename.chop_extension (Filename.basename file)) in (Filename.chop_extension (Filename.basename file)) in
Printf.fprintf stdout "module %s : sig\n" unit ; Printf.fprintf oc "module %s : sig\n" unit ;
Printf.fprintf stdout "# 1 %S\n" file ; Printf.fprintf oc "# 1 %S\n" file ;
dump_file stdout file ; dump_file oc file ;
Printf.fprintf stdout "end\n" ; Printf.fprintf oc "end\n" ;
if unit = "Result" then if unit = "Result" then
Printf.fprintf stdout Printf.fprintf oc
"type ('a, 'b) result = ('a, 'b) Result.result = \ "type ('a, 'b) result = ('a, 'b) Result.result = \
\ Ok of 'a | Error of 'b\n" ; \ Ok of 'a | Error of 'b\n" ;
if List.mem unit opened_modules then Printf.fprintf stdout "open %s\n" unit if List.mem unit opened_modules then Printf.fprintf oc "open %s\n" unit
let () = let () =
Printf.fprintf stdout "module type T = sig\n" ; Printf.fprintf stdout "module type T = sig\n" ;

View File

@ -95,11 +95,11 @@ module Protocol : sig
(** An OCaml source component of a protocol implementation. *) (** An OCaml source component of a protocol implementation. *)
and component = { and component = {
(** The OCaml module name. *) (* The OCaml module name. *)
name : string ; name : string ;
(** The OCaml interface source code *) (* The OCaml interface source code *)
interface : string option ; interface : string option ;
(** The OCaml source code *) (* The OCaml source code *)
implementation : string ; implementation : string ;
} }

View File

@ -64,11 +64,13 @@ val of_string: string -> t
external to_int64: t -> int64 = "ml_z_to_int64" external to_int64: t -> int64 = "ml_z_to_int64"
(** Converts to a 64-bit integer. May raise [Overflow]. *) (** Converts to a 64-bit integer. May raise [Overflow]. *)
external of_int64: int64 -> t = "ml_z_of_int64" external of_int64: int64 -> t = "ml_z_of_int64"
(** Converts from a 64-bit integer. *) (** Converts from a 64-bit integer. *)
external to_int: t -> int = "ml_z_to_int" external to_int: t -> int = "ml_z_to_int"
(** Converts to a base integer. May raise an [Overflow]. *) (** Converts to a base integer. May raise an [Overflow]. *)
external of_int: int -> t = "ml_z_of_int" [@@ noalloc] external of_int: int -> t = "ml_z_of_int" [@@ noalloc]
(** Converts from a base integer. *) (** Converts from a base integer. *)

View File

@ -4,7 +4,8 @@
((name compiler_main) ((name compiler_main)
(public_name tezos-protocol-compiler) (public_name tezos-protocol-compiler)
(libraries (tezos_protocol_compiler)) (libraries (tezos_protocol_compiler))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-linkall)) -linkall))
(modules (Compiler_main)))) (modules (Compiler_main))))
@ -15,7 +16,8 @@
tezos_embedded_protocol_genesis tezos_embedded_protocol_genesis
tezos_embedded_protocol_demo tezos_embedded_protocol_demo
tezos_embedded_protocol_alpha)) tezos_embedded_protocol_alpha))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-linkall)) -linkall))
(modules (Node_main)))) (modules (Node_main))))
@ -23,6 +25,7 @@
((name client_main) ((name client_main)
(public_name tezos-client) (public_name tezos-client)
(libraries (lwt utils client_lib client_embedded_genesis client_embedded_alpha)) (libraries (lwt utils client_lib client_embedded_genesis client_embedded_alpha))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-linkall)) -linkall))
(modules (Client_main)))) (modules (Client_main))))

View File

@ -11,7 +11,7 @@
minutils minutils
utils utils
)) ))
(flags (:standard -w +27-30-40@8)) (flags (:standard -w -9+27-30-32-40@8 -safe-string))
(wrapped false))) (wrapped false)))

View File

@ -7,7 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Error_monad
open Micheline open Micheline
type location = { comment : string option } type location = { comment : string option }

View File

@ -7,7 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Error_monad
open Micheline open Micheline
val print_string : Format.formatter -> string -> unit val print_string : Format.formatter -> string -> unit

View File

@ -159,7 +159,7 @@ end
module Option(P : S) = struct module Option(P : S) = struct
type t = P.t option type t = P.t option
let rec compare xs ys = let compare xs ys =
match xs, ys with match xs, ys with
| None, None -> 0 | None, None -> 0
| None, _ -> -1 | None, _ -> -1

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Utils
type json = type json =
[ `O of (string * json) list [ `O of (string * json) list
| `Bool of bool | `Bool of bool
@ -17,10 +15,6 @@ type json =
| `Null | `Null
| `String of string ] | `String of string ]
and document =
[ `O of (string * json) list
| `A of json list ]
type json_schema = Json_schema.schema type json_schema = Json_schema.schema
exception No_case_matched exception No_case_matched
@ -172,8 +166,7 @@ and 'a t = {
type 'a encoding = 'a t type 'a encoding = 'a t
let rec classify : type a l. a t -> Kind.t = fun e -> let rec classify : type a. a t -> Kind.t = fun e ->
let open Kind in
match e.encoding with match e.encoding with
(* Fixed *) (* Fixed *)
| Null -> `Fixed 0 | Null -> `Fixed 0
@ -222,8 +215,6 @@ module Json = struct
exception Parse_error of string exception Parse_error of string
type nonrec json = json
let wrap_error f = let wrap_error f =
fun str -> fun str ->
try f str try f str
@ -292,7 +283,7 @@ module Json = struct
| _ -> e | _ -> e
and lift_union_in_pair and lift_union_in_pair
: type a a_l b b_l. pair_builder -> Kind.t -> a t -> b t -> (a * b) t : type a b. pair_builder -> Kind.t -> a t -> b t -> (a * b) t
= fun b p e1 e2 -> = fun b p e1 e2 ->
match lift_union e1, lift_union e2 with match lift_union e1, lift_union e2 with
| e1, { encoding = Union (_kind, tag, cases) } -> | e1, { encoding = Union (_kind, tag, cases) } ->
@ -323,7 +314,7 @@ module Json = struct
cases) cases)
| e1, e2 -> b.build p e1 e2 | e1, e2 -> b.build p e1 e2
let rec json : type a l. a desc -> a Json_encoding.encoding = let rec json : type a. a desc -> a Json_encoding.encoding =
let open Json_encoding in let open Json_encoding in
function function
| Null -> null | Null -> null
@ -362,19 +353,19 @@ module Json = struct
| Delayed f -> get_json (f ()) | Delayed f -> get_json (f ())
and field_json and field_json
: type a l. a field -> a Json_encoding.field = : type a. a field -> a Json_encoding.field =
let open Json_encoding in let open Json_encoding in
function function
| Req (name, e) -> req name (get_json e) | Req (name, e) -> req name (get_json e)
| Opt (_, name, e) -> opt name (get_json e) | Opt (_, name, e) -> opt name (get_json e)
| Dft (name, e, d) -> dft name (get_json e) d | Dft (name, e, d) -> dft name (get_json e) d
and case_json : type a l. a case -> a Json_encoding.case = and case_json : type a. a case -> a Json_encoding.case =
let open Json_encoding in let open Json_encoding in
function function
| Case { encoding = e ; proj ; inj ; _ } -> case (get_json e) proj inj | Case { encoding = e ; proj ; inj ; _ } -> case (get_json e) proj inj
and get_json : type a l. a t -> a Json_encoding.encoding = fun e -> and get_json : type a. a t -> a Json_encoding.encoding = fun e ->
match e.json_encoding with match e.json_encoding with
| None -> | None ->
let json_encoding = json (lift_union e).encoding in let json_encoding = json (lift_union e).encoding in
@ -459,7 +450,7 @@ module Encoding = struct
let array e = dynamic_size (Variable.array e) let array e = dynamic_size (Variable.array e)
let list e = dynamic_size (Variable.list e) let list e = dynamic_size (Variable.list e)
let conv (type l) proj inj ?schema encoding = let conv proj inj ?schema encoding =
make @@ Conv { proj ; inj ; encoding ; schema } make @@ Conv { proj ; inj ; encoding ; schema }
let string_enum l = dynamic_size (Variable.string_enum l) let string_enum l = dynamic_size (Variable.string_enum l)
@ -546,7 +537,7 @@ module Encoding = struct
raw_merge_objs (obj2 f10 f9) (obj8 f8 f7 f6 f5 f4 f3 f2 f1) raw_merge_objs (obj2 f10 f9) (obj8 f8 f7 f6 f5 f4 f3 f2 f1)
let merge_objs o1 o2 = let merge_objs o1 o2 =
let rec is_obj : type a l. a t -> bool = fun e -> let rec is_obj : type a. a t -> bool = fun e ->
match e.encoding with match e.encoding with
| Obj _ -> true | Obj _ -> true
| Objs _ (* by construction *) -> true | Objs _ (* by construction *) -> true
@ -587,7 +578,7 @@ module Encoding = struct
raw_merge_tups (tup2 e10 e9) (tup8 e8 e7 e6 e5 e4 e3 e2 e1) raw_merge_tups (tup2 e10 e9) (tup8 e8 e7 e6 e5 e4 e3 e2 e1)
let merge_tups t1 t2 = let merge_tups t1 t2 =
let rec is_tup : type a l. a t -> bool = fun e -> let rec is_tup : type a. a t -> bool = fun e ->
match e.encoding with match e.encoding with
| Tup _ -> true | Tup _ -> true
| Tups _ (* by construction *) -> true | Tups _ (* by construction *) -> true
@ -745,7 +736,6 @@ module Binary = struct
} }
let rec length : type x. x t -> x -> int = fun e -> let rec length : type x. x t -> x -> int = fun e ->
let open Kind in
match e.encoding with match e.encoding with
(* Fixed *) (* Fixed *)
| Null -> fun _ -> 0 | Null -> fun _ -> 0
@ -780,7 +770,7 @@ let rec length : type x. x t -> x -> int = fun e ->
| Case { tag = None } -> None | Case { tag = None } -> None
| Case { encoding = e ; proj ; tag = Some _ } -> | Case { encoding = e ; proj ; tag = Some _ } ->
let length v = tag_size sz + length e v in let length v = tag_size sz + length e v in
Some (fun v -> Utils.map_option length (proj v)) in Some (fun v -> Utils.map_option ~f:length (proj v)) in
apply (Utils.filter_map case_length cases) apply (Utils.filter_map case_length cases)
| Mu (`Dynamic, _name, self) -> | Mu (`Dynamic, _name, self) ->
fun v -> length (self e) v fun v -> length (self e) v
@ -953,8 +943,7 @@ let rec length : type x. x t -> x -> int = fun e ->
end end
let rec write_rec let rec write_rec
: type a l. a t -> a -> MBytes.t -> int -> int = fun e -> : type a. a t -> a -> MBytes.t -> int -> int = fun e ->
let open Kind in
let open Writer in let open Writer in
match e.encoding with match e.encoding with
| Null -> (fun () _buf ofs -> ofs) | Null -> (fun () _buf ofs -> ofs)
@ -1159,8 +1148,7 @@ let rec length : type x. x t -> x -> int = fun e ->
end end
let rec read_rec : type a l. a t-> MBytes.t -> int -> int -> int * a = fun e -> let rec read_rec : type a. a t-> MBytes.t -> int -> int -> int * a = fun e ->
let open Kind in
let open Reader in let open Reader in
match e.encoding with match e.encoding with
| Null -> (fun _buf ofs _len -> ofs, ()) | Null -> (fun _buf ofs _len -> ofs, ())

View File

@ -7,5 +7,5 @@
lwt lwt
ocplib-json-typed.bson ocplib-json-typed.bson
ocplib-resto.directory)) ocplib-resto.directory))
(flags (:standard -w +27-30-40@8)) (flags (:standard -w -9+27-30-32-40@8 -safe-string))
(wrapped false))) (wrapped false)))

View File

@ -147,7 +147,7 @@ let rec remove_elem_from_list nb = function
| l when nb <= 0 -> l | l when nb <= 0 -> l
| _ :: tl -> remove_elem_from_list (nb - 1) tl | _ :: tl -> remove_elem_from_list (nb - 1) tl
let rec split_list_at n l = let split_list_at n l =
let rec split n acc = function let rec split n acc = function
| [] -> List.rev acc, [] | [] -> List.rev acc, []
| l when n <= 0 -> List.rev acc, l | l when n <= 0 -> List.rev acc, l
@ -196,7 +196,7 @@ let write_file ?(bin=false) fn contents =
let (<<) g f = fun a -> g (f a) let (<<) g f = fun a -> g (f a)
let rec (--) i j = let (--) i j =
let rec loop acc j = let rec loop acc j =
if j < i then acc else loop (j :: acc) (pred j) in if j < i then acc else loop (j :: acc) (pred j) in
loop [] j loop [] j

View File

@ -62,6 +62,7 @@ val filter_map: ('a -> 'b option) -> 'a list -> 'b list
(** [list_rev_sub l n] is [List.rev l] capped to max [n] elements *) (** [list_rev_sub l n] is [List.rev l] capped to max [n] elements *)
val list_rev_sub : 'a list -> int -> 'a list val list_rev_sub : 'a list -> int -> 'a list
(** [list_sub l n] is [l] capped to max [n] elements *) (** [list_sub l n] is [l] capped to max [n] elements *)
val list_sub: 'a list -> int -> 'a list val list_sub: 'a list -> int -> 'a list

View File

@ -10,7 +10,6 @@
(** Tezos - Versioned (key x value) store (over Irmin) *) (** Tezos - Versioned (key x value) store (over Irmin) *)
open Hash open Hash
open Logging.Db
module IrminPath = Irmin.Path.String_list module IrminPath = Irmin.Path.String_list
@ -95,9 +94,6 @@ let checkout_exn index key =
| Some p -> Lwt.return p | Some p -> Lwt.return p
exception Preexistent_context of Block_hash.t
exception Empty_head of Block_hash.t
let raw_commit ~time ~message context = let raw_commit ~time ~message context =
let info = let info =
Irmin.Info.v ~date:(Time.to_seconds time) ~author:"Tezos" message in Irmin.Info.v ~date:(Time.to_seconds time) ~author:"Tezos" message in
@ -116,6 +112,7 @@ let commit ~time ~message context =
Lwt_utils.Idle_waiter.force_idle Lwt_utils.Idle_waiter.force_idle
context.index.repack_scheduler context.index.repack_scheduler
begin fun () -> begin fun () ->
let open Logging.Db in
lwt_debug "begin git repack" >>= fun () -> lwt_debug "begin git repack" >>= fun () ->
let command = let command =
"git", "git",
@ -138,8 +135,6 @@ let commit ~time ~message context =
(*-- Generic Store Primitives ------------------------------------------------*) (*-- Generic Store Primitives ------------------------------------------------*)
type key = string list
let data_key key = "data" :: key let data_key key = "data" :: key
let undata_key = function let undata_key = function
| "data" :: key -> key | "data" :: key -> key

View File

@ -4,7 +4,8 @@
((name node_db) ((name node_db)
(public_name tezos.node.db) (public_name tezos.node.db)
(libraries (utils minutils leveldb irmin irmin-unix)) (libraries (utils minutils leveldb irmin irmin-unix))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -121,7 +121,6 @@ module MakeBytesStore
type t = S.t type t = S.t
type key = K.t type key = K.t
type value = MBytes.t
let to_path k = let to_path k =
let suffix = K.to_path k in let suffix = K.to_path k in
@ -228,8 +227,8 @@ module MakePersistentSet
| true -> dig K.length K.prefix x | true -> dig K.length K.prefix x
| false -> Lwt.return x | false -> Lwt.return x
let iter c ~f = fold c () (fun x () -> f x) let iter c ~f = fold c () ~f:(fun x () -> f x)
let elements c = fold c [] (fun p xs -> Lwt.return (p :: xs)) let elements c = fold c [] ~f:(fun p xs -> Lwt.return (p :: xs))
end end
@ -239,7 +238,7 @@ module MakeBufferedPersistentSet
include MakePersistentSet(S)(K) include MakePersistentSet(S)(K)
let read c = let read c =
fold c Set.empty (fun p set -> Lwt.return (Set.add p set)) fold c Set.empty ~f:(fun p set -> Lwt.return (Set.add p set))
let write c set = let write c set =
S.set c inited_key empty >>= fun c -> S.set c inited_key empty >>= fun c ->
@ -307,8 +306,8 @@ module MakePersistentMap
| true -> dig K.length K.prefix x | true -> dig K.length K.prefix x
| false -> Lwt.return x | false -> Lwt.return x
let iter c ~f = fold c () (fun k v () -> f k v) let iter c ~f = fold c () ~f:(fun k v () -> f k v)
let bindings c = fold c [] (fun k v acc -> Lwt.return ((k, v) :: acc)) let bindings c = fold c [] ~f:(fun k v acc -> Lwt.return ((k, v) :: acc))
end end
@ -317,7 +316,7 @@ module MakeBufferedPersistentMap
include MakePersistentMap(S)(K)(C) include MakePersistentMap(S)(K)(C)
let read c = fold c Map.empty (fun k v m -> Lwt.return (Map.add k v m)) let read c = fold c Map.empty ~f:(fun k v m -> Lwt.return (Map.add k v m))
let write c m = let write c m =
clear c >>= fun c -> clear c >>= fun c ->
@ -399,10 +398,7 @@ module MakeImperativeProxy
{ rdata: rdata ; { rdata: rdata ;
state: [ `Inited of Scheduler.data | `Initing of Scheduler.data Lwt.t ] ; state: [ `Inited of Scheduler.data | `Initing of Scheduler.data Lwt.t ] ;
wakener: Store.value Lwt.u } wakener: Store.value Lwt.u }
type store = Store.t
type state = Scheduler.state type state = Scheduler.state
type key = Store.key
type value = Store.value
type t = type t =
{ tbl : data Table.t ; { tbl : data Table.t ;
@ -594,7 +590,7 @@ module MakeHashResolver
| [d] -> | [d] ->
Store.list t [prefix] >>= fun prefixes -> Store.list t [prefix] >>= fun prefixes ->
Lwt_list.filter_map_p (fun prefix -> Lwt_list.filter_map_p (fun prefix ->
match remove_prefix d (List.hd (List.rev prefix)) with match remove_prefix ~prefix:d (List.hd (List.rev prefix)) with
| None -> Lwt.return_none | None -> Lwt.return_none
| Some _ -> Lwt.return (Some (build prefix)) | Some _ -> Lwt.return (Some (build prefix))
) prefixes ) prefixes

View File

@ -9,9 +9,6 @@
(** Tezos - Persistent structures on top of {!Context} *) (** Tezos - Persistent structures on top of {!Context} *)
open Lwt
(** Keys in (kex x value) database implementations *) (** Keys in (kex x value) database implementations *)
type key = string list type key = string list

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
module List = ListLabels module List = ListLabels
open Logging.Db
type t = LevelDB.db type t = LevelDB.db
type key = string list type key = string list

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Store_sigs
type t = Raw_store.t type t = Raw_store.t
type global_store = t type global_store = t

View File

@ -140,7 +140,7 @@ module Make_indexed_substore (S : STORE) (I : INDEX) = struct
list t prefix >>= fun prefixes -> list t prefix >>= fun prefixes ->
Lwt_list.map_p (function Lwt_list.map_p (function
| `Key prefix | `Dir prefix -> | `Key prefix | `Dir prefix ->
match Utils.remove_prefix d (List.hd (List.rev prefix)) with match Utils.remove_prefix ~prefix:d (List.hd (List.rev prefix)) with
| None -> Lwt.return_nil | None -> Lwt.return_nil
| Some _ -> loop (i+1) prefix []) | Some _ -> loop (i+1) prefix [])
prefixes prefixes

View File

@ -2,8 +2,10 @@
(library (library
((name node_main_lib) ((name node_main_lib)
(public_name tezos.node.main)
(libraries (utils minutils cmdliner node_net node_shell)) (libraries (utils minutils cmdliner node_net node_shell))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open P2p_types
let (//) = Filename.concat let (//) = Filename.concat
let home = let home =
@ -318,7 +316,7 @@ let update
Utils.first_some Utils.first_some
peer_table_size cfg.net.limits.max_known_peer_ids ; peer_table_size cfg.net.limits.max_known_peer_ids ;
binary_chunks_size = binary_chunks_size =
Utils.map_option (fun x -> x lsl 10) binary_chunks_size ; Utils.map_option ~f:(fun x -> x lsl 10) binary_chunks_size ;
} in } in
let net : net = { let net : net = {
expected_pow = expected_pow =

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open P2p_types
type t = { type t = {
data_dir : string ; data_dir : string ;
net : net ; net : net ;

View File

@ -47,7 +47,6 @@ let protocol_dir data_dir = data_dir // "protocol"
let lock_file data_dir = data_dir // "lock" let lock_file data_dir = data_dir // "lock"
let init_logger ?verbosity (log_config : Node_config_file.log) = let init_logger ?verbosity (log_config : Node_config_file.log) =
let open Logging in
begin begin
match verbosity with match verbosity with
| Some level -> | Some level ->
@ -61,7 +60,7 @@ let init_logger ?verbosity (log_config : Node_config_file.log) =
match Sys.getenv "LWT_LOG" with match Sys.getenv "LWT_LOG" with
| rules -> Some rules | rules -> Some rules
| exception Not_found -> log_config.rules in | exception Not_found -> log_config.rules in
Utils.iter_option Lwt_log_core.load_rules rules Utils.iter_option ~f:Lwt_log_core.load_rules rules
end ; end ;
Logging.init ~template:log_config.template log_config.output Logging.init ~template:log_config.template log_config.output
@ -202,7 +201,7 @@ let run ?verbosity ?sandbox (config : Node_config_file.t) =
lwt_log_notice "Shutting down the Tezos node..." >>= fun () -> lwt_log_notice "Shutting down the Tezos node..." >>= fun () ->
Node.shutdown node >>= fun () -> Node.shutdown node >>= fun () ->
lwt_log_notice "Shutting down the RPC server..." >>= fun () -> lwt_log_notice "Shutting down the RPC server..." >>= fun () ->
Lwt_utils.may RPC_server.shutdown rpc >>= fun () -> Lwt_utils.may ~f:RPC_server.shutdown rpc >>= fun () ->
lwt_log_notice "BYE (%d)" x >>= fun () -> lwt_log_notice "BYE (%d)" x >>= fun () ->
Logging.close () >>= fun () -> Logging.close () >>= fun () ->
return () return ()

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
open Cmdliner open Cmdliner
open P2p_types
open Logging.Node.Main open Logging.Node.Main
let (//) = Filename.concat let (//) = Filename.concat
@ -51,7 +50,7 @@ let wrap
let rpc_tls = let rpc_tls =
Utils.map_option Utils.map_option
(fun (cert, key) -> { Node_config_file.cert ; key }) ~f:(fun (cert, key) -> { Node_config_file.cert ; key })
rpc_tls in rpc_tls in
(* when `--expected-connections` is used, (* when `--expected-connections` is used,

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open P2p_types
type t = { type t = {
data_dir: string option ; data_dir: string option ;
config_file: string ; config_file: string ;

View File

@ -4,7 +4,8 @@
((name node_net) ((name node_net)
(public_name tezos.node.net) (public_name tezos.node.net)
(libraries (utils minutils conduit-lwt-unix cohttp cohttp-lwt-unix)) (libraries (utils minutils conduit-lwt-unix cohttp cohttp-lwt-unix))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -131,9 +131,9 @@ let may_create_discovery_worker _config pool =
let create_maintenance_worker limits pool disco = let create_maintenance_worker limits pool disco =
let bounds = let bounds =
bounds bounds
limits.min_connections ~min:limits.min_connections
limits.expected_connections ~expected:limits.expected_connections
limits.max_connections ~max:limits.max_connections
in in
P2p_maintenance.run P2p_maintenance.run
~connection_timeout:limits.authentification_timeout ~connection_timeout:limits.authentification_timeout
@ -214,7 +214,7 @@ module Real = struct
let get_metadata { pool } conn = let get_metadata { pool } conn =
P2p_connection_pool.Peer_ids.get_metadata pool conn P2p_connection_pool.Peer_ids.get_metadata pool conn
let rec recv _net conn = let recv _net conn =
P2p_connection_pool.read conn >>=? fun msg -> P2p_connection_pool.read conn >>=? fun msg ->
lwt_debug "message read from %a" lwt_debug "message read from %a"
Connection_info.pp Connection_info.pp
@ -611,7 +611,6 @@ module RPC = struct
(opt "last_miss" Time.encoding)) (opt "last_miss" Time.encoding))
let info_of_point_info i = let info_of_point_info i =
let open P2p_connection_pool in
let open P2p_connection_pool_types in let open P2p_connection_pool_types in
let state = match Point_info.State.get i with let state = match Point_info.State.get i with
| Requested _ -> Requested | Requested _ -> Requested

View File

@ -238,7 +238,7 @@ module Reader = struct
mutable worker: unit Lwt.t ; mutable worker: unit Lwt.t ;
} }
let rec read_message st init_mbytes = let read_message st init_mbytes =
let rec loop status = let rec loop status =
Lwt_unix.yield () >>= fun () -> Lwt_unix.yield () >>= fun () ->
let open Data_encoding.Binary in let open Data_encoding.Binary in
@ -306,8 +306,8 @@ module Reader = struct
end ; end ;
st.worker <- st.worker <-
Lwt_utils.worker "reader" Lwt_utils.worker "reader"
(fun () -> worker_loop st []) ~run:(fun () -> worker_loop st [])
(fun () -> Canceler.cancel st.canceler) ; ~cancel:(fun () -> Canceler.cancel st.canceler) ;
st st
let shutdown st = let shutdown st =
@ -327,7 +327,7 @@ module Writer = struct
binary_chunks_size: int ; (* in bytes *) binary_chunks_size: int ; (* in bytes *)
} }
let rec send_message st buf = let send_message st buf =
let rec loop = function let rec loop = function
| [] -> return () | [] -> return ()
| buf :: l -> | buf :: l ->
@ -429,8 +429,8 @@ module Writer = struct
end ; end ;
st.worker <- st.worker <-
Lwt_utils.worker "writer" Lwt_utils.worker "writer"
(fun () -> worker_loop st) ~run:(fun () -> worker_loop st)
(fun () -> Canceler.cancel st.canceler) ; ~cancel:(fun () -> Canceler.cancel st.canceler) ;
st st
let shutdown st = let shutdown st =
@ -480,9 +480,6 @@ let accept
end ; end ;
return conn return conn
exception Not_available
exception Connection_closed
let catch_closed_pipe f = let catch_closed_pipe f =
Lwt.catch f begin function Lwt.catch f begin function
| Lwt_pipe.Closed -> fail P2p_io_scheduler.Connection_closed | Lwt_pipe.Closed -> fail P2p_io_scheduler.Connection_closed

View File

@ -140,8 +140,8 @@ module Answerer = struct
} in } in
st.worker <- st.worker <-
Lwt_utils.worker "answerer" Lwt_utils.worker "answerer"
(fun () -> worker_loop st) ~run:(fun () -> worker_loop st)
(fun () -> Canceler.cancel canceler) ; ~cancel:(fun () -> Canceler.cancel canceler) ;
st st
let shutdown st = let shutdown st =
@ -682,8 +682,6 @@ let pool_stat { io_sched } =
(***************************************************************************) (***************************************************************************)
type error += Rejected of Peer_id.t type error += Rejected of Peer_id.t
type error += Unexpected_point_state
type error += Unexpected_peer_id_state
type error += Pending_connection type error += Pending_connection
type error += Connected type error += Connected
type error += Connection_closed = P2p_io_scheduler.Connection_closed type error += Connection_closed = P2p_io_scheduler.Connection_closed
@ -781,7 +779,7 @@ and authenticate pool ?point_info canceler fd point =
if incoming then if incoming then
Point.Table.remove pool.incoming point Point.Table.remove pool.incoming point
else else
iter_option Point_info.State.set_disconnected point_info ; iter_option ~f:Point_info.State.set_disconnected point_info ;
Lwt.return (Error err) Lwt.return (Error err)
end >>=? fun (info, auth_fd) -> end >>=? fun (info, auth_fd) ->
(* Authentication correct! *) (* Authentication correct! *)
@ -857,7 +855,7 @@ and authenticate pool ?point_info canceler fd point =
Lwt.return (Error err) Lwt.return (Error err)
end >>=? fun conn -> end >>=? fun conn ->
let id_point = let id_point =
match info.id_point, map_option Point_info.point point_info with match info.id_point, map_option ~f:Point_info.point point_info with
| (addr, _), Some (_, port) -> addr, Some port | (addr, _), Some (_, port) -> addr, Some port
| id_point, None -> id_point in | id_point, None -> id_point in
return return

View File

@ -337,7 +337,7 @@ module Log_event : sig
type t = type t =
(** Pool-level events *) (* Pool-level events *)
| Too_few_connections | Too_few_connections
| Too_many_connections | Too_many_connections
@ -347,10 +347,11 @@ module Log_event : sig
| Gc_points | Gc_points
(** Garbage collection of known point table has been triggered. *) (** Garbage collection of known point table has been triggered. *)
| Gc_peer_ids | Gc_peer_ids
(** Garbage collection of known peer_ids table has been triggered. *) (** Garbage collection of known peer_ids table has been triggered. *)
(** Connection-level events *) (* Connection-level events *)
| Incoming_connection of Point.t | Incoming_connection of Point.t
(** We accept(2)-ed an incoming connection *) (** We accept(2)-ed an incoming connection *)

View File

@ -300,7 +300,6 @@ module Peer_info = struct
| External_disconnection | External_disconnection
let kind_encoding = let kind_encoding =
let open Data_encoding in
Data_encoding.string_enum [ Data_encoding.string_enum [
"incoming_request", Accepting_request ; "incoming_request", Accepting_request ;
"rejecting_request", Rejecting_request ; "rejecting_request", Rejecting_request ;

View File

@ -7,7 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open P2p_types
include Logging.Make (struct let name = "p2p.discovery" end) include Logging.Make (struct let name = "p2p.discovery" end)
type t = () type t = ()

View File

@ -171,8 +171,8 @@ module Scheduler(IO : IO) = struct
} in } in
st.worker <- st.worker <-
Lwt_utils.worker IO.name Lwt_utils.worker IO.name
(fun () -> worker_loop st) ~run:(fun () -> worker_loop st)
(fun () -> Canceler.cancel st.canceler) ; ~cancel:(fun () -> Canceler.cancel st.canceler) ;
st st
let create_connection st in_param out_param canceler id = let create_connection st in_param out_param canceler id =
@ -418,7 +418,7 @@ let read_now conn ?pos ?len buf =
| None -> | None ->
try try
map_option map_option
(read_from conn ?pos ?len buf) ~f:(read_from conn ?pos ?len buf)
(Lwt_pipe.pop_now conn.read_queue) (Lwt_pipe.pop_now conn.read_queue)
with Lwt_pipe.Closed -> Some (Error [Connection_closed]) with Lwt_pipe.Closed -> Some (Error [Connection_closed])

View File

@ -185,8 +185,8 @@ let run ~connection_timeout bounds pool disco =
} in } in
st.maintain_worker <- st.maintain_worker <-
Lwt_utils.worker "maintenance" Lwt_utils.worker "maintenance"
(fun () -> worker_loop st) ~run:(fun () -> worker_loop st)
(fun () -> Canceler.cancel canceler) ; ~cancel:(fun () -> Canceler.cancel canceler) ;
st st
let maintain { just_maintained ; please_maintain } = let maintain { just_maintained ; please_maintain } =

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Logging.Net
module Canceler = Lwt_utils.Canceler module Canceler = Lwt_utils.Canceler
module Version = struct module Version = struct

View File

@ -62,8 +62,8 @@ let run ~backlog pool ?addr port =
} in } in
st.worker <- st.worker <-
Lwt_utils.worker "welcome" Lwt_utils.worker "welcome"
(fun () -> worker_loop st) ~run:(fun () -> worker_loop st)
(fun () -> Canceler.cancel st.canceler) ; ~cancel:(fun () -> Canceler.cancel st.canceler) ;
Lwt.return st Lwt.return st
end begin fun exn -> end begin fun exn ->
lwt_log_error lwt_log_error

View File

@ -54,7 +54,7 @@ let locked_set_head chain_store data block =
Lwt.return hash Lwt.return hash
in in
Chain_traversal.new_blocks Chain_traversal.new_blocks
data.current_head block >>= fun (ancestor, path) -> ~from_block:data.current_head ~to_block:block >>= fun (ancestor, path) ->
let ancestor = Block.hash ancestor in let ancestor = Block.hash ancestor in
pop_blocks ancestor data.current_head >>= fun () -> pop_blocks ancestor data.current_head >>= fun () ->
Lwt_list.fold_left_s push_block ancestor path >>= fun _ -> Lwt_list.fold_left_s push_block ancestor path >>= fun _ ->

View File

@ -38,10 +38,6 @@ module Make_raw
with type key := Hash.t with type key := Hash.t
and type value := Disk_table.value) = struct and type value := Disk_table.value) = struct
type key = Hash.t
type value = Disk_table.value
type param = Disk_table.store
module Request = struct module Request = struct
type param = Request_message.param request_param type param = Request_message.param request_param
let active { active } = active () let active { active } = active ()
@ -73,7 +69,6 @@ end
module Fake_operation_storage = struct module Fake_operation_storage = struct
type store = State.Net.t type store = State.Net.t
type key = Operation_hash.t
type value = Operation.t type value = Operation.t
let known _ _ = Lwt.return_false let known _ _ = Lwt.return_false
let read _ _ = Lwt.return (Error_monad.error_exn Not_found) let read _ _ = Lwt.return (Error_monad.error_exn Not_found)
@ -98,7 +93,6 @@ module Raw_operation =
module Block_header_storage = struct module Block_header_storage = struct
type store = State.Net.t type store = State.Net.t
type key = Block_hash.t
type value = Block_header.t type value = Block_header.t
let known = State.Block.known_valid let known = State.Block.known_valid
let read net_state h = let read net_state h =
@ -106,7 +100,7 @@ module Block_header_storage = struct
return (State.Block.header b) return (State.Block.header b)
let read_opt net_state h = let read_opt net_state h =
State.Block.read_opt net_state h >>= fun b -> State.Block.read_opt net_state h >>= fun b ->
Lwt.return (Utils.map_option State.Block.header b) Lwt.return (Utils.map_option ~f:State.Block.header b)
let read_exn net_state h = let read_exn net_state h =
State.Block.read_exn net_state h >>= fun b -> State.Block.read_exn net_state h >>= fun b ->
Lwt.return (State.Block.header b) Lwt.return (State.Block.header b)
@ -129,7 +123,6 @@ module Raw_block_header =
module Operation_hashes_storage = struct module Operation_hashes_storage = struct
type store = State.Net.t type store = State.Net.t
type key = Block_hash.t * int
type value = Operation_hash.t list type value = Operation_hash.t list
let known net_state (h, _) = State.Block.known_valid net_state h let known net_state (h, _) = State.Block.known_valid net_state h
let read net_state (h, i) = let read net_state (h, i) =
@ -207,7 +200,6 @@ end
module Operations_storage = struct module Operations_storage = struct
type store = State.Net.t type store = State.Net.t
type key = Block_hash.t * int
type value = Operation.t list type value = Operation.t list
let known net_state (h, _) = State.Block.known_valid net_state h let known net_state (h, _) = State.Block.known_valid net_state h
let read net_state (h, i) = let read net_state (h, i) =
@ -276,7 +268,6 @@ end
module Protocol_storage = struct module Protocol_storage = struct
type store = State.t type store = State.t
type key = Protocol_hash.t
type value = Protocol.t type value = Protocol.t
let known = State.Protocol.known let known = State.Protocol.known
let read = State.Protocol.read let read = State.Protocol.read
@ -351,8 +342,6 @@ let db { global_db } = global_db
module P2p_reader = struct module P2p_reader = struct
type t = p2p_reader
let may_activate global_db state net_id f = let may_activate global_db state net_id f =
match Net_id.Table.find state.peer_active_nets net_id with match Net_id.Table.find state.peer_active_nets net_id with
| net_db -> | net_db ->
@ -858,11 +847,6 @@ let watch_protocol { protocol_db } =
Raw_protocol.Table.watch protocol_db.table Raw_protocol.Table.watch protocol_db.table
module Raw = struct module Raw = struct
type 'a t =
| Bootstrap
| Advertise of P2p_types.Point.t list
| Message of 'a
| Disconnect
let encoding = P2p.Raw.encoding Message.cfg.encoding let encoding = P2p.Raw.encoding Message.cfg.encoding
let supported_versions = Message.cfg.versions let supported_versions = Message.cfg.versions
end end
@ -902,7 +886,6 @@ module Make
type t = Kind.t type t = Kind.t
type key = Table.key type key = Table.key
type value = Table.value type value = Table.value
type param = Table.param
let known t k = Table.known (Kind.proj t) k let known t k = Table.known (Kind.proj t) k
type error += Missing_data = Table.Missing_data type error += Missing_data = Table.Missing_data
type error += Canceled = Table.Canceled type error += Canceled = Table.Canceled

View File

@ -323,7 +323,6 @@ end = struct
include Logging.Make(struct let name = "node.distributed_db.scheduler." ^ Hash.name end) include Logging.Make(struct let name = "node.distributed_db.scheduler." ^ Hash.name end)
type key = Hash.t type key = Hash.t
type param = Request.param
type t = { type t = {
param: Request.param ; param: Request.param ;

View File

@ -4,7 +4,8 @@
((name node_shell) ((name node_shell)
(public_name tezos.node.shell) (public_name tezos.node.shell)
(libraries (utils minutils node_net node_db node_updater ezjsonm ocplib-json-typed.bson)) (libraries (utils minutils node_net node_db node_updater ezjsonm ocplib-json-typed.bson))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -619,7 +619,7 @@ module RPC = struct
let block_stream, stopper = let block_stream, stopper =
Validator.new_head_watcher node.mainnet_validator in Validator.new_head_watcher node.mainnet_validator in
let first_run = ref true in let first_run = ref true in
let rec next () = let next () =
if !first_run then begin if !first_run then begin
first_run := false ; first_run := false ;
Chain.head node.mainnet_net >>= fun head -> Chain.head node.mainnet_net >>= fun head ->

View File

@ -40,8 +40,6 @@ let list_pendings ~from_block ~to_block old_mempool =
(** Worker *) (** Worker *)
exception Invalid_operation of Operation_hash.t
open Prevalidation open Prevalidation
type t = { type t = {
@ -73,7 +71,7 @@ let create net_db =
Chain.head net_state >>= fun head -> Chain.head net_state >>= fun head ->
let timestamp = ref (Time.now ()) in let timestamp = ref (Time.now ()) in
(start_prevalidation head !timestamp () >|= ref) >>= fun validation_state -> (start_prevalidation ~predecessor:head ~timestamp:!timestamp () >|= ref) >>= fun validation_state ->
let pending = Operation_hash.Table.create 53 in let pending = Operation_hash.Table.create 53 in
let head = ref head in let head = ref head in
let operations = ref empty_result in let operations = ref empty_result in
@ -92,7 +90,7 @@ let create net_db =
Lwt.return_unit in Lwt.return_unit in
let reset_validation_state head timestamp = let reset_validation_state head timestamp =
start_prevalidation head timestamp () >>= fun state -> start_prevalidation ~predecessor:head ~timestamp () >>= fun state ->
validation_state := state; validation_state := state;
Lwt.return_unit in Lwt.return_unit in

View File

@ -365,9 +365,6 @@ let apply_block net_state db
module Context_db = struct module Context_db = struct
type key = Block_hash.t
type value = State.Block.t
type data = type data =
{ validator: net_validator ; { validator: net_validator ;
state: [ `Inited of Block_header.t tzresult state: [ `Inited of Block_header.t tzresult
@ -608,7 +605,7 @@ module Context_db = struct
end end
let rec create_validator ?parent worker ?max_child_ttl state db net = let create_validator ?parent worker ?max_child_ttl state db net =
let net_id = State.Net.id net in let net_id = State.Net.id net in
let net_db = Distributed_db.activate db net in let net_db = Distributed_db.activate db net in
@ -776,8 +773,6 @@ let rec create_validator ?parent worker ?max_child_ttl state db net =
Lwt.return v Lwt.return v
type error += Unknown_network of Net_id.t
let create state db = let create state db =
let validators : net_validator Lwt.t Net_id.Table.t = let validators : net_validator Lwt.t Net_id.Table.t =

View File

@ -4,7 +4,8 @@
((name node_updater) ((name node_updater)
(public_name tezos.node.updater) (public_name tezos.node.updater)
(libraries (utils minutils micheline tezos_protocol_compiler node_db dynlink)) (libraries (utils minutils micheline tezos_protocol_compiler node_db dynlink))
(flags (:standard -w +27-30-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -27,7 +27,7 @@ let () =
(library (library
((name tezos_protocol_environment_alpha) ((name tezos_protocol_environment_alpha)
(public_name tezos.protocol_environment.alpha) (public_name tezos.protocol_environment.alpha)
(library_flags (:standard -linkall)) (library_flags (:standard -linkall -w -9 -safe-string))
(libraries (node_updater)) (libraries (node_updater))
(modules (Environment)))) (modules (Environment))))
@ -36,8 +36,8 @@ let () =
(public_name tezos.embedded_raw_protocol.alpha) (public_name tezos.embedded_raw_protocol.alpha)
(libraries (tezos_protocol_environment_alpha)) (libraries (tezos_protocol_environment_alpha))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -nopervasives -nostdlib (flags (:standard -nopervasives -nostdlib -safe-string
-w +a-4-6-7-9-29-40..42-44-45-48 -w +a-4-6-7-9-29-32-40..42-44-45-48
-warn-error -a+8 -warn-error -a+8
-open Tezos_protocol_environment_alpha__Environment -open Tezos_protocol_environment_alpha__Environment
-open Error_monad -open Error_monad
@ -48,7 +48,7 @@ let () =
(library (library
((name tezos_embedded_protocol_alpha) ((name tezos_embedded_protocol_alpha)
(public_name tezos.embedded_protocol.alpha) (public_name tezos.embedded_protocol.alpha)
(library_flags (:standard -linkall)) (library_flags (:standard -linkall -w -9-32 -safe-string))
(libraries (tezos_embedded_raw_protocol_alpha node_shell)) (libraries (tezos_embedded_raw_protocol_alpha node_shell))
(modules (Registerer)))) (modules (Registerer))))

View File

@ -32,8 +32,8 @@
((name tezos_embedded_raw_protocol_demo) ((name tezos_embedded_raw_protocol_demo)
(libraries (tezos_protocol_environment_demo)) (libraries (tezos_protocol_environment_demo))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -nopervasives -nostdlib (flags (:standard -nopervasives -nostdlib -safe-string
-w +a-4-6-7-9-29-40..42-44-45-48 -w +a-4-6-7-9-29-32-40..42-44-45-48
-warn-error -a+8 -warn-error -a+8
-open Tezos_protocol_environment_demo__Environment -open Tezos_protocol_environment_demo__Environment
-open Error_monad -open Error_monad
@ -43,7 +43,7 @@
(library (library
((name tezos_embedded_protocol_demo) ((name tezos_embedded_protocol_demo)
(library_flags (:standard -linkall)) (library_flags (:standard -linkall -w -9-32 -safe-string))
(libraries (tezos_embedded_raw_protocol_demo node_shell)) (libraries (tezos_embedded_raw_protocol_demo node_shell))
(modules (Registerer)))) (modules (Registerer))))

View File

@ -25,15 +25,17 @@
(library (library
((name tezos_protocol_environment_genesis) ((name tezos_protocol_environment_genesis)
(public_name tezos.protocol_environment.genesis)
(libraries (node_updater)) (libraries (node_updater))
(modules (Environment)))) (modules (Environment))))
(library (library
((name tezos_embedded_raw_protocol_genesis) ((name tezos_embedded_raw_protocol_genesis)
(public_name tezos.embedded_raw_protocol.genesis)
(libraries (tezos_protocol_environment_genesis)) (libraries (tezos_protocol_environment_genesis))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -nopervasives -nostdlib (flags (:standard -nopervasives -nostdlib -safe-string
-w +a-4-6-7-9-29-40..42-44-45-48 -w +a-4-6-7-9-29-32-40..42-44-45-48
-warn-error -a+8 -warn-error -a+8
-open Tezos_protocol_environment_genesis__Environment -open Tezos_protocol_environment_genesis__Environment
-open Error_monad -open Error_monad
@ -43,7 +45,8 @@
(library (library
((name tezos_embedded_protocol_genesis) ((name tezos_embedded_protocol_genesis)
(library_flags (:standard -linkall)) (public_name tezos.embedded_protocol.genesis)
(library_flags (:standard -linkall -w -9-32 -safe-string))
(libraries (tezos_embedded_raw_protocol_genesis node_shell)) (libraries (tezos_embedded_raw_protocol_genesis node_shell))
(modules (Registerer)))) (modules (Registerer))))

View File

@ -168,8 +168,8 @@ module MakeEncodings(E: sig
let check_ambiguous_prefix prefix encodings = let check_ambiguous_prefix prefix encodings =
List.iter List.iter
(fun (Encoding { encoded_prefix = s }) -> (fun (Encoding { encoded_prefix = s }) ->
if remove_prefix s prefix <> None || if remove_prefix ~prefix:s prefix <> None ||
remove_prefix prefix s <> None then remove_prefix ~prefix s <> None then
Format.ksprintf invalid_arg Format.ksprintf invalid_arg
"Base58.register_encoding: duplicate prefix: %S, %S." s prefix) "Base58.register_encoding: duplicate prefix: %S, %S." s prefix)
encodings encodings

View File

@ -287,14 +287,14 @@ let command ?group ~desc options params handler =
(* Param combinators *) (* Param combinators *)
let string ~name ~desc next = let string ~name ~desc next =
param name desc { converter=(fun _ s -> return s) ; autocomplete=None } next param ~name ~desc { converter=(fun _ s -> return s) ; autocomplete=None } next
(* Help commands *) (* Help commands *)
let help_group = let help_group =
{ name = "man" ; { name = "man" ;
title = "Access the documentation" } title = "Access the documentation" }
let rec string_contains ~needle ~haystack = let string_contains ~needle ~haystack =
try try
Some (Str.search_forward (Str.regexp_string needle) haystack 0) Some (Str.search_forward (Str.regexp_string needle) haystack 0)
with Not_found -> with Not_found ->
@ -539,7 +539,7 @@ let has_args : type a ctx. (a, ctx) args -> bool = function
| NoArgs -> false | NoArgs -> false
| AddArg (_,_) -> true | AddArg (_,_) -> true
let rec print_options_brief (type ctx) = let print_options_brief (type ctx) =
let help_option : let help_option :
type a. Format.formatter -> (a, ctx) arg -> unit = type a. Format.formatter -> (a, ctx) arg -> unit =
fun ppf -> function fun ppf -> function
@ -631,7 +631,7 @@ let contains_params_args :
in help params in help params
let print_command : let print_command :
type a ctx ret. ?prefix: string -> ?highlights:string list -> Format.formatter -> (ctx, ret) command -> unit type ctx ret. ?prefix: string -> ?highlights:string list -> Format.formatter -> (ctx, ret) command -> unit
= fun ?(prefix = "") ?(highlights=[]) ppf (Command { params ; desc ; options=Argument { spec } }) -> = fun ?(prefix = "") ?(highlights=[]) ppf (Command { params ; desc ; options=Argument { spec } }) ->
if contains_params_args params spec if contains_params_args params spec
then then
@ -686,7 +686,6 @@ let command_args_help ppf command =
command command
let usage let usage
(type ctx) (type ret)
ppf ppf
?global_options ?global_options
~details ~details
@ -727,7 +726,7 @@ let usage
Format.fprintf ppf "@]" Format.fprintf ppf "@]"
let command_usage let command_usage
(type ctx) (type ret) ppf commands = ppf commands =
let exe = Filename.basename Sys.executable_name in let exe = Filename.basename Sys.executable_name in
let prefix = exe ^ " [global options] " in let prefix = exe ^ " [global options] " in
Format.fprintf ppf Format.fprintf ppf

View File

@ -21,6 +21,7 @@ val parameter : ?autocomplete:('ctx -> string list tzresult Lwt.t) ->
(** {2 Flags and Options } *) (** {2 Flags and Options } *)
(** {3 Options and Switches } *) (** {3 Options and Switches } *)
(** Type for option or switch *) (** Type for option or switch *)
type ('a, 'ctx) arg type ('a, 'ctx) arg
@ -37,6 +38,7 @@ val default_arg : doc:string -> parameter:string ->
default:string -> default:string ->
('p, 'ctx) parameter -> ('p, 'ctx) parameter ->
('p, 'ctx) arg ('p, 'ctx) arg
(** Create a boolean switch. (** Create a boolean switch.
The value will be set to [true] if the switch is provided and [false] if it is not. *) The value will be set to [true] if the switch is provided and [false] if it is not. *)
val switch : doc:string -> parameter:string -> val switch : doc:string -> parameter:string ->
@ -144,6 +146,7 @@ val prefix:
string -> string ->
('a, 'ctx, 'ret) params -> ('a, 'ctx, 'ret) params ->
('a, 'ctx, 'ret) params ('a, 'ctx, 'ret) params
(** Multiple words given in sequence for a command line *) (** Multiple words given in sequence for a command line *)
val prefixes: val prefixes:
string list -> string list ->
@ -154,6 +157,7 @@ val prefixes:
val fixed: val fixed:
string list -> string list ->
('ctx -> 'ret tzresult Lwt.t, 'ctx, 'ret) params ('ctx -> 'ret tzresult Lwt.t, 'ctx, 'ret) params
(** End the description of the command line *) (** End the description of the command line *)
val stop: val stop:
('ctx -> 'ret tzresult Lwt.t, 'ctx, 'ret) params ('ctx -> 'ret tzresult Lwt.t, 'ctx, 'ret) params

View File

@ -7,8 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Utils
(** Tezos - X25519/XSalsa20-Poly1305 cryptography *) (** Tezos - X25519/XSalsa20-Poly1305 cryptography *)
type secret_key = Sodium.Box.secret_key type secret_key = Sodium.Box.secret_key
@ -16,7 +14,6 @@ type public_key = Sodium.Box.public_key
type channel_key = Sodium.Box.channel_key type channel_key = Sodium.Box.channel_key
type nonce = Sodium.Box.nonce type nonce = Sodium.Box.nonce
type target = Z.t type target = Z.t
exception TargetNot256Bit
module Public_key_hash = Hash.Make_Blake2B (Base58) (struct module Public_key_hash = Hash.Make_Blake2B (Base58) (struct
let name = "Crypto_box.Public_key_hash" let name = "Crypto_box.Public_key_hash"

View File

@ -40,8 +40,6 @@ module Make() = struct
pp: Format.formatter -> 'err -> unit ; } -> pp: Format.formatter -> 'err -> unit ; } ->
error_kind error_kind
type registred_errors = error_kind list
let error_kinds let error_kinds
: error_kind list ref : error_kind list ref
= ref [] = ref []
@ -281,7 +279,7 @@ module Make() = struct
filter_map_s f t >>=? fun rt -> filter_map_s f t >>=? fun rt ->
return (rh :: rt) return (rh :: rt)
let rec filter_map_p f l = let filter_map_p f l =
match l with match l with
| [] -> return [] | [] -> return []
| h :: t -> | h :: t ->

View File

@ -7,14 +7,11 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Error_monad
let (//) = Filename.concat let (//) = Filename.concat
let (>>=) = Lwt.bind let (>>=) = Lwt.bind
let (>|=) = Lwt.(>|=) let (>|=) = Lwt.(>|=)
open Error_monad open Error_monad
open Utils
let () = let () =
let expected_primitive = "blake2b" let expected_primitive = "blake2b"
@ -549,7 +546,6 @@ module Generic_hash =
module Net_id = struct module Net_id = struct
type t = string type t = string
type net_id = t
let name = "Net_id" let name = "Net_id"
let title = "Network identifier" let title = "Network identifier"

View File

@ -18,7 +18,7 @@
;; Internal ;; Internal
minutils minutils
)) ))
(flags (:standard -w +27-30-40@8)) (flags (:standard -w -9+27-30-32-40@8 -safe-string))
(wrapped false))) (wrapped false)))

View File

@ -30,7 +30,7 @@ let notify_put dropbox =
dropbox.put_waiter <- None ; dropbox.put_waiter <- None ;
Lwt.wakeup_later w () Lwt.wakeup_later w ()
let rec put dropbox elt = let put dropbox elt =
if dropbox.closed then if dropbox.closed then
raise Closed raise Closed
else begin else begin

View File

@ -91,7 +91,7 @@ let rec push ({ closed ; queue ; current_size ;
wait_pop q >>= fun () -> wait_pop q >>= fun () ->
push q elt push q elt
let rec push_now ({ closed ; queue ; compute_size ; let push_now ({ closed ; queue ; compute_size ;
current_size ; max_size current_size ; max_size
} as q) elt = } as q) elt =
if closed then raise Closed ; if closed then raise Closed ;

View File

@ -358,7 +358,7 @@ let stable_sort cmp l =
let sort = stable_sort let sort = stable_sort
let rec read_bytes ?(pos = 0) ?len fd buf = let read_bytes ?(pos = 0) ?len fd buf =
let len = match len with None -> Bytes.length buf - pos | Some l -> l in let len = match len with None -> Bytes.length buf - pos | Some l -> l in
let rec inner pos len = let rec inner pos len =
if len = 0 then if len = 0 then

View File

@ -7,7 +7,6 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Error_monad
open CalendarLib open CalendarLib
module T = struct module T = struct

View File

@ -3,4 +3,5 @@
(library (library
((name test_lib) ((name test_lib)
(libraries (kaputt utils minutils)) (libraries (kaputt utils minutils))
(wrapped false))) (wrapped false)
(flags (:standard -w -9-32 -safe-string))))

View File

@ -38,7 +38,7 @@ let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () =
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
let exe = let exe =
let (//) = Filename.concat in let (//) = Filename.concat in
Filename.(Sys.getcwd () // ".." // "src" // "node_main.exe") in Sys.getcwd () // ".." // "src" // "node_main.exe" in
let pid = let pid =
Unix.create_process exe Unix.create_process exe
[| "tezos-node" ; [| "tezos-node" ;

View File

@ -5,7 +5,9 @@
test_p2p_connection_pool test_p2p_connection_pool
test_p2p_io_scheduler)) test_p2p_io_scheduler))
(libraries (minutils utils test_lib node_net)) (libraries (minutils utils test_lib node_net))
(flags (:standard -linkall (flags (:standard -w -9-32
-linkall
-safe-string
-open Error_monad -open Error_monad
-open Hash -open Hash
-open Utils -open Utils

View File

@ -370,7 +370,6 @@ let spec = Arg.[
] ]
let main () = let main () =
let open Utils in
let anon_fun _num_peers = raise (Arg.Bad "No anonymous argument.") in let anon_fun _num_peers = raise (Arg.Bad "No anonymous argument.") in
let usage_msg = "Usage: %s.\nArguments are:" in let usage_msg = "Usage: %s.\nArguments are:" in
Arg.parse spec anon_fun usage_msg ; Arg.parse spec anon_fun usage_msg ;

View File

@ -10,7 +10,8 @@
client_lib client_lib
client_embedded_genesis client_embedded_genesis
client_embedded_alpha)) client_embedded_alpha))
(flags (:standard -open Error_monad (flags (:standard -w -9-32 -safe-string
-open Error_monad
-open Hash -open Hash
-open Tezos_data -open Tezos_data
-open Tezos_protocol_environment_alpha -open Tezos_protocol_environment_alpha

View File

@ -171,6 +171,7 @@ module Assert : sig
val unknown_contract : msg:string -> 'a tzresult -> unit val unknown_contract : msg:string -> 'a tzresult -> unit
(** [unknown_contract ~msg result] raises if result is not a (** [unknown_contract ~msg result] raises if result is not a
[Storage_error]. *) [Storage_error]. *)
val non_existing_contract : msg:string -> 'a tzresult -> unit val non_existing_contract : msg:string -> 'a tzresult -> unit
val balance_too_low : msg:string -> 'a tzresult -> unit val balance_too_low : msg:string -> 'a tzresult -> unit
val non_spendable : msg:string -> 'a tzresult -> unit val non_spendable : msg:string -> 'a tzresult -> unit

View File

@ -11,7 +11,9 @@
tezos_embedded_protocol_demo tezos_embedded_protocol_demo
tezos_embedded_protocol_alpha tezos_embedded_protocol_alpha
tezos_embedded_protocol_genesis)) tezos_embedded_protocol_genesis))
(flags (:standard -open Error_monad (flags (:standard -w -9-32
-safe-string
-open Error_monad
-open Hash -open Hash
-open Utils -open Utils
-open Tezos_data)))) -open Tezos_data))))

View File

@ -93,7 +93,7 @@ type t = {
let wrap_context_init f base_dir = let wrap_context_init f base_dir =
let root = base_dir // "context" in let root = base_dir // "context" in
Context.init root >>= fun idx -> Context.init ~root ?patch_context:None >>= fun idx ->
Context.commit_genesis idx Context.commit_genesis idx
~net_id ~net_id
~time:genesis.time ~time:genesis.time

View File

@ -217,7 +217,6 @@ let test_hashset (type t)
(Make_substore(Store)(struct let name = ["test_set"] end)) (Make_substore(Store)(struct let name = ["test_set"] end))
(Block_hash) (Block_hash)
(BlockSet) in (BlockSet) in
let open BlockSet in
let bhset : BlockSet.t = BlockSet.add bh2 (BlockSet.add bh1 BlockSet.empty) in let bhset : BlockSet.t = BlockSet.add bh2 (BlockSet.add bh1 BlockSet.empty) in
StoreSet.store_all s bhset >>= fun () -> StoreSet.store_all s bhset >>= fun () ->
StoreSet.read_all s >>= fun bhset' -> StoreSet.read_all s >>= fun bhset' ->
@ -227,8 +226,8 @@ let test_hashset (type t)
StoreSet.store_all s bhset2 >>= fun () -> StoreSet.store_all s bhset2 >>= fun () ->
StoreSet.read_all s >>= fun bhset2' -> StoreSet.read_all s >>= fun bhset2' ->
Assert.equal_block_set ~msg:__LOC__ bhset2 bhset2' ; Assert.equal_block_set ~msg:__LOC__ bhset2 bhset2' ;
StoreSet.fold s BlockSet.empty StoreSet.fold s ~init:BlockSet.empty
(fun bh acc -> Lwt.return (BlockSet.add bh acc)) >>= fun bhset2'' -> ~f:(fun bh acc -> Lwt.return (BlockSet.add bh acc)) >>= fun bhset2'' ->
Assert.equal_block_set ~msg:__LOC__ bhset2 bhset2'' ; Assert.equal_block_set ~msg:__LOC__ bhset2 bhset2'' ;
Store.store s ["day";"current"] (MBytes.of_string "Mercredi") >>= fun () -> Store.store s ["day";"current"] (MBytes.of_string "Mercredi") >>= fun () ->
StoreSet.remove_all s >>= fun () -> StoreSet.remove_all s >>= fun () ->

View File

@ -7,7 +7,9 @@
test_stream_data_encoding test_stream_data_encoding
test_utils)) test_utils))
(libraries (minutils utils test_lib)) (libraries (minutils utils test_lib))
(flags (:standard -open Error_monad (flags (:standard -w -9-32
-safe-string
-open Error_monad
-open Hash -open Hash
-open Utils -open Utils
-open Tezos_data)))) -open Tezos_data))))

View File

@ -1,5 +1,4 @@
open Data_encoding open Data_encoding
open Hash
open Error_monad open Error_monad
let (>>=) = Lwt.bind let (>>=) = Lwt.bind

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
open Error_monad open Error_monad
open Hash
let rec (--) i j = let rec (--) i j =
if j < i then [] if j < i then []

View File

@ -1,5 +1,4 @@
open Data_encoding open Data_encoding
open Hash
open Error_monad open Error_monad
let (>>=) = Lwt.bind let (>>=) = Lwt.bind
@ -22,7 +21,7 @@ let rec fold_left_pending f accu l =
| a::l -> fold_left_pending f (f accu a l) l | a::l -> fold_left_pending f (f accu a l) l
let test_read_simple_bin_ko_invalid_data let test_read_simple_bin_ko_invalid_data
?msg ?(not_equal=Assert.not_equal) encoding value = ?(not_equal=Assert.not_equal) encoding value =
let len_data = MBytes.length (Binary.to_bytes encoding value) in let len_data = MBytes.length (Binary.to_bytes encoding value) in
if classify encoding != `Variable && len_data > 0 then if classify encoding != `Variable && len_data > 0 then
for sz = 1 to len_data do for sz = 1 to len_data do
@ -64,14 +63,14 @@ let test_read_simple_bin_ko_invalid_data
let unexpected loc = let unexpected loc =
loc ^ ": This case should not happen" loc ^ ": This case should not happen"
let test_read_simple_bin_ko_await ?msg encoding value = let test_read_simple_bin_ko_await encoding value =
let len_data = MBytes.length (Binary.to_bytes encoding value) in let len_data = MBytes.length (Binary.to_bytes encoding value) in
if classify encoding != `Variable && len_data > 0 then if classify encoding != `Variable && len_data > 0 then
for sz = 1 to len_data do for sz = 1 to len_data do
let l = Binary.to_bytes_list sz encoding value in let l = Binary.to_bytes_list sz encoding value in
match List.rev l with match List.rev l with
| [] -> Assert.fail_msg "%s" (unexpected __LOC__) | [] -> Assert.fail_msg "%s" (unexpected __LOC__)
| e::r -> | _ :: r ->
let l = List.rev r in (* last mbyte removed !! *) let l = List.rev r in (* last mbyte removed !! *)
ignore( ignore(
fold_left_pending fold_left_pending
@ -96,7 +95,7 @@ let test_read_simple_bin_ko_await ?msg encoding value =
| Binary.Error -> | Binary.Error ->
if not (classify encoding == `Variable) then if not (classify encoding == `Variable) then
Assert.fail_msg "%s" (unexpected __LOC__) Assert.fail_msg "%s" (unexpected __LOC__)
| Binary.Success result -> | Binary.Success _ ->
Assert.fail_msg "%s" (unexpected __LOC__) Assert.fail_msg "%s" (unexpected __LOC__)
end; end;
_done _done
@ -139,7 +138,7 @@ let test_read_simple_bin_ok ?msg ?(equal=Assert.equal) encoding value =
done done
let test_check_simple_bin_ko_invalid_data let test_check_simple_bin_ko_invalid_data
?msg ?(not_equal=Assert.not_equal) encoding value = encoding value =
let len_data = MBytes.length (Binary.to_bytes encoding value) in let len_data = MBytes.length (Binary.to_bytes encoding value) in
if classify encoding != `Variable && len_data > 0 then if classify encoding != `Variable && len_data > 0 then
for sz = 1 to len_data do for sz = 1 to len_data do
@ -168,7 +167,7 @@ let test_check_simple_bin_ko_invalid_data
match status with match status with
| Binary.Await _ -> () | Binary.Await _ -> ()
| Binary.Error -> () | Binary.Error -> ()
| Binary.Success {res; remaining} -> | Binary.Success { remaining } ->
Assert.equal ~msg:__LOC__ remaining []; Assert.equal ~msg:__LOC__ remaining [];
(* res is unit for check *) (* res is unit for check *)
end; end;
@ -177,14 +176,14 @@ let test_check_simple_bin_ko_invalid_data
) )
done done
let test_check_simple_bin_ko_await ?msg encoding value = let test_check_simple_bin_ko_await encoding value =
let len_data = MBytes.length (Binary.to_bytes encoding value) in let len_data = MBytes.length (Binary.to_bytes encoding value) in
if classify encoding != `Variable && len_data > 0 then if classify encoding != `Variable && len_data > 0 then
for sz = 1 to len_data do for sz = 1 to len_data do
let l = Binary.to_bytes_list sz encoding value in let l = Binary.to_bytes_list sz encoding value in
match List.rev l with match List.rev l with
| [] -> Assert.fail_msg "%s" (unexpected __LOC__) | [] -> Assert.fail_msg "%s" (unexpected __LOC__)
| e::r -> | _ :: r ->
let l = List.rev r in (* last mbyte removed !! *) let l = List.rev r in (* last mbyte removed !! *)
ignore( ignore(
fold_left_pending fold_left_pending
@ -209,7 +208,7 @@ let test_check_simple_bin_ko_await ?msg encoding value =
| Binary.Error -> | Binary.Error ->
if not (classify encoding == `Variable) then if not (classify encoding == `Variable) then
Assert.fail_msg "%s" (unexpected __LOC__) Assert.fail_msg "%s" (unexpected __LOC__)
| Binary.Success result -> | Binary.Success _ ->
Assert.fail_msg "%s" (unexpected __LOC__) Assert.fail_msg "%s" (unexpected __LOC__)
end; end;
_done _done
@ -217,7 +216,7 @@ let test_check_simple_bin_ko_await ?msg encoding value =
) )
done done
let test_check_simple_bin_ok ?msg ?(equal=Assert.equal) encoding value = let test_check_simple_bin_ok encoding value =
let len_data = max 1 (MBytes.length (Binary.to_bytes encoding value)) in let len_data = max 1 (MBytes.length (Binary.to_bytes encoding value)) in
for sz = 1 to len_data do for sz = 1 to len_data do
ignore( ignore(
@ -238,7 +237,7 @@ let test_check_simple_bin_ok ?msg ?(equal=Assert.equal) encoding value =
)status _todo )status _todo
in in
match status with match status with
| Binary.Success {res; remaining} -> | Binary.Success { remaining } ->
Assert.equal ~msg:__LOC__ remaining []; Assert.equal ~msg:__LOC__ remaining [];
(* res is unit for check *) (* res is unit for check *)
| Binary.Await _ -> Assert.fail_msg "%s" (unexpected __LOC__) | Binary.Await _ -> Assert.fail_msg "%s" (unexpected __LOC__)
@ -254,15 +253,14 @@ let test_check_simple_bin_ok ?msg ?(equal=Assert.equal) encoding value =
let test_simple let test_simple
~msg ?(equal=Assert.equal) ?(not_equal=Assert.not_equal) enc value ~msg ?(equal=Assert.equal) ?(not_equal=Assert.not_equal) enc value
= =
test_check_simple_bin_ok ~msg:(msg ^ ": binary-ok") ~equal enc value; test_check_simple_bin_ok enc value;
test_check_simple_bin_ko_await ~msg:(msg ^ ": binary-ko_await") enc value; test_check_simple_bin_ko_await enc value;
test_check_simple_bin_ko_invalid_data test_check_simple_bin_ko_invalid_data enc value;
~msg:(msg ^ ": binary-invalid_data") ~not_equal enc value;
test_read_simple_bin_ok ~msg:(msg ^ ": binary-ok") ~equal enc value; test_read_simple_bin_ok ~msg:(msg ^ ": binary-ok") ~equal enc value;
test_read_simple_bin_ko_await ~msg:(msg ^ ": binary-ko_await") enc value; test_read_simple_bin_ko_await enc value;
test_read_simple_bin_ko_invalid_data test_read_simple_bin_ko_invalid_data
~msg:(msg ^ ": binary-invalid_data") ~not_equal enc value ~not_equal enc value

View File

@ -8,7 +8,6 @@
(**************************************************************************) (**************************************************************************)
open Error_monad open Error_monad
open Hash
let rec (--) i j = let rec (--) i j =
if j < i then [] if j < i then []