filename
stringlengths
3
67
data
stringlengths
0
58.3M
license
stringlengths
0
19.5k
p2p_point_state.ml
open P2p_point type 'data t = | Requested of {cancel : Lwt_canceler.t} | Accepted of {current_peer_id : P2p_peer.Id.t; cancel : Lwt_canceler.t} | Running of {data : 'data; current_peer_id : P2p_peer.Id.t} | Disconnected type 'data state = 'data t let pp ppf = function | Requested _ -> Format.fprintf ppf "requested" | Accepted {current_peer_id; _} -> Format.fprintf ppf "accepted %a" P2p_peer.Id.pp current_peer_id | Running {current_peer_id; _} -> Format.fprintf ppf "running %a" P2p_peer.Id.pp current_peer_id | Disconnected -> Format.fprintf ppf "disconnected" module Info = struct type reconnection_config = { factor : float; initial_delay : Time.System.Span.t; disconnection_delay : Time.System.Span.t; increase_cap : Time.System.Span.t; } type reconnection_info = { delay : Time.System.Span.t; end_time : Time.System.t; } type 'data t = { point : Id.t; mutable trusted : bool; mutable state : 'data state; mutable last_failed_connection : Time.System.t option; mutable last_rejected_connection : (P2p_peer.Id.t * Time.System.t) option; mutable last_established_connection : (P2p_peer.Id.t * Time.System.t) option; mutable known_public : bool; mutable last_disconnection : (P2p_peer.Id.t * Time.System.t) option; mutable reconnection_info : reconnection_info option; events : Pool_event.t Ringo.Ring.t; mutable expected_peer_id : P2p_peer.Id.t option; watchers : Pool_event.t Lwt_watcher.input; } type 'data point_info = 'data t let compare pi1 pi2 = Id.compare pi1.point pi2.point let log_size = 100 let default_reconnection_config = { factor = 1.2; initial_delay = Ptime.Span.of_int_s 1; disconnection_delay = Ptime.Span.of_int_s 60; increase_cap = Ptime.Span.of_int_s 172800 (* 2 days *); } let reconnection_config_encoding = let open Data_encoding in conv (fun {factor; initial_delay; disconnection_delay; increase_cap} -> (factor, initial_delay, disconnection_delay, increase_cap)) (fun (factor, initial_delay, disconnection_delay, increase_cap) -> {factor; initial_delay; disconnection_delay; increase_cap}) (obj4 (dft "factor" ~description: "The factor by which the reconnection delay is increased when a \ peer that was previously disconnected is disconnected again. \ This value should be set to 1 for a linear back-off and to >1 \ for an exponential back-off." float default_reconnection_config.factor) (dft "initial-delay" ~description: "The span of time a peer is disconnected for when it is first \ disconnected." Time.System.Span.encoding default_reconnection_config.initial_delay) (dft "disconnection-delay" ~description: "The span of time a peer is disconnected for when it is \ disconnected as the result of an error." Time.System.Span.encoding default_reconnection_config.disconnection_delay) (dft "increase-cap" ~description: "The maximum amount by which the reconnection is extended. This \ limits the rate of the exponential back-off, which eventually \ becomes linear when it reaches this limit. This limit is set to \ avoid reaching the End-of-Time when repeatedly reconnection a \ peer." Time.System.Span.encoding default_reconnection_config.increase_cap)) let create ?(trusted = false) ?expected_peer_id addr port = { point = (addr, port); trusted; state = Disconnected; last_failed_connection = None; last_rejected_connection = None; last_established_connection = None; last_disconnection = None; known_public = false; events = Ringo.Ring.create log_size; reconnection_info = None; watchers = Lwt_watcher.create_input (); expected_peer_id; } let point s = s.point let trusted s = s.trusted let set_trusted gi = gi.trusted <- true let unset_trusted gi = gi.trusted <- false let reset_reconnection_delay gi = gi.reconnection_info <- None let get_expected_peer_id gi = gi.expected_peer_id let last_established_connection s = s.last_established_connection let last_disconnection s = s.last_disconnection let last_failed_connection s = s.last_failed_connection let last_rejected_connection s = s.last_rejected_connection let known_public s = s.known_public let can_reconnect ~now {reconnection_info; _} = (* TODO : use Option.map_default when will be available *) match reconnection_info with | None -> false | Some gr -> Time.System.compare now gr.end_time <= 0 let reconnection_time {reconnection_info; _} = (* TODO : use Option.map_default when will be available *) match reconnection_info with None -> None | Some gr -> Some gr.end_time let last_seen s = Time.System.recent s.last_rejected_connection (Time.System.recent s.last_established_connection s.last_disconnection) let last_miss s = Option.merge Time.System.max s.last_failed_connection (Option.map snd @@ Time.System.recent s.last_rejected_connection s.last_disconnection) let log {events; watchers; _} ~timestamp kind = let event = Time.System.stamp ~time:timestamp kind in Ringo.Ring.add events event ; Lwt_watcher.notify watchers event let log_incoming_rejection ~timestamp point_info peer_id = log point_info ~timestamp (Rejecting_request peer_id) let events {events; _} = Ringo.Ring.elements events let watch {watchers; _} = Lwt_watcher.create_stream watchers end let get {Info.state; _} = state let is_disconnected {Info.state; _} = match state with | Disconnected -> true | Requested _ | Accepted _ | Running _ -> false let set_requested ~timestamp point_info cancel = assert ( match point_info.Info.state with | Requested _ -> true | Accepted _ | Running _ -> false | Disconnected -> true) ; point_info.state <- Requested {cancel} ; Info.log point_info ~timestamp Outgoing_request let set_accepted ~timestamp point_info current_peer_id cancel = (* log_notice "SET_ACCEPTED %a@." P2p_point.pp point_info.point ; *) assert ( match point_info.Info.state with | Accepted _ | Running _ -> false | Requested _ | Disconnected -> true) ; point_info.state <- Accepted {current_peer_id; cancel} ; Info.log point_info ~timestamp (Accepting_request current_peer_id) let set_private point_info known_private = point_info.Info.known_public <- not known_private let set_running ~timestamp point_info peer_id data = assert ( match point_info.Info.state with | Disconnected -> true (* request to unknown peer_id. *) | Running _ -> false | Accepted {current_peer_id; _} -> P2p_peer.Id.equal peer_id current_peer_id | Requested _ -> true) ; point_info.state <- Running {data; current_peer_id = peer_id} ; point_info.last_established_connection <- Some (peer_id, timestamp) ; Info.log point_info ~timestamp (Connection_established peer_id) let maxed_time_add t s = match Ptime.add_span t s with Some t -> t | None -> Ptime.max let set_reconnection_delay reconnection_config timestamp point_info = let disconnection_delay = match point_info.Info.reconnection_info with | None -> reconnection_config.Info.initial_delay | Some gr -> gr.delay in let end_time = maxed_time_add timestamp disconnection_delay in let delay = let new_delay = Time.System.Span.multiply_exn reconnection_config.Info.factor disconnection_delay in if Ptime.Span.compare reconnection_config.Info.increase_cap new_delay > 0 then new_delay else reconnection_config.Info.increase_cap in point_info.Info.reconnection_info <- Some {delay; end_time} let set_disconnected ~timestamp ?(requested = false) reconnection_config point_info = let event : Pool_event.kind = match point_info.Info.state with | Requested _ -> set_reconnection_delay reconnection_config timestamp point_info ; point_info.last_failed_connection <- Some timestamp ; Request_rejected None | Accepted {current_peer_id; _} -> set_reconnection_delay reconnection_config timestamp point_info ; point_info.last_rejected_connection <- Some (current_peer_id, timestamp) ; Request_rejected (Some current_peer_id) | Running {current_peer_id; _} -> let delay = reconnection_config.Info.initial_delay in let end_time = maxed_time_add timestamp reconnection_config.Info.disconnection_delay in point_info.reconnection_info <- Some {delay; end_time} ; point_info.last_disconnection <- Some (current_peer_id, timestamp) ; if requested then Disconnection current_peer_id else External_disconnection current_peer_id | Disconnected -> assert false in point_info.state <- Disconnected ; Info.log point_info ~timestamp event let set_expected_peer_id point_info id = point_info.Info.expected_peer_id <- Some id let get_expected_peer_id point_info = point_info.Info.expected_peer_id
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* Copyright (c) 2020 Nomadic Labs, <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
field.ml
type t = | Varint of Int64.t (* int32, int64, uint32, uint64, sint32, sint64, bool, enum *) | Fixed_64_bit of Int64.t (* fixed64, sfixed64, double *) | Length_delimited of { offset : int; length : int; data : string; } (* string, bytes, embedded messages, packed repeated fields *) | Fixed_32_bit of Int32.t (* fixed32, sfixed32, float *) let varint v = Varint v let fixed_32_bit v = Fixed_32_bit v let fixed_64_bit v = Fixed_64_bit v let length_delimited ?(offset=0) ?length data = let length = Option.value ~default:(String.length data - offset) length in Length_delimited {offset; length; data} let pp: Format.formatter -> t -> unit = fun fmt -> function | Varint a0 -> (Format.fprintf fmt "(@[<2>Field.Varint@ "; (Format.fprintf fmt "%LdL") a0; Format.fprintf fmt "@])") | Fixed_64_bit a0 -> (Format.fprintf fmt "(@[<2>Field.Fixed_64_bit@ "; (Format.fprintf fmt "%LdL") a0; Format.fprintf fmt "@])") | Length_delimited { offset = aoffset; length = alength; data = adata } -> (Format.fprintf fmt "@[<2>Field.Length_delimited {@,"; (((Format.fprintf fmt "@[%s =@ " "offset"; (Format.fprintf fmt "%d") aoffset; Format.fprintf fmt "@]"); Format.fprintf fmt ";@ "; Format.fprintf fmt "@[%s =@ " "length"; (Format.fprintf fmt "%d") alength; Format.fprintf fmt "@]"); Format.fprintf fmt ";@ "; Format.fprintf fmt "@[%s =@ " "data"; (Format.fprintf fmt "%S") adata; Format.fprintf fmt "@]"); Format.fprintf fmt "@]}") | Fixed_32_bit a0 -> (Format.fprintf fmt "(@[<2>Field.Fixed_32_bit@ "; (Format.fprintf fmt "%ldl") a0; Format.fprintf fmt "@])") let show : t -> string = Format.asprintf "%a" pp
backtrace_view.mli
open! Core open Memtrace_viewer_common open Bonsai_web val render : Data.Backtrace.t -> Vdom.Node.t
ast_builder.ml
open! Import module Default = struct module Located = struct type 'a t = 'a Loc.t let loc (x : _ t) = x.loc let mk ~loc x = { loc; txt = x } let map f t = { t with txt = f t.txt } let map_lident x = map (fun x -> Longident.Lident x) x let lident ~loc x = mk ~loc (Longident.parse x) end include Ast_builder_generated.M module Latest = struct let ppat_construct = ppat_construct let constructor_declaration ~loc ~name ~vars ~args ~res () = constructor_declaration ~loc ~name ~vars ~args ~res end (*------ stable layer above Ast_builder_generated.M -----*) let ppat_construct ~loc lid p = { ppat_loc_stack = []; ppat_attributes = []; ppat_loc = loc; ppat_desc = Ppat_construct (lid, Option.map p ~f:(fun p -> ([], p))); } let constructor_declaration ~loc ~name ~args ~res = { pcd_name = name; pcd_vars = []; pcd_args = args; pcd_res = res; pcd_loc = loc; pcd_attributes = []; } (*-------------------------------------------------------*) let pstr_value_list ~loc rec_flag = function | [] -> [] | vbs -> [ pstr_value ~loc rec_flag vbs ] let nonrec_type_declaration ~loc:_ ~name:_ ~params:_ ~cstrs:_ ~kind:_ ~private_:_ ~manifest:_ = failwith "Ppxlib.Ast_builder.nonrec_type_declaration: don't use this function" let eint ~loc t = pexp_constant ~loc (Pconst_integer (Int.to_string t, None)) let echar ~loc t = pexp_constant ~loc (Pconst_char t) let estring ~loc t = pexp_constant ~loc (Pconst_string (t, loc, None)) let efloat ~loc t = pexp_constant ~loc (Pconst_float (t, None)) let eint32 ~loc t = pexp_constant ~loc (Pconst_integer (Int32.to_string t, Some 'l')) let eint64 ~loc t = pexp_constant ~loc (Pconst_integer (Int64.to_string t, Some 'L')) let enativeint ~loc t = pexp_constant ~loc (Pconst_integer (Nativeint.to_string t, Some 'n')) let pint ~loc t = ppat_constant ~loc (Pconst_integer (Int.to_string t, None)) let pchar ~loc t = ppat_constant ~loc (Pconst_char t) let pstring ~loc t = ppat_constant ~loc (Pconst_string (t, loc, None)) let pfloat ~loc t = ppat_constant ~loc (Pconst_float (t, None)) let pint32 ~loc t = ppat_constant ~loc (Pconst_integer (Int32.to_string t, Some 'l')) let pint64 ~loc t = ppat_constant ~loc (Pconst_integer (Int64.to_string t, Some 'L')) let pnativeint ~loc t = ppat_constant ~loc (Pconst_integer (Nativeint.to_string t, Some 'n')) let ebool ~loc t = pexp_construct ~loc (Located.lident ~loc (Bool.to_string t)) None let pbool ~loc t = ppat_construct ~loc (Located.lident ~loc (Bool.to_string t)) None let evar ~loc v = pexp_ident ~loc (Located.mk ~loc (Longident.parse v)) let pvar ~loc v = ppat_var ~loc (Located.mk ~loc v) let eunit ~loc = pexp_construct ~loc (Located.lident ~loc "()") None let punit ~loc = ppat_construct ~loc (Located.lident ~loc "()") None let pexp_tuple ~loc l = match l with [ x ] -> x | _ -> pexp_tuple ~loc l let ppat_tuple ~loc l = match l with [ x ] -> x | _ -> ppat_tuple ~loc l let ptyp_tuple ~loc l = match l with [ x ] -> x | _ -> ptyp_tuple ~loc l let pexp_tuple_opt ~loc l = match l with [] -> None | _ :: _ -> Some (pexp_tuple ~loc l) let ppat_tuple_opt ~loc l = match l with [] -> None | _ :: _ -> Some (ppat_tuple ~loc l) let ptyp_poly ~loc vars ty = match vars with [] -> ty | _ -> ptyp_poly ~loc vars ty let pexp_apply ~loc e el = match (e, el) with | _, [] -> e | { pexp_desc = Pexp_apply (e, args); pexp_attributes = []; _ }, _ -> { e with pexp_desc = Pexp_apply (e, args @ el) } | _ -> pexp_apply ~loc e el let eapply ~loc e el = pexp_apply ~loc e (List.map el ~f:(fun e -> (Asttypes.Nolabel, e))) let eabstract ~loc ps e = List.fold_right ps ~init:e ~f:(fun p e -> pexp_fun ~loc Asttypes.Nolabel None p e) let esequence ~loc el = match List.rev el with | [] -> eunit ~loc | hd :: tl -> List.fold_left tl ~init:hd ~f:(fun acc e -> pexp_sequence ~loc e acc) let pconstruct cd arg = ppat_construct ~loc:cd.pcd_loc (Located.map_lident cd.pcd_name) arg let econstruct cd arg = pexp_construct ~loc:cd.pcd_loc (Located.map_lident cd.pcd_name) arg let rec elist ~loc l = match l with | [] -> pexp_construct ~loc (Located.mk ~loc (Longident.Lident "[]")) None | x :: l -> pexp_construct ~loc (Located.mk ~loc (Longident.Lident "::")) (Some (pexp_tuple ~loc [ x; elist ~loc l ])) let rec plist ~loc l = match l with | [] -> ppat_construct ~loc (Located.mk ~loc (Longident.Lident "[]")) None | x :: l -> ppat_construct ~loc (Located.mk ~loc (Longident.Lident "::")) (Some (ppat_tuple ~loc [ x; plist ~loc l ])) let unapplied_type_constr_conv_without_apply ~loc (ident : Longident.t) ~f = match ident with | Lident n -> pexp_ident ~loc { txt = Lident (f n); loc } | Ldot (path, n) -> pexp_ident ~loc { txt = Ldot (path, f n); loc } | Lapply _ -> Location.raise_errorf ~loc "unexpected applicative functor type" let type_constr_conv ~loc:apply_loc { Loc.loc; txt = longident } ~f args = let loc = { loc with loc_ghost = true } in match (longident : Longident.t) with | Lident _ | Ldot ((Lident _ | Ldot _), _) | Lapply _ -> ( let ident = unapplied_type_constr_conv_without_apply longident ~loc ~f in match args with | [] -> ident | _ :: _ -> eapply ~loc:apply_loc ident args) | Ldot ((Lapply _ as module_path), n) -> let suffix_n functor_ = String.uncapitalize_ascii functor_ ^ "__" ^ n in let rec gather_lapply functor_args : Longident.t -> Longident.t * _ = function | Lapply (rest, arg) -> gather_lapply (arg :: functor_args) rest | Lident functor_ -> (Lident (suffix_n functor_), functor_args) | Ldot (functor_path, functor_) -> (Ldot (functor_path, suffix_n functor_), functor_args) in let ident, functor_args = gather_lapply [] module_path in eapply ~loc:apply_loc (unapplied_type_constr_conv_without_apply ident ~loc ~f) (List.map functor_args ~f:(fun path -> pexp_pack ~loc (pmod_ident ~loc { txt = path; loc })) @ args) let unapplied_type_constr_conv ~loc longident ~f = type_constr_conv longident ~loc ~f [] let eta_reduce = let rec gather_params acc expr = match expr with | { pexp_desc = Pexp_fun (label, None (* no default expression *), subpat, body); pexp_attributes = []; pexp_loc = _; pexp_loc_stack = _; } -> ( match subpat with | { ppat_desc = Ppat_var name; ppat_attributes = []; ppat_loc = _; ppat_loc_stack = _; } -> gather_params ((label, name, None) :: acc) body | { ppat_desc = Ppat_constraint ( { ppat_desc = Ppat_var name; ppat_attributes = []; ppat_loc = _; ppat_loc_stack = _; }, ty ); ppat_attributes = []; ppat_loc = _; ppat_loc_stack = _; } -> (* We reduce [fun (x : ty) -> f x] by rewriting it [(f : ty -> _)]. *) gather_params ((label, name, Some ty) :: acc) body | _ -> (List.rev acc, expr)) | _ -> (List.rev acc, expr) in let annotate ~loc expr params = if List.exists params ~f:(fun (_, _, ty) -> Option.is_some ty) then let ty = List.fold_right params ~init:(ptyp_any ~loc) ~f:(fun (param_label, param, ty_opt) acc -> let loc = param.loc in let ty = match ty_opt with None -> ptyp_any ~loc | Some ty -> ty in ptyp_arrow ~loc param_label ty acc) in pexp_constraint ~loc expr ty else expr in let rec gather_args n x = if n = 0 then Some (x, []) else match x with | { pexp_desc = Pexp_apply (body, args); pexp_attributes = []; pexp_loc = _; pexp_loc_stack = _; } -> if List.length args <= n then match gather_args (n - List.length args) body with | None -> None | Some (body, args') -> Some (body, args' @ args) else None | _ -> None in fun expr -> let params, body = gather_params [] expr in match gather_args (List.length params) body with | None -> None | Some (({ pexp_desc = Pexp_ident _; _ } as f_ident), args) -> ( match List.for_all2 args params ~f:(fun (arg_label, arg) (param_label, param, _) -> Poly.( = ) (arg_label : arg_label) param_label && match arg with | { pexp_desc = Pexp_ident { txt = Lident name'; _ }; pexp_attributes = []; pexp_loc = _; pexp_loc_stack = _; } -> String.( = ) name' param.txt | _ -> false) with | false -> None | true -> Some (annotate ~loc:expr.pexp_loc f_ident params)) | _ -> None let eta_reduce_if_possible expr = Option.value (eta_reduce expr) ~default:expr let eta_reduce_if_possible_and_nonrec expr ~rec_flag = match rec_flag with | Recursive -> expr | Nonrecursive -> eta_reduce_if_possible expr end module type Loc = Ast_builder_intf.Loc module type S = sig include Ast_builder_intf.S module Latest : sig val ppat_construct : longident loc -> (label loc list * pattern) option -> pattern val constructor_declaration : name:label loc -> vars:label loc list -> args:constructor_arguments -> res:core_type option -> unit -> constructor_declaration end val ppat_construct : longident loc -> pattern option -> pattern val constructor_declaration : name:label loc -> args:constructor_arguments -> res:core_type option -> constructor_declaration end module Make (Loc : sig val loc : Location.t end) : S = struct include Ast_builder_generated.Make (Loc) module Latest = struct let ppat_construct = ppat_construct let constructor_declaration ~name ~vars ~args ~res () = constructor_declaration ~name ~vars ~args ~res end (*----- stable layer above Ast_builder_generated.Make (Loc) -----*) let ppat_construct lid p = { ppat_loc_stack = []; ppat_attributes = []; ppat_loc = loc; ppat_desc = Ppat_construct (lid, Option.map p ~f:(fun p -> ([], p))); } let constructor_declaration ~name ~args ~res = { pcd_name = name; pcd_vars = []; pcd_args = args; pcd_res = res; pcd_loc = loc; pcd_attributes = []; } (*---------------------------------------------------------------*) let pstr_value_list = Default.pstr_value_list let nonrec_type_declaration ~name ~params ~cstrs ~kind ~private_ ~manifest = Default.nonrec_type_declaration ~loc ~name ~params ~cstrs ~kind ~private_ ~manifest module Located = struct include Default.Located let loc _ = Loc.loc let mk x = mk ~loc:Loc.loc x let lident x = lident ~loc:Loc.loc x end let pexp_tuple l = Default.pexp_tuple ~loc l let ppat_tuple l = Default.ppat_tuple ~loc l let ptyp_tuple l = Default.ptyp_tuple ~loc l let pexp_tuple_opt l = Default.pexp_tuple_opt ~loc l let ppat_tuple_opt l = Default.ppat_tuple_opt ~loc l let ptyp_poly vars ty = Default.ptyp_poly ~loc vars ty let pexp_apply e el = Default.pexp_apply ~loc e el let eint t = Default.eint ~loc t let echar t = Default.echar ~loc t let estring t = Default.estring ~loc t let efloat t = Default.efloat ~loc t let eint32 t = Default.eint32 ~loc t let eint64 t = Default.eint64 ~loc t let enativeint t = Default.enativeint ~loc t let ebool t = Default.ebool ~loc t let evar t = Default.evar ~loc t let pint t = Default.pint ~loc t let pchar t = Default.pchar ~loc t let pstring t = Default.pstring ~loc t let pfloat t = Default.pfloat ~loc t let pint32 t = Default.pint32 ~loc t let pint64 t = Default.pint64 ~loc t let pnativeint t = Default.pnativeint ~loc t let pbool t = Default.pbool ~loc t let pvar t = Default.pvar ~loc t let eunit = Default.eunit ~loc let punit = Default.punit ~loc let econstruct = Default.econstruct let pconstruct = Default.pconstruct let eapply e el = Default.eapply ~loc e el let eabstract ps e = Default.eabstract ~loc ps e let esequence el = Default.esequence ~loc el let elist l = Default.elist ~loc l let plist l = Default.plist ~loc l let type_constr_conv ident ~f args = Default.type_constr_conv ~loc ident ~f args let unapplied_type_constr_conv ident ~f = Default.unapplied_type_constr_conv ~loc ident ~f let eta_reduce = Default.eta_reduce let eta_reduce_if_possible = Default.eta_reduce_if_possible let eta_reduce_if_possible_and_nonrec = Default.eta_reduce_if_possible_and_nonrec end let make loc = (module Make (struct let loc = loc end) : S)
dune
(test (name pbkdf_tests) (libraries pbkdf alcotest))
CCOption.ml
(* This file is free software, part of containers. See file "license" for more details. *) (** {1 Options} *) type 'a t = 'a option let[@inline] map f = function | None -> None | Some x -> Some (f x) let map_or ~default f = function | None -> default | Some x -> f x let map_lazy default_fn f = function | None -> default_fn () | Some x -> f x let is_some = function | None -> false | Some _ -> true let is_none = function | None -> true | Some _ -> false let compare f o1 o2 = match o1, o2 with | None, None -> 0 | Some _, None -> 1 | None, Some _ -> -1 | Some x, Some y -> f x y let equal f o1 o2 = match o1, o2 with | None, None -> true | Some _, None | None, Some _ -> false | Some x, Some y -> f x y let return x = Some x let some = return let none = None let[@inline] flat_map f o = match o with | None -> None | Some x -> f x let[@inline] bind o f = flat_map f o let ( >>= ) = bind let pure x = Some x let ( <*> ) f x = match f, x with | None, _ | _, None -> None | Some f, Some x -> Some (f x) let or_ ~else_ a = match a with | None -> else_ | Some _ -> a let or_lazy ~else_ a = match a with | None -> else_ () | Some _ -> a let ( <+> ) a b = or_ ~else_:b a let choice l = List.fold_left ( <+> ) None l let map2 f o1 o2 = match o1, o2 with | None, _ | _, None -> None | Some x, Some y -> Some (f x y) let filter p = function | Some x as o when p x -> o | _ -> None let if_ p x = if p x then Some x else None let exists p = function | None -> false | Some x -> p x let for_all p = function | None -> true | Some x -> p x let iter f o = match o with | None -> () | Some x -> f x let fold f acc o = match o with | None -> acc | Some x -> f acc x let get_or ~default x = match x with | None -> default | Some y -> y let value x ~default = match x with | None -> default | Some y -> y let get_exn = function | Some x -> x | None -> invalid_arg "CCOption.get_exn" let get_exn_or msg = function | Some x -> x | None -> invalid_arg msg let get_lazy default_fn x = match x with | None -> default_fn () | Some y -> y let sequence_l l = let rec aux acc l = match l with | [] -> Some (List.rev acc) | Some x :: l' -> aux (x :: acc) l' | None :: _ -> raise Exit in try aux [] l with Exit -> None let wrap ?(handler = fun _ -> true) f x = try Some (f x) with e -> if handler e then None else raise e let wrap2 ?(handler = fun _ -> true) f x y = try Some (f x y) with e -> if handler e then None else raise e let to_list o = match o with | None -> [] | Some x -> [ x ] let of_list = function | x :: _ -> Some x | [] -> None let to_result err = function | None -> Error err | Some x -> Ok x let to_result_lazy err_fn = function | None -> Error (err_fn ()) | Some x -> Ok x let of_result = function | Error _ -> None | Ok x -> Some x module Infix = struct let ( >|= ) x f = map f x let ( >>= ) = ( >>= ) let ( <*> ) = ( <*> ) let ( <$> ) = map let ( <+> ) = ( <+> ) [@@@ifge 4.8] let ( let+ ) = ( >|= ) let ( let* ) = ( >>= ) let[@inline] ( and+ ) o1 o2 = match o1, o2 with | Some x, Some y -> Some (x, y) | _ -> None let ( and* ) = ( and+ ) [@@@endif] end include Infix type 'a iter = ('a -> unit) -> unit type 'a gen = unit -> 'a option type 'a printer = Format.formatter -> 'a -> unit type 'a random_gen = Random.State.t -> 'a let random g st = if Random.State.bool st then Some (g st) else None exception ExitChoice let choice_iter s = let r = ref None in (try s (function | None -> () | Some _ as o -> r := o; raise ExitChoice) with ExitChoice -> ()); !r let rec choice_seq s = match s () with | Seq.Nil -> None | Seq.Cons (Some x, _) -> Some x | Seq.Cons (None, tl) -> choice_seq tl let to_gen o = match o with | None -> fun () -> None | Some _ -> let first = ref true in fun () -> if !first then ( first := false; o ) else None let to_iter o k = match o with | None -> () | Some x -> k x let to_seq o () = match o with | None -> Seq.Nil | Some x -> Seq.Cons (x, Seq.empty) let pp ppx out = function | None -> Format.pp_print_string out "None" | Some x -> Format.fprintf out "@[Some %a@]" ppx x let flatten = function | Some x -> x | None -> None let return_if b x = if b then Some x else None
(* This file is free software, part of containers. See file "license" for more details. *)
l2lCheckLoops.ml
(* Time-stamp: <modified the 29/08/2019 (at 15:45) by Erwan Jahier> *) open Lxm open Lic module IdMap = Map.Make(struct type t = Lv6Id.t let compare = compare end) module IdSet = Set.Make(struct type t = Lv6Id.t let compare = compare end) (* Associate to an ident the set of idents it depends on *) type dependencies = (Lxm.t * IdSet.t) IdMap.t (*********************************************************************************) (* Compute the set of vars appearing in an expression *) let (vars_of_exp : Lic.val_exp -> IdSet.t) = fun ve -> let rec aux s ve = vars_of_val_exp_core s ve.ve_core and vars_of_val_exp_core s = function | CallByPosLic ({ it=FBY ;_}, _) | CallByPosLic ({ it=PRE ;_}, _) -> s (* pre is not a dependance! *) | CallByPosLic (by_pos_op, vel) -> let s = vars_of_by_pos_op s by_pos_op.it in List.fold_left aux s vel | Merge(ce, l) -> let s = aux s ce in List.fold_left (fun s (_,ve) -> aux s ve) s l | CallByNameLic(_, _) -> s and vars_of_by_pos_op s = function | VAR_REF id -> IdSet.add id s | PREDEF_CALL(_) | ARRAY_SLICE _ | ARRAY_ACCES _ | ARROW | FBY | CURRENT _ | WHEN _ | ARRAY | HAT(_) | STRUCT_ACCESS _ | TUPLE | CONCAT | CONST_REF _ | CALL _ | CONST _ -> s | PRE -> assert false and _vars_of_static_arg s = function | ConstStaticArgLic(id,_) | TypeStaticArgLic(id,_) | NodeStaticArgLic(id,_) -> IdSet.add id s in aux IdSet.empty ve (*********************************************************************************) exception DepLoop of (Lxm.t * string) exception Error of (Lxm.t * string * LicPrg.t) type visit_status = Todo | Doing | Done type visit_info = visit_status IdMap.t let (status : Lv6Id.t -> visit_info -> visit_status) = IdMap.find (* At init, all the idents are 'Todo' *) let (visit_init: dependencies -> visit_info) = fun deps -> let f id _ acc = IdMap.add id Todo acc in IdMap.fold f deps IdMap.empty let rec (visit : dependencies -> visit_info -> Lv6Id.t -> Lv6Id.t list -> visit_info) = fun deps vi id path -> assert (IdMap.mem id deps); let path = id::path in let lxm, iddeps = IdMap.find id deps in let iddeps = (* filter out id that have no deps (inputs, pre, const)*) IdSet.filter (fun id -> IdMap.mem id deps) iddeps in let doing,iddeps = IdSet.partition (fun id -> status id vi = Doing) iddeps in let _ = if (not (IdSet.is_empty doing)) then let id = IdSet.choose doing in let idl = List.rev (id::path) in let msg = "Dependency loop on "^id^": " ^ (String.concat "->" idl) ^ "\n" in raise (DepLoop (lxm,msg)) in let to_visit,_ = IdSet.partition (fun id -> status id vi = Todo) iddeps in let vi = IdSet.fold (fun id vi -> let vi = IdMap.add id Doing vi in let vi = visit deps vi id path in let vi = IdMap.add id Done vi in vi ) to_visit vi in vi (* Update the dependency graph according to the information contained in the equation. *) let (update_dependencies : dependencies -> Lic.eq_info srcflagged -> dependencies) = fun deps { it = (ll,exp) ; src = lxm } -> let lvars = List.map (fun l -> (Lic.var_info_of_left l).var_name_eff) ll in let rvars = vars_of_exp exp in let deps = List.fold_left (fun deps v -> let deps = try IdMap.add v (lxm,(IdSet.union (snd (IdMap.find v deps)) rvars)) deps with Not_found -> IdMap.add v (lxm,rvars) deps in deps ) deps lvars in deps let (check_node : Lic.node_exp -> unit) = fun node -> match node.def_eff with | ExternLic | MetaOpLic | AbstractLic _ -> () | BodyLic{ eqs_eff = eql;_ } -> let dependencies_init = IdMap.empty in let deps = List.fold_left update_dependencies dependencies_init eql in let vi = visit_init deps in let f id _ vi = visit deps vi id [] in ignore (IdMap.fold f deps vi) (* exported *) let (doit : LicPrg.t -> unit) = fun inprg -> let (do_node : Lic.node_key -> Lic.node_exp -> unit) = fun _nk ne -> check_node ne in try LicPrg.iter_nodes do_node inprg with DepLoop(lxm,msg) -> raise (Error(lxm,msg,inprg))
(* Time-stamp: <modified the 29/08/2019 (at 15:45) by Erwan Jahier> *)
bindings.c
/* Generated by ocaml-tree-sitter for tsx. */ #include <string.h> #include <tree_sitter/api.h> #include <caml/alloc.h> #include <caml/bigarray.h> #include <caml/callback.h> #include <caml/custom.h> #include <caml/memory.h> #include <caml/mlvalues.h> #include <caml/threads.h> // Implemented by parser.c TSLanguage *tree_sitter_tsx(); typedef struct _parser { TSParser *parser; } parser_W; static void finalize_parser(value v) { parser_W *p; p = (parser_W *)Data_custom_val(v); ts_parser_delete(p->parser); } static struct custom_operations parser_custom_ops = { .identifier = "parser handling", .finalize = finalize_parser, .compare = custom_compare_default, .hash = custom_hash_default, .serialize = custom_serialize_default, .deserialize = custom_deserialize_default }; // OCaml function CAMLprim value octs_create_parser_tsx(value unit) { CAMLparam0(); CAMLlocal1(v); parser_W parserWrapper; TSParser *parser = ts_parser_new(); parserWrapper.parser = parser; v = caml_alloc_custom(&parser_custom_ops, sizeof(parser_W), 0, 1); memcpy(Data_custom_val(v), &parserWrapper, sizeof(parser_W)); ts_parser_set_language(parser, tree_sitter_tsx()); CAMLreturn(v); };
/* Generated by ocaml-tree-sitter for tsx. */
timedesc_sexp.ml
let wrap_to_sexp_into_pp_sexp (f : 'a -> Sexplib.Sexp.t) : Format.formatter -> 'a -> unit = fun formatter x -> Sexplib.Sexp.pp formatter (f x) module Date = struct let to_sexp = To_sexp.sexp_of_date let to_sexp_string x = Sexplib.Sexp.to_string (To_sexp.sexp_of_date x) let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.date_of_sexp let of_sexp_string = Of_sexp_utils.wrap_of_sexp_into_of_sexp_string Of_sexp.date_of_sexp let pp_sexp = wrap_to_sexp_into_pp_sexp To_sexp.sexp_of_date end module Time = struct let to_sexp = To_sexp.sexp_of_time let to_sexp_string x = Sexplib.Sexp.to_string (To_sexp.sexp_of_time x) let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.time_of_sexp let of_sexp_string = Of_sexp_utils.wrap_of_sexp_into_of_sexp_string Of_sexp.time_of_sexp let pp_sexp = wrap_to_sexp_into_pp_sexp To_sexp.sexp_of_time end module Span = struct let to_sexp = To_sexp.sexp_of_span let to_sexp_string x = Sexplib.Sexp.to_string (To_sexp.sexp_of_span x) let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.span_of_sexp let of_sexp_string = Of_sexp_utils.wrap_of_sexp_into_of_sexp_string Of_sexp.span_of_sexp let pp_sexp = wrap_to_sexp_into_pp_sexp To_sexp.sexp_of_span end module Timestamp = struct let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.span_of_sexp let to_sexp = To_sexp.sexp_of_span end let to_sexp = To_sexp.sexp_of_date_time let to_sexp_string x = Sexplib.Sexp.to_string (To_sexp.sexp_of_date_time x) let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.date_time_of_sexp let of_sexp_string = Of_sexp_utils.wrap_of_sexp_into_of_sexp_string Of_sexp.date_time_of_sexp let pp_sexp = wrap_to_sexp_into_pp_sexp To_sexp.sexp_of_date_time module Zoneless = struct let to_sexp = To_sexp.sexp_of_zoneless let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.zoneless_of_sexp end module Time_zone = struct open Sexplib let of_sexp (x : Sexp.t) : Timedesc.Time_zone.t option = let open Of_sexp_utils in try match x with | List l -> ( match l with | Atom "tz" :: Atom name :: transitions -> transitions |> List.map (fun x -> match x with | Sexp.List [ start; List [ Atom is_dst; offset ] ] -> let start = int64_of_sexp start in let is_dst = match is_dst with | "t" -> true | "f" -> false | _ -> invalid_data "" in let offset = int_of_sexp offset in let entry = Timedesc.Time_zone.{ is_dst; offset } in (start, entry) | _ -> invalid_data "") |> Timedesc.Time_zone.Raw.of_transitions ~name | _ -> invalid_data "") | Atom _ -> invalid_data "" with _ -> None let to_sexp (t : Timedesc.Time_zone.t) : Sexp.t = let open To_sexp_utils in Sexp.List (Atom "tz" :: Atom (Timedesc.Time_zone.name t) :: List.map (fun ((start, _), entry) -> Sexp.List [ sexp_of_int64 start; Sexp.List [ (if Timedesc.Time_zone.(entry.is_dst) then Atom "t" else Atom "f"); sexp_of_int entry.offset; ]; ]) (Timedesc.Time_zone.Raw.to_transitions t)) let of_string s = match Sexp.of_string s with | exception _ -> None | x -> of_sexp x module Db = struct open Sexplib let of_sexp (x : Sexp.t) : Timedesc.Time_zone.Db.db option = let open Of_sexp_utils in try match x with | Atom _ -> invalid_data "" | List l -> Some (l |> List.to_seq |> Seq.map (fun x -> match of_sexp x with | None -> invalid_data "" | Some x -> x) |> Timedesc.Time_zone.Db.of_seq) with _ -> None let to_sexp db = Sexp.List (Timedesc_tzdb.M.bindings db |> List.map (fun (name, table) -> Timedesc.Time_zone.Raw.of_table_exn ~name table) |> List.map to_sexp ) let of_string s = match Sexp.of_string s with | exception _ -> None | x -> of_sexp x end end module Time_zone_info = struct let of_sexp = Of_sexp_utils.wrap_of_sexp Of_sexp.tz_info_of_sexp let to_sexp = To_sexp.sexp_of_tz_info end
hash_set_intf.ml
open! Import module Key = Hashtbl_intf.Key module type Accessors = sig include Container.Generic (** override [Container.Generic.mem] *) val mem : 'a t -> 'a -> bool (** preserves the equality function *) val copy : 'a t -> 'a t val add : 'a t -> 'a -> unit (** [strict_add t x] returns [Ok ()] if the [x] was not in [t], or an [Error] if it was. *) val strict_add : 'a t -> 'a -> unit Or_error.t val strict_add_exn : 'a t -> 'a -> unit val remove : 'a t -> 'a -> unit (** [strict_remove t x] returns [Ok ()] if the [x] was in [t], or an [Error] if it was not. *) val strict_remove : 'a t -> 'a -> unit Or_error.t val strict_remove_exn : 'a t -> 'a -> unit val clear : 'a t -> unit val equal : 'a t -> 'a t -> bool val filter : 'a t -> f:('a -> bool) -> 'a t val filter_inplace : 'a t -> f:('a -> bool) -> unit (** [inter t1 t2] computes the set intersection of [t1] and [t2]. Runs in O(min(length t1, length t2)). Behavior is undefined if [t1] and [t2] don't have the same equality function. *) val inter : 'key t -> 'key t -> 'key t val union : 'a t -> 'a t -> 'a t val diff : 'a t -> 'a t -> 'a t val of_hashtbl_keys : ('a, _) Hashtbl.t -> 'a t val to_hashtbl : 'key t -> f:('key -> 'data) -> ('key, 'data) Hashtbl.t end type ('key, 'z) create_options = ('key, unit, 'z) Hashtbl_intf.create_options type ('key, 'z) create_options_without_first_class_module = ('key, unit, 'z) Hashtbl_intf.create_options_without_first_class_module module type Creators = sig type 'a t val create : ?growth_allowed:bool (** defaults to [true] *) -> ?size:int (** initial size -- default 0 *) -> 'a Key.t -> 'a t val of_list : ?growth_allowed:bool (** defaults to [true] *) -> ?size:int (** initial size -- default 0 *) -> 'a Key.t -> 'a list -> 'a t end module type Creators_generic = sig type 'a t type 'a elt type ('a, 'z) create_options val create : ('a, unit -> 'a t) create_options val of_list : ('a, 'a elt list -> 'a t) create_options end module type Sexp_of_m = sig type t [@@deriving_inline sexp_of] val sexp_of_t : t -> Sexplib0.Sexp.t [@@@end] end module type M_of_sexp = sig type t [@@deriving_inline of_sexp] val t_of_sexp : Sexplib0.Sexp.t -> t [@@@end] include Hashtbl_intf.Key.S with type t := t end module type M_sexp_grammar = sig type t [@@deriving_inline sexp_grammar] val t_sexp_grammar : t Sexplib0.Sexp_grammar.t [@@@end] end module type Equal_m = sig end module type For_deriving = sig type 'a t module type M_of_sexp = M_of_sexp module type Sexp_of_m = Sexp_of_m module type Equal_m = Equal_m (** [M] is meant to be used in combination with OCaml applicative functor types: {[ type string_hash_set = Hash_set.M(String).t ]} which stands for: {[ type string_hash_set = String.t Hash_set.t ]} The point is that [Hash_set.M(String).t] supports deriving, whereas the second syntax doesn't (because [t_of_sexp] doesn't know what comparison/hash function to use). *) module M (Elt : T.T) : sig type nonrec t = Elt.t t end val sexp_of_m__t : (module Sexp_of_m with type t = 'elt) -> 'elt t -> Sexp.t val m__t_of_sexp : (module M_of_sexp with type t = 'elt) -> Sexp.t -> 'elt t val m__t_sexp_grammar : (module M_sexp_grammar with type t = 'elt) -> 'elt t Sexplib0.Sexp_grammar.t val equal_m__t : (module Equal_m) -> 'elt t -> 'elt t -> bool end module type Hash_set = sig type 'a t [@@deriving_inline sexp_of] val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t [@@@end] (** We use [[@@deriving sexp_of]] but not [[@@deriving sexp]] because we want people to be explicit about the hash and comparison functions used when creating hashtables. One can use [Hash_set.Poly.t], which does have [[@@deriving sexp]], to use polymorphic comparison and hashing. *) module Key = Key module type Creators = Creators module type Creators_generic = Creators_generic module type For_deriving = For_deriving type nonrec ('key, 'z) create_options = ('key, 'z) create_options include Creators with type 'a t := 'a t (** @open *) module type Accessors = Accessors include Accessors with type 'a t := 'a t with type 'a elt = 'a (** @open *) val hashable_s : 'key t -> 'key Key.t type nonrec ('key, 'z) create_options_without_first_class_module = ('key, 'z) create_options_without_first_class_module (** A hash set that uses polymorphic comparison *) module Poly : sig type nonrec 'a t = 'a t [@@deriving_inline sexp, sexp_grammar] include Sexplib0.Sexpable.S1 with type 'a t := 'a t val t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.t [@@@end] include Creators_generic with type 'a t := 'a t with type 'a elt = 'a with type ('key, 'z) create_options := ('key, 'z) create_options_without_first_class_module include Accessors with type 'a t := 'a t with type 'a elt := 'a elt end module Creators (Elt : sig type 'a t val hashable : 'a t Hashable.t end) : sig val t_of_sexp : (Sexp.t -> 'a Elt.t) -> Sexp.t -> 'a Elt.t t include Creators_generic with type 'a t := 'a Elt.t t with type 'a elt := 'a Elt.t with type ('elt, 'z) create_options := ('elt, 'z) create_options_without_first_class_module end include For_deriving with type 'a t := 'a t (**/**) (*_ See the Jane Street Style Guide for an explanation of [Private] submodules: https://opensource.janestreet.com/standards/#private-submodules *) module Private : sig val hashable : 'a t -> 'a Hashable.t end end
core.mli
(** Core LSP protocoal and language types *) module Location : sig type t = { uri : Lang.LUri.File.t ; range : Lang.Range.t } [@@deriving yojson] end (** {1 document/definition} *) module LocationLink : sig type t = { originSelectionRange : Lang.Range.t option [@default None] ; targetUri : Lang.LUri.File.t ; targetRange : Lang.Range.t ; targetSelectionRange : Lang.Range.t } [@@deriving yojson] end (** {1 DocumentSymbols} *) module DocumentSymbol : sig type t = { name : string ; detail : string option [@default None] ; kind : int ; tags : int list option [@default None] ; deprecated : bool option [@default None] ; range : Lang.Range.t ; selectionRange : Lang.Range.t ; children : t list option [@default None] } [@@deriving yojson] end (** Not used as of today, superseded by DocumentSymbol *) module SymInfo : sig type t = { name : string ; kind : int ; location : Location.t } [@@deriving yojson] end (** {1 Hover} *) module HoverContents : sig type t = { kind : string ; value : string } [@@deriving yojson] end module HoverInfo : sig type t = { contents : HoverContents.t ; range : Lang.Range.t option [@default None] } [@@deriving yojson] end (** {1 Completion} *) module LabelDetails : sig type t = { detail : string } [@@deriving yojson] end module TextEditReplace : sig type t = { insert : Lang.Range.t ; replace : Lang.Range.t ; newText : string } [@@deriving yojson] end module CompletionData : sig type t = { label : string ; insertText : string option [@default None] ; labelDetails : LabelDetails.t option [@default None] ; textEdit : TextEditReplace.t option [@default None] ; commitCharacters : string list option [@default None] } [@@deriving yojson] end (** Code Lenses *) module Command : sig type t = { title : string ; command : string ; arguments : Yojson.Safe.t list option [@default None] } [@@deriving yojson] end module CodeLens : sig type t = { range : Lang.Range.t ; command : Command.t option [@default None] ; data : Yojson.Safe.t option [@default None] } [@@deriving yojson] end (** Pull Diagnostics *) module DocumentDiagnosticParams : sig type t = { textDocument : string ; indentifier : string option [@default None] ; previousResultId : string option [@default None] ; workDoneToken : Base.ProgressToken.t option [@default None] ; partialResultToken : Base.ProgressToken.t option [@default None] } [@@deriving of_yojson] end module FullDocumentDiagnosticReport : sig type t = { kind : string ; resultId : string option [@default None] ; items : JLang.Diagnostic.t list (* relatedDocuments to be added in 0.2.x *) } [@@deriving to_yojson] end module UnchangedDocumentDiagnosticReport : sig type t = { kind : string ; resultId : string option [@default None] } [@@deriving to_yojson] end (** partial result: The first literal send need to be a DocumentDiagnosticReport followed by n DocumentDiagnosticReportPartialResult literals defined as follows: *) module DocumentDiagnosticReportPartialResult : sig type t = { relatedDocuments : (Lang.LUri.File.t * FullDocumentDiagnosticReport.t) list } [@@deriving to_yojson] end
(************************************************************************) (* Coq Language Server Protocol *) (* Copyright 2019 MINES ParisTech -- LGPL 2.1+ *) (* Copyright 2019-2023 Inria -- LGPL 2.1+ *) (* Written by: Emilio J. Gallego Arias *) (************************************************************************)
aig_tactic.h
#pragma once #include "util/params.h" class tactic; tactic * mk_aig_tactic(params_ref const & p = params_ref()); /* ADD_TACTIC("aig", "simplify Boolean structure using AIGs.", "mk_aig_tactic()") */
/*++ Copyright (c) 2011 Microsoft Corporation Module Name: aig_tactic.h Abstract: Tactic for minimizing circuits using AIGs. Author: Leonardo (leonardo) 2011-10-24 Notes: --*/
set_term_coeff_fmpz.c
#include "fmpz_mod_mpoly.h" void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, slong i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) { if (i >= (ulong) A->length) flint_throw(FLINT_ERROR, "fmpz_mod_mpoly_set_term_coeff_fmpz: index is out of range"); fmpz_mod_set_fmpz(A->coeffs + i, c, ctx->ffinfo); } void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, slong i, ulong c, const fmpz_mod_mpoly_ctx_t ctx) { if (i >= (ulong) A->length) flint_throw(FLINT_ERROR, "fmpz_mod_mpoly_set_term_coeff_ui: index is out of range"); fmpz_mod_set_ui(A->coeffs + i, c, ctx->ffinfo); } void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, slong i, slong c, const fmpz_mod_mpoly_ctx_t ctx) { if (i >= (ulong) A->length) flint_throw(FLINT_ERROR, "fmpz_mod_mpoly_set_term_coeff_si: index is out of range"); fmpz_mod_set_si(A->coeffs + i, c, ctx->ffinfo); }
/* Copyright (C) 2021 Daniel Schultz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */
nice_parser.ml
let reraise exn = Printexc.(raise_with_backtrace exn (get_raw_backtrace ())) module type RAW_PARSER = sig type token type result exception LexError of string exception ParseError val next_token : Lexing.lexbuf -> token val parse : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> result end module type NICE_PARSER = sig type token type result exception LexError of { msg: string; loc: Location.t } exception ParseError of { token: token; loc: Location.t } val pp_exceptions : unit -> unit val parse_string : ?pos:Lexing.position -> string -> result val parse_chan : ?pos:Lexing.position -> in_channel -> result val parse_file : string -> result end module Make (P : RAW_PARSER) : NICE_PARSER with type token = P.token and type result = P.result = struct type token = P.token type result = P.result exception LexError of { msg: string; loc: Location.t } exception ParseError of { token: token; loc:Location.t } let pp_exceptions () = begin Location.register_error_of_exn (function | LexError {msg; loc} -> Some (Location.error ~loc msg) | ParseError {loc; _} -> Some (Location.error ~loc "[parser] unexpected token") | _ -> None ); Printexc.register_printer (function exn -> try ignore (Format.flush_str_formatter ()); Location.report_exception Format.str_formatter exn; Some (Format.flush_str_formatter ()); with _ -> None ); end let curr_token : token option ref = ref None let next_token lexbuf = let token = P.next_token lexbuf in curr_token := Some token; token let parse ?(file="") lexbuf = Location.input_name := file; Location.input_lexbuf := Some lexbuf; try P.parse next_token lexbuf with | P.LexError msg -> reraise (LexError { msg; loc = Location.curr lexbuf }) | P.ParseError -> let[@warning "-8"] (Some token) = !curr_token in reraise (ParseError { token; loc = Location.curr lexbuf }) let parse_string ?(pos : Lexing.position option) s = match pos with | None -> parse (Lexing.from_string s) | Some ({pos_fname=file; _} as p) -> parse ~file Lexing.{(from_string s) with lex_start_p=p; lex_curr_p=p} let parse_chan ?(pos : Lexing.position option) chan = match pos with | None -> parse (Lexing.from_channel chan) | Some ({pos_fname=file; _} as p) -> parse ~file Lexing.{(from_channel chan) with lex_start_p=p; lex_curr_p=p} let parse_file file = Stdio.In_channel.with_file file ~f:(fun chan -> let lexbuf = Lexing.from_channel chan in Location.init lexbuf file; parse ~file lexbuf ) end
oml_probabilities.ml
type 'a t = ('a * float) list let most_likely = function | [] -> Oml_util.invalid_arg "Probabilities.most_likely: empty probabilities" | h::tl -> ListLabels.fold_left ~f:(fun ((_,p1) as c1) ((_,p2) as c2) -> if p2 > p1 then c2 else c1) ~init:h tl |> fst
(* Copyright 2015,2016: Leonid Rozenberg <leonidr@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *)
Ff_sig.ml
(** Base module signature for a finite field *) module type BASE = sig exception Not_in_field of Bytes.t type t (** The order of the finite field *) val order : Z.t (** minimal number of bytes required to encode a value of the field. *) val size_in_bytes : int (** [check_bytes bs] returns [true] if [bs] is a correct byte representation of a field element *) val check_bytes : Bytes.t -> bool (** The neutral element for the addition *) val zero : t (** The neutral element for the multiplication *) val one : t (** [is_zero x] returns [true] if [x] is the neutral element for the addition *) val is_zero : t -> bool (** [is_one x] returns [true] if [x] is the neutral element for the multiplication *) val is_one : t -> bool (** Use carefully! [random ()] returns a random element of the field. A state for the PRNG can be given to initialize the PRNG in the requested state. If no state is given, no initialisation is performed *) val random : ?state:Random.State.t -> unit -> t (** Use carefully! [non_null_random ()] returns a non null random element of the field. A state for the PRNG can be given to initialize the PRNG in the requested state. If no state is given, no initialisation is performed *) val non_null_random : ?state:Random.State.t -> unit -> t (** [add a b] returns [a + b mod order] *) val add : t -> t -> t (** Infix operator for [add] *) val ( + ) : t -> t -> t (** [sub a b] returns [a - b mod order] *) val sub : t -> t -> t (** [mul a b] returns [a * b mod order] *) val mul : t -> t -> t (** Infix operator for [mul] *) val ( * ) : t -> t -> t (** [eq a b] returns [true] if [a = b mod order], else [false] *) val eq : t -> t -> bool (** Infix operator for [eq] *) val ( = ) : t -> t -> bool (** [negate x] returns [-x mod order]. Equivalently, [negate x] returns the unique [y] such that [x + y mod order = 0] *) val negate : t -> t (** Infix operator for [negate] *) val ( - ) : t -> t (** [inverse_exn x] returns [x^-1] if [x] is not [0], else raise [Division_by_zero] *) val inverse_exn : t -> t (** [inverse_opt x] returns [x^-1] if [x] is not [0] as an option, else [None] *) val inverse_opt : t -> t option (** [div_exn a b] returns [a * b^-1]. Raise [Division_by_zero] if [b = zero] *) val div_exn : t -> t -> t (** [div_opt a b] returns [a * b^-1] as an option. Return [None] if [b = zero] *) val div_opt : t -> t -> t option (** Infix operator for [div_exn] *) val ( / ) : t -> t -> t (** [square x] returns [x^2] *) val square : t -> t (** [double x] returns [2x] *) val double : t -> t (** [pow x n] returns [x^n] *) val pow : t -> Z.t -> t (** Infix operator for [pow] *) val ( ** ) : t -> Z.t -> t (** Construct a value of type [t] from the bytes representation in little endian of the field element. For non prime fields, the encoding starts with the coefficient of the constant monomial. Raise [Not_in_field] if the bytes do not represent an element in the field. *) val of_bytes_exn : Bytes.t -> t (** From a predefined little endian bytes representation, construct a value of type [t]. The same representation than [of_bytes_exn] is used. Return [None] if the bytes do not represent an element in the field. *) val of_bytes_opt : Bytes.t -> t option (** Convert the value t to a bytes representation. The number of bytes is [size_in_bytes] and the encoding must be in little endian. For instance, the encoding of [1] in prime fields is always a bytes sequence of size [size_in_bytes] starting with the byte [0b00000001]. For non prime fields, the encoding starts with the coefficient of the constant monomial. *) val to_bytes : t -> Bytes.t end (** Module type for prime field of the form GF(p) where p is prime *) module type PRIME = sig include BASE (** Returns [s, q] such that [order - 1 = 2^s * q] *) val factor_power_of_two : int * Z.t (** Create a value t from a predefined string representation. It is not required that to_string of_string t = t. By default, decimal representation of the number is used, modulo the order of the field *) val of_string : string -> t (** String representation of a value t. It is not required that to_string of_string t = t. By default, decimal representation of the number is used *) val to_string : t -> string (** [of_z x] builds an element t from the Zarith element [x]. [mod order] is applied if [x >= order] *) val of_z : Z.t -> t (** [to_z x] builds a Zarith element, using the decimal representation. Arithmetic on the result can be done using the modular functions on integers *) val to_z : t -> Z.t (** Returns the Legendre symbol of the parameter. Note it does not work for [p = 2] *) val legendre_symbol : t -> Z.t (** [is_quadratic_residue x] returns [true] if [x] is a quadratic residue i.e. if there exists [n] such that [n^2 mod p = 1] *) val is_quadratic_residue : t -> bool (** [sqrt_opt x] returns a square root of [x] *) val sqrt_opt : t -> t option end (** Module type for prime field with additional functions to manipulate roots of unity *) module type PRIME_WITH_ROOT_OF_UNITY = sig include PRIME (** Returns a nth root of unity *) val get_nth_root_of_unity : Z.t -> t (** [is_nth_root_of_unity n x] returns [true] if [x] is a nth-root of unity*) val is_nth_root_of_unity : Z.t -> t -> bool end
(** Base module signature for a finite field *) module type BASE = sig
js-pipebang.ml
let f x = x >>| fun x -> g x >>| fun x -> h x ;; let f x = x >>| fun x -> g x >>| fun x -> h x ;; let f x = x |! fun x -> g x |! fun x -> h x ;; let f x = x |! fun x -> g x |! fun x -> h x ;; let _ = (z (fun x -> x) |! Validate.of_list) (* Tuareg indents this line too far. *) let _ = (* Tuareg works correctly on this (if you drop the fun). *) (z x |! Validate.of_list) (* jli found this great one. Tuareg gets confused by the paren before List.map and indents |! way too far, under "k ^". ocp-indent should shine, since it understands the syntax better. *) let _ = List.filter_opt [ format old (fun old -> "removed: " ^ (List.map old ~f:(fun (k, v) -> k ^ "=" ^ acl_to_string v) |! String.concat ~sep:", ")) ] (* (|>) = (|!) *) let f x = x |> fun x -> g x |> fun x -> h x ;; let f x = x |> fun x -> g x |> fun x -> h x ;; let _ = (z (fun x -> x) |> Validate.of_list) (* Tuareg indents this line too far. *) let _ = (* Tuareg works correctly on this (if you drop the fun). *) (z x |> Validate.of_list) (* jli found this great one. Tuareg gets confused by the paren before List.map and indents |> way too far, under "k ^". ocp-indent should shine, since it understands the syntax better. *) let _ = List.filter_opt [ format old (fun old -> "removed: " ^ (List.map old ~f:(fun (k, v) -> k ^ "=" ^ acl_to_string v) |> String.concat ~sep:", ")) ]
unix_read_job.c
/* This file is part of Lwt, released under the MIT license. See LICENSE.md for details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. */ #include "lwt_config.h" #if !defined(LWT_ON_WINDOWS) #include <caml/alloc.h> #include <caml/memory.h> #include <caml/mlvalues.h> #include <caml/unixsupport.h> #include <errno.h> #include <string.h> #include "lwt_unix.h" struct job_read { struct lwt_unix_job job; /* The file descriptor. */ int fd; /* The amount of data to read. */ long length; /* The OCaml string. */ value string; /* The offset in the string. */ long offset; /* The result of the read syscall. */ long result; /* The value of errno. */ int error_code; /* The temporary buffer. */ char buffer[]; }; static void worker_read(struct job_read *job) { job->result = read(job->fd, job->buffer, job->length); job->error_code = errno; } static value result_read(struct job_read *job) { long result = job->result; if (result < 0) { int error_code = job->error_code; caml_remove_generational_global_root(&(job->string)); lwt_unix_free_job(&job->job); unix_error(error_code, "read", Nothing); } else { memcpy(Bytes_val(job->string) + job->offset, job->buffer, result); caml_remove_generational_global_root(&(job->string)); lwt_unix_free_job(&job->job); return Val_long(result); } } CAMLprim value lwt_unix_read_job(value val_fd, value val_buffer, value val_offset, value val_length) { long length = Long_val(val_length); LWT_UNIX_INIT_JOB(job, read, length); job->fd = Int_val(val_fd); job->length = length; job->string = val_buffer; job->offset = Long_val(val_offset); caml_register_generational_global_root(&(job->string)); return lwt_unix_alloc_job(&(job->job)); } #endif
/* This file is part of Lwt, released under the MIT license. See LICENSE.md for details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. */
amendment.ml
open Alpha_context (** Returns the proposal submitted by the most delegates. Returns None in case of a tie, if proposal quorum is below required minimum or if there are no proposals. *) let select_winning_proposal ctxt = Vote.get_proposals ctxt >>=? fun proposals -> let merge proposal vote winners = match winners with | None -> Some ([proposal], vote) | Some (winners, winners_vote) as previous -> if Compare.Int32.(vote = winners_vote) then Some (proposal :: winners, winners_vote) else if Compare.Int32.(vote > winners_vote) then Some ([proposal], vote) else previous in match Protocol_hash.Map.fold merge proposals None with | Some ([proposal], vote) -> Vote.listing_size ctxt >>=? fun max_vote -> let min_proposal_quorum = Constants.min_proposal_quorum ctxt in let min_vote_to_pass = Int32.div (Int32.mul min_proposal_quorum max_vote) 100_00l in if Compare.Int32.(vote >= min_vote_to_pass) then return_some proposal else return_none | _ -> return_none (* in case of a tie, let's do nothing. *) (** A proposal is approved if it has supermajority and the participation reaches the current quorum. Supermajority means the yays are more 8/10 of casted votes. The participation is the ratio of all received votes, including passes, with respect to the number of possible votes. The participation EMA (exponential moving average) uses the last participation EMA and the current participation./ The expected quorum is calculated using the last participation EMA, capped by the min/max quorum protocol constants. *) let check_approval_and_update_participation_ema ctxt = Vote.get_ballots ctxt >>=? fun ballots -> Vote.listing_size ctxt >>=? fun maximum_vote -> Vote.get_participation_ema ctxt >>=? fun participation_ema -> Vote.get_current_quorum ctxt >>=? fun expected_quorum -> (* Note overflows: considering a maximum of 8e8 tokens, with roll size as small as 1e3, there is a maximum of 8e5 rolls and thus votes. In 'participation' an Int64 is used because in the worst case 'all_votes is 8e5 and after the multiplication is 8e9, making it potentially overflow a signed Int32 which is 2e9. *) let casted_votes = Int32.add ballots.yay ballots.nay in let all_votes = Int32.add casted_votes ballots.pass in let supermajority = Int32.div (Int32.mul 8l casted_votes) 10l in let participation = (* in centile of percentage *) Int64.(to_int32 (div (mul (of_int32 all_votes) 100_00L) (of_int32 maximum_vote))) in let outcome = Compare.Int32.(participation >= expected_quorum && ballots.yay >= supermajority) in let new_participation_ema = Int32.(div (add (mul 8l participation_ema) (mul 2l participation)) 10l) in Vote.set_participation_ema ctxt new_participation_ema >>=? fun ctxt -> return (ctxt, outcome) (** Implements the state machine of the amendment procedure. Note that [freeze_listings], that computes the vote weight of each delegate, is run at the beginning of each voting period. *) let start_new_voting_period ctxt = Vote.get_current_period_kind ctxt >>=? function | Proposal -> begin select_winning_proposal ctxt >>=? fun proposal -> Vote.clear_proposals ctxt >>= fun ctxt -> Vote.clear_listings ctxt >>=? fun ctxt -> match proposal with | None -> Vote.freeze_listings ctxt >>=? fun ctxt -> return ctxt | Some proposal -> Vote.init_current_proposal ctxt proposal >>=? fun ctxt -> Vote.freeze_listings ctxt >>=? fun ctxt -> Vote.set_current_period_kind ctxt Testing_vote >>=? fun ctxt -> return ctxt end | Testing_vote -> check_approval_and_update_participation_ema ctxt >>=? fun (ctxt, approved) -> Vote.clear_ballots ctxt >>= fun ctxt -> Vote.clear_listings ctxt >>=? fun ctxt -> if approved then let expiration = (* in two days maximum... *) Time.add (Timestamp.current ctxt) (Constants.test_chain_duration ctxt) in Vote.get_current_proposal ctxt >>=? fun proposal -> fork_test_chain ctxt proposal expiration >>= fun ctxt -> Vote.set_current_period_kind ctxt Testing >>=? fun ctxt -> return ctxt else Vote.clear_current_proposal ctxt >>=? fun ctxt -> Vote.freeze_listings ctxt >>=? fun ctxt -> Vote.set_current_period_kind ctxt Proposal >>=? fun ctxt -> return ctxt | Testing -> Vote.freeze_listings ctxt >>=? fun ctxt -> Vote.set_current_period_kind ctxt Promotion_vote >>=? fun ctxt -> return ctxt | Promotion_vote -> check_approval_and_update_participation_ema ctxt >>=? fun (ctxt, approved) -> begin if approved then Vote.get_current_proposal ctxt >>=? fun proposal -> activate ctxt proposal >>= fun ctxt -> return ctxt else return ctxt end >>=? fun ctxt -> Vote.clear_ballots ctxt >>= fun ctxt -> Vote.clear_listings ctxt >>=? fun ctxt -> Vote.clear_current_proposal ctxt >>=? fun ctxt -> Vote.freeze_listings ctxt >>=? fun ctxt -> Vote.set_current_period_kind ctxt Proposal >>=? fun ctxt -> return ctxt type error += (* `Branch *) | Invalid_proposal | Unexpected_proposal | Unauthorized_proposal | Too_many_proposals | Empty_proposal | Unexpected_ballot | Unauthorized_ballot let () = let open Data_encoding in (* Invalid proposal *) register_error_kind `Branch ~id:"invalid_proposal" ~title:"Invalid proposal" ~description:"Ballot provided for a proposal that is not the current one." ~pp:(fun ppf () -> Format.fprintf ppf "Invalid proposal") empty (function Invalid_proposal -> Some () | _ -> None) (fun () -> Invalid_proposal) ; (* Unexpected proposal *) register_error_kind `Branch ~id:"unexpected_proposal" ~title:"Unexpected proposal" ~description:"Proposal recorded outside of a proposal period." ~pp:(fun ppf () -> Format.fprintf ppf "Unexpected proposal") empty (function Unexpected_proposal -> Some () | _ -> None) (fun () -> Unexpected_proposal) ; (* Unauthorized proposal *) register_error_kind `Branch ~id:"unauthorized_proposal" ~title:"Unauthorized proposal" ~description:"The delegate provided for the proposal is not in the voting listings." ~pp:(fun ppf () -> Format.fprintf ppf "Unauthorized proposal") empty (function Unauthorized_proposal -> Some () | _ -> None) (fun () -> Unauthorized_proposal) ; (* Unexpected ballot *) register_error_kind `Branch ~id:"unexpected_ballot" ~title:"Unexpected ballot" ~description:"Ballot recorded outside of a voting period." ~pp:(fun ppf () -> Format.fprintf ppf "Unexpected ballot") empty (function Unexpected_ballot -> Some () | _ -> None) (fun () -> Unexpected_ballot) ; (* Unauthorized ballot *) register_error_kind `Branch ~id:"unauthorized_ballot" ~title:"Unauthorized ballot" ~description:"The delegate provided for the ballot is not in the voting listings." ~pp:(fun ppf () -> Format.fprintf ppf "Unauthorized ballot") empty (function Unauthorized_ballot -> Some () | _ -> None) (fun () -> Unauthorized_ballot) ; (* Too many proposals *) register_error_kind `Branch ~id:"too_many_proposals" ~title:"Too many proposals" ~description:"The delegate reached the maximum number of allowed proposals." ~pp:(fun ppf () -> Format.fprintf ppf "Too many proposals") empty (function Too_many_proposals -> Some () | _ -> None) (fun () -> Too_many_proposals) ; (* Empty proposal *) register_error_kind `Branch ~id:"empty_proposal" ~title:"Empty proposal" ~description:"Proposal lists cannot be empty." ~pp:(fun ppf () -> Format.fprintf ppf "Empty proposal") empty (function Empty_proposal -> Some () | _ -> None) (fun () -> Empty_proposal) (* @return [true] if [List.length l] > [n] w/o computing length *) let rec longer_than l n = if Compare.Int.(n < 0) then assert false else match l with | [] -> false | _ :: rest -> if Compare.Int.(n = 0) then true else (* n > 0 *) longer_than rest (n-1) let record_proposals ctxt delegate proposals = begin match proposals with | [] -> fail Empty_proposal | _ :: _ -> return_unit end >>=? fun () -> Vote.get_current_period_kind ctxt >>=? function | Proposal -> Vote.in_listings ctxt delegate >>= fun in_listings -> if in_listings then Vote.recorded_proposal_count_for_delegate ctxt delegate >>=? fun count -> fail_when (longer_than proposals (Constants.max_proposals_per_delegate - count)) Too_many_proposals >>=? fun () -> fold_left_s (fun ctxt proposal -> Vote.record_proposal ctxt proposal delegate) ctxt proposals >>=? fun ctxt -> return ctxt else fail Unauthorized_proposal | Testing_vote | Testing | Promotion_vote -> fail Unexpected_proposal let record_ballot ctxt delegate proposal ballot = Vote.get_current_period_kind ctxt >>=? function | Testing_vote | Promotion_vote -> Vote.get_current_proposal ctxt >>=? fun current_proposal -> fail_unless (Protocol_hash.equal proposal current_proposal) Invalid_proposal >>=? fun () -> Vote.has_recorded_ballot ctxt delegate >>= fun has_ballot -> fail_when has_ballot Unauthorized_ballot >>=? fun () -> Vote.in_listings ctxt delegate >>= fun in_listings -> if in_listings then Vote.record_ballot ctxt delegate ballot else fail Unauthorized_ballot | Testing | Proposal -> fail Unexpected_ballot let last_of_a_voting_period ctxt l = Compare.Int32.(Int32.succ l.Level.voting_period_position = Constants.blocks_per_voting_period ctxt ) let may_start_new_voting_period ctxt = let level = Level.current ctxt in if last_of_a_voting_period ctxt level then start_new_voting_period ctxt else return ctxt
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
cf_endian_little_aux.c
#include "cf_endian_little_aux.h" #include <stdio.h> /*---------------------------------------------------------------------------* module Unsafe *---------------------------------------------------------------------------*/ CAMLprim value cf_endian_lds16l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); int16_t n = (int16_t) cf_endian_ld16l(p); CAMLreturn(Val_int(n)); } CAMLprim value cf_endian_ldu16l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); uint16_t n = cf_endian_ld16l(p); CAMLreturn(Val_int(n)); } CAMLprim value cf_endian_lds32l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); int32_t n = (int32_t) cf_endian_ld32l(p); CAMLreturn(Val_int(n)); } CAMLprim value cf_endian_ldu32l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); uint32_t n = cf_endian_ld32l(p); CAMLreturn(Val_int(n)); } CAMLprim value cf_endian_lds64l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); int64_t n = (int64_t) cf_endian_ld64l(p); CAMLreturn(Val_int(n)); } CAMLprim value cf_endian_ldu64l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); uint64_t n = cf_endian_ld64l(p); CAMLreturn(Val_int(n)); } CAMLprim uint32_t cf_endian_ldi32l_unsafe_fast(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); CAMLreturn(cf_endian_ld32l(p)); } CAMLprim value cf_endian_ldi32l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); uint32_t n = cf_endian_ldi32l_unsafe_fast(vOctets, vPos); CAMLreturn(caml_copy_int32(n)); } CAMLprim uint64_t cf_endian_ldi64l_unsafe_fast(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); const uint8_t* p = (const uint8_t*) String_val(vOctets) + Long_val(vPos); CAMLreturn(cf_endian_ld64l(p)); } CAMLprim value cf_endian_ldi64l_unsafe(value vOctets, value vPos) { CAMLparam2(vOctets, vPos); uint64_t n = cf_endian_ldi64l_unsafe_fast(vOctets, vPos); CAMLreturn(caml_copy_int64(n)); } CAMLprim void cf_endian_sti16l_unsafe(value vInt, value vOctets, value vPos) { CAMLparam3(vInt, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); uint16_t n = Long_val(vInt); cf_endian_st16l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sts32l_unsafe(value vInt, value vOctets, value vPos) { CAMLparam3(vInt, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); int32_t n = Long_val(vInt); cf_endian_st32l(p, n); CAMLreturn0; } CAMLprim void cf_endian_stu32l_unsafe(value vInt, value vOctets, value vPos) { CAMLparam3(vInt, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); uint32_t n = Long_val(vInt); cf_endian_st32l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sts64l_unsafe(value vInt, value vOctets, value vPos) { CAMLparam3(vInt, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); int64_t n = Long_val(vInt); cf_endian_st64l(p, n); CAMLreturn0; } CAMLprim void cf_endian_stu64l_unsafe(value vInt, value vOctets, value vPos) { CAMLparam3(vInt, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); uint64_t n = Long_val(vInt); cf_endian_st64l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sti32l_unsafe_fast(uint32_t n, value vOctets, value vPos) { CAMLparam2(vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); cf_endian_st32l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sti32l_unsafe(value vInt32, value vOctets, value vPos) { CAMLparam3(vInt32, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); uint32_t n = (uint32_t) Int32_val(vInt32); cf_endian_st32l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sti64l_unsafe_fast(uint64_t n, value vOctets, value vPos) { CAMLparam2(vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); cf_endian_st64l(p, n); CAMLreturn0; } CAMLprim void cf_endian_sti64l_unsafe(value vInt64, value vOctets, value vPos) { CAMLparam3(vInt64, vOctets, vPos); uint8_t* p = (uint8_t*) String_val(vOctets) + Long_val(vPos); uint64_t n = (uint64_t) Int64_val(vInt64); cf_endian_st64l(p, n); CAMLreturn0; } /*--- $File: src/cf/cf_endian_little_aux.c $ ---*/
/*---------------------------------------------------------------------------* Copyright (C) 2017-2019, james woodyatt All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/
obj_hashtable.h
#pragma once #include "util/hash.h" #include "util/hashtable.h" /** \brief Special entry for a hashtable of obj pointers (i.e., objects that have a hash() method). This entry uses 0x0 and 0x1 to represent HT_FREE and HT_DELETED. */ template<typename T> class obj_hash_entry { T * m_ptr = nullptr; public: typedef T * data; unsigned get_hash() const { return m_ptr->hash(); } bool is_free() const { return m_ptr == nullptr; } bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); } bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); } T * get_data() const { return m_ptr; } T * & get_data() { return m_ptr; } void set_data(T * d) { m_ptr = d; } void set_hash(unsigned h) { SASSERT(h == m_ptr->hash()); } void mark_as_deleted() { m_ptr = reinterpret_cast<T *>(1); } void mark_as_free() { m_ptr = nullptr; } }; template<typename T> class obj_hashtable : public core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>, ptr_eq<T> > { public: obj_hashtable(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY): core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>, ptr_eq<T> >(initial_capacity) {} }; template<typename Key, typename Value> class obj_map { public: struct key_data { Key * m_key; Value m_value; key_data():m_key(nullptr), m_value() { } key_data(Key * k): m_key(k), m_value() { } key_data(Key * k, Value const & v): m_key(k), m_value(v) { } key_data(Key * k, Value && v) : m_key(k), m_value(std::move(v)) { } Value const & get_value() const { return m_value; } Key & get_key () const { return *m_key; } unsigned hash() const { return m_key->hash(); } bool operator==(key_data const & other) const { return m_key == other.m_key; } }; class obj_map_entry { key_data m_data; public: typedef key_data data; unsigned get_hash() const { return m_data.hash(); } bool is_free() const { return m_data.m_key == nullptr; } bool is_deleted() const { return m_data.m_key == reinterpret_cast<Key *>(1); } bool is_used() const { return m_data.m_key != reinterpret_cast<Key *>(0) && m_data.m_key != reinterpret_cast<Key *>(1); } key_data const & get_data() const { return m_data; } key_data & get_data() { return m_data; } void set_data(key_data && d) { m_data = std::move(d); } void set_hash(unsigned h) { SASSERT(h == m_data.hash()); } void mark_as_deleted() { m_data.m_key = reinterpret_cast<Key *>(1); } void mark_as_free() { m_data.m_key = nullptr; } }; typedef core_hashtable<obj_map_entry, obj_hash<key_data>, default_eq<key_data> > table; table m_table; public: obj_map(): m_table(DEFAULT_HASHTABLE_INITIAL_CAPACITY) {} typedef typename table::iterator iterator; typedef typename table::data data; typedef typename table::entry entry; typedef Key key; typedef Value value; void reset() { m_table.reset(); } void finalize() { m_table.finalize(); } bool empty() const { return m_table.empty(); } unsigned size() const { return m_table.size(); } unsigned capacity() const { return m_table.capacity(); } iterator begin() const { return m_table.begin(); } iterator end() const { return m_table.end(); } void insert(Key * const k, Value const & v) { m_table.insert(key_data(k, v)); } void insert(Key * const k, Value && v) { m_table.insert(key_data(k, std::move(v))); } Value& insert_if_not_there(Key * k, Value const & v) { return m_table.insert_if_not_there2(key_data(k, v))->get_data().m_value; } obj_map_entry * insert_if_not_there3(Key * k, Value const & v) { return m_table.insert_if_not_there2(key_data(k, v)); } obj_map_entry * find_core(Key * k) const { return m_table.find_core(key_data(k)); } bool find(Key * const k, Value & v) const { obj_map_entry * e = find_core(k); if (e) { v = e->get_data().m_value; } return (nullptr != e); } value const & find(key * k) const { obj_map_entry * e = find_core(k); SASSERT(e); return e->get_data().m_value; } value & find(key * k) { obj_map_entry * e = find_core(k); SASSERT(e); return e->get_data().m_value; } value const & operator[](key * k) const { return find(k); } value & operator[](key * k) { return find(k); } iterator find_iterator(Key * k) const { return m_table.find(key_data(k)); } bool contains(Key * k) const { return find_core(k) != nullptr; } void remove(Key * k) { m_table.remove(key_data(k)); } void erase(Key * k) { remove(k); } unsigned long long get_num_collision() const { return m_table.get_num_collision(); } void get_collisions(Key * k, vector<Key*>& collisions) { vector<key_data> cs; m_table.get_collisions(key_data(k), cs); for (key_data const& kd : cs) { collisions.push_back(kd.m_key); } } void swap(obj_map & other) { m_table.swap(other.m_table); } }; /** \brief Reset and deallocate the values stored in a mapping of the form obj_map<Key, Value*> */ template<typename Key, typename Value> void reset_dealloc_values(obj_map<Key, Value*> & m) { for (auto & kv : m) { dealloc(kv.m_value); } m.reset(); } /** \brief Remove the key k from the mapping m, and delete the value associated with k. */ template<typename Key, typename Value> void erase_dealloc_value(obj_map<Key, Value*> & m, Key * k) { Value * v = 0; bool contains = m.find(k, v); m.erase(k); if (contains) { dealloc(v); } }
/*++ Copyright (c) 2006 Microsoft Corporation Module Name: obj_hashtable.h Abstract: <abstract> Author: Leonardo de Moura (leonardo) 2008-02-16. Revision History: --*/
dune
(library (name foo) (libraries bytes unix findlib) (private_modules privmod) (modules privmod) (preprocess (pps fooppx))) (library (name bar) (modules file) (preprocess (pps fooppx))) (include_subdirs unqualified)
mtime.ml
(* Time spans Time spans are in nanoseconds and we represent them by an unsigned 64-bit integer. This allows to represent spans for: (2^64-1) / 1_000_000_000 / (24 * 3600 * 365.25) ≅ 584.5 Julian years *) type span = int64 (* unsigned nanoseconds *) module Span = struct type t = span let zero = 0L let one = 1L let min_span = zero let max_span = -1L (* Predicates *) let equal = Int64.equal let compare = Int64.unsigned_compare (* Arithmetic *) let add = Int64.add let abs_diff s0 s1 = if compare s0 s1 < 0 then Int64.sub s1 s0 else Int64.sub s0 s1 (* Durations *) let ( * ) n s = Int64.mul (Int64.of_int n) s let ns = 1L let us = 1_000L let ms = 1_000_000L let s = 1_000_000_000L let min = 60_000_000_000L let hour = 3600_000_000_000L let day = 86400_000_000_000L let year = 31_557_600_000_000_000L (* Converting *) let to_uint64_ns s = s let of_uint64_ns ns = ns let max_float_int = 9007199254740992. (* 2^53. *) let int64_min_int_float = Int64.to_float Int64.min_int let int64_max_int_float = Int64.to_float Int64.max_int let of_float_ns sf = if sf < 0. || sf >= max_float_int || not (Float.is_finite sf) then None else Some (Int64.of_float sf) let to_float_ns s = if Int64.compare 0L s <= 0 then Int64.to_float s else int64_max_int_float +. (-. int64_min_int_float +. Int64.to_float s) let unsafe_of_uint64_ns_option nsopt = nsopt (* Formatting *) let pf = Format.fprintf let rec pp_si_span unit_str unit_str_len si_unit si_higher_unit ppf span = let geq x y = Int64.unsigned_compare x y >= 0 in let m = Int64.unsigned_div span si_unit in let n = Int64.unsigned_rem span si_unit in let pp_unit ppf () = Format.pp_print_as ppf unit_str_len unit_str in match m with | m when geq m 100L -> (* No fractional digit *) let m_up = if Int64.equal n 0L then m else Int64.succ m in let span' = Int64.mul m_up si_unit in if geq span' si_higher_unit then pp ppf span' else (pf ppf "%Ld" m_up; pp_unit ppf ()) | m when geq m 10L -> (* One fractional digit w.o. trailing zero *) let f_factor = Int64.unsigned_div si_unit 10L in let f_m = Int64.unsigned_div n f_factor in let f_n = Int64.unsigned_rem n f_factor in let f_m_up = if Int64.equal f_n 0L then f_m else Int64.succ f_m in begin match f_m_up with | 0L -> pf ppf "%Ld" m; pp_unit ppf () | f when geq f 10L -> pp ppf Int64.(add (mul m si_unit) (mul f f_factor)) | f -> pf ppf "%Ld.%Ld" m f; pp_unit ppf () end | m -> (* Two or zero fractional digits w.o. trailing zero *) let f_factor = Int64.unsigned_div si_unit 100L in let f_m = Int64.unsigned_div n f_factor in let f_n = Int64.unsigned_rem n f_factor in let f_m_up = if Int64.equal f_n 0L then f_m else Int64.succ f_m in match f_m_up with | 0L -> pf ppf "%Ld" m; pp_unit ppf () | f when geq f 100L -> pp ppf Int64.(add (mul m si_unit) (mul f f_factor)) | f when Int64.equal (Int64.rem f 10L) 0L -> pf ppf "%Ld.%Ld" m (Int64.div f 10L); pp_unit ppf () | f -> pf ppf "%Ld.%02Ld" m f; pp_unit ppf () and pp_non_si unit_str unit unit_lo_str unit_lo unit_lo_size ppf span = let geq x y = Int64.unsigned_compare x y >= 0 in let m = Int64.unsigned_div span unit in let n = Int64.unsigned_rem span unit in if Int64.equal n 0L then pf ppf "%Ld%s" m unit_str else let f_m = Int64.unsigned_div n unit_lo in let f_n = Int64.unsigned_rem n unit_lo in let f_m_up = if Int64.equal f_n 0L then f_m else Int64.succ f_m in match f_m_up with | f when geq f unit_lo_size -> pp ppf Int64.(add (mul m unit) (mul f unit_lo)) | f -> pf ppf "%Ld%s%Ld%s" m unit_str f unit_lo_str and pp ppf span = let geq x y = Int64.unsigned_compare x y >= 0 in let lt x y = Int64.unsigned_compare x y = -1 in match span with | sp when lt sp us -> pf ppf "%Ldns" sp | sp when lt sp ms -> pp_si_span "\xCE\xBCs" 2 us ms ppf sp | sp when lt sp s -> pp_si_span "ms" 2 ms s ppf sp | sp when lt sp min -> pp_si_span "s" 1 s min ppf sp | sp when lt sp hour -> pp_non_si "min" min "s" s 60L ppf sp | sp when lt sp day -> pp_non_si "h" hour "min" min 60L ppf sp | sp when lt sp year -> pp_non_si "d" day "h" hour 24L ppf sp | sp -> let m = Int64.unsigned_div sp year in let n = Int64.unsigned_rem sp year in if Int64.equal n 0L then pf ppf "%Lda" m else let f_m = Int64.unsigned_div n day in let f_n = Int64.unsigned_rem n day in let f_m_up = if Int64.equal f_n 0L then f_m else Int64.succ f_m in match f_m_up with | f when geq f 366L -> pf ppf "%Lda" (Int64.succ m) | f -> pf ppf "%Lda%Ldd" m f let dump ppf s = Format.fprintf ppf "%Lu" s end (* Monotonic timestamps *) type t = int64 let to_uint64_ns s = s let of_uint64_ns ns = ns let min_stamp = 0L let max_stamp = -1L (* Predicates *) let equal = Int64.equal let compare = Int64.unsigned_compare let is_earlier t ~than = compare t than < 0 let is_later t ~than = compare t than > 0 (* Arithmetic *) let span t0 t1 = if compare t0 t1 < 0 then Int64.sub t1 t0 else Int64.sub t0 t1 let add_span t s = let sum = Int64.add t s in if compare t sum <= 0 then Some sum else None let sub_span t s = if compare t s < 0 then None else Some (Int64.sub t s) (* Formatters *) let pp ppf ns = Format.fprintf ppf "%Luns" ns let dump ppf ns = Format.fprintf ppf "%Lu" ns (*--------------------------------------------------------------------------- Copyright (c) 2015 The mtime programmers Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ---------------------------------------------------------------------------*)
(*--------------------------------------------------------------------------- Copyright (c) 2015 The mtime programmers. All rights reserved. Distributed under the ISC license, see terms at the end of the file. ---------------------------------------------------------------------------*)
queue.ml
open Sihl_contract.Queue open Sihl_core.Container let to_sexp { name; max_tries; retry_delay; _ } = let open Sexplib0.Sexp_conv in let open Sexplib0.Sexp in List [ List [ Atom "name"; sexp_of_string name ] ; List [ Atom "max_tries"; sexp_of_int max_tries ] ; List [ Atom "retry_delay" ; sexp_of_string (Sihl_core.Time.show_duration retry_delay) ] ] ;; let pp fmt t = Sexplib0.Sexp.pp_hum fmt (to_sexp t) let default_tries = 5 let default_retry_delay = Sihl_core.Time.OneMinute let create ~name ~input_to_string ~string_to_input ~handle ?failed () = let failed = failed |> Option.value ~default:(fun _ -> Lwt_result.return ()) in { name ; input_to_string ; string_to_input ; handle ; failed ; max_tries = default_tries ; retry_delay = default_retry_delay } ;; let set_max_tries max_tries job = { job with max_tries } let set_retry_delay retry_delay job = { job with retry_delay } (* Service *) let instance : (module Sig) option ref = ref None let dispatch job ?delay input = let module Service = (val unpack name instance : Sig) in Service.dispatch job ?delay input ;; let register_jobs jobs = let module Service = (val unpack name instance : Sig) in Service.register_jobs jobs ;; let lifecycle () = let module Service = (val unpack name instance : Sig) in Service.lifecycle ;; let register ?(jobs = []) implementation = let module Service = (val implementation : Sig) in instance := Some implementation; Service.register ~jobs () ;;
extract_prototype.ml
open Xml let debug = ref false let included_modules = Hashtbl.create 17 let ml_header = Buffer.create 99 let add_ml_header s = Buffer.add_string ml_header s let () = add_ml_header "type -'a obj\n" let c_header= Buffer.create 99 let add_c_header s = Buffer.add_string c_header s let pre_fill_header () = add_c_header "#include <caml/mlvalues.h>\n\ #include <caml/alloc.h>\n\ #define Val_double(val) caml_copy_double(val)\n\ #define Val_string_new(val) caml_copy_string(val)\n\ #define Val_int32(val) caml_copy_int32(val)\n\ #define Val_int32_new(val) caml_copy_int32(val)\n" let () = pre_fill_header () let reset_headers () = Buffer.clear ml_header; Buffer.clear c_header; pre_fill_header () (* #include <gtk/gtk.h> #define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API #include <gtk/gtktextdisplay.h> #include <gdk/gdkprivate.h> #include <glib/gstdio.h> *) module SSet= Set.Make(struct type t = string let compare = Pervasives.compare end) let caml_avoid = List.fold_right SSet.add ["let";"external";"open";"true";"false";"exit"; "match"] SSet.empty let is_caml_avoid s = let c = Char.lowercase_ascii (s.[0]) in let s = Bytes.of_string s in Bytes.set s 0 c ; let s = Bytes.to_string s in SSet.mem s caml_avoid type c_simple_stub = {cs_nb_arg:int; cs_c_name:string; cs_ret:string; cs_params:string list} type c_stub = Simple of c_simple_stub | Complex of string type ml_stub = { ms_c_name:string; ms_ml_name:string; ms_ret:string; ms_params:string list; } type stub = { stub_c:c_stub; stub_external:ml_stub; } type transfer_ownership = ODefault | OFull | ONone | OContainer type direction = DDefault | DIn | DOut | DInOut type c_typ = { mutable t_name:string; mutable t_c_typ:string; mutable t_content: c_typ option } type c_array = { mutable a_c_typ:string; mutable a_fixed_size:string; mutable a_zero_terminated: string; mutable a_length: string; (* rank of arg containing length?*) mutable a_typ: c_typ } type bf_member = { mutable bfm_name:string; mutable bfm_value:string; mutable bfm_c_identifier:string; } type bf = { mutable bf_name:string; mutable bf_ctype:string; mutable bf_members: bf_member list } type typ = NoType | Array of c_array | Typ of c_typ type parameter = { mutable p_name:string; mutable p_ownership: transfer_ownership; mutable p_typ: typ; mutable p_scope:string; mutable p_closure:string; mutable p_destroy:string; mutable p_direction:direction; mutable p_allow_none:bool; mutable p_caller_allocates:bool; mutable p_doc:string; mutable p_varargs:bool; } type return_value = { mutable r_ownership: transfer_ownership; mutable r_typ : typ; mutable r_doc : string; } type function_ = { mutable f_name:string; mutable c_identifier:string; mutable version:string; mutable doc:string; mutable return_value: return_value; mutable parameters: parameter list; mutable deprecated: string; mutable deprecated_version:string; mutable throws: bool; mutable introspectable: bool; } type constant = { mutable const_name:string; mutable const_type:c_typ; mutable const_value:string; } type constructor = function_ type c_method = function_ type property = { mutable pr_name:string; mutable pr_version:string; mutable pr_writable:bool; mutable pr_readable:bool; mutable pr_construct:bool; mutable pr_construct_only:bool; mutable pr_doc:string; mutable pr_typ:typ;} type signal type klass = {mutable c_name:string; mutable c_c_type:string; mutable c_abstract:bool; mutable c_doc:string; mutable c_parent:string; mutable c_glib_type_name:string; mutable c_glib_get_type:string; mutable c_glib_type_struct:string; mutable c_constructors: constructor list; mutable c_methods: c_method list; mutable c_functions: function_ list; mutable c_properties : property list; mutable c_glib_signals : signal list; mutable c_disguised:bool } type namespace = { mutable ns_name: string; mutable ns_c_symbol_prefixes: string; mutable ns_c_identifier_prefixes: string; mutable ns_version: string; mutable ns_constants: constant list; mutable ns_klass: klass list; mutable ns_functions: function_ list; mutable ns_bf: bf list; mutable ns_shared_library: string; } type included = { mutable inc_name: string; mutable inc_version: string; } type package = { mutable pack_name: string; } type c_include = { mutable c_inc_name: string; } type repository = { mutable rep_version:string; mutable rep_xmlns:string; mutable rep_xmlns_c:string; mutable rep_xmlns_glib:string; mutable rep_includes: included list; mutable rep_package: package; mutable rep_c_include: c_include; mutable rep_namespace: namespace; } module Pretty = struct let rec pp_list sep fmt l = match l with | [] -> () | e::r -> Format.fprintf fmt "%s%s" e sep; pp_list sep fmt r let rec pp_args sep fmt l = match l with | [] -> () | (n,v)::r -> Format.fprintf fmt "'%s'='%s'%s" n v sep; pp_args sep fmt r end let dummy_bfm () = { bfm_c_identifier="";bfm_value="";bfm_name=""} let dummy_bf () = { bf_name="";bf_ctype="";bf_members=[] } let dummy_ownership () = ODefault let dummy_typ () = NoType let dummy_c_typ () = {t_name="";t_c_typ="";t_content=None} let dummy_array () = {a_c_typ=""; a_fixed_size=""; a_zero_terminated=""; a_length=""; a_typ= dummy_c_typ(); } let dummy_parameter () = {p_name="";p_ownership=dummy_ownership (); p_typ=dummy_typ (); p_scope="";p_closure="";p_destroy="";p_direction=DDefault; p_caller_allocates=true; p_allow_none=false;p_doc="";p_varargs=false;} let dummy_property () = {pr_name="";pr_version=""; pr_typ=dummy_typ (); pr_writable=false; pr_readable=true; pr_construct=false; pr_construct_only=false; pr_doc="";} let dummy_return_value () = {r_ownership=dummy_ownership (); r_typ=dummy_typ(); r_doc=""} let dummy_function () = { f_name="";c_identifier="";version="";doc=""; return_value=dummy_return_value (); parameters= [];deprecated=""; deprecated_version="";throws=false;introspectable=true;} let dummy_constant () = {const_name="";const_type=dummy_c_typ();const_value=""} let dummy_klass () = { c_name=""; c_c_type = ""; c_abstract = false; c_disguised=false; c_doc = ""; c_parent=""; c_glib_type_name=""; c_glib_get_type=""; c_glib_type_struct=""; c_constructors=[]; c_methods=[]; c_functions=[]; c_properties=[]; c_glib_signals=[]; } let dummy_namespace () = { ns_name="<dummy>"; ns_c_symbol_prefixes=""; ns_c_identifier_prefixes=""; ns_version="0"; ns_klass = []; ns_functions = []; ns_constants= []; ns_shared_library = ""; ns_bf=[]; } let dummy_package () = {pack_name = "<dummy>";} let dummy_c_include () = { c_inc_name = "<dummy>";} let dummy_repository () = { rep_version=""; rep_xmlns = ""; rep_xmlns_c = ""; rep_xmlns_glib = ""; rep_includes = []; rep_package = dummy_package (); rep_c_include = dummy_c_include (); rep_namespace = dummy_namespace (); } let debug_ownership fmt o = Format.fprintf fmt "%s" (match o with | ODefault -> "default" | OFull -> "full" | ONone -> "none" | OContainer -> "container") let debug_array fmt a = Format.fprintf fmt "ARRAY" let debug_ctyp fmt t = Format.fprintf fmt "@[tname:%s@]@ @[t_c_typ:%s@]" t.t_name t.t_c_typ let debug_typ fmt t = match t with | NoType -> Format.fprintf fmt "NOTYPE" | Array a -> debug_array fmt a | Typ t -> debug_ctyp fmt t let debug_parameter fmt p = Format.fprintf fmt "(%a%s%s) @[%a@]%s@ " debug_ownership p.p_ownership (match p.p_direction with | DDefault -> "" | DIn -> ",in" | DOut -> ",out" | DInOut -> ",inout") (if p.p_allow_none then ",?" else "") debug_typ p.p_typ (if p.p_caller_allocates then "" else "(not caller allocates)") let debug_parameters fmt l = let c = ref 0 in List.iter (fun p -> Format.fprintf fmt "param %d:@[%a@]@\n" !c debug_parameter p; incr c;) l let debug_return_value fmt r = Format.fprintf fmt "(%a) %a" debug_ownership r.r_ownership debug_typ r.r_typ let debug_function fmt l = Format.fprintf fmt "@[Name='%s'@ C:'%s'@ Version:'%s'@ Deprecated since '%s'(%s)@\n\ Returns: @[%a@]@\n\ Args:@[%a@]@]" l.f_name l.c_identifier l.version l.deprecated_version l.deprecated debug_return_value l.return_value debug_parameters l.parameters let debug_property fmt p = Format.fprintf fmt "@[Name='%s'@ Version:'%s'@ Writable:%b Readable:%b@\n\ Type: @[%a@]@]" p.pr_name p.pr_version p.pr_writable p.pr_readable debug_typ p.pr_typ let debug_klass fmt k = Format.fprintf fmt "@[<hov 1>Class: '%s'@ Parent:'%s'@ Abstract:%b@ \ C type:'%s'@ get_type:'%s'" k.c_name k.c_parent k.c_abstract k.c_glib_type_name k.c_glib_get_type ; List.iter (fun f -> Format.fprintf fmt "Constructor %a@\n" debug_function f) k.c_constructors; List.iter (fun f -> Format.fprintf fmt "Function %a@\n" debug_function f) k.c_functions; List.iter (fun f -> Format.fprintf fmt "Method %a@\n" debug_function f) k.c_methods; List.iter (fun f -> Format.fprintf fmt "Property %a@\n" debug_property f) k.c_properties; Format.fprintf fmt "@]" let debug_namespace fmt n = Format.fprintf fmt "@[<hov 1>Namespace: '%s'@ " n.ns_name; List.iter (fun k -> Format.fprintf fmt "@[%a@]@\n" debug_klass k) n.ns_klass; Format.fprintf fmt "@]@\n" let debug_repository fmt rep = Format.fprintf fmt "@[<hov 1>Repository: '%s'@ " rep.rep_version; debug_namespace fmt rep.rep_namespace; Format.fprintf fmt "@]@\n" exception Cannot_emit of string let fail_emit s = raise (Cannot_emit s) module Translations = struct let tbl = Hashtbl.create 17 let base_translation = [ ["gboolean"],("Val_bool","Bool_val",fun _ ->"bool"); [ "int"; "gint";"guint";"guint8";"gint8"; "guint16";"gint16"; "gushort"; "char";"gchar";"guchar"; "gssize";"gsize"], ("Val_int","Int_val",fun _ -> "int"); [ "gint32";"guint32";"gunichar"], ("Val_int32","Int32_val",fun _ -> "int32"); [ "gint64";"guint64";], ("Val_int64","Int64_val",fun _ -> "int64"); [ "void" ] , ("Unit","void_param????",fun _ -> "unit"); ["gdouble"; "long double"; "glong"; "gulong" ; "double"] , ("Val_double","Double_val",fun _ -> "float"); [ "gchar*";"char*"; "guchar*" ], ("Val_string","String_val",fun _ -> "string"); ] let () = List.iter (fun (kl,v) -> List.iter (fun k -> Hashtbl.add tbl k v) kl) base_translation let find k = try Hashtbl.find tbl k with Not_found -> fail_emit ("Cannot translate type " ^k) let to_type_macro s = match s with | "GtkCList" -> "GTK_CLIST" | "GtkCTree" -> "GTK_CTREE" | "GtkHSV" -> "GTK_HSV" | "GtkIMContext" -> "GTK_IM_CONTEXT" | "GtkIMMulticontext" -> "GTK_IM_MULTICONTEXT" | "GtkUIManager" -> "GTK_UI_MANAGER" | "GdkDisplay" -> "GDK_DISPLAY_OBJECT" | "GdkGC" -> "GDK_GC" | _ -> let length = String.length s in if length <= 1 then String.uppercase_ascii s else let buff = Buffer.create (length+3) in Buffer.add_char buff s.[0]; for i=1 to length-1 do if 'A'<=s.[i] && s.[i]<='Z' then begin Buffer.add_char buff '_'; Buffer.add_char buff s.[i] end else Buffer.add_char buff (Char.uppercase_ascii s.[i]) done; Buffer.contents buff let add_klass_type ~is_record c_typ = if c_typ <> "" then let val_of = "Val_"^c_typ in let of_val = c_typ^"_val" in if is_record then begin add_c_header (Format.sprintf "/*TODO: conversion for record '%s' */@." c_typ) end else begin add_c_header (Format.sprintf "#define %s(val) check_cast(%s,val)@." of_val (to_type_macro c_typ)); add_c_header (Format.sprintf "#define %s(val) Val_GObject((GObject*)val)@." val_of); add_c_header (Format.sprintf "#define %s_new(val) Val_GObject_new((GObject*)val)@." val_of); end; Hashtbl.add tbl (c_typ^"*") (val_of,of_val, fun variance -> Format.sprintf "[%c`%s] obj" variance (String.lowercase_ascii c_typ)) end let repositories = ref [] let register_reposirory n = repositories:=n::!repositories let get_repositories () = List.rev !repositories module Emit = struct let emit_parameter rank p = match p.p_typ with | NoType -> fail_emit "NoType(p)" | Array _ -> fail_emit "Array(TODO)" | Typ ct -> match p.p_direction with | DIn | DDefault -> let ctyp = match p.p_ownership with | OFull -> ct.t_c_typ ^"*" | _ -> ct.t_c_typ in let _,c_base,ml_base = Translations.find ctyp in let ml_base = ml_base '>' in if p.p_allow_none then Format.sprintf "Option_val(arg%d,%s,NULL) Ignore" rank c_base, ml_base^" option" else c_base,ml_base | DOut | DInOut -> fail_emit "(out)" let emit_parameters throws l = let l = if throws then let gerror = dummy_parameter()in let t = dummy_c_typ () in t.t_c_typ<-"GError**"; gerror.p_name<-"error"; gerror.p_typ<-Typ t; l@[gerror] else l in let counter = ref 0 in List.split (List.map (fun p -> incr counter;emit_parameter !counter p) l) let emit_return_value r = match r.r_typ with | NoType -> fail_emit "NoType" | Array _ -> fail_emit "Array" | Typ ct -> let c_typ,_,ml_typ = Translations.find ct.t_c_typ in match r.r_ownership with | OFull -> c_typ ^ "_new",ml_typ | ONone | ODefault | OContainer -> c_typ,ml_typ let emit_prototype f = let nb_args = List.length f.parameters in let c_params,ml_params = emit_parameters f.throws f.parameters in let c_ret,ml_ret = emit_return_value f.return_value in let ml_ret = ml_ret '<' in {stub_c=Simple {cs_nb_arg=nb_args; cs_c_name=f.c_identifier; cs_ret=c_ret; cs_params=c_params}; stub_external={ms_c_name="ml_"^f.c_identifier; ms_ml_name=f.f_name; ms_ret=ml_ret; ms_params= match ml_params with | [] -> ["unit"] | _ -> ml_params;}} let emit_method k m = try let self = dummy_parameter()in let t = dummy_c_typ () in t.t_c_typ<-k.c_c_type^"*"; self.p_name<-"self"; self.p_typ<-Typ t; let nb_args = List.length m.parameters+1 in let c_params,ml_params = emit_parameters m.throws (self::m.parameters) in let c_ret,ml_ret = emit_return_value m.return_value in let ml_ret = ml_ret '<' in Some {stub_c=Simple {cs_nb_arg=nb_args; cs_c_name=m.c_identifier; cs_ret=c_ret; cs_params=c_params}; stub_external={ms_c_name="ml_"^m.c_identifier; ms_ml_name=m.f_name; ms_ret=ml_ret; ms_params=ml_params;}} with Cannot_emit s -> Format.printf "Cannot emit method %s::%S '%s'@." k.c_name m.f_name s; None let emit_function p = try Some (emit_prototype p) with Cannot_emit s -> Format.printf "Cannot emit function %s:'%s'@." p.c_identifier s; None let emit_klass k = let methods = List.map (emit_method k) k.c_methods in let functions = List.map emit_function k.c_functions in k.c_name,methods,functions module Print = struct open Pretty let c_stub fmt s = match s with | Simple s -> Format.fprintf fmt "ML_%d(%s,%a%s)@\n" s.cs_nb_arg s.cs_c_name (pp_list ", ") s.cs_params s.cs_ret; if s.cs_nb_arg>=6 then Format.fprintf fmt "ML_bc%d(ml_%s)@ " s.cs_nb_arg s.cs_c_name | Complex s -> Format.fprintf fmt "%s@." s let ml_stub fmt s = Format.fprintf fmt "external %s: %a%s = \"%s\"@ " s.ms_ml_name (pp_list " -> ") s.ms_params s.ms_ret s.ms_c_name let stub fmt s = Format.fprintf fmt "=====@.%a%a@." c_stub s.stub_c ml_stub s.stub_external let may_ml_stub fmt s = match s with | Some s -> ml_stub fmt s.stub_external | None -> () let may_c_stub fmt s = match s with | Some s -> c_stub fmt s.stub_c | None -> () let klass ~ml ~c (k_name,methods,functions) = Format.fprintf ml "@[<hv 2>module %s = struct@\n" k_name; List.iter (may_ml_stub ml) methods; List.iter (may_ml_stub ml) functions; Format.fprintf ml "@]end@\n"; Format.fprintf c "@[/* Module %s */@\n" k_name; List.iter (may_c_stub c) methods; List.iter (may_c_stub c) functions; Format.fprintf c "@]/* end of %s */@\n" k_name let functions ~ml ~c f = Format.fprintf ml "@[(* Global functions *)@\n"; List.iter (may_ml_stub ml) f; Format.fprintf ml "(* End of global functions *)@]@\n"; Format.fprintf c "@[/* Global functions */@\n"; List.iter (may_c_stub c) f; Format.fprintf c "/* End of global functions */@]@\n" let repository r = let n = r.rep_namespace in let stub_ml_channel = open_out ("stubs/stubs_"^n.ns_name^".ml") in let ml = Format.formatter_of_out_channel stub_ml_channel in let stub_c_channel = open_out ("stubs/ml_stubs_"^n.ns_name^".c") in let c = Format.formatter_of_out_channel stub_c_channel in Format.fprintf ml "%s@\n" (Buffer.contents ml_header); Format.fprintf c "%s@\n" (Buffer.contents c_header); Format.fprintf c "#include <%s>@." r.rep_c_include.c_inc_name; Format.fprintf c "#include \"../wrappers.h\"@\n\ #include \"../ml_gobject.h\"@."; List.iter (klass ~ml ~c) (List.map emit_klass n.ns_klass); functions ~ml ~c (List.map emit_function n.ns_functions); Format.fprintf ml "@."; Format.fprintf c "@."; close_out stub_ml_channel; close_out stub_c_channel end end let debug_all () = Format.printf "ALL REPOSITORIES:@."; List.iter (fun ns -> debug_repository Format.std_formatter ns) (get_repositories ()) let rec parse_c_typ set attrs children = let typ = dummy_c_typ () in List.iter (fun (key,v) -> match key with | "name" -> typ.t_name <- v | "c:type" -> typ.t_c_typ <- v | other -> Format.printf "Ignoring attribute in typ:%s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in type:%s@." s | Element (key,attrs,children) -> match key with | "type" -> parse_c_typ (fun t -> typ.t_content <- Some t) attrs children | other -> Format.printf "Ignoring child in typ:%s@." other) children; set typ let parse_type_name set attrs = let typ = dummy_c_typ () in List.iter (fun (key,v) -> match key with | "name" -> typ.t_name <- v | "c:type" -> typ.t_c_typ <- v | other -> Format.printf "Ignoring attribute in basic typ %s:%s@." typ.t_name other) attrs; set typ let parse_alias attrs children = let fresh = ref (dummy_c_typ ()) in parse_type_name (fun t -> fresh := t) attrs; let old = ref (dummy_c_typ ()) in List.iter (function | PCData s -> Format.printf "Ignoring PCData in type alias %s:%s@." !fresh.t_name s | Element (key,attrs,children) -> (match key with | "type" -> parse_type_name (fun t -> old := t) attrs | "doc" when not !debug -> () | other -> Format.printf "Ignoring child in type alias %s:%s@." !fresh.t_name other)) children; if !debug then Format.printf "Parsing alias: %s@." !fresh.t_name; let old_trans = Translations.find !old.t_c_typ in Hashtbl.add Translations.tbl !fresh.t_c_typ old_trans let parse_constant set attrs children = let result = dummy_constant () in List.iter (fun (key,v) -> match key with | "name" -> result.const_name <- v | "value" -> result.const_value <- v | other -> Format.printf "Ignoring attribute in constant %s:%s@." result.const_name other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in constant %s:%s@." result.const_name s | Element (key,attrs,children) -> (match key with | "type" -> parse_type_name (fun t -> result.const_type <- t) attrs | other -> Format.printf "Ignoring child in constant %s:%s@." result.const_name other)) children; set result let parse_ownership set s = match s with "full" -> set OFull | "none" -> set ONone | "container" -> set OContainer | s -> Format.printf "Ignoring ownership transfer '%s'@." s let parse_array set attrs children = let r = dummy_array () in List.iter (fun (key,v) -> match key with | "c:type" -> r.a_c_typ <- v | "length" -> r.a_length <- v | "name" when not !debug -> () | other -> Format.printf "Ignoring attribute in array: %s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in array:%s@." s | Element (key,attrs,children) -> match key with | "type" -> parse_c_typ (fun t -> r.a_typ <-t) attrs children | other -> Format.printf "Ignoring child in array:%s@." other) children; set r let parse_return_value set attrs children = let r = dummy_return_value () in List.iter (fun (key,v) -> match key with | "transfer-ownership" -> parse_ownership (fun o -> r.r_ownership <-o) v | "doc" -> r.r_doc <- v | other -> Format.printf "Ignoring attribute in return-value:%s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in return-value:%s@." s | Element (key,attrs,children) -> match key with | "type" -> parse_c_typ (fun t -> assert (r.r_typ= NoType); r.r_typ <-Typ t) attrs children | "array" -> parse_array (fun t -> assert (r.r_typ= NoType); r.r_typ <- Array t) attrs children | "doc" when not !debug -> () | other -> Format.printf "Ignoring child in return-value:%s@." other) children; set r let parse_property set attrs children = let p = dummy_property () in List.iter (fun (key,v) -> match key with | "name" -> p.pr_name <- v | "doc" -> p.pr_doc <- v | "version" -> p.pr_version <- v | "writable" -> p.pr_writable <- v="1" | "readable" -> p.pr_readable <- v="1" | "construct" -> p.pr_construct <- v="1" | "construct-only" -> p.pr_construct_only <- v="1" | other -> Format.printf "Ignoring attribute in property:%s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in property:%s@." s | Element (key,attrs,children) -> match key with | "type" -> parse_c_typ (fun t -> assert (p.pr_typ=NoType); p.pr_typ <-Typ t) attrs children | "array" -> parse_array (fun t -> assert (p.pr_typ= NoType); p.pr_typ <- Array t) attrs children | other -> Format.printf "Ignoring child in property:%s@." other) children; set p let parse_parameter set attrs children = let r = dummy_parameter () in List.iter (fun (key,v) -> match key with | "name" -> r.p_name <- v | "transfer-ownership" -> parse_ownership (fun o -> r.p_ownership <- o) v | "scope" -> r.p_scope <- v | "closure" -> r.p_closure <- v | "destroy" -> r.p_destroy <- v | "direction" -> begin match v with | "in" -> r.p_direction <- DIn | "out" -> r.p_direction <- DOut | "inout" -> r.p_direction <- DInOut | s -> Format.printf "Ignoring direction in parameter: %s@." s end | "allow-none" -> r.p_allow_none <- v="1" | "caller-allocates" -> r.p_caller_allocates <- v="1" | "doc" -> r.p_doc <- v | other -> Format.printf "Ignoring attribute in parameter: %s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in parameter:%s@." s | Element (key,attrs,children) -> match key with | "type" -> parse_c_typ (fun t -> r.p_typ <- Typ t) attrs children | "varargs" -> r.p_varargs <- true | "array" -> parse_array (fun t -> r.p_typ <- Array t) attrs children | "doc" when not !debug -> () | other -> Format.printf "Ignoring child in parameter:%s@." other) children; set r let parse_parameters set attrs children = let r = ref [] in List.iter (fun (key,v) -> match key with | other -> Format.printf "Ignoring attribute in parameters:%s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in parameters:%s@." s | Element (key,attrs,children) -> match key with | "parameter" -> parse_parameter (fun t -> r := t::!r) attrs children | "doc" when not !debug -> () | other -> Format.printf "Ignoring child in parameters:%s@." other) children; set (List.rev !r) let parse_bf set attrs children = let bf = dummy_bf () in set bf let parse_function set attrs children = let fct = dummy_function () in List.iter (fun (key,v) -> match key with | "name" -> fct.f_name <- v | "c:identifier" -> fct.c_identifier <- v | "version" -> fct.version <- v | "doc" -> fct.doc <- v | "deprecated" -> fct.deprecated <- v | "deprecated-version" -> fct.deprecated_version <- v | "throws" -> fct.throws <- v="1" | "introspectable" -> fct.introspectable <- v="1" | other -> Format.printf "Ignoring attribute in fct: %s@." other) attrs; if is_caml_avoid fct.f_name then fct.f_name <- fct.c_identifier; List.iter (function | PCData s -> Format.printf "Ignoring PCData in fct:%s@." s | Element (key,attrs,children) -> match key with | "return-value" -> parse_return_value (fun r -> fct.return_value <- r) attrs children | "parameters" -> parse_parameters (fun l -> fct.parameters <- l) attrs children | "doc" when not !debug -> () | other -> Format.printf "Ignoring fct child: %s@." other) children; set fct let parse_constructor set attrs children = parse_function set attrs children let parse_method set attrs children = parse_function set attrs children let parse_klass ~is_record set attrs children = let k = dummy_klass () in List.iter (fun (key,v) -> match key with | "name" -> k.c_name <- v | "c:type" -> k.c_c_type <- v | "doc" -> k.c_doc <- v | "parent" -> k.c_parent <- v | "glib:type-name" -> k.c_glib_type_name <- v | "glib:get-type" -> k.c_glib_get_type <- v | "glib:type-struct" -> k.c_glib_type_struct <- v | "abstract" -> k.c_abstract<- v="1" | "disguised" -> k.c_disguised<- v="1" | "version" when not !debug -> () | other -> Format.printf "Ignoring attribute in klass %s: %s@." k.c_name other) attrs; Translations.add_klass_type ~is_record k.c_c_type; List.iter (function | PCData s -> Format.printf "Ignoring PCData in klass %s:%s@." k.c_name s | Element (key,attrs,children) -> match key with | "function" -> parse_function (fun f -> k.c_functions <- f::k.c_functions) attrs children | "constructor" -> parse_constructor (fun f -> k.c_constructors <- f::k.c_constructors) attrs children | "method" -> parse_method (fun f -> k.c_methods <- f::k.c_methods) attrs children | "property" -> parse_property (fun f -> k.c_properties <- f::k.c_properties) attrs children | "field"|"implements"|"virtual-method"|"doc" -> if !debug then Format.printf "Ignoring unused child in klass %s: %s@." k.c_name key | other -> Format.printf "Ignoring child in klass %s: %s@." k.c_name other) children; set k let parse_package set attrs = let k = dummy_package () in List.iter (fun (key,v) -> match key with | "name" -> k.pack_name <- v | other -> Format.printf "Ignoring attribute in package %s: %s@." k.pack_name other) attrs; set k let parse_c_include set attrs = let k = dummy_c_include () in List.iter (fun (key,v) -> match key with | "name" -> k.c_inc_name <- v | other -> Format.printf "Ignoring attribute in c_include %s: %s@." k.c_inc_name other) attrs; set k let rec parse_repository set dir attrs children = let k = dummy_repository () in List.iter (fun (key,v) -> match key with | "version" -> k.rep_version <- v | "xmlns" -> k.rep_xmlns <- v | "xmlns:c" -> k.rep_xmlns_c <- v | "xmlns:glib" -> k.rep_xmlns_glib <- v | other -> Format.printf "Ignoring attribute in repository: %s@." other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in repository:%s@." s | Element (key,attrs,children) -> match key with | "include" -> assert (children = []); parse_include (fun f -> k.rep_includes <- f::k.rep_includes) dir attrs | "package" -> assert (children = []); parse_package (fun f -> k.rep_package <- f) attrs | "c:include" -> assert (children=[]); parse_c_include (fun f -> k.rep_c_include <- f) attrs | "namespace" -> parse_namespace (fun f -> k.rep_namespace <- f) attrs children | other -> Format.printf "Ignoring child in repository: %s@." other) children; set k and parse_xml dir x = match x with | PCData c -> Format.printf "CDATA: %S@ " c | Element ("repository",attrs,children) -> parse_repository register_reposirory dir attrs children | Element (key,attrs,children) -> let children = begin match key with | other -> Format.printf "Ignoring toplevel child:%s@." other; children end in List.iter (parse_xml dir) children and parse_include set dir args = match args with | ["name",name;"version",version] -> if not (Hashtbl.mem included_modules name) then begin Hashtbl.add included_modules name (); Format.printf "Including %s@." name; parse dir (name^"-"^version^".gir") end; set { inc_name = name; inc_version=version;} | _ -> Format.printf "Cannot parse include: %a@." (Pretty.pp_args ";") args and parse_namespace set attrs children = let n = dummy_namespace () in List.iter (fun (key,v) -> match key with | "name" -> n.ns_name <- v | "version" -> n.ns_version <- v | "shared-library" -> n.ns_shared_library <- v | "c:identifier-prefixes" -> n.ns_c_identifier_prefixes <- v | "c:symbol-prefixes" -> n.ns_c_symbol_prefixes <- v | other -> Format.printf "Ignoring attribute in namespace %s: %s@." n.ns_name other) attrs; List.iter (function | PCData s -> Format.printf "Ignoring PCData in namespace %s:%s@." n.ns_name s | Element (key,attrs,children) -> try match key with | "constant" -> parse_constant (fun c -> n.ns_constants <- c::n.ns_constants) attrs children | "function" -> parse_function (fun f -> n.ns_functions <- f::n.ns_functions) attrs children | "alias" -> parse_alias attrs children | "record" -> parse_klass ~is_record:true (fun k -> n.ns_klass <- k::n.ns_klass) attrs children | "class" -> parse_klass ~is_record:false (fun k -> n.ns_klass <- k::n.ns_klass) attrs children | "bitfield" -> parse_bf (fun k -> n.ns_bf <- k::n.ns_bf) attrs children | other -> Format.printf "Ignoring child in namespace %s: %s@." n.ns_name other with Cannot_emit s -> Format.printf "Could not emit %s(%a) because %s@." key (Pretty.pp_args ";") attrs s) children; set n and parse dir f = try let full = Filename.concat dir f in Format.printf "Parsing '%s'@." full; let xml = Xml.parse_file full in parse_xml dir xml with Xml.Error m -> Format.printf "XML error:%s@." (Xml.error m); exit 1 let () = for i=1 to Array.length Sys.argv - 1 do let name=Filename.basename Sys.argv.(i) in let dir = Filename.dirname Sys.argv.(i) in parse dir name done; debug_all(); List.iter Emit.Print.repository (get_repositories ()) (* let funcs,klass = emit_all () in let stub_ml_channel = open_out "stubs.ml" in let ml = Format.formatter_of_out_channel stub_ml_channel in let stub_c_channel = open_out "ml_stubs.c" in let c = Format.formatter_of_out_channel stub_c_channel in Format.fprintf ml "%s@\n" (Buffer.contents ml_header); Format.fprintf c "%s@\n" (Buffer.contents c_header); List.iter (Pretty.klass ~ml ~c) klass; Pretty.functions ~ml ~c funcs; Format.fprintf ml "@."; Format.fprintf c "@."; close_out stub_ml_channel; close_out stub_c_channel; *)
print_rules.ml
open Stdune open Import let doc = "Dump internal rules." let man = [ `S "DESCRIPTION" ; `P {|Dump Dune internal rules for the given targets. If no targets are given, dump all the internal rules.|} ; `P {|By default the output is a list of S-expressions, one S-expression per rule. Each S-expression is of the form:|} ; `Pre " ((deps (<dependencies>))\n\ \ (targets (<targets>))\n\ \ (context <context-name>)\n\ \ (action <action>))" ; `P {|$(b,<context-name>) is the context is which the action is executed. It is omitted if the action is independent from the context.|} ; `P {|$(b,<action>) is the action following the same syntax as user actions, as described in the manual.|} ; `Blocks Common.help_secs ] let info = Cmd.info "rules" ~doc ~man let print_rule_makefile ppf (rule : Dune_engine.Reflection.Rule.t) = let action = Action.For_shell.Progn [ Mkdir (Path.to_string (Path.build rule.dir)) ; Action.for_shell rule.action ] in (* Makefiles seem to allow directory targets, so we include them. *) let targets = Path.Build.Set.union rule.targets.files rule.targets.dirs in Format.fprintf ppf "@[<hov 2>@{<makefile-stuff>%a:%t@}@]@,@<0>\t@{<makefile-action>%a@}\n" (Format.pp_print_list ~pp_sep:Format.pp_print_space (fun ppf p -> Format.pp_print_string ppf (Path.to_string p))) (List.map ~f:Path.build (Path.Build.Set.to_list targets)) (fun ppf -> Path.Set.iter rule.expanded_deps ~f:(fun dep -> Format.fprintf ppf "@ %s" (Path.to_string dep))) Pp.to_fmt (Action_to_sh.pp action) let print_rule_sexp ppf (rule : Dune_engine.Reflection.Rule.t) = let sexp_of_action action = Action.for_shell action |> Action.For_shell.encode in let paths ps = Dune_lang.Encoder.list Dpath.Build.encode (Path.Build.Set.to_list ps) in let sexp = Dune_lang.Encoder.record (List.concat [ [ ("deps", Dep.Set.encode rule.deps) ; ( "targets" , Dune_lang.Encoder.record [ ("files", paths rule.targets.files) ; ("directories", paths rule.targets.dirs) ] ) ] ; (match rule.context with | None -> [] | Some c -> [ ("context", Dune_engine.Context_name.encode c.name) ]) ; [ ("action", sexp_of_action rule.action) ] ]) in Format.fprintf ppf "%a@," Dune_lang.Deprecated.pp_split_strings sexp module Syntax = struct type t = | Makefile | Sexp let term = let doc = "Output the rules in Makefile syntax." in let+ makefile = Arg.(value & flag & info [ "m"; "makefile" ] ~doc) in if makefile then Makefile else Sexp let print_rule = function | Makefile -> print_rule_makefile | Sexp -> print_rule_sexp let print_rules syntax ppf rules = Dune_lang.Deprecated.prepare_formatter ppf; Format.pp_open_vbox ppf 0; Format.pp_print_list (print_rule syntax) ppf rules; Format.pp_print_flush ppf () end let term = let+ common = Common.term and+ out = Arg.( value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc:"Output to a file instead of stdout.") and+ recursive = Arg.( value & flag & info [ "r"; "recursive" ] ~doc: "Print all rules needed to build the transitive dependencies of \ the given targets.") and+ syntax = Syntax.term and+ targets = Arg.(value & pos_all dep [] & Arg.info [] ~docv:"TARGET") in let config = Common.init common in let out = Option.map ~f:Path.of_string out in Scheduler.go ~common ~config (fun () -> let open Fiber.O in let* setup = Import.Main.setup () in Build_system.run_exn (fun () -> let open Memo.O in let* setup = setup in let* request = match targets with | [] -> Load_rules.all_direct_targets () >>| Path.Build.Map.foldi ~init:[] ~f:(fun p _ acc -> Path.build p :: acc) >>| Action_builder.paths | _ -> Memo.return (Target.interpret_targets (Common.root common) config setup targets) in let+ rules = Dune_engine.Reflection.eval ~request ~recursive in let print oc = let ppf = Format.formatter_of_out_channel oc in Syntax.print_rules syntax ppf rules in match out with | None -> print stdout | Some fn -> Io.with_file_out fn ~f:print)) let command = Cmd.v info term
dune
; File auto-generated by gentests.ml ; Auto-generated part begin ; Test for test-as-001.psmt2 ; Incremental test (rule (target test-as-001.incremental) (deps (:input test-as-001.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=incremental --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-as-001.expected test-as-001.incremental))) ; Full mode test (rule (target test-as-001.full) (deps (:input test-as-001.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=full --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-as-001.expected test-as-001.full))) ; Test for test-par-datatype.psmt2 ; Incremental test (rule (target test-par-datatype.incremental) (deps (:input test-par-datatype.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=incremental --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-par-datatype.expected test-par-datatype.incremental))) ; Full mode test (rule (target test-par-datatype.full) (deps (:input test-par-datatype.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=full --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-par-datatype.expected test-par-datatype.full))) ; Test for test-par.psmt2 ; Incremental test (rule (target test-par.incremental) (deps (:input test-par.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=incremental --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-par.expected test-par.incremental))) ; Full mode test (rule (target test-par.full) (deps (:input test-par.psmt2)) (package dolmen_bin) (action (chdir %{workspace_root} (with-outputs-to %{target} (with-accepted-exit-codes (or 0 (not 0)) (run dolmen --mode=full --color=never %{input} %{read-lines:flags.dune})))))) (rule (alias runtest) (package dolmen_bin) (action (diff test-par.expected test-par.full))) ; Auto-generated part end
session.ml
open Preferences (** A session is a script buffer + proof + messages, interacting with a coqtop, and a few other elements around *) class type ['a] page = object inherit GObj.widget method update : 'a -> unit method on_update : callback:('a -> unit) -> unit method data : 'a end class type control = object method detach : unit -> unit end type errpage = (int * string) list page type jobpage = string CString.Map.t page type breakpoint = { mark_id : string; mutable prev_byte_offset : int; (* UTF-8 byte offset for Coq *) (* prev_uni_offset may differ from mark#offset as the script is edited *) mutable prev_uni_offset : int; (* unicode offset for GTK *) } type session = { buffer : GText.buffer; script : Wg_ScriptView.script_view; proof : Wg_ProofView.proof_view; (* the proof context panel *) messages : Wg_RoutedMessageViews.message_views_router; segment : Wg_Segment.segment; (* color coded status bar near bottom of the screen *) fileops : FileOps.ops; coqops : CoqOps.ops; coqtop : Coq.coqtop; command : Wg_Command.command_window; (* aka the Query Pane *) finder : Wg_Find.finder; (* Find / Replace panel *) debugger : Wg_Debugger.debugger_view; tab_label : GMisc.label; errpage : errpage; jobpage : jobpage; sid : int; basename : string; mutable control : control; mutable abs_file_name : string option; mutable debug_stop_pt : (session * int * int) option; mutable breakpoints : breakpoint list; mutable last_db_goals : Pp.t } let next_sid = ref 0 let create_buffer () = let buffer = GSourceView3.source_buffer ~tag_table:Tags.Script.table ~highlight_matching_brackets:true ?language:(lang_manager#language source_language#get) ?style_scheme:(style_manager#style_scheme source_style#get) () in let _ = buffer#create_mark ~name:"start_of_input" buffer#start_iter in let _ = buffer#create_mark ~left_gravity:false ~name:"stop_of_input" buffer#end_iter in let _ = buffer#create_mark ~name:"prev_insert" buffer#start_iter in let _ = buffer#place_cursor ~where:buffer#start_iter in let _ = buffer#add_selection_clipboard Ideutils.cb in buffer let create_script coqtop source_buffer = let script = Wg_ScriptView.script_view coqtop ~source_buffer ~show_line_numbers:true ~wrap_mode:`NONE () (* todo: line numbers don't appear *) in let _ = script#misc#set_name "ScriptWindow" in script (** NB: Events during text edition: - [begin_user_action] - [insert_text] (or [delete_range] when deleting) - [changed] - [end_user_action] When pasting a text containing tags (e.g. the sentence terminators), there is actually many [insert_text] and [changed]. For instance, for "a. b.": - [begin_user_action] - [insert_text] (for "a") - [changed] - [insert_text] (for ".") - [changed] - [apply_tag] (for the tag of ".") - [insert_text] (for " b") - [changed] - [insert_text] (for ".") - [changed] - [apply_tag] (for the tag of ".") - [end_user_action] Since these copy-pasted tags may interact badly with the retag mechanism, we now don't monitor the "changed" event, but rather the "begin_user_action" and "end_user_action". We begin by setting a mark at the initial cursor point. At the end, the zone between the mark and the cursor is to be untagged and then retagged. *) let misc () = CDebug.(get_flag misc) type action_stack_entry = Mark of Gtk.text_mark | Begin type action_stack = action_stack_entry list option let call_coq_or_cancel_action coqtop coqops (buffer : GText.buffer) it = let () = try buffer#delete_mark (`NAME "target") with GText.No_such_mark _ -> () in let mark = buffer#create_mark ~name:"target" it in let action = coqops#go_to_mark (`MARK mark) in ignore @@ Coq.try_grab coqtop action (fun () -> ()) let init_user_action (stack : action_stack ref) = match !stack with | None -> stack := Some [] | Some _ -> assert false let close_user_action (stack : action_stack ref) = match !stack with | None -> assert false | Some marks -> let () = stack := None in marks let handle_iter coqtop coqops (buffer : GText.buffer) it (stack : action_stack ref) = match it with | None -> () | Some it -> match !stack with | Some marks -> (* We are inside an user action, deferring to its end *) let ent = if it#offset > 0 then Mark (buffer#create_mark it) else Begin in stack := Some (ent :: marks) | None -> (* Otherwise we move to the mark now *) call_coq_or_cancel_action coqtop coqops buffer it let set_buffer_handlers (buffer : GText.buffer) script (coqops : CoqOps.ops) coqtop = let action_stack : action_stack ref = ref None in let get_start () = buffer#get_iter_at_mark (`NAME "start_of_input") in let get_stop () = buffer#get_iter_at_mark (`NAME "stop_of_input") in let ensure_marks_exist () = try ignore(buffer#get_mark (`NAME "stop_of_input")) with GText.No_such_mark _ -> assert false in let get_insert () = buffer#get_iter_at_mark `INSERT in let update_prev it = let prev = buffer#get_iter_at_mark (`NAME "prev_insert") in if it#offset < prev#offset then buffer#move_mark (`NAME "prev_insert") ~where:it in let debug_edit_zone () = if false (*!Minilib.debug*) then begin buffer#remove_tag Tags.Script.edit_zone ~start:buffer#start_iter ~stop:buffer#end_iter; buffer#apply_tag Tags.Script.edit_zone ~start:(get_start()) ~stop:(get_stop()) end in let processed_sentence_just_before_error it = let rec aux old it = if it#is_start then None else if it#has_tag Tags.Script.processed then Some old else if it#has_tag Tags.Script.error_bg then aux it it#backward_char else None in aux it it#copy in let insert_cb it s = if String.length s = 0 then () else begin if misc () then Minilib.log ("insert_cb " ^ string_of_int it#offset); let () = update_prev it in let iter = if it#has_tag Tags.Script.processed then Some it else if it#has_tag Tags.Script.error_bg then processed_sentence_just_before_error it else None in handle_iter coqtop coqops buffer iter action_stack end in let delete_cb ~start ~stop = if misc () then Minilib.log (Printf.sprintf "delete_cb %d %d" start#offset stop#offset); let min_iter, max_iter = if start#compare stop < 0 then start, stop else stop, start in let () = update_prev min_iter in let rec aux iter = if iter#equal max_iter then None else if iter#has_tag Tags.Script.processed then Some min_iter#backward_char else if iter#has_tag Tags.Script.error_bg then processed_sentence_just_before_error iter else aux iter#forward_char in let iter = aux min_iter in handle_iter coqtop coqops buffer iter action_stack in let begin_action_cb () = let () = if misc () then Minilib.log "begin_action_cb" in let () = init_user_action action_stack in let where = get_insert () in buffer#move_mark (`NAME "prev_insert") ~where in let end_action_cb () = let () = if misc () then Minilib.log "end_action_cb" in let marks = close_user_action action_stack in let () = ensure_marks_exist () in if CList.is_empty marks then let start, stop = get_start (), get_stop () in let () = List.iter (fun tag -> buffer#remove_tag tag ~start ~stop) Tags.Script.ephemere in Sentence.tag_on_insert buffer else (* If coq was asked to backtrack, the cleanup must be done by the backtrack_until function, since it may move the stop_of_input to a point indicated by coq. *) let iters = List.map (fun mark -> match mark with | Mark mark -> buffer#get_iter_at_mark (`MARK mark) | Begin -> buffer#start_iter ) marks in let iter = List.hd @@ List.sort (fun it1 it2 -> it1#compare it2) iters in let () = List.iter (fun mark -> try match mark with | Mark mark -> buffer#delete_mark (`MARK mark) | Begin -> let action = Coq.seq (coqops#backtrack_to_begin ()) (Coq.lift (fun () -> Sentence.tag_on_insert buffer)) in ignore @@ Coq.try_grab coqtop action (fun () -> ()) with GText.No_such_mark _ -> ()) marks in call_coq_or_cancel_action coqtop coqops buffer iter in let mark_deleted_cb m = match GtkText.Mark.get_name m with | Some "insert" -> () | Some s -> if misc () then Minilib.log (s^" deleted") | None -> () in let mark_set_cb it m = debug_edit_zone (); let ins = get_insert () in let () = Ideutils.display_location ins in match GtkText.Mark.get_name m with | Some "insert" -> () | Some s -> if misc () then Minilib.log (s^" moved") | None -> () in let set_busy b = let prop = `EDITABLE b in let tags = [Tags.Script.processed] in List.iter (fun tag -> tag#set_property prop) tags in (* Pluging callbacks *) let () = Coq.setup_script_editable coqtop set_busy in let _ = buffer#connect#insert_text ~callback:insert_cb in let _ = buffer#connect#delete_range ~callback:delete_cb in let _ = buffer#connect#begin_user_action ~callback:begin_action_cb in let _ = buffer#connect#end_user_action ~callback:end_action_cb in let _ = buffer#connect#after#mark_set ~callback:mark_set_cb in let _ = buffer#connect#after#mark_deleted ~callback:mark_deleted_cb in () let find_int_col s l = match List.assoc s l with `IntC c -> c | _ -> assert false let find_string_col s l = match List.assoc s l with `StringC c -> c | _ -> assert false let make_table_widget ?sort cd cb = let frame = GBin.scrolled_window ~hpolicy:`NEVER ~vpolicy:`AUTOMATIC () in let columns, store = let cols = new GTree.column_list in let columns = List.map (function | (`Int,n,_) -> n, `IntC (cols#add Gobject.Data.int) | (`String,n,_) -> n, `StringC (cols#add Gobject.Data.string)) cd in columns, GTree.list_store cols in let data = GTree.view ~vadjustment:frame#vadjustment ~hadjustment:frame#hadjustment ~rules_hint:true ~headers_visible:false ~model:store ~packing:frame#add () in let () = data#set_headers_visible true in let () = data#set_headers_clickable true in (* FIXME: handle this using CSS *) (* let refresh clr = data#misc#modify_bg [`NORMAL, `NAME clr] in *) (* let _ = background_color#connect#changed ~callback:refresh in *) (* let _ = data#misc#connect#realize ~callback:(fun () -> refresh background_color#get) in *) let mk_rend c = GTree.cell_renderer_text [], ["text",c] in let cols = List.map2 (fun (_,c) (_,n,v) -> let c = match c with | `IntC c -> GTree.view_column ~renderer:(mk_rend c) () | `StringC c -> GTree.view_column ~renderer:(mk_rend c) () in c#set_title n; c#set_visible v; c#set_sizing `AUTOSIZE; c) columns cd in let make_sorting i (_, c) = let sort (store : GTree.model) it1 it2 = match c with | `IntC c -> compare (store#get ~row:it1 ~column:c) (store#get ~row:it2 ~column:c) | `StringC c -> compare (store#get ~row:it1 ~column:c) (store#get ~row:it2 ~column:c) in store#set_sort_func i sort in CList.iteri make_sorting columns; CList.iteri (fun i c -> c#set_sort_column_id i) cols; List.iter (fun c -> ignore(data#append_column c)) cols; ignore( data#connect#row_activated ~callback:(fun tp vc -> cb columns store tp vc) ); let () = match sort with None -> () | Some (i, t) -> store#set_sort_column_id i t in frame, (fun f -> f columns store) let create_errpage (script : Wg_ScriptView.script_view) : errpage = let table, access = make_table_widget ~sort:(0, `ASCENDING) [`Int,"Line",true; `String,"Error message",true] (fun columns store tp vc -> let row = store#get_iter tp in let lno = store#get ~row ~column:(find_int_col "Line" columns) in let where = script#buffer#get_iter (`LINE (lno-1)) in script#buffer#place_cursor ~where; script#misc#grab_focus (); ignore (script#scroll_to_iter ~use_align:false ~yalign:0.75 ~within_margin:0.25 where)) in let tip = GMisc.label ~text:"Double click to jump to error line" () in let box = GPack.vbox ~homogeneous:false () in let () = box#pack ~expand:true table#coerce in let () = box#pack ~expand:false ~padding:2 tip#coerce in let last_update = ref [] in let callback = ref (fun _ -> ()) in object (self) inherit GObj.widget box#as_widget method update errs = if !last_update = errs then () else begin last_update := errs; access (fun _ store -> store#clear ()); !callback errs; List.iter (fun (lno, msg) -> access (fun columns store -> let line = store#append () in store#set ~row:line ~column:(find_int_col "Line" columns) lno; store#set ~row:line ~column:(find_string_col "Error message" columns) msg)) errs end method on_update ~callback:cb = callback := cb method data = !last_update end let create_jobpage coqtop coqops : jobpage = let table, access = make_table_widget ~sort:(0, `ASCENDING) [`String,"Worker",true; `String,"Job name",true] (fun columns store tp vc -> let row = store#get_iter tp in let w = store#get ~row ~column:(find_string_col "Worker" columns) in let info () = Minilib.log ("Coq busy, discarding query") in ignore @@ Coq.try_grab coqtop (coqops#stop_worker w) info ) in let tip = GMisc.label ~text:"Double click to interrupt worker" () in let box = GPack.vbox ~homogeneous:false () in let () = box#pack ~expand:true table#coerce in let () = box#pack ~expand:false ~padding:2 tip#coerce in let last_update = ref CString.Map.empty in let callback = ref (fun _ -> ()) in object (self) inherit GObj.widget box#as_widget method update jobs = if !last_update = jobs then () else begin last_update := jobs; access (fun _ store -> store#clear ()); !callback jobs; CString.Map.iter (fun id job -> access (fun columns store -> let column = find_string_col "Worker" columns in if job = "Dead" then store#foreach (fun _ row -> if store#get ~row ~column = id then store#remove row || true else false) else let line = store#append () in store#set ~row:line ~column id; store#set ~row:line ~column:(find_string_col "Job name" columns) job)) jobs end method on_update ~callback:cb = callback := cb method data = !last_update end let create_proof () = let proof = Wg_ProofView.proof_view () in let _ = proof#misc#set_can_focus true in let _ = GtkBase.Widget.add_events proof#as_widget [`ENTER_NOTIFY;`POINTER_MOTION] in proof let dummy_control : control = object method detach () = () end let to_abs_file_name f = if Filename.is_relative f then Filename.concat (Unix.getcwd ()) f else f let create file coqtop_args = let (basename, abs_file_name) = match file with | None -> ("*scratch*", None) | Some f -> (Glib.Convert.filename_to_utf8 Filename.(remove_extension (basename f)), Some (to_abs_file_name f)) in let coqtop = Coq.spawn_coqtop basename coqtop_args in let reset () = Coq.reset_coqtop coqtop in let buffer = create_buffer () in let script = create_script coqtop buffer in let proof = create_proof () in incr next_sid; let sid = !next_sid in let create_messages () = let messages = Wg_MessageView.message_view sid in let _ = messages#misc#set_can_focus true in Wg_RoutedMessageViews.message_views ~route_0:messages in let messages = create_messages () in let segment = new Wg_Segment.segment () in let finder = new Wg_Find.finder basename (script :> GText.view) in let debugger = Wg_Debugger.debugger (Printf.sprintf "Debugger (%s)" basename) sid in let fops = new FileOps.fileops (buffer :> GText.buffer) file reset in let _ = fops#update_stats in let cops = new CoqOps.coqops script proof messages segment coqtop (fun () -> fops#filename) in let command = new Wg_Command.command_window basename coqtop cops messages sid in let errpage = create_errpage script in let jobpage = create_jobpage coqtop cops in let _ = set_buffer_handlers (buffer :> GText.buffer) script cops coqtop in let _ = Coq.set_reset_handler coqtop cops#handle_reset_initial in let _ = Coq.init_coqtop coqtop cops#initialize in let tab_label = GMisc.label ~text:basename () in (* todo: ugly custom tooltips...*) (* tab_label#misc#set_size_request ~height:100 ~width:200 (); tab_label#misc#modify_bg [`NORMAL, `NAME "#FF0000"]; (match abs_file_name with | Some f -> GtkBase.Widget.Tooltip.set_markup tab_label#as_widget ("<span background=\"yellow\" foreground=\"black\">" ^ f ^ "</span>"); let label2 = GMisc.label ~text:"hello?" () in GtkBase.Tooltip.set_custom (label2#coerce : Gtk.tooltip) label | None -> ()); *) { buffer = (buffer :> GText.buffer); script=script; proof=proof; messages=messages; segment=segment; fileops=fops; coqops=cops; coqtop=coqtop; command=command; finder=finder; debugger=debugger; tab_label= tab_label; errpage=errpage; jobpage=jobpage; sid=sid; basename = basename; control = dummy_control; abs_file_name = abs_file_name; debug_stop_pt = None; breakpoints = []; last_db_goals = Pp.mt () } let kill (sn:session) = (* To close the detached views of this script, we call manually [destroy] on it, triggering some callbacks in [detach_view]. In a more modern lablgtk, rather use the page-removed signal ? *) sn.coqops#destroy (); sn.script#destroy (); Coq.close_coqtop sn.coqtop let window_size = ref (window_width#get, window_height#get) let build_layout (sn:session) = let debugger_paned = GPack.paned `VERTICAL () in let debugger_box = GPack.vbox ~packing:(debugger_paned#pack2 ~shrink:false ~resize:true) () in let session_paned = GPack.paned `VERTICAL ~packing:(debugger_paned#pack1 ~shrink:false ~resize:true) () in let session_box = GPack.vbox ~packing:(session_paned#pack1 ~shrink:false ~resize:true) () in (* Left part of the window. *) let eval_paned = GPack.paned `HORIZONTAL ~border_width:5 ~packing:(session_box#pack ~expand:true) () in let script_frame = GBin.frame ~shadow_type:`IN ~packing:(eval_paned#pack1 ~shrink:false) () in let script_scroll = GBin.scrolled_window ~vpolicy:`AUTOMATIC ~hpolicy:`AUTOMATIC ~packing:script_frame#add () in (* Right part of the window *) let state_paned = GPack.paned `VERTICAL ~packing:(eval_paned#pack2 ~shrink:true) () in (* Proof buffer. *) let title = Printf.sprintf "Proof (%s)" sn.tab_label#text in let proof_detachable = Wg_Detachable.detachable ~title () in let () = proof_detachable#button#misc#hide () in let () = proof_detachable#frame#set_shadow_type `IN in let () = state_paned#pack1 ~shrink:true proof_detachable#coerce in let proof_scroll = GBin.scrolled_window ~vpolicy:`AUTOMATIC ~hpolicy:`AUTOMATIC ~packing:proof_detachable#pack () in let callback _ = proof_detachable#show; proof_scroll#coerce#misc#set_size_request ~width:0 ~height:0 () in let () = proof_detachable#connect#attached ~callback in let callback _ = proof_scroll#coerce#misc#set_size_request ~width:500 ~height:400 () in let () = proof_detachable#connect#detached ~callback in (* Message buffer. *) let message_frame = GPack.notebook ~packing:(state_paned#pack2 ~shrink:true) () in let add_msg_page pos name text (w : GObj.widget) = let detachable = Wg_Detachable.detachable ~title:(text^" ("^name^")") () in detachable#add w#coerce; let label = GPack.hbox ~spacing:5 () in let lbl = GMisc.label ~text ~packing:label#add () in let but = GButton.button () in but#add (GMisc.label ~markup:"<small>↗</small>" ())#coerce; label#add but#coerce; ignore(message_frame#insert_page ~pos ~tab_label:label#coerce detachable#coerce); ignore(but#connect#clicked ~callback:(fun _ -> message_frame#remove_page (message_frame#page_num detachable#coerce); detachable#button#clicked ())); detachable#connect#detached ~callback:(fun _ -> if message_frame#all_children = [] then message_frame#misc#hide (); w#misc#set_size_request ~width:500 ~height:400 ()); detachable#connect#attached ~callback:(fun _ -> w#misc#set_size_request ~width:1 ~height:1 (); (* force resize *) ignore(message_frame#insert_page ~pos ~tab_label:label#coerce detachable#coerce); message_frame#misc#show (); detachable#show); detachable#button#misc#hide (); detachable, lbl in let session_tab = GPack.hbox ~homogeneous:false () in let img = GMisc.image ~icon_size:`SMALL_TOOLBAR ~packing:session_tab#pack () in let _ = sn.buffer#connect#modified_changed ~callback:(fun () -> if sn.buffer#modified then img#set_stock `SAVE else img#set_stock `YES) in (* There was an issue in the previous implementation for setting the position of the handle. It was using the size_allocate event but there is an issue with size_allocate. G. Melquiond analyzed that at starting time, the size_allocate event is only issued in Layout phase of the gtk loop so that it is actually processed only in the next iteration of the event-update-layout-paint loop, after the user does something and trigger an effective new event (see #10578). So we preventively enforce an estimated position for the handles to be used in the very first initializing iteration of the loop *) let () = (* 14 is the estimated size for vertical borders *) let estimated_vertical_handle_position = (fst !window_size - 14) / 2 in (* 169 is the estimated size for menus, command line, horizontal border *) let estimated_horizontal_handle_position = (snd !window_size - 169) / 2 in if estimated_vertical_handle_position > 0 then eval_paned#set_position estimated_vertical_handle_position; if estimated_horizontal_handle_position > 0 then state_paned#set_position estimated_horizontal_handle_position in session_box#pack sn.finder#coerce; debugger_box#add sn.debugger#coerce; sn.debugger#hide (); (sn.messages#route 0)#set_forward_show_debugger sn.debugger#show; sn.debugger#set_forward_paned_pos (fun pos -> debugger_paned#set_position pos); (* segment should not be in the debugger box *) debugger_box#pack ~expand:false ~fill:false sn.segment#coerce; debugger_paned#set_position 1000000; sn.command#pack_in (session_paned#pack2 ~shrink:false ~resize:false); script_scroll#add sn.script#coerce; proof_scroll#add sn.proof#coerce; let detach, _ = add_msg_page 0 sn.tab_label#text "Messages" sn.messages#default_route#coerce in let _, label = add_msg_page 1 sn.tab_label#text "Errors" sn.errpage#coerce in let _, _ = add_msg_page 2 sn.tab_label#text "Jobs" sn.jobpage#coerce in (* When a message is received, focus on the message pane *) let _ = sn.messages#default_route#connect#pushed ~callback:(fun _ _ -> let num = message_frame#page_num detach#coerce in if 0 <= num then message_frame#goto_page num ) in (* When an error occurs, paint the error label in red *) let txt = label#text in let red s = "<span foreground=\"#FF0000\">" ^ s ^ "</span>" in sn.errpage#on_update ~callback:(fun l -> if l = [] then (label#set_use_markup false; label#set_text txt) else (label#set_text (red txt);label#set_use_markup true)); session_tab#pack sn.tab_label#coerce; img#set_stock `YES; let control = object method detach () = proof_detachable#detach () end in let () = sn.control <- control in (Some session_tab#coerce,None,debugger_paned#coerce)
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
main.ml
open Lwt.Infix let () = Logs.set_level (Some Logs.Warning); Logs.set_reporter (Logs_fmt.reporter ()) let () = Lwt_main.run begin let service = Echo.local in Echo.ping service "foo" >>= fun reply -> Fmt.pr "Got reply %S@." reply; Lwt.return_unit end
pa_ast.ml
open Asttypes open Parsetree open Longident let loc_str _loc desc = { pstr_desc = desc; pstr_loc = _loc; } let loc_sig _loc desc = { psig_desc = desc; psig_loc = _loc; } let loc_expr ?(attributes=[]) _loc e = { pexp_desc = e; pexp_loc = _loc; pexp_attributes = attributes; pexp_loc_stack = [] } let loc_pat ?(attributes=[]) _loc pat = { ppat_desc = pat; ppat_loc = _loc; ppat_attributes = attributes; ppat_loc_stack = [] } let loc_pcl ?(attributes=[]) _loc desc = { pcl_desc = desc; pcl_loc = _loc; pcl_attributes = attributes; } let loc_typ ?(attributes=[]) _loc typ = { ptyp_desc = typ; ptyp_loc = _loc; ptyp_attributes = attributes; ptyp_loc_stack = [] } let pctf_loc ?(attributes=[]) _loc desc = { pctf_desc = desc; pctf_loc = _loc; pctf_attributes = attributes } let pcty_loc ?(attributes=[]) _loc desc = { pcty_desc = desc; pcty_loc = _loc; pcty_attributes = attributes } let loc_pcf ?(attributes=[]) _loc desc = { pcf_desc = desc; pcf_loc = _loc; pcf_attributes = attributes } let mexpr_loc ?(attributes=[]) _loc desc = { pmod_desc = desc; pmod_loc = _loc; pmod_attributes = attributes } let mtyp_loc ?(attributes=[]) _loc desc = { pmty_desc = desc; pmty_loc = _loc; pmty_attributes = attributes } let pexp_construct(a,b) = Pexp_construct(a,b) let pexp_fun(label, opt, pat, expr) = Pexp_fun(label,opt,pat,expr) let ghost loc = Location.({loc with loc_ghost = true}) let no_ghost loc = Location.({loc with loc_ghost = false}) let de_ghost e = loc_expr (no_ghost e.pexp_loc) e.pexp_desc let id_loc txt loc = { txt; loc } let loc_id loc txt = { txt; loc } let rec merge = function | [] -> assert false | [loc] -> loc | l1::_ as ls -> let ls = List.rev ls in let rec fn = function | [] -> assert false | [loc] -> loc | l2::ls when Location.(l2.loc_start = l2.loc_end) -> fn ls | l2::ls -> Location.( {loc_start = l1.loc_start; loc_end = l2.loc_end; loc_ghost = l1.loc_ghost && l2.loc_ghost}) in fn ls let merge2 l1 l2 = Location.( {loc_start = l1.loc_start; loc_end = l2.loc_end; loc_ghost = l1.loc_ghost && l2.loc_ghost}) let const_string s = Pconst_string(s, None) let const_float s = Pconst_float(s,None) let const_char s = Pconst_char(s) let const_int s = Pconst_integer(string_of_int s,None) let const_int32 s = Pconst_integer(Int32.to_string s, Some 'l') let const_int64 s = Pconst_integer(Int64.to_string s, Some 'L') let const_nativeint s = Pconst_integer(Nativeint.to_string s, Some 'n') let exp_string _loc s = loc_expr _loc (Pexp_constant (const_string s)) let exp_int _loc i = loc_expr _loc (Pexp_constant (Pconst_integer (string_of_int i,None))) let exp_char _loc c = loc_expr _loc (Pexp_constant (Pconst_char c)) let exp_float _loc f = loc_expr _loc (Pexp_constant (Pconst_float (f,None))) let exp_int32 _loc i = loc_expr _loc (Pexp_constant (Pconst_integer (Int32.to_string i,Some 'l'))) let exp_int64 _loc i = loc_expr _loc (Pexp_constant (Pconst_integer (Int64.to_string i,Some 'L'))) let exp_nativeint _loc i = loc_expr _loc (Pexp_constant (Pconst_integer(Nativeint.to_string i,Some 'n'))) let exp_const _loc c es = let c = id_loc c _loc in loc_expr _loc (pexp_construct(c, es)) let exp_record _loc fs = let f (l, e) = (id_loc l _loc, e) in let fs = List.map f fs in loc_expr _loc (Pexp_record (fs, None)) let exp_None _loc = let cnone = id_loc (Lident "None") _loc in loc_expr _loc (pexp_construct(cnone, None)) let exp_Some _loc a = let csome = id_loc (Lident "Some") _loc in loc_expr _loc (pexp_construct(csome, Some a)) let exp_option _loc = function | None -> exp_None _loc | Some e -> exp_Some _loc e let exp_unit _loc = let cunit = id_loc (Lident "()") _loc in loc_expr _loc (pexp_construct(cunit, None)) let exp_tuple _loc l = match l with | [] -> exp_unit _loc | [e] -> e | _ -> loc_expr _loc (Pexp_tuple l) let exp_array _loc l = loc_expr _loc (Pexp_array l) let exp_Nil _loc = let cnil = id_loc (Lident "[]") _loc in loc_expr _loc (pexp_construct(cnil, None)) let exp_true _loc = let ctrue = id_loc (Lident "true") _loc in loc_expr _loc (pexp_construct(ctrue, None)) let exp_false _loc = let cfalse = id_loc (Lident "false") _loc in loc_expr _loc (pexp_construct(cfalse, None)) let exp_bool _loc b = if b then exp_true _loc else exp_false _loc let exp_Cons _loc a l = loc_expr _loc (pexp_construct(id_loc (Lident "::") _loc, Some (exp_tuple _loc [a;l]))) let exp_list _loc l = List.fold_right (exp_Cons _loc) l (exp_Nil _loc) let exp_ident _loc id = loc_expr _loc (Pexp_ident (id_loc (Lident id) _loc )) let exp_lident _loc id = loc_expr _loc (Pexp_ident (id_loc id _loc )) let pat_ident _loc id = loc_pat _loc (Ppat_var (id_loc id _loc)) let pat_array _loc l = loc_pat _loc (Ppat_array l) let typ_unit _loc = loc_typ _loc (Ptyp_constr (id_loc (Lident "unit") _loc, [])) let typ_tuple _loc l = match l with | [] -> typ_unit _loc | [t] -> t | _ -> loc_typ _loc (Ptyp_tuple l) let nolabel = Nolabel let labelled s = Labelled s let optional s = Optional s let exp_apply _loc f l = loc_expr _loc (Pexp_apply(f, List.map (fun x -> nolabel, x) l)) let exp_apply1 _loc f x = loc_expr _loc (Pexp_apply(f, [nolabel, x])) let exp_apply2 _loc f x y = loc_expr _loc (Pexp_apply(f, [nolabel, x; nolabel, y])) let exp_Some_fun _loc = loc_expr _loc (pexp_fun(nolabel, None, pat_ident _loc "x", (exp_Some _loc (exp_ident _loc "x")))) let exp_fun _loc id e = loc_expr _loc (pexp_fun(nolabel, None, pat_ident _loc id, e)) let exp_lab_apply _loc f l = loc_expr _loc (Pexp_apply(f, l)) let exp_app _loc = exp_fun _loc "x" (exp_fun _loc "y" (exp_apply _loc (exp_ident _loc "y") [exp_ident _loc "x"])) let exp_glr_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Ldot(Lident "Earley_core", "Earley"),f)) _loc) )) let exp_glrstr_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Lident "Earley_str",f)) _loc) )) let exp_list_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Lident "List",f)) _loc) )) let exp_str_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Lident "Str",f)) _loc) )) let exp_prelude_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Lident "Pa_ocaml_prelude",f)) _loc) )) let exp_location_fun _loc f = loc_expr _loc (Pexp_ident((id_loc (Ldot(Lident "Location",f)) _loc) )) let exp_Cons_fun _loc = exp_fun _loc "x" (exp_fun _loc "l" (exp_Cons _loc (exp_ident _loc "x") (exp_ident _loc "l"))) let exp_Cons_rev_fun _loc = exp_fun _loc "x" (exp_fun _loc "l" (exp_Cons _loc (exp_ident _loc "x") (exp_apply _loc (exp_list_fun _loc "rev") [exp_ident _loc "l"]))) let exp_apply_fun _loc = exp_fun _loc "a" (exp_fun _loc "f" (exp_apply _loc (exp_ident _loc "f") [exp_ident _loc "a"])) let ppat_alias _loc p id = if id = "_" then p else loc_pat _loc (Ppat_alias (p, (id_loc (id) _loc))) let constructor_declaration ?(attributes=[]) _loc name args res = { pcd_name = name; pcd_args = args; pcd_res = res; pcd_attributes = attributes; pcd_loc = _loc } let label_declaration ?(attributes=[]) _loc name mut ty = { pld_name = name; pld_mutable = mut; pld_type = ty; pld_attributes = attributes; pld_loc = _loc } type tpar = Joker of Location.t | Name of string loc let params_map params = let fn (name, var) = match name with | Joker _loc -> (loc_typ _loc Ptyp_any, var) | Name name -> (loc_typ name.loc (Ptyp_var name.txt), var) in List.map fn params let type_declaration ?(attributes=[]) _loc name params cstrs kind priv manifest = let params = params_map params in { ptype_name = name; ptype_params = params; ptype_cstrs = cstrs; ptype_kind = kind; ptype_private = priv; ptype_manifest = manifest; ptype_attributes = attributes; ptype_loc = _loc; } let class_type_declaration ?(attributes=[]) _loc name params virt expr = let params = params_map params in { pci_params = params ; pci_virt = virt ; pci_name = name ; pci_expr = expr ; pci_attributes = attributes ; pci_loc = _loc } let pstr_eval e = Pstr_eval(e, []) let psig_value ?(attributes=[]) _loc name ty prim = Psig_value { pval_name = name; pval_type = ty ; pval_prim = prim ; pval_attributes = attributes; pval_loc = _loc } let value_binding ?(attributes=[]) _loc pat expr = { pvb_pat = pat; pvb_expr = expr; pvb_attributes = attributes; pvb_loc = _loc } let module_binding _loc name mt me = let me = match mt with None -> me | Some mt -> mexpr_loc _loc (Pmod_constraint(me,mt)) in { pmb_name = name; pmb_expr = me; pmb_attributes = []; pmb_loc = _loc } let module_declaration ?(attributes=[]) _loc name mt = { pmd_name = name; pmd_type = mt; pmd_attributes = attributes; pmd_loc = _loc } let ppat_construct(a,b) = Ppat_construct(a,b) let pexp_constraint(a,b) = Pexp_constraint(a,b) let pexp_coerce(a,b,c) = Pexp_coerce(a,b,c) let pexp_assertfalse _loc = loc_expr _loc (Pexp_assert(loc_expr _loc (pexp_construct({ txt = Lident "false"; loc = _loc}, None)))) let make_case = fun pat expr guard -> { pc_lhs = pat; pc_rhs = expr; pc_guard = guard } let pexp_function cases = Pexp_function (cases) let pat_unit _loc = let unt = id_loc (Lident "()") _loc in loc_pat _loc (ppat_construct (unt, None)) let pat_tuple _loc l = match l with | [] -> pat_unit _loc | [p] -> p | _ -> loc_pat _loc (Ppat_tuple l) let pat_list _loc _loc_c l = let nil = id_loc (Lident "[]") (ghost _loc_c) in let hd = match l with [] -> assert false | x::_ -> x in let cons x xs = let cloc = ghost (merge2 x.ppat_loc _loc) in let c = id_loc (Lident "::") cloc in let cons = ppat_construct (c, Some (loc_pat cloc (Ppat_tuple [x;xs]))) in let loc = if x == hd then _loc else cloc in loc_pat loc cons in List.fold_right cons l (loc_pat (ghost _loc_c) (ppat_construct (nil, None))) let ppat_list = pat_list
(* ====================================================================== Copyright Christophe Raffalli & Rodolphe Lepigre LAMA, UMR 5127 - Université Savoie Mont Blanc christophe.raffalli@univ-savoie.fr rodolphe.lepigre@univ-savoie.fr This software contains implements a parser combinator library together with a syntax extension mechanism for the OCaml language. It can be used to write parsers using a BNF-like format through a syntax extens- ion called pa_parser. This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software. You can use, modify and/or redistribute it under the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA at the following URL: http://www.cecill.info The exercising of this freedom is conditional upon a strong obligation of giving credits for everybody that distributes a software incorpora- ting a software ruled by the current license so as all contributions to be properly identified and acknowledged. As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. ====================================================================== *)
importdl.c
/* Support for dynamic loading of extension modules */ #include "Python.h" #include "pycore_call.h" #include "pycore_pystate.h" #include "pycore_runtime.h" /* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is supported on this platform. configure will then compile and link in one of the dynload_*.c files, as appropriate. We will call a function in those modules to get a function pointer to the module's init function. */ #ifdef HAVE_DYNAMIC_LOADING #include "importdl.h" #ifdef MS_WINDOWS extern dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, const char *shortname, PyObject *pathname, FILE *fp); #else extern dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix, const char *shortname, const char *pathname, FILE *fp); #endif static const char * const ascii_only_prefix = "PyInit"; static const char * const nonascii_prefix = "PyInitU"; /* Get the variable part of a module's export symbol name. * Returns a bytes instance. For non-ASCII-named modules, the name is * encoded as per PEP 489. * The hook_prefix pointer is set to either ascii_only_prefix or * nonascii_prefix, as appropriate. */ static PyObject * get_encoded_name(PyObject *name, const char **hook_prefix) { PyObject *tmp; PyObject *encoded = NULL; PyObject *modname = NULL; Py_ssize_t name_len, lastdot; /* Get the short name (substring after last dot) */ name_len = PyUnicode_GetLength(name); if (name_len < 0) { return NULL; } lastdot = PyUnicode_FindChar(name, '.', 0, name_len, -1); if (lastdot < -1) { return NULL; } else if (lastdot >= 0) { tmp = PyUnicode_Substring(name, lastdot + 1, name_len); if (tmp == NULL) return NULL; name = tmp; /* "name" now holds a new reference to the substring */ } else { Py_INCREF(name); } /* Encode to ASCII or Punycode, as needed */ encoded = PyUnicode_AsEncodedString(name, "ascii", NULL); if (encoded != NULL) { *hook_prefix = ascii_only_prefix; } else { if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) { PyErr_Clear(); encoded = PyUnicode_AsEncodedString(name, "punycode", NULL); if (encoded == NULL) { goto error; } *hook_prefix = nonascii_prefix; } else { goto error; } } /* Replace '-' by '_' */ modname = _PyObject_CallMethod(encoded, &_Py_ID(replace), "cc", '-', '_'); if (modname == NULL) goto error; Py_DECREF(name); Py_DECREF(encoded); return modname; error: Py_DECREF(name); Py_XDECREF(encoded); return NULL; } PyObject * _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp) { #ifndef MS_WINDOWS PyObject *pathbytes = NULL; #endif PyObject *name_unicode = NULL, *name = NULL, *path = NULL, *m = NULL; const char *name_buf, *hook_prefix; const char *oldcontext; dl_funcptr exportfunc; PyModuleDef *def; PyModInitFunction p0; name_unicode = PyObject_GetAttrString(spec, "name"); if (name_unicode == NULL) { return NULL; } if (!PyUnicode_Check(name_unicode)) { PyErr_SetString(PyExc_TypeError, "spec.name must be a string"); goto error; } name = get_encoded_name(name_unicode, &hook_prefix); if (name == NULL) { goto error; } name_buf = PyBytes_AS_STRING(name); path = PyObject_GetAttrString(spec, "origin"); if (path == NULL) goto error; if (PySys_Audit("import", "OOOOO", name_unicode, path, Py_None, Py_None, Py_None) < 0) { goto error; } #ifdef MS_WINDOWS exportfunc = _PyImport_FindSharedFuncptrWindows(hook_prefix, name_buf, path, fp); #else pathbytes = PyUnicode_EncodeFSDefault(path); if (pathbytes == NULL) goto error; exportfunc = _PyImport_FindSharedFuncptr(hook_prefix, name_buf, PyBytes_AS_STRING(pathbytes), fp); Py_DECREF(pathbytes); #endif if (exportfunc == NULL) { if (!PyErr_Occurred()) { PyObject *msg; msg = PyUnicode_FromFormat( "dynamic module does not define " "module export function (%s_%s)", hook_prefix, name_buf); if (msg == NULL) goto error; PyErr_SetImportError(msg, name_unicode, path); Py_DECREF(msg); } goto error; } p0 = (PyModInitFunction)exportfunc; /* Package context is needed for single-phase init */ oldcontext = _Py_PackageContext; _Py_PackageContext = PyUnicode_AsUTF8(name_unicode); if (_Py_PackageContext == NULL) { _Py_PackageContext = oldcontext; goto error; } m = _PyImport_InitFunc_TrampolineCall(p0); _Py_PackageContext = oldcontext; if (m == NULL) { if (!PyErr_Occurred()) { PyErr_Format( PyExc_SystemError, "initialization of %s failed without raising an exception", name_buf); } goto error; } else if (PyErr_Occurred()) { PyErr_Clear(); PyErr_Format( PyExc_SystemError, "initialization of %s raised unreported exception", name_buf); m = NULL; goto error; } if (Py_IS_TYPE(m, NULL)) { /* This can happen when a PyModuleDef is returned without calling * PyModuleDef_Init on it */ PyErr_Format(PyExc_SystemError, "init function of %s returned uninitialized object", name_buf); m = NULL; /* prevent segfault in DECREF */ goto error; } if (PyObject_TypeCheck(m, &PyModuleDef_Type)) { Py_DECREF(name_unicode); Py_DECREF(name); Py_DECREF(path); return PyModule_FromDefAndSpec((PyModuleDef*)m, spec); } /* Fall back to single-phase init mechanism */ if (hook_prefix == nonascii_prefix) { /* don't allow legacy init for non-ASCII module names */ PyErr_Format( PyExc_SystemError, "initialization of %s did not return PyModuleDef", name_buf); goto error; } /* Remember pointer to module init function. */ def = PyModule_GetDef(m); if (def == NULL) { PyErr_Format(PyExc_SystemError, "initialization of %s did not return an extension " "module", name_buf); goto error; } def->m_base.m_init = p0; /* Remember the filename as the __file__ attribute */ if (PyModule_AddObjectRef(m, "__file__", path) < 0) { PyErr_Clear(); /* Not important enough to report */ } PyObject *modules = PyImport_GetModuleDict(); if (_PyImport_FixupExtensionObject(m, name_unicode, path, modules) < 0) goto error; Py_DECREF(name_unicode); Py_DECREF(name); Py_DECREF(path); return m; error: Py_DECREF(name_unicode); Py_XDECREF(name); Py_XDECREF(path); Py_XDECREF(m); return NULL; } #endif /* HAVE_DYNAMIC_LOADING */
t-farey_neighbors.c
#include <stdio.h> #include <stdlib.h> #include "fmpq.h" int main(void) { slong i, q, steps; FLINT_TEST_INIT(state); flint_printf("farey_neighbors...."); fflush(stdout); /* walk from -2 to 2 with a known number of steps */ for (q = 1; q <= 4 * flint_test_multiplier(); q++) { fmpq_t s, t, cur, left, right; fmpz_t Q; fmpq_init(s); fmpq_init(t); fmpq_init(cur); fmpq_init(left); fmpq_init(right); steps = 0; for (i = 1; i <= q; i++) steps += 4*n_euler_phi(i); fmpz_init_set_ui(Q, q); fmpq_set_si(cur, -2, 1); for (i = 0; i < steps; i++) { fmpq_farey_neighbors(left, right, cur, Q); fmpq_sub(t, cur, left); fmpz_one(fmpq_numref(s)); fmpz_mul(fmpq_denref(s), fmpq_denref(left), fmpq_denref(cur)); if (!fmpq_equal(s, t)) { flint_printf("FAIL:\n"); flint_printf("check left neighbor i = %wd, q = %wd\n", i, q); fflush(stdout); flint_abort(); } fmpq_sub(t, right, cur); fmpz_one(fmpq_numref(s)); fmpz_mul(fmpq_denref(s), fmpq_denref(right), fmpq_denref(cur)); if (!fmpq_equal(s, t)) { flint_printf("FAIL:\n"); flint_printf("check right neighbor i = %wd, q = %wd\n", i, q); fflush(stdout); flint_abort(); } fmpq_swap(cur, right); } fmpq_set_si(right, 2, 1); if (!fmpq_equal(cur, right)) { flint_printf("FAIL:\n"); flint_printf("check end q = %wd\n", q); fflush(stdout); flint_abort(); } fmpz_clear(Q); fmpq_clear(s); fmpq_clear(t); fmpq_clear(cur); fmpq_clear(left); fmpq_clear(right); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
/* Copyright (C) 2019 Daniel Schultz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */
unit_pool3d_generic.ml
(** Unit test for Pooling3D operations *) open Owl_types (** Functor to generate test module *) module Make (N : Ndarray_Algodiff with type elt = float) = struct (* Functions used in tests *) let tolerance_f64 = 1e-8 let tolerance_f32 = 5e-4 let close a b = N.(sub a b |> abs |> sum') < tolerance_f32 let test_maxpool3d input_shape kernel stride pad = let inp = N.sequential ~a:1. input_shape in N.max_pool3d ~padding:pad inp kernel stride let test_avgpool3d input_shape kernel stride pad = let inp = N.sequential ~a:1. input_shape in N.avg_pool3d ~padding:pad inp kernel stride let test_maxpool3d_back input_shape kernel stride pad = let input = N.sequential ~a:1. input_shape in let output = N.max_pool3d ~padding:pad input kernel stride in let output_shape = N.shape output in let output' = N.sequential ~a:1. output_shape in N.max_pool3d_backward pad input kernel stride output' let test_avgpool3d_back input_shape kernel stride pad = let input = N.sequential ~a:1. input_shape in let output = N.avg_pool3d ~padding:pad input kernel stride in let output_shape = N.shape output in let output' = N.sequential ~a:1. output_shape in N.avg_pool3d_backward pad input kernel stride output' let verify_value fn input_shape kernel stride pad expected = let a = fn input_shape kernel stride pad in let output_shape = N.shape a in let b = N.of_array expected output_shape in close a b (* Test AvgPooling3D and MaxPooling3D forward operations *) module To_test_pool3d = struct (* testAvgPool3dValidPadding *) let fun00 () = let expected = [| 20.5; 21.5; 22.5 |] in verify_value test_avgpool3d [| 1; 3; 3; 3; 3 |] [| 2; 2; 2 |] [| 2; 2; 2 |] VALID expected (* testAvgPool3dSamePadding *) let fun01 () = let expected = [| 20.5; 21.5; 22.5; 26.5; 27.5; 28.5 |] in verify_value test_avgpool3d [| 1; 2; 2; 4; 3 |] [| 2; 2; 2 |] [| 2; 2; 2 |] SAME expected (* testAvgPool3dSamePaddingDifferentStrides *) let fun02 () = let expected = [| 1.5; 4.5; 7.5; 17.5; 20.5; 23.5; 33.5; 36.5; 39.5 |] in verify_value test_avgpool3d [| 1; 5; 8; 1; 1 |] [| 1; 2; 3 |] [| 2; 3; 1 |] SAME expected (* testMaxPool3dValidPadding *) let fun03 () = let expected = [| 40.0; 41.0; 42.0 |] in verify_value test_maxpool3d [| 1; 3; 3; 3; 3 |] [| 2; 2; 2 |] [| 2; 2; 2 |] VALID expected (* testMaxPool3dSamePadding *) let fun04 () = let expected = [| 31.; 32.; 33.; 34.; 35.; 36. |] in verify_value test_maxpool3d [| 1; 2; 2; 3; 3 |] [| 2; 2; 2 |] [| 2; 2; 2 |] SAME expected (* testMaxPool3dSamePaddingDifferentStrides *) let fun05 () = let expected = [| 2.; 5.; 8.; 18.; 21.; 24.; 34.; 37.; 40. |] in verify_value test_maxpool3d [| 1; 5; 8; 1; 1 |] [| 1; 2; 3 |] [| 2; 3; 1 |] SAME expected (* testKernelSmallerThanStride1 *) let fun06 () = let expected = [| 1.; 3.; 7.; 9.; 19.; 21.; 25.; 27. |] in verify_value test_maxpool3d [| 1; 3; 3; 3; 1 |] [| 1; 1; 1 |] [| 2; 2; 2 |] SAME expected (* testKernelSmallerThanStride2 *) let fun07 () = let expected = [| 58.; 61.; 79.; 82.; 205.; 208.; 226.; 229. |] in verify_value test_maxpool3d [| 1; 7; 7; 7; 1 |] [| 2; 2; 2 |] [| 3; 3; 3 |] VALID expected (* testKernelSmallerThanStride3 *) let fun08 () = let expected = [| 1.; 3.; 7.; 9.; 19.; 21.; 25.; 27. |] in verify_value test_avgpool3d [| 1; 3; 3; 3; 1 |] [| 1; 1; 1 |] [| 2; 2; 2 |] SAME expected (* testKernelSmallerThanStride4 *) let fun09 () = let expected = [| 29.5; 32.5; 50.5; 53.5; 176.5; 179.5; 197.5; 200.5 |] in verify_value test_avgpool3d [| 1; 7; 7; 7; 1 |] [| 2; 2; 2 |] [| 3; 3; 3 |] VALID expected end (* Test MaxPooling3D backward operations *) module To_test_maxpool3d_back = struct (* testMaxPoolGradValidPadding1_1_3d *) let fun00 () = let expected = [| 1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; 11.; 12.; 13.; 14.; 15.; 16.; 17.; 18. ; 19.; 20.; 21.; 22.; 23.; 24.; 25.; 26.; 27. |] in verify_value test_maxpool3d_back [| 1; 3; 3; 3; 1 |] [| 1; 1; 1 |] [| 1; 1; 1 |] VALID expected (* testMaxPoolGradValidPadding2_1_6 *) let fun01 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 0.; 0.; 1.; 2.; 3.; 4.; 5.; 0.; 6.; 7.; 8.; 9.; 10.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 11.; 12.; 13.; 14.; 15.; 0.; 16.; 17.; 18.; 19.; 20. |] in verify_value test_maxpool3d_back [| 1; 3; 3; 6; 1 |] [| 2; 2; 2 |] [| 1; 1; 1 |] VALID expected (* testMaxPoolGradValidPadding2_1_7 *) let fun02 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 1.; 2.; 3.; 4.; 5.; 6.; 0.; 7.; 8.; 9.; 10.; 11.; 12.; 0.; 13.; 14. ; 15.; 16.; 17.; 18.; 0.; 19.; 20.; 21.; 22.; 23.; 24.; 0.; 0.; 0.; 0.; 0.; 0. ; 0.; 0.; 25.; 26.; 27.; 28.; 29.; 30.; 0.; 31.; 32.; 33.; 34.; 35.; 36.; 0.; 37. ; 38.; 39.; 40.; 41.; 42.; 0.; 43.; 44.; 45.; 46.; 47.; 48. |] in verify_value test_maxpool3d_back [| 1; 3; 5; 7; 1 |] [| 2; 2; 2 |] [| 1; 1; 1 |] VALID expected (* testMaxPoolGradValidPadding2_2 *) let fun03 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 1.; 2. |] in verify_value test_maxpool3d_back [| 1; 2; 2; 2; 2 |] [| 2; 2; 2 |] [| 2; 2; 2 |] VALID expected (* testMaxPoolGradSamePadding1_1 *) let fun04 () = let expected = [| 1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; 11.; 12.; 13.; 14.; 15.; 16.; 17.; 18. ; 19.; 20.; 21.; 22.; 23.; 24. |] in verify_value test_maxpool3d_back [| 1; 3; 2; 4; 1 |] [| 1; 1; 1 |] [| 1; 1; 1 |] SAME expected (* testMaxPoolGradSamePadding2_1 *) let fun05 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 6.; 8.; 22.; 0.; 0.; 0.; 0. ; 0.; 60.; 64.; 140. |] in verify_value test_maxpool3d_back [| 1; 3; 2; 4; 1 |] [| 2; 2; 2 |] [| 1; 1; 1 |] SAME expected (* testMaxPoolGradSamePadding2_2 *) let fun06 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 1.; 0.; 2.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 3.; 0.; 4.; 0.; 0.; 0.; 0.; 0.; 5.; 0.; 6. |] in verify_value test_maxpool3d_back [| 1; 5; 2; 4; 1 |] [| 2; 2; 2 |] [| 2; 2; 2 |] SAME expected (* testMaxPoolGradSamePadding3_1 *) let fun07 () = let expected = [| 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0. ; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 1.; 2.; 3.; 4.; 5.; 13.; 0.; 23.; 25.; 27. ; 29.; 31.; 68.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 65.; 67.; 69.; 71.; 73.; 152. ; 0.; 172.; 176.; 180.; 184.; 188.; 388. |] in verify_value test_maxpool3d_back [| 1; 3; 3; 7; 1 |] [| 3; 3; 3 |] [| 1; 1; 1 |] SAME expected end (* Test AvgPooling3D backward operations *) module To_test_avgpool3d_back = struct (* testAvgPoolGradValidPadding1_1 *) let fun00 () = let expected = [| 1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; 11.; 12.; 13.; 14.; 15.; 16.; 17.; 18. ; 19.; 20.; 21.; 22.; 23.; 24.; 25.; 26.; 27. |] in verify_value test_avgpool3d_back [| 1; 3; 3; 3; 1 |] [| 1; 1; 1 |] [| 1; 1; 1 |] VALID expected (* testAvgPoolGradValidPadding2_1 *) let fun01 () = let expected = [| 0.125; 0.375; 0.25; 0.5; 1.25; 0.75; 0.375; 0.875; 0.5; 0.75; 1.75; 1.; 2.; 4.5 ; 2.5; 1.25; 2.75; 1.5; 0.625; 1.375; 0.75; 1.5; 3.25; 1.75; 0.875; 1.875; 1. |] in verify_value test_avgpool3d_back [| 1; 3; 3; 3; 1 |] [| 2; 2; 2 |] [| 1; 1; 1 |] VALID expected (* testAvgPoolGradValidPadding2_2 *) let fun02 () = let expected = [| 0.125; 0.25; 0.125; 0.25; 0.125; 0.25; 0.125; 0.25; 0.125; 0.25; 0.125; 0.25 ; 0.125; 0.25; 0.125; 0.25 |] in verify_value test_avgpool3d_back [| 1; 2; 2; 2; 2 |] [| 2; 2; 2 |] [| 2; 2; 2 |] VALID expected (* testAvgPoolGradSamePadding1_1 *) let fun03 () = let expected = [| 1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; 11.; 12.; 13.; 14.; 15.; 16.; 17.; 18. ; 19.; 20.; 21.; 22.; 23.; 24. |] in verify_value test_avgpool3d_back [| 1; 3; 2; 4; 1 |] [| 1; 1; 1 |] [| 1; 1; 1 |] SAME expected (* testAvgPoolGradSamePadding2_1 *) let fun04 () = let expected = [| 0.125; 0.625; 0.875; 3.375; 1.375; 4.875; 5.625; 19.125 |] in verify_value test_avgpool3d_back [| 1; 2; 2; 2; 1 |] [| 2; 2; 2 |] [| 1; 1; 1 |] SAME expected (* testAvgPoolGradSamePadding2_2 *) let fun05 () = let expected = [| 0.125; 0.125; 0.25; 0.25; 0.125; 0.125; 0.25; 0.25; 0.125; 0.125; 0.25; 0.25 ; 0.125; 0.125; 0.25; 0.25; 0.375; 0.375; 0.5; 0.5; 0.375; 0.375; 0.5; 0.5; 0.375 ; 0.375; 0.5; 0.5; 0.375; 0.375; 0.5; 0.5; 1.25; 1.25; 1.5; 1.5; 1.25; 1.25; 1.5 ; 1.5 |] in verify_value test_avgpool3d_back [| 1; 5; 2; 4; 1 |] [| 2; 2; 2 |] [| 2; 2; 2 |] SAME expected (* testAvgPoolGradSamePadding3_1 *) let fun06 () = let expected = [| 7.29166651; 10.57870388; 9.86111164; 10.55555534; 11.25; 14.05092716 ; 10.30092621; 15.55555439; 22.37036705; 20.44444466; 21.55555725; 22.66666603 ; 27.92592621; 20.37037277; 12.15277767; 17.38426018; 15.69444466; 16.38888931 ; 17.08333397; 20.85648346; 15.16203785; 23.33333397; 33.25925827; 29.77777863 ; 30.8888855; 31.99999809; 38.81481552; 28.14814758; 43.55555344; 61.92592621 ; 55.11110687; 56.88888931; 58.66666794; 70.81481934; 51.25925827; 31.11111259 ; 44.1481514; 39.11111069; 40.22221756; 41.33333969; 49.70370483; 35.92592621 ; 21.875; 30.99537086; 27.36111259; 28.05555534; 28.75000191; 34.46759415 ; 24.88425827; 38.88888931; 55.0370369; 48.44444275; 49.55554962; 50.66666794 ; 60.59259033; 43.70370483; 26.73611259; 37.80093002; 33.19444275; 33.88888931 ; 34.58333588; 41.27314758; 29.74537086 |] in verify_value test_avgpool3d_back [| 1; 3; 3; 7; 1 |] [| 3; 3; 3 |] [| 1; 1; 1 |] SAME expected end (* tests for forward 3D pooling operations *) let fun_forward00 () = Alcotest.(check bool) "fun_forward00" true (To_test_pool3d.fun00 ()) let fun_forward01 () = Alcotest.(check bool) "fun_forward01" true (To_test_pool3d.fun01 ()) let fun_forward02 () = Alcotest.(check bool) "fun_forward02" true (To_test_pool3d.fun02 ()) let fun_forward03 () = Alcotest.(check bool) "fun_forward03" true (To_test_pool3d.fun03 ()) let fun_forward04 () = Alcotest.(check bool) "fun_forward04" true (To_test_pool3d.fun04 ()) let fun_forward05 () = Alcotest.(check bool) "fun_forward05" true (To_test_pool3d.fun05 ()) let fun_forward06 () = Alcotest.(check bool) "fun_forward06" true (To_test_pool3d.fun06 ()) let fun_forward07 () = Alcotest.(check bool) "fun_forward07" true (To_test_pool3d.fun07 ()) let fun_forward08 () = Alcotest.(check bool) "fun_forward08" true (To_test_pool3d.fun08 ()) let fun_forward09 () = Alcotest.(check bool) "fun_forward09" true (To_test_pool3d.fun09 ()) (* tests for backward 3D maxpooling operations *) let fun_max3d_back00 () = Alcotest.(check bool) "fun_max3d_back00" true (To_test_maxpool3d_back.fun00 ()) let fun_max3d_back01 () = Alcotest.(check bool) "fun_max3d_back01" true (To_test_maxpool3d_back.fun01 ()) let fun_max3d_back02 () = Alcotest.(check bool) "fun_max3d_back02" true (To_test_maxpool3d_back.fun02 ()) let fun_max3d_back03 () = Alcotest.(check bool) "fun_max3d_back03" true (To_test_maxpool3d_back.fun03 ()) let fun_max3d_back04 () = Alcotest.(check bool) "fun_max3d_back04" true (To_test_maxpool3d_back.fun04 ()) let fun_max3d_back05 () = Alcotest.(check bool) "fun_max3d_back05" true (To_test_maxpool3d_back.fun05 ()) let fun_max3d_back06 () = Alcotest.(check bool) "fun_max3d_back06" true (To_test_maxpool3d_back.fun06 ()) let fun_max3d_back07 () = Alcotest.(check bool) "fun_max3d_back07" true (To_test_maxpool3d_back.fun07 ()) (* tests for backward 2D avgpooling operations *) let fun_avg3d_back00 () = Alcotest.(check bool) "fun_avg3d_back00" true (To_test_avgpool3d_back.fun00 ()) let fun_avg3d_back01 () = Alcotest.(check bool) "fun_avg3d_back01" true (To_test_avgpool3d_back.fun01 ()) let fun_avg3d_back02 () = Alcotest.(check bool) "fun_avg3d_back02" true (To_test_avgpool3d_back.fun02 ()) let fun_avg3d_back03 () = Alcotest.(check bool) "fun_avg3d_back03" true (To_test_avgpool3d_back.fun03 ()) let fun_avg3d_back04 () = Alcotest.(check bool) "fun_avg3d_back04" true (To_test_avgpool3d_back.fun04 ()) let fun_avg3d_back05 () = Alcotest.(check bool) "fun_avg3d_back05" true (To_test_avgpool3d_back.fun05 ()) let fun_avg3d_back06 () = Alcotest.(check bool) "fun_avg3d_back06" true (To_test_avgpool3d_back.fun06 ()) let test_set = [ "fun_forward00", `Slow, fun_forward00; "fun_forward01", `Slow, fun_forward01 ; "fun_forward02", `Slow, fun_forward02; "fun_forward03", `Slow, fun_forward03 ; "fun_forward04", `Slow, fun_forward04; "fun_forward05", `Slow, fun_forward05 ; "fun_forward06", `Slow, fun_forward06; "fun_forward07", `Slow, fun_forward07 ; "fun_forward08", `Slow, fun_forward08; "fun_forward09", `Slow, fun_forward09 ; "fun_max3d_back00", `Slow, fun_max3d_back00 ; "fun_max3d_back01", `Slow, fun_max3d_back01 ; "fun_max3d_back02", `Slow, fun_max3d_back02 ; "fun_max3d_back03", `Slow, fun_max3d_back03 ; "fun_max3d_back04", `Slow, fun_max3d_back04 ; "fun_max3d_back05", `Slow, fun_max3d_back05 ; "fun_max3d_back06", `Slow, fun_max3d_back06 ; "fun_max3d_back07", `Slow, fun_max3d_back07 ; "fun_avg3d_back00", `Slow, fun_avg3d_back00 ; "fun_avg3d_back01", `Slow, fun_avg3d_back01 ; "fun_avg3d_back02", `Slow, fun_avg3d_back02 ; "fun_avg3d_back03", `Slow, fun_avg3d_back03 ; "fun_avg3d_back04", `Slow, fun_avg3d_back04 ; "fun_avg3d_back05", `Slow, fun_avg3d_back05 ; "fun_avg3d_back06", `Slow, fun_avg3d_back06 ] end
(** Unit test for Pooling3D operations *)
marshal.mli
type extern_flags = | No_sharing | Closures | Compat_32 val to_channel : out_channel -> 'a -> extern_flags list -> unit external to_bytes : 'a -> extern_flags list -> bytes = "caml_output_value_to_bytes" external to_string : 'a -> extern_flags list -> string = "caml_output_value_to_string" val to_buffer : bytes -> int -> int -> 'a -> extern_flags list -> int val from_channel : in_channel -> 'a val from_bytes : bytes -> int -> 'a val from_string : string -> int -> 'a val header_size : int val data_size : bytes -> int -> int val total_size : bytes -> int -> int
impure2.mli
val f: int -> int (*@ y = f x pure diverges *)
uint16.ml
open Stdint type uint16 = Uint16.t type t = uint16 let add = Uint16.add let sub = Uint16.sub let mul = Uint16.mul let div = Uint16.div let rem = Uint16.rem let logand = Uint16.logand let logor = Uint16.logor let logxor = Uint16.logxor let lognot = Uint16.lognot let shift_left = Uint16.shift_left let shift_right = Uint16.shift_right let of_int = Uint16.of_int let to_int = Uint16.to_int let of_float = Uint16.of_float let to_float = Uint16.to_float let of_int32 = Uint16.of_int32 let to_int32 = Uint16.to_int32 let bits_of_float = Uint16.of_float (* This may cause issues *) let float_of_bits = Uint16.to_float (* This may cause issues *) let zero = Uint16.zero let one = Uint16.one let succ = Uint16.succ let pred = Uint16.pred let max_int = Uint16.max_int let min_int = Uint16.min_int module Conv = Uint.Str_conv.Make(struct type t = uint16 let fmt = "Ul" let name = "Uint16" let zero = zero let max_int = max_int let bits = 16 let of_int = of_int let to_int = to_int let add = add let mul = mul let divmod = (fun x y -> div x y, rem x y) end) let of_string = Conv.of_string let to_string = Conv.to_string let to_string_bin = Conv.to_string_bin let to_string_oct = Conv.to_string_oct let to_string_hex = Conv.to_string_hex let printer = Conv.printer let printer_bin = Conv.printer_bin let printer_oct = Conv.printer_oct let printer_hex = Conv.printer_hex let compare = Stdlib.compare
serialize.ml
open Faraday module IOVec = Httpaf.IOVec type frame_info = { flags : Flags.t ; stream_id : Stream_identifier.t ; padding : Bigstringaf.t ; max_frame_payload : int } let write_uint24 t n = let write_octet t o = write_uint8 t (o land 0xff) in write_octet t (n lsr 16); write_octet t (n lsr 8); write_octet t n let write_frame_header t frame_header = let { Frame.payload_length; flags; stream_id; frame_type } = frame_header in write_uint24 t payload_length; write_uint8 t (Frame.FrameType.serialize frame_type); write_uint8 t flags; BE.write_uint32 t stream_id let write_frame_with_padding t info frame_type length writer = let header, writer = if Bigstringaf.length info.padding = 0 then let header = { Frame.payload_length = length ; flags = info.flags ; stream_id = info.stream_id ; frame_type } in header, writer else let pad_length = Bigstringaf.length info.padding in let writer' t = write_uint8 t pad_length; writer t; schedule_bigstring ~off:0 ~len:pad_length t info.padding in let header = { Frame.payload_length = length + pad_length + 1 ; flags = Flags.set_padded info.flags ; stream_id = info.stream_id ; frame_type } in header, writer' in write_frame_header t header; writer t let write_data_frame t ?off ?len info body = let writer t = write_string t ?off ?len body in let length = match len with Some len -> len | None -> String.length body in write_frame_with_padding t info Data length writer let schedule_data_frame t info ?off ?len bstr = let writer t = schedule_bigstring t ?off ?len bstr in let length = match len with Some len -> len | None -> Bigstringaf.length bstr in write_frame_with_padding t info Data length writer let write_priority t { Priority.exclusive; stream_dependency; weight } = let stream_dependency_id = if exclusive then Priority.set_exclusive stream_dependency else stream_dependency in BE.write_uint32 t stream_dependency_id; (* From RFC7540§6.3: * An unsigned 8-bit integer representing a priority weight for the stream * (see Section 5.3). Add one to the value to obtain a weight between 1 and * 256. * * Note: we store priority with values from 1 to 256, so decrement here. *) write_uint8 t (weight - 1) let bounded_schedule_iovecs t ~len iovecs = let rec loop t remaining iovecs = match remaining, iovecs with | 0, _ | _, [] -> () | remaining, { IOVec.buffer; off; len } :: xs -> if remaining < len then schedule_bigstring t ~off ~len:remaining buffer else ( schedule_bigstring t ~off ~len buffer; loop t (remaining - len) xs) in loop t len iovecs let write_headers_frame t info ~priority ?len iovecs = let len = match len with Some len -> len | None -> IOVec.lengthv iovecs in if priority == Priority.default_priority then (* See RFC7540§6.3: * Just the Header Block Fragment length if no priority. *) let writer t = bounded_schedule_iovecs t ~len iovecs in write_frame_with_padding t info Headers len writer else (* See RFC7540§6.2: * Exclusive Bit & Stream Dependency (4 octets) + Weight (1 octet) + * Header Block Fragment length. *) let payload_length = len + 5 in let info' = { info with flags = Flags.set_priority info.flags } in let writer t = write_priority t priority; bounded_schedule_iovecs t ~len iovecs in write_frame_with_padding t info' Headers payload_length writer let write_priority_frame t info priority = let header = { Frame.flags = info.flags ; stream_id = info.stream_id (* See RFC7540§6.3: * Stream Dependency (4 octets) + Weight (1 octet). *) ; payload_length = 5 ; frame_type = Priority } in write_frame_header t header; write_priority t priority let write_rst_stream_frame t info e = let header = { Frame.flags = info.flags ; stream_id = info.stream_id (* From RFC7540§6.4: * The RST_STREAM frame contains a single unsigned, 32-bit integer * identifying the error code (Section 7). *) ; payload_length = 4 ; frame_type = RSTStream } in write_frame_header t header; BE.write_uint32 t (Error_code.serialize e) let write_settings_frame t info settings = let header = { Frame.flags = info.flags ; stream_id = info.stream_id (* From RFC7540§6.5.1: * The payload of a SETTINGS frame consists of zero or more * parameters, each consisting of an unsigned 16-bit setting * identifier and an unsigned 32-bit value. *) ; payload_length = List.length settings * 6 ; frame_type = Settings } in write_frame_header t header; Settings.write_settings_payload t settings let write_push_promise_frame t info ~promised_id ?len iovecs = let len = match len with Some len -> len | None -> IOVec.lengthv iovecs in let payload_length = (* From RFC7540§6.6: * The PUSH_PROMISE frame includes the unsigned 31-bit identifier of the * stream the endpoint plans to create along with a set of headers that * provide additional context for the stream. *) 4 + len in let writer t = BE.write_uint32 t promised_id; bounded_schedule_iovecs t ~len iovecs in write_frame_with_padding t info PushPromise payload_length writer let default_ping_payload = (* From RFC7540§6.7: * In addition to the frame header, PING frames MUST contain 8 octets of * opaque data in the payload. *) let bstr = Bigstringaf.create 8 in for i = 0 to 7 do Bigstringaf.unsafe_set bstr i '\000' done; bstr let write_ping_frame t info ?(off = 0) payload = (* From RFC7540§6.7: * In addition to the frame header, PING frames MUST contain 8 octets of * opaque data in the payload. *) let payload_length = 8 in let header = { Frame.flags = info.flags ; stream_id = info.stream_id ; payload_length ; frame_type = Ping } in write_frame_header t header; schedule_bigstring ~off ~len:payload_length t payload let write_go_away_frame t info stream_id error_code debug_data = let debug_data_len = Bigstringaf.length debug_data in let header = { Frame.flags = info.flags ; stream_id = info.stream_id (* See RFC7540§6.8: * Last-Stream-ID (4 octets) + Error Code (4 octets) + Additional * Debug Data (opaque) *) ; payload_length = 8 + debug_data_len ; frame_type = GoAway } in write_frame_header t header; BE.write_uint32 t stream_id; BE.write_uint32 t (Error_code.serialize error_code); schedule_bigstring t ~off:0 ~len:debug_data_len debug_data let write_window_update_frame t info window_size = let header = { Frame.flags = info.flags ; stream_id = info.stream_id (* From RFC7540§6.9: * The payload of a WINDOW_UPDATE frame is one reserved bit plus an * unsigned 31-bit integer indicating the number of octets that the * sender can transmit in addition to the existing flow-control * window. *) ; payload_length = 4 ; frame_type = WindowUpdate } in write_frame_header t header; BE.write_uint32 t window_size let write_continuation_frame t info ?len iovecs = let len = match len with Some len -> len | None -> IOVec.lengthv iovecs in let header = { Frame.flags = info.flags ; stream_id = info.stream_id ; payload_length = len ; frame_type = Continuation } in write_frame_header t header; bounded_schedule_iovecs t ~len iovecs let write_unknown_frame t ~code info payload = let payload_length = Bigstringaf.length payload in let header = { Frame.flags = info.flags ; stream_id = info.stream_id ; payload_length ; frame_type = Unknown code } in write_frame_header t header; schedule_bigstring t ~off:0 ~len:payload_length payload let write_connection_preface t = (* From RFC7540§3.5: * In HTTP/2, each endpoint is required to send a connection preface as a * final confirmation of the protocol in use and to establish the initial * settings for the HTTP/2 connection. [...] The client connection preface * starts with a sequence of 24 octets, [...] the string * PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n. *) write_string t Frame.connection_preface module Writer = struct type t = { buffer : Bigstringaf.t (* The buffer that the encoder uses for buffered writes. Managed by * the control module for the encoder. *) ; encoder : Faraday.t (* The encoder that handles encoding for writes. Uses the [buffer] * referenced above internally. *) ; mutable drained_bytes : int (* The number of bytes that were not written due to the output stream * being closed before all buffered output could be written. Useful * for detecting error cases. *) ; headers_block_buffer : Bigstringaf.t ; mutable wakeup : Optional_thunk.t } let create buffer_size = let buffer = Bigstringaf.create buffer_size in let encoder = Faraday.of_bigstring buffer in { buffer ; encoder ; drained_bytes = 0 ; headers_block_buffer = Bigstringaf.create 0x1000 ; wakeup = Optional_thunk.none } let faraday t = t.encoder let make_frame_info ?(padding = Bigstringaf.empty) ?(flags = Flags.default_flags) ?(max_frame_size = Config.default.read_buffer_size) stream_id = { flags; stream_id; padding; max_frame_payload = max_frame_size } let write_connection_preface t settings_list = write_connection_preface t.encoder; let frame_info = make_frame_info Stream_identifier.connection in (* From RFC7540§3.5: * This sequence MUST be followed by a SETTINGS frame (Section 6.5), * which MAY be empty. *) write_settings_frame t.encoder frame_info settings_list let chunk_data_frames ?(off = 0) ~f frame_info total_length = let { max_frame_payload; _ } = frame_info in if max_frame_payload < total_length then let rec loop ~off remaining = if max_frame_payload < remaining then ( (* Note: If we're splitting data into several frames, only the last * one should contain the END_STREAM flag, so unset it here if it's * set. *) let frame_info = { frame_info with flags = Flags.clear_end_stream frame_info.flags } in f ~off ~len:max_frame_payload frame_info; loop ~off:(off + max_frame_payload) (remaining - max_frame_payload)) else f ~off ~len:remaining frame_info in loop ~off total_length else f ~off ~len:total_length frame_info let write_data t frame_info ?off ?len str = if not (is_closed t.encoder) then let total_length = match len with Some len -> len | None -> String.length str in chunk_data_frames frame_info ?off total_length ~f:(fun ~off ~len frame_info -> write_data_frame t.encoder frame_info ~off ~len str) let schedule_data t frame_info ?off ?len bstr = if not (is_closed t.encoder) then let total_length = match len with Some len -> len | None -> Bigstringaf.length bstr in chunk_data_frames frame_info ?off total_length ~f:(fun ~off ~len frame_info -> schedule_data_frame t.encoder frame_info ~off ~len bstr) (* Chunk header block fragments into HEADERS|PUSH_PROMISE + CONTINUATION * frames. *) let chunk_header_block_fragments t frame_info ?(has_priority = false) ~(write_frame : Faraday.t -> frame_info -> ?len:int -> Bigstringaf.t iovec list -> unit) faraday = let block_size = Faraday.pending_bytes faraday in let total_length = if has_priority then (* See RFC7540§6.2: Exclusive Bit & Stream Dependency (4 octets) + Weight (1 octet) + Header Block Fragment length. *) block_size + 5 else block_size in let { max_frame_payload; _ } = frame_info in if max_frame_payload < total_length then ( let headers_block_len = if has_priority then max_frame_payload - 5 else max_frame_payload in ignore (Faraday.serialize faraday (fun iovecs -> write_frame t.encoder frame_info ~len:headers_block_len iovecs; `Ok headers_block_len)); let rec loop remaining = if max_frame_payload < remaining then ( (* Note: Don't reuse flags from frame info as CONTINUATION frames * only define END_HEADERS. * * From RFC7540§6.10: * The CONTINUATION frame defines the following flag: * * END_HEADERS (0x4): When set, bit 2 indicates that this frame * ends a header block (Section 4.3). *) let frame_info = { frame_info with flags = Flags.default_flags } in ignore (Faraday.serialize faraday (fun iovecs -> write_continuation_frame t.encoder frame_info ~len:max_frame_payload iovecs; `Ok max_frame_payload)); loop (remaining - max_frame_payload)) else let frame_info = { frame_info with flags = Flags.(set_end_header default_flags) } in ignore (Faraday.serialize faraday (fun iovecs -> write_continuation_frame t.encoder frame_info ~len:remaining iovecs; `Ok remaining)) in loop (block_size - headers_block_len)) else let frame_info = { frame_info with flags = Flags.set_end_header frame_info.flags } in ignore (Faraday.serialize faraday (fun iovecs -> let len = IOVec.lengthv iovecs in write_frame t.encoder frame_info ~len iovecs; `Ok len)) let encode_headers hpack_encoder faraday headers = List.iter (fun header -> Hpack.Encoder.encode_header hpack_encoder faraday header) (Headers.to_hpack_list headers) let write_request_like_frame t hpack_encoder ~write_frame frame_info request = let { Request.meth; target; scheme; headers } = request in let faraday = Faraday.of_bigstring t.headers_block_buffer in Hpack.Encoder.encode_header hpack_encoder faraday { Headers.name = ":method" ; value = Httpaf.Method.to_string meth ; sensitive = false }; if meth <> `CONNECT then ( (* From RFC7540§8.3: * The :scheme and :path pseudo-header fields MUST be omitted. *) Hpack.Encoder.encode_header hpack_encoder faraday { Headers.name = ":path"; value = target; sensitive = false }; Hpack.Encoder.encode_header hpack_encoder faraday { Headers.name = ":scheme"; value = scheme; sensitive = false }); encode_headers hpack_encoder faraday headers; chunk_header_block_fragments t frame_info ~write_frame faraday let write_request_headers t hpack_encoder ~priority frame_info request = if not (is_closed t.encoder) then let write_frame = write_headers_frame ~priority in write_request_like_frame t hpack_encoder ~write_frame frame_info request let write_push_promise t hpack_encoder frame_info ~promised_id request = if not (is_closed t.encoder) then let write_frame = write_push_promise_frame ~promised_id in write_request_like_frame t hpack_encoder ~write_frame frame_info request let write_response_headers t hpack_encoder frame_info response = if not (is_closed t.encoder) then ( let { Response.status; headers; _ } = response in let faraday = Faraday.of_bigstring t.headers_block_buffer in (* From RFC7540§8.1.2.4: * For HTTP/2 responses, a single :status pseudo-header field is defined * that carries the HTTP status code field (see [RFC7231], Section 6). * This pseudo-header field MUST be included in all responses; otherwise, * the response is malformed (Section 8.1.2.6). *) Hpack.Encoder.encode_header hpack_encoder faraday { Headers.name = ":status" ; value = Status.to_string status ; sensitive = false }; encode_headers hpack_encoder faraday headers; chunk_header_block_fragments t frame_info ~write_frame:(write_headers_frame ~priority:Priority.default_priority) ~has_priority:false faraday) let write_response_trailers t hpack_encoder frame_info trailers = if not (is_closed t.encoder) then ( let faraday = Faraday.of_bigstring t.headers_block_buffer in (* From RFC7540§8.1: * optionally, one HEADERS frame, followed by zero or more * CONTINUATION frames containing the trailer-part, if present (see * [RFC7230], Section 4.1.2). *) encode_headers hpack_encoder faraday trailers; chunk_header_block_fragments t frame_info ~write_frame:(write_headers_frame ~priority:Priority.default_priority) ~has_priority:false faraday) let write_rst_stream t frame_info e = if not (is_closed t.encoder) then write_rst_stream_frame t.encoder frame_info e let write_window_update t frame_info n = if not (is_closed t.encoder) then write_window_update_frame t.encoder frame_info n let schedule_iovecs t ~len frame_info iovecs = if not (is_closed t.encoder) then let writer t ~len ~iovecs = bounded_schedule_iovecs t ~len iovecs in chunk_data_frames frame_info len ~f:(fun ~off ~len frame_info -> write_frame_with_padding t.encoder frame_info Data len (writer ~iovecs:(IOVec.shiftv iovecs off) ~len)) let write_priority t frame_info priority = if not (is_closed t.encoder) then write_priority_frame t.encoder frame_info priority let write_settings t frame_info settings = if not (is_closed t.encoder) then write_settings_frame t.encoder frame_info settings let write_ping t frame_info ?off payload = if not (is_closed t.encoder) then write_ping_frame t.encoder frame_info ?off payload let write_go_away t frame_info ~debug_data ~last_stream_id error = if not (is_closed t.encoder) then write_go_away_frame t.encoder frame_info last_stream_id error debug_data let on_wakeup_writer t k = if Faraday.is_closed t.encoder then failwith "on_wakeup_writer on closed conn" else if Optional_thunk.is_some t.wakeup then failwith "on_wakeup: only one callback can be registered at a time" else t.wakeup <- Optional_thunk.some k let wakeup t = let f = t.wakeup in t.wakeup <- Optional_thunk.none; Optional_thunk.call_if_some f let flush t f = flush t.encoder f let yield t = Faraday.yield t.encoder let close t = Faraday.close t.encoder let close_and_drain t = Faraday.close t.encoder; let drained = Faraday.drain t.encoder in t.drained_bytes <- t.drained_bytes + drained let is_closed t = Faraday.is_closed t.encoder let drained_bytes t = t.drained_bytes let report_result t result = match result with | `Closed -> close_and_drain t | `Ok len -> shift t.encoder len let next t = match Faraday.operation t.encoder with | `Close -> `Close (drained_bytes t) | `Yield -> `Yield | `Writev iovecs -> `Write iovecs end
(*---------------------------------------------------------------------------- * Copyright (c) 2017 Inhabited Type LLC. * Copyright (c) 2019 Antonio N. Monteiro. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the author nor the names of his contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*)
operation_result.ml
open Protocol open Alpha_context open Apply_results let pp_manager_operation_content (type kind) source internal pp_result ppf ((operation, result) : kind manager_operation * _) = Format.fprintf ppf "@[<v 0>" ; (match operation with | Transaction {destination; amount; parameters; entrypoint} -> Format.fprintf ppf "@[<v 2>%s:@,Amount: %s%a@,From: %a@,To: %a" (if internal then "Internal transaction" else "Transaction") Client_proto_args.tez_sym Tez.pp amount Contract.pp source Contract.pp destination ; (match entrypoint with | "default" -> () | _ -> Format.fprintf ppf "@,Entrypoint: %s" entrypoint) ; (if not (Script_repr.is_unit_parameter parameters) then let expr = WithExceptions.Option.to_exn ~none:(Failure "ill-serialized argument") (Data_encoding.force_decode parameters) in Format.fprintf ppf "@,Parameter: @[<v 0>%a@]" Michelson_v1_printer.print_expr expr) ; pp_result ppf result ; Format.fprintf ppf "@]" | Origination {delegate; credit; script = {code; storage}; preorigination = _} -> Format.fprintf ppf "@[<v 2>%s:@,From: %a@,Credit: %s%a" (if internal then "Internal origination" else "Origination") Contract.pp source Client_proto_args.tez_sym Tez.pp credit ; let code = WithExceptions.Option.to_exn ~none:(Failure "ill-serialized code") (Data_encoding.force_decode code) and storage = WithExceptions.Option.to_exn ~none:(Failure "ill-serialized storage") (Data_encoding.force_decode storage) in let {Michelson_v1_parser.source; _} = Michelson_v1_printer.unparse_toplevel code in Format.fprintf ppf "@,@[<hv 2>Script:@ @[<h>%a@]@,@[<hv 2>Initial storage:@ %a@]" Format.pp_print_text source Michelson_v1_printer.print_expr storage ; (match delegate with | None -> Format.fprintf ppf "@,No delegate for this contract" | Some delegate -> Format.fprintf ppf "@,Delegate: %a" Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" | Reveal key -> Format.fprintf ppf "@[<v 2>%s of manager public key:@,Contract: %a@,Key: %a%a@]" (if internal then "Internal revelation" else "Revelation") Contract.pp source Signature.Public_key.pp key pp_result result | Delegation None -> Format.fprintf ppf "@[<v 2>%s:@,Contract: %a@,To: nobody%a@]" (if internal then "Internal Delegation" else "Delegation") Contract.pp source pp_result result | Delegation (Some delegate) -> Format.fprintf ppf "@[<v 2>%s:@,Contract: %a@,To: %a%a@]" (if internal then "Internal Delegation" else "Delegation") Contract.pp source Signature.Public_key_hash.pp delegate pp_result result) ; Format.fprintf ppf "@]" let pp_balance_updates ppf = function | [] -> () | balance_updates -> let open Receipt in (* For dry runs, the baker's key is zero (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" else Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map (fun (balance, update, origin) -> let balance = match balance with | Contract c -> Format.asprintf "%a" Contract.pp c | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" pp_baker pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" pp_baker pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" pp_baker pkh Cycle.pp l in let balance = match origin with | Block_application -> balance | Protocol_migration -> Format.asprintf "migration %s" balance in (balance, update)) balance_updates in let column_size = List.fold_left (fun acc (balance, _) -> Compare.Int.max acc (String.length balance)) 0 balance_updates in let pp_update ppf = function | Credited amount -> Format.fprintf ppf "+%s%a" Client_proto_args.tez_sym Tez.pp amount | Debited amount -> Format.fprintf ppf "-%s%a" Client_proto_args.tez_sym Tez.pp amount in let pp_one ppf (balance, update) = let to_fill = column_size + 3 - String.length balance in let filler = String.make to_fill '.' in Format.fprintf ppf "%s %s %a" balance filler pp_update update in Format.fprintf ppf "@[<v 0>%a@]" (Format.pp_print_list pp_one) balance_updates let pp_manager_operation_contents_and_result ppf ( Manager_operation {source; fee; operation; counter; gas_limit; storage_limit}, Manager_operation_result {balance_updates; operation_result; internal_operation_results} ) = let pp_lazy_storage_diff = function | None -> () | Some lazy_storage_diff -> ( let big_map_diff = Contract.Legacy_big_map_diff.of_lazy_storage_diff lazy_storage_diff in match (big_map_diff :> Contract.Legacy_big_map_diff.item list) with | [] -> () | _ :: _ -> (* TODO: print all lazy storage diff *) Format.fprintf ppf "@,@[<v 2>Updated big_maps:@ %a@]" Michelson_v1_printer.print_big_map_diff lazy_storage_diff) in let pp_transaction_result (Transaction_result { balance_updates; consumed_gas; storage; originated_contracts; storage_size; paid_storage_size_diff; lazy_storage_diff; allocated_destination_contract = _; }) = (match originated_contracts with | [] -> () | contracts -> Format.fprintf ppf "@,@[<v 2>Originated contracts:@,%a@]" (Format.pp_print_list Contract.pp) contracts) ; (match storage with | None -> () | Some expr -> Format.fprintf ppf "@,@[<hv 2>Updated storage:@ %a@]" Michelson_v1_printer.print_expr expr) ; pp_lazy_storage_diff lazy_storage_diff ; if storage_size <> Z.zero then Format.fprintf ppf "@,Storage size: %s bytes" (Z.to_string storage_size) ; if paid_storage_size_diff <> Z.zero then Format.fprintf ppf "@,Paid storage size diff: %s bytes" (Z.to_string paid_storage_size_diff) ; Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas ; match balance_updates with | [] -> () | balance_updates -> Format.fprintf ppf "@,Balance updates:@, %a" pp_balance_updates balance_updates in let pp_origination_result (Origination_result { lazy_storage_diff; balance_updates; consumed_gas; originated_contracts; storage_size; paid_storage_size_diff; }) = (match originated_contracts with | [] -> () | contracts -> Format.fprintf ppf "@,@[<v 2>Originated contracts:@,%a@]" (Format.pp_print_list Contract.pp) contracts) ; if storage_size <> Z.zero then Format.fprintf ppf "@,Storage size: %s bytes" (Z.to_string storage_size) ; pp_lazy_storage_diff lazy_storage_diff ; if paid_storage_size_diff <> Z.zero then Format.fprintf ppf "@,Paid storage size diff: %s bytes" (Z.to_string paid_storage_size_diff) ; Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas ; match balance_updates with | [] -> () | balance_updates -> Format.fprintf ppf "@,Balance updates:@, %a" pp_balance_updates balance_updates in let pp_result (type kind) ppf (result : kind manager_operation_result) = Format.fprintf ppf "@," ; match result with | Skipped _ -> Format.fprintf ppf "This operation was skipped" | Failed (_, _errs) -> Format.fprintf ppf "This operation FAILED." | Applied (Reveal_result {consumed_gas}) -> Format.fprintf ppf "This revelation was successfully applied" ; Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas | Backtracked (Reveal_result _, _) -> Format.fprintf ppf "@[<v 0>This revelation was BACKTRACKED, its expected effects were \ NOT applied.@]" | Applied (Delegation_result {consumed_gas}) -> Format.fprintf ppf "This delegation was successfully applied" ; Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas | Backtracked (Delegation_result _, _) -> Format.fprintf ppf "@[<v 0>This delegation was BACKTRACKED, its expected effects were \ NOT applied.@]" | Applied (Transaction_result _ as tx) -> Format.fprintf ppf "This transaction was successfully applied" ; pp_transaction_result tx | Backtracked ((Transaction_result _ as tx), _errs) -> Format.fprintf ppf "@[<v 0>This transaction was BACKTRACKED, its expected effects (as \ follow) were NOT applied.@]" ; pp_transaction_result tx | Applied (Origination_result _ as op) -> Format.fprintf ppf "This origination was successfully applied" ; pp_origination_result op | Backtracked ((Origination_result _ as op), _errs) -> Format.fprintf ppf "@[<v 0>This origination was BACKTRACKED, its expected effects (as \ follow) were NOT applied.@]" ; pp_origination_result op in Format.fprintf ppf "@[<v 0>@[<v 2>Manager signed operations:@,\ From: %a@,\ Fee to the baker: %s%a@,\ Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp fee (Z.to_string counter) Gas.Arith.pp_integral gas_limit (Z.to_string storage_limit) ; (match balance_updates with | [] -> () | balance_updates -> Format.fprintf ppf "@,Balance updates:@, %a" pp_balance_updates balance_updates) ; Format.fprintf ppf "@,%a" (pp_manager_operation_content (Contract.implicit_contract source) false pp_result) (operation, operation_result) ; (match internal_operation_results with | [] -> () | _ :: _ -> Format.fprintf ppf "@,@[<v 2>Internal operations:@ %a@]" (Format.pp_print_list (fun ppf (Internal_operation_result (op, res)) -> pp_manager_operation_content op.source false pp_result ppf (op.operation, res))) internal_operation_results) ; Format.fprintf ppf "@]" let rec pp_contents_and_result_list : type kind. Format.formatter -> kind contents_and_result_list -> unit = fun ppf -> function | Single_and_result (Seed_nonce_revelation {level; nonce}, Seed_nonce_revelation_result bus) -> Format.fprintf ppf "@[<v 2>Seed nonce revelation:@,\ Level: %a@,\ Nonce (hash): %a@,\ Balance updates:@,\ \ %a@]" Raw_level.pp level Nonce_hash.pp (Nonce.hash nonce) pp_balance_updates bus | Single_and_result (Double_baking_evidence {bh1; bh2}, Double_baking_evidence_result bus) -> Format.fprintf ppf "@[<v 2>Double baking evidence:@,\ Exhibit A: %a@,\ Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" Block_hash.pp (Block_header.hash bh1) Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus | Single_and_result ( Double_endorsement_evidence {op1; op2; slot = _}, Double_endorsement_evidence_result bus ) -> Format.fprintf ppf "@[<v 2>Double endorsement evidence:@,\ Exhibit A: %a@,\ Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" Operation_hash.pp (Operation.hash op1) Operation_hash.pp (Operation.hash op2) pp_balance_updates bus | Single_and_result (Activate_account {id; _}, Activate_account_result bus) -> Format.fprintf ppf "@[<v 2>Genesis account activation:@,\ Account: %a@,\ Balance updates:@,\ \ %a@]" Ed25519.Public_key_hash.pp id pp_balance_updates bus | Single_and_result ( Endorsement_with_slot { endorsement = {protocol_data = {contents = Single (Endorsement {level}); _}; _}; _; }, Endorsement_with_slot_result (Endorsement_result {balance_updates; delegate; slots}) ) | Single_and_result ( Endorsement {level}, Endorsement_result {balance_updates; delegate; slots} ) -> Format.fprintf ppf "@[<v 2>Endorsement:@,\ Level: %a@,\ Balance updates:%a@,\ Delegate: %a@,\ Slots: %a@]" Raw_level.pp level pp_balance_updates balance_updates Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots | Single_and_result (Proposals {source; period; proposals}, Proposals_result) -> Format.fprintf ppf "@[<v 2>Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[<v 0>%a@]@]" Signature.Public_key_hash.pp source period (Format.pp_print_list Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[<v 2>Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" Signature.Public_key_hash.pp source period Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) | Single_and_result (Failing_noop _arbitrary, _) -> (* the Failing_noop operation always fails and can't have result *) . | Single_and_result ((Manager_operation _ as op), (Manager_operation_result _ as res)) -> Format.fprintf ppf "%a" pp_manager_operation_contents_and_result (op, res) | Cons_and_result ((Manager_operation _ as op), (Manager_operation_result _ as res), rest) -> Format.fprintf ppf "%a@\n%a" pp_manager_operation_contents_and_result (op, res) pp_contents_and_result_list rest let pp_operation_result ppf ((op, res) : 'kind contents_list * 'kind contents_result_list) = Format.fprintf ppf "@[<v 0>" ; let contents_and_result_list = Apply_results.pack_contents_list op res in pp_contents_and_result_list ppf contents_and_result_list ; Format.fprintf ppf "@]@." let pp_internal_operation ppf (Internal_operation {source; operation; nonce = _}) = pp_manager_operation_content source true (fun _ppf () -> ()) ppf (operation, ())
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
splay.ml
(* Translation in ocaml by VB: This program is probably not the best splay tree implementation in OCaml, because it tries to follow exactly the steps of the Google v8 benchmark. *) let kSplayTreeSize = 8000 let kSplayTreeModifications = 80 let kSplayTreePayloadDepth = 5 type content_leaf = { array : int array ; string : string } type content = | CLeaf of content_leaf | CNode of content * content type tree = | Empty | Node of (tree * float * content * tree) (** * Perform the splay operation for the given key. Moves the node with * the given key to the top of the tree. If no node has the given * key, the last node on the search path is moved to the top of the * tree. This is the simplified top-down splaying algorithm from: * "Self-adjusting Binary Search Trees" by Sleator and Tarjan *) let rec splay_ ((left, key, value, right) as a) k = if k = key then a else if k < key then match left with | Empty -> a (* not found *) | Node (lleft, lk, lv, lright) -> ( if k = lk then lleft, lk, lv, Node (lright, key, value, right) (* zig *) else if k < lk then match lleft with | Empty -> Empty, lk, lv, Node (lright, key, value, right) (* not found *) | Node n -> (* zig-zig *) let llleft, llk, llv, llright = splay_ n k in llleft, llk, llv, Node (llright, lk, lv, Node (lright, key, value, right)) else match lright with | Empty -> lleft, lk, lv, Node (Empty, key, value, right) | Node n -> (* zig-zag *) let lrleft, lrk, lrv, lrright = splay_ n k in Node (lleft, lk, lv, lrleft), lrk, lrv, Node (lrright, key, value, right)) else match right with | Empty -> a | Node (rleft, rk, rv, rright) -> ( if k = rk then Node (left, key, value, rleft), rk, rv, rright (* zag *) else if k > rk then match rright with | Empty -> Node (left, key, value, rleft), rk, rv, rright (* not found *) | Node n -> (* zag-zag *) let rrleft, rrk, rrv, rrright = splay_ n k in Node (Node (left, key, value, rleft), rk, rv, rrleft), rrk, rrv, rrright else match rleft with | Empty -> Node (left, key, value, rleft), rk, rv, rright (* not found *) | Node n -> (* zag-zig *) let rlleft, rlk, rlv, rlright = splay_ n k in Node (left, key, value, rlleft), rlk, rlv, Node (rlright, rk, rv, rright)) let splay t key = match t with | Empty -> t | Node n -> Node (splay_ n key) let insert key value t = (* Splay on the key to move the last node on the search path for the key to the root of the tree. *) let t = splay t key in match t with | Empty -> Node (Empty, key, value, Empty) | Node (left, rk, rv, right) -> if rk = key then t else if key > rk then Node (Node (left, rk, rv, Empty), key, value, right) else Node (left, key, value, Node (Empty, rk, rv, right)) let remove key t = let t = splay t key in match t with | Empty -> t | Node (_, rk, _, _) when rk <> key -> raise Not_found | Node (Empty, _, _, right) -> right | Node (left, _, _, right) -> ( match splay left key with | Node (lleft, lk, lv, Empty) -> Node (lleft, lk, lv, right) | _ -> failwith "remove") let find key t = let t = splay t key in match t with | Node (_, k, v, _) when k = key -> Some v, t | _ -> None, t let rec findMax = function (* here we do not splay (but that's what the original program does) *) | Empty -> raise Not_found | Node (_, k, _, Empty) -> k | Node (_, _, _, right) -> findMax right let findGreatestLessThan key t = (* Splay on the key to move the node with the given key or the last node on the search path to the top of the tree. Now the result is either the root node or the greatest node in the left subtree. *) let t = splay t key in match t with | Empty -> None, t | Node (_, k, _, _) when k < key -> Some k, t | Node (Empty, _, _, _) -> None, t | Node (left, _, _, _) -> Some (findMax left), t let exportKeys t = let rec aux l length = function | Empty -> l, length | Node (left, k, _, right) -> let l, length = aux l length right in aux (k :: l) (length + 1) left in aux [] 0 t let rec generatePayloadTree depth tag = if depth = 0 then CLeaf { array = [| 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 |] ; string = "String for key " ^ tag ^ " in leaf node" } else CNode (generatePayloadTree (depth - 1) tag, generatePayloadTree (depth - 1) tag) let random = let seed = ref 49734321 in fun () -> (* // Robert Jenkins' 32 bit integer hash function. *) let s = !seed in let s = (s + 0x7ed55d16 + (s lsl 12)) land 0xffffffff in let s = s lxor 0xc761c23c lxor (s lsr 19) in let s = s + 0x165667b1 + (s lsl 5) in let s = (s + 0xd3a2646c) lxor (s lsl 9) in let s = (s + 0xfd7046c5 + (s lsl 3)) land 0xffffffff in let s = s lxor 0xb55a4f09 lxor (s lsr 16) in seed := s; float (s land 0xfffffff) /. float 0x10000000 let generateKey = random let insertNewNode t = let rec aux t = let key = generateKey () in let vo, t = find key t in match vo with | None -> key, t | _ -> aux t in let key, t = aux t in let payload = generatePayloadTree kSplayTreePayloadDepth (string_of_float key) in key, insert key payload t let splaySetup () = let rec aux i t = if i < kSplayTreeSize then aux (i + 1) (snd (insertNewNode t)) else t in aux 0 Empty let splayTearDown t = let keys, length = exportKeys t in (* // Verify that the splay tree has the right size. *) if length <> kSplayTreeSize then failwith "Splay tree has wrong size"; (* // Verify that the splay tree has sorted, unique keys. *) match keys with | [] -> () | a :: l -> ignore (List.fold_left (fun b e -> if b >= e then failwith "Splay tree not sorted" else e) a l) let splayRun t = (* // Replace a few nodes in the splay tree. *) let rec aux i t = if i < kSplayTreeModifications then let key, t = insertNewNode t in aux (i + 1) (match findGreatestLessThan key t with | None, t -> remove key t | Some k, t -> remove k t) else t in aux 0 t let ( ++ ) a b = b a let () = splaySetup () ++ splayRun ++ splayTearDown
(* // Copyright 2009 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This benchmark is based on a JavaScript log processing module used // by the V8 profiler to generate execution time profiles for runs of // JavaScript applications, and it effectively measures how fast the // JavaScript engine is at allocating nodes and reclaiming the memory // used for old nodes. Because of the way splay trees work, the engine // also has to deal with a lot of changes to the large tree object // graph. *)
jsoo_tests.ml
open Stdune module Jsoo_rules = Dune_rules.Jsoo_rules let%expect_test _ = let test s l = match Jsoo_rules.Version.of_string s with | None -> print_endline "Could not parse version" | Some version -> let c = Jsoo_rules.Version.compare version l in let r = match c with | Eq -> "=" | Lt -> "<" | Gt -> ">" in print_endline r in (* equal *) test "5.0.1" (5, 0); [%expect {| = |}]; test "5.0.0" (5, 0); [%expect {| = |}]; test "5.0" (5, 0); [%expect {| = |}]; test "5" (5, 0); [%expect {| = |}]; test "5.0+1" (5, 0); [%expect {| = |}]; test "5.0~1" (5, 0); [%expect {| = |}]; test "5.0+1" (5, 0); [%expect {| = |}]; test "5.0.1+git-5.0.1-14-g904cf100b0" (5, 0); [%expect {| = |}]; test "5.0.1" (5, 1); [%expect {| < |}]; test "5.0" (5, 1); [%expect {| < |}]; test "5.1.1" (5, 0); [%expect {| > |}]; test "5.1" (5, 0); [%expect {| > |}]; test "4.0.1" (5, 0); [%expect {| < |}]; test "5.0.1" (4, 0); [%expect {| > |}]; ()
write.c
#include <string.h> #include "calcium.h" void calcium_write(calcium_stream_t out, const char * s) { if (out->fp != NULL) { flint_fprintf(out->fp, s); } else { slong len, alloc; len = strlen(s); alloc = out->len + len + 1; if (alloc > out->alloc) { alloc = FLINT_MAX(alloc, out->alloc * 2); out->s = flint_realloc(out->s, alloc); out->alloc = alloc; } memcpy(out->s + out->len, s, len + 1); out->len += len; } }
/* Copyright (C) 2020 Fredrik Johansson This file is part of Calcium. Calcium is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <http://www.gnu.org/licenses/>. */
nativeint.mli
val zero : nativeint val one : nativeint val minus_one : nativeint external neg : nativeint -> nativeint = "%nativeint_neg" external add : nativeint -> nativeint -> nativeint = "%nativeint_add" external sub : nativeint -> nativeint -> nativeint = "%nativeint_sub" external mul : nativeint -> nativeint -> nativeint = "%nativeint_mul" external div : nativeint -> nativeint -> nativeint = "%nativeint_div" val unsigned_div : nativeint -> nativeint -> nativeint external rem : nativeint -> nativeint -> nativeint = "%nativeint_mod" val unsigned_rem : nativeint -> nativeint -> nativeint val succ : nativeint -> nativeint val pred : nativeint -> nativeint val abs : nativeint -> nativeint val size : int val max_int : nativeint val min_int : nativeint external logand : nativeint -> nativeint -> nativeint = "%nativeint_and" external logor : nativeint -> nativeint -> nativeint = "%nativeint_or" external logxor : nativeint -> nativeint -> nativeint = "%nativeint_xor" val lognot : nativeint -> nativeint external shift_left : nativeint -> int -> nativeint = "%nativeint_lsl" external shift_right : nativeint -> int -> nativeint = "%nativeint_asr" external shift_right_logical : nativeint -> int -> nativeint = "%nativeint_lsr" external of_int : int -> nativeint = "%nativeint_of_int" external to_int : nativeint -> int = "%nativeint_to_int" val unsigned_to_int : nativeint -> int option external of_float : float -> nativeint = "caml_nativeint_of_float" "caml_nativeint_of_float_unboxed"[@@unboxed ][@@noalloc ] external to_float : nativeint -> float = "caml_nativeint_to_float" "caml_nativeint_to_float_unboxed"[@@unboxed ][@@noalloc ] external of_int32 : int32 -> nativeint = "%nativeint_of_int32" external to_int32 : nativeint -> int32 = "%nativeint_to_int32" external of_string : string -> nativeint = "caml_nativeint_of_string" val of_string_opt : string -> nativeint option val to_string : nativeint -> string type t = nativeint val compare : t -> t -> int val unsigned_compare : t -> t -> int val equal : t -> t -> bool external format : string -> nativeint -> string = "caml_nativeint_format"
rounding_mode.mli
include Value.S with type s = Farith.Mode.t val init : Egraph.wt -> unit
(*************************************************************************) (* This file is part of Colibri2. *) (* *) (* Copyright (C) 2014-2021 *) (* CEA (Commissariat à l'énergie atomique et aux énergies *) (* alternatives) *) (* *) (* you can redistribute it and/or modify it under the terms of the GNU *) (* Lesser General Public License as published by the Free Software *) (* Foundation, version 2.1. *) (* *) (* It is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU Lesser General Public License for more details. *) (* *) (* See the GNU Lesser General Public License version 2.1 *) (* for more details (enclosed in the file licenses/LGPLv2.1). *) (*************************************************************************)
time_repr.mli
include module type of struct include Time end (** Internal timestamp representation. *) type time = t (** Pretty-prints the time stamp using RFC3339 format. *) val pp : Format.formatter -> t -> unit (** Parses RFC3339 representation and returns a timestamp. *) val of_seconds_string : string -> time option (** Returns the timestamp encoded in RFC3339 format. *) val to_seconds_string : time -> string (** Adds a time span to a timestamp. This function fails on integer overflow *) val ( +? ) : time -> Period_repr.t -> time tzresult (** Returns the difference between two timestamps as a time span. This function fails when the difference is negative *) val ( -? ) : time -> time -> Period_repr.t tzresult
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
arg_helper.mli
(** Decipher command line arguments of the form <value> | <key>=<value>[,...] (as used for example for the specification of inlining parameters varying by simplification round). {b Warning:} this module is unstable and part of {{!Compiler_libs}compiler-libs}. *) module Make (S : sig module Key : sig type t (** The textual representation of a key must not contain '=' or ','. *) val of_string : string -> t module Map : Map.S with type key = t end module Value : sig type t (** The textual representation of a value must not contain ','. *) val of_string : string -> t end end) : sig type parsed val default : S.Value.t -> parsed val set_base_default : S.Value.t -> parsed -> parsed val add_base_override : S.Key.t -> S.Value.t -> parsed -> parsed val reset_base_overrides : parsed -> parsed val set_user_default : S.Value.t -> parsed -> parsed val add_user_override : S.Key.t -> S.Value.t -> parsed -> parsed val parse : string -> string -> parsed ref -> unit type parse_result = | Ok | Parse_failed of exn val parse_no_error : string -> parsed ref -> parse_result val get : key:S.Key.t -> parsed -> S.Value.t end
(**************************************************************************) (* *) (* OCaml *) (* *) (* Pierre Chambart, OCamlPro *) (* Mark Shinwell and Leo White, Jane Street Europe *) (* *) (* Copyright 2015--2016 OCamlPro SAS *) (* Copyright 2015--2016 Jane Street Group LLC *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) (* special exception on linking described in the file LICENSE. *) (* *) (**************************************************************************)
contract_storage.mli
type error += | Balance_too_low of Contract_repr.contract * Tez_repr.t * Tez_repr.t | (* `Temporary *) Counter_in_the_past of Contract_repr.contract * Z.t * Z.t | (* `Branch *) Counter_in_the_future of Contract_repr.contract * Z.t * Z.t | (* `Temporary *) Unspendable_contract of Contract_repr.contract | (* `Permanent *) Non_existing_contract of Contract_repr.contract | (* `Temporary *) Empty_implicit_contract of Signature.Public_key_hash.t | (* `Temporary *) Empty_implicit_delegated_contract of Signature.Public_key_hash.t | (* `Temporary *) Empty_transaction of Contract_repr.t (* `Temporary *) | Inconsistent_hash of Signature.Public_key.t * Signature.Public_key_hash.t * Signature.Public_key_hash.t | (* `Permanent *) Inconsistent_public_key of Signature.Public_key.t * Signature.Public_key.t | (* `Permanent *) Failure of string (* `Permanent *) | Previously_revealed_key of Contract_repr.t (* `Permanent *) | Unrevealed_manager_key of Contract_repr.t (* `Permanent *) val exists : Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t (** [must_exist ctxt contract] fails with the [Non_existing_contract] error if [exists ctxt contract] returns [false]. Even though this function is gas-free, it is always called in a context where some gas consumption is guaranteed whenever necessary. The first context is that of a transfer operation, and in that case the base cost of a manager operation ([Micheclson_v1_gas.Cost_of.manager_operation]) is consumed. The second context is that of an activation operation, and in that case no gas needs to be consumed since that operation is not a manager operation. *) val must_exist : Raw_context.t -> Contract_repr.t -> unit tzresult Lwt.t val allocated : Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t val must_be_allocated : Raw_context.t -> Contract_repr.t -> unit tzresult Lwt.t val list : Raw_context.t -> Contract_repr.t list Lwt.t val check_counter_increment : Raw_context.t -> Signature.Public_key_hash.t -> Z.t -> unit tzresult Lwt.t val increment_counter : Raw_context.t -> Signature.Public_key_hash.t -> Raw_context.t tzresult Lwt.t val get_manager_key : Raw_context.t -> Signature.Public_key_hash.t -> Signature.Public_key.t tzresult Lwt.t val is_manager_key_revealed : Raw_context.t -> Signature.Public_key_hash.t -> bool tzresult Lwt.t val reveal_manager_key : Raw_context.t -> Signature.Public_key_hash.t -> Signature.Public_key.t -> Raw_context.t tzresult Lwt.t val get_balance : Raw_context.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t val get_balance_carbonated : Raw_context.t -> Contract_repr.t -> (Raw_context.t * Tez_repr.t) tzresult Lwt.t val get_counter : Raw_context.t -> Signature.Public_key_hash.t -> Z.t tzresult Lwt.t val get_script_code : Raw_context.t -> Contract_repr.t -> (Raw_context.t * Script_repr.lazy_expr option) tzresult Lwt.t val get_script : Raw_context.t -> Contract_repr.t -> (Raw_context.t * Script_repr.t option) tzresult Lwt.t val get_storage : Raw_context.t -> Contract_repr.t -> (Raw_context.t * Script_repr.expr option) tzresult Lwt.t module Legacy_big_map_diff : sig type item = private | Update of { big_map : Z.t; diff_key : Script_repr.expr; diff_key_hash : Script_expr_hash.t; diff_value : Script_repr.expr option; } | Clear of Z.t | Copy of {src : Z.t; dst : Z.t} | Alloc of { big_map : Z.t; key_type : Script_repr.expr; value_type : Script_repr.expr; } type t = item list val encoding : t Data_encoding.t val to_lazy_storage_diff : t -> Lazy_storage_diff.diffs val of_lazy_storage_diff : Lazy_storage_diff.diffs -> t end val update_script_storage : Raw_context.t -> Contract_repr.t -> Script_repr.expr -> Lazy_storage_diff.diffs option -> Raw_context.t tzresult Lwt.t val credit : Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t val spend : Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t val raw_originate : Raw_context.t -> ?prepaid_bootstrap_storage:bool -> Contract_repr.t -> balance:Tez_repr.t -> script:Script_repr.t * Lazy_storage_diff.diffs option -> delegate:Signature.Public_key_hash.t option -> Raw_context.t tzresult Lwt.t val fresh_contract_from_current_nonce : Raw_context.t -> (Raw_context.t * Contract_repr.t) tzresult val originated_from_current_nonce : since:Raw_context.t -> until:Raw_context.t -> Contract_repr.t list tzresult Lwt.t val init : Raw_context.t -> Raw_context.t tzresult Lwt.t val used_storage_space : Raw_context.t -> Contract_repr.t -> Z.t tzresult Lwt.t val paid_storage_space : Raw_context.t -> Contract_repr.t -> Z.t tzresult Lwt.t val set_paid_storage_space_and_return_fees_to_pay : Raw_context.t -> Contract_repr.t -> Z.t -> (Z.t * Raw_context.t) tzresult Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
dune
(library (name common_installer_generator) (libraries astring findlib fmt))
rewrite.ml
open Pp open CErrors open Util open Names open Constr open Context open EConstr open Vars open Reduction open Tacticals open Tactics open Pretype_errors open Evd open Tactypes open Locus open Locusops open Elimschemes open Environ open Termops open EConstr open Libnames open Proofview.Notations open Context.Named.Declaration module NamedDecl = Context.Named.Declaration (* module RelDecl = Context.Rel.Declaration *) module TC = Typeclasses (** Typeclass-based generalized rewriting. *) (** Constants used by the tactic. *) let classes_dirpath = Names.DirPath.make (List.map Id.of_string ["Classes";"Coq"]) let init_relation_classes () = if is_dirpath_prefix_of classes_dirpath (Lib.cwd ()) then () else Coqlib.check_required_library ["Coq";"Classes";"RelationClasses"] let init_setoid () = if is_dirpath_prefix_of classes_dirpath (Lib.cwd ()) then () else Coqlib.check_required_library ["Coq";"Setoids";"Setoid"] let find_reference dir s = Coqlib.find_reference "generalized rewriting" dir s [@@warning "-3"] let lazy_find_reference dir s = let gr = lazy (find_reference dir s) in fun () -> Lazy.force gr type evars = evar_map * Evar.Set.t (* goal evars, constraint evars *) let find_global dir s = let gr = lazy (find_reference dir s) in fun env (evd,cstrs) -> let (evd, c) = Evd.fresh_global env evd (Lazy.force gr) in (evd, cstrs), c (** Utility for dealing with polymorphic applications *) (** Global constants. *) let coq_eq_ref () = Coqlib.lib_ref "core.eq.type" let coq_eq = find_global ["Coq"; "Init"; "Logic"] "eq" let coq_f_equal = find_global ["Coq"; "Init"; "Logic"] "f_equal" let coq_all = find_global ["Coq"; "Init"; "Logic"] "all" let impl = find_global ["Coq"; "Program"; "Basics"] "impl" (** Bookkeeping which evars are constraints so that we can remove them at the end of the tactic. *) let goalevars evars = fst evars let cstrevars evars = snd evars let new_cstr_evar (evd,cstrs) env t = (* We handle the typeclass resolution of constraints ourselves *) let (evd', t) = Evarutil.new_evar env evd ~typeclass_candidate:false t in let ev, _ = destEvar evd' t in (evd', Evar.Set.add ev cstrs), t (** Building or looking up instances. *) let extends_undefined evars evars' = let f ev evi found = found || not (Evd.mem evars ev) in fold_undefined f evars' false let app_poly_check env evars f args = let (evars, cstrs), fc = f env evars in let evars, t = Typing.checked_appvect env evars fc args in (evars, cstrs), t let app_poly_nocheck env evars f args = let evars, fc = f env evars in evars, mkApp (fc, args) let app_poly_sort b = if b then app_poly_nocheck else app_poly_check let find_class_proof proof_type proof_method env evars carrier relation = try let evars, goal = app_poly_check env evars proof_type [| carrier ; relation |] in let evars', c = TC.resolve_one_typeclass env (goalevars evars) goal in if extends_undefined (goalevars evars) evars' then raise Not_found else app_poly_check env (evars',cstrevars evars) proof_method [| carrier; relation; c |] with e when CErrors.noncritical e -> raise Not_found let eq_pb (ty, env, x, y as pb) (ty', env', x', y' as pb') = let equal x y = Constr.equal (EConstr.Unsafe.to_constr x) (EConstr.Unsafe.to_constr y) in pb == pb' || (ty == ty' && equal x x' && equal y y') let problem_inclusion x y = List.for_all (fun pb -> List.exists (fun pb' -> eq_pb pb pb') y) x let evd_convertible env evd x y = try (* Unfortunately, the_conv_x might say they are unifiable even if some unsolvable constraints remain, so we check that this unification does not introduce any new problem. *) let _, pbs = Evd.extract_all_conv_pbs evd in let evd' = Evarconv.unify_delay env evd x y in let _, pbs' = Evd.extract_all_conv_pbs evd' in if evd' == evd || problem_inclusion pbs' pbs then Some evd' else None with e when CErrors.noncritical e -> None type hypinfo = { prf : constr; car : constr; rel : constr; sort : bool; (* true = Prop; false = Type *) c1 : constr; c2 : constr; holes : Clenv.hole list; } let error_no_relation () = user_err Pp.(str "Cannot find a relation to rewrite.") let rec decompose_app_rel env evd t = (* Head normalize for compatibility with the old meta mechanism *) let t = Reductionops.whd_betaiota env evd t in match EConstr.kind evd t with | App (f, [||]) -> assert false | App (f, [|arg|]) -> (* This treats the special case `g (R x y)`, turning it into the relation `(fun x y => g (R x y))`. Useful when g is negation in particular. *) let (f', argl, argr) = decompose_app_rel env evd arg in let ty = Retyping.get_type_of env evd argl in let ty' = Retyping.get_type_of env evd argr in let r = Retyping.relevance_of_type env evd ty in let r' = Retyping.relevance_of_type env evd ty' in let f'' = mkLambda (make_annot (Name Namegen.default_dependent_ident) r, ty, mkLambda (make_annot (Name (Id.of_string "y")) r', lift 1 ty', mkApp (lift 2 f, [| mkApp (lift 2 f', [| mkRel 2; mkRel 1 |]) |]))) in (f'', argl, argr) | App (f, args) -> let len = Array.length args in let fargs = Array.sub args 0 (Array.length args - 2) in let rel = mkApp (f, fargs) in rel, args.(len - 2), args.(len - 1) | _ -> error_no_relation () let decompose_app_rel env evd t = let (rel, t1, t2) = decompose_app_rel env evd t in let ty = try Retyping.get_type_of ~lax:true env evd rel with Retyping.RetypeError _ -> error_no_relation () in if not (Reductionops.is_arity env evd ty) then None else match Reductionops.splay_arity env evd ty with | [_, ty2; _, ty1], concl -> if noccurn evd 1 ty2 then Some (rel, ty1, subst1 mkProp ty2, concl, t1, t2) else None | _ -> assert false let decompose_app_rel_error env evd t = match decompose_app_rel env evd t with | Some e -> e | None -> error_no_relation () let decompose_applied_relation env sigma (c,l) = let open Context.Rel.Declaration in let ctype = Retyping.get_type_of env sigma c in let find_rel ty = let sigma, cl = Clenv.make_evar_clause env sigma ty in let sigma = Clenv.solve_evar_clause env sigma true cl l in let { Clenv.cl_holes = holes; Clenv.cl_concl = t } = cl in match decompose_app_rel env sigma t with | None -> None | Some (equiv, ty1, ty2, concl, c1, c2) -> match evd_convertible env sigma ty1 ty2 with | None -> None | Some sigma -> let args = Array.map_of_list (fun h -> h.Clenv.hole_evar) holes in let value = mkApp (c, args) in Some (sigma, { prf=value; car=ty1; rel = equiv; sort = Sorts.is_prop (ESorts.kind sigma concl); c1=c1; c2=c2; holes }) in match find_rel ctype with | Some c -> c | None -> let ctx,t' = Reductionops.splay_prod env sigma ctype in (* Search for underlying eq *) let t' = it_mkProd_or_LetIn t' (List.map (fun (n,t) -> LocalAssum (n, t)) ctx) in match find_rel t' with | Some c -> c | None -> user_err Pp.(str "Cannot find an homogeneous relation to rewrite.") (** Utility functions *) module GlobalBindings (M : sig val relation_classes : string list val morphisms : string list val relation : string list * string val app_poly : env -> evars -> (env -> evars -> evars * constr) -> constr array -> evars * constr val arrow : env -> evars -> evars * constr end) = struct open M open Context.Rel.Declaration let relation : env -> evars -> evars * constr = find_global (fst relation) (snd relation) let reflexive_type = find_global relation_classes "Reflexive" let reflexive_proof = find_global relation_classes "reflexivity" let symmetric_type = find_global relation_classes "Symmetric" let symmetric_proof = find_global relation_classes "symmetry" let transitive_type = find_global relation_classes "Transitive" let transitive_proof = find_global relation_classes "transitivity" let forall_relation = find_global morphisms "forall_relation" let pointwise_relation = find_global morphisms "pointwise_relation" let forall_relation_ref = lazy_find_reference morphisms "forall_relation" let pointwise_relation_ref = lazy_find_reference morphisms "pointwise_relation" let respectful = find_global morphisms "respectful" let default_relation = find_global ["Coq"; "Classes"; "SetoidTactics"] "DefaultRelation" let coq_forall = find_global morphisms "forall_def" let subrelation = find_global relation_classes "subrelation" let do_subrelation = find_global morphisms "do_subrelation" let apply_subrelation = find_global morphisms "apply_subrelation" let rewrite_relation_class = find_global relation_classes "RewriteRelation" let proper_class = let r = lazy (find_reference morphisms "Proper") in fun env sigma -> TC.class_info env sigma (Lazy.force r) let proper_proxy_class = let r = lazy (find_reference morphisms "ProperProxy") in fun env sigma -> TC.class_info env sigma (Lazy.force r) let proper_proj env sigma = mkConst (Option.get (List.hd (proper_class env sigma).TC.cl_projs).TC.meth_const) let proper_type env (sigma,cstrs) = let l = (proper_class env sigma).TC.cl_impl in let (sigma, c) = Evd.fresh_global env sigma l in (sigma, cstrs), c let proper_proxy_type env (sigma,cstrs) = let l = (proper_proxy_class env sigma).TC.cl_impl in let (sigma, c) = Evd.fresh_global env sigma l in (sigma, cstrs), c let proper_proof env evars carrier relation x = let evars, goal = app_poly env evars proper_proxy_type [| carrier ; relation; x |] in new_cstr_evar evars env goal let get_reflexive_proof env = find_class_proof reflexive_type reflexive_proof env let get_symmetric_proof env = find_class_proof symmetric_type symmetric_proof env let get_transitive_proof env = find_class_proof transitive_type transitive_proof env let mk_relation env evars ty = let evars', ty = Evarsolve.refresh_universes ~onlyalg:true ~status:(Evd.UnivFlexible false) (Some false) env (fst evars) ty in app_poly env (evars', snd evars) relation [| ty |] (** Build an inferred signature from constraints on the arguments and expected output relation *) let build_signature evars env m (cstrs : (types * types option) option list) (finalcstr : (types * types option) option) = let mk_relty evars newenv ty obj = match obj with | None | Some (_, None) -> let evars, relty = mk_relation newenv evars ty in if closed0 (goalevars evars) ty then let env' = Environ.reset_with_named_context (Environ.named_context_val env) env in new_cstr_evar evars env' relty else new_cstr_evar evars newenv relty | Some (x, Some rel) -> evars, rel in let rec aux env evars ty l = let t = Reductionops.whd_all env (goalevars evars) ty in match EConstr.kind (goalevars evars) t, l with | Prod (na, ty, b), obj :: cstrs -> let b = Reductionops.nf_betaiota env (goalevars evars) b in if noccurn (goalevars evars) 1 b (* non-dependent product *) then let ty = Reductionops.nf_betaiota env (goalevars evars) ty in let (evars, b', arg, cstrs) = aux env evars (subst1 mkProp b) cstrs in let evars, relty = mk_relty evars env ty obj in let evars', b' = Evarsolve.refresh_universes ~onlyalg:true ~status:(Evd.UnivFlexible false) (Some false) env (fst evars) b' in let evars, newarg = app_poly env (evars', snd evars) respectful [| ty ; b' ; relty ; arg |] in evars, mkProd(na, ty, b), newarg, (ty, Some relty) :: cstrs else let (evars, b, arg, cstrs) = aux (push_rel (LocalAssum (na, ty)) env) evars b cstrs in let ty = Reductionops.nf_betaiota env (goalevars evars) ty in let pred = mkLambda (na, ty, b) in let liftarg = mkLambda (na, ty, arg) in let evars, arg' = app_poly env evars forall_relation [| ty ; pred ; liftarg |] in if Option.is_empty obj then evars, mkProd(na, ty, b), arg', (ty, None) :: cstrs else user_err Pp.(str "build_signature: no constraint can apply on a dependent argument") | _, obj :: _ -> anomaly ~label:"build_signature" (Pp.str "not enough products.") | _, [] -> (match finalcstr with | None | Some (_, None) -> let t = Reductionops.nf_betaiota env (fst evars) ty in let evars, rel = mk_relty evars env t None in evars, t, rel, [t, Some rel] | Some (t, Some rel) -> evars, t, rel, [t, Some rel]) in aux env evars m cstrs (** Folding/unfolding of the tactic constants. *) let unfold_impl n sigma t = match EConstr.kind sigma t with | App (arrow, [| a; b |])(* when eq_constr arrow (Lazy.force impl) *) -> mkProd (make_annot n Sorts.Relevant, a, lift 1 b) | _ -> assert false let unfold_all sigma t = match EConstr.kind sigma t with | App (id, [| a; b |]) (* when eq_constr id (Lazy.force coq_all) *) -> (match EConstr.kind sigma b with | Lambda (n, ty, b) -> mkProd (n, ty, b) | _ -> assert false) | _ -> assert false let unfold_forall sigma t = match EConstr.kind sigma t with | App (id, [| a; b |]) (* when eq_constr id (Lazy.force coq_all) *) -> (match EConstr.kind sigma b with | Lambda (n, ty, b) -> mkProd (n, ty, b) | _ -> assert false) | _ -> assert false let arrow_morphism env evd n ta tb a b = let ap = is_Prop (goalevars evd) ta and bp = is_Prop (goalevars evd) tb in if ap && bp then app_poly env evd impl [| a; b |], unfold_impl n else if ap then (* Domain in Prop, CoDomain in Type *) (app_poly env evd arrow [| a; b |]), unfold_impl n (* (evd, mkProd (Anonymous, a, b)), (fun x -> x) *) else if bp then (* Dummy forall *) (app_poly env evd coq_all [| a; mkLambda (make_annot n Sorts.Relevant, a, lift 1 b) |]), unfold_forall else (* None in Prop, use arrow *) (app_poly env evd arrow [| a; b |]), unfold_impl n let rec decomp_pointwise sigma n c = if Int.equal n 0 then c else match EConstr.kind sigma c with | App (f, [| a; b; relb |]) when isRefX sigma (pointwise_relation_ref ()) f -> decomp_pointwise sigma (pred n) relb | App (f, [| a; b; arelb |]) when isRefX sigma (forall_relation_ref ()) f -> decomp_pointwise sigma (pred n) (Reductionops.beta_applist sigma (arelb, [mkRel 1])) | _ -> invalid_arg "decomp_pointwise" let rec apply_pointwise sigma rel = function | arg :: args -> (match EConstr.kind sigma rel with | App (f, [| a; b; relb |]) when isRefX sigma (pointwise_relation_ref ()) f -> apply_pointwise sigma relb args | App (f, [| a; b; arelb |]) when isRefX sigma (forall_relation_ref ()) f -> apply_pointwise sigma (Reductionops.beta_applist sigma (arelb, [arg])) args | _ -> invalid_arg "apply_pointwise") | [] -> rel let refresh_univs env evars ty = let evars', ty = Evarsolve.refresh_universes ~onlyalg:true ~status:(Evd.UnivFlexible false) (Some false) env (fst evars) ty in (evars', snd evars), ty let pointwise_or_dep_relation env evars n t car rel = let evars, car = refresh_univs env evars car in if noccurn (goalevars evars) 1 car && noccurn (goalevars evars) 1 rel then app_poly env evars pointwise_relation [| t; lift (-1) car; lift (-1) rel |] else app_poly env evars forall_relation [| t; mkLambda (make_annot n Sorts.Relevant, t, car); mkLambda (make_annot n Sorts.Relevant, t, rel) |] let lift_cstr env evars (args : constr list) c ty cstr = let start evars env car = match cstr with | None | Some (_, None) -> let evars, rel = mk_relation env evars car in new_cstr_evar evars env rel | Some (ty, Some rel) -> evars, rel in let rec aux evars env prod n = if Int.equal n 0 then start evars env prod else let sigma = goalevars evars in match EConstr.kind sigma (Reductionops.whd_all env sigma prod) with | Prod (na, ty, b) -> if noccurn sigma 1 b then let b' = lift (-1) b in let evars, rb = aux evars env b' (pred n) in app_poly env evars pointwise_relation [| ty; b'; rb |] else let evars, rb = aux evars (push_rel (LocalAssum (na, ty)) env) b (pred n) in app_poly env evars forall_relation [| ty; mkLambda (na, ty, b); mkLambda (na, ty, rb) |] | _ -> raise Not_found in let rec find env c ty = function | [] -> None | arg :: args -> try let evars, found = aux evars env ty (succ (List.length args)) in Some (evars, found, c, ty, arg :: args) with Not_found -> let sigma = goalevars evars in let ty = Reductionops.whd_all env sigma ty in find env (mkApp (c, [| arg |])) (prod_applist sigma ty [arg]) args in find env c ty args let unlift_cstr env sigma = function | None -> None | Some codom -> Some (decomp_pointwise (goalevars sigma) 1 codom) (** Looking up declared rewrite relations (instances of [RewriteRelation]) *) let is_applied_rewrite_relation env sigma rels t = match EConstr.kind sigma t with | App (c, args) when Array.length args >= 2 -> let head = if isApp sigma c then fst (destApp sigma c) else c in if isRefX sigma (coq_eq_ref ()) head then None else (try let env' = push_rel_context rels env in match decompose_app_rel env' sigma t with | None -> None | Some (equiv, ty1, ty2, concl, c1, c2) -> let (evars, evset), inst = app_poly env' (sigma,Evar.Set.empty) rewrite_relation_class [| ty1; equiv |] in let sigma, _ = TC.resolve_one_typeclass env' evars inst in (* We check that the relation is homogeneous *after* launching resolution, as this convertibility test might be expensive in general (e.g. this slows down mathcomp-odd-order). *) match evd_convertible env sigma ty1 ty2 with | None -> None | Some sigma -> Some (it_mkProd_or_LetIn t rels) with e when CErrors.noncritical e -> None) | _ -> None end let type_app_poly env env evd f args = let evars, c = app_poly_nocheck env evd f args in let evd', t = Typing.type_of env (goalevars evars) c in (evd', cstrevars evars), c module PropGlobal = struct module Consts = struct let relation_classes = ["Coq"; "Classes"; "RelationClasses"] let morphisms = ["Coq"; "Classes"; "Morphisms"] let relation = ["Coq"; "Relations";"Relation_Definitions"], "relation" let app_poly = app_poly_nocheck let arrow = find_global ["Coq"; "Program"; "Basics"] "arrow" let coq_inverse = find_global ["Coq"; "Program"; "Basics"] "flip" end module G = GlobalBindings(Consts) include G include Consts let inverse env evd car rel = type_app_poly env env evd coq_inverse [| car ; car; mkProp; rel |] (* app_poly env evd coq_inverse [| car ; car; mkProp; rel |] *) end module TypeGlobal = struct module Consts = struct let relation_classes = ["Coq"; "Classes"; "CRelationClasses"] let morphisms = ["Coq"; "Classes"; "CMorphisms"] let relation = relation_classes, "crelation" let app_poly = app_poly_check let arrow = find_global ["Coq"; "Classes"; "CRelationClasses"] "arrow" let coq_inverse = find_global ["Coq"; "Classes"; "CRelationClasses"] "flip" end module G = GlobalBindings(Consts) include G include Consts let inverse env (evd,cstrs) car rel = let evd, car = Evarsolve.refresh_universes ~onlyalg:true (Some false) env evd car in let (evd, sort) = Evarutil.new_Type ~rigid:Evd.univ_flexible evd in app_poly_check env (evd,cstrs) coq_inverse [| car ; car; sort; rel |] end let get_type_of_refresh env evars t = let evars', tty = Evarsolve.get_type_of_refresh env (fst evars) t in (evars', snd evars), tty let sort_of_rel env evm rel = ESorts.kind evm (Reductionops.sort_of_arity env evm (Retyping.get_type_of env evm rel)) let is_applied_rewrite_relation = PropGlobal.is_applied_rewrite_relation (* let _ = *) (* Hook.set Equality.is_applied_rewrite_relation is_applied_rewrite_relation *) let split_head = function hd :: tl -> hd, tl | [] -> assert(false) let get_symmetric_proof b = if b then PropGlobal.get_symmetric_proof else TypeGlobal.get_symmetric_proof let rewrite_db = "rewrite" let conv_transparent_state = TransparentState.cst_full let rewrite_transparent_state () = Hints.Hint_db.transparent_state (Hints.searchtable_map rewrite_db) let rewrite_core_unif_flags = { Unification.modulo_conv_on_closed_terms = None; Unification.use_metas_eagerly_in_conv_on_closed_terms = true; Unification.use_evars_eagerly_in_conv_on_closed_terms = true; Unification.modulo_delta = TransparentState.empty; Unification.modulo_delta_types = TransparentState.full; Unification.check_applied_meta_types = true; Unification.use_pattern_unification = true; Unification.use_meta_bound_pattern_unification = true; Unification.allowed_evars = Evarsolve.AllowedEvars.all; Unification.restrict_conv_on_strict_subterms = false; Unification.modulo_betaiota = false; Unification.modulo_eta = true; } (* Flags used for the setoid variant of "rewrite" and for the strategies "hints"/"old_hints"/"terms" of "rewrite_strat", and for solving pre-existing evars in "rewrite" (see unify_abs) *) let rewrite_unif_flags = let flags = rewrite_core_unif_flags in { Unification.core_unify_flags = flags; Unification.merge_unify_flags = flags; Unification.subterm_unify_flags = flags; Unification.allow_K_in_toplevel_higher_order_unification = true; Unification.resolve_evars = true } let rewrite_core_conv_unif_flags = { rewrite_core_unif_flags with Unification.modulo_conv_on_closed_terms = Some conv_transparent_state; Unification.modulo_delta_types = conv_transparent_state; Unification.modulo_betaiota = true } (* Fallback flags for the setoid variant of "rewrite" *) let rewrite_conv_unif_flags = let flags = rewrite_core_conv_unif_flags in { Unification.core_unify_flags = flags; Unification.merge_unify_flags = flags; Unification.subterm_unify_flags = flags; Unification.allow_K_in_toplevel_higher_order_unification = true; Unification.resolve_evars = true } (* Flags for "setoid_rewrite c"/"rewrite_strat -> c" *) let general_rewrite_unif_flags () = let ts = rewrite_transparent_state () in let core_flags = { rewrite_core_unif_flags with Unification.modulo_conv_on_closed_terms = Some ts; Unification.use_evars_eagerly_in_conv_on_closed_terms = true; Unification.modulo_delta = ts; Unification.modulo_delta_types = TransparentState.full; Unification.modulo_betaiota = true } in { Unification.core_unify_flags = core_flags; Unification.merge_unify_flags = core_flags; Unification.subterm_unify_flags = { core_flags with Unification.modulo_delta = TransparentState.empty }; Unification.allow_K_in_toplevel_higher_order_unification = true; Unification.resolve_evars = true } let refresh_hypinfo env sigma (cb : EConstr.t with_bindings delayed_open) = let sigma, cbl = cb env sigma in let sigma, hypinfo = decompose_applied_relation env sigma cbl in let { c1; c2; car; rel; prf; sort; holes } = hypinfo in sigma, (car, rel, prf, c1, c2, holes, sort) (** FIXME: write this in the new monad interface *) let solve_remaining_by env sigma holes by = match by with | None -> sigma | Some tac -> let map h = if h.Clenv.hole_deps then None else match EConstr.kind sigma h.Clenv.hole_evar with | Evar (evk, _) -> Some evk | _ -> None in (* Only solve independent holes *) let indep = List.map_filter map holes in let ist = { Geninterp.lfun = Id.Map.empty ; poly = false ; extra = Geninterp.TacStore.empty } in let solve_tac = match tac with | Genarg.GenArg (Genarg.Glbwit tag, tac) -> Ftactic.run (Geninterp.interp tag ist tac) (fun _ -> Proofview.tclUNIT ()) in let solve_tac = tclCOMPLETE solve_tac in let solve sigma evk = let evi = try Some (Evd.find_undefined sigma evk) with Not_found -> None in match evi with | None -> sigma (* Evar should not be defined, but just in case *) | Some evi -> let env = Evd.evar_env env evi in let ty = Evd.evar_concl evi in let name, poly = Id.of_string "rewrite", false in let c, sigma = Proof.refine_by_tactic ~name ~poly env sigma ty solve_tac in Evd.define evk (EConstr.of_constr c) sigma in List.fold_left solve sigma indep let no_constraints cstrs = fun ev _ -> not (Evar.Set.mem ev cstrs) let poly_inverse sort = if sort then PropGlobal.inverse else TypeGlobal.inverse type rewrite_proof = | RewPrf of constr * constr (** A Relation (R : rew_car -> rew_car -> Prop) and a proof of R rew_from rew_to *) | RewCast of cast_kind (** A proof of convertibility (with casts) *) type rewrite_result_info = { rew_car : constr ; (** A type *) rew_from : constr ; (** A term of type rew_car *) rew_to : constr ; (** A term of type rew_car *) rew_prf : rewrite_proof ; (** A proof of rew_from == rew_to *) rew_evars : evars; } type rewrite_result = | Fail | Identity | Success of rewrite_result_info type 'a strategy_input = { state : 'a ; (* a parameter: for instance, a state *) env : Environ.env ; unfresh : Id.Set.t; (* Unfresh names *) term1 : constr ; ty1 : types ; (* first term and its type (convertible to rew_from) *) cstr : (bool (* prop *) * constr option) ; evars : evars } type 'a pure_strategy = { strategy : 'a strategy_input -> 'a * rewrite_result (* the updated state and the "result" *) } type strategy = unit pure_strategy let symmetry env sort rew = let { rew_evars = evars; rew_car = car; } = rew in let (rew_evars, rew_prf) = match rew.rew_prf with | RewCast _ -> (rew.rew_evars, rew.rew_prf) | RewPrf (rel, prf) -> try let evars, symprf = get_symmetric_proof sort env evars car rel in let prf = mkApp (symprf, [| rew.rew_from ; rew.rew_to ; prf |]) in (evars, RewPrf (rel, prf)) with Not_found -> let evars, rel = poly_inverse sort env evars car rel in (evars, RewPrf (rel, prf)) in { rew with rew_from = rew.rew_to; rew_to = rew.rew_from; rew_prf; rew_evars; } (* Matching/unifying the rewriting rule against [t] *) let unify_eqn (car, rel, prf, c1, c2, holes, sort) l2r flags env (sigma, cstrs) by t = try let left = if l2r then c1 else c2 in let sigma = Unification.w_unify ~flags env sigma CONV left t in let sigma = TC.resolve_typeclasses ~filter:(no_constraints cstrs) ~fail:true env sigma in let sigma = solve_remaining_by env sigma holes by in let nf c = Reductionops.nf_evar sigma (Reductionops.nf_meta env sigma c) in let c1 = nf c1 and c2 = nf c2 and rew_car = nf car and rel = nf rel and prf = nf prf in let ty1 = Retyping.get_type_of env sigma c1 in let ty2 = Retyping.get_type_of env sigma c2 in begin match Reductionops.infer_conv ~pb:CUMUL env sigma ty2 ty1 with | None -> None | Some sigma -> let rew_evars = sigma, cstrs in let rew_prf = RewPrf (rel, prf) in let rew = { rew_evars; rew_prf; rew_car; rew_from = c1; rew_to = c2; } in let rew = if l2r then rew else symmetry env sort rew in Some rew end with | e when noncritical e -> None let unify_abs (car, rel, prf, c1, c2) l2r sort env (sigma, cstrs) t = try let left = if l2r then c1 else c2 in (* The pattern is already instantiated, so the next w_unify is basically an eq_constr, except when preexisting evars occur in either the lemma or the goal, in which case the eq_constr also solved this evars *) let sigma = Unification.w_unify ~flags:rewrite_unif_flags env sigma CONV left t in let rew_evars = sigma, cstrs in let rew_prf = RewPrf (rel, prf) in let rew = { rew_car = car; rew_from = c1; rew_to = c2; rew_prf; rew_evars; } in let rew = if l2r then rew else symmetry env sort rew in Some rew with | e when noncritical e -> None type rewrite_flags = { under_lambdas : bool; on_morphisms : bool } let default_flags = { under_lambdas = true; on_morphisms = true; } let get_opt_rew_rel = function RewPrf (rel, prf) -> Some rel | _ -> None let new_global env (evars, cstrs) gr = let (sigma,c) = Evd.fresh_global env evars gr in (sigma, cstrs), c let make_eq env sigma = new_global env sigma Coqlib.(lib_ref "core.eq.type") let make_eq_refl env sigma = new_global env sigma Coqlib.(lib_ref "core.eq.refl") let get_rew_prf env evars r = match r.rew_prf with | RewPrf (rel, prf) -> evars, (rel, prf) | RewCast c -> let evars, eq = make_eq env evars in let evars, eq_refl = make_eq_refl env evars in let rel = mkApp (eq, [| r.rew_car |]) in evars, (rel, mkCast (mkApp (eq_refl, [| r.rew_car; r.rew_from |]), c, mkApp (rel, [| r.rew_from; r.rew_to |]))) let poly_subrelation sort = if sort then PropGlobal.subrelation else TypeGlobal.subrelation let resolve_subrelation env car rel sort prf rel' res = if Termops.eq_constr (fst res.rew_evars) rel rel' then res else let evars, app = app_poly_check env res.rew_evars (poly_subrelation sort) [|car; rel; rel'|] in let evars, subrel = new_cstr_evar evars env app in let appsub = mkApp (subrel, [| res.rew_from ; res.rew_to ; prf |]) in { res with rew_prf = RewPrf (rel', appsub); rew_evars = evars } let resolve_morphism env m args args' (b,cstr) evars = let evars, proj, sigargs, m', args, args' = let first = match (Array.findi (fun _ b -> not (Option.is_empty b)) args') with | Some i -> i | None -> invalid_arg "resolve_morphism" in let morphargs, morphobjs = Array.chop first args in let morphargs', morphobjs' = Array.chop first args' in let appm = mkApp(m, morphargs) in let evd, appmtype = Typing.type_of env (goalevars evars) appm in let evars = evd, snd evars in let cstrs = List.map (Option.map (fun r -> r.rew_car, get_opt_rew_rel r.rew_prf)) (Array.to_list morphobjs') in (* Desired signature *) let evars, appmtype', signature, sigargs = if b then PropGlobal.build_signature evars env appmtype cstrs cstr else TypeGlobal.build_signature evars env appmtype cstrs cstr in (* Actual signature found *) let evars', appmtype' = Evarsolve.refresh_universes ~status:(Evd.UnivFlexible false) ~onlyalg:true (Some false) env (fst evars) appmtype' in let cl_args = [| appmtype' ; signature ; appm |] in let evars, app = app_poly_sort b env (evars', snd evars) (if b then PropGlobal.proper_type else TypeGlobal.proper_type) cl_args in let dosub, appsub = if b then PropGlobal.do_subrelation, PropGlobal.apply_subrelation else TypeGlobal.do_subrelation, TypeGlobal.apply_subrelation in let _, dosub = app_poly_sort b env evars dosub [||] in let _, appsub = app_poly_nocheck env evars appsub [||] in let dosub_id = Id.of_string "do_subrelation" in let env' = EConstr.push_named (LocalDef (make_annot dosub_id Sorts.Relevant, dosub, appsub)) env in let evars, morph = new_cstr_evar evars env' app in (* Replace the free [dosub_id] in the evar by the global reference *) let morph = Vars.replace_vars (fst evars) [dosub_id , dosub] morph in evars, morph, sigargs, appm, morphobjs, morphobjs' in let projargs, subst, evars, respars, typeargs = Array.fold_left2 (fun (acc, subst, evars, sigargs, typeargs') x y -> let (carrier, relation), sigargs = split_head sigargs in match relation with | Some relation -> let carrier = substl subst carrier and relation = substl subst relation in (match y with | None -> let evars, proof = (if b then PropGlobal.proper_proof else TypeGlobal.proper_proof) env evars carrier relation x in [ proof ; x ; x ] @ acc, subst, evars, sigargs, x :: typeargs' | Some r -> let evars, proof = get_rew_prf env evars r in [ snd proof; r.rew_to; x ] @ acc, subst, evars, sigargs, r.rew_to :: typeargs') | None -> if not (Option.is_empty y) then user_err Pp.(str "Cannot rewrite inside dependent arguments of a function"); x :: acc, x :: subst, evars, sigargs, x :: typeargs') ([], [], evars, sigargs, []) args args' in let proof = applist (proj, List.rev projargs) in let newt = applist (m', List.rev typeargs) in match respars with [ a, Some r ] -> evars, proof, substl subst a, substl subst r, newt | _ -> assert(false) let apply_constraint env car rel prf cstr res = match snd cstr with | None -> res | Some r -> resolve_subrelation env car rel (fst cstr) prf r res let coerce env cstr res = let evars, (rel, prf) = get_rew_prf env res.rew_evars res in let res = { res with rew_evars = evars } in apply_constraint env res.rew_car rel prf cstr res let apply_rule unify : occurrences_count pure_strategy = { strategy = fun { state = occs ; env ; term1 = t ; ty1 = ty ; cstr ; evars } -> let unif = if isEvar (goalevars evars) t then None else unify env evars t in match unif with | None -> (occs, Fail) | Some rew -> let b, occs = update_occurrence_counter occs in if not b then (occs, Fail) else if Termops.eq_constr (fst rew.rew_evars) t rew.rew_to then (occs, Identity) else let res = { rew with rew_car = ty } in let res = Success (coerce env cstr res) in (occs, res) } let apply_lemma l2r flags oc by loccs : strategy = { strategy = fun ({ state = () ; env ; term1 = t ; evars = (sigma, cstrs) } as input) -> let sigma, c = oc sigma in let sigma, hypinfo = decompose_applied_relation env sigma c in let { c1; c2; car; rel; prf; sort; holes } = hypinfo in let rew = (car, rel, prf, c1, c2, holes, sort) in let evars = (sigma, cstrs) in let unify env evars t = let rew = unify_eqn rew l2r flags env evars by t in match rew with | None -> None | Some rew -> Some rew in let loccs, res = (apply_rule unify).strategy { input with state = initialize_occurrence_counter loccs ; evars } in check_used_occurrences loccs; (), res } let e_app_poly env evars f args = let evars', c = app_poly_nocheck env !evars f args in evars := evars'; c let make_leibniz_proof env c ty r = let evars = ref r.rew_evars in let prf = match r.rew_prf with | RewPrf (rel, prf) -> let rel = e_app_poly env evars coq_eq [| ty |] in let prf = e_app_poly env evars coq_f_equal [| r.rew_car; ty; mkLambda (make_annot Anonymous Sorts.Relevant, r.rew_car, c); r.rew_from; r.rew_to; prf |] in RewPrf (rel, prf) | RewCast k -> r.rew_prf in { rew_car = ty; rew_evars = !evars; rew_from = subst1 r.rew_from c; rew_to = subst1 r.rew_to c; rew_prf = prf } let fold_match ?(force=false) env sigma c = let case = destCase sigma c in let (ci, p, iv, c, brs) = EConstr.expand_case env sigma case in let cty = Retyping.get_type_of env sigma c in let dep, pred, sk = let env', ctx, body = let ctx, pred = decompose_lam_assum sigma p in let env' = push_rel_context ctx env in env', ctx, pred in let sortp = Retyping.get_sort_family_of env' sigma body in let sortc = Retyping.get_sort_family_of env sigma cty in let dep = not (noccurn sigma 1 body) in let pred = if dep then p else it_mkProd_or_LetIn (subst1 mkProp body) (List.tl ctx) in let sk = if sortp == Sorts.InProp then if sortc == Sorts.InProp then if dep then case_dep_scheme_kind_from_prop else case_scheme_kind_from_prop else ( if dep then case_dep_scheme_kind_from_type_in_prop else case_scheme_kind_from_type) else ((* sortc <> InProp by typing *) if dep then case_dep_scheme_kind_from_type else case_scheme_kind_from_type) in match Ind_tables.lookup_scheme sk ci.ci_ind with | Some cst -> dep, pred, cst | None -> raise Not_found in let app = let ind, args = Inductiveops.find_mrectype env sigma cty in let pars, args = List.chop ci.ci_npar args in let meths = Array.to_list brs in applist (mkConst sk, pars @ [pred] @ meths @ args @ [c]) in sk, env, app let unfold_match env sigma sk app = match EConstr.kind sigma app with | App (f', args) when QConstant.equal env (fst (destConst sigma f')) sk -> let v = Environ.constant_value_in env (sk,Univ.Instance.empty)(*FIXME*) in let v = EConstr.of_constr v in Reductionops.whd_beta env sigma (mkApp (v, args)) | _ -> app let is_rew_cast = function RewCast _ -> true | _ -> false let subterm all flags (s : 'a pure_strategy) : 'a pure_strategy = let rec aux { state ; env ; unfresh ; term1 = t ; ty1 = ty ; cstr = (prop, cstr) ; evars } = let cstr' = Option.map (fun c -> (ty, Some c)) cstr in match EConstr.kind (goalevars evars) t with | App (m, args) -> let rewrite_args state success = let state, (args', evars', progress) = Array.fold_left (fun (state, (acc, evars, progress)) arg -> if not (Option.is_empty progress) && not all then state, (None :: acc, evars, progress) else let evars, argty = get_type_of_refresh env evars arg in let state, res = s.strategy { state ; env ; unfresh ; term1 = arg ; ty1 = argty ; cstr = (prop,None) ; evars } in let res' = match res with | Identity -> let progress = if Option.is_empty progress then Some false else progress in (None :: acc, evars, progress) | Success r -> (Some r :: acc, r.rew_evars, Some true) | Fail -> (None :: acc, evars, progress) in state, res') (state, ([], evars, success)) args in let res = match progress with | None -> Fail | Some false -> Identity | Some true -> let args' = Array.of_list (List.rev args') in if Array.exists (function | None -> false | Some r -> not (is_rew_cast r.rew_prf)) args' then let evars', prf, car, rel, c2 = resolve_morphism env m args args' (prop, cstr') evars' in let res = { rew_car = ty; rew_from = t; rew_to = c2; rew_prf = RewPrf (rel, prf); rew_evars = evars' } in Success res else let args' = Array.map2 (fun aorig anew -> match anew with None -> aorig | Some r -> r.rew_to) args args' in let res = { rew_car = ty; rew_from = t; rew_to = mkApp (m, args'); rew_prf = RewCast DEFAULTcast; rew_evars = evars' } in Success res in state, res in if flags.on_morphisms then let evars, mty = get_type_of_refresh env evars m in let evars, cstr', m, mty, argsl, args = let argsl = Array.to_list args in let lift = if prop then PropGlobal.lift_cstr else TypeGlobal.lift_cstr in match lift env evars argsl m mty None with | Some (evars, cstr', m, mty, args) -> evars, Some cstr', m, mty, args, Array.of_list args | None -> evars, None, m, mty, argsl, args in let state, m' = s.strategy { state ; env ; unfresh ; term1 = m ; ty1 = mty ; cstr = (prop, cstr') ; evars } in match m' with | Fail -> rewrite_args state None (* Standard path, try rewrite on arguments *) | Identity -> rewrite_args state (Some false) | Success r -> (* We rewrote the function and get a proof of pointwise rel for the arguments. We just apply it. *) let prf = match r.rew_prf with | RewPrf (rel, prf) -> let app = if prop then PropGlobal.apply_pointwise else TypeGlobal.apply_pointwise in RewPrf (app (goalevars evars) rel argsl, mkApp (prf, args)) | x -> x in let res = { rew_car = Reductionops.hnf_prod_appvect env (goalevars evars) r.rew_car args; rew_from = mkApp(r.rew_from, args); rew_to = mkApp(r.rew_to, args); rew_prf = prf; rew_evars = r.rew_evars } in let res = match prf with | RewPrf (rel, prf) -> Success (apply_constraint env res.rew_car rel prf (prop,cstr) res) | _ -> Success res in state, res else rewrite_args state None | Prod (n, x, b) when noccurn (goalevars evars) 1 b -> let b = subst1 mkProp b in let evars, tx = get_type_of_refresh env evars x in let evars, tb = get_type_of_refresh env evars b in let arr = if prop then PropGlobal.arrow_morphism else TypeGlobal.arrow_morphism in let (evars', mor), unfold = arr env evars n.binder_name tx tb x b in let state, res = aux { state ; env ; unfresh ; term1 = mor ; ty1 = ty ; cstr = (prop,cstr) ; evars = evars' } in let res = match res with | Success r -> Success { r with rew_to = unfold (goalevars r.rew_evars) r.rew_to } | Fail | Identity -> res in state, res | Prod (n, dom, codom) -> let lam = mkLambda (n, dom, codom) in let (evars', app), unfold = if eq_constr (fst evars) ty mkProp then (app_poly_sort prop env evars coq_all [| dom; lam |]), TypeGlobal.unfold_all else let forall = if prop then PropGlobal.coq_forall else TypeGlobal.coq_forall in (app_poly_sort prop env evars forall [| dom; lam |]), TypeGlobal.unfold_forall in let state, res = aux { state ; env ; unfresh ; term1 = app ; ty1 = ty ; cstr = (prop,cstr) ; evars = evars' } in let res = match res with | Success r -> Success { r with rew_to = unfold (goalevars r.rew_evars) r.rew_to } | Fail | Identity -> res in state, res (* TODO: real rewriting under binders: introduce x x' (H : R x x') and rewrite with H at any occurrence of x. Ask for (R ==> R') for the lambda. Formalize this. B. Barras' idea is to have a context of relations, of length 1, with Σ for gluing dependent relations and using projections to get them out. *) | Lambda (n, t, b) when flags.under_lambdas -> let unfresh, n' = let id = match n.binder_name with | Anonymous -> Namegen.default_dependent_ident | Name id -> id in let id = Tactics.fresh_id_in_env unfresh id env in Id.Set.add id unfresh, {n with binder_name = Name id} in let unfresh = match n'.binder_name with | Anonymous -> unfresh | Name id -> Id.Set.add id unfresh in let open Context.Rel.Declaration in let env' = EConstr.push_rel (LocalAssum (n', t)) env in let bty = Retyping.get_type_of env' (goalevars evars) b in let unlift = if prop then PropGlobal.unlift_cstr else TypeGlobal.unlift_cstr in let state, b' = s.strategy { state ; env = env' ; unfresh ; term1 = b ; ty1 = bty ; cstr = (prop, unlift env evars cstr) ; evars } in let res = match b' with | Success r -> let r = match r.rew_prf with | RewPrf (rel, prf) -> let point = if prop then PropGlobal.pointwise_or_dep_relation else TypeGlobal.pointwise_or_dep_relation in let evars, rel = point env r.rew_evars n'.binder_name t r.rew_car rel in let prf = mkLambda (n', t, prf) in { r with rew_prf = RewPrf (rel, prf); rew_evars = evars } | x -> r in Success { r with rew_car = mkProd (n, t, r.rew_car); rew_from = mkLambda(n, t, r.rew_from); rew_to = mkLambda (n, t, r.rew_to) } | Fail | Identity -> b' in state, res | Case (ci, u, pms, p, iv, c, brs) -> let (ci, p, iv, c, brs) = EConstr.expand_case env (goalevars evars) (ci, u, pms, p, iv, c, brs) in let cty = Retyping.get_type_of env (goalevars evars) c in let evars', eqty = app_poly_sort prop env evars coq_eq [| cty |] in let cstr' = Some eqty in let state, c' = s.strategy { state ; env ; unfresh ; term1 = c ; ty1 = cty ; cstr = (prop, cstr') ; evars = evars' } in let state, res = match c' with | Success r -> let case = mkCase (EConstr.contract_case env (goalevars evars) (ci, lift 1 p, map_invert (lift 1) iv, mkRel 1, Array.map (lift 1) brs)) in let res = make_leibniz_proof env case ty r in state, Success (coerce env (prop,cstr) res) | Fail | Identity -> if Array.for_all (Int.equal 0) ci.ci_cstr_ndecls then let evars', eqty = app_poly_sort prop env evars coq_eq [| ty |] in let cstr = Some eqty in let state, found, brs' = Array.fold_left (fun (state, found, acc) br -> if not (Option.is_empty found) then (state, found, fun x -> lift 1 br :: acc x) else let state, res = s.strategy { state ; env ; unfresh ; term1 = br ; ty1 = ty ; cstr = (prop,cstr) ; evars } in match res with | Success r -> (state, Some r, fun x -> mkRel 1 :: acc x) | Fail | Identity -> (state, None, fun x -> lift 1 br :: acc x)) (state, None, fun x -> []) brs in match found with | Some r -> let ctxc = mkCase (EConstr.contract_case env (goalevars evars) (ci, lift 1 p, map_invert (lift 1) iv, lift 1 c, Array.of_list (List.rev (brs' c')))) in state, Success (make_leibniz_proof env ctxc ty r) | None -> state, c' else match try Some (fold_match env (goalevars evars) t) with Not_found -> None with | None -> state, c' | Some (cst, _, t') -> let state, res = aux { state ; env ; unfresh ; term1 = t' ; ty1 = ty ; cstr = (prop,cstr) ; evars } in let res = match res with | Success prf -> Success { prf with rew_from = t; rew_to = unfold_match env (goalevars evars) cst prf.rew_to } | x' -> c' in state, res in let res = match res with | Success r -> Success (coerce env (prop,cstr) r) | Fail | Identity -> res in state, res | _ -> state, Fail in { strategy = aux } let all_subterms = subterm true default_flags let one_subterm = subterm false default_flags (** Requires transitivity of the rewrite step, if not a reduction. Not tail-recursive. *) let transitivity state env unfresh cstr (res : rewrite_result_info) (next : 'a pure_strategy) : 'a * rewrite_result = let cstr = match cstr with | _, Some _ -> cstr | prop, None -> prop, get_opt_rew_rel res.rew_prf in let state, nextres = next.strategy { state; env; unfresh; cstr; term1 = res.rew_to; ty1 = res.rew_car; evars = res.rew_evars; } in let res = match nextres with | Fail -> Fail | Identity -> Success res | Success res' -> match res.rew_prf with | RewCast c -> Success { res' with rew_from = res.rew_from } | RewPrf (rew_rel, rew_prf) -> match res'.rew_prf with | RewCast _ -> Success { res with rew_to = res'.rew_to } | RewPrf (res'_rel, res'_prf) -> let trans = if fst cstr then PropGlobal.transitive_type else TypeGlobal.transitive_type in let evars, prfty = app_poly_sort (fst cstr) env res'.rew_evars trans [| res.rew_car; rew_rel |] in let evars, prf = new_cstr_evar evars env prfty in let prf = mkApp (prf, [|res.rew_from; res'.rew_from; res'.rew_to; rew_prf; res'_prf |]) in Success { res' with rew_from = res.rew_from; rew_evars = evars; rew_prf = RewPrf (res'_rel, prf) } in state, res (** Rewriting strategies. Inspired by ELAN's rewriting strategies: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.21.4049 *) module Strategies = struct let fail : 'a pure_strategy = { strategy = fun { state } -> state, Fail } let id : 'a pure_strategy = { strategy = fun { state } -> state, Identity } let refl : 'a pure_strategy = { strategy = fun { state ; env ; term1 = t ; ty1 = ty ; cstr = (prop,cstr) ; evars } -> let evars, rel = match cstr with | None -> let mkr = if prop then PropGlobal.mk_relation else TypeGlobal.mk_relation in let evars, rty = mkr env evars ty in new_cstr_evar evars env rty | Some r -> evars, r in let evars, proof = let proxy = if prop then PropGlobal.proper_proxy_type else TypeGlobal.proper_proxy_type in let evars, mty = app_poly_sort prop env evars proxy [| ty ; rel; t |] in new_cstr_evar evars env mty in let res = Success { rew_car = ty; rew_from = t; rew_to = t; rew_prf = RewPrf (rel, proof); rew_evars = evars } in state, res } let progress (s : 'a pure_strategy) : 'a pure_strategy = { strategy = fun input -> let state, res = s.strategy input in match res with | Fail -> state, Fail | Identity -> state, Fail | Success r -> state, Success r } let seq first snd : 'a pure_strategy = { strategy = fun ({ env ; unfresh ; cstr } as input) -> let state, res = first.strategy input in match res with | Fail -> state, Fail | Identity -> snd.strategy { input with state } | Success res -> transitivity state env unfresh cstr res snd } let choice fst snd : 'a pure_strategy = { strategy = fun input -> let state, res = fst.strategy input in match res with | Fail -> snd.strategy { input with state } | Identity | Success _ -> state, res } let try_ str : 'a pure_strategy = choice str id let check_interrupt str input = Control.check_for_interrupt (); str input let fix (f : 'a pure_strategy -> 'a pure_strategy) : 'a pure_strategy = let rec aux input = (f { strategy = fun input -> check_interrupt aux input }).strategy input in { strategy = aux } let any (s : 'a pure_strategy) : 'a pure_strategy = fix (fun any -> try_ (seq s any)) let repeat (s : 'a pure_strategy) : 'a pure_strategy = seq s (any s) let bu (s : 'a pure_strategy) : 'a pure_strategy = fix (fun s' -> seq (choice (progress (all_subterms s')) s) (try_ s')) let td (s : 'a pure_strategy) : 'a pure_strategy = fix (fun s' -> seq (choice s (progress (all_subterms s'))) (try_ s')) let innermost (s : 'a pure_strategy) : 'a pure_strategy = fix (fun ins -> choice (one_subterm ins) s) let outermost (s : 'a pure_strategy) : 'a pure_strategy = fix (fun out -> choice s (one_subterm out)) let lemmas cs : 'a pure_strategy = List.fold_left (fun tac (l,l2r,by) -> choice tac (apply_lemma l2r rewrite_unif_flags l by AllOccurrences)) fail cs let inj_open hint = (); fun sigma -> let (ctx, lemma) = Autorewrite.RewRule.rew_lemma hint in (* not sure sideff:true is really needed here *) let sigma = Evd.merge_context_set ~sideff:true UnivRigid sigma ctx in (sigma, (EConstr.of_constr lemma, NoBindings)) let old_hints (db : string) : 'a pure_strategy = let rules = Autorewrite.find_rewrites db in lemmas (List.map (fun hint -> (inj_open hint, Autorewrite.RewRule.rew_l2r hint, Autorewrite.RewRule.rew_tac hint)) rules) let hints (db : string) : 'a pure_strategy = { strategy = fun ({ term1 = t } as input) -> let t = EConstr.Unsafe.to_constr t in let rules = Autorewrite.find_matches db t in let lemma hint = (inj_open hint, Autorewrite.RewRule.rew_l2r hint, Autorewrite.RewRule.rew_tac hint) in let lems = List.map lemma rules in (lemmas lems).strategy input } let reduce (r : Redexpr.red_expr) : 'a pure_strategy = { strategy = fun { state = state ; env = env ; term1 = t ; ty1 = ty ; cstr = cstr ; evars = evars } -> let rfn, ckind = Redexpr.reduction_of_red_expr env r in let sigma = goalevars evars in let (sigma, t') = rfn env sigma t in if Termops.eq_constr sigma t' t then state, Identity else state, Success { rew_car = ty; rew_from = t; rew_to = t'; rew_prf = RewCast ckind; rew_evars = sigma, cstrevars evars } } let fold_glob c : 'a pure_strategy = { strategy = fun { state ; env ; term1 = t ; ty1 = ty ; cstr ; evars } -> (* let sigma, (c,_) = Tacinterp.interp_open_constr_with_bindings is env (goalevars evars) c in *) let sigma, c = Pretyping.understand_tcc env (goalevars evars) c in let unfolded = try Tacred.try_red_product env sigma c with e when CErrors.noncritical e -> user_err Pp.(str "fold: the term is not unfoldable!") in try let sigma = Unification.w_unify env sigma CONV ~flags:(Unification.elim_flags ()) unfolded t in let c' = Reductionops.nf_evar sigma c in state, Success { rew_car = ty; rew_from = t; rew_to = c'; rew_prf = RewCast DEFAULTcast; rew_evars = (sigma, snd evars) } with e when CErrors.noncritical e -> state, Fail } end (** The strategy for a single rewrite, dealing with occurrences. *) (** A dummy initial clauseenv to avoid generating initial evars before even finding a first application of the rewriting lemma, in setoid_rewrite mode *) let rewrite_with l2r flags c occs : strategy = { strategy = fun ({ state = () } as input) -> let unify env evars t = let (sigma, cstrs) = evars in let (sigma, rew) = refresh_hypinfo env sigma c in unify_eqn rew l2r flags env (sigma, cstrs) None t in let app = apply_rule unify in let strat = Strategies.fix (fun aux -> Strategies.choice (Strategies.progress app) (subterm true default_flags aux)) in let occs, res = strat.strategy { input with state = initialize_occurrence_counter occs } in check_used_occurrences occs; ((), res) } let apply_strategy (s : strategy) env unfresh concl (prop, cstr) evars = let evars, ty = get_type_of_refresh env evars concl in let _, res = s.strategy { state = () ; env ; unfresh ; term1 = concl ; ty1 = ty ; cstr = (prop, Some cstr) ; evars } in res let solve_constraints env (evars,cstrs) = let oldtcs = Evd.get_typeclass_evars evars in let evars' = Evd.set_typeclass_evars evars cstrs in let evars' = TC.resolve_typeclasses env ~filter:TC.all_evars ~split:false ~fail:true evars' in Evd.set_typeclass_evars evars' oldtcs let nf_zeta = Reductionops.clos_norm_flags (CClosure.RedFlags.mkflags [CClosure.RedFlags.fZETA]) exception RewriteFailure of Environ.env * Evd.evar_map * pretype_error type result = (evar_map * constr option * types) option option exception UnsolvedConstraints of Environ.env * Evd.evar_map * Evar.t let () = CErrors.register_handler begin function | UnsolvedConstraints (env, evars, ev) -> Some (str "Unsolved constraint remaining: " ++ spc () ++ Termops.pr_evar_info env evars (Evd.find evars ev) ++ str ".") | _ -> None end let cl_rewrite_clause_aux ?(abs=None) strat env avoid sigma concl is_hyp : result = let sigma, sort = Typing.sort_of env sigma concl in let evdref = ref sigma in let evars = (!evdref, Evar.Set.empty) in let evars, cstr = let prop, (evars, arrow) = if Sorts.is_prop sort then true, app_poly_sort true env evars impl [||] else false, app_poly_sort false env evars TypeGlobal.arrow [||] in match is_hyp with | None -> let evars, t = poly_inverse prop env evars (mkSort sort) arrow in evars, (prop, t) | Some _ -> evars, (prop, arrow) in let eq = apply_strategy strat env avoid concl cstr evars in match eq with | Fail -> None | Identity -> Some None | Success res -> let (_, cstrs) = res.rew_evars in let evars = solve_constraints env res.rew_evars in let iter ev = if not (Evd.is_defined evars ev) then raise (UnsolvedConstraints (env, evars, ev)) in let () = Evar.Set.iter iter cstrs in let newt = res.rew_to in let res = match res.rew_prf with | RewCast c -> None | RewPrf (rel, p) -> let p = nf_zeta env evars p in let term = match abs with | None -> p | Some (t, ty) -> mkApp (mkLambda (make_annot (Name (Id.of_string "lemma")) Sorts.Relevant, ty, p), [| t |]) in let proof = match is_hyp with | None -> term | Some id -> mkApp (term, [| mkVar id |]) in Some proof in Some (Some (evars, res, newt)) (** Insert a declaration after the last declaration it depends on *) let rec insert_dependent env sigma decl accu hyps = match hyps with | [] -> List.rev_append accu [decl] | ndecl :: rem -> if occur_var_in_decl env sigma (NamedDecl.get_id ndecl) decl then List.rev_append accu (decl :: hyps) else insert_dependent env sigma decl (ndecl :: accu) rem let assert_replacing id newt tac = let prf = Proofview.Goal.enter begin fun gl -> let concl = Proofview.Goal.concl gl in let env = Proofview.Goal.env gl in let sigma = Tacmach.project gl in let ctx = named_context env in let after, before = List.split_when (NamedDecl.get_id %> Id.equal id) ctx in let nc = match before with | [] -> assert false | d :: rem -> insert_dependent env sigma (LocalAssum (make_annot (NamedDecl.get_id d) Sorts.Relevant, newt)) [] after @ rem in let env' = Environ.reset_with_named_context (val_of_named_context nc) env in Refine.refine ~typecheck:true begin fun sigma -> let (sigma, ev) = Evarutil.new_evar env' sigma concl in let (sigma, ev') = Evarutil.new_evar env sigma newt in let map d = let n = NamedDecl.get_id d in if Id.equal n id then ev' else mkVar n in let (e, _) = destEvar sigma ev in (sigma, mkLEvar sigma (e, List.map map nc)) end end in Proofview.tclTHEN prf (Proofview.tclFOCUS 2 2 tac) let newfail n s = let info = Exninfo.reify () in Proofview.tclZERO ~info (Tacticals.FailError (n, lazy s)) let cl_rewrite_clause_newtac ?abs ?origsigma ~progress strat clause = let open Proofview.Notations in (* For compatibility *) let beta = Tactics.reduct_in_concl ~cast:false ~check:false (Reductionops.nf_betaiota, DEFAULTcast) in let beta_hyp id = Tactics.reduct_in_hyp ~check:false ~reorder:false Reductionops.nf_betaiota (id, InHyp) in let treat sigma res state = match res with | None -> newfail 0 (str "Nothing to rewrite") | Some None -> if progress then newfail 0 (str"Failed to progress") else Proofview.tclUNIT () | Some (Some res) -> let (undef, prf, newt) = res in let fold ev _ accu = if Evd.mem sigma ev then accu else ev :: accu in let gls = List.rev (Evd.fold_undefined fold undef []) in let gls = List.map (fun gl -> Proofview.goal_with_state gl state) gls in match clause, prf with | Some id, Some p -> let tac = tclTHENLIST [ Refine.refine ~typecheck:true (fun h -> (h,p)); Proofview.Unsafe.tclNEWGOALS gls; ] in Proofview.Unsafe.tclEVARS undef <*> tclTHENFIRST (assert_replacing id newt tac) (beta_hyp id) | Some id, None -> Proofview.Unsafe.tclEVARS undef <*> convert_hyp ~check:false ~reorder:false (LocalAssum (make_annot id Sorts.Relevant, newt)) <*> beta_hyp id | None, Some p -> Proofview.Unsafe.tclEVARS undef <*> Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let make = begin fun sigma -> let (sigma, ev) = Evarutil.new_evar env sigma newt in (sigma, mkApp (p, [| ev |])) end in Refine.refine ~typecheck:true make <*> Proofview.Unsafe.tclNEWGOALS gls end | None, None -> Proofview.Unsafe.tclEVARS undef <*> convert_concl ~cast:false ~check:false newt DEFAULTcast in Proofview.Goal.enter begin fun gl -> let concl = Proofview.Goal.concl gl in let env = Proofview.Goal.env gl in let state = Proofview.Goal.state gl in let sigma = Tacmach.project gl in let ty = match clause with | None -> concl | Some id -> EConstr.of_constr (Environ.named_type id env) in let env = match clause with | None -> env | Some id -> (* Only consider variables not depending on [id] *) let ctx = named_context env in let filter decl = not (occur_var_in_decl env sigma id decl) in let nctx = List.filter filter ctx in Environ.reset_with_named_context (val_of_named_context nctx) env in try let res = cl_rewrite_clause_aux ?abs strat env Id.Set.empty sigma ty clause in let sigma = match origsigma with None -> sigma | Some sigma -> sigma in treat sigma res state <*> (* For compatibility *) beta <*> Proofview.shelve_unifiable with | PretypeError (env, evd, (UnsatisfiableConstraints _ as e)) -> raise (RewriteFailure (env, evd, e)) end let tactic_init_setoid () = try init_setoid (); Proofview.tclUNIT () with e when CErrors.noncritical e -> let _, info = Exninfo.capture e in Tacticals.tclFAIL ~info (str"Setoid library not loaded") let cl_rewrite_clause_strat progress strat clause = tactic_init_setoid () <*> (if progress then Proofview.tclPROGRESS else fun x -> x) (Proofview.tclOR (cl_rewrite_clause_newtac ~progress strat clause) (fun (e, info) -> match e with | Tacticals.FailError (n, pp) -> tclFAILn ~info n (str"setoid rewrite failed: " ++ Lazy.force pp) | e -> Proofview.tclZERO ~info e)) (** Setoid rewriting when called with "setoid_rewrite" *) let cl_rewrite_clause l left2right occs clause = let strat = rewrite_with left2right (general_rewrite_unif_flags ()) l occs in cl_rewrite_clause_strat true strat clause (** Setoid rewriting when called with "rewrite_strat" *) let cl_rewrite_clause_strat strat clause = cl_rewrite_clause_strat false strat clause let apply_glob_constr ((_, c) : _ * EConstr.t delayed_open) l2r occs = (); fun ({ state = () ; env = env } as input) -> let c sigma = let (sigma, c) = c env sigma in (sigma, (c, NoBindings)) in let flags = general_rewrite_unif_flags () in (apply_lemma l2r flags c None occs).strategy input let interp_glob_constr_list env = let make c = (); fun sigma -> let sigma, c = Pretyping.understand_tcc env sigma c in (sigma, (c, NoBindings)) in List.map (fun c -> make c, true, None) (* Syntax for rewriting with strategies *) type unary_strategy = Subterms | Subterm | Innermost | Outermost | Bottomup | Topdown | Progress | Try | Any | Repeat type binary_strategy = | Compose type nary_strategy = Choice type ('constr,'redexpr) strategy_ast = | StratId | StratFail | StratRefl | StratUnary of unary_strategy * ('constr,'redexpr) strategy_ast | StratBinary of binary_strategy * ('constr,'redexpr) strategy_ast * ('constr,'redexpr) strategy_ast | StratNAry of nary_strategy * ('constr,'redexpr) strategy_ast list | StratConstr of 'constr * bool | StratTerms of 'constr list | StratHints of bool * string | StratEval of 'redexpr | StratFold of 'constr let rec map_strategy (f : 'a -> 'a2) (g : 'b -> 'b2) : ('a,'b) strategy_ast -> ('a2,'b2) strategy_ast = function | StratId | StratFail | StratRefl as s -> s | StratUnary (s, str) -> StratUnary (s, map_strategy f g str) | StratBinary (s, str, str') -> StratBinary (s, map_strategy f g str, map_strategy f g str') | StratNAry (s, strs) -> StratNAry (s, List.map (map_strategy f g) strs) | StratConstr (c, b) -> StratConstr (f c, b) | StratTerms l -> StratTerms (List.map f l) | StratHints (b, id) -> StratHints (b, id) | StratEval r -> StratEval (g r) | StratFold c -> StratFold (f c) let pr_ustrategy = function | Subterms -> str "subterms" | Subterm -> str "subterm" | Innermost -> str "innermost" | Outermost -> str "outermost" | Bottomup -> str "bottomup" | Topdown -> str "topdown" | Progress -> str "progress" | Try -> str "try" | Any -> str "any" | Repeat -> str "repeat" let paren p = str "(" ++ p ++ str ")" let rec pr_strategy prc prr = function | StratId -> str "id" | StratFail -> str "fail" | StratRefl -> str "refl" | StratUnary (s, str) -> pr_ustrategy s ++ spc () ++ paren (pr_strategy prc prr str) | StratNAry (Choice, strs) -> str "choice" ++ spc () ++ prlist_with_sep spc (fun str -> paren (pr_strategy prc prr str)) strs | StratBinary (Compose, str1, str2) -> pr_strategy prc prr str1 ++ str ";" ++ spc () ++ pr_strategy prc prr str2 | StratConstr (c, true) -> prc c | StratConstr (c, false) -> str "<-" ++ spc () ++ prc c | StratTerms cl -> str "terms" ++ spc () ++ pr_sequence prc cl | StratHints (old, id) -> let cmd = if old then "old_hints" else "hints" in str cmd ++ spc () ++ str id | StratEval r -> str "eval" ++ spc () ++ prr r | StratFold c -> str "fold" ++ spc () ++ prc c let rec strategy_of_ast = function | StratId -> Strategies.id | StratFail -> Strategies.fail | StratRefl -> Strategies.refl | StratUnary (f, s) -> let s' = strategy_of_ast s in let f' = match f with | Subterms -> all_subterms | Subterm -> one_subterm | Innermost -> Strategies.innermost | Outermost -> Strategies.outermost | Bottomup -> Strategies.bu | Topdown -> Strategies.td | Progress -> Strategies.progress | Try -> Strategies.try_ | Any -> Strategies.any | Repeat -> Strategies.repeat in f' s' | StratBinary (f, s, t) -> let s' = strategy_of_ast s in let t' = strategy_of_ast t in let f' = match f with | Compose -> Strategies.seq in f' s' t' | StratNAry (Choice, strs) -> let strs = List.map (strategy_of_ast) strs in begin match strs with | [] -> assert false | s::strs -> List.fold_left Strategies.choice s strs end | StratConstr (c, b) -> { strategy = apply_glob_constr c b AllOccurrences } | StratHints (old, id) -> if old then Strategies.old_hints id else Strategies.hints id | StratTerms l -> { strategy = (fun ({ state = () ; env } as input) -> let l' = interp_glob_constr_list env (List.map fst l) in (Strategies.lemmas l').strategy input) } | StratEval r -> { strategy = (fun ({ state = () ; env ; evars } as input) -> let (sigma, r_interp) = r env (goalevars evars) in (Strategies.reduce r_interp).strategy { input with evars = (sigma,cstrevars evars) }) } | StratFold c -> Strategies.fold_glob (fst c) let proper_projection env sigma r ty = let rel_vect n m = Array.init m (fun i -> mkRel(n+m-i)) in let ctx, inst = decompose_prod_assum sigma ty in let mor, args = destApp sigma inst in let instarg = mkApp (r, rel_vect 0 (List.length ctx)) in let app = mkApp (PropGlobal.proper_proj env sigma, Array.append args [| instarg |]) in it_mkLambda_or_LetIn app ctx let build_morphism_signature env sigma m = let m,ctx = Constrintern.interp_constr env sigma m in let sigma = Evd.from_ctx ctx in let t = Retyping.get_type_of env sigma m in let cstrs = let rec aux t = match EConstr.kind sigma t with | Prod (na, a, b) -> None :: aux b | _ -> [] in aux t in let evars, t', sig_, cstrs = PropGlobal.build_signature (sigma, Evar.Set.empty) env t cstrs None in let evd = ref evars in let _ = List.iter (fun (ty, rel) -> Option.iter (fun rel -> let default = e_app_poly env evd PropGlobal.default_relation [| ty; rel |] in let evd', t = new_cstr_evar !evd env default in evd := evd') rel) cstrs in let morph = e_app_poly env evd PropGlobal.proper_type [| t; sig_; m |] in let evd = solve_constraints env !evd in evd, morph let default_morphism env sigma sign m = let t = Retyping.get_type_of env sigma m in let evars, _, sign, cstrs = PropGlobal.build_signature (sigma, Evar.Set.empty) env t (fst sign) (snd sign) in let evars, morph = app_poly_check env evars PropGlobal.proper_type [| t; sign; m |] in let evars, mor = TC.resolve_one_typeclass env (goalevars evars) morph in mor, proper_projection env sigma mor morph (** Bind to "rewrite" too *) (* Find a subterm which matches the pattern to rewrite for "rewrite" *) let unification_rewrite l2r c1 c2 sigma prf car rel but env = let (sigma,c') = try (* ~flags:(false,true) to allow to mark occurrences that must not be rewritten simply by replacing them with let-defined definitions in the context *) Unification.w_unify_to_subterm ~flags:rewrite_unif_flags env sigma ((if l2r then c1 else c2),but) with | ex when Pretype_errors.precatchable_exception ex -> (* ~flags:(true,true) to make Ring work (since it really exploits conversion) *) Unification.w_unify_to_subterm ~flags:rewrite_conv_unif_flags env sigma ((if l2r then c1 else c2),but) in let nf c = Reductionops.nf_evar sigma c in let c1 = if l2r then nf c' else nf c1 and c2 = if l2r then nf c2 else nf c' and car = nf car and rel = nf rel in let prf = nf prf in let prfty = nf (Retyping.get_type_of env sigma prf) in let sort = sort_of_rel env sigma but in let abs = prf, prfty in let prf = mkRel 1 in let res = (car, rel, prf, c1, c2) in abs, sigma, res, Sorts.is_prop sort let get_hyp gl (c,l) clause l2r = let evars = Tacmach.project gl in let env = Tacmach.pf_env gl in let sigma, hi = decompose_applied_relation env evars (c,l) in let but = match clause with | Some id -> Tacmach.pf_get_hyp_typ id gl | None -> Reductionops.nf_evar evars (Tacmach.pf_concl gl) in unification_rewrite l2r hi.c1 hi.c2 sigma hi.prf hi.car hi.rel but env let general_rewrite_flags = { under_lambdas = false; on_morphisms = true } (** Setoid rewriting when called with "rewrite" *) let general_s_rewrite cl l2r occs (c,l) ~new_goals = Proofview.Goal.enter begin fun gl -> let abs, evd, res, sort = get_hyp gl (c,l) cl l2r in let unify env evars t = unify_abs res l2r sort env evars t in let app = apply_rule unify in let recstrat aux = Strategies.choice app (subterm true general_rewrite_flags aux) in let substrat = Strategies.fix recstrat in let strat = { strategy = fun ({ state = () } as input) -> let occs, res = substrat.strategy { input with state = initialize_occurrence_counter occs } in check_used_occurrences occs; (), res } in let origsigma = Tacmach.project gl in tactic_init_setoid () <*> Proofview.tclOR (tclPROGRESS (tclTHEN (Proofview.Unsafe.tclEVARS evd) (cl_rewrite_clause_newtac ~progress:true ~abs:(Some abs) ~origsigma strat cl))) (fun (e, info) -> match e with | e -> Proofview.tclZERO ~info e) end let _ = Hook.set Equality.general_setoid_rewrite_clause general_s_rewrite (** [setoid_]{reflexivity,symmetry,transitivity} tactics *) exception RelationNotDeclared of Environ.env * Evd.evar_map * string * EConstr.types let () = CErrors.register_handler begin function | RelationNotDeclared (env, sigma, ty, concl) -> let rel, _, _, _, _, _ = decompose_app_rel_error env sigma concl in Some (str" The relation " ++ Printer.pr_econstr_env env sigma rel ++ str" is not a declared " ++ str ty ++ str" relation. Maybe you need to require the Coq.Classes.RelationClasses library") | _ -> None end let not_declared ~info env sigma ty concl = Proofview.tclZERO ~info (RelationNotDeclared (env, sigma, ty, concl)) let setoid_proof ty fn fallback = Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Tacmach.project gl in let concl = Proofview.Goal.concl gl in Proofview.tclORELSE begin try let rel, ty1, ty2, concl, _, _ = decompose_app_rel_error env sigma concl in let (sigma, t) = Typing.type_of env sigma rel in let car = snd (List.hd (fst (Reductionops.splay_prod env sigma t))) in (try init_relation_classes () with _ -> raise Not_found); fn env sigma car rel with e when CErrors.noncritical e -> (* XXX what is the right test here as to whether e can be converted ? *) let e, info = Exninfo.capture e in Proofview.tclZERO ~info e end begin function | e -> Proofview.tclORELSE fallback begin function (e', info) -> match e' with | Hipattern.NoEquationFound -> begin match e with | (Not_found, _) -> not_declared ~info env sigma ty concl | (e, info) -> Proofview.tclZERO ~info e end | e' -> Proofview.tclZERO ~info e' end end end let tac_open ((evm,_), c) tac = (tclTHEN (Proofview.Unsafe.tclEVARS evm) (tac c)) let poly_proof getp gett env evm car rel = if Sorts.is_prop (sort_of_rel env evm rel) then getp env (evm,Evar.Set.empty) car rel else gett env (evm,Evar.Set.empty) car rel let setoid_reflexivity = setoid_proof "reflexive" (fun env evm car rel -> tac_open (poly_proof PropGlobal.get_reflexive_proof TypeGlobal.get_reflexive_proof env evm car rel) (fun c -> tclCOMPLETE (apply c))) (reflexivity_red true) let setoid_symmetry = setoid_proof "symmetric" (fun env evm car rel -> tac_open (poly_proof PropGlobal.get_symmetric_proof TypeGlobal.get_symmetric_proof env evm car rel) (fun c -> apply c)) (symmetry_red true) let setoid_transitivity c = setoid_proof "transitive" (fun env evm car rel -> tac_open (poly_proof PropGlobal.get_transitive_proof TypeGlobal.get_transitive_proof env evm car rel) (fun proof -> match c with | None -> eapply proof | Some c -> apply_with_bindings (proof,ImplicitBindings [ c ]))) (transitivity_red true c) let setoid_symmetry_in id = Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Proofview.Goal.sigma gl in let ctype = Retyping.get_type_of env sigma (mkVar id) in let binders,concl = decompose_prod_assum sigma ctype in let (equiv, args) = decompose_app sigma concl in let rec split_last_two = function | [c1;c2] -> [],(c1, c2) | x::y::z -> let l,res = split_last_two (y::z) in x::l, res | _ -> user_err Pp.(str "Cannot find an equivalence relation to rewrite.") in let others,(c1,c2) = split_last_two args in let he,c1,c2 = mkApp (equiv, Array.of_list others),c1,c2 in let new_hyp' = mkApp (he, [| c2 ; c1 |]) in let new_hyp = it_mkProd_or_LetIn new_hyp' binders in (tclTHENLAST (Tactics.assert_after_replacing id new_hyp) (tclTHENLIST [ intros; setoid_symmetry; apply (mkVar id); Tactics.assumption ])) end let _ = Hook.set Tactics.setoid_reflexivity setoid_reflexivity let _ = Hook.set Tactics.setoid_symmetry setoid_symmetry let _ = Hook.set Tactics.setoid_symmetry_in setoid_symmetry_in let _ = Hook.set Tactics.setoid_transitivity setoid_transitivity let get_lemma_proof f env evm x y = let (evm, _), c = f env (evm,Evar.Set.empty) x y in evm, c let get_reflexive_proof = get_lemma_proof PropGlobal.get_reflexive_proof let get_symmetric_proof = get_lemma_proof PropGlobal.get_symmetric_proof let get_transitive_proof = get_lemma_proof PropGlobal.get_transitive_proof module Internal = struct let build_signature env sigma m cstr finalcstr = let evars = (sigma, Evar.Set.empty) in let ((sigma, _), _, sig_, cstr) = PropGlobal.build_signature evars env m cstr finalcstr in sigma, sig_, cstr let build_morphism_signature = build_morphism_signature let default_morphism = default_morphism end
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
depsolver.mli
(** Dependency solver. Implementation of the Edos algorithms *) (** the solver is an abstract data type associated to a universe *) type solver (** initialize the solver. *) val load : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> solver (** check if the universe universe is consistent (all installed packages are coinstallable) This function is a wrapper of Cudf_checker.is_consistent. *) val is_consistent : Cudf.universe -> Diagnostic.diagnosis (** check if the given package can be installed in the universe Packages marked as `Keep_package must be always installed.*) val edos_install : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package -> Diagnostic.diagnosis (** check if the give package list can be installed in the universe *) val edos_coinstall : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list -> Diagnostic.diagnosis (** accept a list of list of packages and return the coinstallability test of the cartesian product. *) val edos_coinstall_prod : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list list -> Diagnostic.diagnosis list (** remove uninstallable packages from the universe . *) val trim : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.universe (** remove uninstallable packages from the pkglist. *) val trimlist : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list -> Cudf.package list (** return the list of broken packages.*) val find_broken : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list (** return the list of installable packages. *) val find_installable : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list (** return the list of broken packages.*) val find_listbroken : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list -> Cudf.package list (** return the list of installable packages. *) val find_listinstallable : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> Cudf.universe -> Cudf.package list -> Cudf.package list (** [univcheck ] check if all packages in the universe can be installed. Since not all packages are directly tested for installation, if a packages is installable, the installation might be empty. To obtain an installation set for each installable packages, the correct procedure is to iter on the list of packages. @param callback : execute a function for each package. This function can have side effects and can be used to collect the installation set or the failure reason. @return the number of broken packages *) val univcheck : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?callback:(Diagnostic.diagnosis -> unit) -> ?explain:bool -> Cudf.universe -> int val univcheck_lowmem : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?callback:(Diagnostic.diagnosis -> unit) -> ?explain:bool -> Cudf.universe -> int (** [listcheck ~callback:c subuniverse l] check if all packages in [l] can be installed. Invariant : l is a subset of universe can be installed in the solver universe. It is responsability of the user to pass listcheck an appropriate subuniverse` @param callback : execute a function for each package. @return the number of broken packages *) val listcheck : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?callback:(Diagnostic.diagnosis -> unit) -> ?explain:bool -> Cudf.universe -> Cudf.package list -> int (** [dependency_closure index l] return the union of the dependency closure of all packages in [l] . @param maxdepth the maximum cone depth (infinite by default) @param conjunctive consider only conjunctive dependencies (false by default) @param universe the package universe @param pkglist a subset of [universe] *) val dependency_closure : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?maxdepth:int -> ?conjunctive:bool -> Cudf.universe -> Cudf.package list -> Cudf.package list (** [reverse_dependencies univ ] compute the reverse dependency list of all packages in the universe [univ] *) val reverse_dependencies : Cudf.universe -> Cudf.package list Dose_common.CudfAdd.Cudf_hashtbl.t (** [reverse_dependencies_closure univ ] compute the reverse dependency list of all packages in [l] in the universe [univ] *) val reverse_dependency_closure : ?maxdepth:int -> Cudf.universe -> Cudf.package list -> Cudf.package list type enc = Cnf | Dimacs (** [output_clauses enc univ] return a string encoded accordingly to [enc] (default cnf). *) val output_clauses : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?enc:enc -> Cudf.universe -> string (** The result of the depclean function is a tuple containing a package, a list of dependencies that are redundant and a list of conflicts that are redundant *) type depclean_result = Cudf.package * (Cudf_types.vpkglist * Cudf_types.vpkg * Cudf.package list) list * (Cudf_types.vpkg * Cudf.package list) list (** For each package [p] in [packagelist], [depclean univ packagelist] detect redundundant dependencies that refer to packages that are either missing or not co-installable together with the root package [p] *) val depclean : ?global_constraints:(Cudf_types.vpkglist * Cudf.package list) list -> ?callback:(depclean_result -> unit) -> Cudf.universe -> Cudf.package list -> depclean_result list type solver_result = | Sat of (Cudf.preamble option * Cudf.universe) | Unsat of Diagnostic.diagnosis option | Error of string (** an empty package used to enforce global contraints on the request *) val dummy_request : Cudf.package val add_dummy : Cudf.universe -> Cudf.request -> Cudf.package -> Cudf.universe * Cudf.package (** [check_request] check if there exists a solution for the give cudf document if ?dummy is specified, adds this dummy package to the user request. This parameter is used to encode a list of 'essential' packages that must always be installed in the solution alongside with the user request. if ?cmd is specified, it will be used to call an external cudf solver to satisfy the request. if ?criteria is specified it will be used as optimization criteria. if ?explain is specified and there is no solution for the give request, the result will contain the failure reason. *) val check_request : ?cmd:string -> ?criteria:string -> ?dummy:Cudf.package -> ?explain:bool -> Cudf.cudf -> solver_result (** Same as [check_request], but allows to specify any function to call the external solver. It should raise [Depsolver.Unsat] on failure. *) val check_request_using : ?call_solver:(Cudf.cudf -> Cudf.preamble option * Cudf.universe) -> ?dummy:Cudf.package -> ?explain:bool -> Cudf.cudf -> solver_result (** Build the installation graph from a cudf solution universe and sets of packages to be installed/removed (see CudfAdd.make_summary) *) val installation_graph : solution:Cudf.universe -> Dose_common.CudfAdd.Cudf_set.t * Dose_common.CudfAdd.Cudf_set.t -> Defaultgraphs.ActionGraph.G.t
(**************************************************************************************) (* Copyright (C) 2009 Pietro Abate <pietro.abate@pps.jussieu.fr> *) (* Copyright (C) 2009 Mancoosi Project *) (* *) (* This library is free software: you can redistribute it and/or modify *) (* it under the terms of the GNU Lesser General Public License as *) (* published by the Free Software Foundation, either version 3 of the *) (* License, or (at your option) any later version. A special linking *) (* exception to the GNU Lesser General Public License applies to this *) (* library, see the COPYING file for more information. *) (**************************************************************************************)
warnings.mli
open Format type t = | Comment_start (* 1 *) | Comment_not_end (* 2 *) | Deprecated of string (* 3 *) | Fragile_match of string (* 4 *) | Partial_application (* 5 *) | Labels_omitted (* 6 *) | Method_override of string list (* 7 *) | Partial_match of string (* 8 *) | Non_closed_record_pattern of string (* 9 *) | Statement_type (* 10 *) | Unused_match (* 11 *) | Unused_pat (* 12 *) | Instance_variable_override of string list (* 13 *) | Illegal_backslash (* 14 *) | Implicit_public_methods of string list (* 15 *) | Unerasable_optional_argument (* 16 *) | Undeclared_virtual_method of string (* 17 *) | Not_principal of string (* 18 *) | Without_principality of string (* 19 *) | Unused_argument (* 20 *) | Nonreturning_statement (* 21 *) | Preprocessor of string (* 22 *) | Useless_record_with (* 23 *) | Bad_module_name of string (* 24 *) | All_clauses_guarded (* 25 *) | Unused_var of string (* 26 *) | Unused_var_strict of string (* 27 *) | Wildcard_arg_to_constant_constr (* 28 *) | Eol_in_string (* 29 *) | Duplicate_definitions of string * string * string * string (* 30 *) | Multiple_definition of string * string * string (* 31 *) | Unused_value_declaration of string (* 32 *) | Unused_open of string (* 33 *) | Unused_type_declaration of string (* 34 *) | Unused_for_index of string (* 35 *) | Unused_ancestor of string (* 36 *) | Unused_constructor of string * bool * bool (* 37 *) | Unused_extension of string * bool * bool (* 38 *) | Unused_rec_flag (* 39 *) | Name_out_of_scope of string * string list * bool (* 40 *) | Ambiguous_name of string list * string list * bool (* 41 *) | Disambiguated_name of string (* 42 *) | Nonoptional_label of string (* 43 *) | Open_shadow_identifier of string * string (* 44 *) | Open_shadow_label_constructor of string * string (* 45 *) | Bad_env_variable of string * string (* 46 *) | Attribute_payload of string * string (* 47 *) | Eliminated_optional_arguments of string list (* 48 *) | No_cmi_file of string (* 49 *) | Bad_docstring of bool (* 50 *) ;; val parse_options : bool -> string -> unit;; val is_active : t -> bool;; val is_error : t -> bool;; val defaults_w : string;; val defaults_warn_error : string;; val print : formatter -> t -> unit;; exception Errors of int;; val check_fatal : unit -> unit;; val help_warnings: unit -> unit type state val backup: unit -> state val restore: state -> unit
(***********************************************************************) (* *) (* OCaml *) (* *) (* Pierre Weis && Damien Doligez, INRIA Rocquencourt *) (* *) (* Copyright 1998 Institut National de Recherche en Informatique et *) (* en Automatique. All rights reserved. This file is distributed *) (* under the terms of the Q Public License version 1.0. *) (* *) (***********************************************************************)
dune
(executable (public_name foo)) (install (section man) (package foo) (files mp))
discover.ml
module C = Configurator.V1 let () = C.main ~name:"vorbis-pkg-config" (fun c -> let default : C.Pkg_config.package_conf = { libs = ["-lvorbis"; "-lvorbisfile"; "-lvorbisenc"]; cflags = [] } in let conf = match C.Pkg_config.get c with | None -> default | Some pc -> ( match C.Pkg_config.query pc ~package:"vorbis vorbisfile vorbisenc" with | None -> default | Some deps -> deps) in C.Flags.write_sexp "c_flags.sexp" conf.cflags; C.Flags.write_sexp "c_library_flags.sexp" conf.libs)
configuration.ml
open! Core_kernel open! Import let default_context = 16 (* The following constants were all chosen empirically. *) (* Default cutoff for line-level semantic cleanup. Any match of [default_line_big_enough] or more will not be deleted, even if it's surrounded by large inserts and deletes. Raising this quantity can only decrease the number of matches, and lowering it can only increase the number of matches. *) let default_line_big_enough = 3 (* Analogous to above, but for word-level refinement *) let default_word_big_enough = 7 (* Governs the behavior of [split_for_readability]. We will only split ranges around matches of size greater than [too_short_to_split]. Note that this should always be at least 1, otherwise we will split on a single `Newline token. Raising this quantity will result in less ranges being split, and setting it to infinity is the same as passing in [~interleave:false]. *) let too_short_to_split = 2 let warn_if_no_trailing_newline_in_both_default = true type t = { output : Output.t ; rules : Format.Rules.t ; ext_cmp : string option ; float_tolerance : Percent.t option ; produce_unified_lines : bool ; unrefined : bool ; keep_ws : bool ; split_long_lines : bool ; interleave : bool ; assume_text : bool ; context : int ; line_big_enough : int ; word_big_enough : int ; shallow : bool ; quiet : bool ; double_check : bool ; mask_uniques : bool ; prev_alt : string option ; next_alt : string option ; location_style : Format.Location_style.t ; warn_if_no_trailing_newline_in_both : bool [@default warn_if_no_trailing_newline_in_both_default] [@sexp_drop_default.equal] } [@@deriving compare, fields, sexp_of] let invariant t = Invariant.invariant [%here] t [%sexp_of: t] (fun () -> let check f field = Invariant.check_field t f field in Fields.iter ~output: (check (fun output -> if Output.implies_unrefined output then [%test_eq: bool] t.unrefined true ~message:"output implies unrefined")) ~rules:ignore ~ext_cmp: (check (fun ext_cmp -> Option.iter ext_cmp ~f:(fun (_ : string) -> [%test_eq: bool] t.unrefined true ~message:"ext_cmp implies unrefined"))) ~float_tolerance: (check (fun float_tolerance -> if Option.is_some float_tolerance then [%test_eq: string option] t.ext_cmp None ~message:"ext_cmp and float_tolerance cannot both be some")) ~produce_unified_lines:ignore ~unrefined:ignore ~keep_ws:ignore ~interleave:ignore ~assume_text:ignore ~split_long_lines: ignore ~context:ignore ~line_big_enough: (check (fun line_big_enough -> [%test_pred: int] Int.is_positive line_big_enough ~message:"line_big_enough must be positive")) ~word_big_enough: (check (fun word_big_enough -> [%test_pred: int] Int.is_positive word_big_enough ~message:"word_big_enough must be positive")) ~shallow:ignore ~quiet:ignore ~double_check:ignore ~mask_uniques:ignore ~prev_alt:ignore ~next_alt:ignore ~location_style:ignore ~warn_if_no_trailing_newline_in_both:ignore) ;; let create_exn ~output ~rules ~float_tolerance ~produce_unified_lines ~unrefined ~keep_ws ~split_long_lines ~interleave ~assume_text ~context ~line_big_enough ~word_big_enough ~shallow ~quiet ~double_check ~mask_uniques ~prev_alt ~next_alt ~location_style ~warn_if_no_trailing_newline_in_both = let t = { output ; rules ; ext_cmp = None ; float_tolerance ; produce_unified_lines ; unrefined ; keep_ws ; split_long_lines ; interleave ; assume_text ; context ; line_big_enough ; word_big_enough ; shallow ; quiet ; double_check ; mask_uniques ; prev_alt ; next_alt ; location_style ; warn_if_no_trailing_newline_in_both } in invariant t; t ;; let override_internal ?output ?rules ?ext_cmp ?float_tolerance ?produce_unified_lines ?unrefined ?keep_ws ?split_long_lines ?interleave ?assume_text ?context ?line_big_enough ?word_big_enough ?shallow ?quiet ?double_check ?mask_uniques ?prev_alt ?next_alt ?location_style ?warn_if_no_trailing_newline_in_both t = let output = Option.value ~default:t.output output in let ext_cmp = Option.value ~default:t.ext_cmp ext_cmp in let unrefined = Option.value ~default:t.unrefined unrefined || is_some ext_cmp || Output.implies_unrefined output in let t = let value value field = Option.value value ~default:(Field.get field t) in Fields.map ~output:(const output) ~rules:(value rules) ~ext_cmp:(const ext_cmp) ~float_tolerance:(value float_tolerance) ~produce_unified_lines:(value produce_unified_lines) ~unrefined:(const unrefined) ~keep_ws:(value keep_ws) ~interleave:(value interleave) ~assume_text:(value assume_text) ~split_long_lines:(value split_long_lines) ~context:(value context) ~line_big_enough:(value line_big_enough) ~word_big_enough:(value word_big_enough) ~shallow:(value shallow) ~quiet:(value quiet) ~double_check:(value double_check) ~mask_uniques:(value mask_uniques) ~prev_alt:(value prev_alt) ~next_alt:(value next_alt) ~location_style:(value location_style) ~warn_if_no_trailing_newline_in_both:(value warn_if_no_trailing_newline_in_both) in invariant t; t ;; let override ?output ?rules ?float_tolerance ?produce_unified_lines ?unrefined ?keep_ws ?split_long_lines ?interleave ?assume_text ?context ?line_big_enough ?word_big_enough ?shallow ?quiet ?double_check ?mask_uniques ?prev_alt ?next_alt ?location_style ?warn_if_no_trailing_newline_in_both t = override_internal ?output ?rules ~ext_cmp:None ?float_tolerance ?produce_unified_lines ?unrefined ?keep_ws ?split_long_lines ?interleave ?assume_text ?context ?line_big_enough ?word_big_enough ?shallow ?quiet ?double_check ?mask_uniques ?prev_alt ?next_alt ?location_style ?warn_if_no_trailing_newline_in_both t ;; let default = { output = Ansi ; rules = { line_same = Format.Rule.create [] ~pre:(Format.Rule.Affix.create " |" ~styles:[ Bg Bright_black; Fg Black ]) ; line_prev = Format.Rule.create [ Fg Red ] ~pre:(Format.Rule.Affix.create "-|" ~styles:[ Bg Red; Fg Black ]) ; line_next = Format.Rule.create [ Fg Green ] ~pre:(Format.Rule.Affix.create "+|" ~styles:[ Bg Green; Fg Black ]) ; line_unified = Format.Rule.create [] ~pre:(Format.Rule.Affix.create "!|" ~styles:[ Bg Yellow; Fg Black ]) ; word_same_prev = Format.Rule.create [ Dim ] ; word_same_next = Format.Rule.blank ; word_same_unified = Format.Rule.blank ; word_prev = Format.Rule.create [ Fg Red ] ; word_next = Format.Rule.create [ Fg Green ] ; hunk = Format.Rule.create [ Bold ] ~pre:(Format.Rule.Affix.create "@|" ~styles:[ Bg Bright_black; Fg Black ]) ~suf: (Format.Rule.Affix.create " ============================================================") ; header_prev = Format.Rule.create [ Bold ] ~pre:(Format.Rule.Affix.create "------ " ~styles:[ Fg Red ]) ; header_next = Format.Rule.create [ Bold ] ~pre:(Format.Rule.Affix.create "++++++ " ~styles:[ Fg Green ]) } ; ext_cmp = None ; float_tolerance = None ; produce_unified_lines = true ; unrefined = false ; keep_ws = false ; split_long_lines = false ; interleave = true ; assume_text = false ; context = default_context ; line_big_enough = default_line_big_enough ; word_big_enough = default_word_big_enough ; shallow = false ; quiet = false ; double_check = false ; mask_uniques = false ; prev_alt = None ; next_alt = None ; location_style = Diff ; warn_if_no_trailing_newline_in_both = warn_if_no_trailing_newline_in_both_default } ;; module Private = struct let with_ext_cmp t ~ext_cmp ~notify = if is_some ext_cmp then notify (); { t with ext_cmp } ;; end
stack.c
#include "fmpz_mod_mpoly_factor.h" void fmpz_mod_poly_stack_init(fmpz_mod_poly_stack_t S) { S->alloc = 0; S->array = NULL; S->top = 0; } void fmpz_mod_poly_stack_clear(fmpz_mod_poly_stack_t S) { slong i; FLINT_ASSERT(S->top == 0); for (i = 0; i < S->alloc; i++) { fmpz_mod_poly_clear(S->array[i], NULL); flint_free(S->array[i]); } flint_free(S->array); } /* insure that k slots are available after top and return pointer to top */ fmpz_mod_poly_struct ** fmpz_mod_poly_stack_fit_request( fmpz_mod_poly_stack_t S, slong k) { slong newalloc, i; FLINT_ASSERT(S->alloc >= S->top); if (S->top + k > S->alloc) { newalloc = FLINT_MAX(1, S->top + k); S->array = FLINT_ARRAY_REALLOC(S->array, newalloc, fmpz_mod_poly_struct *); for (i = S->alloc; i < newalloc; i++) { S->array[i] = FLINT_ARRAY_ALLOC(1, fmpz_mod_poly_struct); fmpz_mod_poly_init(S->array[i], NULL); } S->alloc = newalloc; } return S->array + S->top; } void fmpz_mod_bpoly_stack_init(fmpz_mod_bpoly_stack_t S) { S->alloc = 0; S->array = NULL; S->top = 0; } void fmpz_mod_bpoly_stack_clear(fmpz_mod_bpoly_stack_t S) { slong i; FLINT_ASSERT(S->top == 0); for (i = 0; i < S->alloc; i++) { fmpz_mod_bpoly_clear(S->array[i], NULL); flint_free(S->array[i]); } flint_free(S->array); } /* insure that k slots are available after top and return pointer to top */ fmpz_mod_bpoly_struct ** fmpz_mod_bpoly_stack_fit_request( fmpz_mod_bpoly_stack_t S, slong k) { slong newalloc, i; FLINT_ASSERT(S->alloc >= S->top); if (S->top + k > S->alloc) { newalloc = FLINT_MAX(1, S->top + k); S->array = FLINT_ARRAY_REALLOC(S->array, newalloc, fmpz_mod_bpoly_struct *); for (i = S->alloc; i < newalloc; i++) { S->array[i] = FLINT_ARRAY_ALLOC(1, fmpz_mod_bpoly_struct); fmpz_mod_bpoly_init(S->array[i], NULL); } S->alloc = newalloc; } return S->array + S->top; } void fmpz_mod_polyun_stack_init(fmpz_mod_polyun_stack_t S) { S->alloc = 0; S->array = NULL; S->top = 0; } void fmpz_mod_polyun_stack_clear(fmpz_mod_polyun_stack_t S) { slong i; FLINT_ASSERT(S->top == 0); for (i = 0; i < S->alloc; i++) { fmpz_mod_polyun_clear(S->array[i], NULL); flint_free(S->array[i]); } flint_free(S->array); } /* insure that k slots are available after top and return pointer to top */ fmpz_mod_polyun_struct ** fmpz_mod_polyun_stack_fit_request( fmpz_mod_polyun_stack_t S, slong k) { slong newalloc, i; FLINT_ASSERT(S->alloc >= S->top); if (S->top + k > S->alloc) { newalloc = FLINT_MAX(1, S->top + k); S->array = FLINT_ARRAY_REALLOC(S->array, newalloc, fmpz_mod_polyun_struct *); for (i = S->alloc; i < newalloc; i++) { S->array[i] = FLINT_ARRAY_ALLOC(1, fmpz_mod_polyun_struct); fmpz_mod_polyun_init(S->array[i], NULL); } S->alloc = newalloc; } return S->array + S->top; } void fmpz_mod_mpolyn_stack_init(fmpz_mod_mpolyn_stack_t S, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) { S->alloc = 0; S->array = NULL; S->top = 0; S->bits = bits; } void fmpz_mod_mpolyn_stack_clear( fmpz_mod_mpolyn_stack_t S, const fmpz_mod_mpoly_ctx_t ctx) { slong i; FLINT_ASSERT(S->top == 0); for (i = 0; i < S->alloc; i++) { fmpz_mod_mpolyn_clear(S->array[i], ctx); flint_free(S->array[i]); } flint_free(S->array); } /* insure that k slots are available after top and return pointer to top */ fmpz_mod_mpolyn_struct ** fmpz_mod_mpolyn_stack_fit_request( fmpz_mod_mpolyn_stack_t S, slong k, const fmpz_mod_mpoly_ctx_t ctx) { slong newalloc, i; FLINT_ASSERT(S->alloc >= S->top); if (S->top + k > S->alloc) { newalloc = FLINT_MAX(1, S->top + k); S->array = FLINT_ARRAY_REALLOC(S->array, newalloc, fmpz_mod_mpolyn_struct *); for (i = S->alloc; i < newalloc; i++) { S->array[i] = FLINT_ARRAY_ALLOC(1, fmpz_mod_mpolyn_struct); fmpz_mod_mpolyn_init(S->array[i], S->bits, ctx); } S->alloc = newalloc; } return S->array + S->top; }
/* Copyright (C) 2020 Daniel Schultz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */
sapling_helpers.ml
open Protocol module Common = struct let memo_size_of_int i = match Alpha_context.Sapling.Memo_size.parse_z @@ Z.of_int i with | Ok memo_size -> memo_size | Error _ -> assert false let int_of_memo_size ms = Alpha_context.Sapling.Memo_size.unparse_to_z ms |> Z.to_int let wrap e = Lwt.return (Environment.wrap_tzresult e) let assert_true res = res >|=? fun res -> assert res let assert_false res = res >|=? fun res -> assert (not res) let assert_some res = res >|=? function Some s -> s | None -> assert false let assert_none res = res >>=? function Some _ -> assert false | None -> return_unit let assert_error res = res >>= function Ok _ -> assert false | Error _ -> return_unit let print ?(prefix = "") e v = Printf.printf "%s: %s\n" prefix Data_encoding.(Json.to_string (Json.construct e v)) let to_hex x encoding = Hex.show (Hex.of_bytes Data_encoding.Binary.(to_bytes_exn encoding x)) let randomized_byte ?pos v encoding = let bytes = Data_encoding.Binary.(to_bytes_exn encoding v) in let rec aux () = let random_char = Random.int 256 |> char_of_int in let pos = Option.value ~default:(Random.int (Bytes.length bytes)) pos in if random_char = Bytes.get bytes pos then aux () else Bytes.set bytes pos random_char in aux () ; Data_encoding.Binary.(of_bytes_exn encoding bytes) type wallet = { sk : Tezos_sapling.Core.Wallet.Spending_key.t; vk : Tezos_sapling.Core.Wallet.Viewing_key.t; } let wallet_gen () = let sk = Tezos_sapling.Core.Wallet.Spending_key.of_seed (Tezos_crypto.Hacl.Rand.gen 32) in let vk = Tezos_sapling.Core.Wallet.Viewing_key.of_sk sk in {sk; vk} let gen_addr n vk = let rec aux n index res = if Compare.Int.( <= ) n 0 then res else let (new_index, new_addr) = Tezos_sapling.Core.Client.Viewing_key.new_address vk index in aux (n - 1) new_index (new_addr :: res) in aux n Tezos_sapling.Core.Client.Viewing_key.default_index [] let gen_nf () = let {vk; _} = wallet_gen () in let addr = snd @@ Tezos_sapling.Core.Wallet.Viewing_key.(new_address vk default_index) in let amount = 10L in let rcm = Tezos_sapling.Core.Client.Rcm.random () in let position = 10L in Tezos_sapling.Core.Client.Nullifier.compute addr vk ~amount rcm ~position let gen_cm_cipher ~memo_size () = let open Tezos_sapling.Core.Client in let {vk; _} = wallet_gen () in let addr = snd @@ Tezos_sapling.Core.Wallet.Viewing_key.(new_address vk default_index) in let amount = 10L in let rcm = Tezos_sapling.Core.Client.Rcm.random () in let cm = Commitment.compute addr ~amount rcm in let cipher = let payload_enc = Data_encoding.Binary.to_bytes_exn Data_encoding.bytes (Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) in Data_encoding.Binary.of_bytes_exn Ciphertext.encoding (Bytes.concat Bytes.empty [ Bytes.create (32 + 32); payload_enc; Bytes.create (24 + 64 + 16 + 24); ]) in (cm, cipher) (* rebuilds from empty at each call *) let client_state_of_diff ~memo_size (root, diff) = let open Alpha_context.Sapling in let cs = Tezos_sapling.Storage.add (Tezos_sapling.Storage.empty ~memo_size) diff.commitments_and_ciphertexts in assert (Tezos_sapling.Storage.get_root cs = root) ; List.fold_left (fun s nf -> Tezos_sapling.Storage.add_nullifier s nf) cs diff.nullifiers end module Alpha_context_helpers = struct include Common let init () = Context.init 1 >>=? fun (b, _) -> Alpha_context.prepare b.context ~level:b.header.shell.level ~predecessor_timestamp:b.header.shell.timestamp ~timestamp:b.header.shell.timestamp (* ~fitness:b.header.shell.fitness *) >>= wrap >|=? fun (ctxt, _, _) -> ctxt (* takes a state obtained from Sapling.empty_state or Sapling.state_from_id and passed through Sapling.verify_update *) let finalize ctx = let open Alpha_context in let open Sapling in function | {id = None; diff; memo_size} -> Sapling.fresh ~temporary:false ctx >>= wrap >>=? fun (ctx, id) -> let init = Lazy_storage.Alloc {memo_size} in let lazy_storage_diff = Lazy_storage.Update {init; updates = diff} in let diffs = [Lazy_storage.make Sapling_state id lazy_storage_diff] in Lazy_storage.apply ctx diffs >>= wrap >|=? fun (ctx, _added_size) -> (ctx, id) | {id = Some id; diff; _} -> let init = Lazy_storage.Existing in let lazy_storage_diff = Lazy_storage.Update {init; updates = diff} in let diffs = [Lazy_storage.make Sapling_state id lazy_storage_diff] in Lazy_storage.apply ctx diffs >>= wrap >|=? fun (ctx, _added_size) -> (ctx, id) (* disk only version *) let verify_update ctx ?memo_size ?id vt = let anti_replay = "anti-replay" in (match id with | None -> (match memo_size with | None -> ( match vt.Environment.Sapling.UTXO.outputs with | [] -> failwith "Can't infer memo_size from empty outputs" | output :: _ -> return @@ Environment.Sapling.Ciphertext.get_memo_size output.ciphertext) | Some memo_size -> return memo_size) >>=? fun memo_size -> let memo_size = memo_size_of_int memo_size in let vs = Alpha_context.Sapling.empty_state ~memo_size () in return (vs, ctx) | Some id -> (* Storage.Sapling.Roots.get (Obj.magic ctx, id) 0l *) (* >>= wrap *) (* >>=? fun (_, root) -> *) (* print ~prefix:"verify: " Environment.Sapling.Hash.encoding root ; *) Alpha_context.Sapling.state_from_id ctx id >>= wrap) >>=? fun (vs, ctx) -> Alpha_context.Sapling.verify_update ctx vs vt anti_replay >>= wrap >>=? fun (ctx, res) -> match res with | None -> return_none | Some (_balance, vs) -> finalize ctx vs >>=? fun (ctx, id) -> let fake_fitness = Alpha_context.( let level = match Raw_level.of_int32 0l with | Error _ -> assert false | Ok l -> l in Fitness.create_without_locked_round ~level ~predecessor_round:Round.zero ~round:Round.zero |> Fitness.to_raw) in let ectx = (Alpha_context.finalize ctx fake_fitness).context in (* bump the level *) Alpha_context.prepare ectx ~level: Alpha_context.( Raw_level.to_int32 Level.((succ ctx (current ctx)).level)) ~predecessor_timestamp:(Time.Protocol.of_seconds Int64.zero) ~timestamp:(Time.Protocol.of_seconds Int64.zero) >>= wrap >|=? fun (ctx, _, _) -> Some (ctx, id) let transfer_inputs_outputs w cs is = (* Tezos_sapling.Storage.size cs *) (* |> fun (a, b) -> *) (* Printf.printf "%Ld %Ld" a b ; *) let inputs = List.map (fun i -> Tezos_sapling.Forge.Input.get cs (Int64.of_int i) w.vk |> WithExceptions.Option.get ~loc:__LOC__ |> snd) is in let addr = snd @@ Tezos_sapling.Core.Wallet.Viewing_key.(new_address w.vk default_index) in let memo_size = Tezos_sapling.Storage.get_memo_size cs in let o = Tezos_sapling.Forge.make_output addr 1000000L (Bytes.create memo_size) in (inputs, [o]) let transfer w cs is = let anti_replay = "anti-replay" in let (ins, outs) = transfer_inputs_outputs w cs is in (* change the wallet of this last line *) Tezos_sapling.Forge.forge_transaction ins outs w.sk anti_replay cs let client_state_alpha ctx id = Alpha_context.Sapling.get_diff ctx id () >>= wrap >>=? fun diff -> Alpha_context.Sapling.state_from_id ctx id >>= wrap >|=? fun ({memo_size; _}, _ctx) -> let memo_size = int_of_memo_size memo_size in client_state_of_diff ~memo_size diff end (* Interpreter level *) module Interpreter_helpers = struct include Common include Contract_helpers (** Returns a block in which the contract is originated. Also returns the associated anti-replay string and KT1 address. *) let originate_contract file storage src b baker = originate_contract file storage src b baker >|=? fun (dst, b) -> let anti_replay = Format.asprintf "%a%a" Alpha_context.Contract.pp dst Chain_id.pp Chain_id.zero in (dst, b, anti_replay) let hex_shield ~memo_size wallet anti_replay = let ps = Tezos_sapling.Storage.empty ~memo_size in let addr = snd @@ Tezos_sapling.Core.Wallet.Viewing_key.( new_address wallet.vk default_index) in let output = Tezos_sapling.Forge.make_output addr 15L (Bytes.create memo_size) in let pt = Tezos_sapling.Forge.forge_transaction [] [output] wallet.sk anti_replay ps in let hex_string = "0x" ^ Hex.show (Hex.of_bytes Data_encoding.Binary.( to_bytes_exn Tezos_sapling.Core.Client.UTXO.transaction_encoding pt)) in hex_string (* Make a transaction and sync a local client state. [to_exclude] is the list of addresses that cannot bake the block*) let transac_and_sync ~memo_size block parameters amount src dst baker = let amount_tez = Test_tez.(Alpha_context.Tez.one_mutez *! Int64.of_int amount) in let fee = Test_tez.of_int 10 in Op.transaction ~fee (B block) src dst amount_tez ~parameters >>=? fun operation -> Incremental.begin_construction ~policy:Block.(By_account baker) block >>=? fun incr -> Incremental.add_operation incr operation >>=? fun incr -> Incremental.finalize_block incr >>=? fun block -> Alpha_services.Contract.single_sapling_get_diff Block.rpc_ctxt block dst ~offset_commitment:0L ~offset_nullifier:0L () >|=? fun diff -> let state = client_state_of_diff ~memo_size diff in (block, state) (* Returns a list of printed shield transactions and their total amount. *) let shield ~memo_size sk number_transac vk printer anti_replay = let state = Tezos_sapling.Storage.empty ~memo_size in let rec aux number_transac number_outputs index amount_output total res = if Compare.Int.(number_transac <= 0) then (res, total) else let (new_index, new_addr) = Tezos_sapling.Core.Wallet.Viewing_key.(new_address vk index) in let outputs = List.init ~when_negative_length:() number_outputs (fun _ -> Tezos_sapling.Forge.make_output new_addr amount_output (Bytes.create memo_size)) |> function | Error () -> assert false (* conditional above guards against this *) | Ok outputs -> outputs in let tr_hex = to_hex (Tezos_sapling.Forge.forge_transaction ~number_dummy_inputs:0 ~number_dummy_outputs:0 [] outputs sk anti_replay state) Tezos_sapling.Core.Client.UTXO.transaction_encoding in aux (number_transac - 1) (number_outputs + 1) new_index (Int64.add 20L amount_output) (total + (number_outputs * Int64.to_int amount_output)) (printer tr_hex :: res) in aux number_transac 2 Tezos_sapling.Core.Wallet.Viewing_key.default_index 20L 0 [] (* This fails if the operation is not correct wrt the block *) let next_block block operation = Incremental.begin_construction block >>=? fun incr -> Incremental.add_operation incr operation >>=? fun incr -> Incremental.finalize_block incr end
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2020-2021 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
ssl_stubs.c
/** * Libssl bindings for OCaml. * * @author Samuel Mimram */ /* * WARNING: because of thread callbacks, all ssl functions should be in * blocking sections. */ #include <unistd.h> #include <string.h> #include <assert.h> #include <caml/alloc.h> #include <caml/callback.h> #include <caml/custom.h> #include <caml/fail.h> #include <caml/memory.h> #include <caml/mlvalues.h> #include <caml/threads.h> #include <caml/unixsupport.h> #include <caml/bigarray.h> #include <openssl/ssl.h> #include <openssl/pem.h> #include <openssl/err.h> #include <openssl/crypto.h> #include <openssl/tls1.h> #include <openssl/x509v3.h> #include "ocaml_ssl.h" #ifdef WIN32 #include <windows.h> #else #include <pthread.h> #endif static int client_verify_callback(int, X509_STORE_CTX *); #ifdef NO_NAKED_POINTERS static value vclient_verify_callback = Val_int(0); #endif static DH *load_dh_param(const char *dhfile); /******************* * Data structures * *******************/ /* Contexts */ #define Ctx_val(v) (*((SSL_CTX**)Data_custom_val(v))) static void finalize_ctx(value block) { SSL_CTX *ctx = Ctx_val(block); SSL_CTX_free(ctx); } static struct custom_operations ctx_ops = { "ocaml_ssl_ctx", finalize_ctx, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; /* Sockets */ #define SSL_val(v) (*((SSL**)Data_custom_val(v))) static void finalize_ssl_socket(value block) { SSL *ssl = SSL_val(block); SSL_free(ssl); } static struct custom_operations socket_ops = { "ocaml_ssl_socket", finalize_ssl_socket, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; /* Option types */ #define Val_none Val_int(0) static value Val_some(value v) { CAMLparam1(v); CAMLlocal1(some); some = caml_alloc(1, 0); Store_field(some, 0, v); CAMLreturn(some); } /****************** * Initialization * ******************/ #ifdef WIN32 struct CRYPTO_dynlock_value { HANDLE mutex; }; static HANDLE *mutex_buf = NULL; static void locking_function(int mode, int n, const char *file, int line) { if (mode & CRYPTO_LOCK) WaitForSingleObject(mutex_buf[n], INFINITE); else ReleaseMutex(mutex_buf[n]); } static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line) { struct CRYPTO_dynlock_value *value; value = malloc(sizeof(struct CRYPTO_dynlock_value)); if (!value) return NULL; if (!(value->mutex = CreateMutex(NULL, FALSE, NULL))) { free(value); return NULL; } return value; } static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) { if (mode & CRYPTO_LOCK) WaitForSingleObject(l->mutex, INFINITE); else ReleaseMutex(l->mutex); } static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { CloseHandle(l->mutex); free(l); } #else struct CRYPTO_dynlock_value { pthread_mutex_t mutex; }; static pthread_mutex_t *mutex_buf = NULL; static void locking_function(int mode, int n, const char *file, int line) { if (mode & CRYPTO_LOCK) pthread_mutex_lock(&mutex_buf[n]); else pthread_mutex_unlock(&mutex_buf[n]); } static unsigned long id_function(void) { return ((unsigned long) pthread_self()); } static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line) { struct CRYPTO_dynlock_value *value; value = malloc(sizeof(struct CRYPTO_dynlock_value)); if (!value) return NULL; pthread_mutex_init(&value->mutex, NULL); return value; } static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) { if (mode & CRYPTO_LOCK) pthread_mutex_lock(&l->mutex); else pthread_mutex_unlock(&l->mutex); } static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { pthread_mutex_destroy(&l->mutex); free(l); } #endif CAMLprim value ocaml_ssl_init(value use_threads) { CAMLparam1(use_threads); int i; SSL_library_init(); SSL_load_error_strings(); if(Int_val(use_threads)) { #ifdef WIN32 mutex_buf = malloc(CRYPTO_num_locks() * sizeof(HANDLE)); #else mutex_buf = malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); #endif assert(mutex_buf); for (i = 0; i < CRYPTO_num_locks(); i++) #ifdef WIN32 mutex_buf[i] = CreateMutex(NULL, FALSE, NULL); #else pthread_mutex_init(&mutex_buf[i], NULL); #endif CRYPTO_set_locking_callback(locking_function); #ifndef WIN32 /* Windows does not require id_function, see threads(3) */ CRYPTO_set_id_callback(id_function); #endif CRYPTO_set_dynlock_create_callback(dyn_create_function); CRYPTO_set_dynlock_lock_callback(dyn_lock_function); CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function); } CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_get_error_string(value unit) { CAMLparam1(unit); char buf[256]; ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); CAMLreturn(caml_copy_string(buf)); } /***************************** * Context-related functions * *****************************/ static int protocol_flags[] = { SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3, SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, #ifdef HAVE_TLS11 SSL_OP_NO_TLSv1_1 #else 0 /* not supported, nothing to disable */ #endif , #ifdef HAVE_TLS12 SSL_OP_NO_TLSv1_2 #else 0 /* not supported ,nothing to disable */ #endif , #ifdef HAVE_TLS13 SSL_OP_NO_TLSv1_3 #else 0 /* not supported, nothing to disable */ #endif }; static const SSL_METHOD *get_method(int protocol, int type) { const SSL_METHOD *method = NULL; caml_release_runtime_system(); switch (protocol) { case 0: switch (type) { case 0: method = SSLv23_client_method(); break; case 1: method = SSLv23_server_method(); break; case 2: method = SSLv23_method(); break; } break; #ifndef OPENSSL_NO_SSL3 case 1: switch (type) { case 0: method = SSLv3_client_method(); break; case 1: method = SSLv3_server_method(); break; case 2: method = SSLv3_method(); break; } break; #endif case 2: switch (type) { case 0: method = TLSv1_client_method(); break; case 1: method = TLSv1_server_method(); break; case 2: method = TLSv1_method(); break; } break; case 3: #ifdef HAVE_TLS11 switch (type) { case 0: method = TLSv1_1_client_method(); break; case 1: method = TLSv1_1_server_method(); break; case 2: method = TLSv1_1_method(); break; } #endif break; case 4: #ifdef HAVE_TLS12 switch (type) { case 0: method = TLSv1_2_client_method(); break; case 1: method = TLSv1_2_server_method(); break; case 2: method = TLSv1_2_method(); break; } #endif break; case 5: #ifdef HAVE_TLS13 switch (type) { case 0: method = TLS_client_method(); break; case 1: method = TLS_server_method(); break; case 2: method = TLS_method(); break; } #endif break; default: caml_acquire_runtime_system(); caml_invalid_argument("Unknown method (this should not have happened, please report)."); break; } caml_acquire_runtime_system(); if (method == NULL) caml_raise_constant(*caml_named_value("ssl_exn_method_error")); return method; } CAMLprim value ocaml_ssl_create_context(value protocol, value type) { CAMLparam2(protocol, type); CAMLlocal1(block); SSL_CTX *ctx; const SSL_METHOD *method = get_method(Int_val(protocol), Int_val(type)); caml_release_runtime_system(); ctx = SSL_CTX_new(method); if (!ctx) { caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_context_error")); } /* In non-blocking mode, accept a buffer with a different address on a write retry (since the GC may need to move it). In blocking mode, hide SSL_ERROR_WANT_(READ|WRITE) from us. */ SSL_CTX_set_mode(ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | SSL_MODE_AUTO_RETRY); caml_acquire_runtime_system(); block = caml_alloc_custom(&ctx_ops, sizeof(SSL_CTX*), 0, 1); Ctx_val(block) = ctx; CAMLreturn(block); } CAMLprim value ocaml_ssl_ctx_add_extra_chain_cert(value context, value cert) { CAMLparam2(context, cert); SSL_CTX *ctx = Ctx_val(context); const char *cert_data = String_val(cert); int cert_data_length = caml_string_length(cert); char buf[256]; X509 *x509_cert = NULL; BIO *cbio; caml_release_runtime_system(); cbio = BIO_new_mem_buf((void*)cert_data, cert_data_length); x509_cert = PEM_read_bio_X509(cbio, NULL, 0, NULL); if (NULL == x509_cert || SSL_CTX_add_extra_chain_cert(ctx, x509_cert) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_add_cert_to_store(value context, value cert) { CAMLparam2(context,cert); SSL_CTX *ctx = Ctx_val(context); const char *cert_data = String_val(cert); int cert_data_length = caml_string_length(cert); char buf[256]; X509 *x509_cert = NULL; BIO *cbio; caml_release_runtime_system(); cbio = BIO_new_mem_buf((void*)cert_data, cert_data_length); x509_cert = PEM_read_bio_X509(cbio, NULL, 0, NULL); X509_STORE *store = SSL_CTX_get_cert_store(ctx); if (NULL == x509_cert || X509_STORE_add_cert(store, x509_cert) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_use_certificate(value context, value cert, value privkey) { CAMLparam3(context, cert, privkey); SSL_CTX *ctx = Ctx_val(context); const char *cert_name = String_val(cert); const char *privkey_name = String_val(privkey); char buf[256]; caml_release_runtime_system(); if (SSL_CTX_use_certificate_chain_file(ctx, cert_name) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } if (SSL_CTX_use_PrivateKey_file(ctx, privkey_name, SSL_FILETYPE_PEM) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_private_key_error"), caml_copy_string(buf)); } if (!SSL_CTX_check_private_key(ctx)) { caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_unmatching_keys")); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_use_certificate_from_string(value context, value cert, value privkey) { CAMLparam3(context, cert, privkey); SSL_CTX *ctx = Ctx_val(context); const char *cert_data = String_val(cert); int cert_data_length = caml_string_length(cert); const char *privkey_data = String_val(privkey); int privkey_data_length = caml_string_length(privkey); char buf[256]; X509 *x509_cert = NULL; EVP_PKEY *pkey = NULL; BIO *cbio, *kbio; cbio = BIO_new_mem_buf((void*)cert_data, cert_data_length); x509_cert = PEM_read_bio_X509(cbio, NULL, 0, NULL); if (NULL == x509_cert || SSL_CTX_use_certificate(ctx, x509_cert) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } kbio = BIO_new_mem_buf((void*)privkey_data, privkey_data_length); pkey = PEM_read_bio_PrivateKey(kbio, NULL, 0, NULL); if (NULL == pkey || SSL_CTX_use_PrivateKey(ctx, pkey) <= 0) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_raise_with_arg(*caml_named_value("ssl_exn_private_key_error"), caml_copy_string(buf)); } if (!SSL_CTX_check_private_key(ctx)) { caml_raise_constant(*caml_named_value("ssl_exn_unmatching_keys")); } CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_get_verify_result(value socket) { CAMLparam1(socket); int ans; SSL *ssl = SSL_val(socket); caml_release_runtime_system(); ans = SSL_get_verify_result(ssl); caml_acquire_runtime_system(); CAMLreturn(Val_int(ans)); } CAMLprim value ocaml_ssl_get_verify_error_string(value verrn) { CAMLparam1(verrn); int errn = Int_val(verrn); const char *error_string; caml_release_runtime_system(); error_string = X509_verify_cert_error_string(errn); caml_acquire_runtime_system(); CAMLreturn(caml_copy_string(error_string)); } CAMLprim value ocaml_ssl_digest(value vevp, value vcert) { CAMLparam2(vevp, vcert); CAMLlocal1(vdigest); char buf[384/8]; const EVP_MD *evp; if (vevp == caml_hash_variant("SHA384")) evp = EVP_sha384(); else if(vevp == caml_hash_variant("SHA256")) evp = EVP_sha256(); else evp = EVP_sha1(); size_t digest_size = EVP_MD_size(evp); assert(digest_size <= sizeof(buf)); X509 *x509 = *((X509 **) Data_custom_val(vcert)); caml_release_runtime_system(); int status = X509_digest(x509, evp, (unsigned char*)buf, NULL); caml_acquire_runtime_system(); if (0 == status) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } vdigest = caml_alloc_string(digest_size); memcpy(Bytes_val(vdigest), buf, digest_size); CAMLreturn(vdigest); } CAMLprim value ocaml_ssl_get_client_verify_callback_ptr(value unit) { CAMLparam1(unit); #ifdef NO_NAKED_POINTERS if (Is_long(vclient_verify_callback)) { vclient_verify_callback = caml_alloc_shr(1, Abstract_tag); *((int(**) (int, X509_STORE_CTX*))Data_abstract_val(vclient_verify_callback)) = client_verify_callback; caml_register_generational_global_root(&vclient_verify_callback); } CAMLreturn(vclient_verify_callback); #else CAMLreturn((value)client_verify_callback); #endif } static int client_verify_callback_verbose = 1; CAMLprim value ocaml_ssl_set_client_verify_callback_verbose(value verbose) { CAMLparam1(verbose); client_verify_callback_verbose = Bool_val(verbose); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_set_verify(value context, value vmode, value vcallback) { CAMLparam3(context, vmode, vcallback); SSL_CTX *ctx = Ctx_val(context); int mode = 0; value mode_tl = vmode; int (*callback) (int, X509_STORE_CTX*) = NULL; if (Is_long(vmode)) mode = SSL_VERIFY_NONE; while (Is_block(mode_tl)) { switch(Int_val(Field(mode_tl, 0))) { case 0: mode |= SSL_VERIFY_PEER; break; case 1: mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_PEER; break; case 2: mode |= SSL_VERIFY_CLIENT_ONCE | SSL_VERIFY_PEER; break; default: caml_invalid_argument("mode"); } mode_tl = Field(mode_tl, 1); } if (Is_block(vcallback)) { #ifdef NO_NAKED_POINTERS vcallback = Field(vcallback, 0); if (!Is_block(vcallback) || Tag_val(vcallback) != Abstract_tag || Wosize_val(vcallback) != 1) caml_invalid_argument("callback"); callback = *((int(**) (int, X509_STORE_CTX*))Data_abstract_val(vcallback)); #else callback = (int(*) (int, X509_STORE_CTX*))Field(vcallback, 0); #endif } caml_release_runtime_system(); SSL_CTX_set_verify(ctx, mode, callback); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_set_verify_depth(value context, value vdepth) { CAMLparam2(context, vdepth); SSL_CTX *ctx = Ctx_val(context); int depth = Int_val(vdepth); if (depth < 0) caml_invalid_argument("depth"); caml_release_runtime_system(); SSL_CTX_set_verify_depth(ctx, depth); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_set_client_CA_list_from_file(value context, value vfilename) { CAMLparam2(context, vfilename); SSL_CTX *ctx = Ctx_val(context); const char *filename = String_val(vfilename); STACK_OF(X509_NAME) *cert_names; char buf[256]; caml_release_runtime_system(); cert_names = SSL_load_client_CA_file(filename); if (cert_names != 0) SSL_CTX_set_client_CA_list(ctx, cert_names); else { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } #ifdef HAVE_ALPN static int get_alpn_buffer_length(value vprotos) { value protos_tl = vprotos; int total_len = 0; while (protos_tl != Val_emptylist) { total_len += caml_string_length(Field(protos_tl, 0)) + 1; protos_tl = Field(protos_tl, 1); } return total_len; } static void build_alpn_protocol_buffer(value vprotos, unsigned char *protos) { int proto_idx = 0; while (vprotos != Val_emptylist) { value head = Field(vprotos, 0); int len = caml_string_length(head); protos[proto_idx++] = len; int i; for (i = 0; i < len; i++) protos[proto_idx++] = Byte_u(head, i); vprotos = Field(vprotos, 1); } } CAMLprim value ocaml_ssl_ctx_set_alpn_protos(value context, value vprotos) { CAMLparam2(context, vprotos); SSL_CTX *ctx = Ctx_val(context); int total_len = get_alpn_buffer_length(vprotos); unsigned char protos[total_len]; build_alpn_protocol_buffer(vprotos, protos); caml_release_runtime_system(); SSL_CTX_set_alpn_protos(ctx, protos, sizeof(protos)); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } static value build_alpn_protocol_list(const unsigned char *protocol_buffer, unsigned int len) { CAMLparam0(); CAMLlocal3(protocol_list, current, tail); int idx = 0; protocol_list = Val_emptylist; while (idx < len) { int proto_len = (int) protocol_buffer[idx++]; char proto[proto_len + 1]; int i; for (i = 0; i < proto_len; i++) proto[i] = (char) protocol_buffer[idx++]; proto[proto_len] = '\0'; tail = caml_alloc(2, 0); Store_field(tail, 0, caml_copy_string(proto)); Store_field(tail, 1, Val_emptylist); if (protocol_list == Val_emptylist) protocol_list = tail; else Store_field(current, 1, tail); current = tail; } CAMLreturn(protocol_list); } /* The `alpn_select_cb` function below acquires the runtime lock before calling * this one. Some more info in https://github.com/ocaml/ocaml/issues/11485 */ CAMLprim value caml_alpn_select_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg) { CAMLparam0(); CAMLlocal3(protocol_list, selected_protocol, selected_protocol_opt); int len; protocol_list = build_alpn_protocol_list(in, inlen); selected_protocol_opt = caml_callback(*((value*)arg), protocol_list); if(selected_protocol_opt == Val_none) { CAMLreturn(SSL_TLSEXT_ERR_NOACK); } selected_protocol = Field(selected_protocol_opt, 0); len = caml_string_length(selected_protocol); *out = String_val(selected_protocol); *outlen = len; CAMLreturn(SSL_TLSEXT_ERR_OK); } static int alpn_select_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg) { int res; caml_acquire_runtime_system(); res = caml_alpn_select_cb(ssl, out, outlen, in, inlen, arg); caml_release_runtime_system(); return res; } CAMLprim value ocaml_ssl_ctx_set_alpn_select_callback(value context, value cb) { CAMLparam2(context, cb); SSL_CTX *ctx = Ctx_val(context); value *select_cb; select_cb = malloc(sizeof(value)); *select_cb = cb; caml_register_global_root(select_cb); caml_release_runtime_system(); SSL_CTX_set_alpn_select_cb(ctx, alpn_select_cb, select_cb); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } #else CAMLprim value ocaml_ssl_ctx_set_alpn_protos(value context, value vprotos) { CAMLparam2(context, vprotos); caml_raise_constant(*caml_named_value("ssl_exn_method_error")); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_set_alpn_select_callback(value context, value cb) { CAMLparam2(context, cb); caml_raise_constant(*caml_named_value("ssl_exn_method_error")); CAMLreturn(Val_unit); } #endif static int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata) { value s; int len; caml_acquire_runtime_system(); s = caml_callback(*((value*)userdata), Val_int(rwflag)); len = caml_string_length(s); assert(len <= size); memcpy(buf, String_val(s), len); caml_release_runtime_system(); return len; } CAMLprim value ocaml_ssl_ctx_set_default_passwd_cb(value context, value cb) { CAMLparam2(context, cb); SSL_CTX *ctx = Ctx_val(context); value *pcb; /* TODO: this never gets freed or even unregistered */ pcb = malloc(sizeof(value)); *pcb = cb; caml_register_global_root(pcb); caml_release_runtime_system(); SSL_CTX_set_default_passwd_cb(ctx, pem_passwd_cb); SSL_CTX_set_default_passwd_cb_userdata(ctx, pcb); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_honor_cipher_order(value context) { CAMLparam1(context); SSL_CTX *ctx = Ctx_val(context); SSL_CTX_set_options(ctx, SSL_OP_CIPHER_SERVER_PREFERENCE); CAMLreturn(Val_unit); } /**************************** * Cipher-related functions * ****************************/ CAMLprim value ocaml_ssl_ctx_set_cipher_list(value context, value ciphers_string) { CAMLparam2(context, ciphers_string); SSL_CTX *ctx = Ctx_val(context); const char *ciphers = String_val(ciphers_string); if(*ciphers == 0) caml_raise_constant(*caml_named_value("ssl_exn_cipher_error")); caml_release_runtime_system(); if(SSL_CTX_set_cipher_list(ctx, ciphers) != 1) { caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_cipher_error")); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_disable_protocols(value context, value protocol_list) { CAMLparam2(context, protocol_list); SSL_CTX *ctx = Ctx_val(context); int flags = caml_convert_flag_list(protocol_list, protocol_flags); caml_release_runtime_system(); SSL_CTX_set_options(ctx, flags); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_version(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); int version; int ret; caml_release_runtime_system(); version = SSL_version(ssl); caml_acquire_runtime_system(); switch(version) { case SSL3_VERSION: ret = 1; break; case TLS1_VERSION: ret = 2; break; case TLS1_1_VERSION: ret = 3; break; case TLS1_2_VERSION: ret = 4; break; #ifdef HAVE_TLS13 case TLS1_3_VERSION: ret = 5; break; #endif default: caml_failwith("Ssl.version"); } CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_get_current_cipher(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); caml_release_runtime_system(); SSL_CIPHER *cipher = (SSL_CIPHER*)SSL_get_current_cipher(ssl); caml_acquire_runtime_system(); if (!cipher) caml_raise_constant(*caml_named_value("ssl_exn_cipher_error")); CAMLreturn((value)cipher); } CAMLprim value ocaml_ssl_get_cipher_description(value vcipher) { CAMLparam1(vcipher); char buf[1024]; SSL_CIPHER *cipher = (SSL_CIPHER*)vcipher; caml_release_runtime_system(); SSL_CIPHER_description(cipher, buf, 1024); caml_acquire_runtime_system(); CAMLreturn(caml_copy_string(buf)); } CAMLprim value ocaml_ssl_get_cipher_name(value vcipher) { CAMLparam1(vcipher); const char *name; SSL_CIPHER *cipher = (SSL_CIPHER*)vcipher; caml_release_runtime_system(); name = SSL_CIPHER_get_name(cipher); caml_acquire_runtime_system(); CAMLreturn(caml_copy_string(name)); } CAMLprim value ocaml_ssl_get_cipher_version(value vcipher) { CAMLparam1(vcipher); const char *version; SSL_CIPHER *cipher = (SSL_CIPHER*)vcipher; caml_release_runtime_system(); version = SSL_CIPHER_get_version(cipher); caml_acquire_runtime_system(); CAMLreturn(caml_copy_string(version)); } CAMLprim value ocaml_ssl_ctx_init_dh_from_file(value context, value dh_file_path) { CAMLparam2(context, dh_file_path); DH *dh = NULL; SSL_CTX *ctx = Ctx_val(context); const char *dh_cfile_path = String_val(dh_file_path); if(*dh_cfile_path == 0) caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error")); dh = load_dh_param(dh_cfile_path); caml_release_runtime_system(); if (dh != NULL){ if(SSL_CTX_set_tmp_dh(ctx,dh) != 1){ caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error")); } SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE); caml_acquire_runtime_system(); DH_free(dh); } else { caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error")); } CAMLreturn(Val_unit); } #ifdef HAVE_EC CAMLprim value ocaml_ssl_ctx_init_ec_from_named_curve(value context, value curve_name) { CAMLparam2(context, curve_name); EC_KEY *ecdh = NULL; int nid = 0; SSL_CTX *ctx = Ctx_val(context); const char *ec_curve_name = String_val(curve_name); if(*ec_curve_name == 0) caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error")); nid = OBJ_sn2nid(ec_curve_name); if(nid == 0){ caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error")); } caml_release_runtime_system(); ecdh = EC_KEY_new_by_curve_name(nid); if(ecdh != NULL){ if(SSL_CTX_set_tmp_ecdh(ctx,ecdh) != 1){ caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error")); } SSL_CTX_set_options(ctx, SSL_OP_SINGLE_ECDH_USE); caml_acquire_runtime_system(); EC_KEY_free(ecdh); } else{ caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error")); } CAMLreturn(Val_unit); } #else CAMLprim value ocaml_ssl_ctx_init_ec_from_named_curve(value context, value curve_name) { CAMLparam2(context, curve_name); caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error")); CAMLreturn(Val_unit); } #endif /********************************* * Certificate-related functions * *********************************/ #define Cert_val(v) (*((X509**)Data_custom_val(v))) static void finalize_cert(value block) { X509 *cert = Cert_val(block); X509_free(cert); } static struct custom_operations cert_ops = { "ocaml_ssl_cert", finalize_cert, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; CAMLprim value ocaml_ssl_read_certificate(value vfilename) { CAMLparam1(vfilename); CAMLlocal1(block); const char *filename = String_val(vfilename); X509 *cert = NULL; FILE *fh = NULL; char buf[256]; if((fh = fopen(filename, "r")) == NULL) caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string("couldn't open certificate file")); caml_release_runtime_system(); if((PEM_read_X509(fh, &cert, 0, 0)) == NULL) { fclose(fh); ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } fclose(fh); caml_acquire_runtime_system(); block = caml_alloc_custom(&cert_ops, sizeof(X509*), 0, 1); Cert_val(block) = cert; CAMLreturn(block); } CAMLprim value ocaml_ssl_write_certificate(value vfilename, value certificate) { CAMLparam2(vfilename, certificate); const char *filename = String_val(vfilename); X509 *cert = Cert_val(certificate); FILE *fh = NULL; char buf[256]; if((fh = fopen(filename, "w")) == NULL) caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string("couldn't open certificate file")); caml_release_runtime_system(); if(PEM_write_X509(fh, cert) == 0) { fclose(fh); ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_acquire_runtime_system(); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } fclose(fh); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_get_certificate(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); char buf[256]; caml_release_runtime_system(); X509 *cert = SSL_get_peer_certificate(ssl); caml_acquire_runtime_system(); if (!cert) { ERR_error_string_n(ERR_get_error(), buf, sizeof(buf)); caml_raise_with_arg(*caml_named_value("ssl_exn_certificate_error"), caml_copy_string(buf)); } CAMLlocal1(block); block = caml_alloc_final(2, finalize_cert, 0, 1); (*((X509 **) Data_custom_val(block))) = cert; CAMLreturn(block); } CAMLprim value ocaml_ssl_get_issuer(value certificate) { CAMLparam1(certificate); X509 *cert = Cert_val(certificate); caml_release_runtime_system(); char *issuer = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); caml_acquire_runtime_system(); if (!issuer) caml_raise_not_found (); CAMLreturn(caml_copy_string(issuer)); } CAMLprim value ocaml_ssl_get_subject(value certificate) { CAMLparam1(certificate); X509 *cert = Cert_val(certificate); caml_release_runtime_system(); char *subject = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); caml_acquire_runtime_system(); if (subject == NULL) caml_raise_not_found (); CAMLreturn(caml_copy_string(subject)); } static value alloc_tm(struct tm *tm) { value res; res = caml_alloc_small(9, 0); Field(res,0) = Val_int(tm->tm_sec); Field(res,1) = Val_int(tm->tm_min); Field(res,2) = Val_int(tm->tm_hour); Field(res,3) = Val_int(tm->tm_mday); Field(res,4) = Val_int(tm->tm_mon); Field(res,5) = Val_int(tm->tm_year); Field(res,6) = Val_int(tm->tm_wday); Field(res,7) = Val_int(tm->tm_yday); Field(res,8) = tm->tm_isdst ? Val_true : Val_false; return res; } #ifdef HAVE_ASN1_TIME_TO_TM CAMLprim value ocaml_ssl_get_start_date(value certificate) { CAMLparam1(certificate); X509 *cert = Cert_val(certificate); struct tm t; caml_release_runtime_system(); ASN1_TIME_to_tm(X509_get0_notBefore(cert), &t); caml_acquire_runtime_system(); CAMLreturn(alloc_tm(&t)); } CAMLprim value ocaml_ssl_get_expiration_date(value certificate) { CAMLparam1(certificate); X509 *cert = Cert_val(certificate); struct tm t; caml_release_runtime_system(); ASN1_TIME_to_tm(X509_get0_notAfter(cert), &t); caml_acquire_runtime_system(); CAMLreturn(alloc_tm(&t)); } #else CAMLprim value ocaml_ssl_get_start_date(value ignored) { caml_invalid_argument ("SSL.get_start_date not implemented"); } CAMLprim value ocaml_ssl_get_expiration_date(value ignored) { caml_invalid_argument ("SSL.get_expiration_date not implemented"); } #endif CAMLprim value ocaml_ssl_ctx_load_verify_locations(value context, value ca_file, value ca_path) { CAMLparam3(context, ca_file, ca_path); SSL_CTX *ctx = Ctx_val(context); const char *CAfile = String_val(ca_file); const char *CApath = String_val(ca_path); if(*CAfile == 0) CAfile = NULL; if(*CApath == 0) CApath = NULL; caml_release_runtime_system(); if(SSL_CTX_load_verify_locations(ctx, CAfile, CApath) != 1) { caml_acquire_runtime_system(); caml_invalid_argument("cafile or capath"); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_ctx_set_default_verify_paths(value context) { CAMLparam1(context); int ret; SSL_CTX *ctx = Ctx_val(context); caml_release_runtime_system(); ret = SSL_CTX_set_default_verify_paths(ctx); caml_acquire_runtime_system(); CAMLreturn(Val_bool(ret)); } /************************* * Operations on sockets * *************************/ CAMLprim value ocaml_ssl_get_file_descr(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); int fd; caml_release_runtime_system(); fd = SSL_get_fd(ssl); caml_acquire_runtime_system(); CAMLreturn(Val_int(fd)); } CAMLprim value ocaml_ssl_embed_socket(value socket_, value context) { CAMLparam2(socket_, context); CAMLlocal1(block); #ifdef Socket_val SOCKET socket = Socket_val(socket_); #else int socket = Int_val(socket_); #endif SSL_CTX *ctx = Ctx_val(context); SSL *ssl; block = caml_alloc_custom(&socket_ops, sizeof(SSL*), 0, 1); if (socket < 0) caml_raise_constant(*caml_named_value("ssl_exn_invalid_socket")); caml_release_runtime_system(); ssl = SSL_new(ctx); if (!ssl) { caml_acquire_runtime_system(); caml_raise_constant(*caml_named_value("ssl_exn_handler_error")); } SSL_set_fd(ssl, socket); caml_acquire_runtime_system(); SSL_val(block) = ssl; CAMLreturn(block); } #ifdef HAVE_SNI CAMLprim value ocaml_ssl_set_client_SNI_hostname(value socket, value vhostname) { CAMLparam2(socket, vhostname); SSL *ssl = SSL_val(socket); const char *hostname = String_val(vhostname); caml_release_runtime_system(); SSL_set_tlsext_host_name(ssl, hostname); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } #else CAMLprim value ocaml_ssl_set_client_SNI_hostname(value socket, value vhostname) { CAMLparam2(socket, vhostname); caml_raise_constant(*caml_named_value("ssl_exn_method_error")); CAMLreturn(Val_unit); } #endif #ifdef HAVE_ALPN CAMLprim value ocaml_ssl_set_alpn_protos(value socket, value vprotos) { CAMLparam2(socket, vprotos); SSL *ssl = SSL_val(socket); int total_len = get_alpn_buffer_length(vprotos); unsigned char protos[total_len]; build_alpn_protocol_buffer(vprotos, protos); caml_release_runtime_system(); SSL_set_alpn_protos(ssl, protos, sizeof(protos)); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_get_negotiated_alpn_protocol(value socket) { CAMLparam1(socket); CAMLlocal1(proto); SSL *ssl = SSL_val(socket); const unsigned char *data; unsigned int len; SSL_get0_alpn_selected(ssl, &data, &len); if (len == 0) CAMLreturn(Val_none); /* Note: we use the implementation `caml_alloc_initialized_string` (which * unfortunately requires OCaml >= 4.06) instead of `copy_string` here * because the selected protocol in `data` is not NULL-terminated. * * From https://www.openssl.org/docs/man1.0.2/man3/SSL_get0_alpn_selected.html: * SSL_get0_alpn_selected() returns a pointer to the selected protocol in * data with length len. It is not NUL-terminated. data is set to NULL and * len is set to 0 if no protocol has been selected. data must not be * freed. */ proto = caml_alloc_string (len); memcpy((char *)String_val(proto), (const char*)data, len); CAMLreturn(Val_some(proto)); } #else CAMLprim value ocaml_ssl_set_alpn_protos(value socket, value vprotos) { CAMLparam2(socket, vprotos); caml_raise_constant(*caml_named_value("ssl_exn_method_error")); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_get_negotiated_alpn_protocol(value socket) { CAMLparam1(socket); caml_raise_constant(*caml_named_value("ssl_exn_method_error")); CAMLreturn(Val_unit); } #endif CAMLprim value ocaml_ssl_connect(value socket) { CAMLparam1(socket); int ret, err; SSL *ssl = SSL_val(socket); caml_release_runtime_system(); ret = SSL_connect(ssl); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_connection_error"), Val_int(err)); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_verify(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); long ans; caml_release_runtime_system(); ans = SSL_get_verify_result(ssl); caml_acquire_runtime_system(); if (ans != 0) { if (2 <= ans && ans <= 32) caml_raise_with_arg(*caml_named_value("ssl_exn_verify_error"), Val_int(ans - 2)); /* Not very nice, but simple */ else caml_raise_with_arg(*caml_named_value("ssl_exn_verify_error"), Val_int(31)); } CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_set_hostflags(value socket, value flag_lst) { CAMLparam2(socket, flag_lst); SSL *ssl = SSL_val(socket); unsigned int flags = 0; while (Is_block(flag_lst)) { switch(Int_val(Field(flag_lst, 0))) { case 0: flags |= X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT; break; case 1: flags |= X509_CHECK_FLAG_NO_WILDCARDS; break; case 2: flags |= X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS; break; case 3: flags |= X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS; break; case 4: flags |= X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS; break; default: caml_invalid_argument("flags"); } flag_lst = Field(flag_lst, 1); } caml_release_runtime_system(); X509_VERIFY_PARAM_set_hostflags(SSL_get0_param(ssl), flags); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_set1_host(value socket, value host) { CAMLparam2(socket, host); SSL *ssl = SSL_val(socket); const char *hostname = String_val (host); caml_release_runtime_system(); X509_VERIFY_PARAM_set1_host (SSL_get0_param(ssl), hostname, 0); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_set1_ip(value socket, value ip) { CAMLparam2(socket, ip); SSL *ssl = SSL_val(socket); const char *ipval = String_val (ip); caml_release_runtime_system(); X509_VERIFY_PARAM_set1_ip_asc (SSL_get0_param(ssl), ipval); caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_write(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; int buflen = Int_val(length); char *buf = malloc(buflen); SSL *ssl = SSL_val(socket); if (Int_val(start) + Int_val(length) > caml_string_length(buffer)) caml_invalid_argument("Buffer too short."); memmove(buf, (char*)String_val(buffer) + Int_val(start), buflen); caml_release_runtime_system(); ERR_clear_error(); ret = SSL_write(ssl, buf, buflen); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); free(buf); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_write_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_write_bigarray(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; SSL *ssl = SSL_val(socket); struct caml_ba_array *ba = Caml_ba_array_val(buffer); char *buf = ((char *)ba->data) + Int_val(start); if(Int_val(start) < 0) caml_invalid_argument("Ssl.write_bigarray: negative offset"); if(Int_val(length) < 0) caml_invalid_argument("Ssl.write_bigarray: negative length"); if (Int_val(start) + Int_val(length) > ba->dim[0]) caml_invalid_argument("Ssl.write_bigarray: buffer too short."); caml_release_runtime_system(); ERR_clear_error(); ret = SSL_write(ssl, buf, Int_val(length)); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_write_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_write_bigarray_blocking(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; SSL *ssl = SSL_val(socket); struct caml_ba_array *ba = Caml_ba_array_val(buffer); char *buf = ((char *)ba->data) + Int_val(start); if(Int_val(start) < 0) caml_invalid_argument("Ssl.write_bigarray_blocking: negative offset"); if(Int_val(length) < 0) caml_invalid_argument("Ssl.write_bigarray_blocking: negative length"); if (Int_val(start) + Int_val(length) > ba->dim[0]) caml_invalid_argument("Ssl.write_bigarray: buffer too short."); ERR_clear_error(); ret = SSL_write(ssl, buf, Int_val(length)); err = SSL_get_error(ssl, ret); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_write_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_read(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; int buflen = Int_val(length); char *buf = malloc(buflen); SSL *ssl = SSL_val(socket); if (Int_val(start) + Int_val(length) > caml_string_length(buffer)) caml_invalid_argument("Buffer too short."); caml_release_runtime_system(); ERR_clear_error(); ret = SSL_read(ssl, buf, buflen); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); memmove(((char*)String_val(buffer)) + Int_val(start), buf, buflen); free(buf); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_read_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_read_into_bigarray(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; struct caml_ba_array *ba = Caml_ba_array_val(buffer); char *buf = ((char *)ba->data) + Int_val(start); SSL *ssl = SSL_val(socket); if(Int_val(start) < 0) caml_invalid_argument("Ssl.read_into_bigarray: negative offset"); if(Int_val(length) < 0) caml_invalid_argument("Ssl.read_into_bigarray: negative length"); if (Int_val(start) + Int_val(length) > ba->dim[0]) caml_invalid_argument("Ssl.read_into_bigarray: buffer too short."); caml_release_runtime_system(); ERR_clear_error(); ret = SSL_read(ssl, buf, Int_val(length)); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_read_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_read_into_bigarray_blocking(value socket, value buffer, value start, value length) { CAMLparam2(socket, buffer); int ret, err; struct caml_ba_array *ba = Caml_ba_array_val(buffer); char *buf = ((char *)ba->data) + Int_val(start); SSL *ssl = SSL_val(socket); if(Int_val(start) < 0) caml_invalid_argument("Ssl.read_into_bigarray: negative offset"); if(Int_val(length) < 0) caml_invalid_argument("Ssl.read_into_bigarray: negative length"); if (Int_val(start) + Int_val(length) > ba->dim[0]) caml_invalid_argument("Ssl.read_into_bigarray: buffer too short."); ERR_clear_error(); ret = SSL_read(ssl, buf, Int_val(length)); err = SSL_get_error(ssl, ret); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_read_error"), Val_int(err)); CAMLreturn(Val_int(ret)); } CAMLprim value ocaml_ssl_accept(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); int ret, err; caml_release_runtime_system(); ERR_clear_error(); ret = SSL_accept(ssl); err = SSL_get_error(ssl, ret); caml_acquire_runtime_system(); if (err != SSL_ERROR_NONE) caml_raise_with_arg(*caml_named_value("ssl_exn_accept_error"), Val_int(err)); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_flush(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); BIO *bio; caml_release_runtime_system(); bio = SSL_get_wbio(ssl); if(bio) { /* TODO: raise an error */ assert(BIO_flush(bio) == 1); } caml_acquire_runtime_system(); CAMLreturn(Val_unit); } CAMLprim value ocaml_ssl_shutdown(value socket) { CAMLparam1(socket); SSL *ssl = SSL_val(socket); int ret; caml_release_runtime_system(); ret = SSL_shutdown(ssl); caml_acquire_runtime_system(); switch (ret) { case 0: case 1: /* close(SSL_get_fd(SSL_val(socket))); */ CAMLreturn(Val_int(ret)); default: ret = SSL_get_error(ssl, ret); caml_raise_with_arg(*caml_named_value("ssl_exn_connection_error"), Val_int(ret)); } } /* ======================================================== */ /* T.F.: Here, we steal the client_verify_callback function from netkit-telnet-ssl-0.17.24+0.1/libtelnet/ssl.c From the original file header: The modifications to support SSLeay were done by Tim Hudson tjh@mincom.oz.au You can do whatever you like with these patches except pretend that you wrote them. Email ssl-users-request@mincom.oz.au to get instructions on how to join the mailing list that discusses SSLeay and also these patches. */ #define ONELINE_NAME(X) X509_NAME_oneline(X, 0, 0) /* Quick translation ... */ #ifndef VERIFY_ERR_UNABLE_TO_GET_ISSUER #define VERIFY_ERR_UNABLE_TO_GET_ISSUER X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT #endif #ifndef VERIFY_ERR_DEPTH_ZERO_SELF_SIGNED_CERT #define VERIFY_ERR_DEPTH_ZERO_SELF_SIGNED_CERT X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT #endif #ifndef VERIFY_OK #define VERIFY_OK X509_V_OK #endif #ifndef VERIFY_ERR_UNABLE_TO_GET_ISSUER #define VERIFY_ERR_UNABLE_TO_GET_ISSUER X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT #endif /* Need to think about this mapping in terms of what the real * equivalent of this actually is. */ #ifndef VERIFY_ROOT_OK #define VERIFY_ROOT_OK VERIFY_OK #endif static int client_verify_callback(int ok, X509_STORE_CTX *ctx) { char *subject, *issuer; int depth, error; char *xs; depth = X509_STORE_CTX_get_error_depth(ctx); error = X509_STORE_CTX_get_error(ctx); xs = (char*)X509_STORE_CTX_get_current_cert(ctx); subject = issuer = NULL; /* First thing is to have a meaningful name for the current * certificate that is being verified ... and if we cannot * determine that then something is seriously wrong! */ subject=(char*)ONELINE_NAME(X509_get_subject_name((X509*)xs)); if (subject == NULL) { ERR_print_errors_fp(stderr); ok = 0; goto return_time; } issuer = (char*)ONELINE_NAME(X509_get_issuer_name((X509*)xs)); if (issuer == NULL) { ERR_print_errors_fp(stderr); ok = 0; goto return_time; } /* If the user wants us to be chatty about things then this * is a good time to wizz the certificate chain past quickly :-) */ if (client_verify_callback_verbose) { fprintf(stderr, "Certificate[%d] subject=%s\n", depth, subject); fprintf(stderr, "Certificate[%d] issuer =%s\n", depth, issuer); fflush(stderr); } /* If the server is using a self signed certificate then * we need to decide if that is good enough for us to * accept ... */ if (error == VERIFY_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) { if (1) { /* Make 100% sure that in secure more we drop the * connection if the server does not have a * real certificate! */ if (client_verify_callback_verbose) { fprintf(stderr,"SSL: rejecting connection - server has a self-signed certificate\n"); fflush(stderr); } /* Sometimes it is really handy to be able to debug things * and still get a connection! */ ok = 0; goto return_time; } else { ok = 1; goto return_time; } } /* If we have any form of error in secure mode we reject the connection. */ if (!((error == VERIFY_OK) || (error == VERIFY_ROOT_OK))) { if (1) { if (client_verify_callback_verbose) { fprintf(stderr, "SSL: rejecting connection - error=%d\n", error); if (error == VERIFY_ERR_UNABLE_TO_GET_ISSUER) { fprintf(stderr, "unknown issuer: %s\n", issuer); } else { ERR_print_errors_fp(stderr); } fflush(stderr); } ok = 0; goto return_time; } else { /* Be nice and display a lot more meaningful stuff * so that we know which issuer is unknown no matter * what the callers options are ... */ if (error == VERIFY_ERR_UNABLE_TO_GET_ISSUER && client_verify_callback_verbose) { fprintf(stderr, "SSL: unknown issuer: %s\n", issuer); fflush(stderr); } } } return_time: /* Clean up things. */ if (subject) free(subject); if (issuer) free(issuer); return ok; } static DH *load_dh_param(const char *dhfile) { DH *ret=NULL; BIO *bio; if ((bio=BIO_new_file(dhfile,"r")) == NULL) goto err; ret=PEM_read_bio_DHparams(bio,NULL,NULL,NULL); err: if (bio != NULL) BIO_free(bio); return(ret); }
/* * Copyright (C) 2003-2005 Samuel Mimram * * This file is part of Ocaml-ssl. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
TestUnionFind.ml
let postincrement r = let v = !r in r := v + 1; v let time msg f = let start = Unix.gettimeofday() in let v = f() in let finish = Unix.gettimeofday() in Printf.fprintf stderr "%s: %.2f seconds.\n%!" msg (finish -. start); v let skip () = Printf.fprintf stderr "\n%!" let announce name = Printf.fprintf stderr "%s\n%!" name let n, k = 1000000, 10000000 (* We need [3 * k] random integers of amplitude [n]. *) let integers = Random.self_init(); time "Preparation of the random numbers" begin fun () -> Array.init (3 * k) (fun _ -> Random.int n) end let () = Printf.printf "Running the UnionFind benchmarks...\n\n%!" let new_random_stream () : unit -> int = let c = ref 0 in fun () -> integers.(postincrement c) (* -------------------------------------------------------------------------- *) (* Testing UnionFind, which uses primitive references. *) let () = announce "UnionFind"; let random : unit -> int = new_random_stream() in let point : int UnionFind.elem array = time "Initialization" (fun () -> Array.init n UnionFind.make) in time "Calling union and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in if not (UnionFind.eq point.(i) point.(j)) then begin let vi = UnionFind.get point.(i) and vj = UnionFind.get point.(j) in let p = UnionFind.union point.(i) point.(j) in let v = vi + vj in UnionFind.set p v end end else begin (* Find. *) let i = random() in let _ = UnionFind.find point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Also UnionFind, using [merge]. *) let () = announce "UnionFind (with merge)"; let random : unit -> int = new_random_stream() in let point : int UnionFind.elem array = time "Initialization" (fun () -> Array.init n UnionFind.make) in time "Calling merge and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in let _ = UnionFind.merge (+) point.(i) point.(j) in () end else begin (* Find. *) let i = random() in let _ = UnionFind.find point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreVector). *) let () = announce "UnionFind.Make(StoreVector)"; let module Store = UnionFind.StoreVector in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling union and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in if not (UnionFind.eq s point.(i) point.(j)) then begin let vi = UnionFind.get s point.(i) and vj = UnionFind.get s point.(j) in let p = UnionFind.union s point.(i) point.(j) in let v = vi + vj in UnionFind.set s p v end end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreRef), which also uses primitive references. *) let () = announce "UnionFind.Make(StoreRef)"; let module Store = UnionFind.StoreRef in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling union and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in if not (UnionFind.eq s point.(i) point.(j)) then begin let vi = UnionFind.get s point.(i) and vj = UnionFind.get s point.(j) in let p = UnionFind.union s point.(i) point.(j) in let v = vi + vj in UnionFind.set s p v end end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreTransactionalRef), which uses transactional references implemented on top of primitive references. *) let () = announce "UnionFind.Make(StoreTransactionalRef)"; let module Store = UnionFind.StoreTransactionalRef in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling union and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in if not (UnionFind.eq s point.(i) point.(j)) then begin let vi = UnionFind.get s point.(i) and vj = UnionFind.get s point.(j) in let p = UnionFind.union s point.(i) point.(j) in let v = vi + vj in UnionFind.set s p v end end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreTransactionalRef), with [merge]. *) let () = announce "UnionFind.Make(StoreTransactionalRef) (with merge)"; let module Store = UnionFind.StoreTransactionalRef in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling merge and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in let _ = UnionFind.merge s (+) point.(i) point.(j) in () end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreMap), which uses immutable maps. *) let () = announce "UnionFind.Make(StoreMap)"; let module Store = UnionFind.StoreMap in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling union and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in if not (UnionFind.eq s point.(i) point.(j)) then begin let vi = UnionFind.get s point.(i) and vj = UnionFind.get s point.(j) in let p = UnionFind.union s point.(i) point.(j) in let v = vi + vj in UnionFind.set s p v end end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip () (* -------------------------------------------------------------------------- *) (* Testing UnionFind.Make(StoreMap), with [merge]. *) let () = announce "UnionFind.Make(StoreMap), with merge"; let module Store = UnionFind.StoreMap in let module UnionFind = UnionFind.Make(Store) in let random : unit -> int = new_random_stream() in let s = Store.new_store() in let point : int UnionFind.rref array = time "Initialization" (fun () -> Array.init n (UnionFind.make s)) in time "Calling merge and find" (fun () -> for _op = 1 to k do if random() mod 2 = 0 then begin (* Union. *) let i = random() and j = random() in let _ = UnionFind.merge s (+) point.(i) point.(j) in () end else begin (* Find. *) let i = random() in let _ = UnionFind.get s point.(i) in () end done ); skip ()
gc_stats.ml
open! Import module Steps_timer = struct type duration = Stats.Latest_gc.duration = { wall : float; sys : float; user : float; } type t = { timer : duration; prev_stepname : string } let get_wtime () = (Mtime_clock.now () |> Mtime.to_uint64_ns |> Int64.to_float) /. 1e9 let get_stime () = Rusage.((get Self).stime) let get_utime () = Rusage.((get Self).utime) let create first_stepname = let wall = get_wtime () in let sys = get_stime () in let user = get_utime () in let timer = { wall; sys; user } in { timer; prev_stepname = first_stepname } let progress prev next_stepname = let wall = get_wtime () in let sys = get_stime () in let user = get_utime () in let next = { wall; sys; user } in let wall = next.wall -. prev.timer.wall in let sys = next.sys -. prev.timer.sys in let user = next.user -. prev.timer.user in let delta = (prev.prev_stepname, { wall; sys; user }) in let next = { timer = next; prev_stepname = next_stepname } in (next, delta) end module Main = struct module S = Stats.Latest_gc type t = { stats : S.stats; timer : Steps_timer.t } (** [t] is the running state while computing the stats *) let create first_stepname ~generation ~commit_offset ~before_suffix_start_offset ~before_suffix_end_offset ~after_suffix_start_offset = let stats = Irmin.Type.(random S.stats_t |> unstage) () in (* [repr] provides doesn't provide a generator that fills a type with zeroes but it provides a random generator. Let's use it for our initial value. *) let stats = S. { stats with generation; steps = []; commit_offset; before_suffix_start_offset; before_suffix_end_offset; after_suffix_start_offset; } in let timer = Steps_timer.create first_stepname in { stats; timer } let finish_current_step t next_stepname = let timer, prev_step = Steps_timer.progress t.timer next_stepname in let stats = { t.stats with steps = prev_step :: t.stats.steps } in { stats; timer } let finalise t worker ~after_suffix_end_offset = let t = finish_current_step t "will not appear in the stats" in { t.stats with S.worker; after_suffix_end_offset; steps = List.rev t.stats.steps; } end module Worker = struct module S = Stats.Latest_gc type t = { stats : S.worker; current_stepname : string; prev_wtime : float; prev_stime : float; prev_utime : float; prev_rusage : S.rusage; prev_ocaml_gc : S.ocaml_gc; } (** [t] is the running state while computing the stats *) let is_darwin = lazy (try match Unix.open_process_in "uname" |> input_line with | "Darwin" -> true | _ -> false with Unix.Unix_error _ -> false) let get_wtime () = (Mtime_clock.now () |> Mtime.to_uint64_ns |> Int64.to_float) /. 1e9 let get_stime () = Rusage.((get Self).stime) let get_utime () = Rusage.((get Self).utime) let get_rusage : unit -> S.rusage = fun () -> let Rusage.{ maxrss; minflt; majflt; inblock; oublock; nvcsw; nivcsw; _ } = Rusage.(get Self) in let maxrss = if Lazy.force is_darwin then Int64.div maxrss 1000L else maxrss in S.{ maxrss; minflt; majflt; inblock; oublock; nvcsw; nivcsw } let get_ocaml_gc : unit -> S.ocaml_gc = fun () -> let open Stdlib.Gc in let v = quick_stat () in S. { minor_words = v.minor_words; promoted_words = v.promoted_words; major_words = v.major_words; minor_collections = v.minor_collections; major_collections = v.major_collections; heap_words = v.heap_words; compactions = v.compactions; top_heap_words = v.top_heap_words; stack_size = v.stack_size; } let create : string -> t = fun first_stepname -> (* Reseting all irmin-pack stats. We'll reset again at every step. Since the GC worker lives alone in a fork, these global variable mutations will not interfere with the rest of the world. *) Stats.reset_stats (); Irmin_pack.Stats.reset_stats (); let wtime = get_wtime () in let stime = get_stime () in let utime = get_utime () in let rusage = get_rusage () in let ocaml_gc = get_ocaml_gc () in let stats = S. { initial_maxrss = rusage.maxrss; initial_heap_words = ocaml_gc.heap_words; initial_top_heap_words = ocaml_gc.top_heap_words; initial_stack_size = ocaml_gc.stack_size; steps = []; files = []; objects_traversed = Int63.zero; suffix_transfers = []; } in { stats; current_stepname = first_stepname; prev_utime = utime; prev_wtime = wtime; prev_stime = stime; prev_rusage = rusage; prev_ocaml_gc = ocaml_gc; } let incr_objects_traversed t = let stats = { t.stats with objects_traversed = Int63.succ t.stats.objects_traversed } in { t with stats } let add_suffix_transfer t count = let stats = { t.stats with suffix_transfers = count :: t.stats.suffix_transfers } in { t with stats } let finish_current_step t next_stepname = let wtime = get_wtime () in let stime = get_stime () in let utime = get_utime () in let duration = let wall = wtime -. t.prev_wtime in let sys = stime -. t.prev_stime in let user = utime -. t.prev_utime in S.{ wall; sys; user } in let prev_rusage, rusage = let x = t.prev_rusage in let y = get_rusage () in let ( - ) = Int64.sub in ( y, S. { y with minflt = y.minflt - x.minflt; majflt = y.majflt - x.majflt; inblock = y.inblock - x.inblock; oublock = y.oublock - x.oublock; nvcsw = y.nvcsw - x.nvcsw; nivcsw = y.nivcsw - x.nivcsw; } ) in let prev_ocaml_gc, ocaml_gc = let x = t.prev_ocaml_gc in let y = get_ocaml_gc () in ( y, S. { y with minor_words = y.minor_words -. x.minor_words; promoted_words = y.promoted_words -. x.promoted_words; major_words = y.major_words -. x.major_words; minor_collections = y.minor_collections - x.minor_collections; major_collections = y.major_collections - x.major_collections; compactions = y.compactions - x.compactions; } ) in (* [clone] duplicates a value. Used below to snapshot mutable values. *) let clone typerepr v = match Irmin.Type.to_string typerepr v |> Irmin.Type.of_string typerepr with | Error _ -> assert false | Ok v -> v in let pack_store = Stats.((get ()).pack_store |> Pack_store.export |> clone Pack_store.t) in Stats.report_index (); let index = Stats.((get ()).index |> Index.export |> clone Index.t) in let inode = Irmin_pack.Stats.((get ()).inode |> Inode.export |> clone Inode.t) in Stats.reset_stats (); Irmin_pack.Stats.reset_stats (); let step = S.{ duration; rusage; ocaml_gc; index; pack_store; inode } in (* The [steps] list is built in reverse order and reversed in [finalise] *) let steps = (t.current_stepname, step) :: t.stats.steps in let stats = { t.stats with steps } in { current_stepname = next_stepname; stats; prev_wtime = wtime; prev_stime = stime; prev_utime = utime; prev_rusage; prev_ocaml_gc; } let add_file_size t file_name size = let stats = { t.stats with files = (file_name, size) :: t.stats.files } in { t with stats } let finalise : t -> S.worker = fun t -> let t = finish_current_step t "will not appear in the stats" in { t.stats with steps = List.rev t.stats.steps; suffix_transfers = List.rev t.stats.suffix_transfers; } end
(* * Copyright (c) 2022-2022 Tarides <contact@tarides.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
ref.mli
(** This module extends {{!Base.Ref}[Base.Ref]}. *) open! Import open Perms.Export type 'a t = 'a Base.Ref.t = { mutable contents : 'a } [@@deriving bin_io, quickcheck, typerep] (** @inline *) include module type of struct include Base.Ref end with type 'a t := 'a t module Permissioned : sig type ('a, -'perms) t [@@deriving sexp, bin_io] val create : 'a -> ('a, [< _ perms ]) t val read_only : ('a, [> read ]) t -> ('a, read) t (** [get] and [(!)] are two names for the same function. *) val ( ! ) : ('a, [> read ]) t -> 'a val get : ('a, [> read ]) t -> 'a (** [set] and [(:=)] are two names for the same function. *) val set : ('a, [> write ]) t -> 'a -> unit val ( := ) : ('a, [> write ]) t -> 'a -> unit val of_ref : 'a ref -> ('a, [< read_write ]) t val to_ref : ('a, [> read_write ]) t -> 'a ref val swap : ('a, [> read_write ]) t -> ('a, [> read_write ]) t -> unit val replace : ('a, [> read_write ]) t -> ('a -> 'a) -> unit val set_temporarily : ('a, [> read_write ]) t -> 'a -> f:(unit -> 'b) -> 'b end
(** This module extends {{!Base.Ref}[Base.Ref]}. *)
csdpcert.ml
open NumCompat open Sos open Sos_types open Sos_lib module Mc = Micromega module C2Ml = Mutils.CoqToCaml type micromega_polys = (Micromega.q Mc.pol * Mc.op1) list type csdp_certificate = S of Sos_types.positivstellensatz option | F of string type provername = string * int option let flags = [Open_append; Open_binary; Open_creat] let chan = open_out_gen flags 0o666 "trace" module M = struct open Mc let rec expr_to_term = function | PEc z -> Const (C2Ml.q_to_num z) | PEX v -> Var ("x" ^ string_of_int (C2Ml.index v)) | PEmul (p1, p2) -> let p1 = expr_to_term p1 in let p2 = expr_to_term p2 in let res = Mul (p1, p2) in res | PEadd (p1, p2) -> Add (expr_to_term p1, expr_to_term p2) | PEsub (p1, p2) -> Sub (expr_to_term p1, expr_to_term p2) | PEpow (p, n) -> Pow (expr_to_term p, C2Ml.n n) | PEopp p -> Opp (expr_to_term p) end open M let partition_expr l = let rec f i = function | [] -> ([], [], []) | (e, k) :: l -> ( let eq, ge, neq = f (i + 1) l in match k with | Mc.Equal -> ((e, i) :: eq, ge, neq) | Mc.NonStrict -> (eq, (e, Axiom_le i) :: ge, neq) | Mc.Strict -> (* e > 0 == e >= 0 /\ e <> 0 *) (eq, (e, Axiom_lt i) :: ge, (e, Axiom_lt i) :: neq) | Mc.NonEqual -> (eq, ge, (e, Axiom_eq i) :: neq) ) (* Not quite sure -- Coq interface has changed *) in f 0 l let rec sets_of_list l = match l with | [] -> [[]] | e :: l -> let s = sets_of_list l in s @ List.map (fun s0 -> e :: s0) s (* The exploration is probably not complete - for simple cases, it works... *) let real_nonlinear_prover d l = let l = List.map (fun (e, op) -> (Mc.denorm e, op)) l in try let eq, ge, neq = partition_expr l in let rec elim_const = function | [] -> [] | (x, y) :: l -> let p = poly_of_term (expr_to_term x) in if poly_isconst p then elim_const l else (p, y) :: elim_const l in let eq = elim_const eq in let peq = List.map fst eq in let pge = List.map (fun (e, psatz) -> (poly_of_term (expr_to_term e), psatz)) ge in let monoids = List.map (fun m -> ( List.fold_right (fun (p, kd) y -> let p = poly_of_term (expr_to_term p) in match kd with | Axiom_lt i -> poly_mul p y | Axiom_eq i -> poly_mul (poly_pow p 2) y | _ -> failwith "monoids") m (poly_const Q.one) , List.map snd m )) (sets_of_list neq) in let cert_ideal, cert_cone, monoid = deepen_until d (fun d -> tryfind (fun m -> let ci, cc = real_positivnullstellensatz_general false d peq pge (poly_neg (fst m)) in (ci, cc, snd m)) monoids) 0 in let proofs_ideal = List.map2 (fun q i -> Eqmul (term_of_poly q, Axiom_eq i)) cert_ideal (List.map snd eq) in let proofs_cone = List.map term_of_sos cert_cone in let proof_ne = let neq, lt = List.partition (function Axiom_eq _ -> true | _ -> false) monoid in let sq = match List.map (function Axiom_eq i -> i | _ -> failwith "error") neq with | [] -> Rational_lt Q.one | l -> Monoid l in List.fold_right (fun x y -> Product (x, y)) lt sq in let proof = end_itlist (fun s t -> Sum (s, t)) ((proof_ne :: proofs_ideal) @ proofs_cone) in S (Some proof) with | Sos_lib.TooDeep -> S None | any -> F (Printexc.to_string any) (* This is somewhat buggy, over Z, strict inequality vanish... *) let pure_sos l = let l = List.map (fun (e, o) -> (Mc.denorm e, o)) l in (* If there is no strict inequality, I should nonetheless be able to try something - over Z > is equivalent to -1 >= *) try let l = List.combine l (CList.interval 0 (List.length l - 1)) in let lt, i = try List.find (fun (x, _) -> snd x = Mc.Strict) l with Not_found -> List.hd l in let plt = poly_neg (poly_of_term (expr_to_term (fst lt))) in let n, polys = sumofsquares plt in (* n * (ci * pi^2) *) let pos = Product ( Rational_lt n , List.fold_right (fun (c, p) rst -> Sum (Product (Rational_lt c, Square (term_of_poly p)), rst)) polys (Rational_lt Q.zero) ) in let proof = Sum (Axiom_lt i, pos) in (* let s,proof' = scale_certificate proof in let cert = snd (cert_of_pos proof') in *) S (Some proof) with (* | Sos.CsdpNotFound -> F "Sos.CsdpNotFound" *) | any -> (* May be that could be refined *) S None let run_prover prover pb = match prover with | "real_nonlinear_prover", Some d -> real_nonlinear_prover d pb | "pure_sos", None -> pure_sos pb | prover, _ -> Printf.printf "unknown prover: %s\n" prover; exit 1 let main () = try let (prover, poly) = (input_value stdin : provername * micromega_polys) in let cert = run_prover prover poly in (* Printf.fprintf chan "%a -> %a" print_list_term poly output_csdp_certificate cert ; close_out chan ; *) output_value stdout (cert : csdp_certificate); flush stdout; Marshal.to_channel chan (cert : csdp_certificate) []; flush chan; exit 0 with any -> Printf.fprintf chan "error %s" (Printexc.to_string any); exit 1 ;; let _ = main () in () (* Local Variables: *) (* coding: utf-8 *) (* End: *)
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************) (* *) (* Micromega: A reflexive tactic using the Positivstellensatz *) (* *) (* Frédéric Besson (Irisa/Inria) 2006-2008 *) (* *) (************************************************************************)
xml.mli
(** Xml Light Xml Light is a minimal Xml parser & printer for OCaml. It provide few functions to parse a basic Xml document into an OCaml data structure and to print back the data structures to an Xml document. Xml Light has also support for {b DTD} (Document Type Definition). {i (c)Copyright 2002-2003 Nicolas Cannasse} *) (** {6 Xml Data Structure} *) (** An Xml node is either [Element (tag-name, attributes, children)] or [PCData text] *) type xml = | Element of (string * (string * string) list * xml list) | PCData of string (** {6 Xml Parsing} *) (** For easily parsing an Xml data source into an xml data structure, you can use theses functions. But if you want advanced parsing usage, please look at the {!XmlParser} module. All the parsing functions can raise some exceptions, see the {{:#exc}Exceptions} section for more informations. *) (** Parse the named file into an Xml data structure. *) val parse_file : string -> xml (** Read the content of the in_channel and parse it into an Xml data structure. *) val parse_in : in_channel -> xml (** Parse the string containing an Xml document into an Xml data structure. *) val parse_string : string -> xml (** {6:exc Xml Exceptions} *) (** Several exceptions can be raised when parsing an Xml document : {ul {li {!Xml.Error} is raised when an xml parsing error occurs. the {!Xml.error_msg} tells you which error occured during parsing and the {!Xml.error_pos} can be used to retreive the document location where the error occured at.} {li {!Xml.File_not_found} is raised when and error occured while opening a file with the {!Xml.parse_file} function or when a DTD file declared by the Xml document is not found {i (see the {!XmlParser} module for more informations on how to handle the DTD file loading)}.} } If the Xml document is containing a DTD, then some other exceptions can be raised, see the module {!Dtd} for more informations. *) type error_pos type error_msg = | UnterminatedComment | UnterminatedString | UnterminatedEntity | IdentExpected | CloseExpected | NodeExpected | AttributeNameExpected | AttributeValueExpected | EndOfTagExpected of string | EOFExpected type error = error_msg * error_pos exception Error of error exception File_not_found of string (** Get a full error message from an Xml error. *) val error : error -> string (** Get the Xml error message as a string. *) val error_msg : error_msg -> string (** Get the line the error occured at. *) val line : error_pos -> int (** Get the relative character range (in current line) the error occured at.*) val range : error_pos -> int * int (** Get the absolute character range the error occured at. *) val abs_range : error_pos -> int * int (** {6 Xml Functions} *) exception Not_element of xml exception Not_pcdata of xml exception No_attribute of string (** [tag xdata] returns the tag value of the xml node. Raise {!Xml.Not_element} if the xml is not an element *) val tag : xml -> string (** [pcdata xdata] returns the PCData value of the xml node. Raise {!Xml.Not_pcdata} if the xml is not a PCData *) val pcdata : xml -> string (** [attribs xdata] returns the attribute list of the xml node. First string if the attribute name, second string is attribute value. Raise {!Xml.Not_element} if the xml is not an element *) val attribs : xml -> (string * string) list (** [attrib xdata "href"] returns the value of the ["href"] attribute of the xml node (attribute matching is case-insensitive). Raise {!Xml.No_attribute} if the attribute does not exists in the node's attribute list Raise {!Xml.Not_element} if the xml is not an element *) val attrib : xml -> string -> string (** [children xdata] returns the children list of the xml node Raise {!Xml.Not_element} if the xml is not an element *) val children : xml -> xml list (*** [enum xdata] returns the children enumeration of the xml node Raise {!Xml.Not_element} if the xml is not an element *) (* val enum : xml -> xml Enum.t *) (** [iter f xdata] calls f on all children of the xml node. Raise {!Xml.Not_element} if the xml is not an element *) val iter : (xml -> unit) -> xml -> unit (** [map f xdata] is equivalent to [List.map f (Xml.children xdata)] Raise {!Xml.Not_element} if the xml is not an element *) val map : (xml -> 'a) -> xml -> 'a list (** [fold f init xdata] is equivalent to [List.fold_left f init (Xml.children xdata)] Raise {!Xml.Not_element} if the xml is not an element *) val fold : ('a -> xml -> 'a) -> 'a -> xml -> 'a (** {6 Xml Printing} *) (** Print the xml data structure into a compact xml string (without any user-readable formating ). *) val to_string : xml -> string (** Print the xml data structure into an user-readable string with tabs and lines break between different nodes. *) val to_string_fmt : xml -> string
(* * Xml Light, an small Xml parser/printer with DTD support. * Copyright (C) 2003 Nicolas Cannasse (ncannasse@motion-twin.com) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *)
trace_decoding_interop.mli
open! Core type enum := string list * string type record := (string * string) list * string val event_kinds : enum val decode_result : enum val event_packet : record val add_section_packet : record val decoding_config : record val recording_config : record val mmap : record val setup_info : record val trace_meta : record val gen_ocaml_enum : enum -> unit val gen_ocaml_record : ?for_sig:bool -> record -> unit val gen_c_enum : enum -> unit val gen_c_record_enum : record -> unit
error.ml
open UtilsLib let update_loc lexbuf file = let pos = lexbuf.Lexing.lex_curr_p in let new_file = match file with | None -> pos.Lexing.pos_fname | Some s -> s in lexbuf.Lexing.lex_curr_p <- { pos with Lexing.pos_fname = new_file; Lexing.pos_lnum = pos.Lexing.pos_lnum + 1; Lexing.pos_bol = pos.Lexing.pos_cnum; } let infix_as_prefix = ref None let set_infix l = infix_as_prefix := Some l let unset_infix () = infix_as_prefix := None (*let bad_infix_usage () = !infix_as_prefix *) type lex_error = | Unstarted_comment | Unstarted_bracket | Mismatch_parentheses of char | Unclosed_comment | Expect of string | Bad_token type parse_error = | Syntax_error of string | Duplicated_term of string | Duplicated_type of string | Binder_expected of string | Unknown_constant of string | Not_def_as_infix of string | Unknown_constant_nor_variable of string | Unknown_constant_nor_type of string | Unknown_type of string | Missing_arg_of_Infix of string | No_such_signature of string | No_such_lexicon of string | Not_associative of string | Not_infix of string | Prefix_missing_arg of string | Infix_missing_first_arg of string | Infix_missing_second_arg of string type type_error = | Already_defined_var of string | Not_defined_var of string | Not_defined_const of string | Not_well_typed_term of string * string | Not_well_typed_term_plus of string * string * string | Not_well_kinded_type of string | Non_linear_var of string | Linear_var of string | Other | Is_Used of string * string | Two_occurrences_of_linear_variable of (Lexing.position * Lexing.position) | Non_empty_context of (string*(Lexing.position * Lexing.position)*(Lexing.position * Lexing.position)*string) | Not_normal | Vacuous_abstraction of (string * (Lexing.position * Lexing.position)) type env_error = | Duplicated_signature of string | Duplicated_lexicon of string | Duplicated_entry of string type version_error = Outdated_version of (string*string) type lexicon_error = | Missing_interpretations of (string * string * (string list)) type error = | Parse_error of parse_error * (Lexing.position * Lexing.position) | Lexer_error of lex_error * (Lexing.position * Lexing.position) | Type_error of type_error * (Lexing.position * Lexing.position) | Env_error of env_error * (Lexing.position * Lexing.position) | Version_error of version_error | Lexicon_error of lexicon_error * (Lexing.position * Lexing.position) | System_error of string type warning = | Variable_or_constant of (string * (Lexing.position * Lexing.position)) exception Error of error let compute_comment_for_position pos1 pos2 = let line2 = pos2.Lexing.pos_lnum in let col2 = pos2.Lexing.pos_cnum - pos2.Lexing.pos_bol in let pos1 = pos1 in let line1 = pos1.Lexing.pos_lnum in let col1 = pos1.Lexing.pos_cnum - pos1.Lexing.pos_bol in if line1=line2 then Printf.sprintf "line %d, characters %d-%d" line2 col1 col2 else Printf.sprintf "line %d, character %d to line %d, character %d" line1 col1 line2 col2 let lex_error_to_string = function | Unstarted_comment -> "Syntax error: No comment opened before this closing of comment" | Unstarted_bracket -> "Syntax error: No bracket opened before this right bracket" | Unclosed_comment -> "Syntax error: Unclosed comment" | Mismatch_parentheses c -> Printf.sprintf "Syntax error: Unclosed parenthesis '%c'" c | Expect s -> Printf.sprintf "Syntax error: %s expected" s | Bad_token -> "Lexing error: no such token allowed" let parse_error_to_string = function | Syntax_error s -> Printf.sprintf "Syntax error: %s" s | Duplicated_type ty -> Printf.sprintf "Syntax error: Type \"%s\" has already been defined" ty | Duplicated_term te -> Printf.sprintf "Syntax error: Term \"%s\" has already been defined" te | Binder_expected id -> Printf.sprintf "Syntax error: Unknown binder \"%s\"" id | Unknown_constant id -> Printf.sprintf "Syntax error: Unknown constant \"%s\"" id | Not_def_as_infix id -> Printf.sprintf "Syntax error: \"%s\" is not an infix operator" id | Unknown_constant_nor_variable id -> Printf.sprintf "Syntax error: Unknown constant or variable \"%s\"" id | Unknown_constant_nor_type id -> Printf.sprintf "Syntax error: Unknown constant or type \"%s\"" id | Unknown_type id -> Printf.sprintf "Syntax error: Unknown atomic type \"%s\"" id | Missing_arg_of_Infix id -> Printf.sprintf "Syntax error: \"%s\" is defined as infix but used here with less than two arguments" id | No_such_signature s -> Printf.sprintf "Syntax error: Signature id \"%s\" not in the current environment" s | No_such_lexicon s -> Printf.sprintf "Syntax error: Lexicon id \"%s\" not in the current environment" s | Not_associative s -> Printf.sprintf "Syntax error: Operator \"%s\" is not associative but is used without parenthesis" s | Not_infix s -> Printf.sprintf "Syntax error: Operator \"%s\" is not infix but is used as infix" s | Prefix_missing_arg s -> Printf.sprintf "Syntax error: The prefix operator \"%s\" is missing its argument" s | Infix_missing_first_arg s -> Printf.sprintf "Syntax error: The infix operator \"%s\" is missing its first argument" s | Infix_missing_second_arg s -> Printf.sprintf "Syntax error: The infix operator \"%s\" is missing its first argument" s let type_error_to_string = function | Already_defined_var s -> Printf.sprintf "Var \"%s\" is already defined" s | Not_defined_var s -> Printf.sprintf "Var \"%s\" is not defined" s | Not_defined_const s -> Printf.sprintf "Const \"%s\" is not defined" s | Not_well_typed_term (s,typ) -> Printf.sprintf "Term \"%s\" not well typed.\nType expected : %s\n" s typ | Not_well_typed_term_plus (s,typ,wrong_typ) -> Printf.sprintf "Term \"%s\" not well typed.\n \"%s\" is of type %s but is here used with type %s\n" s s typ wrong_typ | Not_well_kinded_type s -> Printf.sprintf "Type \"%s\" not well kinded" s | Non_linear_var s -> Printf.sprintf "Var \"%s\" is supposed to be non linear" s | Linear_var s -> Printf.sprintf "Var \"%s\" is supposed to be linear" s | Other -> "Not yet implemented" | Is_Used (s1,s2) -> Printf.sprintf "The type of this expression is \"%s\" but is used with type %s" s1 s2 | Two_occurrences_of_linear_variable (s,e) -> Printf.sprintf "This linear variable was already used: %s" (compute_comment_for_position s e) | Non_empty_context (x,(s,e),funct_pos,funct_type) -> Printf.sprintf "This term contains a free linear variable \"%s\" at %s and is argument the term of type \"%s\" at %s )" x (compute_comment_for_position s e) funct_type (compute_comment_for_position (fst funct_pos) (snd funct_pos)) | Not_normal -> "This term is not in normal form" | Vacuous_abstraction (x,(s,e)) -> Printf.sprintf "This linear variable \"%s\" is abstracted over but not used in term %s" x (compute_comment_for_position s e) let env_error_to_string = function | Duplicated_signature s -> Printf.sprintf "Syntax error: Signature id \"%s\" is used twice in this environment" s | Duplicated_lexicon s -> Printf.sprintf "Syntax error: Lexicon id \"%s\" is used twice in this environment" s | Duplicated_entry s -> Printf.sprintf "Syntax error: Entry id \"%s\" is used twice in this environment" s let lexicon_error_to_string = function | Missing_interpretations (lex_name,abs_name,missing_inters) -> Printf.sprintf "Lexicon definition error: Lexicon \"%s\" is missing the interpretations of the following terms of the abstract signature \"%s\":\n%s" lex_name abs_name (Utils.string_of_list "\n" (fun x -> Printf.sprintf"\t%s" x) missing_inters) let version_error_to_string = function | Outdated_version (old_v,current_v) -> Printf.sprintf "You are trying to use an object file that was generated with a former version of the acgc compiler (version %s) while the current version of the compiler is %s" old_v current_v let warning_to_string w input_file = match w with | Variable_or_constant (s,(start,e)) -> Printf.sprintf "File \"%s\", %s\nWarning: %s" input_file (compute_comment_for_position start e) (Printf.sprintf "\"%s\" is a variable here, but is also declared as constant in the signature" s) let error_msg e input_file = let msg,location_msg = match e with | Parse_error (er,(s,e)) -> parse_error_to_string er,Some (compute_comment_for_position s e) | Lexer_error (er,(s,e)) -> lex_error_to_string er,Some (compute_comment_for_position s e) | Type_error (er,(s,e)) -> type_error_to_string er,Some (compute_comment_for_position s e) | Env_error (er,(s,e)) -> env_error_to_string er,Some (compute_comment_for_position s e) | Version_error er -> version_error_to_string er,None | Lexicon_error (er,(s,e)) -> lexicon_error_to_string er,Some (compute_comment_for_position s e) | System_error s -> Printf.sprintf "System error: \"%s\"" s,None in match location_msg with | None -> msg | Some loc -> Printf.sprintf "File \"%s\", %s\n%s" input_file loc msg (* let dyp_error lexbuf = let pos1=Lexing.lexeme_start_p lexbuf in let pos2=Lexing.lexeme_end_p lexbuf in match bad_infix_usage () with | None -> Error (Parse_error (Dyp_error,(pos1,pos2))) | Some (sym,(s,e)) -> Error (Parse_error (Missing_arg_of_Infix sym,(s,e))) *) (* let emit_warning w input_file = match w with | Variable_or_constant (_,(pos1,pos2)) -> let msg = warning_to_string w input_file in let line2 = pos2.Lexing.pos_lnum in let col2 = pos2.Lexing.pos_cnum - pos2.Lexing.pos_bol in let pos1 = pos1 in let line1 = pos1.Lexing.pos_lnum in let col1 = pos1.Lexing.pos_cnum - pos1.Lexing.pos_bol in if line1=line2 then Printf.sprintf "File \"%s\", line %d, characters %d-%d\nWarning: %s" input_file line2 col1 col2 msg else Printf.sprintf "File \"%s\", from l:%d, c:%d to l:%d,c:%d\nWarning: %s" input_file line1 col1 line2 col2 msg *) let warnings_to_string input_file ws = Utils.string_of_list "\n" (fun w -> warning_to_string w input_file) ws let get_loc_error = function | Parse_error (_,(s,e)) | Lexer_error (_,(s,e)) | Type_error (_,(s,e)) | Env_error (_,(s,e)) | Lexicon_error (_,(s,e)) -> (s,e) | (Version_error _ | System_error _) -> failwith "Bug: should not occur" let get_string_error = function | Parse_error (er,pos) -> parse_error_to_string er,pos | Lexer_error (er,pos) -> lex_error_to_string er,pos | Type_error (er,pos) -> type_error_to_string er,pos | Env_error (er,pos) -> env_error_to_string er,pos | Lexicon_error (er,pos) -> lexicon_error_to_string er,pos | (Version_error _ | System_error _) -> failwith "Bug: should not occur" let change_loc err pos = match err with | Parse_error (er,_) -> Parse_error (er,pos) | Lexer_error (er,_) -> Lexer_error (er,pos) | Type_error (er,_) -> Type_error (er,pos) | Env_error (er,_) -> Env_error (er,pos) | Lexicon_error (er,_) -> Lexicon_error (er,pos) | (Version_error _ | System_error _) -> failwith "Bug: should not occur"
(**************************************************************************) (* *) (* ACG development toolkit *) (* *) (* Copyright 2008-2021 INRIA *) (* *) (* More information on "http://acg.gforge.inria.fr/" *) (* License: CeCILL, see the LICENSE file or "http://www.cecill.info" *) (* Authors: see the AUTHORS file *) (* *) (* *) (* *) (* *) (* $Rev:: $: Revision of last commit *) (* $Author:: $: Author of last commit *) (* $Date:: $: Date of last commit *) (* *) (**************************************************************************)
linker.mli
open Stdlib module Fragment : sig type t val provides : t -> string list val parse_file : string -> t list val parse_string : string -> t list val parse_builtin : Builtins.File.t -> t list val pack : t -> t end val reset : unit -> unit val load_files : target_env:Target_env.t -> string list -> unit val load_fragments : target_env:Target_env.t -> filename:string -> Fragment.t list -> unit val check_deps : unit -> unit type state type always_required = { filename : string ; program : Javascript.program ; requires : string list } type output = { runtime_code : Javascript.program ; always_required_codes : always_required list } val init : unit -> state val resolve_deps : ?linkall:bool -> state -> StringSet.t -> state * StringSet.t val link : Javascript.program -> state -> output val get_provided : unit -> StringSet.t val all : state -> string list val origin : name:string -> string option
(* Js_of_ocaml compiler * http://www.ocsigen.org/js_of_ocaml/ * Copyright (C) 2010 Jérôme Vouillon * Laboratoire PPS - CNRS Université Paris Diderot * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, with linking exception; * either version 2.1 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
kzg_pack.ml
module SMap = Plonk.SMap (** Extension of the KZG_pack implementation with additional types and functions used in by Distributed_prover *) module Make (Pack : Aggregation.Pack.Aggregator) (PC : Kzg.PC_for_distribution_sig with type BasePC.Scalar.t = Pack.scalar and type Commitment.t = Pack.g1 SMap.t) = struct module BasePC = Aggregation.Polynomial_commitment.Make_impl (Pack) (PC) module Commitment = struct include BasePC.Commitment let recombine l = List.fold_left Pack.combine (List.hd l) (List.tl l) let recombine_prover_aux l = let cm = PC.Commitment.recombine (List.map fst l) in let p_a = PC.Commitment.recombine_prover_aux (List.map snd l) in (cm, p_a) let empty = Pack.empty_commitment let empty_prover_aux = (PC.Commitment.empty, PC.Commitment.empty_prover_aux) end include (BasePC : module type of BasePC with module Commitment := Commitment) type worker_msg = Scalar.t * string list list [@@deriving repr] type main_prover_msg = Poly.t list * Commitment.prover_aux list [@@deriving repr] type main_prover_state = Public_parameters.prover * transcript * Scalar.t * query list * Scalar.t SMap.t list * main_prover_msg let merge_answers : answer list -> answer = let open SMap in List.fold_left (union (fun _k m1 m2 -> Some (union_disjoint m1 m2))) empty let distributed_prove_worker f_map_list prover_aux_list (r, poly_keys_list) = let gen_powers r l = List.mapi (fun i x -> (x, Scalar.pow r @@ Z.of_int i)) l |> SMap.of_list in let r_powers_list = List.map (gen_powers r) poly_keys_list in let f_list = List.map2 (fun f_map r_map -> let polys = SMap.bindings f_map in let coeffs = List.map (fun (name, _) -> SMap.find name r_map) polys in Poly.linear (List.map snd polys) coeffs) f_map_list r_powers_list in (f_list, prover_aux_list) let distributed_prove_main1 (pp : Public_parameters.prover) transcript query_list answer_list secret_list prover_aux_list = let transcript = expand_with_query query_list transcript in let transcript = expand_with_answer answer_list transcript in let r, transcript = Fr_generation.random_fr transcript in let s_list = List.map (batch_answers r) answer_list in let get_keys map_map = SMap.fold (fun _ m acc -> SMap.union (fun _ _ x -> Some x) m acc) map_map SMap.empty |> SMap.bindings |> List.map fst in let poly_keys_list = List.map get_keys answer_list in let worker_message = (r, poly_keys_list) in (* The main thread simulates a worker, since it is the only one who knows the information about t_map, g_map, plook_map. We need to pad a dummy secret and a dummy prover_aux at the end, corresponding to f_map, which the main thread does not have information about. *) let main_msg = distributed_prove_worker secret_list prover_aux_list worker_message in let state = (pp, transcript, r, query_list, s_list, main_msg) in (worker_message, state) let distributed_prove_main2 ( (pp : Public_parameters.prover), transcript, r, query_list, s_list, main_msg ) worker_msg_list = let worker_msg_list = main_msg :: worker_msg_list in let f_list_list = List.map fst worker_msg_list in let f_list = Plonk.List.mapn (List.fold_left Poly.add Poly.zero) f_list_list in let prover_aux_list_list = List.map snd worker_msg_list in let prover_aux_list = Plonk.List.mapn Commitment.recombine_prover_aux prover_aux_list_list in (* [cmts_list] is a list of G1.t SMap.t, containing the PC commitments to every polynomial (note that PC.Commitment.t = Bls12_381.G1.t SMap.t) *) let cmts_list = List.map (fun (cmts, _prover_aux) -> List.map snd @@ SMap.bindings cmts |> Array.of_list) prover_aux_list in (* [packed_values] has type [G1.t list] and it is the result of batching each map in [cmt_list] with powers of [r]. [pack_proof] asserts that [packed_values] was correctly computed. *) let (packed_values, pack_proof), transcript = Pack.prove pp.pp_pack_prover transcript r cmts_list in (* prepare [f_list] and [s_list], the batched version of [f_map_list] polys and [answer_list] (using randomness [r]) by selecting a dummy name for them [string_of_int i] in order to call the underlying PC *) let f_map_list = List.mapi (fun i l -> SMap.singleton (string_of_int i) l) f_list in let s_map_list = List.mapi (fun i m -> SMap.map (fun s -> SMap.singleton (string_of_int i) s) m) s_list in let prover_aux_list = List.map snd prover_aux_list in (* call the underlying PC prover on the batched polynomials/evaluations the verifier will verify such proof using [packed_values] as the commitments *) let pc_proof, transcript = PC.prove pp.pp_pc_prover transcript f_map_list prover_aux_list query_list s_map_list in let proof = { pc_proof; packed_values; pack_proof } in let transcript = expand_with_proof proof transcript in (proof, transcript) end module Kzg_pack_impl = Make (Aggregation.Pack) (Kzg.Kzg_impl)
(*****************************************************************************) (* *) (* MIT License *) (* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
google_protobuf_struct_pc.ml
[@@@ocaml.warning "-39"] let (>>=) = Runtime.Result.(>>=) let (>>|) = Runtime.Result.(>>|) module Field' = Runtime.Field_value module Bin' = Runtime.Binary_format module Text' = Runtime.Text_format module Null_value : sig type t = | Null_value [@@deriving eq, show] val default : unit -> t val to_int : t -> int val of_int : int -> t option val to_string : t -> string val of_string : string -> t option end = struct type t = | Null_value [@@deriving eq, show] let default = fun () -> Null_value let to_int = function | Null_value -> 0 let of_int = function | 0 -> Some Null_value | _ -> None let to_string = function | Null_value -> "NULL_VALUE" let of_string = function | "NULL_VALUE" -> Some Null_value | _ -> None end module rec Struct' : sig module rec Fields_entry : sig type t = { key : string; value' : Value'.t option; } [@@deriving eq, show] val to_binary : t -> (string, [> Bin'.serialization_error]) result val of_binary : string -> (t, [> Bin'.deserialization_error]) result val to_text : t -> (string, [> Text'.serialization_error]) result val of_text : string -> (t, [> Text'.deserialization_error]) result end type t = { fields : Struct'.Fields_entry.t list; } [@@deriving eq, show] val to_binary : t -> (string, [> Bin'.serialization_error]) result val of_binary : string -> (t, [> Bin'.deserialization_error]) result val to_text : t -> (string, [> Text'.serialization_error]) result val of_text : string -> (t, [> Text'.deserialization_error]) result end = struct module rec Fields_entry : sig type t = { key : string; value' : Value'.t option; } [@@deriving eq, show] val to_binary : t -> (string, [> Bin'.serialization_error]) result val of_binary : string -> (t, [> Bin'.deserialization_error]) result val to_text : t -> (string, [> Text'.serialization_error]) result val of_text : string -> (t, [> Text'.deserialization_error]) result end = struct type t = { key : string; value' : Value'.t option; } [@@deriving eq, show] let rec to_binary = fun { key; value' } -> let _o = Runtime.Byte_output.create () in Bin'.serialize_field 1 Field'.String_t key _o >>= fun () -> Bin'.serialize_user_field 2 Value'.to_binary value' _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_binary = fun input' -> Ok (Runtime.Byte_input.create input') >>= Bin'.deserialize_message >>= fun _m -> Bin'.decode_field 1 Field'.String_t _m >>= fun key -> Bin'.decode_user_field 2 Value'.of_binary _m >>= fun value' -> Ok { key; value' } let rec to_text = fun { key; value' } -> let _o = Runtime.Byte_output.create () in Text'.serialize_field "key" Field'.String_t key _o >>= fun () -> Text'.serialize_user_field "value" Value'.to_text value' _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_text = fun input' -> Ok (Runtime.Byte_input.create input') >>= Text'.deserialize_message >>= fun _m -> Text'.decode_field "key" Field'.String_t _m >>= fun key -> Text'.decode_user_field "value" Value'.of_text _m >>= fun value' -> Ok { key; value' } end type t = { fields : Struct'.Fields_entry.t list; } [@@deriving eq, show] let rec to_binary = fun { fields } -> let _o = Runtime.Byte_output.create () in Bin'.serialize_repeated_user_field 1 Struct'.Fields_entry.to_binary fields _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_binary = fun input' -> Ok (Runtime.Byte_input.create input') >>= Bin'.deserialize_message >>= fun _m -> Bin'.decode_repeated_user_field 1 Struct'.Fields_entry.of_binary _m >>= fun fields -> Ok { fields } let rec to_text = fun { fields } -> let _o = Runtime.Byte_output.create () in Text'.serialize_repeated_user_field "fields" Struct'.Fields_entry.to_text fields _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_text = fun input' -> Ok (Runtime.Byte_input.create input') >>= Text'.deserialize_message >>= fun _m -> Text'.decode_repeated_user_field "fields" Struct'.Fields_entry.of_text _m >>= fun fields -> Ok { fields } end and Value' : sig module Kind : sig type t = | Null_value of Null_value.t | Number_value of float | String_value of string | Bool_value of bool | Struct_value of Struct'.t | List_value of List_value.t [@@deriving eq, show] val null_value : Null_value.t -> t val number_value : float -> t val string_value : string -> t val bool_value : bool -> t val struct_value : Struct'.t -> t val list_value : List_value.t -> t end type t = { kind : Kind.t option; } [@@deriving eq, show] val to_binary : t -> (string, [> Bin'.serialization_error]) result val of_binary : string -> (t, [> Bin'.deserialization_error]) result val to_text : t -> (string, [> Text'.serialization_error]) result val of_text : string -> (t, [> Text'.deserialization_error]) result end = struct module Kind : sig type t = | Null_value of Null_value.t | Number_value of float | String_value of string | Bool_value of bool | Struct_value of Struct'.t | List_value of List_value.t [@@deriving eq, show] val null_value : Null_value.t -> t val number_value : float -> t val string_value : string -> t val bool_value : bool -> t val struct_value : Struct'.t -> t val list_value : List_value.t -> t end = struct type t = | Null_value of Null_value.t | Number_value of float | String_value of string | Bool_value of bool | Struct_value of Struct'.t | List_value of List_value.t [@@deriving eq, show] let null_value value = Null_value value let number_value value = Number_value value let string_value value = String_value value let bool_value value = Bool_value value let struct_value value = Struct_value value let list_value value = List_value value end type t = { kind : Kind.t option; } [@@deriving eq, show] let rec to_binary = fun { kind } -> let _o = Runtime.Byte_output.create () in (match kind with | None -> Ok () | Some Null_value null_value -> Bin'.serialize_enum_field 1 Null_value.to_int null_value _o | Some Number_value number_value -> Bin'.serialize_field 2 Field'.Double_t number_value _o | Some String_value string_value -> Bin'.serialize_field 3 Field'.String_t string_value _o | Some Bool_value bool_value -> Bin'.serialize_field 4 Field'.Bool_t bool_value _o | Some Struct_value struct_value -> Bin'.serialize_user_oneof_field 5 Struct'.to_binary struct_value _o | Some List_value list_value -> Bin'.serialize_user_oneof_field 6 List_value.to_binary list_value _o) >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_binary = fun input' -> Ok (Runtime.Byte_input.create input') >>= Bin'.deserialize_message >>= fun _m -> Bin'.decode_oneof_field [ 1, (fun _m -> Bin'.decode_enum_field 1 Null_value.of_int Null_value.default _m >>| Kind.null_value); 2, (fun _m -> Bin'.decode_field 2 Field'.Double_t _m >>| Kind.number_value); 3, (fun _m -> Bin'.decode_field 3 Field'.String_t _m >>| Kind.string_value); 4, (fun _m -> Bin'.decode_field 4 Field'.Bool_t _m >>| Kind.bool_value); 5, (fun _m -> Bin'.decode_user_oneof_field 5 Struct'.of_binary _m >>| Kind.struct_value); 6, (fun _m -> Bin'.decode_user_oneof_field 6 List_value.of_binary _m >>| Kind.list_value); ] _m >>= fun kind -> Ok { kind } let rec to_text = fun { kind } -> let _o = Runtime.Byte_output.create () in (match kind with | None -> Ok () | Some Null_value null_value -> Text'.serialize_enum_field "null_value" Null_value.to_string null_value _o | Some Number_value number_value -> Text'.serialize_field "number_value" Field'.Double_t number_value _o | Some String_value string_value -> Text'.serialize_field "string_value" Field'.String_t string_value _o | Some Bool_value bool_value -> Text'.serialize_field "bool_value" Field'.Bool_t bool_value _o | Some Struct_value struct_value -> Text'.serialize_user_oneof_field "struct_value" Struct'.to_text struct_value _o | Some List_value list_value -> Text'.serialize_user_oneof_field "list_value" List_value.to_text list_value _o) >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_text = fun input' -> Ok (Runtime.Byte_input.create input') >>= Text'.deserialize_message >>= fun _m -> Text'.decode_oneof_field [ "null_value", (fun _m -> Text'.decode_enum_field "null_value" Null_value.of_string Null_value.default _m >>| Kind.null_value); "number_value", (fun _m -> Text'.decode_field "number_value" Field'.Double_t _m >>| Kind.number_value); "string_value", (fun _m -> Text'.decode_field "string_value" Field'.String_t _m >>| Kind.string_value); "bool_value", (fun _m -> Text'.decode_field "bool_value" Field'.Bool_t _m >>| Kind.bool_value); "struct_value", (fun _m -> Text'.decode_user_oneof_field "struct_value" Struct'.of_text _m >>| Kind.struct_value); "list_value", (fun _m -> Text'.decode_user_oneof_field "list_value" List_value.of_text _m >>| Kind.list_value); ] _m >>= fun kind -> Ok { kind } end and List_value : sig type t = { values : Value'.t list; } [@@deriving eq, show] val to_binary : t -> (string, [> Bin'.serialization_error]) result val of_binary : string -> (t, [> Bin'.deserialization_error]) result val to_text : t -> (string, [> Text'.serialization_error]) result val of_text : string -> (t, [> Text'.deserialization_error]) result end = struct type t = { values : Value'.t list; } [@@deriving eq, show] let rec to_binary = fun { values } -> let _o = Runtime.Byte_output.create () in Bin'.serialize_repeated_user_field 1 Value'.to_binary values _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_binary = fun input' -> Ok (Runtime.Byte_input.create input') >>= Bin'.deserialize_message >>= fun _m -> Bin'.decode_repeated_user_field 1 Value'.of_binary _m >>= fun values -> Ok { values } let rec to_text = fun { values } -> let _o = Runtime.Byte_output.create () in Text'.serialize_repeated_user_field "values" Value'.to_text values _o >>= fun () -> Ok (Runtime.Byte_output.contents _o) let rec of_text = fun input' -> Ok (Runtime.Byte_input.create input') >>= Text'.deserialize_message >>= fun _m -> Text'.decode_repeated_user_field "values" Value'.of_text _m >>= fun values -> Ok { values } end
refl.ml
include Desc module Builtins = Builtins module Tools = Tools include Convert include Map include Show module Compare = Compare module Comparer = Compare.Comparer module Comparers = Compare.Comparers let compare_gen = Compare.compare_gen let compare_poly = Compare.compare_poly let compare = Compare.compare module Eq = Eq module Equaler = Eq.Equaler module Equalers = Eq.Equalers let equal_poly = Eq.equal_poly let equal = Eq.equal module Hash = Hash let hash = Hash.hash include Enum include Iter include Fold include Make module Lift = Lift module Visit = Visit module Ocaml_attributes = struct type ('a, 'arity, 'b) typed_attribute_kind += | Attribute_doc : ('a, 'arity, string) typed_attribute_kind end
lock.mli
val set_mutex : lock:(unit -> unit) -> unlock:(unit -> unit) -> unit (** Set a pair of lock/unlock functions that are used to protect access to global state, if needed. By default these do nothing. *) val with_lock : (unit -> 'a) -> 'a (** Call [f()] while holding the mutex defined {!set_mutex}, then release the mutex. *)
il_ruby_helpers.mli
open Utils_ruby open Il_ruby type pos2 = Parse_info.t val mkstmt : stmt_node -> pos2 -> stmt val update_stmt : stmt -> stmt_node -> stmt val fold_stmt : ('a -> stmt -> 'a) -> 'a -> stmt -> 'a val compute_cfg : stmt -> unit val empty_stmt : unit -> stmt val fresh_local : stmt -> identifier val pos_of : stmt -> pos2 val msg_id_of_string : string -> msg_id class type cfg_visitor = object method visit_stmt : stmt Visitor.visit_method method visit_id : identifier Visitor.visit_method method visit_literal : literal Visitor.visit_method method visit_expr : expr Visitor.visit_method method visit_lhs : lhs Visitor.visit_method method visit_tuple : tuple_expr Visitor.visit_method method visit_rescue_guard : rescue_guard Visitor.visit_method method visit_def_name : def_name Visitor.visit_method method visit_class_kind : class_kind Visitor.visit_method method visit_method_param : method_formal_param Visitor.visit_method method visit_msg_id : msg_id Visitor.visit_method method visit_block_param : block_formal_param Visitor.visit_method end (* A visitor that walks every node in a CFG *) class default_visitor : cfg_visitor (* A visitor that walks every node in the current scope. For instance, nested method bodies are not visited, however method blocks are. *) class scoped_visitor : cfg_visitor val visit_stmt : cfg_visitor -> stmt -> stmt val visit_msg_id : cfg_visitor -> msg_id -> msg_id val visit_id : cfg_visitor -> identifier -> identifier val visit_block_param : cfg_visitor -> block_formal_param -> block_formal_param val visit_literal : cfg_visitor -> literal -> literal val visit_expr : cfg_visitor -> expr -> expr val visit_lhs : cfg_visitor -> lhs -> lhs val visit_star_expr : cfg_visitor -> star_expr -> star_expr val visit_tuple : cfg_visitor -> tuple_expr -> tuple_expr val visit_rescue_guard : cfg_visitor -> rescue_guard -> rescue_guard val visit_class_kind : cfg_visitor -> class_kind -> class_kind val visit_def_name : cfg_visitor -> def_name -> def_name val visit_method_param : cfg_visitor -> method_formal_param -> method_formal_param (* Converts all instances of the local variable [var] to [sub] in the current scope of s. *) val alpha_convert_local : var:string -> sub:string -> stmt -> stmt val compute_cfg_locals : ?env:StrSet.t -> stmt -> unit (* A convenience module for easier construction of stmt nodes. All expression forms include an explicit row variable to prevent unnecessary coercions, optional forms are presented as optional arguments, and common use cases have a separate, simplified signature. *) module Abbr : sig val mcall : ?lhs:lhs -> ?targ:expr -> msg_id -> star_expr list -> ?cb:codeblock -> unit -> stmt val seq : stmt list -> pos2 -> stmt val exnblock : stmt -> rescue_block list -> ?eelse:stmt -> ?ensure:stmt -> pos2 -> stmt val yield : ?lhs:lhs -> ?args:star_expr list -> pos2 -> stmt val assign : lhs -> tuple_expr -> pos2 -> stmt val if_s : expr -> t:stmt -> f:stmt -> pos2 -> stmt val alias_g : link:builtin_or_global -> orig:builtin_or_global -> pos2 -> stmt val alias_m : link:msg_id -> orig:msg_id -> pos2 -> stmt val return : ?v:tuple_expr -> pos2 -> stmt val module_s : ?lhs:lhs -> identifier -> stmt -> pos2 -> stmt val local : string -> identifier val case : ?default:stmt -> expr -> (tuple_expr * stmt) list -> pos2 -> stmt val nameclass : ?lhs:lhs -> identifier -> ?inh:identifier -> stmt -> pos2 -> stmt val metaclass : ?lhs:lhs -> identifier -> stmt -> pos2 -> stmt val meth : ?targ:identifier -> def_name -> method_formal_param list -> stmt -> pos2 -> stmt val break : ?v:tuple_expr -> pos2 -> stmt val redo : pos2 -> stmt val retry : pos2 -> stmt val next : ?v:tuple_expr -> pos2 -> stmt val rblock : rescue_guard list -> stmt -> rescue_block val undef : msg_id list -> pos2 -> stmt val expr : expr -> pos2 -> stmt val defined : identifier -> stmt -> pos2 -> stmt val while_s : expr -> stmt -> pos2 -> stmt val for_s : block_formal_param list -> expr -> stmt -> pos2 -> stmt end
raw_level_repr.ml
type t = int32 type raw_level = t include (Compare.Int32 : Compare.S with type t := t) let encoding = Data_encoding.int32 let pp ppf level = Format.fprintf ppf "%ld" level let rpc_arg = let construct raw_level = Int32.to_string raw_level in let destruct str = match Int32.of_string str with | exception _ -> Error "Cannot parse level" | raw_level -> Ok raw_level in RPC_arg.make ~descr:"A level integer" ~name: "block_level" ~construct ~destruct () let root = 0l let succ = Int32.succ let pred l = if l = 0l then None else Some (Int32.pred l) let diff = Int32.sub let to_int32 l = l let of_int32_exn l = if Compare.Int32.(l >= 0l) then l else invalid_arg "Level_repr.of_int32" type error += Unexpected_level of Int32.t (* `Permanent *) let () = register_error_kind `Permanent ~id:"unexpected_level" ~title:"Unexpected level" ~description:"Level must be non-negative." ~pp:(fun ppf l -> Format.fprintf ppf "The level is %s but should be non-negative." (Int32.to_string l)) Data_encoding.(obj1 (req "level" int32)) (function Unexpected_level l -> Some l | _ -> None) (fun l -> Unexpected_level l) let of_int32 l = try Ok (of_int32_exn l) with _ -> Error [Unexpected_level l] module Index = struct type t = raw_level let path_length = 1 let to_path level l = Int32.to_string level :: l let of_path = function | [s] -> begin try Some (Int32.of_string s) with _ -> None end | _ -> None let rpc_arg = rpc_arg let encoding = encoding let compare = compare end
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
dune
;; The PPX-dependent executable under test (executable (name test_logs) (modules test_logs) (preprocess (pps ppx_irmin.internal)) (libraries fmt)) ;; Run the PPX on the `.ml` file (rule (targets pp.ml) (action (write-file %{targets} "let () = Ppxlib.Driver.standalone ()"))) (executable (name pp) (modules pp) (libraries ppx_irmin.internal ppxlib)) (rule (targets test_logs-processed.actual) (deps (:pp pp.exe) (:input test_logs.ml)) (action (run ./%{pp} -deriving-keep-w32 both --impl %{input} -o %{targets}))) ;; Compare the post-processed output to the .expected file (rule (alias runtest) (package ppx_irmin) (action (diff test_logs-processed.expected test_logs-processed.actual))) ;; Ensure that the post-processed executable runs correctly (rule (alias runtest) (targets test_logs-output.actual) (package ppx_irmin) (action (with-outputs-to %{targets} (run ./test_logs.exe)))) ;; Compare the output logs of the executable run to the .expected file (rule (alias runtest) (package ppx_irmin) (action (diff test_logs-output.expected test_logs-output.actual)))
fprint.c
#include "fq_zech_vec.h" #ifdef T #undef T #endif #define T fq_zech #define CAP_T FQ_ZECH #include "fq_vec_templates/fprint.c" #undef CAP_T #undef T
/* Copyright (C) 2013 Mike Hansen This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */
lwt_utils.mli
val never_ending : unit -> 'a Lwt.t (** [worker name ~on_event ~run ~cancel] internally calls [run ()] (which returns a promise [p]) and returns its own promise [work]. If [p] becomes fulfilled, then [work] also becomes fulfilled. If [p] becomes rejected then [cancel ()] is called and, once its promise is resolved, [work] is fulfilled. This gives the opportunity for the function [cancel] to clean-up some resources. The function [on_event] is called at different times (start, failure, end) and is mostly meant as a logging mechanism but can also be used for other purposes such as synchronization between different workers. If the promises returned by [on_event] or [cancel] raise an exception or become rejected, the exception/failure is simply ignored and the promise is treated as having resolved anyway. Note that the promise [work] returned by the [worker] function is not cancelable. If you need to cancel the promise returned by [run], you need to embed your own synchronization system within [run]. E.g., [let p, r = Lwt.wait in let run () = let main = … in Lwt.pick [main ; p] in] *) val worker : string -> on_event:(string -> [`Ended | `Failed of string | `Started] -> unit Lwt.t) -> run:(unit -> unit Lwt.t) -> cancel:(unit -> unit Lwt.t) -> unit Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* Copyright (c) 2018-2021 Nomadic Labs, <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
assignop.c
void foo() { var i; i += eval(1); }
dune
(library (name lev_fiber_csexp) (public_name lev-fiber-csexp) (libraries fiber csexp stdune dyn lev_fiber))
services_registration.ml
open Alpha_context type rpc_context = { block_hash : Block_hash.t; block_header : Block_header.shell_header; context : Alpha_context.t; } let rpc_init ({block_hash; block_header; context} : Updater.rpc_context) = let level = block_header.level in let timestamp = block_header.timestamp in let fitness = block_header.fitness in Alpha_context.prepare ~level ~predecessor_timestamp:timestamp ~timestamp ~fitness context >>=? fun context -> return {block_hash; block_header; context} let rpc_services = ref (RPC_directory.empty : Updater.rpc_context RPC_directory.t) let register0_fullctxt s f = rpc_services := RPC_directory.register !rpc_services s (fun ctxt q i -> rpc_init ctxt >>=? fun ctxt -> f ctxt q i) let opt_register0_fullctxt s f = rpc_services := RPC_directory.opt_register !rpc_services s (fun ctxt q i -> rpc_init ctxt >>=? fun ctxt -> f ctxt q i) let register0 s f = register0_fullctxt s (fun {context; _} -> f context) let register0_noctxt s f = rpc_services := RPC_directory.register !rpc_services s (fun _ q i -> f q i) let register1_fullctxt s f = rpc_services := RPC_directory.register !rpc_services s (fun (ctxt, arg) q i -> rpc_init ctxt >>=? fun ctxt -> f ctxt arg q i) let register1 s f = register1_fullctxt s (fun {context; _} x -> f context x) let register1_noctxt s f = rpc_services := RPC_directory.register !rpc_services s (fun (_, arg) q i -> f arg q i) let register2_fullctxt s f = rpc_services := RPC_directory.register !rpc_services s (fun ((ctxt, arg1), arg2) q i -> rpc_init ctxt >>=? fun ctxt -> f ctxt arg1 arg2 q i) let register2 s f = register2_fullctxt s (fun {context; _} a1 a2 q i -> f context a1 a2 q i) let get_rpc_services () = let p = RPC_directory.map (fun c -> rpc_init c >>= function Error _ -> assert false | Ok c -> Lwt.return c.context) (Storage_description.build_directory Alpha_context.description) in RPC_directory.register_dynamic_directory !rpc_services RPC_path.(open_root / "context" / "raw" / "json") (fun _ -> Lwt.return p)
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
gntmap.c
#include <mini-os/os.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h> #include <errno.h> #include <xen/grant_table.h> #include <inttypes.h> #include <mini-os/gntmap.h> //#define GNTMAP_DEBUG #ifdef GNTMAP_DEBUG #define DEBUG(_f, _a...) \ printk("MINI_OS(gntmap.c:%d): %s" _f "\n", __LINE__, __func__, ## _a) #else #define DEBUG(_f, _a...) ((void)0) #endif #define DEFAULT_MAX_GRANTS 128 struct gntmap_entry { unsigned long host_addr; grant_handle_t handle; }; static inline int gntmap_entry_used(struct gntmap_entry *entry) { return entry->host_addr != 0; } static struct gntmap_entry* gntmap_find_free_entry(struct gntmap *map) { int i; for (i = 0; i < map->nentries; i++) { if (!gntmap_entry_used(&map->entries[i])) return &map->entries[i]; } DEBUG("(map=%p): all %d entries full", map, map->nentries); return NULL; } static struct gntmap_entry* gntmap_find_entry(struct gntmap *map, unsigned long addr) { int i; for (i = 0; i < map->nentries; i++) { if (map->entries[i].host_addr == addr) return &map->entries[i]; } return NULL; } int gntmap_set_max_grants(struct gntmap *map, int count) { DEBUG("(map=%p, count=%d)", map, count); if (map->nentries != 0) return -EBUSY; map->entries = xmalloc_array(struct gntmap_entry, count); if (map->entries == NULL) return -ENOMEM; memset(map->entries, 0, sizeof(struct gntmap_entry) * count); map->nentries = count; return 0; } static int _gntmap_map_grant_ref(struct gntmap_entry *entry, unsigned long host_addr, uint32_t domid, uint32_t ref, int writable) { struct gnttab_map_grant_ref op; int rc; op.ref = (grant_ref_t) ref; op.dom = (domid_t) domid; op.host_addr = (uint64_t) host_addr; op.flags = GNTMAP_host_map; if (!writable) op.flags |= GNTMAP_readonly; rc = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1); if (rc != 0 || op.status != GNTST_okay) { printk("GNTTABOP_map_grant_ref failed: " "returned %d, status %" PRId16 "\n", rc, op.status); return rc != 0 ? rc : op.status; } entry->host_addr = host_addr; entry->handle = op.handle; return 0; } static int _gntmap_unmap_grant_ref(struct gntmap_entry *entry) { struct gnttab_unmap_grant_ref op; int rc; op.host_addr = (uint64_t) entry->host_addr; op.dev_bus_addr = 0; op.handle = entry->handle; rc = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1); if (rc != 0 || op.status != GNTST_okay) { printk("GNTTABOP_unmap_grant_ref failed: " "returned %d, status %" PRId16 "\n", rc, op.status); return rc != 0 ? rc : op.status; } entry->host_addr = 0; return 0; } int gntmap_munmap(struct gntmap *map, unsigned long start_address, int count) { int i, rc; struct gntmap_entry *ent; DEBUG("(map=%p, start_address=%lx, count=%d)", map, start_address, count); for (i = 0; i < count; i++) { ent = gntmap_find_entry(map, start_address + PAGE_SIZE * i); if (ent == NULL) { printk("gntmap: tried to munmap unknown page\n"); return -EINVAL; } rc = _gntmap_unmap_grant_ref(ent); if (rc != 0) return rc; } return 0; } void* gntmap_map_grant_refs(struct gntmap *map, uint32_t count, uint32_t *domids, int domids_stride, uint32_t *refs, int writable) { unsigned long addr; struct gntmap_entry *ent; int i; DEBUG("(map=%p, count=%" PRIu32 ", " "domids=%p [%" PRIu32 "...], domids_stride=%d, " "refs=%p [%" PRIu32 "...], writable=%d)", map, count, domids, domids == NULL ? 0 : domids[0], domids_stride, refs, refs == NULL ? 0 : refs[0], writable); (void) gntmap_set_max_grants(map, DEFAULT_MAX_GRANTS); addr = allocate_ondemand((unsigned long) count, 1); if (addr == 0) return NULL; for (i = 0; i < count; i++) { ent = gntmap_find_free_entry(map); if (ent == NULL || _gntmap_map_grant_ref(ent, #ifdef __arm__ to_phys(addr + PAGE_SIZE * i), #else addr + PAGE_SIZE * i, #endif domids[i * domids_stride], refs[i], writable) != 0) { (void) gntmap_munmap(map, addr, i); return NULL; } } return (void*) addr; } void gntmap_init(struct gntmap *map) { DEBUG("(map=%p)", map); map->nentries = 0; map->entries = NULL; } void gntmap_fini(struct gntmap *map) { struct gntmap_entry *ent; int i; DEBUG("(map=%p)", map); for (i = 0; i < map->nentries; i++) { ent = &map->entries[i]; if (gntmap_entry_used(ent)) (void) _gntmap_unmap_grant_ref(ent); } xfree(map->entries); map->entries = NULL; map->nentries = 0; }
/* * Manages grant mappings from other domains. * * Diego Ongaro <diego.ongaro@citrix.com>, July 2008 * * Files of type FTYPE_GNTMAP contain a gntmap, which is an array of * (host address, grant handle) pairs. Grant handles come from a hypervisor map * operation and are needed for the corresponding unmap. * * This is a rather naive implementation in terms of performance. If we start * using it frequently, there's definitely some low-hanging fruit here. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */
set.mli
module type OrderedType = sig type t val compare : t -> t -> int end module type S = sig type elt type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val disjoint : t -> t -> bool val diff : t -> t -> t val compare : t -> t -> int val equal : t -> t -> bool val subset : t -> t -> bool val iter : (elt -> unit) -> t -> unit val map : (elt -> elt) -> t -> t val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a val for_all : (elt -> bool) -> t -> bool val exists : (elt -> bool) -> t -> bool val filter : (elt -> bool) -> t -> t val partition : (elt -> bool) -> t -> (t * t) val cardinal : t -> int val elements : t -> elt list val min_elt : t -> elt val min_elt_opt : t -> elt option val max_elt : t -> elt val max_elt_opt : t -> elt option val choose : t -> elt val choose_opt : t -> elt option val split : elt -> t -> (t * bool * t) val find : elt -> t -> elt val find_opt : elt -> t -> elt option val find_first : (elt -> bool) -> t -> elt val find_first_opt : (elt -> bool) -> t -> elt option val find_last : (elt -> bool) -> t -> elt val find_last_opt : (elt -> bool) -> t -> elt option val of_list : elt list -> t val to_seq_from : elt -> t -> elt Seq.t val to_seq : t -> elt Seq.t val add_seq : elt Seq.t -> t -> t val of_seq : elt Seq.t -> t end module Make : functor (Ord : OrderedType) -> sig type elt = Ord.t type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val disjoint : t -> t -> bool val diff : t -> t -> t val compare : t -> t -> int val equal : t -> t -> bool val subset : t -> t -> bool val iter : (elt -> unit) -> t -> unit val map : (elt -> elt) -> t -> t val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a val for_all : (elt -> bool) -> t -> bool val exists : (elt -> bool) -> t -> bool val filter : (elt -> bool) -> t -> t val partition : (elt -> bool) -> t -> (t * t) val cardinal : t -> int val elements : t -> elt list val min_elt : t -> elt val min_elt_opt : t -> elt option val max_elt : t -> elt val max_elt_opt : t -> elt option val choose : t -> elt val choose_opt : t -> elt option val split : elt -> t -> (t * bool * t) val find : elt -> t -> elt val find_opt : elt -> t -> elt option val find_first : (elt -> bool) -> t -> elt val find_first_opt : (elt -> bool) -> t -> elt option val find_last : (elt -> bool) -> t -> elt val find_last_opt : (elt -> bool) -> t -> elt option val of_list : elt list -> t val to_seq_from : elt -> t -> elt Seq.t val to_seq : t -> elt Seq.t val add_seq : elt Seq.t -> t -> t val of_seq : elt Seq.t -> t end
public_lib.ml
let x = 1
dune
(executable (name multipart_httpaf) (modules multipart_httpaf) (libraries http-multipart-formdata lwt lwt.unix httpaf httpaf-lwt-unix) (preprocess (pps ppx_deriving.show ppx_deriving.ord)))
commitment_storage.mli
val init: Raw_context.t -> Commitment_repr.t list -> Raw_context.t tzresult Lwt.t val get_opt: Raw_context.t -> Blinded_public_key_hash.t -> Tez_repr.t option tzresult Lwt.t val delete: Raw_context.t -> Blinded_public_key_hash.t -> Raw_context.t tzresult Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
flags.ml
open Util type t = int (* From RFC7540§6.2: * Flags that have no defined semantics for a particular frame type MUST be * ignored and MUST be left unset (0x0) when sending. *) let default_flags = 0x0 (* From RFC7540§6.2: * END_STREAM (0x1): When set, bit 0 indicates that the header block (Section * 4.3) is the last that the endpoint will send for the identified stream. *) let test_end_stream x = test_bit x 0 let set_end_stream x = set_bit x 0 let clear_end_stream x = clear_bit x 0 (* From RFC7540§6.7: * ACK (0x1): When set, bit 0 indicates that this PING frame is a PING * response. *) let test_ack x = test_bit x 0 let set_ack x = set_bit x 0 (* From RFC7540§6.2: * END_HEADERS (0x4): When set, bit 2 indicates that this frame contains an * entire header block (Section 4.3) and is not followed by any CONTINUATION * frames. *) let test_end_header x = test_bit x 2 let set_end_header x = set_bit x 2 (* From RFC7540§6.2: * PADDED (0x8): When set, bit 3 indicates that the Pad Length field and any * padding that it describes are present. *) let test_padded x = test_bit x 3 let set_padded x = set_bit x 3 (* From RFC7540§6.2: * PRIORITY (0x20): When set, bit 5 indicates that the Exclusive Flag (E), * Stream Dependency, and Weight fields are present; see Section 5.3. *) let test_priority x = test_bit x 5 let set_priority x = set_bit x 5
(*---------------------------------------------------------------------------- * Copyright (c) 2019 António Nuno Monteiro * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*)
parameters_repr.mli
(** This module defines protocol parameters, i.e. constants regulating the behaviour of the blockchain under the protocol. *) (** An implict contract (account) initially existing on a chain since genesis. *) type bootstrap_account = { public_key_hash : Signature.Public_key_hash.t; public_key : Signature.Public_key.t option; amount : Tez_repr.t; } (** An originated contract initially existing on a chain since genesis. *) type bootstrap_contract = { delegate : Signature.Public_key_hash.t option; amount : Tez_repr.t; script : Script_repr.t; } (** Protocol parameters define some constants regulating behaviour of the chain. *) type t = { bootstrap_accounts : bootstrap_account list; bootstrap_contracts : bootstrap_contract list; commitments : Commitment_repr.t list; constants : Constants_repr.parametric; security_deposit_ramp_up_cycles : int option; no_reward_cycles : int option; } val encoding : t Data_encoding.t val check_params : t -> unit tzresult
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
lwt_tester.mli
(** {2 Lwt version of Exenum.tester } *) (** Note that [tester] does not comply with non-lwt exceptions: some exceptions may get lost. @param verbose_period A message is printed every [verbose_period] tests. @param tos Function used to print values of the enumeration. @param len [len] consecutive values are enumerated, then the index is doubled (and we loop) @param upto By default, the tests go on forever. *) val tester : 'a Exenum.t -> ?from:Z.t -> ?upto:Z.t -> ?verbose_period:int -> ?tos:('a -> string) -> len:int -> ('a -> unit Lwt.t) -> unit Lwt.t
(** {2 Lwt version of Exenum.tester } *)
windows_get_page_size.c
/* This file is part of Lwt, released under the MIT license. See LICENSE.md for details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. */ #include "lwt_config.h" #if defined(LWT_ON_WINDOWS) #include <caml/mlvalues.h> #include <caml/unixsupport.h> CAMLprim value lwt_unix_get_page_size(value Unit) { SYSTEM_INFO si; GetSystemInfo(&si); return Val_long(si.dwPageSize); } #endif
/* This file is part of Lwt, released under the MIT license. See LICENSE.md for details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. */
conback.mli
module type ACTIVATIONS = sig (** Event channels handlers. *) type event (** identifies the an event notification received from xen *) val program_start: event (** represents an event which 'fired' when the program started *) val after: Eventchn.t -> event -> event Lwt.t (** [next channel event] blocks until the system receives an event newer than [event] on channel [channel]. If an event is received while we aren't looking then this will be remembered and the next call to [after] will immediately unblock. If the system is suspended and then resumed, all event channel bindings are invalidated and this function will fail with Generation.Invalid *) end type stats = { mutable total_read: int; (** bytes read *) mutable total_write: int; (** bytes written *) } module type CONSOLE = sig include Mirage_console_lwt.S val connect: string -> t Lwt.t end module Make(A: ACTIVATIONS)(X: Xs_client_lwt.S)(C: CONSOLE): sig val exists: X.client -> string -> bool Lwt.t val request_close: string -> int * int -> unit Lwt.t val force_close: int * int -> unit Lwt.t val run: string -> string -> int * int -> stats Lwt.t val destroy: string -> int * int -> unit Lwt.t val create: ?backend_domid:int -> ?name:string -> string -> int * int -> unit Lwt.t end
(* * Copyright (c) 2010-2011 Anil Madhavapeddy <anil@recoil.org> * Copyright (c) 2012-14 Citrix Systems Inc * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
value0.mli
(** This module exists to break the dependency between [Value] and [Callback]. *) open! Core open! Import type t [@@deriving sexp_of] val sexp_of_t_ref : (t -> Sexp.t) ref
(** This module exists to break the dependency between [Value] and [Callback]. *)
t-mul_ui.c
#include "arf.h" #include "flint/ulong_extras.h" int arf_mul_ui_naive(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) { arf_t t; int r; arf_init(t); arf_set_ui(t, y); r = arf_mul(z, x, t, prec, rnd); arf_clear(t); return r; } int main() { slong iter, iter2; flint_rand_t state; flint_printf("mul_ui...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) { arf_t x, z, v; ulong y; slong prec, r1, r2; arf_rnd_t rnd; arf_init(x); arf_init(z); arf_init(v); for (iter2 = 0; iter2 < 100; iter2++) { arf_randtest_special(x, state, 2000, 10); y = n_randtest(state); prec = 2 + n_randint(state, 2000); if (n_randint(state, 10) == 0) prec = ARF_PREC_EXACT; switch (n_randint(state, 5)) { case 0: rnd = ARF_RND_DOWN; break; case 1: rnd = ARF_RND_UP; break; case 2: rnd = ARF_RND_FLOOR; break; case 3: rnd = ARF_RND_CEIL; break; default: rnd = ARF_RND_NEAR; break; } switch (n_randint(state, 2)) { case 0: r1 = arf_mul_ui(z, x, y, prec, rnd); r2 = arf_mul_ui_naive(v, x, y, prec, rnd); if (!arf_equal(z, v) || r1 != r2) { flint_printf("FAIL!\n"); flint_printf("prec = %wd, rnd = %d\n\n", prec, rnd); flint_printf("x = "); arf_print(x); flint_printf("\n\n"); flint_printf("y = "); flint_printf("%wd", y); flint_printf("\n\n"); flint_printf("z = "); arf_print(z); flint_printf("\n\n"); flint_printf("v = "); arf_print(v); flint_printf("\n\n"); flint_printf("r1 = %wd, r2 = %wd\n", r1, r2); flint_abort(); } break; default: r2 = arf_mul_ui_naive(v, x, y, prec, rnd); r1 = arf_mul_ui(x, x, y, prec, rnd); if (!arf_equal(x, v) || r1 != r2) { flint_printf("FAIL (aliasing)!\n"); flint_printf("prec = %wd, rnd = %d\n\n", prec, rnd); flint_printf("x = "); arf_print(x); flint_printf("\n\n"); flint_printf("y = "); flint_printf("%wd", y); flint_printf("\n\n"); flint_printf("v = "); arf_print(v); flint_printf("\n\n"); flint_printf("r1 = %wd, r2 = %wd\n", r1, r2); flint_abort(); } break; } } arf_clear(x); arf_clear(z); arf_clear(v); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
/* Copyright (C) 2012 Fredrik Johansson This file is part of Arb. Arb is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <http://www.gnu.org/licenses/>. */
csr.ml
open Cmdliner open Common let org = let doc = "Organization name for the certificate signing request." in Arg.(required & pos ~rev:false 1 (some string) None & info [] ~doc ~docv:"O") let certfile = let doc = "Filename to which to save the completed certificate-signing request." in Arg.(value & opt string "csr.pem" & info ["c"; "certificate"; "csr"; "out"] ~doc) let csr org cn bits certfile keyfile = Mirage_crypto_rng_unix.initialize (); let privkey = `RSA (Mirage_crypto_pk.Rsa.generate ~bits ()) in let dn = X509.Distinguished_name.[ Relative_distinguished_name.(singleton (CN cn)) ; Relative_distinguished_name.(singleton (O org)) ; ] in match X509.Signing_request.create dn privkey with | Error _ as e -> e | Ok csr -> let csr_pem = X509.Signing_request.encode_pem csr in let key_pem = X509.Private_key.encode_pem privkey in match (write_pem certfile csr_pem, write_pem keyfile key_pem) with | Ok (), Ok () -> Ok () | Error str, _ | _, Error str -> Error str let csr_t = Term.(term_result (pure csr $ org $ common_name $ length $ certfile $ keyfile)) let csr_info = let doc = "generate a certificate-signing request" in let man = [ `S "BUGS"; `P "Submit bugs at https://github.com/yomimono/ocaml-certify";] in Term.info "csr" ~doc ~man
sinsemilla_zcash_generators.ml
open Pallas let generators_zcash_coordinates = [| ( Hex.to_bytes (`Hex "5fea442091eb915ab562debeaf5ba0297bfc4a7dead431140f1f88e68b21b50d"), Hex.to_bytes (`Hex "83648ebf764fc21701ba652e1c044a94d0d593842966af9c1ca052f1c2400f2f") ); ( Hex.to_bytes (`Hex "91af08a13ee34ace8f9b6424ca0077e604541739eb33fdc81895e1b3b4121121"), Hex.to_bytes (`Hex "eec510f893c2831dbc190e674a743cb4fe355acd793e8aa33bb0ad933999c506") ); ( Hex.to_bytes (`Hex "246d8fa175c4e022c011544b33b30cf4339b5b35e2a46146a325f949cd2cb325"), Hex.to_bytes (`Hex "5797fdb88d6b7da6d2cc45f9b9ebe14b1147b423f3d0537d2c69d070baf20f14") ); ( Hex.to_bytes (`Hex "bcda19040feffaa526188b9312ca39651f702cd05c46ff60c93218e1485a2114"), Hex.to_bytes (`Hex "dc36ca25365d1d0156ade2534b3bb697bd03580bb9a011c74d88cbbe57696610") ); ( Hex.to_bytes (`Hex "3609ed4bf6ce48cdce6138f7528b940e9f053fd295b5b99a1c15639e3bf95c31"), Hex.to_bytes (`Hex "1a721ca3847657e21da570c08613ef81ca7843d0529afb2a40adfb8db3c0542c") ); ( Hex.to_bytes (`Hex "df3f5aaa6296621e9b38319ddc57fb94b73a6cbe2e54c563c55e927ea551741d"), Hex.to_bytes (`Hex "4b45caaac81d4c93ddc0ef4e8c0486c0bc6f4b1672149cc4c77e479339514b0a") ); ( Hex.to_bytes (`Hex "8f1144acbdce7c7e1cff29842f2755e0245fa724f8b5803c6846d410743c3d0d"), Hex.to_bytes (`Hex "cc5522b51bb2ea7982094fdec0616812e95aa52386312ea04f33589712e7942b") ); ( Hex.to_bytes (`Hex "2f9d12d73e38770e189b0f4b71df83622c0666d67c616408570b9174bafa7e19"), Hex.to_bytes (`Hex "27c1fd12cbe2b885cd4527deb575887a1bd399ed976af58da956e9d64755d934") ); ( Hex.to_bytes (`Hex "55b0246b92d21cd28e414672077a16a4479b54efab11293e66ee1cb1e8d05a30"), Hex.to_bytes (`Hex "38b9bfa5cf73399bd68038d1a50ca212a434b7c342120782d8bfbb6d0291253e") ); ( Hex.to_bytes (`Hex "be56486b62e3bcf68434665bf1e65edf613e6647f1bd37bc1f77ccae20ed802a"), Hex.to_bytes (`Hex "53d7d940cd58afaeeb44a939a1817667aed180d0204278db73c8892f539fed3b") ); ( Hex.to_bytes (`Hex "343be7691c356da932b474bb2ce6dfe5093963c586f80b3e520f6b519d676911"), Hex.to_bytes (`Hex "ee52563a48267f441239e8afb303d877d34f8f9879a71ebe5df8ef46d858dc24") ); ( Hex.to_bytes (`Hex "305087bc2ec61d8565573c700c51571992c9ae3ae88d39d4cbd1e0e06451640a"), Hex.to_bytes (`Hex "6d93a61a4c4968d7a4c248a5eed7890cb1767899b7871f7e82f179383db63f15") ); ( Hex.to_bytes (`Hex "3934a842190665c5f23d3a197cf516770aea7a8de1b0251301768ba65317a905"), Hex.to_bytes (`Hex "3cd4bd26162343245f57f2a364e79f954e149997406a09d708957e3430c6291c") ); ( Hex.to_bytes (`Hex "2ae71114466f43e8592a497234401a2c91b68a938d0a47134435c9ceb534e325"), Hex.to_bytes (`Hex "3d4bad9c33d2c5ceab45cca461070da4b284802d50d24c1974245961db646001") ); ( Hex.to_bytes (`Hex "c95c3725b565f0e2ab25888c87592825666a9dbcc13152927e9c90c1d02b9c37"), Hex.to_bytes (`Hex "30947563a7effba0f083737b411e0e43406ef3663a12eadd1b9fd59954c2a911") ); ( Hex.to_bytes (`Hex "aaed2e861e9e5a0bc661ff618243a3c0a1f30148dcf6414b826f65d3b2c76f0c"), Hex.to_bytes (`Hex "b53b603ee8500df35f8e547d78b49f58eb0eead132b0d5068efedc966da79224") ); ( Hex.to_bytes (`Hex "d9e54f3a694d19072270ed5cd6cef4c3b7e6eef9c3c56519040eb53b455d170c"), Hex.to_bytes (`Hex "9a97a8025ce6286ec21e3a21b2bd55918aa01bacd25d92a59029012d4f3d6e10") ); ( Hex.to_bytes (`Hex "0a6d8f716957f52a809c3ddb3501cc0a055e1393959df83155b1ed20e3eae526"), Hex.to_bytes (`Hex "c9d15fb9eefd5bd774538c810aa8631e40c00b0fe6c3b14b0c4b14cd2a88051d") ); ( Hex.to_bytes (`Hex "945b395ef290c37e49a58fc655073042070481af33971092d900eb14d7600d31"), Hex.to_bytes (`Hex "0a651044cb4304ce43ef00f95340c0b1dd1f1293a3e787405ceccecd9e55e23e") ); ( Hex.to_bytes (`Hex "43eb09c7bbb2a0a2240618bfea17de8a8781ac1ee5ce3dbe8dacec0981041917"), Hex.to_bytes (`Hex "5ba015cc3a97bc2a3a190a570bdfa850441d0e4f98e0f187c5f8feb9c53a6712") ); ( Hex.to_bytes (`Hex "6933586dfed061b4879282c90f11bcccf0a5262647da6302c619379c22d28912"), Hex.to_bytes (`Hex "126269f809d1847f7ef3c9603584b6e7aab9a3a8a326abc9441eadd4e9e5a708") ); ( Hex.to_bytes (`Hex "fbcfa6670ed757d663d6d8f57a8fc21bddac2e5e97cb6c172a221ca9f148dc08"), Hex.to_bytes (`Hex "8c12b640eb0caac617a270c2e59ea1943a08f4a114f1799fd0b355aa4109f421") ); ( Hex.to_bytes (`Hex "c1c2137103e7c68421f52c5e9a5a49955eb8c81ba2c09dae022d7f250978de2b"), Hex.to_bytes (`Hex "f9d24e31a6c014a16f877e3d08e6e79b2afd29d9236805c1bd50e2832a6dac15") ); ( Hex.to_bytes (`Hex "0b3421a4d59ffeb026cd9e3c71f1e448bc954a3d71acf4e433d0b51a28612b31"), Hex.to_bytes (`Hex "9c5ddbaf00d45b4090936bef9080ebaadd533ce2b3c0697459455db0bf214f2e") ); ( Hex.to_bytes (`Hex "842e12762bd8bfa0272d48b50aca786c1debaf625356ae7508ead48b7f3b9b08"), Hex.to_bytes (`Hex "792570c63438ca7f58625d08d23162a034eb82d736682fb3c410ae3531e80837") ); ( Hex.to_bytes (`Hex "fec7056c14c06d9f5fa67cd6b5b3191154fee6f72e6dbf454f3eb69aac084101"), Hex.to_bytes (`Hex "73d114a5e736f957f2a33e28b8a94e3ddfd856bfbe9b450bcec3176483be9600") ); ( Hex.to_bytes (`Hex "101e0aa66e7e84bff78aa159a90d7d006ef25d80396f669b98470dc7b1a8da2d"), Hex.to_bytes (`Hex "15320421a1e4fa8a5f435c661d2845fcd6d0a497235d42cf16e44435e4d53b20") ); ( Hex.to_bytes (`Hex "91b969c742a35563a5fba87c613594af7c86c61b5319c69b848ce97cb2b4c635"), Hex.to_bytes (`Hex "e2d005aaf2528b35a711691004f4361e5e9212f55d77b1df60568528ff4c0e2f") ); ( Hex.to_bytes (`Hex "4f399d65aa45c69bc252f5afd5f9fb63df0d7d15f9a1812add1b2b796d8d4008"), Hex.to_bytes (`Hex "ed6f42a4e0c91462b04ddcb2c12d0c58918b077ce67c6edf07580aaac7869b14") ); ( Hex.to_bytes (`Hex "5dd16a0120fb6623a292be3209a5117edb854dd3903c46dfaeddfb3724357d3b"), Hex.to_bytes (`Hex "2c3be7e2a27801d717fdbb49607a76eb048518715a0c81a08aac317a14dae130") ); ( Hex.to_bytes (`Hex "e205a379c31c6c99dff97fdaa735d961fed1840e503c7ee709c0dfc198609d11"), Hex.to_bytes (`Hex "89adac0bf6683ce8ea8a337f6b5fe4e3110a0327b7ed02cbd237a0c7d8fcfe0d") ); ( Hex.to_bytes (`Hex "3f2ec1c0efe149020e141bfc50f735fda4240aee25fdcc3436e9501437ea852d"), Hex.to_bytes (`Hex "a6c67670877e03ea989a81714a05861eddff55de670ab2c8ad6e60c5dcf1a02f") ); ( Hex.to_bytes (`Hex "2a14698258409d147e0ccd8799867ec460c2e84ce4848390513def99eccc650d"), Hex.to_bytes (`Hex "5cbb951bcebe9f3dce60125bea8769732c3c99e043ccc5693d5eb2bc05289612") ); ( Hex.to_bytes (`Hex "f67057f8ac790ffdf258873bd05aad2c87f03a95ba4e9dd76303d8628c777400"), Hex.to_bytes (`Hex "b204b775bd43534d6cbd9f38df6469fb14c4f136514f9909854ecbc6aef47607") ); ( Hex.to_bytes (`Hex "c49dac8c6eb107226502c3926424cc6f45b8f4140ae0051f72e804c2bed4a901"), Hex.to_bytes (`Hex "a881fb24ae6983f76799ae38a2a841f70db3aefa85080844e618b9491f7ff703") ); ( Hex.to_bytes (`Hex "01c14bfd83e073ad7f193bca06c699b20665a80b0000c861764fb5c4f3359116"), Hex.to_bytes (`Hex "8ce292ebce5860872d0e6cf8e016f034503f7bc45e49b086ff85c5c42bc4f103") ); ( Hex.to_bytes (`Hex "8c79ab2cb7947d0123f5aa185bcb6d8d0bc294895d8b088e13fe35e678e1ba19"), Hex.to_bytes (`Hex "19014a99b48427ab337e5c630efea49dc4afa2ca12814311e7c4d9de94dacf3a") ); ( Hex.to_bytes (`Hex "bc557a3108cbcebbe6f03832cdddaa361ed6abe6b60500df7c083d054ec62725"), Hex.to_bytes (`Hex "ef683a03ee48e86be1cef4d4acf9a355bf2865d4ce57ddf696cc09b57dea271e") ); ( Hex.to_bytes (`Hex "80421695d912bce5f65d2551c20d002a82d84c164b9236a949cea8328a35a934"), Hex.to_bytes (`Hex "a2accbdfe477e86021a5f825883ea50a98f0dd83c56c25e3b8cda35a5cfcdb3b") ); ( Hex.to_bytes (`Hex "d8163deaeaf7956d8353d66b9a4ec00383b2fec417bb05ec073b1feda5039e28"), Hex.to_bytes (`Hex "8676b1fe2fc56a2b4889494e92dab7bcd3db4dd081cd95a94a225911576c460c") ); ( Hex.to_bytes (`Hex "0c9fd2a4e79b9360a20a99b7a2621815c28ce71c2ce6a344f3e57d42ea251e20"), Hex.to_bytes (`Hex "4f6bff27e95e535826719295b3b5baa981561ee60807602c6d02a737f668d431") ); ( Hex.to_bytes (`Hex "b327f932da2bec9787ed61c3389f797e88fa01d60bac8f58fe274d7336775f27"), Hex.to_bytes (`Hex "b9d945c5278a2664eb0123c43da2a0461cc8cfdc4ce07dac99b4128378473030") ); ( Hex.to_bytes (`Hex "2880153246a19194abe10164c2c963ee7b84e6e39c138fe62f84ca9a03e8e90c"), Hex.to_bytes (`Hex "0946c725d1049de0adf85ec0d0bb7037679569a1888c8bdde4a627f11239992d") ); ( Hex.to_bytes (`Hex "08dd636f595431e5c09fa110fe13a0f740a074acdc76b4d73f783f2fbf75a008"), Hex.to_bytes (`Hex "00b2d2800932621977197f5fb6e1a63d359cdbf2bf4d6861049281b3f54b213c") ); ( Hex.to_bytes (`Hex "9d8e05e38d69fc46530e8be5297482ede830d865b52a3bff501e256f8e89e62e"), Hex.to_bytes (`Hex "9e7f78b76516ea2f83909e3352eb4ca8f69b0669092832fca49544d27075a022") ); ( Hex.to_bytes (`Hex "50938d0230142e8bc02686bffb41ada9a7b4630a9867ffecd2ab840d0b64ec38"), Hex.to_bytes (`Hex "c4ddd99f9d2417da132c18a3425d623862a27753684cb074ed8050ababc8611e") ); ( Hex.to_bytes (`Hex "8cdb929df43b6392c3fcd612027e425b689c993c5b2b0cd235366d73a846a734"), Hex.to_bytes (`Hex "2073c09ff19a4c48c2ddb04e044c6223733b4d851435e8273bc7a77ce8166430") ); ( Hex.to_bytes (`Hex "6b3545cc0d11d432ae0703fc5e7ff4488396fff32b0e53785f2e05daab91d636"), Hex.to_bytes (`Hex "2eff025377dadbbe247079f217594c4af5d7e3021c7f890ae4a04f61f3b0ac01") ); ( Hex.to_bytes (`Hex "ffd846f0c024d34eb454bc41ca1a1fd850589331fd703d630ea9989303eb152f"), Hex.to_bytes (`Hex "c937f75a9944bee7e72c33031b913c07da2dfff5ed25a66edfd32d09f6639002") ); ( Hex.to_bytes (`Hex "c1c692700b26f21524248b67e336fd0090323d40d5366314bea6dda820d6cc26"), Hex.to_bytes (`Hex "f65b3cd9f805d6249408ca75901450be1811834143d5ea7014e561be93427e19") ); ( Hex.to_bytes (`Hex "5644735c7132509b1f8829b3cf79ff2a05237786f727ad20546284009cdfb21f"), Hex.to_bytes (`Hex "8fd23c631c5026d77e1dc787bde975eedca37a3dd1ffa0e5ed9aab8a182a0135") ); ( Hex.to_bytes (`Hex "38a02517b73be3a5ecca26d1fa446f1a113c6b8b7b0c82c6924f4bf2871a691e"), Hex.to_bytes (`Hex "42ce8dcd4fcf4bef8a0c175af961d49e337b3ecc1a455b88b495b0ffc94de017") ); ( Hex.to_bytes (`Hex "32e0f01adea434e129aa65fdcaab5560f62963750fbd0981a69bcd6f0c2e923d"), Hex.to_bytes (`Hex "ed4901c9ffb51da5da443abe3c228688f163c78b830df39c9ad0765561dcd623") ); ( Hex.to_bytes (`Hex "0c992a2b6e83e279b97e4f43030f2d98abd56ce77fb4d28b0290ce02d5a36015"), Hex.to_bytes (`Hex "38f5f6791d70ca38a75c5a26a2156a0edb3c8acebdbb4169c2715d72bdbced22") ); ( Hex.to_bytes (`Hex "cc172b9bb44262eb08b7b3cfbfc045dc3e3f1afdab71e91ad5f916616a925038"), Hex.to_bytes (`Hex "3a1ad599f92246dbf31e98731826cddd9438d1b30885b53b676aeea7e86e0120") ); ( Hex.to_bytes (`Hex "20a64dbabffde740cef9e32230b956f0257334e749eeb802e38dbce161f56f1d"), Hex.to_bytes (`Hex "9d3689817a024eb81d036607da75f222ecf270c18716e54fd117e13969c02a3b") ); ( Hex.to_bytes (`Hex "0cb2ef79eb1e07621a6b6f9c0101390e3d086308d4b29aad0c438ed9a60dbb24"), Hex.to_bytes (`Hex "8427285352758edc235e9a386bd3f097b49bdf4dec2759df404d27f8780b5f20") ); ( Hex.to_bytes (`Hex "ce430d68f696cd01ef5689b581e9d1eab659d3618f196c7cabca8ea22c658e2f"), Hex.to_bytes (`Hex "f00f4af3c8e593f8270e204532cb0ac7c66d29aeea36c6f88944671dc1822823") ); ( Hex.to_bytes (`Hex "7f2abe68482c8ed485377ce9243176fd765a6228a0179424b66b1458398edb1a"), Hex.to_bytes (`Hex "7122d83333a9b2c5ebcc8d031f1034c2abef609f90b6f31471a705ba97deba27") ); ( Hex.to_bytes (`Hex "415354a414a8813787dbb08d114f39a8e20408444093895f185081a5f27ac232"), Hex.to_bytes (`Hex "2145d8530a477250194d78f826f4caf314a3030d07fcc759152a2ad88147c905") ); ( Hex.to_bytes (`Hex "5c0e21700582d180fdc305bb749dc1c332dc5d797209d7b4f21fb09058d80317"), Hex.to_bytes (`Hex "1c8f5bd930baa14806231dcf720cf0d8529a28314cceac1312df46f04b5f183e") ); ( Hex.to_bytes (`Hex "ce5abe15df75e56f250b467780ad1f2c80e5ff95918db91f7403f6256bf8d225"), Hex.to_bytes (`Hex "4da0aaad9bdd6de50c3d3d1052543a440fc3012b54e38f26ecb636c0afd00a36") ); ( Hex.to_bytes (`Hex "23df58731932bed54d9bc0656c6ccd3612f23a7d9dca86283ff87f2c00c1d00a"), Hex.to_bytes (`Hex "30ea68c280365c96bd7a8fc7881cc29081b42ed3fd7dbdadc89c7efe873f323e") ); ( Hex.to_bytes (`Hex "c965bcbcf7c427a995da6c35b4546bb16a94a1c0ce217d46f3fca88b7a7a943a"), Hex.to_bytes (`Hex "2b806b2e2fc8d56a8cdafa9a225b3421d5a19cfabb908ffcfb1cf43e235d6017") ); ( Hex.to_bytes (`Hex "ffb6f88436475b7426f2287de672a72f123d580a1c285c7f3a2e063974b90121"), Hex.to_bytes (`Hex "623a4ecf091116e642189d11adba0e25490fbc246a35d4fbe4fba67da7867f19") ); ( Hex.to_bytes (`Hex "22a0b465f0cc7850c1ce0c7679f6ddcaf2a050953119f957814b2f2051039919"), Hex.to_bytes (`Hex "329f7dd593104cba0fe90f0a45f10aa8f76a137328430a6438c1ebd25f466519") ); ( Hex.to_bytes (`Hex "fc6f6dd8df75754db5ba9914c0727b8cf6408643e99f5483c7927d6d2317a501"), Hex.to_bytes (`Hex "669d2d15df9a0e856e36ee4356f27bb89cf26d08af1cdd39fa5c180cfacb2e2b") ); ( Hex.to_bytes (`Hex "5efb0c2cc3d2f42f482e781efb20665b39a1a6a68f044e1689d2177498de7711"), Hex.to_bytes (`Hex "f896638b3cf6734468767ce418701388d65865938a65546e164d24c12ef36515") ); ( Hex.to_bytes (`Hex "ca5464ad46b0f8d3fb5974f0288e830735102039076e262cb4581e9643aede1a"), Hex.to_bytes (`Hex "8508cc972592accb41bbb8ecf2419702fe0fa8bc8188f7529739ead9d73b2626") ); ( Hex.to_bytes (`Hex "ee15ba101cb09b23d92183e82f2edee05884b20d3da09e24eaa864c31010a102"), Hex.to_bytes (`Hex "55bfd380bd6663bdd07085df0e3e68b96be3ed042f640af004a50bb322d6ff37") ); ( Hex.to_bytes (`Hex "be79f5d2a7071ac33b7386dd164ae09307ac6f38d112c9be39e76cb7d9259119"), Hex.to_bytes (`Hex "31a7170d8c9a6a9756722044c4c96faf8dbf7e95f80e5b7e329512751a40fe1a") ); ( Hex.to_bytes (`Hex "fab0136665fae43be494262e61be1f3a57dd5e3bfca69100d4ea6bcfda5dfd39"), Hex.to_bytes (`Hex "8d932da0108e1ef6245cb1e1fb5a3d301594c5f183c23b4f686dee256b63ea19") ); ( Hex.to_bytes (`Hex "79c30811ffd6712f1624f8c89b64383300107009ba7fcb291cc7bbde8dbe0632"), Hex.to_bytes (`Hex "c03dff970c999747bc971bbc3c24f3b0598af34caf2817809611df5332eb563f") ); ( Hex.to_bytes (`Hex "1f2e096e7434665b820aeff9f587e2c2ca660c21dd954224ae954cbc2dea881d"), Hex.to_bytes (`Hex "563361f8b88e9de171e9107fd610534bbf0061284e39e61ae335a33e8e98c90b") ); ( Hex.to_bytes (`Hex "def20ec2b7adbec30897325b5cebcae81b631da9f5c80b7c7fa896bb0d7b7d35"), Hex.to_bytes (`Hex "85edf6e66d6f73ad09631e07ea6f76a100446e541911ff73b96e3217a3a0b537") ); ( Hex.to_bytes (`Hex "7b4581ecb6d7fb71f8e2bd8e0b88dba38272f7775e9dae6fd8f4e5aafe332239"), Hex.to_bytes (`Hex "806d6f738c93db103197d15623e73d3468a45d9d7ac3b3782b0a60910e301716") ); ( Hex.to_bytes (`Hex "a31aac5b77884a42e5c08c7ee836c8a86492fe03742371c30ea3667a8ac9f126"), Hex.to_bytes (`Hex "d944b20d6eb3a35135e07d88881dea3edaf31fd502a9cb2568644845900be736") ); ( Hex.to_bytes (`Hex "c1d1610bb5fd28272115d16e70a071cb6fab071dbe2909054cc87e2b627bd221"), Hex.to_bytes (`Hex "80cfe07efe1c3ae11664e1a8368c30ae846de09c9efb99ed42180398b8caa734") ); ( Hex.to_bytes (`Hex "8fc2eb3aef35bbfd870e441e06284b830d150766e32565bd87d96a88983d3c18"), Hex.to_bytes (`Hex "a95b3dbf6ee0b2ef57b91a3783e72e8df807c7b0bd8032caf068f508886be11d") ); ( Hex.to_bytes (`Hex "5bec4e92c0bd6d7847419c181c6c10e2d50a17bbaba84b7ac85e6a17ca5cd227"), Hex.to_bytes (`Hex "e3381a6a9c54ccbcc1f8d5bc83d3e7ff70c84bf23306451ec12195ab09076e34") ); ( Hex.to_bytes (`Hex "3e5aca3c4ff4735e357e6cdda3c765a9dc894911e4eec63e076bbed4eadf8310"), Hex.to_bytes (`Hex "9ccfdb9d254b4d29c66145804e97ce7acdc0684d3f847e5025e9c0fe788f2d0a") ); ( Hex.to_bytes (`Hex "05b26d2d8bc75ef0c53fa68d3bd9ed74b5e162c93dee142de27506a279e7963d"), Hex.to_bytes (`Hex "df534224fc20b074e5c1848a1c73675eca9c83ee2f57b9763d7984e5c74fec20") ); ( Hex.to_bytes (`Hex "6c9c2fbf503a8d61c9539dd0ad129e2c9ca771992ae10ec4f24adb8c495e9321"), Hex.to_bytes (`Hex "710d474871a46d52fd44067ea6adb691b08ef1f6c80fd30e03d5cea7d2a93933") ); ( Hex.to_bytes (`Hex "d2c4e2eba96b83509fb84ecf486e971aad176cd7363904875117b4941322af29"), Hex.to_bytes (`Hex "c350097f10cd44f6bc94ea01c37184885852e63bcfb23789cb9802e2f5204726") ); ( Hex.to_bytes (`Hex "dd6b5a4e7229c7950b751e2f97a655cc75c313f9c390b7b96c12d6bc2a0cdf1d"), Hex.to_bytes (`Hex "c2681fe5e77f61b2d18ce22700f76aaf772e2c4ab55be822311cbe6afe6caf04") ); ( Hex.to_bytes (`Hex "f3e25fc04e8ca68eef317bbaadd45501d9ea841ddf74eaa597e8380a90082325"), Hex.to_bytes (`Hex "512163113e884aa6fff8772443d707d1fc365871f849af0d35647a68630b813e") ); ( Hex.to_bytes (`Hex "2713839dd3f1e8b816fb232f9a12fdee584b7c41e995e75c70a1758c8c507935"), Hex.to_bytes (`Hex "715eb2e44c57b9e115b57ee84db47ca3b88a559db92492f423f65b9e7f99c409") ); ( Hex.to_bytes (`Hex "07f9ee130539105099a89ad3aa6a1947021a09e71b85de540ee7574997a28427"), Hex.to_bytes (`Hex "abdf8598efcaee2478f6275f093089d11f09d915f46ad31f448e37b481ec4b08") ); ( Hex.to_bytes (`Hex "134f93e4b4749fb13ce284f01be8a0e31b23a3ae1fefb2afee87c0ac46e88102"), Hex.to_bytes (`Hex "2f5493730fd075d9d0599eec1ef9aef80c28c5b9118c85d283f8dd5a525d003b") ); ( Hex.to_bytes (`Hex "ecf321e2ea98667b9defe381998c52aa22af14bb1a5e9485e00142d676565a00"), Hex.to_bytes (`Hex "1b02310aaa2103f4ce01e94372419d4be46ffdffa130efdc6b5ce717905d5c11") ); ( Hex.to_bytes (`Hex "5f73ee291aa30bb5059fbe55444287e041bb347f56533d4bd58f73efa2df9235"), Hex.to_bytes (`Hex "7facaa5eb4a2ea5e51daf45d58a164ba8ba1a1e2181ef264f4f4b3602c474427") ); ( Hex.to_bytes (`Hex "76d03a5a4c7db71aa9558f132e34efec3bf9bd1ccfd481e55c3d7d9f59f3a10e"), Hex.to_bytes (`Hex "5fc1e39fa5ae25fce0644ff41ad7ebc8eda5b538542e6baa20fb7e1f50d9d71c") ); ( Hex.to_bytes (`Hex "f97ef6d275cc2cb96cc74bbb50708c7c05b77c3e71dd06ae6f9a990a6eb6e712"), Hex.to_bytes (`Hex "901ade464c1773ce2436e6dc5c8c33f2baca0761f1d01173c13b6e2fd83cc507") ); ( Hex.to_bytes (`Hex "0c886306cb689f6733c7f2b8b93aeb22d57a17eef2cb9a8c05c9b296c24c1502"), Hex.to_bytes (`Hex "4cde53bb9872f8f99016c41e208c36df0e2eabc582d6644969cdb71f23fd401c") ); ( Hex.to_bytes (`Hex "5db75689fc8b192165b5a4350b621d996dd84e8145c4ea71323f3947b69dc728"), Hex.to_bytes (`Hex "13f117ae6020ce1450fc4612c5fd45be73beac1019431c8e2e918317c6531213") ); ( Hex.to_bytes (`Hex "37dd05107e766d028a42641aa22359070e6a9db70745aeee6b2573810d76d537"), Hex.to_bytes (`Hex "c0566f939ed91452582f31670eb5a02638d2c16e2970fa3d901a285ff20d0c17") ); ( Hex.to_bytes (`Hex "68bd4dbacb3b7a39f51ad106162877f56e1e0c22b5301408c973e345c4caee04"), Hex.to_bytes (`Hex "d1654f1a9d61e63d7a6b54eb2ba90e68bf51fc19ba31d4013007a713d1350c07") ); ( Hex.to_bytes (`Hex "0bc54be3da437a321763eff90cb82792f5657a7231c37b20870419958e365b2f"), Hex.to_bytes (`Hex "c18b4b04c7f9da598450784c4a94b31a30a19fed136a16b7b9e000c3e0916521") ); ( Hex.to_bytes (`Hex "5fb91ff28812a95f44477b83a813d2bb8c5d386970324a0ac1c9c5d593f1b92d"), Hex.to_bytes (`Hex "ff9b1a1a9898bd7b0e0654ef154dd24a5e035e91a3c7248816e352813ba0ea04") ); ( Hex.to_bytes (`Hex "0cd011e217518e71612c06e8a70420680688ee0252124de1bed8ad17cebbd635"), Hex.to_bytes (`Hex "3e853e579590506d54ff5dbd45bbe99b0ae5b2c215d642d11c8349b0dc45210d") ); ( Hex.to_bytes (`Hex "fb547735aa32e48f8b89d39413856647c4759dc8d0856f773481b01e1e094411"), Hex.to_bytes (`Hex "6493b4dc36908f393e1c46dd191fa7aa9e655d7bf30b24da7038f27b3882091c") ); ( Hex.to_bytes (`Hex "fdd95fe793c97065f93787e1eed39555584bc7cea7322906fab484bc6c810202"), Hex.to_bytes (`Hex "74dab95f9c9ef01dee50f44271f247b8a6dc75da3b3499f4266725743b328117") ); ( Hex.to_bytes (`Hex "d251887f370dff5ab3bf7de859295373961cb7fb6c474c638376fdce1888df11"), Hex.to_bytes (`Hex "3d547745c4faac35fc61581644db8f5c30fb3ccf390f194bb8d6a34268c8dc27") ); ( Hex.to_bytes (`Hex "3463e1bcb5366f700d8f7ed68ebc63ed8b14a1d9118289539a9f1ded661a4e08"), Hex.to_bytes (`Hex "e56e839324e9e0a96108958f64d6c4540643238dffbedee2102b480b89193820") ); ( Hex.to_bytes (`Hex "d78a0c331cf8fe3a467fb73c8bb3318f37f2bcb4e3a9e80b58ae17799b72ce09"), Hex.to_bytes (`Hex "e08d324786ef99d14481f5a34467037b94790a58efb845a5ab076997111c7410") ); ( Hex.to_bytes (`Hex "afb9da869ad63dcc3e0b2bd5095ae7d4757f108b1d09ade81ef0d8f82ecc432b"), Hex.to_bytes (`Hex "630f3db0510c14bd5d28cf4b3c92061011790c12997a21726f05538f792b2f01") ); ( Hex.to_bytes (`Hex "6c4813a39f94eb0bf8ab9d05d6e45c0d162bf576414b91494cebb597c75d141a"), Hex.to_bytes (`Hex "02dcfbb52bfb0a9b7ee6328b01d02eb7a140f6e7acf4c18de835c1e2e699030a") ); ( Hex.to_bytes (`Hex "d63b850afc3ce5248a53845240a491c6673fcaa287855f28acb19a58ba294900"), Hex.to_bytes (`Hex "b5119eb5510fd04718d0244fc5e64c0377225293f5fdfacd59e480cda4014017") ); ( Hex.to_bytes (`Hex "cd64e488a6fbf2054ede9383114f07cc16f63a2dd184d38cdbc5bd6561c52e08"), Hex.to_bytes (`Hex "3814f6cd63d4f40f0b8297121385d4b96f7b116049ab7a5749de476fa5ca9f18") ); ( Hex.to_bytes (`Hex "059c9d4534f2666aa20c6a04e7b4b35273860bacc7f50c5f4d0fb78a8b374d2d"), Hex.to_bytes (`Hex "e37d3b46f3c3e8250cdd23b39364b71d7f7cf869c7cba696e1657bd5e4093304") ); ( Hex.to_bytes (`Hex "a0e020c5044d05cff13aa11cc7ed40d50004dd774b04934999ff7eb7cda90e1b"), Hex.to_bytes (`Hex "3bcd1c32a80e28693df0a8a195b8ab723477872c8f93d3f3cf6b73ae69177012") ); ( Hex.to_bytes (`Hex "2da15fadf0a2523e64b0bc38a65b18442266f15befd38befbf28b216c25ef53e"), Hex.to_bytes (`Hex "059cf4f214cb2bb858096e35e5aecb1e3ad8cd851c6850d88ac1cda3307a2813") ); ( Hex.to_bytes (`Hex "d2e45b673115c976d5a3e7f5c0eff3bf5a2e04c7eb1f16bf2d213e5e5ca83300"), Hex.to_bytes (`Hex "07165b735f29feb31188852f9f16074c4be214e33dcdaf53fc44469d1a2fdd33") ); ( Hex.to_bytes (`Hex "7181e7979606418e95c7bf320812ff268a809611a40ad70bf599d24044f3e03a"), Hex.to_bytes (`Hex "9a66ad2d0bb774243f7198e8a7660346baaed90b245b69b3eae25e466dbb743c") ); ( Hex.to_bytes (`Hex "eac2dd91a342896ea9fbf3fce1288ac378f1795a512631eb5b413a2d3d5e1f34"), Hex.to_bytes (`Hex "a84c5e3764ce4974336db30f5a740206559070d391f8582943e0c82d1222b209") ); ( Hex.to_bytes (`Hex "171a867f62c6b406301af709558a926814c56f210c7e160f265c2ad095af3a3d"), Hex.to_bytes (`Hex "c69b3143ff9ddff155f7a6c95bab2837953fd72e3502738ca02b90c70c6e653f") ); ( Hex.to_bytes (`Hex "0a3f62d00459459fb67ba6729e022378e42b0a512cf2fb99e78a23472ddf852e"), Hex.to_bytes (`Hex "e36678e87b317d32943edf95ef755ea4490f02c46dc71a7b5e817ca3cdfb603a") ); ( Hex.to_bytes (`Hex "c2a5a4e28ea0df17c83c397fbffd370dab3aa369ee0a655fef6f2f513fcdcc21"), Hex.to_bytes (`Hex "bb3b34197bf4015503579b83da2529c6db98c74aff5d69e8b3b1e8e0c0311626") ); ( Hex.to_bytes (`Hex "df27009ef97ab811f1a4fcd648bfd7af33c2f442ff1a40d5b237408d45628d15"), Hex.to_bytes (`Hex "36eb436247fd6f8b2e195d42a62a6d6c4c6260de15af4891a00086383899873e") ); ( Hex.to_bytes (`Hex "c2e7e1e4772c07fede6862e68c3cd8939b73bc2902519f6159af2bc0245f663a"), Hex.to_bytes (`Hex "76a8c85898f157c5f91a817395983177e6935d998d917d6b36968ec97d067f30") ); ( Hex.to_bytes (`Hex "75c6686a755436a453354f7999f2f288c762ae74b845117f81b4270f1af8ee0d"), Hex.to_bytes (`Hex "8ccf5e7fcf473e9947045e1b2c5d10e882ac1d1a23b9adca30e22b4b69897a14") ); ( Hex.to_bytes (`Hex "84611eae66e323479bea19d77f3204ee7df252e173bedb248d43716176990021"), Hex.to_bytes (`Hex "6712949b4e8ee4ef84a0b0fa8689b1ac5eea11ae6356107b0c401c771d224f27") ); ( Hex.to_bytes (`Hex "1e3d57869017b85cc4dddd2ede6305ddebff88b357e5ba785d36d04af1b9841a"), Hex.to_bytes (`Hex "6a2366e9b8bfdad1c80cd6cb91fad3573a334802968092dc7f994752b4216c37") ); ( Hex.to_bytes (`Hex "b1f721dc7ac0f0134b85fe05e9695c2a4fda7d1d4dd173059da474b6dae53e19"), Hex.to_bytes (`Hex "904b4a71ca74a17f93a7a5522eaa21fe91c75b0f36b5dc696ce2d70337b2161b") ); ( Hex.to_bytes (`Hex "e6b8d4276568f6eacf1f6626b4aaa01a735ea0a2af9ba71a8540c28e2c728935"), Hex.to_bytes (`Hex "8ffb47d79104424157bf8a72f7630bc20bd22aab74191df678a9cd28b3a2163a") ); ( Hex.to_bytes (`Hex "11e084e8c89a9a4726ae03cdb0934e5077e919131f9e11c7e71577dbe7119337"), Hex.to_bytes (`Hex "58ec786548ef5bf0dd50cade2fb5b905a295f69bfec4926c6d55d78ae465e62a") ); ( Hex.to_bytes (`Hex "3950113a07f018941daa3c29e6f7ba84e8e8376cb57be54b9e2f9dba6c0c012e"), Hex.to_bytes (`Hex "73133a79c5630cb392a6dae468a8a7c2ddb61fb77be69f782a8e263192c11228") ); ( Hex.to_bytes (`Hex "b6bcfbd66d8b3e8ae2cb83358695b6faa1b5bfa4473c2e3d9de951b3760e1517"), Hex.to_bytes (`Hex "5777a465fa22a82e1c7455c64ae62f1f7095acf55a20aad1e9c8360888ddcf27") ); ( Hex.to_bytes (`Hex "79792a82295f307de29664a3c14f82804d0f7ac7f41c3df7be26196a3cbe9c1c"), Hex.to_bytes (`Hex "2318761c8caf17aa26e9f6ba90a2d0092bc2d6b5f8061cf6cdd932fc6d1a2f17") ); ( Hex.to_bytes (`Hex "b92f20b54387d35ad240be5095263a08e3cd673f031811b910b8cf3062f44628"), Hex.to_bytes (`Hex "4cc537e9e7b523e2213f8bb0fd77c5f2d3a705752b65c1b630e1602e98a48f2c") ); ( Hex.to_bytes (`Hex "f395754185e1bb5602c207945300c1ec2efd307615c4a59020ce1064f28e331f"), Hex.to_bytes (`Hex "d4b7561a59543b1a25bdc8cf2bc41127651962a4d64213b328be6a6c2757041e") ); ( Hex.to_bytes (`Hex "d6e9c21f2d12f033f4b50d6de207afbb2809f290dbe1a4ad519b1f7ed3780d32"), Hex.to_bytes (`Hex "f9790eb82ffe4f6d4d9c6001f546971617e11f3769aa949c617697827da4ff08") ); ( Hex.to_bytes (`Hex "1517557d5f41ed0e7b4511aa983b20f4fb0a7644d5f35390a176a2deba03c202"), Hex.to_bytes (`Hex "afa542e84a02d7552fcdeb9dba038cb5b542aaceb6c86b0c3e5c356eab7f4e3b") ); ( Hex.to_bytes (`Hex "e9db0d6af8819deaf1e6573209280fce04ff52fd643b390024ef238d21584229"), Hex.to_bytes (`Hex "5bdc17950f717fbbca48ab435314dbb95134e81fe360cd948bbe98f7e07ce12b") ); ( Hex.to_bytes (`Hex "a23a1f078bee71d94866212f6f044265eb2fc5c4b4a01170cbc75d30e4756a17"), Hex.to_bytes (`Hex "24ae75ce0b68feb8447bd2c3f6cb498587c5406aa792eea831f13d01bab0e609") ); ( Hex.to_bytes (`Hex "65dafd64979e0bb82d8ac50b11b4c0b0555ce1c6a0b11bace8707ad3414da436"), Hex.to_bytes (`Hex "2fe7aa81b2ef776aa7fa589b868678c5dc68337ebd3374ab00a0547f2ead9217") ); ( Hex.to_bytes (`Hex "a7a99503eff692872972c2663d7f75d31090c7d576e84969a78b7f0c16f16c17"), Hex.to_bytes (`Hex "bfc28da9f0d8f5f0e9d96cac9ee0184157f6975fe451d14ee454b8265637e713") ); ( Hex.to_bytes (`Hex "d006c2f35732cdbc42a391f9ae8e39316c5aa32f14442d5a5231f613c7bcef3c"), Hex.to_bytes (`Hex "ab007e01973b06c8c3acb544d5fd205ecd188feff6c0ce6cebbf6aec774bee14") ); ( Hex.to_bytes (`Hex "b3eadb58382296c029ef10dbb0610e5ca41dcb8aedf19a6c39d925c473fe763f"), Hex.to_bytes (`Hex "6f5580b2e882d4da4ec5dc7fde06f4c3b954361db888ca37d3a4447276f76102") ); ( Hex.to_bytes (`Hex "fe8e2aa19aca1c7e9bec22c5a8628b94f83d8c219b04bb9d78af55d26c3afd1e"), Hex.to_bytes (`Hex "1f0a654d750fb5a4132c5ea7866cb725531d4def87686cfdf051bc71d30b590a") ); ( Hex.to_bytes (`Hex "50d6d0b8a8ceeedcd4f2296a8d8b2d4feb11f9ea8f52d043522b6c54524c0424"), Hex.to_bytes (`Hex "f6d9f01ccdfac396d86a509f126763ca5b9b5ffa05d0852f30c196983f159e06") ); ( Hex.to_bytes (`Hex "57d9614c12826e689e6486a4de9baac78d7aa3d4e091c2d3f3285f2ce3e20701"), Hex.to_bytes (`Hex "1b59d7c3df450bab3df60b714a85b5f7f3260c2ef1c84d5485eacc30a7959b2d") ); ( Hex.to_bytes (`Hex "f056ce95c2333d513170d77fdd2f2bbd31e0e209fe474f5db454807b4248942f"), Hex.to_bytes (`Hex "67746ad365d66fdf076bea2f1f19c95d2264407163efa2ec2cf7da96c0507101") ); ( Hex.to_bytes (`Hex "5828ce874f1d7a3619cd3781075c549dfd3b8f7372201adfd425f05220414e11"), Hex.to_bytes (`Hex "ead566bfdf28fd18759a49f9f077bd8b3b45e8f3994f62634984388afeed8027") ); ( Hex.to_bytes (`Hex "d45aa90e82300274fd2f5035e57bb263b660e2fb3ecbdc917734320fb1bfe225"), Hex.to_bytes (`Hex "4f09b439713ac0adbbc2d1b40fc6f8edcb9f02b747091169658050a8e02ff401") ); ( Hex.to_bytes (`Hex "d0b496e562cd2dffc80ff55ad41ad3c7fd63a6b1fa73bfa005a03e7e9546c501"), Hex.to_bytes (`Hex "79678f93cfaaebef9172de076e3f866996e7e6ad678e6ec0e99a6679e7ab4b16") ); ( Hex.to_bytes (`Hex "e08f27b5516e331c0b06b08867020f83f4cd36618afe89e55b3130ec36bbe204"), Hex.to_bytes (`Hex "fb5b3493b55ce6cdf4f5874283fba110c12819460ca2c737626b2641855adc2a") ); ( Hex.to_bytes (`Hex "ba61e24235ba3239cd4dde829e391e3a733cac03ff6d5f3aa916d953f415bd2c"), Hex.to_bytes (`Hex "37898da95fa325248c589f5dd3a2660a2b8551395a8c32f855dda2b4666f4808") ); ( Hex.to_bytes (`Hex "64954d3a8083c3a4f254eb310cbd9a1011a212b0b4573da8853ffd4c0cc84939"), Hex.to_bytes (`Hex "409ef11e0d3fcdfd81b492467754f84707862f251d0efc6019dcc345082a4715") ); ( Hex.to_bytes (`Hex "af7be5486d592e0428f615cb4130d7d91609884e78a3ec65da01e9270d7f9f05"), Hex.to_bytes (`Hex "43b4f84cd4777dd3ec76417da672a1bf4e7b242561b7c8d8f5242d5c88649b07") ); ( Hex.to_bytes (`Hex "be6db5a403079fd2fc466b95a86ae2750628e202e749a4841c12acced6f1bb38"), Hex.to_bytes (`Hex "d1b66630731a72c706ec3bb5f3553717212c1e3e62bd2a3c160166633bd48d08") ); ( Hex.to_bytes (`Hex "b68b5a05776f16a1a48d89588c2d856317774b75cdf4b4345f51e7f32daa2615"), Hex.to_bytes (`Hex "b8e457261ac5854045862446a45e79969839d6e3a10304c8084b3221b0c29c19") ); ( Hex.to_bytes (`Hex "c27768d15ddb2aa52eaf520b22f9036bbd22efb4e801c87f1d2f81ecc267e512"), Hex.to_bytes (`Hex "0bc2e8a414400903cca800a2d60cbfe7ea945bfbfe6508c6ac41683f45149309") ); ( Hex.to_bytes (`Hex "d8756f8b57fdd7bf6a293dd36ef87ef012ee8ed478c954503ac46f4fcb763d0b"), Hex.to_bytes (`Hex "eb90ed4e5a62f7bef773fe22deba8d1ffe1be53a94ab60c93e975c86d8b25808") ); ( Hex.to_bytes (`Hex "dd043a84373ce4e2c0e766691e8ae928a1f529d64f30c46afb320cece1f1fc2d"), Hex.to_bytes (`Hex "6e7fd099f81567bdff47cc89995a85cbc435726826242dddb8fca3a3c60e6819") ); ( Hex.to_bytes (`Hex "7610941f6eb9aba568027ab951b4b55175e3ed584fdce0d7637e6df7a518ee2b"), Hex.to_bytes (`Hex "b4d71d44be807ded3bcf193c0ad3c2a4ed911f2e9b734fac813d89e3da486235") ); ( Hex.to_bytes (`Hex "c0a1cb4d8cfc797ca1c158b9351c62814df06532196e410a417fe14548489e00"), Hex.to_bytes (`Hex "d1eb35ab94932d71fb49e1d81ee11263de1ae5773399af84c91d36cd6c3c423f") ); ( Hex.to_bytes (`Hex "e1b1237f566e71f394490d6a4d3c8f53ec3289b02a6e2aafaf98a237c7493e2f"), Hex.to_bytes (`Hex "cc18c3dcbaafebc53dfd39634c6bf264ccb627fa5495f05e35e1e451c15edd21") ); ( Hex.to_bytes (`Hex "3c4be5f9eac482c343c13eb17af2ea470f40afca75376c2adf26ee65a6cbd108"), Hex.to_bytes (`Hex "25cd82f30df1f2fdf3d24540724d2b814b082264e232c3c1d38c76f1a49ea426") ); ( Hex.to_bytes (`Hex "5393e594ea9132e1e5827bfc8056697d02fed7fc9fbca6ad351341ac4fe9d42a"), Hex.to_bytes (`Hex "ef9845d8578566f16a5c3a9cdf78f8b6cf8c7300b9e2930931ae85486768b009") ); ( Hex.to_bytes (`Hex "76a1512ca7de6141178ec18228e27b14cd8bafd427b87cf433aaa990c45ea030"), Hex.to_bytes (`Hex "41a8a83edbf6093205692deac6069c1d8f6239acc834fe6adeac2faced03f835") ); ( Hex.to_bytes (`Hex "edb5eb83dbdf8dbec307ab57558a5a18b0ebd564b1999c10f7c4e7c0be404302"), Hex.to_bytes (`Hex "3904106bb637516bcd1e1d1afe002e6f975fb47a62ffafe26843ad0bbc3ed131") ); ( Hex.to_bytes (`Hex "5b80e077c2002ce53e61e400fc6c9a2843af0eb8e6646dbae110eba23abb8d02"), Hex.to_bytes (`Hex "71afc2b2845de0b5b4d42dedc819a88c1d184e89851223bf202842afec55dd13") ); ( Hex.to_bytes (`Hex "785579f4649ed57c121dad4d0183e4b27b7aaef33333bc6973ce568ee3be8b1d"), Hex.to_bytes (`Hex "8e6df39332e0ed62904dfd4270b6ffe011189d3c7cb9e52830b2c256d74e6e1a") ); ( Hex.to_bytes (`Hex "4586a17c8e35280841fc31c8d004144eb982ed1def42d9a2c941e6337899b82f"), Hex.to_bytes (`Hex "51e322123b88a11f98295ca672e6928aac66e30cae70952c798f942f30c48221") ); ( Hex.to_bytes (`Hex "55449c90201437719548ffe5fa72a879602d9d25118ac5640b9d402c3f244a1b"), Hex.to_bytes (`Hex "cf775c3e7b09b724c1d32c8ae4bb3c10c10a2bbd35ff53fbc3932fda5c072035") ); ( Hex.to_bytes (`Hex "2b1911731ed60ff7bb66781f58663f66c2769960f3dc23b266b128c6d3cec322"), Hex.to_bytes (`Hex "ea7156465be190c35bd8c712747a9c83c2f28d4765c1ab9e51b99f275e242604") ); ( Hex.to_bytes (`Hex "6aa1ac087b582ef3d618d1a054090fef1b71930f0e0d3a668615c20989d9a93b"), Hex.to_bytes (`Hex "9bf3fa7869feb0671788175d977c654391d3269a543934361dd6053ca5611229") ); ( Hex.to_bytes (`Hex "3549d916dcf813b2d8b33f8bb95b086ccb6123a312778e3cbf8d919628538611"), Hex.to_bytes (`Hex "610495c36f6a0fdd9a8b0af3eccd2e40829c3d4a4254c063344701e6b0873b1e") ); ( Hex.to_bytes (`Hex "aaf8253f22febfd29a89e388d2da133d961747102b040ce4a4b7b9b25f35ef20"), Hex.to_bytes (`Hex "b74ea40590fc84255e2860e8aa0f3dc7f693ce9db5e4a9a3fa73675a64470210") ); ( Hex.to_bytes (`Hex "9dee5ff0efd44db404afc3575ee311d3e0ac35df48e7fa6a05af5cedbf475228"), Hex.to_bytes (`Hex "59590904c4bbe16706c6cef13c0264102c8d5577937bea12a40dcaa65a9de614") ); ( Hex.to_bytes (`Hex "58bfcc41a164ad3d966dbbe195cc45cd449f68c17110714f2c60ad35ce27420f"), Hex.to_bytes (`Hex "5cf62ae72405ef54bcdf2e43834daf7b1799ebb7fb4b79345e3f75bcf25fad1b") ); ( Hex.to_bytes (`Hex "a0e4b46e2363df1773b980c2581e9aec17e2ab12ad468d5aa4791f4bcc2e2202"), Hex.to_bytes (`Hex "c3cf7e626bc2c68dacfe578c9234d4ca1e7601f27fc57e4c9fa0ecebc9197a1a") ); ( Hex.to_bytes (`Hex "8f3ef4de3ad3ddfb0ae30f0b5d1c50d61befc8c434fdd56f4e3ab3c8be4f7e33"), Hex.to_bytes (`Hex "b16f987c11539afe9c8912d1eed9fe90148871c1db1935a932f1422e59d8321a") ); ( Hex.to_bytes (`Hex "4cab95d50e571fbdebbc17dc9e06112ee893d202f54e635cc5537b9d9d94e43b"), Hex.to_bytes (`Hex "ac0ec06c6a4587f0ebedb77324678eb6999a918352e54895d6b5ae041f0f0701") ); ( Hex.to_bytes (`Hex "176e6232ea9a3a4969e9b274154c8e7b98caf2b5b6615380a379921701c5d739"), Hex.to_bytes (`Hex "e9f2dc43195cd3536032bf474f6013ba6a59464de7b82483eb45d8b7db9b8218") ); ( Hex.to_bytes (`Hex "e8e983f1510a270d038f6630f9a776d2e9885d9eb5978dd4e144a14590ee8a0e"), Hex.to_bytes (`Hex "40bba03f9f4a182864af5004d0ac0f719f6e7419df4b0f90d4761521a32da427") ); ( Hex.to_bytes (`Hex "8d66dc3740cf89b628c42d14010a7793fd0878c8c4ea3431ed6865806190fc3a"), Hex.to_bytes (`Hex "b657ad3f3d7dc760b359aa34bc9ef45984730a0c09d0639dce6186bc58c35925") ); ( Hex.to_bytes (`Hex "b4795c149256095cb4b0bd495fbb8bdad79dbf9d942c35417881749e79dc5304"), Hex.to_bytes (`Hex "3995c707059f01da326def2ad54539e6e2394349c64e194144fd81be55efa22e") ); ( Hex.to_bytes (`Hex "92f8be04a94f9ff4fb3f00378b97dc62a644634225e60267fc7e8edc2ce13b3b"), Hex.to_bytes (`Hex "9010e4937fe6bd101e99b0ec1ea1cc8c00e48aebf072dd50ad8a87a756db3c3f") ); ( Hex.to_bytes (`Hex "30b4f455a6530aff6b8e1c84a241be0fda24345549624ae4f3e4d9cf83d1163d"), Hex.to_bytes (`Hex "0d01124a477a73f10c01e35a202a8633b26ec97c8cac75947e78e392baed5e2d") ); ( Hex.to_bytes (`Hex "c88bb63accbd32eca86b05828dc6f15e0a230f76b1c6792a02ac424807c06902"), Hex.to_bytes (`Hex "d70df7ac736aa5de2cd305d6fd24aeef8f8a725a790144760dcf3bee3559bf29") ); ( Hex.to_bytes (`Hex "e05728d9a4fcecaf2a468d2d254aefa2088c1f7bd21c9c3f4ee786ae65e8063f"), Hex.to_bytes (`Hex "ce5c2a54c660ca2b451ff9ddcaa01720cfb903f14f6ae19e2add8045ec5b9537") ); ( Hex.to_bytes (`Hex "c6edcfc1b4e4918613fd20818c46f6b489dc26b81775b1050c71ef3c6835610c"), Hex.to_bytes (`Hex "591ce26b5f0219b1da341accd4c80ee6ff347abdf8a8ba61bad333a4982a271c") ); ( Hex.to_bytes (`Hex "c4539b226e8f75c74f83d41fe3148781f4b19252141c729ba06985fd5e63d02a"), Hex.to_bytes (`Hex "3ed819a1e7b69a35f01e641f63fc8f59fd2092772b4b4e447992c9e75852df03") ); ( Hex.to_bytes (`Hex "2e5e30be6152349174287aa31da1d4e6ece744b31f281cbab588da58d7d90d16"), Hex.to_bytes (`Hex "6a56febb8f8fdeda5ff3235426650020a522a671f201190f2023cbfe3a50a032") ); ( Hex.to_bytes (`Hex "ba551712975983061b2e3087d0c9572a76d0dc3f7bc5078fb51311ecafb24908"), Hex.to_bytes (`Hex "2d88279c6153d613935d0fa68a02d984f262fa337b43eef11d97db3fe40d6f0c") ); ( Hex.to_bytes (`Hex "67ef93970444236e413c924ce590d57cfe451116d10edc27b1c9b4cff44ee01c"), Hex.to_bytes (`Hex "67d3cfdd8f9f5bfdc2c97993bdc65d6ab8637b52ce9e97c2722a0f583d873d32") ); ( Hex.to_bytes (`Hex "897a1dc3c782f944b5608d1759e84698ac70d68597510aa5b756389111877707"), Hex.to_bytes (`Hex "4c0540709350a18f94b3a884e48dafe01d268f467ffad96e8a04702f4c8fe026") ); ( Hex.to_bytes (`Hex "159b41bf6a361016cf4904f5a53395549474b934867403ff236a09e583decd2c"), Hex.to_bytes (`Hex "b2d7fe1f25c72497a7bbb7b3d1a24a01b903bd01abd628edfd37c83c559ad804") ); ( Hex.to_bytes (`Hex "3dcecba8c72d5350936c79891a6832939f95aae755f31c1b8bec979861c4040b"), Hex.to_bytes (`Hex "0360c2ea1598c091058f528b5ac944dfc596a232b9539dfb81944d51c0a7f705") ); ( Hex.to_bytes (`Hex "aac36af3bd2ee8e9c684e3ddba3a3cd6d257d5bb944765a0b46bebb8e374f12a"), Hex.to_bytes (`Hex "1cbc1cb628ecb7c1a5ad443bd91fdfa6e140b754bd1fb441aed60062b5b7b607") ); ( Hex.to_bytes (`Hex "257c0cc6b11409f8bb0bd2d97a9d6ec990605a06b614f19b1c63993975c0f307"), Hex.to_bytes (`Hex "71fefb4170a9846ded6a3248ccf867730d9898b99ab0a49f9b9d8140f451b510") ); ( Hex.to_bytes (`Hex "eb0688841f21b2133fa9bd68e5a86187dbbec7b2b01879fee666fae72894b80e"), Hex.to_bytes (`Hex "0f02dd74d15caea4d5ebbcd78374360a9fb489a579e4ee02023d03f73f441f38") ); ( Hex.to_bytes (`Hex "6cabea659972e9bf3e2296d143c6d791e20eba2fe01ec4c11192d5ee82a59103"), Hex.to_bytes (`Hex "0a87be5f50acf5f6b710a9a34fce3245fced6f07dc95042e8ec770b099686625") ); ( Hex.to_bytes (`Hex "99463af7f831d35984ec3e6b33a19eb8da958fe69285bb67fcfaed036e431709"), Hex.to_bytes (`Hex "7e6f68773fc12827ebf82af4e8d615262657fb1f77dfc55c97b42d919feba000") ); ( Hex.to_bytes (`Hex "de61c15ff712a5455455963c44e3c60fd0eb5521c537ea4f91e89f59accfc207"), Hex.to_bytes (`Hex "bb020c3c5d932ad39c5e2b43681e636293b33d1fd2be2c07164bdc8349e7ed28") ); ( Hex.to_bytes (`Hex "eebaa88d3948de06e0f49302a720cc6854767724e2a93fdeb5be6a1754fad63f"), Hex.to_bytes (`Hex "9997a7e59ff553536dd43bf8051d8217c35f5ea08d076d42e7d6437406e88e27") ); ( Hex.to_bytes (`Hex "633f2983cb0162c0a85cc3e603bb1226b2b25f48c9e8f46c9ed87035992ef71d"), Hex.to_bytes (`Hex "a7706d1bc2d3a478692fc1b02fc8d814e34a8849aa2d78f64ffd12dff4eed235") ); ( Hex.to_bytes (`Hex "ed19b023ccfdaeb4999989c1b7a189ac2d0a7a4f65815b3c3f1d6517697db30a"), Hex.to_bytes (`Hex "107b3dd049f530a1c7b876afa5fb3efe684d15d592b29c473757d17c27b1ed08") ); ( Hex.to_bytes (`Hex "669ed14a81355072c109a294016aad9f131a38013f3f98ea5b881f787ce9b317"), Hex.to_bytes (`Hex "dfb65d52ed121a87d7a30959b09dc2adcedacc7073df07980418e816e8cbcc31") ); ( Hex.to_bytes (`Hex "1a301685a3c7b642ec3faa584d548564012a250ca45c05e18568e8adc5aced3c"), Hex.to_bytes (`Hex "0cc263e5ccede54dea36366ab7537908a3a3cae69ccfda1eb1b3984115b4823f") ); ( Hex.to_bytes (`Hex "5876f5150361812782a51da579b7c0fcd7e1f292f3bfdf9901ae4da81e2f091e"), Hex.to_bytes (`Hex "8020a28ec52b6f1e755f99035db1d98eaf200e91a9eb7a72b1cb5a9255dcc638") ); ( Hex.to_bytes (`Hex "472722db05bcfc912c0c6b33c136bc256352fedc49c9f44d5abe90ec5b78ec2e"), Hex.to_bytes (`Hex "655bb1c193fc7e4d6b98dc0fccfaef2d4da7a3caef985012c1418359fe772406") ); ( Hex.to_bytes (`Hex "eae3d555667e3db687cc6561cbb416fb9016e26a4d6cd2369d44f8816cc76a16"), Hex.to_bytes (`Hex "2b5c88936839e282306adf85989d871b04cead696d150754fafacce52dbd0609") ); ( Hex.to_bytes (`Hex "2378969741cc7c7397ec6f1fe0280710242d9ebad3089bfc65c94029e5aaf506"), Hex.to_bytes (`Hex "be438528cd62f1286538adfc0d689e3fce13b376210361862f37b9abcdd4bd14") ); ( Hex.to_bytes (`Hex "df4e4ee7d7b3256c3904ad2e65aefb67518a0bbf370882c1847df34d19cec93b"), Hex.to_bytes (`Hex "b840de98742e056ac77f6d4c73a078ca62ec697426a10a5aedc70f851c85172f") ); ( Hex.to_bytes (`Hex "0dfc91fd3ac017333ca9a8fecf9e0d386eb89f3abce1cd7ee3afa4987b3f7017"), Hex.to_bytes (`Hex "c7f2a0c920504bc58cc9efadc3056bc6107d478eaea78df3f5ef1b9c9a0c8437") ); ( Hex.to_bytes (`Hex "1e8239a7fe7e93506e10a1faa26cf87ff12c9d7e4b972a2510b02bd69cd1691b"), Hex.to_bytes (`Hex "4e84a2127f5a6fc11457ad8ebbd053ae674f6666f50ac7a3761251938ab9cb3e") ); ( Hex.to_bytes (`Hex "e9f048e85348c5bd8524771ebe67281b949ecada5415f5e070b6c48913da8611"), Hex.to_bytes (`Hex "002b76c7053d51162b875fb9a4e3b2203213fc1539eb7cbf6a4990accc5a2304") ); ( Hex.to_bytes (`Hex "9f2556d85d7eb001c1b055a18f20437f738b932115e82889ac7e38a514978d17"), Hex.to_bytes (`Hex "bb46204c8a65b4fc7fc735a282e4c76bff88b73fb0f7e8444237046e7277e73c") ); ( Hex.to_bytes (`Hex "da913ed4a0eaee55275fca7824600ec951e0b6cb40ec2a6c7cbe484a5c36ff0b"), Hex.to_bytes (`Hex "c98dead804ef5a144d41c8e5489b562d73fe8f063a941c787bb97a96389f6133") ); ( Hex.to_bytes (`Hex "d42b9679a571beac2be7b99c6b76083a65b03d532cd88815e6c36777d1c1d630"), Hex.to_bytes (`Hex "176ee4efac0d525d3f7dab6e1f657ad8dbb64e321f59756ae4d87477989a5d1a") ); ( Hex.to_bytes (`Hex "6bff01aee97225022b2136efd21a5aceadb33dda420fc1140e0fa9165e626722"), Hex.to_bytes (`Hex "ec71d6d6d35df47baccc9811020abb01fa48fa24ca34d015e2c076dd5b8ca819") ); ( Hex.to_bytes (`Hex "2d1efa34c17cd9fd3481cf9c75b71437776b82d9e37a6bb7a291bde131f6cb1e"), Hex.to_bytes (`Hex "de4ed1eace0011b63c63f79b5cdc649fe6c26ef0264d5e31266f88505a534a02") ); ( Hex.to_bytes (`Hex "4123b6741e4f759ca12ca3cff2db29c27896b9e106a0128005228e9ff47d9a28"), Hex.to_bytes (`Hex "4c85cc14b78692a239b2b8ba805ac063df1693335ba9bc77066ec467e878a10a") ); ( Hex.to_bytes (`Hex "fcb0ebab05e3836924c6e4cd11864740edb77f55fedbeecdd118028e141ce804"), Hex.to_bytes (`Hex "2906a821338d56e553aebbf2e966f897bb2b02504eb6a5ce1af5eaace052341a") ); ( Hex.to_bytes (`Hex "522cc78c17d705341b1e9a3904a5a72844c8e9f739e270f188dc69bb9563d31c"), Hex.to_bytes (`Hex "2d8ee604510b5b676321ed1dcc6e7f187970e3851e42531a51772b75c7e38a15") ); ( Hex.to_bytes (`Hex "d7cfa9123e8800555347bd120204d89cd5da2bf65489751fd0d2fec29cfabb0b"), Hex.to_bytes (`Hex "8da2244809d9e619513e8398c0c4d68c596fccbe4f1946b6e51334d7ece22034") ); ( Hex.to_bytes (`Hex "9ef61016e3e5a980208e5610924a9cdd56435cc8b6ae6cf80d704b5eccdfad31"), Hex.to_bytes (`Hex "04dfe17914d9abe9dc74f636f323f0b7b68b137f7133d2a96f9734cb1726151f") ); ( Hex.to_bytes (`Hex "785022fba3000d965f3f610e56718899eba3a6cc97afbab2fdb504c7e7197f2e"), Hex.to_bytes (`Hex "09b2d90d9f46bb5726bd4ac88681409c60974524b730135450b84fee7737a73e") ); ( Hex.to_bytes (`Hex "530088be2d5e41627a5f95055b815de67454e043ede75b6bff203d013ceff929"), Hex.to_bytes (`Hex "1a71f0cf74e05c64dc30e60a5e6e089bdf68f27fe65e6517a962eae60f193028") ); ( Hex.to_bytes (`Hex "8142619c8b56a6f9ced546d57bf3f34b147b74341077fc47eff96af7a42a463a"), Hex.to_bytes (`Hex "794cefaed7190d481d93fbae75e160abb4a51fc7d085554d3595d597628e960a") ); ( Hex.to_bytes (`Hex "f99dac243f9036e4a617a81df0dd00932a93bcb439683e127fd7fd3588841827"), Hex.to_bytes (`Hex "bc46099bbd7ae452a5e4eb0fce3e85c05d997e34c835f8f324a2c02c13e9de19") ); ( Hex.to_bytes (`Hex "58a7e6b4a98353a447e4c123b500159036572686c8c05ee85af8c840e6a86114"), Hex.to_bytes (`Hex "c8b272fdea081d5003f46d4f79ec63eb190d531c50f2e3f1d8193d6959d72e06") ); ( Hex.to_bytes (`Hex "75fc49b28da3c4a29085c7772107e48aa59e5b8d044bdc037d3103e8380d890d"), Hex.to_bytes (`Hex "a7ad589360ee103e0ed76208eb4809351c8c5a18df80aa7577a827d080c3e737") ); ( Hex.to_bytes (`Hex "cf069af065a5fdaaeb0068b6c0f0e991eb5d9a9a614a89baa5672aa72f6cab35"), Hex.to_bytes (`Hex "6fa2c1bb305834dd4797c36f0c14d2c32cf6a3a4aa4a80655f9e041b2bda8a2c") ); ( Hex.to_bytes (`Hex "0f63ad986a241e642c2eb319de91ab7261b669214b77925ccd61ce7043c51a1e"), Hex.to_bytes (`Hex "48845b28f53fb29c276731f32ba4b49b20476ec813a5dd6285aed04ff0a03821") ); ( Hex.to_bytes (`Hex "c0c2c831308aff05af137db38a4e0c32620ae07d9261e15f01df99c8ec6e3932"), Hex.to_bytes (`Hex "0bdb4c25a75a6af80140507c4363f8ff3428c41331ce7e90044ff6fe20918300") ); ( Hex.to_bytes (`Hex "05710be81556a30d68eaf583c7350dcd84c714fd178f5619805b218e9d164438"), Hex.to_bytes (`Hex "51ed9b1cf46fcc1f6becd75d8194e5345d7cad7c16d3a00b8e638a393cc8c03e") ); ( Hex.to_bytes (`Hex "239ea8ca2adde330aa3421a9c72456ca0a0c62be5d4c9a56e10764f035f4b50b"), Hex.to_bytes (`Hex "3bf5225e97e1e8dffbb13771c5befa8d1aae85b6989fe101c1c228059014c128") ); ( Hex.to_bytes (`Hex "f8e4d80acef7cc3d3b769e192e318e588d5525032fa56a8cf3f472c669bac429"), Hex.to_bytes (`Hex "d752717118f2ec194eba38fa557aee0695fd3c6cf2a4f0d80c7fbb4daf61f73e") ); ( Hex.to_bytes (`Hex "755fbb04adba0f1ff0e2f456b602ef4aa48ea0b8ff9b894c8d70c7a12c7e4e3f"), Hex.to_bytes (`Hex "bf9b9c1c107af602d68aa28bdb0cf305e2a860159ac43ac118593594dbbe3415") ); ( Hex.to_bytes (`Hex "23be10b8ff6d87fa412075e0e10cc772ef3c1f5138bfc8075be21bed3e5f6c1a"), Hex.to_bytes (`Hex "b065fa85aec0dd51473fc34cca4d5b8307681a22bd02d61b9fae908a1a3dc232") ); ( Hex.to_bytes (`Hex "0d9614a12c53ed0e0d034597072d8369928797c50e8cb80cbc8fbdbaf346d43e"), Hex.to_bytes (`Hex "bb6ee77c6295a72f0b5e867c1950217e0926160b86690e6dbd9dd20303a8ed17") ); ( Hex.to_bytes (`Hex "6e4f75287ff0dd5a696e38ce1910d2de464546d10e5d11ba7bd5f76bf5adb81c"), Hex.to_bytes (`Hex "9f5c6730e743b3740c2538c06c1abeaa68eb5c7c0258f98ef3cb34b60823f726") ); ( Hex.to_bytes (`Hex "a3092a2ed09c97e6b60841b1b41ab4bf6157b02c81dd0d2982e5108d2d646c2a"), Hex.to_bytes (`Hex "a4843ee12a8a3685d2869e49b26cce9e11684e1f0403d1a60bc04f2986354917") ); ( Hex.to_bytes (`Hex "ecc988b233f900d06cf8fcb127fa0800f60ade5e36dcb877263feb592dea9d28"), Hex.to_bytes (`Hex "fc4d6e2bad9ae96e8d5cb563fbf957a310d7a898c4039db9194fc39d80b9fd2c") ); ( Hex.to_bytes (`Hex "df5cbdfa4bf23f4ae8203336b35b1574b6a3a699d9ad05f6583fa53df1396503"), Hex.to_bytes (`Hex "08c4590410e9a54a9930fcdbe4d4dfe4ae8be1471e6de4ec520faf3af8fb7125") ); ( Hex.to_bytes (`Hex "f056a66f5a758bc0a6195835d2cb17ac9fd5de76a9631d0e71cd8f06ccba0d0f"), Hex.to_bytes (`Hex "36c266d31788b69ad75f883f7642da7aec44e39f4fde3d08094df7ca93e1de33") ); ( Hex.to_bytes (`Hex "6eb48728fd8b9535284ebef10191385fd508ed99baacd1f93e3773fa66a6ae34"), Hex.to_bytes (`Hex "c26c69b26d385085c09e04856ff2e0ac54543d9d6dd41e8eeeae445bd8827809") ); ( Hex.to_bytes (`Hex "60a73554a0193713d0face0fb73a59eb3a850dbfa8896b066e01f71b20df051a"), Hex.to_bytes (`Hex "c66a887e8a56f0690d88b8cc1afbd190f403870f9bcbf381cf6e36a98903e528") ); ( Hex.to_bytes (`Hex "15d7dd64293fbb5006773fdca6f9aad53d3c9cc433146d6e404406b0900e871a"), Hex.to_bytes (`Hex "672afe9f0d8f4a8fb2e83d8b37fff73d4a22e5b250ac00e2d6195f6275bea82e") ); ( Hex.to_bytes (`Hex "a684df79aef35293d27c1eb96ac721d89b36e5af7d8b161501285fedb3d1b239"), Hex.to_bytes (`Hex "edcdc04ad3c8c1e3b212b87fbb486724cae9239af6468df17357bd3cbf73b112") ); ( Hex.to_bytes (`Hex "4dc76a4707cb920da29ee5912ab87991e0f592d6b33afcd5503ac300d0efee3d"), Hex.to_bytes (`Hex "cd4332fa447037ce83a175a9ca04ea2371b862ec2eb0a33af08e58c51121a904") ); ( Hex.to_bytes (`Hex "5f66a57d02a197dc1858fdce5d5bbba17135cd62761a4e7b702d76529bd9a33a"), Hex.to_bytes (`Hex "5977c3fe3679bd943c5a2e23554b167271b2bd52a2e26b753b6f56d674bbf233") ); ( Hex.to_bytes (`Hex "b9d9dcd65672fdc85e7f657fd8c903cadb46f62bfa4339fd91a599634f59c122"), Hex.to_bytes (`Hex "6c06be58891bd3a351d771434cdf7637877a0000cd1d4f6b19e233a4e9836d3a") ); ( Hex.to_bytes (`Hex "a18c9d74ca92ac2bc16483d96ab7ffcd66e24b07439e714a313df14a9f191d21"), Hex.to_bytes (`Hex "723f8a7d75f35c61cfe0252b4e0a71e20f18e1a9f8627ee063468fd269516836") ); ( Hex.to_bytes (`Hex "117225a02bb926508b55032a9abe610fce5758c5ce4fb56ed76b0e38a0209331"), Hex.to_bytes (`Hex "a8f64a55431de56f72f9c9b9c048f06f7704a307ca7bf3b6a16e97f30c08b401") ); ( Hex.to_bytes (`Hex "83bfc521b214850ce3f186f7f8f7656a46f05b862c3a453c07e7c1fb3f8ce218"), Hex.to_bytes (`Hex "bd60e019907e11b379f2d58529b02c68803cf3ac3918072d2a25e4095abefb24") ); ( Hex.to_bytes (`Hex "dd1330fd4913383fc4acf9642c3fa3505248aeea9ac2fcbd1f4d7e73f1e7cd08"), Hex.to_bytes (`Hex "f9cf2e0df195ebc9b87cfae81e09162edf87b1b245d53823a5394a93cd019c2f") ); ( Hex.to_bytes (`Hex "32dd98fa86244f2f02ab2994b950b35a09fbf967085b004d4cfb4462281b7937"), Hex.to_bytes (`Hex "ed1970ad411b7af3f3ef04049162583d31710b69649d1037010a8a642bfe3d32") ); ( Hex.to_bytes (`Hex "ac904c42631b992cb119019248e1e0cddd234ea9cdcd0a6b5ba2675485ec830a"), Hex.to_bytes (`Hex "f55f29e056b4aee29e0fd4957e15f2bb232186528583f3fc60182163b8c6d409") ); ( Hex.to_bytes (`Hex "6add8ab69b26985a2ab2394641b9fe1e2b62ae46041c713504c4e2614e0c2407"), Hex.to_bytes (`Hex "79bfe0b9c532f24e7946b9826d2c4928ce5a95d562c1c96d4b7e46cbc946a123") ); ( Hex.to_bytes (`Hex "4457881667e4a60e510f063ca9c73ad7f00f1109ef3e461bb0152b8b1b1af525"), Hex.to_bytes (`Hex "f0cf47d8d724940e224dd3c8261cca9e8a3571a0f4447c3ecc2a859e553ee002") ); ( Hex.to_bytes (`Hex "8c54724f63e9f6fa1830cb067866ba75d01ea6f6c14d5cdd117d9c964aaa8a35"), Hex.to_bytes (`Hex "f726410b8cb8927172d67351aa5fbfdc6b38c5d77b3f44288288540d2d622603") ); ( Hex.to_bytes (`Hex "8df0491620861df3db1c2ec6c950c21f8b302ac17f7da23fd6402b3f98767a08"), Hex.to_bytes (`Hex "1fcf1af1f855fe1def349599fdc933ee1823aa686a7706c3ac64f037fb5ac32a") ); ( Hex.to_bytes (`Hex "9734e3e5e8cfde3aedcb4a370f93416cd88aa8c764f8b0125825f497b0df0f37"), Hex.to_bytes (`Hex "99cfb51ae4b120723c629c77de923216e7864a4b220034b05b92f26ea2af9b30") ); ( Hex.to_bytes (`Hex "2751c0f912500634754b009919f428c8f3e380f41da1d7f607f242fc462d332d"), Hex.to_bytes (`Hex "e36e689e5062462e255e9edf7cdefdabd575024b950e57fd139aea2802ef7724") ); ( Hex.to_bytes (`Hex "be58ca762fe23ebc0bc59bd5d877a83e46d78b77659b8ba8631582a68176c63a"), Hex.to_bytes (`Hex "0ca6a275a1262d010e529e5b751693d204080af9b281b37b897ade700dbba133") ); ( Hex.to_bytes (`Hex "90ee4484cac9cab0611d27ffad198e966bf65a83093e263f640c1cdaf771bd05"), Hex.to_bytes (`Hex "8225856fcedee961f5c9f55dee17d1e547815dbc5f5bd6a34e753c1b9c82583b") ); ( Hex.to_bytes (`Hex "80ef9cb51691e839999a8d86153feee84484d5a5dd6a324b669ff79f0294fe14"), Hex.to_bytes (`Hex "cbb512002040668f13fa371579c9cc6f82826a38cc3e9ed1dd745c6d85c72c16") ); ( Hex.to_bytes (`Hex "af88fe078e2ec0dc34f8aeff172a3bbdd5780b6498326f0c56cf10e083a6a434"), Hex.to_bytes (`Hex "33ea7372eeabf363a5920b042e703705c93bd68dc36e7d5445158a75125b6400") ); ( Hex.to_bytes (`Hex "75510fb3917e8eee4f2ab1988b321891f52e19ce437d6b0cc27707f745658326"), Hex.to_bytes (`Hex "29f8d58f0b7898d7a4eb78025ea068c4c17a64003cf1fab776d1a43bee6a2a32") ); ( Hex.to_bytes (`Hex "dd138961d64d3b1e948f95daddf28b242618e19726481682ecdce7a59893ac21"), Hex.to_bytes (`Hex "f43f4c5b758d2d77e3bcdffff9d077761f408ea208b8a3106ec849b3465b6e3f") ); ( Hex.to_bytes (`Hex "7c36bef187d8855559b63aa55acc07af4617a835e1923e9283f14df28c26f23b"), Hex.to_bytes (`Hex "4da7785e7304e66f478446b79190a139ebcbedb75ec494a5c3ecca4cda13c90b") ); ( Hex.to_bytes (`Hex "034937c52c2cd41d61ae39d4e77dcda6074b7a3b7f89db15d73d51cef8815c38"), Hex.to_bytes (`Hex "c98d9e191c0bd80eed391d5b2267e2792f070b6c4179048b34d9255337a60715") ); ( Hex.to_bytes (`Hex "3546ad84eb8631af3603d3cc316379a71f677cc6e26c28f10a7cb25c69b4c100"), Hex.to_bytes (`Hex "daa3ae1c0ebe4f7c18be4802ad1b7bc1616c0fc503f9ddbde703a9ea5e843f2f") ); ( Hex.to_bytes (`Hex "7f144b2610663873057018e0e6ea8ae7fcb8926e4d4f9e90283fb498c433ec20"), Hex.to_bytes (`Hex "ea3e0755a1eaa8290f1b312a7c229d721b65ee6d999c54b1f517248ac32a6030") ); ( Hex.to_bytes (`Hex "e7d138fc320fa13f122e0cd06c71301107cf9cbbeee77b8bc8b4257c4e0ddc03"), Hex.to_bytes (`Hex "4e49f01c2f2d37cccba73f69711981f289d712012357c8715ad368de62403a0b") ); ( Hex.to_bytes (`Hex "f53ce68f5d96572e2fb4cf9675037d1e21f271e0faacebe46bb9a925aa30c818"), Hex.to_bytes (`Hex "a5db45b155c9351e558c664c39a2bf38e544e10ac0b6792b18de1a2af2700633") ); ( Hex.to_bytes (`Hex "2c5289807dc13703931e09e5f9b7f38c8228f95b9500c2308f307434946e0318"), Hex.to_bytes (`Hex "bbf3ab1460e9ac8348a25867894ce9397822bbbaaf4e823bbeab0e778adcfc05") ); ( Hex.to_bytes (`Hex "ec11dca69faf154d56b783faf7b48896122c56c5929500a9a9763ec2b2f93131"), Hex.to_bytes (`Hex "d1178d410bbc77635e20a8a12fc6c7bde12775dc8ce508b8a00aea426a9ae33c") ); ( Hex.to_bytes (`Hex "e0aa951b61369c91291f7085f5adc021957e430a24a8d81550e25b977f0e8724"), Hex.to_bytes (`Hex "8f4f25d342f98a2b03280e9d93f2bfb81136e5fd0114362be06f251e3d975f09") ); ( Hex.to_bytes (`Hex "f7afd7af69cab5255f9667b61b763157f6d578e00080dbf06c486f9a51d65f10"), Hex.to_bytes (`Hex "253adf4e187cedf6c1264cb5fcd216f70ac7f8de72300383a8d8f9c6cc43723c") ); ( Hex.to_bytes (`Hex "1329afa140f59ad29af000ed7517f886b6fc96798d7278c9cf2b525ccfc4aa15"), Hex.to_bytes (`Hex "a265f65b658badcc0a8a3dfe29447e19eff7c8cb825a26bc7acc330ce97b6309") ); ( Hex.to_bytes (`Hex "63f1a59cce37dc75670d01f81c4fe43c70ae04d36f913319d03ea73d8228c909"), Hex.to_bytes (`Hex "298d35eb5b781a1436cab86b2175a110268264997ed751cd6cb53825b115961d") ); ( Hex.to_bytes (`Hex "d354576fbdc1717c6cb1df953d53a0c9c686eb48601145c92e0d448cf3f8a805"), Hex.to_bytes (`Hex "60f488cf9559d811423fbbf78a7feb445beaee7943bb8cbe862f50ed8fb9dc02") ); ( Hex.to_bytes (`Hex "15a95d4dbeaea24aec6233b9b26c25340766446a1ead29d2f8cb5fe6b2e2fd35"), Hex.to_bytes (`Hex "c07c0ae1cce5369a9e8e4264bfad417dc3dd7de7b0aa4ac686b017dd44ceb628") ); ( Hex.to_bytes (`Hex "09de57c73ef02917d6ddae3c98d51487be5cf8761b98bc46b634d4985d7a7c1b"), Hex.to_bytes (`Hex "fcfa970f818861fb007d444753129e7666ac376be59466e1d640a4aa2c590d0e") ); ( Hex.to_bytes (`Hex "744e9a7b1c6977b48a9973b2a0ea611c388769a8042b9592cb314df9c7d1ae18"), Hex.to_bytes (`Hex "a03aa09102a1b463e8e200cd596a5684ea99fbf4768facd96c00191f3cc39a24") ); ( Hex.to_bytes (`Hex "29c1d99dc5c511a69a3b0c461e4349b40764ac50de28ca8a47efa7a7a6f2e12b"), Hex.to_bytes (`Hex "521fca87c9464ca16293f9a4bbf4fd40475df0ffe28cf2992362fd2072e63923") ); ( Hex.to_bytes (`Hex "df1953d5ee397eb09e7b63cdb6a22e2e854d76585c1c30b2116e3f8576880131"), Hex.to_bytes (`Hex "40f788fdbb011c6df9f00e8178ec45ac537cd95ee789789164a8fb1272e7022e") ); ( Hex.to_bytes (`Hex "d8fb04a995ce2b484edfd4d9ef459f09a5326c035616706edf12d547d7cf380a"), Hex.to_bytes (`Hex "794876ac01110e571ae45e2014ffd6997dca6483e14ccbc0ab8827210f3a213f") ); ( Hex.to_bytes (`Hex "89318e9905d791d42a143c66dcbabe7bbf18cb639098711d7be5cc2bc5a1f824"), Hex.to_bytes (`Hex "526f46b9ab3f521017761b6b50612146bb15665f33b12be2e3d44cc32ebef700") ); ( Hex.to_bytes (`Hex "a9111819c0ba7c9bcd1327bf331c4ae17107d54e6f67349cdfcbc7e4f9b8c33b"), Hex.to_bytes (`Hex "be2b193aa5e7c3c05b60a8d8c0be9796b0488dd08bdc32f847db367a647dd30a") ); ( Hex.to_bytes (`Hex "a07769d5cadc491a61e4482b407469274a42c1f6b2b735769fb889a2f410e62b"), Hex.to_bytes (`Hex "04fcf33e67c1613eedf047ce8b264f7036d8ded25f3f4514d81dcd4e34d8c92c") ); ( Hex.to_bytes (`Hex "43e2437ca7a2be116a1e49bb581accae3e4f4b846c3b18ad018c781ea829f23a"), Hex.to_bytes (`Hex "dd4657381188c9e55b064b3fa637a2186e504f8aa377eb959f9e81bbb4e7190f") ); ( Hex.to_bytes (`Hex "c9cc0d12958689420d508fb2b576477c430e5762f6a087736f720304751a0a3e"), Hex.to_bytes (`Hex "d0e2a5f57f61b8a48fbec08d177501bfceaa63570f8a123ef2c51b1bb6051910") ); ( Hex.to_bytes (`Hex "b0697ac336631c6a38c99c4cf5b801abf10f5888c277704b1393572662949d21"), Hex.to_bytes (`Hex "b4b81d4854eccaf019f8ed8c6e70aa9c27d92d34f84c2e891995a8c280191c24") ); ( Hex.to_bytes (`Hex "c34c36eb3e585722885028d57e3e2927cd6ff9605714ca7eb69b40d5fd416d36"), Hex.to_bytes (`Hex "f919821e5929fe8b16e2ecef2217cfbbfea5ee0343fd6095a8fa6f05f4cca201") ); ( Hex.to_bytes (`Hex "4ca918520badb5f454936ddd9090243a7cc587de690fdc983e40f15f7c35da3d"), Hex.to_bytes (`Hex "3ab15dc89b451951407fb0900c72fc2b81d58bf81d0f378598a20ec06e22db37") ); ( Hex.to_bytes (`Hex "d277a139a923b363cc013d7148972fe6bf59a1a0509008251d85b8e9787c7c3d"), Hex.to_bytes (`Hex "ce6fb2b4cb548439b9d41fb1b1f16ec097a2d7e71c78564453f4b8f19481cd04") ); ( Hex.to_bytes (`Hex "f47a17b6cb834818d5c3fea46c54572d0adc3292a8e34d9876f513b37a7de50f"), Hex.to_bytes (`Hex "b72d0e70b14a5f6727710d3add6b44b0808074c1a3c6668dfb92520589ae9e33") ); ( Hex.to_bytes (`Hex "ceb69754e746c62801d108093a75faa3dc2a5d06f5d0091f73156e21ddd18a17"), Hex.to_bytes (`Hex "571e41b006a30e03a9bd28dfec032a761cb5c9ec5af3c1a231e13f8014717f03") ); ( Hex.to_bytes (`Hex "66835394bbb5ea592430f0c2f807d15ff285a0770a9e1f494633d65aba5b4819"), Hex.to_bytes (`Hex "40f7f65f70857de0fbeb8ff74b9feba7e28774bad5d8c74e48a4d31a0cbf2f15") ); ( Hex.to_bytes (`Hex "04e38ab8b7a45189e52dd66394f4bafb04b6fb46cff4dc525382a2f0af616738"), Hex.to_bytes (`Hex "55f23d0c33a39ea7fa7bf3ef0618c098d6bcb8367b7c04ceeaed63c3f4a78b3c") ); ( Hex.to_bytes (`Hex "ef0aab7161f63dafb0ccb7fe27df2af44e71e0956a0952f600dc9fbb2e2fd212"), Hex.to_bytes (`Hex "1a7e5c743be1d32b31473b1ced8bd5306c0e6d1560dee94fe1a56c04ca82751e") ); ( Hex.to_bytes (`Hex "4ebe302d3a3b264b4e9c9eefb5e103a34dd3781fc7d30c1a091a932be2cbc60b"), Hex.to_bytes (`Hex "e67850c90a54f85e855e65850bb7905d784ce63617c753ed669179308a468616") ); ( Hex.to_bytes (`Hex "489e31b714dd0d0ddc3f915382bc2e71ba081eb5a4ddcf5f78fe442deb063d2f"), Hex.to_bytes (`Hex "2df3b3a0348669a55095300dd0e6a6c8589f20967482e7890564905b04f1b305") ); ( Hex.to_bytes (`Hex "f15e3fc9ab9f5665f03fb0e545fb778c5d0d61a604446214a98c128c82fd3114"), Hex.to_bytes (`Hex "2a53817ae0fff4e073e5457669e054622a82fd194bfa423652bb910335d18524") ); ( Hex.to_bytes (`Hex "254966b206e3685752f629e7a1fdefd2c0a99c317cd4c621eeb34de5360c0124"), Hex.to_bytes (`Hex "800b1bebfc905149f29104ee15c3c2f0d6b30713089dbc6164a207363eb74a02") ); ( Hex.to_bytes (`Hex "3feff4547e387f106bf5430ada320a290909834e56869f8b0362aeb6450f7f27"), Hex.to_bytes (`Hex "0e4cccf565286b541000bf07d6557082710361febd687e3f35724d0f45eb8716") ); ( Hex.to_bytes (`Hex "48266d31ac4ea678aa507fa621253e75fd461ff1a579786eb76edab1ff18d905"), Hex.to_bytes (`Hex "e93ac99b6358b9ba5557cf04463f7bc3dfd2299f79aee47da3000c06a6e17b04") ); ( Hex.to_bytes (`Hex "b67cdf61c271c8491a0beae96cca80530efeb84103445ad01c3d5f038cd10c08"), Hex.to_bytes (`Hex "4a2494a8b3e17452b27f1ea2af74dcdeb454ee990d5fb1eff6dbb64e62324c16") ); ( Hex.to_bytes (`Hex "776888d553ab0a72aedf7116f85caacee7520554169e4b6dbe063f23fa476c1c"), Hex.to_bytes (`Hex "3faaa4f40a3cf5619a38f0b434235852fef8aa5030dba1c85c476cc434dbdc26") ); ( Hex.to_bytes (`Hex "893e403870290832e34ff1193b59a190e41bd7e671eef3095e534a13258f1f0e"), Hex.to_bytes (`Hex "1276acb1f9b819d5465874900e85f791282bcf08113646884c0de0732ba6ea13") ); ( Hex.to_bytes (`Hex "6fc65a4453a3394fb784bae167a79db5a8af5409049c1737d8b66ad636f2cf2f"), Hex.to_bytes (`Hex "7b596a0d95f21a680a722560ae9c42564d575c768d99448ad26e17107ee6ee12") ); ( Hex.to_bytes (`Hex "eebf04aff16610a3906579fb36ea3725b975e164f625a7b35ed0359e7e938807"), Hex.to_bytes (`Hex "a2a09f8f7edf4eb521a9739b002062e3fbae4fcd468cdbf8dade90b5ee431925") ); ( Hex.to_bytes (`Hex "cb7718de822b8ea859d06ce4d7f5948bda1f54328103a787912ef3f58f72b722"), Hex.to_bytes (`Hex "97f950fa69783d67a351d2f499241997d3b1c7cfa81d211c3799ac77609bcb2b") ); ( Hex.to_bytes (`Hex "b6ae910e358e85a6e8da3e42166aa597540ea028a28dd3f93a57aa12fb889b1e"), Hex.to_bytes (`Hex "22c30c2db763e19bed8c7039d44c506637ab3ec4caffb1d3fe60979f8ab24611") ); ( Hex.to_bytes (`Hex "3489b1a89ed2dada9b5306360f9450127688f16c39b12bde6563289f63cfe811"), Hex.to_bytes (`Hex "a65a02218c5f1550fb1d674588d8a1a1b20f36d2350827497bb896b982555327") ); ( Hex.to_bytes (`Hex "8fcab4e092e4c58c483cc6b0f7298fb21e77a23210ef387ead3237e643c51333"), Hex.to_bytes (`Hex "0c732ceb574d697608fef7b3c09e7405a4f149e45324a7201280604f56c67020") ); ( Hex.to_bytes (`Hex "4c006a23431ac27edb56135d430e75a07d76d9a0de38fef3100162b593f03703"), Hex.to_bytes (`Hex "245d06748471ce62af55d581a5c9bb6beabe1860e64e2dfaa0dce7e754c60b28") ); ( Hex.to_bytes (`Hex "fb44c2b03d91e1b038598e21c4d9a4aac628d65f6b9b463522b2d34307919523"), Hex.to_bytes (`Hex "9ee94c4b9b12aa5cec851353aaec45ef2bfbc2c8cca20f9c0ab818f531819c18") ); ( Hex.to_bytes (`Hex "dda413b06c422c03a0d917335a5e1be1803b0d83fdb99214d4555ccf949df105"), Hex.to_bytes (`Hex "03d03d6704474c2c078dd897af298ec4df53d8913ddd27d10564d8f252c0940d") ); ( Hex.to_bytes (`Hex "0936b9d4c97b810292a5d42d0d6a46fd94c43c05add5bfd7f60606c96d09233e"), Hex.to_bytes (`Hex "bbd048cfada21bcabd5e12e69e2a8848aafacd3300f357a8779f1029b5d80d0c") ); ( Hex.to_bytes (`Hex "1b5716cd762caa63ee9e5df3ee270867288f30ed0c3732f728b2459c0f69e72c"), Hex.to_bytes (`Hex "0022dad2e58f08cf4a5a793ba535756b583deb35c678dd6cd4be94e757da8b08") ); ( Hex.to_bytes (`Hex "fa048235f290924f0f6e7aced59b25bc6a5999fdba7d44e927a6eabb69a35121"), Hex.to_bytes (`Hex "d183994d083f1ec19b617b3a0e882d3afc11f27546dfcea9a879418a40e13b15") ); ( Hex.to_bytes (`Hex "154eaa320bedb4163e1603e02698025dc2fef912a09074a6dee0d413f30db113"), Hex.to_bytes (`Hex "c96fbf0d1458c3fad864ddf3e3db978d8e1973b9c58004f6fe30c7c4a16b440e") ); ( Hex.to_bytes (`Hex "fcb367d6ce02e55331b6352d92f26fbd89b2780c81761e51a6c3ebf268b9d935"), Hex.to_bytes (`Hex "8d3f5917a7f33b4bbf7e769938762048604f4e9603674915f033f043a1813d15") ); ( Hex.to_bytes (`Hex "01ffe53dfc52ba31e2ecd1b9412b6a37a02de8dc3183fc6280a7acf644578f11"), Hex.to_bytes (`Hex "a0f7a71e68dfe6b195f4eb1d63d3ad408bcb5f08bbdabc414722c14220f04f36") ); ( Hex.to_bytes (`Hex "0ed09e0c3816b436dbd1a410dcbfe051abaeb54a35583c918913296a647dab0f"), Hex.to_bytes (`Hex "ab9938c4a5182133a2ff9aec69ef16af00d10bafaa59b2c147737cef07667505") ); ( Hex.to_bytes (`Hex "3498a1fa1808e074fd60ed6b7c2b98fb7446bd2e5a23e3ddb6f4a3fd74525a21"), Hex.to_bytes (`Hex "cecd4dc583976c105454711a467228e1c31d3ac9856bf3d4704bf9d9c5926e0c") ); ( Hex.to_bytes (`Hex "1546c0c026d7651bda7e7b1963e88bbfd1bf5224b1e0d7aa899cd8a55c411135"), Hex.to_bytes (`Hex "636f9649780a33d8d4f66b4b4764e1307c105913507cffca615cf1915eff5209") ); ( Hex.to_bytes (`Hex "74e94aa3de79030d1ad773861f5694ccbffd1bd1e3c01a13d841c76a19c0f825"), Hex.to_bytes (`Hex "4e304d8904344dc1e916b36aa9698316a8ed9ccd70bc3537a54823f53a44b437") ); ( Hex.to_bytes (`Hex "68752e196e1c5699a8449ad787bee765a5cff788691377c41ff96a1fd1d2082e"), Hex.to_bytes (`Hex "ebaf4dcf7868168a6cde05e7d604b3aba715dc8914c859086fb479a075074d27") ); ( Hex.to_bytes (`Hex "13eba84fa8113ddbafd6d39aa87e3aeaae4cf13a35af8199d9dfe87a1ec0382b"), Hex.to_bytes (`Hex "7780063cc0de0d8338ebe25190fa2d42bc760cd10d0df7b8ac88510e675d9f05") ); ( Hex.to_bytes (`Hex "0ee1bde2f89710d9a053288f524c492f3b92abb381d4ce18828418a7dbe3d925"), Hex.to_bytes (`Hex "860995ba0580a7d556256dd76723ffca9410f5d2150e49fd01c12e73a951ec04") ); ( Hex.to_bytes (`Hex "37c2082d55b0759f1f554bb9f6407b8fd4021265651d0aff0e2aad4407355932"), Hex.to_bytes (`Hex "fc8735567b00b0c38b0056154c66fe674ba1907c4ed13339f59ef53766b0dc08") ); ( Hex.to_bytes (`Hex "1e6ff4d79156d6667aed39a0e42574578b09ddc7f5c327fe31a2f1227ab7af1d"), Hex.to_bytes (`Hex "9bac9d9f10e6bfa35c861453f2e638a53561f21319568cd46755c3ebbd667d26") ); ( Hex.to_bytes (`Hex "9afd5a00b755c022c1df4d54b45fe9fbccc6d1434126d548083c7aea2aa7c337"), Hex.to_bytes (`Hex "a4d22febd5afe1779c528c24bf76cfbf4aa4fa9faa07898511983da2adb38a28") ); ( Hex.to_bytes (`Hex "83a29ab02e2f7f8488a0ec5feecb74287286f29a8dfcd93435ff79d54f11013e"), Hex.to_bytes (`Hex "0bc6542237d2045527b7a76bcd148f8f07d580113f9f39754bc2208397567719") ); ( Hex.to_bytes (`Hex "5437efa47d67d821cc71fec4ca790f97f0a2e7933856029272817d5965316c27"), Hex.to_bytes (`Hex "ee4fa1a9d983dbcd2ccedf951e2bfa05847cb6e1ef118cd5e1fde023c6cbc701") ); ( Hex.to_bytes (`Hex "f89b41beb711c45d9e50fd71de610261c1156f4be55fdf938cfc55ef2aa6172b"), Hex.to_bytes (`Hex "43fe2854e727e91348d958533a6e073d9473a00785901d32f9f5853fbc174826") ); ( Hex.to_bytes (`Hex "4a54c9c58c6655dae94af106c242d57d22ee1c3debaf8ab8dcd6a642c225121a"), Hex.to_bytes (`Hex "e7f46170d602d8d8e2e03eede6e3211a6b85e5893892e5cb89bd172eab449003") ); ( Hex.to_bytes (`Hex "0b29b7e3df41e83a706180fddeec3ff1973fe54c4ea239ac22e1d5b2c575ce26"), Hex.to_bytes (`Hex "5d1179dc56f073e4ae0d62ada515e37621973c481e6c13a326d9d586ea836d3e") ); ( Hex.to_bytes (`Hex "f11683d91a742faebd449dcf58582d38be0f2df7ab984e3804386d404bd3f330"), Hex.to_bytes (`Hex "63804722625345c24bbbb4600826173ed62700c5fcda6db8182c295f4148e82f") ); ( Hex.to_bytes (`Hex "fa803c3c28116a7bb4f3f3dfc2b9a29c8037d17e61f20f34ec2b7decace50c3e"), Hex.to_bytes (`Hex "89fb373d2b2e41d7d8feb1c86a8647620c59052839026b6ff4f368922c38ed0c") ); ( Hex.to_bytes (`Hex "abe3e962ecdc17f535670c1beb7e0fefcf37f9707cf2978bfcee3cf8377d8f3b"), Hex.to_bytes (`Hex "e0ca2671e6a89cc808e20579f98a34bbf56fe2156de54a45f4bd822c1f8d451e") ); ( Hex.to_bytes (`Hex "905baaac55d2218ffbe74008a0e529e75deb630b759bc656f782c34cb9c9aa1e"), Hex.to_bytes (`Hex "f4adf0d467d470a3e20b7c19cfc5c15e426d3ff0f451cfc1ff27dc4e4404fb09") ); ( Hex.to_bytes (`Hex "fe315c202f0d2cb19115fb6b1cf7a6eeb20350f79c0aaf67e747371d66bc9803"), Hex.to_bytes (`Hex "86e81ca79bc5cbcfe3f8edabeadcc5137f1337e32bf9cc940e269971f8138406") ); ( Hex.to_bytes (`Hex "2b988d30f7262df837d7645195f763a49327012adb0c3b94d27777d9c743dc36"), Hex.to_bytes (`Hex "d49c00c99c72d0283864b7831e75ce952fd8e41e0c8d757fb22303875c978404") ); ( Hex.to_bytes (`Hex "03bc95c207643b5776b253366243813d9962191638555a71dd1324294c542d1a"), Hex.to_bytes (`Hex "b9eb2aa8370deb352bff687674bf3bc46fe3beca7fe286b068e85e0d8b49a32a") ); ( Hex.to_bytes (`Hex "454e2e36adbfc2bd90929da9c41da5e65d7df660f1067b7ad8d9a7657788cd19"), Hex.to_bytes (`Hex "6f93ff640563518def9713504dc6dbfabce5e4100f7c9fc69d98b6d1eadb2a2d") ); ( Hex.to_bytes (`Hex "637255cdb1b43a58568c2f3110f8e4aa4ddfd9071d2a232f3a77c6c4a3b5ba2f"), Hex.to_bytes (`Hex "f2be5dd31244e573a8e5ec67a187ce3e8167e9593ff623925d0598f510e0e50e") ); ( Hex.to_bytes (`Hex "a445f2d0cf6d6929a066c373bffc7782cf74991f74c241689b28e6184c2e0937"), Hex.to_bytes (`Hex "82f2372d532b8f831660b0c4605edd815d4e114534b07cfc1f34a94d639cff32") ); ( Hex.to_bytes (`Hex "6d5d440031aef09f4ef68c962ce2d87c2dbc3ffd9970c76e7a75ce4a09d4ed03"), Hex.to_bytes (`Hex "abda7daaf4d049b951ce21e4a67579959a19d468c9f787e38c37c2acd8837610") ); ( Hex.to_bytes (`Hex "92f9020d16ca367c1bcf2abd4477c4b37d238e2a7a87fad49a81c5f7daa39413"), Hex.to_bytes (`Hex "5a45631b525e13b65ae138aca01ff94bb655e81b649fd98121145dd78b1b2422") ); ( Hex.to_bytes (`Hex "1bfe89b9695fb4ce458d97c7ed93e7b7390c0341635a073be6d2006c8fb6762d"), Hex.to_bytes (`Hex "3e0c1fce111fc83a0c05b52a29af6550f143baa95a30c18a6730d9e7ba819716") ); ( Hex.to_bytes (`Hex "8fa435d889f0fe20642a07d6667723cb7c3b7cdd570bef18a0a4578f575f3d1a"), Hex.to_bytes (`Hex "89c9323e97257425ee9ab5381acb95de08ae8e325ac4695e179045517038fa12") ); ( Hex.to_bytes (`Hex "f30015b11db7cc54074e55c9087be2ea5d81336e91a0acd753a8dd1173e22409"), Hex.to_bytes (`Hex "2a94e9cc3cf9616d33e8837ed15d9e2d50f7676dea7a1084a5a17c75626ebe3c") ); ( Hex.to_bytes (`Hex "767397b7d011967434eccd4c4616ee911a122aa811ee1aa795de85d1bf4b9f0b"), Hex.to_bytes (`Hex "6da27eeacc7257d1276d0887db5871d14d2bea1eae1f936099dd28b81346dc34") ); ( Hex.to_bytes (`Hex "6ff9e51ed803bd1f7a0791b682971c37e55cbf19a7f52df5539d1d45b2cad602"), Hex.to_bytes (`Hex "c3f9905e7153b8192be0b7629e101e6e355b4a1d2cb70243f84621e26dbeb010") ); ( Hex.to_bytes (`Hex "2273aa81c734cf24e35ec4b12ebd473239ea13047843aef9a6786578b8dc160d"), Hex.to_bytes (`Hex "c8b1a73b02e5419d811a66fc862c5efec30f7e42d6c029e7cb057149ca05f305") ); ( Hex.to_bytes (`Hex "9d7b2f2568a8fa1a2cb4e9527b61199e83f1e3e99d44f4d5e820ce63110e2a32"), Hex.to_bytes (`Hex "73bf51630acb91b3cd6a5a4f7b1f0b6126aa20cd319f763a67bf1b56a228e33c") ); ( Hex.to_bytes (`Hex "b23f40fd399ec73004f56f915612821d6b2bd665deef73fee24da3c642479429"), Hex.to_bytes (`Hex "174da5b241996eaacad4341b9644e25045cb99a1c442066b0ca0fdee9d60f301") ); ( Hex.to_bytes (`Hex "9e4a77e0a506ab4b9953bd52423b30a3209529e77b1fb44bb4faebd0efed213e"), Hex.to_bytes (`Hex "e59964cb5f144c461048ca1ab76135df35565637fc58bc045057bf6b9a27581c") ); ( Hex.to_bytes (`Hex "44cac09dfef0f499021742b082d6fb0290d8682931f1fe2e1044b16d2e22e215"), Hex.to_bytes (`Hex "67069ac9e283a067fb87d26b4ad1ab23b0fd5d2a1eebddab7e6690be0a96600b") ); ( Hex.to_bytes (`Hex "af4f5aba4e6840c76cc37c1395ce224c1a2b5ac42ba41a28599ae0976b146b37"), Hex.to_bytes (`Hex "89e22a98b0bdefc4fc834c56b6a754f5dff831be0fd2678af66d7841039f372c") ); ( Hex.to_bytes (`Hex "4f8e1f4ba82fb62ad4d7e051527604569b0b6162b42e1d86506e0e45bde0c431"), Hex.to_bytes (`Hex "1ebe2af79e3ed3d8ef6c4a7f7bee03b8a64d390c38b43c9af0b5b313278e2812") ); ( Hex.to_bytes (`Hex "3e0fea1f9e118c1d53a7c0af238448cff41a1d4285dc6e0b8e5d1fffddf11f26"), Hex.to_bytes (`Hex "aa6c9ed150579901d48e49b7df821dadb73191b609d77b2480f7a51579b83925") ); ( Hex.to_bytes (`Hex "9a93e8f880fb8975cdbc5ad41008bd9e449bcc0cca79bafd80c95d8fea1aa01a"), Hex.to_bytes (`Hex "0be3836b27fa55a51b8aa48cd31d8f570d376bf802d1f71d9153334e63464a39") ); ( Hex.to_bytes (`Hex "0560a0b2b4ffa620e2c424fb718feb92f884f79667098daa0d330e8d0716e316"), Hex.to_bytes (`Hex "705032d4601a44dd5b7b211b1a77114b482fda264e509bcd7e47722ae3eb0a30") ); ( Hex.to_bytes (`Hex "8c50d4d1874c4f7473a548d95860ecb3ea9fb94379b4ccc4f23feb7c8f922e29"), Hex.to_bytes (`Hex "ad27d0037644ce87200b88e6ca90b99b5a7465e4da412dc99c27292df5812302") ); ( Hex.to_bytes (`Hex "e31dd6300738620705cc7137f3e3dd1eb34ab6c21c057f1b930e0a8a02ef5304"), Hex.to_bytes (`Hex "3fb806518c20f44ab2e91119b80b2fa18462ca13e355238d2de4dd7726c69a19") ); ( Hex.to_bytes (`Hex "cb31a5658b07d5a5addea84096d3d4d64a19842ea3109573dab2242d7f7e4607"), Hex.to_bytes (`Hex "e56551185dd5ca2aadc7c9776a14b20f3d79255ac7f9214a9a665c7e53b61f05") ); ( Hex.to_bytes (`Hex "fce339273e2c775cfd20dcc52751f3fe04b0f0432b09d193812e303ab41a1036"), Hex.to_bytes (`Hex "612927698a2c06a23c55fe33da1eae959f1dc313d68e550c18f5b10badb37926") ); ( Hex.to_bytes (`Hex "876556932d4a994c602dd195820debdec48dec459325c2e1eb887237f2d2352a"), Hex.to_bytes (`Hex "4dee9daf3f2098ddb81921c58c2c665c4e518084cbcd3ea6aa1b2a33d5f4da18") ); ( Hex.to_bytes (`Hex "c370faccadd04cd8a00931cc09d27c000ffa25325e58ed78a0be8a4243aa9e03"), Hex.to_bytes (`Hex "5cc661aaf904f7b8d11f81d7ee1e02b5b6c34106e1d13a5ec809fb97992d6d28") ); ( Hex.to_bytes (`Hex "739c43f5b378162f1b110ad3dd1c1b9f4d83329b9f4701161b722094b6c1c117"), Hex.to_bytes (`Hex "1a20c290720b685b23bc1ab04dcbf9f904e56af2d46b4e1d2f82885969e09d38") ); ( Hex.to_bytes (`Hex "86bd6ca246a5ccb13075488df03681d5072fc493615c22c0d46bdc1cd2590039"), Hex.to_bytes (`Hex "d4228e31de720c6bb6b62f543a9e5bc240749fdae606a8a74d8d2643ce712a3c") ); ( Hex.to_bytes (`Hex "22f18904a211e150cb8e5ffdda1adb07b902901fee51a6f6ca57ca41858fdc25"), Hex.to_bytes (`Hex "dceeedc4e0e641829253a057055adbe1a332e56ea1d4074b32f4ed70970c1a1d") ); ( Hex.to_bytes (`Hex "f4718600f6686bb207439e0b0ba0db751f712fc8b765a7d953e8cb27c0f46527"), Hex.to_bytes (`Hex "5bb67ae924d0a7b26d2a277726eef51d3d2789c751450e6c9d637528997da127") ); ( Hex.to_bytes (`Hex "8dd66042fefc10db6326bea7957c5471a3a1ced06a285812ea47e988ac52df27"), Hex.to_bytes (`Hex "b70fc300535b4e3d326e8836e4bef6935d55d9bd1ccfe4bce21055c3cf324620") ); ( Hex.to_bytes (`Hex "a6c2ecd7f8287c8b172ad204b7ba8434cdbfd8e63855eb682ffd0905258d0804"), Hex.to_bytes (`Hex "08b92e758e01f857e9b36033e29409c764139a96c5e0b531511c4cb69c3b1d24") ); ( Hex.to_bytes (`Hex "378b326307a90f074e45d1f7c97fb7809f9b1cb095ba51a83cdf207254174f10"), Hex.to_bytes (`Hex "fb19e705537ec87d878bd5fbd5f68f335f32f71420e7c5f888fe510cfcfe0903") ); ( Hex.to_bytes (`Hex "8015f89c47813eb3d8391a4378f7433dd116aff8672534cadb0c4b210a431331"), Hex.to_bytes (`Hex "99434f0b7359c913b0a25cc66e1a34e5d3e4143323a652cb21dafcf952c5ed2c") ); ( Hex.to_bytes (`Hex "a72c0bbc21d3f2e25b41f2b98b6d52b20110fe528f2a60bfbc8eeb9589f2683d"), Hex.to_bytes (`Hex "aee060f28c98bc15b47315a75372fed3b955305a86a06e5dfe4067ecfd9aef08") ); ( Hex.to_bytes (`Hex "14c5be91c3d6a64fb8ec64b82932a8b567219841273f5935e491b464d3ab0214"), Hex.to_bytes (`Hex "bf9c825fb5914fadc14617bdce247860af5c35adad5a418902aa318eb1541d1e") ); ( Hex.to_bytes (`Hex "f09217ffe3ff68f2b77a24c16d820dd36a545104a8de35d828671b5b7f78f307"), Hex.to_bytes (`Hex "485bda22307cbe06ceee7ee5afb01961edebd03b93efb2ffcb2f1bdb2cf76901") ); ( Hex.to_bytes (`Hex "8d884b29342856e48456f2643b51fdbc23d4abc4fbb88ef09fb46bc8e300b60f"), Hex.to_bytes (`Hex "def83f3b0efcbce71ed7aef9ea5ea6be581b8acd85ecdf70a6d86c896753f619") ); ( Hex.to_bytes (`Hex "331b223ccfbffa347b09c6d53c884b047c0ccc005a71b0bff5c94420d0547906"), Hex.to_bytes (`Hex "078ddf61da1b19d9754485a646a42a6d13db8aa5bbbfbc92394f1cbafbec5a06") ); ( Hex.to_bytes (`Hex "57bd887c48ebc3868ef8d211d0d48bdbcf4de4a7ea69d8fa286e9c6eed302230"), Hex.to_bytes (`Hex "f691a2bba5edbe0f9a3591ab646aea9273838b4b7072652ef40284e57376fd30") ); ( Hex.to_bytes (`Hex "3abf55a9ab2e84eab9191d65a28c0da27afbeb8c50312eab53e8738391f4ca3a"), Hex.to_bytes (`Hex "97caec92f6a4ca44d3d3ac229a4b2e2baae67bff9e2730bc15175b84716c913b") ); ( Hex.to_bytes (`Hex "47d0d1213bb00212beb554aa5257ae033c2aaf2e084125c97a0b295d1ce5ad13"), Hex.to_bytes (`Hex "4c97365cdc8c41809fc2811a730404d66d1b899306baa223a136164bdc9a6f26") ); ( Hex.to_bytes (`Hex "020cca405eaafd9a518a14a44d9858a3780f42997cccd4ac8b312c2385c18721"), Hex.to_bytes (`Hex "80459f495d3d818a26d8a2df3e1113a566f42df2f7fe8debd09959433bfd3120") ); ( Hex.to_bytes (`Hex "9a30183361658e031816676898ccbcfbed87900b5ff478c0bbbd9c84efe8f230"), Hex.to_bytes (`Hex "91daef49015a6ba37493201b96de957ab85a3b0faa06caec15decb64b863dd31") ); ( Hex.to_bytes (`Hex "b3938ef997b296471e02d91e41b393f422c9115af04959198687c54c32a0c535"), Hex.to_bytes (`Hex "04186326a7ce71feed07bbe55d54353be09b0864028c0c1e7e829e13274bb224") ); ( Hex.to_bytes (`Hex "1b7018481e523df3eb12b14f9b6bd00e385768d5b1f68dd32d1f64e3a354832f"), Hex.to_bytes (`Hex "9c485d8e8bb5572fc561c34d17abb18891a007176061feff2640d93fd9759707") ); ( Hex.to_bytes (`Hex "e034069f084b097df3b4972073426032e34a058f565d952d37a8b0a0e1839420"), Hex.to_bytes (`Hex "65218bc632cb32743f2db07f6521d97b8aed43619ecd8e0f49ec4ab9a95f801e") ); ( Hex.to_bytes (`Hex "04ca44836c89135162b0dc144081f83e3686e3642a401244ab3adf7fcac0a22c"), Hex.to_bytes (`Hex "4e3339ddb611d4aef559883ce864bfac0f8bf1bb0f908ac61cadb75997a1c235") ); ( Hex.to_bytes (`Hex "fa62d868af183e3d136b057f4906d5e3d37f7bbeadfa454e57e9cd203eda5918"), Hex.to_bytes (`Hex "49e76af390a05d64f12a46a0b2b31dd4583c97655e2c6da9d0e0518f18141e14") ); ( Hex.to_bytes (`Hex "f0fe677abe00bbdadaedd76a1ccf7b5ca1556c3156f46c93067f67e1ba6b3a0d"), Hex.to_bytes (`Hex "a3ba600075809bd3af615130fa40e3e82d6585054bc45d19d107a90b6b79d300") ); ( Hex.to_bytes (`Hex "811d33c05eb9720ff03a368eb47009c5c4fc16a72330678d146824fb5d482d01"), Hex.to_bytes (`Hex "de172426b86b91edd34970018d026d428c0de3b950158f39eefdb5ac46c21809") ); ( Hex.to_bytes (`Hex "44402507c9b99312dcac2f1adf0c8840be0305f480cde34d1d5c21e08cdcc921"), Hex.to_bytes (`Hex "bba3d923e0320b2a5da84d2c0033fd8d2c03dcea54fafa9094bb76d9b4e6222b") ); ( Hex.to_bytes (`Hex "f56d433622fb677ff4bf056940a9b78c0af21f48c68500075861b8c4f16b672c"), Hex.to_bytes (`Hex "9e1a9c4a008cf17c6cb05fa18fe631f987957e6721005a4b606c5ea34af6b02f") ); ( Hex.to_bytes (`Hex "5f59700235110c98608a8054c2a007da818815dde167aab0fbc6fc9f46e47520"), Hex.to_bytes (`Hex "32190aaaf6d6d0441be004f3b6522b865e1317b5486e0d693fe392632c93e522") ); ( Hex.to_bytes (`Hex "46fa5ed54dd261f21d2dce2ee18ca2e33c1ae45d0fedc3b6a0cf871a91dab01c"), Hex.to_bytes (`Hex "421f365355564254f53848a045c29b089e5a4179664ecc8d1b66d71dfb80c634") ); ( Hex.to_bytes (`Hex "185b6ed57290652df3dbbd22b4248779236f7817d15b46a385e3134b0e406139"), Hex.to_bytes (`Hex "3c5dd2ae92625efd3f78cbb3bc16754856583c2918fe9f8ecfd0c399a9cd7e25") ); ( Hex.to_bytes (`Hex "120f56aa7ee41383cec1d019ced188a2ced9b524c847e70db8f95060f617f91e"), Hex.to_bytes (`Hex "12d5e3aa17c4b35120b5f93ecb268c3024c11005e2fe249efa09454a2059c410") ); ( Hex.to_bytes (`Hex "0b1db126f6705453b451f8c3982b6e365e7019b0ef1a2ac0293ac4de78f8f20e"), Hex.to_bytes (`Hex "fbd6f8c8fdeae1bbc10f62c04a3582ba7c919bd39a288449141ed5bb6e04b032") ); ( Hex.to_bytes (`Hex "73cf163209e7afe580e5922562ea7cce3d467b9d3dbe3b07d7b9c1e96f970502"), Hex.to_bytes (`Hex "dc16abb94629ef1ec4a5ab5c0eea13552514f9888ff37401e94d4865c6f6b716") ); ( Hex.to_bytes (`Hex "855c62779c2ecb07ec1a517324d3f633aee7f1f10eacf0f7ef90974e94c53f3e"), Hex.to_bytes (`Hex "ad238ce2ff2186f2e6fab52ed245e444f057df5bad91c6dda9dc5d396f15bf36") ); ( Hex.to_bytes (`Hex "9a7d264465a124d5abaeb284962e661fef47b1134568892cf154d031dec6c938"), Hex.to_bytes (`Hex "1de2685a2b03ac05ab206c60c0ddbb133a8b7c22da8a263046ff717bbe3f5b2d") ); ( Hex.to_bytes (`Hex "2bc92e84e385b6118b4924a6dbf44499976a40b041d6c09f7f374c12514f4716"), Hex.to_bytes (`Hex "ae2d34aff3606811c5fcc3f348c205788a09d3d152d11348f9e53b82dfc68f20") ); ( Hex.to_bytes (`Hex "3ebe5e83997a69c1ca1a9931bbb7f15e37c9b8fa3bd93b42dd0b1804a3356729"), Hex.to_bytes (`Hex "dad1a20709c0b7bda1e043b55b8c8c368e748c86209513c27cfec2461f178a0f") ); ( Hex.to_bytes (`Hex "c1e0c0aa16fbdb6a5cf229a37f9f70e6a1adcd3650334503b7ef5d1a0e227c06"), Hex.to_bytes (`Hex "ca52d41f087afbef41fa95399e53c591c22b09b270e29f94f5636c9580eb940c") ); ( Hex.to_bytes (`Hex "e93cb9c48ff0ce769bd189d8bb0065cdbac014e591bc76cb35cc7ff1edb37626"), Hex.to_bytes (`Hex "b13b0d44fc7ceea668b59f5537faf0f9fde07b982299755ccc1eb99f259bba18") ); ( Hex.to_bytes (`Hex "e5f1aab77090aa8867bb332b4a1219ed13f8d2c569e56ee545659c68483d6d3c"), Hex.to_bytes (`Hex "3727926d983cd32dc5d368ccc967384a898450234b10d80d55d5295103a72012") ); ( Hex.to_bytes (`Hex "f6e39ec2dcb74ff3b4d67f789f41ff6824fd50b6446013e1bb060a3f4ebb070f"), Hex.to_bytes (`Hex "6848d6309b3c2faf418dbceebdd076b81d9731a5eacfe1d5b0e745953f739f04") ); ( Hex.to_bytes (`Hex "3426ba1dcaf730075da949ac6cc89c22ff5bf06787549f296572c9bb6f6cf01f"), Hex.to_bytes (`Hex "9efb43c3b385d442ed32f4d709b5a0a641c3543e257560ea1e269b8e3d14002c") ); ( Hex.to_bytes (`Hex "47f2fc2eae58da8f0ee1f754220035ee5468d8a167f06e73db7b81f3f6731b17"), Hex.to_bytes (`Hex "6511782882b44fc38ffc61a1af16a5f121f79f6dbd8cc798c1119fb9d37d383b") ); ( Hex.to_bytes (`Hex "c2015bffdc8d2cf528ca93bddf703d527437c1c4a5d3299cc373de38cbfecd31"), Hex.to_bytes (`Hex "b89cb126283f8cc660fe100693758bfa8499512f95d4f2de85b1adddb66c2122") ); ( Hex.to_bytes (`Hex "4ed2c0f3df8eed6bd4a0bacdb937ef99db54fd65497457af44ca19244eec0427"), Hex.to_bytes (`Hex "c2b17eb6d02bdf8c6be826b43da3f8587f9666fe62af3b650847ce4d587f2623") ); ( Hex.to_bytes (`Hex "3422b7ad84f2126396ab1cfaa20a4f7795567c13e74c2f7bd2e0da8303b26408"), Hex.to_bytes (`Hex "6cb7fe53d13e1d733e4cc9d5bc32f0cac6aab283280bb6c4b5c0cfb93cd62521") ); ( Hex.to_bytes (`Hex "5997d9a1173fe95320a01be03ec7bd5b752fd3f9a6bbf7ac756a3516c8c15219"), Hex.to_bytes (`Hex "e0d4f31ab6f0ec66901a6eed24091c57c014c01fdeb5057780ea73f6225ad71f") ); ( Hex.to_bytes (`Hex "d6aa918c40eae151a35dd76d4adcb39d969a1fe8065a5d56905399ed0ffb2a0b"), Hex.to_bytes (`Hex "a3eaeb24f7e685cbdcb92795b83de70a687a1c95e128e3cb71159e231aae2f2e") ); ( Hex.to_bytes (`Hex "d589c164a2ea58f9f74f1c12d1b766fd1b546de90c6cb33425003b6c0986730e"), Hex.to_bytes (`Hex "ecb83b7fde19bd2c7f17c90d74989d04506c8bdc94e476dc1aab68a96cea163c") ); ( Hex.to_bytes (`Hex "f3dab789ccad5a9185971f0e1cff0929f27e9a0128a1bdd5518dea9e8ffb373d"), Hex.to_bytes (`Hex "38f180a028e3be092021fe07905873e610917c5de11513217754fdeef4690f19") ); ( Hex.to_bytes (`Hex "9b4514c828d087987d9a77c91497fe0b372c70a023a1bc09ef33f9553fd6b52a"), Hex.to_bytes (`Hex "aacb9a6675310477afaa9c275632d9d2030d2e9914f43b168a37230725add32d") ); ( Hex.to_bytes (`Hex "e11e622c4daf70aa6ae14fa4f976bf82f41be928b3df23d8ce50ef8fa7862e0e"), Hex.to_bytes (`Hex "909ee695dd97df96d6bc59e9757d40a355929fd8c5080688332bc16de1b3e32d") ); ( Hex.to_bytes (`Hex "cbb2ec583429960c0e561e7d4d867d0d55c5dd3ca6d328ec1a74630200ebe00d"), Hex.to_bytes (`Hex "0e6f7b937d20c81cc6c87edceee797977ae741e48a088622a4c54fc511482f24") ); ( Hex.to_bytes (`Hex "913021b4b808e602fb83af262cd8f90425252fba44e59c4d3ba5514848e28e3f"), Hex.to_bytes (`Hex "b42a3df93c0aac9d67ed1bf36955d77e3187e7143fb730b5d8b1efc758680a32") ); ( Hex.to_bytes (`Hex "ef5b8cc1739cc7f133af5dbe27fbdcb4b89a13a43734fb005846b8fe2669a927"), Hex.to_bytes (`Hex "015905a804954ff986c18c5fb57016d84cd4ca3fc9410ad8f9fa9669fa6dfb35") ); ( Hex.to_bytes (`Hex "08ddfd8ac81cd4ba27eb8131a3bdd24987f264e72ea4d96bd33dd6aabc7ff91b"), Hex.to_bytes (`Hex "79343fb9b614709e8e0ad985cc3acd2ebf737e3824dadc9aa1e613ee8e20461e") ); ( Hex.to_bytes (`Hex "e712e232374bfcbec78243194e0a9479cb7654ba4121b5317e09c611d9b8d70d"), Hex.to_bytes (`Hex "f724a645be378f870e298db510f7039ef808ca79c0aeeb9dbdb80015ac3ec900") ); ( Hex.to_bytes (`Hex "fb42090389eb08d891e61f81e447ffbc56912274b6d2a748bffd0ee052a78e22"), Hex.to_bytes (`Hex "cad44cc20aca99f121865207a7070f6b36db2d033665458d7833b140483b8802") ); ( Hex.to_bytes (`Hex "1b5b9e9fb44393e6c713fd326aced589979aa15a5c6fd79ed1bbe100c933c42e"), Hex.to_bytes (`Hex "e1ab3e4086edc3ea4e8ab8df5e9afef620dbb09751636a8fa2cf11053d042c1e") ); ( Hex.to_bytes (`Hex "d494a3ba15f2b79a6fa28fe3163e8f1d5674387719fc5941db25c0f3a108ab00"), Hex.to_bytes (`Hex "aa845322474227718ba61efc39d216bb7035e40bc2b73b0e8e9c763bd7d90e10") ); ( Hex.to_bytes (`Hex "ff24e948c9aec34214f44bca8f1a639b16a40e06fef7f29ed18195f09f8db425"), Hex.to_bytes (`Hex "6e76a0353a2de48ad672cde9d8f64d1063292304b25cdf7136625478d7589908") ); ( Hex.to_bytes (`Hex "bf675ba6ad0bdca557b04422a2e89ff290b1b88dee3e115585d47b2f19c11012"), Hex.to_bytes (`Hex "23dfe960e5e8624bdb5e6922a03225e6e4f9a2bf17a3fe4a884b261df6673401") ); ( Hex.to_bytes (`Hex "9d20789f8c3cd5d1d1f6c79d542e13978fcee219b6fe999983adb245c1192718"), Hex.to_bytes (`Hex "caeb1b0de8074064aac8c2215ab49ab5e9bd1b136a16cd37ae113905f179883e") ); ( Hex.to_bytes (`Hex "d1afb380a74728217b149d72a3982dd655e480775bcd76ac5779936455d87113"), Hex.to_bytes (`Hex "61d82178ac35c503ff21d3d4b87f97184cd9d2099d5eec573dc3253d96883329") ); ( Hex.to_bytes (`Hex "33b75b4f0990644c3d1238b69e14252f56fe073ce6d53b58fcd89acfbee3d038"), Hex.to_bytes (`Hex "57f382021076829474d455fd5d4a35906134d7465f0690df6211f7a7e9e8e21e") ); ( Hex.to_bytes (`Hex "f6f92583da20cfc26ce0b53a2b325841afde5fe77003ea5545b3072355519104"), Hex.to_bytes (`Hex "5611d258c7b76c3ad4c80a42a9ace53e2b04b093fc784e8267d679865fec0023") ); ( Hex.to_bytes (`Hex "86124acde74d344595bd45d5be9f00704dfe9c32dc45f3567086224c100f111b"), Hex.to_bytes (`Hex "130b034dee677e58fde3a1cfe04ed62666315be4bc3da431877d99cf741a4c38") ); ( Hex.to_bytes (`Hex "de5baf0315b839a751371659c34f73fe680f71a5abe2ae876960dbfb097f8028"), Hex.to_bytes (`Hex "fe91c30852ef9a955cc396b294488392735ff0997fc45c4af2e55095d423a504") ); ( Hex.to_bytes (`Hex "f0a2738455a1aabb97704a59dd488d84c1ddeefa5cecdce32ed9c4d75a2c8c3a"), Hex.to_bytes (`Hex "e12bfed45077bc3bffba3be5480cba7004680dc1835604a8fe0d7fc631669410") ); ( Hex.to_bytes (`Hex "d7cc7736c5210236b3119e60d946e89d1ee5c50f590f00c6f3832aba186fe512"), Hex.to_bytes (`Hex "fd7c6e6333c972b42b25f1b15e507b74699ebe0f8b8b4f94cd1f35ccb2051b08") ); ( Hex.to_bytes (`Hex "cc02e6a236279ff61f62c4d5b725b64080bcc94ba7e2ba09b4a198324239b019"), Hex.to_bytes (`Hex "dd6ddd92069c25ab77265a71850e3089917b966d354d181577f725c07e01fc1a") ); ( Hex.to_bytes (`Hex "c447d1c91da19cbd65f6ea74e77029a79b8d50e3517fb24af165e2525f85801b"), Hex.to_bytes (`Hex "314cbe25f33ecd479bad2af59538c1e4277f9993a39d33356fcf5af4287e8823") ); ( Hex.to_bytes (`Hex "e211a6e144f06308f8787a8e7555e479d630540f159cfcc84d27de84368e7a3a"), Hex.to_bytes (`Hex "4d3ab3bab52fa3036778645ca634d20bc1d713d0ad192b9760f22ee2942c1216") ); ( Hex.to_bytes (`Hex "fbf853c54d1878df1428553738eae89538db396d2f0903169fbb01c9eae66927"), Hex.to_bytes (`Hex "452db622d21aae6aa91e0d984f704183a62360da03b51773e6927ca7aa5bb116") ); ( Hex.to_bytes (`Hex "e593f3d34f69ad355d63c1ecab6b77b97f840fa852253e672d6cfd6f2e562a28"), Hex.to_bytes (`Hex "33769baf0f3061cd7a76b96fdd7b785f2ea8cba30b3ee6f82658f6706c8b293c") ); ( Hex.to_bytes (`Hex "f08533400b9278f9edf4e787eddf414740b097a0509af79a553d7f7a0104f209"), Hex.to_bytes (`Hex "decf1d1ec7a74c48c1cba5c817fe5e4357500471aa1281e92680c5b805992c1d") ); ( Hex.to_bytes (`Hex "87e6a4e2c1dd4e8a8f858e01e25cff5b6ae5a1832f66e5c6ba2d9b670d00a202"), Hex.to_bytes (`Hex "a0b2767ceaf66a2f5640699bfa4bc7b8141e6d49ad1679fbe2044df105caf41d") ); ( Hex.to_bytes (`Hex "5cea36e3eff68860c854b53a0a119774701bab907e8a4abb07e344a6a805ca16"), Hex.to_bytes (`Hex "cf03e0eef64b6bbc4c31175d39c29794eb57df964e8c28a52fc3b270d22cec05") ); ( Hex.to_bytes (`Hex "4468512dba5a4b1df0cfac1463e7bb0e47595019c352e2caec586b9869776f10"), Hex.to_bytes (`Hex "912653bd24de32ecaab8ba9f79b182af514df3332d59f7addb22805382abd71d") ); ( Hex.to_bytes (`Hex "f9946c35cc5d0177ab739ff85f8f5be73747e281897c4a93e39e04e705ea5209"), Hex.to_bytes (`Hex "f775509d2dc9db7bd49e285ff0218599b26f287afe4f0d929232694bf6edb419") ); ( Hex.to_bytes (`Hex "acb3f918b748932d72cbe907d8c3e61e590b7bbde347f727af390f0e4e264433"), Hex.to_bytes (`Hex "857f279fe514925384fac7755cf1b5ba8aa8cb1b01a5925eefeb986ec47bbe39") ); ( Hex.to_bytes (`Hex "367d9857b85cfcef061c8ae083e33142e55fb499e7c3f48324b38d62d94ac41b"), Hex.to_bytes (`Hex "bc83601aed7351b00f557c379db43f5d56c934c67e1fc49e52e34979bda4a22e") ); ( Hex.to_bytes (`Hex "c515ab186db811cebdebcfe7bb58fdfd41a7de1a65161a01bedcfc0383766718"), Hex.to_bytes (`Hex "a6633674b3a7658ccabcb4822cf6950842bfe51948267f6955c13a69898a9e1c") ); ( Hex.to_bytes (`Hex "62d983b5c150f120a433f36bdd4f7c5b9506566b14f21666d7f939ae2a15093c"), Hex.to_bytes (`Hex "765fe4115cd14c8d957a65a3a2fbe63e68ae90294d94df57fdfc7fdd0696403e") ); ( Hex.to_bytes (`Hex "7f204ec6aacb1d0faf74e8049600ce242b3b164f41a3068283536095a5ff4118"), Hex.to_bytes (`Hex "b7df2d17844a4574878c74e93d66614e10ae52766fc4ac49403da02d31ebf935") ); ( Hex.to_bytes (`Hex "d27c21e629cfb27172c7dc0ce46dfb857a87460a602db0fc34628325a8cbcd0d"), Hex.to_bytes (`Hex "7b3211d658e0e7a5dd0246d4dcda291fe560aa221606d250285d1169d74ac11b") ); ( Hex.to_bytes (`Hex "9f413babd498ad76ff97256e508cadffbd1eea43b6bb063af7c5fb6ff3b0a33d"), Hex.to_bytes (`Hex "6d29f06b0eed47f7b09358d36398b5084e067fa701a3c9fe8603dcd79eb5e918") ); ( Hex.to_bytes (`Hex "4f68a0659b7b6519691bc4192d8c3821fa8783d70b214fae1baaf91756f14a2e"), Hex.to_bytes (`Hex "ac23bb7d88da5a7ea5ce1aaada816a07c71229464a2cf54600cd9aa7473c7c37") ); ( Hex.to_bytes (`Hex "60895a774f9be6d953228c3a6d68f83c50f6dd38e7167c00fbafa9d17fd85c27"), Hex.to_bytes (`Hex "dc39be83e8faac2e92975e5490cb47a15621a50c0b6694b81f2ae654d57b2c10") ); ( Hex.to_bytes (`Hex "43d78a812552503d51449622daa4107638e1cd15a3dbc14a688bb493eae9632a"), Hex.to_bytes (`Hex "aea07c988a7b2f60a29c2bd1ffd96df27451de6c96363474f6988d59012b771d") ); ( Hex.to_bytes (`Hex "2df10325fa79e69ea7c17caba867a0e30d5d00a9d6cf044a0e35ce031fe7b620"), Hex.to_bytes (`Hex "c0e9d9012e3599ff8a918bf328ebff1c4b6a2f6b1d215a3f783f33b9c51afc35") ); ( Hex.to_bytes (`Hex "3bc12e0d30ac29fd9d2690a02888866d3f6e1ddfe3b47b61223d9920bd446210"), Hex.to_bytes (`Hex "53b0837d07624bbab4a55405b3222b75c412a0f320839993f353a7f99512323e") ); ( Hex.to_bytes (`Hex "f62dda67132ab021e571bb2a36f55ed98dbb9a8197cf66c48dd1efa9f5d2c10a"), Hex.to_bytes (`Hex "3d056fe5da722c65f82509dd3cdf163e8eaeaef064dc8644283dccafd6d18310") ); ( Hex.to_bytes (`Hex "22cb04153f906dd6a2f1fd24951d747d1d70055b42112004f928a6a4dba18125"), Hex.to_bytes (`Hex "e80435946131f531ee2723e96a08b5560bd453f4a6db7004c38b466abb3cb737") ); ( Hex.to_bytes (`Hex "5a09622ae6fa645ae109cca39ab95d1acfd4f1b44dbf875c25cec75a45e15435"), Hex.to_bytes (`Hex "3c6559b2aa29fb6299bf69f628e07910d3566ab6a2e1b5c73d667906276ca91d") ); ( Hex.to_bytes (`Hex "95c5e40597758aa304917936bf16b593a9ecb7067c61f3dc0ad946624996041c"), Hex.to_bytes (`Hex "10b09820de629bcb5b3cc4e6dcbd110bb5a471211996060e63b55e54bdf9a00c") ); ( Hex.to_bytes (`Hex "8cd6e15cbbccccab82a20de547af7c6f6f80aaab5e136af3e8aa9510deba6e0c"), Hex.to_bytes (`Hex "e2b3e6699ecc9c75bf63a205df54ddf96b9447cf3cd7da8952bc832bafd81203") ); ( Hex.to_bytes (`Hex "8440093219f4633dbdd30da139092ea824ca16e0482da409d6a5fb486025d522"), Hex.to_bytes (`Hex "8ef085e37b915f20c5968215ea59bae8f4610212055fdb07812d0dcf10fe271b") ); ( Hex.to_bytes (`Hex "bccdc0c42620c5c3f1c4049875a0c9e5016d9b894fa33d33f19fee696f9b9308"), Hex.to_bytes (`Hex "296a0ba6905c3857e39e8998f00afecbc29405ed494f6ce5d0fee4a7df878c1a") ); ( Hex.to_bytes (`Hex "52704a521786cc9b39803ba53ebcd19eaeb3c198280a3be85f0078f379b85621"), Hex.to_bytes (`Hex "030c4c1ad64f45e437d1459eee772dfd2e46cabed1d74c362402066da0615404") ); ( Hex.to_bytes (`Hex "dfc842770be4dca6bb4c5e2f9ffbf677f601a1c8f2a671897e558de61d89f606"), Hex.to_bytes (`Hex "60932cf332eb36e1e39483157a80cc43850e3fbdd86883b89bd9ffa343f7c739") ); ( Hex.to_bytes (`Hex "88a1c5de2480924d3e3586d32ba9fcc666761bf55dc8125875ad85b9ae962236"), Hex.to_bytes (`Hex "5bccbc0e474374af4ee04fbd03df6486e1a6ed90e1df7cbb6d8dc16af049b704") ); ( Hex.to_bytes (`Hex "645de6613a7ecb478b161d614b8f68260a2781f0c6b11e85d3c4d9077765cd0b"), Hex.to_bytes (`Hex "596e64011d9ca7b8148dbe3c810aa0ac6122d4a422d6e39baf0a21ffec448f22") ); ( Hex.to_bytes (`Hex "d877fc32eb32e8011d6d1ecf9fd47ba302693a002676de4a5b287368ba181028"), Hex.to_bytes (`Hex "f7e06a3f8cbd223bf99d9ecce9d47a641a86e2e54e269f591be111c7bb4dc71b") ); ( Hex.to_bytes (`Hex "150eb8f12c5031ea28b448cd60513dc3ecad17de10c923cc479ca51acef9de07"), Hex.to_bytes (`Hex "325964b4baeeaea4654d8710501423b1d6fbb3e273284fd72f46e456e528f737") ); ( Hex.to_bytes (`Hex "b4c54bbb959f307e80c561727df462609085156d2a4f3d8e98a3381694e2d501"), Hex.to_bytes (`Hex "52627651e025942d2b2f6d6d263a1f66ddb8f42f376026e2a5e48e77c3121712") ); ( Hex.to_bytes (`Hex "7c6fce773ebc8980c07f0fd8eb22b2a650823e9490b7b8e9b115b46660069510"), Hex.to_bytes (`Hex "6c2130aa2358afec67c88cae7671d31b924c003a175d4666a25facbbdab80817") ); ( Hex.to_bytes (`Hex "0604d51ef4b35a0f93818e6b24b8d63eef7266c1a717c8efed6fe0555ce6d903"), Hex.to_bytes (`Hex "d9ef153a0a0a66d23a60380260315831070404ef6e578ad0ad02863379fcb512") ); ( Hex.to_bytes (`Hex "61b21a863850b4afefdda20e12253633f0c3e9bd8a1ed2d06766440f07564231"), Hex.to_bytes (`Hex "2695cdb0f62b7dd49759ea036251b6df863df1d93ae9c86bfea39f871e7be336") ); ( Hex.to_bytes (`Hex "f863713825b7419689fb7d9713e2142f01248e810f0f2e875552019442470527"), Hex.to_bytes (`Hex "3ebf77e2e99814e9e80dcc4636131cbcc224bb9d5f260d8117d4220ca74f3c07") ); ( Hex.to_bytes (`Hex "dbcb574f7684e07274ec5aedbe43deaaa8efaa38e7197a6b389c03b2e403e13f"), Hex.to_bytes (`Hex "fc5f479009a4b0f77fd46c59458b27f2209b6100333c898e44b35199120a9a1e") ); ( Hex.to_bytes (`Hex "f7def4251d1d3e27b1be71315a840320d4f2295f6581176dc0295b5d7f5e7008"), Hex.to_bytes (`Hex "ff7c5dfa295893557e5d89f7cd412af33de7a2d143eaf21b54d6530408bf0f02") ); ( Hex.to_bytes (`Hex "139ab82dc799ccc77f453e1a72f869e8275ee9f9759bd5f82172ecb0b9df3c2a"), Hex.to_bytes (`Hex "ae43b3c8879b92daf023ca1ae3223cb39b02d54320c0f67e16601bfbe575160f") ); ( Hex.to_bytes (`Hex "f5a81e589cc4a7daa468f60bdf60245e4661af9c29ece2048962b6c6eee73824"), Hex.to_bytes (`Hex "e35c900950c54cd9bbac987cc93949914f009de6d5a0d6905e000a439997300e") ); ( Hex.to_bytes (`Hex "37ba3ddf71bad216f3467290393a87f978892c2ec70f0973d8db93769fca6a3e"), Hex.to_bytes (`Hex "42822fe167c6bb148ecec764dfdaabb82aeab27bc15b941aec3a71aff6bb2d01") ); ( Hex.to_bytes (`Hex "ac36d7c9da000d245460d51e2454015efb9c423e768e7bb7efbacd38ec954314"), Hex.to_bytes (`Hex "f8f4ef183f46d5a112e9ec6e2b6a13acb6ab5b651a2f5b1712dc628877e5f811") ); ( Hex.to_bytes (`Hex "269f8e1ba5917d91f92edbe2b3d4a796a580eceb93286764ada7dd6a2cc71504"), Hex.to_bytes (`Hex "9db61c54e578fe3107a964a12ea4d06f9da9e75938fe9b7753cceaf913f30215") ); ( Hex.to_bytes (`Hex "2c9609f5d0689962e8a1b9a56c54d80f4d86ee883771714fff9878bbd739be21"), Hex.to_bytes (`Hex "fab4a1567c59302ee107818353ad021a336dfd1c9e2a024dc1b4aa517de33c1f") ); ( Hex.to_bytes (`Hex "9bad87977a27e8d2f3de813d87efb8069492dc0c58a03fcbd5da10b666b80e3e"), Hex.to_bytes (`Hex "e1fc0b298d986f41fca7ea9e469c9de91af38c967cd326e83ebc962965503a30") ); ( Hex.to_bytes (`Hex "9665f9b73dc40d977ab3be7b04a0be8b20ff864f7cc0bfff7b815b2a70e8b02e"), Hex.to_bytes (`Hex "15cf3ac792dfeccd4b1ac14bf4b849a38604351a825ca24c4ece638feea8350c") ); ( Hex.to_bytes (`Hex "9d90c582fffe3033658f7615f5cc37a07eab65d1bfe5b4041f70982e0dd38f3d"), Hex.to_bytes (`Hex "16693f614c35cf76e4b868effc8cacb348336dfbec231e127e00656976469c04") ); ( Hex.to_bytes (`Hex "16ad8a20f85a8bd2c19e2225010ccc8544b7bafcb7001000da5059e1b53c162f"), Hex.to_bytes (`Hex "0c8f4c85a6a50482f31b9c9fed50c2aebacfa84c3b9778a6f6ad6210c2786020") ); ( Hex.to_bytes (`Hex "e7ba44aea2bf72b5d96558ede57b39479dcdd5d76026d812f411fbd0b0910238"), Hex.to_bytes (`Hex "ed004fe304f09eda9e7145f1c5c9c7d1779c32e071b0075d6cccca5af31b1f11") ); ( Hex.to_bytes (`Hex "4bf7ecdbe9fe4e9d401cd16e986bb65477922a1f67e99dc6196f0109c2f71e38"), Hex.to_bytes (`Hex "70483d4c9162cd78c9a766433fb09d96ca8c98adfced3fc639ed6c19f1c37108") ); ( Hex.to_bytes (`Hex "e48825cde05a95bfc685c15b45be5d1a701be7931ffb0f80b893a41f52689904"), Hex.to_bytes (`Hex "7f44a4462ba08808288cb99c8f424fbfe29dff140307378110b4104376908713") ); ( Hex.to_bytes (`Hex "df076b0fc0b42ed1f43977f3b79c674800447db1859c8dd249e375a8e147d90b"), Hex.to_bytes (`Hex "bae16ce5278d62dad89fb896d5f8b93f376258f629b9e35db62e3826a4623515") ); ( Hex.to_bytes (`Hex "5cafe6bd033baf36c60df6d71533a44f979191a420a06770eedd06b3f147321c"), Hex.to_bytes (`Hex "96f60f655abb52c6e164fed20c893ef551ac0e6720c1bd9d8ab02344e0cc8607") ); ( Hex.to_bytes (`Hex "e2ab025c045a529b10fc693ccd0388ab22f86749e7045c4f73c9248d8bba7c3d"), Hex.to_bytes (`Hex "a78c0ec2a96d6fc34d05c718d30cb83ad888fbf18bc400ead575e9784fcd852a") ); ( Hex.to_bytes (`Hex "a211b6d45ef95bac432cc780814d6d134e8d8cd288dfb61f1160d5171bfe6a24"), Hex.to_bytes (`Hex "72495647337b683664bc0d362ddd67145862a9935fdf0c41a0e8c624688b8835") ); ( Hex.to_bytes (`Hex "92d4624a722ac25d8c8d50a72b9b60267184531be65a5950ffcd6597b1346a26"), Hex.to_bytes (`Hex "cba258d3db5bbe7f6aa7a81cfdf7a4404a000ea573321d49ad624fdc4a0e6835") ); ( Hex.to_bytes (`Hex "4efd77f90c99dbbf9ecc6dca9d363764ee5150b548d0b5c74546d571ec730b25"), Hex.to_bytes (`Hex "81b312446be4ae41fb61dc6d00e59e9e94cfcebbf56d2fec3d60160b15e29317") ); ( Hex.to_bytes (`Hex "47620c77796d886f82e1a10f74030015822f6917b20376f3ecb7f50a68731f3d"), Hex.to_bytes (`Hex "9e72f9e45aa7b68117ae1f34aaae35e70abbaae1c5b7ff4e4ac35d4cd4c12302") ); ( Hex.to_bytes (`Hex "327545794df19d4112c5024e3f2880d736c56c75a147fcf082ed6ba00207e31c"), Hex.to_bytes (`Hex "60687914539720aaa05350d971967bb7ba84dd093ee64e8006a8dd961b71e109") ); ( Hex.to_bytes (`Hex "19c089a534ba7f609859825db6babd7938d9bb7fbda4caca4de5f82c85ca9436"), Hex.to_bytes (`Hex "547eb33fc02855f5e466bb1181b7494a5b51c559e777e49448fe090bf2a09b36") ); ( Hex.to_bytes (`Hex "61e7413c434803a9aeb2da070e6c4f33e1e87507b13576fa21191d90d143dd1f"), Hex.to_bytes (`Hex "a3e1f5117eaf42b0da0a840543c3dc724a7aa040f3221feca7af460c14cd4d3d") ); ( Hex.to_bytes (`Hex "63b85aada153166599723a3fa4c50931d98c51acfe89264a254b6f30e528cb32"), Hex.to_bytes (`Hex "32077077f14122ce1af87714bf68c2e97cf5d9bef5c543b6af3eed8f0c8eb31a") ); ( Hex.to_bytes (`Hex "29c95bcf7df437ad20b6a63ccb68c4fe5d62cde260528c3861b447bf9420143e"), Hex.to_bytes (`Hex "d6dbc4b9cc3b91e1fe94d3cb8e016bf548d1d8b28bd8847a1a57d1318bd09510") ); ( Hex.to_bytes (`Hex "a4183ba473da244c1c4f6d8849ad2f199efdb0290022cab9613f0e918ecdc323"), Hex.to_bytes (`Hex "5b99530c2c7b6a44c6d646f7829e40f646f060d6a5f19ad4daa7f7c888669f28") ); ( Hex.to_bytes (`Hex "ea1969f4892f2293af412fd56dceca23ecb7b5a036009f7bf81bf73acc0ea936"), Hex.to_bytes (`Hex "6ee9ed2f5a4d78aca148cce5c20ec7838865bedacd7a3c62c2559f683c4d2e26") ); ( Hex.to_bytes (`Hex "0e13ddd33eb08bc4c0c4e8e38d66dac8784d0e62fb8d9684073a14ef838bd221"), Hex.to_bytes (`Hex "2b519f7cba4107a68f043fb2596bafe96bdd979ae3ff9bb47ce6b5ea7aef3c07") ); ( Hex.to_bytes (`Hex "025cef02bd2e8cbbe7d5a3a86bfb3e9ffd7a2482d6af5edd491dc23496064d0a"), Hex.to_bytes (`Hex "1721457493268bde7591c89a133e278822cefa60113f4dafb0f50c42def72e37") ); ( Hex.to_bytes (`Hex "4fad94e671317a00836499b4437d630b1ee3d971a4d9413fe25f67f759410423"), Hex.to_bytes (`Hex "c322f098d9d989c6eaf3ef96a4044338989686a7fb07f7cd7510f35252aaff00") ); ( Hex.to_bytes (`Hex "0caebd3b5059edc7cfa863f34e0a7107222224251da454b8d1f7718c98d91c36"), Hex.to_bytes (`Hex "5ee81de3a8f5c3d1f572eda2e11ff9616b7a42b447302ad0617f0a14c82aa928") ); ( Hex.to_bytes (`Hex "ef09db68f58f9be61d1bb64584a855a9370ac00bf80f810134b6a12d8774773f"), Hex.to_bytes (`Hex "9e11585f9761fcba024acf941768c88e6b5861eff7b49df732b3e9deff0ecb1e") ); ( Hex.to_bytes (`Hex "026b9a5d511b7c2e635b41bcd95eb86de13178f261c7619ec568e71d077f631d"), Hex.to_bytes (`Hex "fce88aa83b0195b6f59b52561a868760d0c39e44e254e437b1a689a834acf132") ); ( Hex.to_bytes (`Hex "9d8fc89579e9c64511354f36bd137791ec4c37f78ad4b518f321bc82aa50cb1a"), Hex.to_bytes (`Hex "7c13730e1eacb5a0dd332a7c693bcce9b9467f83d6fb433822f0bdda07c3f23a") ); ( Hex.to_bytes (`Hex "af8085b17d5120f3faaeb8da5d76e44eec342ccbc89e876ba79a2cd0610e0418"), Hex.to_bytes (`Hex "d54466ca319a9977378c52dfbb40575cc25c73995bfa6f3cb202e32dcb7f422d") ); ( Hex.to_bytes (`Hex "14d38b244e1f02b76ffc771e7dd4a645b3c047947e17de71958281fc8e6f362c"), Hex.to_bytes (`Hex "be59f73e1c6417d4ea276d3793a4f046943e98a3f38958cc0c6a24950482ca24") ); ( Hex.to_bytes (`Hex "2d02f9fda108414d2aab38fff6c15b44cd67c5088f46342cfbf205b04e22c927"), Hex.to_bytes (`Hex "5858d83a86e37fb6e00a7032c189e735c2729cbe8eea43af420193a57bb9ff35") ); ( Hex.to_bytes (`Hex "eaad3efa779c9c67dde959c17e610c05535d9e270badd0e4d0d2caaca785131c"), Hex.to_bytes (`Hex "9ef9d8768c7505a609c13e23b6095c244fc9defa3f1251999edb1ae132cb060e") ); ( Hex.to_bytes (`Hex "a1e3fa9746c6a6ddbcd2b951803ef4575d45fa2b2616ac05eab46dc414b2e627"), Hex.to_bytes (`Hex "e4ca65722439dfe05b7ad4c3b21ec0093cdc18a7ddd6074b80d6a416b1e66e04") ); ( Hex.to_bytes (`Hex "fb93840d4a882788252ae517bed441b6e5f113ca5ed6bbd1b7f9bd9d7583e614"), Hex.to_bytes (`Hex "d6093e04f227bcc5bc180d74d81b83436c6451db51b9284d064135ae5c92f22f") ); ( Hex.to_bytes (`Hex "65c009a8eab8abd2f74258d54f4c26a56a68ed523368bd368e02d9a220a1033e"), Hex.to_bytes (`Hex "ffbc642ba215cdad4e1d41facffb418b1817c4aa29e77562ca7628a5ddd1f405") ); ( Hex.to_bytes (`Hex "924218dbdf459f25a28827bd219fa38569a42b9d50d04177af7cd3fa8ae42836"), Hex.to_bytes (`Hex "d4edc25209a58cf34f965dface3dc8db0ddc4a705813e5672ab772777f03d72d") ); ( Hex.to_bytes (`Hex "573dbb92bd3893de419460c838724b945542eb6cc05b3de043be0316f60b8928"), Hex.to_bytes (`Hex "c4915bffbedf8d59d86640b0247d1790929562caaa24fe295dee0fd06db51b0e") ); ( Hex.to_bytes (`Hex "c3a231cdd9b1f2802be864533481cafe2678864705847e660424ccdfa52a6a19"), Hex.to_bytes (`Hex "227bcb504eeaf24487252b84a9ac03a27d483fe05e523f9cc83624d6c60fbb1d") ); ( Hex.to_bytes (`Hex "a72e26171df8f8d9bc8bba3e8d21c248ebab2a90c9ac316a8293c6c657be8610"), Hex.to_bytes (`Hex "b03f3844eec4219b1371c6d27c18bbfff99d9c0da086dfbb39ef1569bd0d0019") ); ( Hex.to_bytes (`Hex "83f05071a1e67eb84cbbcac72a17d31da72a537585600d45a9beeaa4f54a870e"), Hex.to_bytes (`Hex "f0bd396a0530d9277524acfa8feafcafd1261eac2bf9ce2755e8f293f2ecce1d") ); ( Hex.to_bytes (`Hex "a6b67cf624f132ecc76f04bba9c06fe74b9d69a8b92fc908191f1336caf0a40a"), Hex.to_bytes (`Hex "8c29f9f53a387ac76a7a618f570c2a6c23576987f483fba8747db12f3893ac0d") ); ( Hex.to_bytes (`Hex "aff7d79b26edaea4658179be905545cf02ba07cac2a566bb3b2fe033fb97712f"), Hex.to_bytes (`Hex "ff55dc2679faf5c675b82c79001dd7b181fc4bb3821b0043ff359d24f9898525") ); ( Hex.to_bytes (`Hex "26c3ea84546986ca8f52057654b4d8641469c8f19813a147968b946633f32606"), Hex.to_bytes (`Hex "1aacdf8c95c69acb565a8cf25d39a251628743017a998229eacd87e53436a020") ); ( Hex.to_bytes (`Hex "87af6aad1538224a14f151fe39c23db2f971761dbc6f44e7416277f2c4b38f00"), Hex.to_bytes (`Hex "e12bcf38bcff35ef2a154b6e67100664ca5543f7651b39cdc42daa8f54aca933") ); ( Hex.to_bytes (`Hex "1aacb71660613eb4bedbdd33fa45172d96b98c15dcc7f2fcda41f522b4d62d22"), Hex.to_bytes (`Hex "71199a6bb68e5fd18cde768b37b45e732fcb1ce209fd9e7ae347d03691680526") ); ( Hex.to_bytes (`Hex "270c7db20e6728a7f4096ed89b85fa0f3e1dca5bdd1d12fc15397092acf5d53e"), Hex.to_bytes (`Hex "b59eb0f39cad662d3f4975391b4a760fe4806cde397d1c3161218e5310a9c510") ); ( Hex.to_bytes (`Hex "9e44fe08552eefd8dc21389bb4f0959792ff561959336d432f5667ffa1c2f02e"), Hex.to_bytes (`Hex "2c259623c05a61eaecf48f2472e5c3d3f815ef359351910853d009c5df7d0b0e") ); ( Hex.to_bytes (`Hex "d13a9b5275745f591aef14e1a29302c2f203874b317918a33181df56fedeb525"), Hex.to_bytes (`Hex "9ac875ce3d6807323e6a66eecc95a30a633a70db4b0d751df2505d6d148ca821") ); ( Hex.to_bytes (`Hex "d05444fe57a1a0f1488ea1b983ea8fe575bd21b3be1e5fe799eb3d26e1cdf02f"), Hex.to_bytes (`Hex "8bd57138cb13ad78154adfde0af90bd75518864a9b4659ceb3f8b0d8f2b9d007") ); ( Hex.to_bytes (`Hex "6081943dc85f8611acf89d7df6cd33ef1608871b1fc8fe7708f2bc818e5ce433"), Hex.to_bytes (`Hex "39808f5f7df59ca78d1e2f18abdbbd461b2de6c3621e1e126b12087a2686ab2a") ); ( Hex.to_bytes (`Hex "264e57924e5f0973abd0c665c5920a803edf338c96739b956e669adbbc0a1217"), Hex.to_bytes (`Hex "a4ddbfdc71dbcea4257145cc12bba92312504450986584491a152d4523a8b915") ); ( Hex.to_bytes (`Hex "b337f8d4c9588118bfd4ea123af5e135729605718010b043f4afaef618bba112"), Hex.to_bytes (`Hex "ffae05648c3ac9d068b8ed214bdb797c0d5885324dab64fed64a964e9b6ef221") ); ( Hex.to_bytes (`Hex "be93bcd82774ad5e10dc40a29bdf741075e483b858f4025eba48711a88945816"), Hex.to_bytes (`Hex "93e4b630a3d620cfcab52a3e5bfc50c04d4b1c5264cad1caa94da94feb999b2d") ); ( Hex.to_bytes (`Hex "c01fab20529e05bf3a0e1e8a2b617d8a8cb3cdf44442deeaf25424818e7f3133"), Hex.to_bytes (`Hex "5e4c9305919b88c8f6977c0a0ec769e5f44891f8c8b9d5442fc7f5685b5a1223") ); ( Hex.to_bytes (`Hex "2814a6f29bbfe49410f389df685790a548bfd7e6c4ea265fef42313a61847717"), Hex.to_bytes (`Hex "44e9a9013da9c5d4b41a82f3b30bf3005c1101905eb0303e01d5620d7d86aa13") ); ( Hex.to_bytes (`Hex "8468d583e66e770dad7fb00c333190c6acb63cd871faf9034e2ef2693f2c5b38"), Hex.to_bytes (`Hex "9c4726f977da2ae5d5f7f9a3dd183240633be00f67ca8a69730da9456fe4e61b") ); ( Hex.to_bytes (`Hex "f3234cb388244fb56c55f3dc0f4df7208351ca876bc429b67d4de597071b053e"), Hex.to_bytes (`Hex "a9c4f4a76bdf45281232c5efb37bd801eb68c3f06f8438743e786895cd4c4c05") ); ( Hex.to_bytes (`Hex "1e60f2ed412b030eaba15626806356caba4a365bf473c1a9c798fe76a4f60b37"), Hex.to_bytes (`Hex "c8237370c8b93ae863e42c92fc12cb681dcde2aaa7cb581dac8573d7bedc4116") ); ( Hex.to_bytes (`Hex "b18c8607b250d9338118b079244d4655cfe7b37063aef8ce9fdf54566f0ddd1e"), Hex.to_bytes (`Hex "7d6df83bd25f19ca870c1d488b7788d804a09c9ab64c1877851739c52284cd18") ); ( Hex.to_bytes (`Hex "a938403c1d06d0d37d333ab36fbad2358c8c48a0d0cc5a2bc855f070f9517731"), Hex.to_bytes (`Hex "44cfdce5462da07d87acfd0004724819ed095279052f5dd3ae40d48fe4667b06") ); ( Hex.to_bytes (`Hex "19623bc5c1f567be4151dc49ebd34d0c72dc3dc8066e85199df3606c344e8005"), Hex.to_bytes (`Hex "ca2e4ee8f8b570d90a0baa6fe7baee8dddcf754c0d4636ceffc2b64ea8300b0c") ); ( Hex.to_bytes (`Hex "37f3da85b4b311d29b8b76d1c9c1af7c9166a06a086d294f50e46e3956176914"), Hex.to_bytes (`Hex "1893b76cbe5e8c9093197a8a3c125e484d5430dc97829cba9f57ad67c8b31b0b") ); ( Hex.to_bytes (`Hex "388e899c6a12bbfd6ae1c724e3b9b0ee7639bda49b64632a672ecf38e38abe2c"), Hex.to_bytes (`Hex "10df874297e2c802365ecbff3a304bfd8026c299645d24fe42096aac03f0d42a") ); ( Hex.to_bytes (`Hex "2e47f25ce4456663f306708c20fa1b58b6538ca62ffc427f853e96a5595c5f3e"), Hex.to_bytes (`Hex "98749517d77cae3fcd170f330df797182496be93a8c4bc0896110a88705ab616") ); ( Hex.to_bytes (`Hex "0064fa6c4ea3b8ec69b037178da62b87d600304d568b2b69f728bdc2326bc81a"), Hex.to_bytes (`Hex "b6ecb84ad77315cd59896fd056d4d810a6a6b840db94d7c4e80122f60514c40f") ); ( Hex.to_bytes (`Hex "29cc86fb214e3cb141a80b225622d46df644099157d35d4836625ce8f337e613"), Hex.to_bytes (`Hex "202595d1d6d23e39d9414d7de0201487a0d54d1bc9e4974f99795693266ee10e") ); ( Hex.to_bytes (`Hex "c4787fb618e8f018d752fe5c76828ec7495272338e102910bb15323e9f77e71c"), Hex.to_bytes (`Hex "ef7df469792c3c0a77b20ac1d35b4a92de00da3f025184a61e35868b7fc64828") ); ( Hex.to_bytes (`Hex "190af46e70005a780c45791e6de19efc31ee138f13beb02115e530eb796e5a20"), Hex.to_bytes (`Hex "92ffcd54367b9b1064d644bb76fd19e2d4cfc6a4f547dc26738e389622009613") ); ( Hex.to_bytes (`Hex "0a7edbdee3ee4f28348674abd6d6a3ebb38887733e136d20d26719084494e206"), Hex.to_bytes (`Hex "26fa5ddd4577f2327e6c1d4369ffb961ddec68d881c35e7b8e991f1b42b46d39") ); ( Hex.to_bytes (`Hex "5a43b30925299ff089620e70727fd85de7e427306b038f42c2c42a85ab38a13b"), Hex.to_bytes (`Hex "c963a6e3f76eeb31ef5e2a2219a5fb662d5fa5d985ea56f07bafc7426e1a9d0f") ); ( Hex.to_bytes (`Hex "4d5c7d5a0fb6d82ed40b2bbb81ec413c57ccd3cfc15162517a25928447f82816"), Hex.to_bytes (`Hex "d23a49dfa0de28105d1fba54e08e649f71504b33a600c3a5cb8d9d4c47d6ec22") ); ( Hex.to_bytes (`Hex "c9b418a64f8878badeb81cefbdcf9024cfa7b849554562622e82d852006cde22"), Hex.to_bytes (`Hex "3bf1b44eb6d874b59174fdc6a87de53aebd26ac59a8451d967bbf58a4327953d") ); ( Hex.to_bytes (`Hex "02e5aea9c9213b422a3759a14f5860b5f32754e152a6e3bd48666a10ee25e913"), Hex.to_bytes (`Hex "d43c51f0c583c0210f67fbbb069ca41ac4de35a920263e0000d3fcfe9b2cd006") ); ( Hex.to_bytes (`Hex "9ddf68399a34ac1bf48c94dd88957a4fda415b42b9b2259c2204066780c3bc34"), Hex.to_bytes (`Hex "6aab7d7608e5432e22d5de3057132e8f7bb99c7b5e425d1ed1a14c3a68c0613b") ); ( Hex.to_bytes (`Hex "b3338ddc1515222f4457cff4d24544874b70247a9c9e39d46dcbaab7cdd0480a"), Hex.to_bytes (`Hex "f8b4ed7694a96532fb34db834c4f35ad6bf583019a97768c4bf33c384a3cc024") ); ( Hex.to_bytes (`Hex "368fde6bde486402cc945b068cc9df47d4657b8f8600ae1b27fcfa49e4ed2537"), Hex.to_bytes (`Hex "adaba0c2742c84075cc6faa13169b09849d6a0c5f5f3a2a0aaf67af0b40ae434") ); ( Hex.to_bytes (`Hex "2d805a98a5824ac0e3f8f20fc211dcf05bab43c342889cf91ebc434960d5fe1e"), Hex.to_bytes (`Hex "877cb172af38732b8a451f13903e767a7e79e7ed8c1a58f54852e5547f886021") ); ( Hex.to_bytes (`Hex "198278bd297906a8a64b6808c2b702456286fa1213a72418c0829cec68eb5f1d"), Hex.to_bytes (`Hex "7e19ffa0d86f0cb5ef17981ac867cb1eade9e2c38e660238c5bdeab8e8bf1f17") ); ( Hex.to_bytes (`Hex "200ba31acb320438f5db8a12769e06723e41f913816230fe3da2c0a3f6fa953d"), Hex.to_bytes (`Hex "0c5f707b6d68915c9af776abab2532a4100e52b0e8ba34152d8a937df7245113") ); ( Hex.to_bytes (`Hex "9aa433073ed4a5d85b68f84d6c16fc5980d51e480b732c6b3987a5b3c9b4740b"), Hex.to_bytes (`Hex "68e94b034cafc3f742b746dad14d0b28f12ba59243637c8121fda40f1972c620") ); ( Hex.to_bytes (`Hex "a9ce8ccc855d9a9be0695f636cdb3a8a841160158cbbe9d9eeb52a296042cc1d"), Hex.to_bytes (`Hex "66696df646c69112dcfaaf6b60d8b2d08e39f221f842e45f0c62eb3542d0971b") ); ( Hex.to_bytes (`Hex "cbb02186ed471191d4137590c5a0d9151457b5f64182b655a818babdcd218f38"), Hex.to_bytes (`Hex "e90bdd57edb6f4d78f712fc7a1dc59c630c2800401b03b671d2b14b034379f08") ); ( Hex.to_bytes (`Hex "d364f06611e2ef3f74fe232b92a61eabd3ed135bb816ccab0297fd5b92581e2f"), Hex.to_bytes (`Hex "0c6e6bcdf55f11e1d3c9626a60608e3b2a9629230a2c712ab5a3c2e51d1f8a39") ); ( Hex.to_bytes (`Hex "27556c51af5ff7b1745d54a911e43418e5489251228f3d5ae4e2e5993b5c9b0c"), Hex.to_bytes (`Hex "78914ccd971b19c5379f1decfd2c1f3d129b74a6b51aea771992501a3775541c") ); ( Hex.to_bytes (`Hex "a3ecf0bd7cbb48ebf9238a3f8faf1838c2525182c62b25126b75916b1c23f220"), Hex.to_bytes (`Hex "df64bc4170b76ce5eb887cecfb3e0765a3e9e3e010fcb84d7ae3d07e8daaf525") ); ( Hex.to_bytes (`Hex "9215b5c574119d983d4f18d323de22bc16920cc3e1e3740d0eef7499e6469f3c"), Hex.to_bytes (`Hex "8fa64e279fbc71cab07787b7d4f40ada525425547f1911e0ce07ad5f241fbc02") ); ( Hex.to_bytes (`Hex "17b081a006e16ef666ed1a14b99fa0bd8f21b2a5d3859b8d0552a09adf446833"), Hex.to_bytes (`Hex "3e28507ac29ecb215e35988a8deb2665d25b5b5a51662546aa31bbeaa2cfcc0d") ); ( Hex.to_bytes (`Hex "7810d5d5dceb01dfa9409745fe4fe7dc6f92d48821c730ecd20bd066bae3f425"), Hex.to_bytes (`Hex "48bd5d3028cfa41ace2fc52941edacf123209d4199ae796aa2dda7abc2cc7a28") ); ( Hex.to_bytes (`Hex "0137e461b167c9f64a3175cf714159ba26d345980cfd66234310552eef75ea07"), Hex.to_bytes (`Hex "b302501d63b36a5f8618f78dd3f1a742b14144e2da5f75b184e8e94781b8d806") ); ( Hex.to_bytes (`Hex "97f76924e10e60770021cf631194289dacd7381ebcd9f594d8f14823eda89d0d"), Hex.to_bytes (`Hex "8143f97e4510cb9d0d25de418e886ff2ff98bea59e56b44db6b183e7fe266e2c") ); ( Hex.to_bytes (`Hex "7ee7688b17215282db0eafda044cb662219bcec56aeffc560fb2a92683216000"), Hex.to_bytes (`Hex "be5758c756f78193d0aab2e92287642c9f89b72297fa1dd2973bd136ab34b337") ); ( Hex.to_bytes (`Hex "7e25acc9a7d2ca1d1e56dedf41bd81f4a19b4fe1595db97ff15f753aaee54f16"), Hex.to_bytes (`Hex "b904ed0480235dd8be670b24caf4a2f0c0e837b139658d323829723cd27a911f") ); ( Hex.to_bytes (`Hex "c8dd1d51691f1a7cbbc6938ad022efaf868efb5d6ede7d6bdf1f1b9bfb141804"), Hex.to_bytes (`Hex "19eede5a8d8d32c28c32aa1f3e23cdfc5d08d2bf62eb4ab774b6dae27a499b34") ); ( Hex.to_bytes (`Hex "408c05de2e4976eefd0d2163a9ce6796784dafbbe7dffb9ffbedf2bb477f4a02"), Hex.to_bytes (`Hex "a6b6c0545394982706937ce9f1045802f8310ff75b7489a5d51ba0d23e758029") ); ( Hex.to_bytes (`Hex "1fcf8dfbea7917c2991ae874683dd4c72502a73d7ae84edfec66c07e64667426"), Hex.to_bytes (`Hex "ff71663e8d43089a33e0f07efdf597256b33e416b3d29034d050e52cb868f10a") ); ( Hex.to_bytes (`Hex "b9d781adce3ae79e872220c4514d7d7fd5212cf7da8ca47e6292057c89aba53b"), Hex.to_bytes (`Hex "621fafe7f62da765016e87ed7970185033f5f8b2ac7b49dd4883ca10e1b10523") ); ( Hex.to_bytes (`Hex "6608816f6e85b87b2c345835a6871029ee2aeca5a1f6970136a982be840e3f2e"), Hex.to_bytes (`Hex "6ed2fede234fd2241f5323e1cbfda3a67a9b59904f5454f588d7052c742c2b1b") ); ( Hex.to_bytes (`Hex "b7615fe7c58caa775d227a2c2cd2b07a336204d9ae0b1a2696fee6df2754ca23"), Hex.to_bytes (`Hex "f1f4e58b26f165396844e0195df0bcfb90daa3dd1a7a20cf9fae58e7b338c12d") ); ( Hex.to_bytes (`Hex "973af151bbd4cde466f147d907b3e00add615495800dc1956ba28cf5cd0d6326"), Hex.to_bytes (`Hex "fbe7257fce7669ecb9b23e6067eff121efd7dc65ae4538b5f0d47534d2e56b00") ); ( Hex.to_bytes (`Hex "b5374dc7f5da37d9d478b0d760ad6f7b8e2e19ccf948a2eaf3619c3f4998ff1b"), Hex.to_bytes (`Hex "b879936971deb41e28c6b084a7ad3116cc74fa060052af00832ac59a480f9714") ); ( Hex.to_bytes (`Hex "6cc37bb0a28c5d585331fbb35b120e6ae5481ca3d8995616cd2e3d2d4328900c"), Hex.to_bytes (`Hex "53059f0aaac3b6370609313b837c5fe7f080ddfe5913280be72ae4781df2ea2a") ); ( Hex.to_bytes (`Hex "bbab98f092b405f9b9fb3d15ad32e7916e956fc23d9bb7230208deb49969a830"), Hex.to_bytes (`Hex "80ce1aef4a1e98abf7767fccb71a6a3ebd24a9b090acfcfcf0d964b31a7b0c29") ); ( Hex.to_bytes (`Hex "102395140359d289029bfee39347f6b8eddd48104c319812475f873fef6af635"), Hex.to_bytes (`Hex "009a0b4eecc9097fe8c5638ba858e5024dd234ebaba2f2dfa53ea561c6042a18") ); ( Hex.to_bytes (`Hex "c0c38d5a489a4977a8540bd6b78b0173d3f434e1ec5a74bd259f96984043e60c"), Hex.to_bytes (`Hex "c95ae8a54aa914b2bf715b2cdb007b3aa73e954ae9971f1fc3bdf290131fdc0f") ); ( Hex.to_bytes (`Hex "4992343612377bfd01e93ea2f6319cb2b0196aabb7098c42c37f4a7fac6edb3e"), Hex.to_bytes (`Hex "fe39d033625fae41ae3f836aad2f1b35d6ab3cdc87de27b0e6fbf48f896b3c1c") ); ( Hex.to_bytes (`Hex "7973d736b4ea79854f6aada70ef67669e0827fbd8604444d336b69d17b08df33"), Hex.to_bytes (`Hex "b1e104773e25aed872cba95c983c806c2ae77371940a764f3eb576a52a3c4917") ); ( Hex.to_bytes (`Hex "a8d2e5bee39c8d0dc77e1614321e113b2924bcf744566a86696b70d65ce6532f"), Hex.to_bytes (`Hex "b95427538da9bcc952ac6033220a201c675f49321f44d18f4ca07a7ba6e79108") ); ( Hex.to_bytes (`Hex "5ee63633c2b0ac3380b25f36b7f7bde99c3524b11c30db3ffc0bfb48a4f85c22"), Hex.to_bytes (`Hex "f537017c5c52d07bac3cf55e9e2ecc256558f633e786bf0afd34d59b37f8ec25") ); ( Hex.to_bytes (`Hex "390d3a43df745919c14566fe55d52af9a305676b69fe22de7fcf8952cd33c630"), Hex.to_bytes (`Hex "b9cd5b21ae06e22d6ff01c5d3a73ba1db607297c620595775f29f85843a4052e") ); ( Hex.to_bytes (`Hex "e2279e0e5a3e8d8cd59a833334aca733f227ca6788ef3a81ea9357aac5825103"), Hex.to_bytes (`Hex "759e190528d37ae38f4d2572b8ec92944f3bd932580d40e4040ede3134f6d723") ); ( Hex.to_bytes (`Hex "c7d27c8b4dfc93ed391013282ae8f92f8274dd8e2f40419b26557ce88a40e82d"), Hex.to_bytes (`Hex "5b6f7890ee7a82846f8aa97acc1aa5fc4176b11fd8c0263b4fce3034a5cf971e") ); ( Hex.to_bytes (`Hex "4b2e30dd6f3fd82862b148df1616338bc6d5beab0b7f66eb2d99002f7d9fb41b"), Hex.to_bytes (`Hex "8f5b755985251b8fa44944ac45562a998e878a3778a7f8c7142f9aaa95d48823") ); ( Hex.to_bytes (`Hex "5ce1a6cc2b83eeb3b0f59cd076092e309005ca0711c9733be5202ae39d723310"), Hex.to_bytes (`Hex "97fbab62c9034d8248daa4fcc30576337bebb1c1925b38d95303d79d3bd5e904") ); ( Hex.to_bytes (`Hex "891bfe2beace312ab2faed3e64789c45f721089adaeb1580388f2eed485d7631"), Hex.to_bytes (`Hex "67a500222ee1d2bb6131c9608e8b7eee7fa11eb5a81350440f603f413deab33f") ); ( Hex.to_bytes (`Hex "9954af65bbe19257db90d1d9ceec8ef3eda1f9ae7f772e78f4897ed4f61a7532"), Hex.to_bytes (`Hex "ac9f9cd757865805aa3f97c759fafc4c25e03a3e9c52ec4690b5fe1cc79f882e") ); ( Hex.to_bytes (`Hex "cf98df27895a364fd490dfe12aad4ddca6a334f5c9f8c7e8b1886f5472db531f"), Hex.to_bytes (`Hex "8e45f36410f721c544caebb413b8f455f7c1c269a1fcbe1f08db6905d0727032") ); ( Hex.to_bytes (`Hex "0ac334455ebf1ce59bac825bfe38119f4067c9648e61e5311fae658008a02616"), Hex.to_bytes (`Hex "2b3b6203ca354f4e66ca434bc74e9e587917399752a8fcadfcb47f30c2c8c93e") ); ( Hex.to_bytes (`Hex "c5fc262b721758e56bbcd757c778d28c138c8356d70e6f21ef67a10c14b2ad2b"), Hex.to_bytes (`Hex "745de4bdac548e7b2bef85f008ee2bf1ba7cb39b38cbbe59053289d23ae5c210") ); ( Hex.to_bytes (`Hex "2b92cca27360bf05f5a661c1b1a140aabef2b3d799a1aae776535bff5a89c82e"), Hex.to_bytes (`Hex "34ad375c6f2aa92154d3304c7e8fd09ef0ddd0736bae920c2485d8f6c9e3af02") ); ( Hex.to_bytes (`Hex "5f44f72e631c64a3e90617ab414401165c6d68d2dde50c5eb2495a5856bd6229"), Hex.to_bytes (`Hex "90c408691239338fc6f2fbf6a10137b37e58a1d595ed5d5bfadc0b9dc9305a17") ); ( Hex.to_bytes (`Hex "ec8489aa5c0b82f90000f7048a6fd58c68c6e642431ebf45830cc8cff25e332b"), Hex.to_bytes (`Hex "4ceb73a99a8c8ed2b85e65c53c638dfc6024f8b18f80f8496ce532c79224df26") ); ( Hex.to_bytes (`Hex "df1510ed4ae102cc321b4861dae6b27a1f7c5979f5ccb8f1d487a5d2761c391f"), Hex.to_bytes (`Hex "78c000c93c8e616106cab85ddad25180597e814aa6bb0cf0a428619979f21202") ); ( Hex.to_bytes (`Hex "2d35d11ea4be12ba064e743038122ac71e52ce7b80464b774419834407f3551b"), Hex.to_bytes (`Hex "56f79971b5053943cd187483d2a218503fe32c48353769c322ed35e9c433d106") ); ( Hex.to_bytes (`Hex "6b9af84255e0d21711994a832c57c463b906e9307d19987c73a71c7b9c0eb81b"), Hex.to_bytes (`Hex "dd82ddf577567f752b18bb5792533060f2463b4911e7e822396307116c9d6224") ); ( Hex.to_bytes (`Hex "fa67480d070027c24c165a8eeda6145adca4fae49b971bf3e12f8aae329c6022"), Hex.to_bytes (`Hex "7a6cba3659cdbecbe039b9dd86778f7623e106e20386e08e5298ad193ebbf114") ); ( Hex.to_bytes (`Hex "8a1f5e86fed0cc3683019b2ff16d2ad1583775808679c18fa65fb2fe92a70a23"), Hex.to_bytes (`Hex "e0bac00ccda5892476464f92d3c50d6f719b349702652aeaed40cd6bb5759625") ); ( Hex.to_bytes (`Hex "b06cce14f6ad11c19200b9ba210eba4ad0ea391ddcd9e99984ea1592c64e841d"), Hex.to_bytes (`Hex "283ad634ce325f66da51f3b4af7f6d1637083a4ac91df271077a02d875ddbd1c") ); ( Hex.to_bytes (`Hex "443407b44f0c16bbf7a400ac613c4f4f8b982b011a273a3c10aed32b60414d1b"), Hex.to_bytes (`Hex "5bb2f7221291f2616423dfd3e7eee6d2969befa1e6246e151994982bf6b4c42c") ); ( Hex.to_bytes (`Hex "525099cf9e37ad900ff12e45065bd3fd4758d6cce19f31327d159b6f5c0ed637"), Hex.to_bytes (`Hex "1136118a6d4b5eef8fe61997ed8af2ff864bc52b04f722000f15a0873917d124") ); ( Hex.to_bytes (`Hex "29df765b04a0b667c572d15d587780d74761471bdaba94fd7579b13b12ef5a05"), Hex.to_bytes (`Hex "5900fdb614790dc4cfc02196e5034bcdb45c1baa593904585c9f3c33937d9e39") ); ( Hex.to_bytes (`Hex "f3a8f36fb63687e9291cd0e27c6b33b6948571e838e1b572942d59f7f01ae339"), Hex.to_bytes (`Hex "9169e9a9d2aa8425f800a057b6c9674d6bf65d24397cef1fce130eb6f561a539") ); ( Hex.to_bytes (`Hex "7d2e9d67b32ba8126e2692cf9d94237946a7da8ed1e097b99d917a93bfd42227"), Hex.to_bytes (`Hex "9173795cfd3ac8dcac9833a73d83a7258b3f0fc03f902ed81ab43f26e67ab220") ); ( Hex.to_bytes (`Hex "abaaec522aec97ef32054cb8730e5664bc9d64211e0f2ef49b423b3e9b762d36"), Hex.to_bytes (`Hex "c7072982d44549a824ebfd9d9a311983479d2f83bd33531beb140e4405468d1a") ); ( Hex.to_bytes (`Hex "84c40e5255f0fe2c8985105ed91a9bd3084b0281a73baf1a0960fe2228c6c339"), Hex.to_bytes (`Hex "ac6732224e89f84579d8f294d40e964228a62e0a7559c391d8b9a22e583f5500") ); ( Hex.to_bytes (`Hex "4ca28d73f497d79d58319033ca7d59278839e1552dcf6925c7ec5a850344353a"), Hex.to_bytes (`Hex "588d2124df53d48cba7bdf396a60b83e042c6d01cdb3b6e159282f12011ec02a") ); ( Hex.to_bytes (`Hex "efbb74eec3beee05207661d2b6be3592fd924fc39be81bbe8bb82c751cf0523e"), Hex.to_bytes (`Hex "53af8acdca51a9f343c37e09e4974ac7229afcbf059e2e0939bae311c85f5a3d") ); ( Hex.to_bytes (`Hex "583a38d52c3de50c2fe7a36c32ebf13e9bfc98768876783cc6c6d249d7ca743e"), Hex.to_bytes (`Hex "d513970cedfa1c1f78183bd4d9cd443cbe8da645e2499ea9902e5767ac8b133d") ); ( Hex.to_bytes (`Hex "2fc76ed735daf783e5069e35e6361b5d0715080e98a1674458fccf12d4e91634"), Hex.to_bytes (`Hex "6577d48e07093027907d2b91b40a22b0c9e919632bbc16b42c349aa1ccd4fa10") ); ( Hex.to_bytes (`Hex "4f8821919427cea6448ee8028fa1a892e9439539d104dfca76177ea27c98f235"), Hex.to_bytes (`Hex "63f8d8e5a31e734f2880cbdac9b1fabed4024eabefd4bd91ec47b86c5e3cea39") ); ( Hex.to_bytes (`Hex "26a5409038d60eba2fce46102d6ae3addabf637d1f03c4074b6df1efe57f0537"), Hex.to_bytes (`Hex "4f7d0f239ada3dcb2ce2c4acc7fac23eca522260c883bc095018907b69c1d701") ); ( Hex.to_bytes (`Hex "8baa62707522160368eb01c378bfe706fee88d518cea455a165ad8fd76f18b1a"), Hex.to_bytes (`Hex "a93d616297ede41d8ec5a5755b262d7c3c49a613e184cfded91a18fcacc95318") ); ( Hex.to_bytes (`Hex "7a855cda90f6f818664c7af4545eaf8b87e45690db5a96c523470bc54f5e410b"), Hex.to_bytes (`Hex "3352c1d18b8e58f74ea01e7b2d51b83bda73dab3100e8237afe05a0126102a2c") ); ( Hex.to_bytes (`Hex "fa3840aba20d91c4b04b1721f60b1989311c70fe4633b61150933f5881fde301"), Hex.to_bytes (`Hex "1e60c198c01761dc1ef85ee47ba2b51a12167ef3163fa252cfe6e297807f0a0b") ); ( Hex.to_bytes (`Hex "a4e78ae72f060b525ee1c515c92afd3c42d5c141820d6f6f329f1360b4bb453d"), Hex.to_bytes (`Hex "79387ac9975cacb12153ab56f2c00cefc66084e16f372a62b5324c37fd7e2905") ); ( Hex.to_bytes (`Hex "0ac65f4c734926c2e6505ab1282f93dad4ce759c13e4e7cc0ccaf384df7e0a2a"), Hex.to_bytes (`Hex "c6e951cf4daee99762ebf834766a6377d784d6151f73dbc180221128a045ae28") ); ( Hex.to_bytes (`Hex "06f96f520479e1485dd21831af96fdd5853e5a297913f21665f0091282666e05"), Hex.to_bytes (`Hex "5348f0180c3b094ded3657c7cfae8cf29ba66f96ba3c240195e1f4a8d169f02b") ); ( Hex.to_bytes (`Hex "188c7a3fa32caba2ee3f2c299e9abf5f6fbfd4629bfbd242a8b21950c4871315"), Hex.to_bytes (`Hex "928f9d70990ade45512d8cf12bc63b01b5a551e477e417dcfacc4827b3e99b18") ); ( Hex.to_bytes (`Hex "973638c3c010d2b11e9f980af01fe9dd0baec4fa1155b1573afba9ed09551534"), Hex.to_bytes (`Hex "a0f2044de4a0360368111df53080380cb6529b35180288db0419293754796916") ); ( Hex.to_bytes (`Hex "46d6152e394d54f7febf5ce7b5852c041e37a3c3e1c78be3fd3f55395449781f"), Hex.to_bytes (`Hex "55fe95ceef03b0b321a2433e20f04734a7a401f1005becd3bbe9cafd55fbaf1d") ); ( Hex.to_bytes (`Hex "7157433be4b222d0a95fae0d7380981f79229deeae1d9ca1e2fb8a1ff1107c2d"), Hex.to_bytes (`Hex "519ec6e5c44d3ee5c3bf3ce77b1cf42a18708b6a3611e0f0bffc778cc844770b") ); ( Hex.to_bytes (`Hex "b9bc403b62bed79e96ebdf5860f6313e0d433163c1905801a96486f1ae7ead21"), Hex.to_bytes (`Hex "0bf657ded685974961286bc41d9c833a9adfcde10eada4aeb2530b1d0e297224") ); ( Hex.to_bytes (`Hex "cfd3b01e84323ea757cdcb16b8c1d25db666c2a9597816acdc5f2fee802fd039"), Hex.to_bytes (`Hex "e508f48123b53df3ce94b6dd64d467a27a3faf83542c0ddefc8ab04ed7d90531") ); ( Hex.to_bytes (`Hex "1c7451aef2d3060f805ab9a45c9d47b7b0891547ab363978ceab73cff77ce117"), Hex.to_bytes (`Hex "a60c397ef0328e22a8164d74e735fe92a7dfd9a11c5e5f232667d63b5b4cdb2a") ); ( Hex.to_bytes (`Hex "4138663266601958049f286b1eb9da240541a46349cf9ab70377b60cc6e5da21"), Hex.to_bytes (`Hex "6e5706647e4823a2b27e67749e9db686e26a8b041d532e7e6705b94664bb9617") ); ( Hex.to_bytes (`Hex "dc041d5645eb906b9aae1c13609443e77432b1d3724e3527f2dbe61c96891b18"), Hex.to_bytes (`Hex "cbeb7d6e74a5934321734b37b057b917fff4eb0a99148ff459add880cca0f02a") ); ( Hex.to_bytes (`Hex "a9c5819a9cd2868a971f1a412f6d93232595fa402a24f6504b0a15c3f1fab005"), Hex.to_bytes (`Hex "951c83ab939a0cc7b1efeacee99ad26e03cfe122b268fec7b4441819d0cf1d38") ); ( Hex.to_bytes (`Hex "d9b7be5d27315a7db6dace25e53de079b4eadc9fdc025a934844117819474d2b"), Hex.to_bytes (`Hex "b21efee2df787376185faac9019391be8ea29647c048ee6093467f7b8c3e242f") ); ( Hex.to_bytes (`Hex "02636a3becfcac58b4ff498ab2ce8c77048a71275df5288cb37d246f86cb4e3c"), Hex.to_bytes (`Hex "86fc3f7bdfd4be7fedf270d4c96c408520020e833d5eef0b8ed77a4574c8602c") ); ( Hex.to_bytes (`Hex "765618f9b7b9b12f85e379f985099c3b3fdf9eb199e2643c1ae2c2f4c703c638"), Hex.to_bytes (`Hex "f934c33b4b4e28b3219ba69c9d4a141ab6b9924979c20c8d85107cd5ca19e60c") ); ( Hex.to_bytes (`Hex "7a6195a6a8d155955e4c6480fe43389fe7c2858dcb3595a46f977ceb1321012d"), Hex.to_bytes (`Hex "b5509164bd72b7b4d51febbd2fd9dd45411bd8414364aaed9202e012c6c16629") ); ( Hex.to_bytes (`Hex "239fd5ffb200956048de58b2ef61c2c0ac00c2517bb9cdcba6704a5b3a2fef0b"), Hex.to_bytes (`Hex "26c273dfcffff969df5d515b1df5863c20e05eef6c402608c9e85f22fe31f005") ); ( Hex.to_bytes (`Hex "6c7319092ed54d31ff39e955eab554f5279f7fd0d8a57577d4afbe57fb43b918"), Hex.to_bytes (`Hex "e7634587741363f5d28c2e62d6a91cbd4ecc1b61066060d0a002f6385e020d36") ); ( Hex.to_bytes (`Hex "b9d32d4e742e9e39ba0c838bf874e343e0f4cd48c4a18942169794b515f36d19"), Hex.to_bytes (`Hex "eb4d3f67d66c88c2d34e9fb82827f221fe48a9d9666d393475bbfe40b45f8910") ); ( Hex.to_bytes (`Hex "4add82fc51a3164350edfc4c507959c95ed1cf843a947372c16ab9c16caaaa15"), Hex.to_bytes (`Hex "6d792b5176d6991bbbdba5cbf1df39ce446d6214a74f1d42695bafdf2a9dad34") ); ( Hex.to_bytes (`Hex "ef6e4a10d1a6ad49cfb7b5cf4f028bcf91cc3b3a9dcc0c84fcdde1644457b929"), Hex.to_bytes (`Hex "80c28c706a71870b3544216f0f803df9ff836a2d673c511dbcf3bdc191d4e60a") ); ( Hex.to_bytes (`Hex "72c1fcf1b0415e47b00bc4690814b709140c586baa2eedc7ae7e5645cedd5a1d"), Hex.to_bytes (`Hex "a9190aed89a905b86ace484a92a0f018ba48676690c37c3784879b5eec7b0101") ); ( Hex.to_bytes (`Hex "d14f4adf9d8624c4778e0615c6e989cb1ead640d9d5f7365a8d2eff31019161a"), Hex.to_bytes (`Hex "b9e2962e44ec2a1cd13c93e7bb6ce2e5330bcfafa5f55241c2afd72cf633bd18") ); ( Hex.to_bytes (`Hex "a362120fd42eef6cb613089a6abe9f629a5e70fd7ae988e1ddbb5e08aeab811c"), Hex.to_bytes (`Hex "cc143dd82de3646b728ed3b712e81c055d95ab9dffe59c7c3a55d57eb2dc112c") ); ( Hex.to_bytes (`Hex "5c7c4365531086a4b59949592835efba5678d58b212dbc6ed8208d8fa8f39411"), Hex.to_bytes (`Hex "440bc602cf1683c52c4f956673dbe8ba74ffc84b4bfe2113c966db5c5dec901f") ); ( Hex.to_bytes (`Hex "1b060b50bc8b783eb4d1407dd5049fa32e3295e60aff75106fd7eb17f2f7e829"), Hex.to_bytes (`Hex "c91f136b790b38bf97453bf50da76464444697dde666267050e68996d1b0fe12") ); ( Hex.to_bytes (`Hex "71495d4e002e13fd7260eab5d20105c5d79e652e52b90292117b4310aa84b23a"), Hex.to_bytes (`Hex "e1f5f770208de04d08c548567db40f55339c7360305a4af7ec48db598cc9523b") ); ( Hex.to_bytes (`Hex "66f29d4dc37265b525e66e2f318dcbd401a50a6f93217ecdb7bcb9e1b5b07331"), Hex.to_bytes (`Hex "2b3836d96703b77ba09f241ae003d5905a29eb21ebfc1a1ddef2b70a8655422a") ); ( Hex.to_bytes (`Hex "8a42dac965ff5bea5453dbea20a5cba4db7b030b43500dd871d4bf173e49f530"), Hex.to_bytes (`Hex "a5db99dd7f0e52a7252aa3d9d06e125d669c3e52c57735f82ad4125f360d9630") ); ( Hex.to_bytes (`Hex "a66a44ac135d9866126e7796262f73b7b150018540b6b71f29a8ace35c045c33"), Hex.to_bytes (`Hex "01aedfbdf8b834114d9e0b11229614fc5a49d2fefe9d2a298c9fd6787447232d") ); ( Hex.to_bytes (`Hex "b9e7e0bf84a397e6618fec7e48e5009680400dd011d9f65c3d9cb47fef9f722f"), Hex.to_bytes (`Hex "eaccb30ecd44276fee750f8582f5a32026f6a94413de5d0a9911ba5a7472ce35") ); ( Hex.to_bytes (`Hex "66a4ad2133e74577c1ea4e9eafb0967e0841fed2d289769059de9a27ec74d70a"), Hex.to_bytes (`Hex "45f930fad22687eb8e752a9536fb9ff55bf17b2797d36cf41e4e88a700e6420e") ); ( Hex.to_bytes (`Hex "397d541ae8c6d74262bda8505f6971b1ba163957935f87fe47f11a9ea1817b2b"), Hex.to_bytes (`Hex "f07c58ebbcf67954ab069ef37c82a155aeaae9d3c40f9c2a82e6199c67b53419") ); ( Hex.to_bytes (`Hex "fb218f0178eb8fe10700a50f7540a5cf8b5e0f9dd5f7e30554371afec14cc92c"), Hex.to_bytes (`Hex "1cae4c8b24f3d2c2dddea9c545777f44689cf632cb26213c5b5da5fbf6cfd208") ); ( Hex.to_bytes (`Hex "12c24c449053d8b5103cf6be9dcf8fe0e3803cfb6a86cce6a40f2fd0e7ff7319"), Hex.to_bytes (`Hex "80e339b674193d43b23b9cd7f5a8e31097f598c733768bc434e443af886a492b") ); ( Hex.to_bytes (`Hex "0a9b46469e5ae36b30f607d157d6fe21628d7babbd0ad3992fe30e4a66180935"), Hex.to_bytes (`Hex "2387382b7bba5404d3ad350544fd4c99821094a6d5e73e5ce257bb161f3a6b3e") ); ( Hex.to_bytes (`Hex "3d27f9f47ae8b6fff0d14f849092b4a3a20341ac7791d9d9e05dad98f8f2a61b"), Hex.to_bytes (`Hex "d2200a0ed0f29921487f691c925dbf47954e42b39d400db5a48f69b90568c80f") ); ( Hex.to_bytes (`Hex "f416d626e672ee36d1e52e8f1e135ca877bcfed5b6494d54fd23df10792d0009"), Hex.to_bytes (`Hex "0b92a74741c68f76f37e9137264dedaf3ca872b962bcef2555e6fea046b6200a") ); ( Hex.to_bytes (`Hex "2c6a0367de093eb86f8a1c9a862de4c6573740a12899cf262bd661bba420a12e"), Hex.to_bytes (`Hex "fdea21b15652aac745fba19199d8a937bd4b3451a8296b0c19fb24f26acc4700") ); ( Hex.to_bytes (`Hex "2f8c6994825b0e9c14ebf7578dab6a245c018bd2f827cc6abbb62e2ec2c3bc14"), Hex.to_bytes (`Hex "84ac0398659ffdbca8f11a7b678c6590349dcafbd7139e77f51d4e32bdf9de0c") ); ( Hex.to_bytes (`Hex "f16190b4dd5db52f60ff8cf4f6c48de1228e951f49179e20c611d8e074e45106"), Hex.to_bytes (`Hex "bbcb3cecc245b6ad1002d3b2c6eaa03594a1433dad2ed94ab68518bc7a0f392e") ); ( Hex.to_bytes (`Hex "8687994af8ecca231833d62b27dbda489977d3b2f940899d8789a505d661fa17"), Hex.to_bytes (`Hex "af8d261de1478fc8bc62ff5512a00dfbca2c83df88cf10ac29abeb19770cf132") ); ( Hex.to_bytes (`Hex "319b27c32f10953178d8a589c5b6feac23a4e8d8b22a679307ba6966c650ac14"), Hex.to_bytes (`Hex "0ee73a0970fc54841697ea7118e2cf83978860253a51878ffd82f3655c844230") ); ( Hex.to_bytes (`Hex "48b962cfe144bde3f9f897f09683a4ac59dd33e5f228e7aa0e7992d202005a20"), Hex.to_bytes (`Hex "58da40633a5747374cc366e608be62c4d10def22bda92b93c2552375d97d053c") ); ( Hex.to_bytes (`Hex "e9c7013bf67abc2177dcbab62a735262af3edaa6d27a36898c64b2a85a222334"), Hex.to_bytes (`Hex "bdcd7ed3b4969fbf1ec2b5a6315788973fd0bd53b0de538e579d418e59f66702") ); ( Hex.to_bytes (`Hex "324ed89925c5ce161a796bf7cf87e90bcb90ed3d24f7e9645b0afdf7457c4b3f"), Hex.to_bytes (`Hex "9b6f5e0a2df54d505ec271c4147ffd0f3532e4f4a6f6f5052f8e9b1bf64ded03") ); ( Hex.to_bytes (`Hex "76b0bcd9cd7e554de47807d29b520854d59bef8333cede58cef1c4807f3be208"), Hex.to_bytes (`Hex "e75f3f1d0a553924dee729c2ba49356f4cc358546381f14f2d5b6cf83310b018") ); ( Hex.to_bytes (`Hex "b6ac90141f98327987baf169c6d132ae2fadde98383e7d48bbe4b91c969d6033"), Hex.to_bytes (`Hex "d942e09d07c1f52d8e33954fd8e25e3a71605d8e541e610f6a4f86b699f54a31") ); ( Hex.to_bytes (`Hex "9c4c34fbda74ec12b0b28c3994c3e786b355410f555e50b304960fd174c28238"), Hex.to_bytes (`Hex "c83c40a7165475041784be18575cc77bbbf0ef5d87cf2572b58ab7e4afa54b35") ); ( Hex.to_bytes (`Hex "6bcf60ae668c28b933616783ed3b018aaf6169a2e7d4d3f90f8a17b73dbf9015"), Hex.to_bytes (`Hex "3bb69de0e56d882931593f59e18deeffb04a4a789cc9106c8fc14e7a400cb808") ); ( Hex.to_bytes (`Hex "646a8476825def07e4831633427566f2a898e0b6b2e5e863153916a1de365d11"), Hex.to_bytes (`Hex "17b88169d4cccbf5c1ac3a5a086e9c731b4ac80ddca2c3438c72c9be0b056130") ); ( Hex.to_bytes (`Hex "9798c484ba9784a77b47116f544adf0bc44fb461c75bd47827bde4015a269c00"), Hex.to_bytes (`Hex "2f442431e288d683287237731041f5da6ca95fa34ee77604cea6c5310cb1bc1c") ); ( Hex.to_bytes (`Hex "41c92574ef095f816eb11faf915beadd5b4d4c6ec08ec4447a34dd094469b23e"), Hex.to_bytes (`Hex "e1367d083b857550d28cb94fed4c37a64d7656fa7104418f31540ae54929492a") ); ( Hex.to_bytes (`Hex "b1c7ca80c594442a204c0cbe62bc805c9da2ee76a6c89b3e5202735389f4e931"), Hex.to_bytes (`Hex "5f79442dcc99c50c69d7bb6d7a2d345f703bb15bac83031e9053cceefab87635") ); ( Hex.to_bytes (`Hex "249a2cf10288730d47fc887a1ad34b579235935d6a3f84fc279cbef8fbf08613"), Hex.to_bytes (`Hex "44f06c290a54235a987a0815f43a92611028cc15cfb4955936f0a05076320617") ); ( Hex.to_bytes (`Hex "0ba9de8555f153262f48a18ad0943dd655d127801547826a4cdab850c502f51d"), Hex.to_bytes (`Hex "37eb62dabebe941c6712b804bc527d0de40400eb33be2f8c2f6135ea840a4004") ); ( Hex.to_bytes (`Hex "36455956528f1b5c5f8297234d4d799b1cba7d0fdfa8debb64552a08f0b2293d"), Hex.to_bytes (`Hex "81c3e8a8bee07a99277e4639892efbd89c74ae326b4ee923f16ed396a7d4be37") ); ( Hex.to_bytes (`Hex "15afa04972fd552b1922bf0086efb684e1258841da2742a7874b48d350dde32d"), Hex.to_bytes (`Hex "af1987013599517c8033adf542c32be1db6fb6d697397147bd8880f01acf8127") ); ( Hex.to_bytes (`Hex "28622ee46785b5d68416abcaeec955baa9bfe2c03eb098b072ab6c2df6925816"), Hex.to_bytes (`Hex "0a750470c2f3ce7cbd0faf87ecb86467da108fb8233e4a95b46e75ed557c6b01") ); ( Hex.to_bytes (`Hex "816a41f4923772154f56874d29d395f9e82e5ccc0e1fd2b0ba22bdd40bc3d027"), Hex.to_bytes (`Hex "730447abc7fd2cdbb90356223dd1f36cca2353b0493b3220922a243af6127438") ); ( Hex.to_bytes (`Hex "3cb844d0380c6a99a5cd925b180609de55a200d5670a43467eac77eb8596f527"), Hex.to_bytes (`Hex "df5ed1df6e239a05631fe6ea5f3161e53ab3a48594a505bbd81eac14badd8532") ); ( Hex.to_bytes (`Hex "c39deb0cd0c049e539aa21b4f67c73d22b3a8f5aa032d6976ca30c8e475f243c"), Hex.to_bytes (`Hex "8b7d4aaa378a0bf2da2320560ce089814781272f54d1ff5a151c90169bd6a203") ); ( Hex.to_bytes (`Hex "b863432a71ecb81d60c02668493a2089dd0a30dae83852ab83fdf90564c0ba1f"), Hex.to_bytes (`Hex "48c73efd6a28ca353a2ad4db71e2744d4b3010e3ff48f71a9c70be6b6448e538") ); ( Hex.to_bytes (`Hex "a54617c480643f9c10ec5596cb115574bac3df9295d9300b95562daa08d2b504"), Hex.to_bytes (`Hex "0b2f80db8a14fae37bf221ccdbde2a6961015e815332bde5b3d7b7746a83ae06") ); ( Hex.to_bytes (`Hex "33823a63e77fa623ac4f717eca4e9afbcd24bda55fef0d956ce3dd6853487a18"), Hex.to_bytes (`Hex "543e66967663d94aab7e444772605b9317baf40c01efd0404eef7be08f8fd62b") ); ( Hex.to_bytes (`Hex "188c7b14a78269e25dbeb9b9c4e67b60efe0dbb37b302de3b0c8d3800b01763a"), Hex.to_bytes (`Hex "928474a66c14a9061b73aa496b2d4bcebb955a4a3d875b79467a76988d77e519") ); ( Hex.to_bytes (`Hex "cafd698328e5c902ec6246d9ed8e6f5488a0bd12268bc4a4532c49cbbcab5135"), Hex.to_bytes (`Hex "f7b4a12904b7bedf6119a90c507343690557d12d5dbcf24c76044d497f164123") ); ( Hex.to_bytes (`Hex "6f35ab8bd567c8ae662697e78934075a875888850be093e5cc1bd88bb78e9832"), Hex.to_bytes (`Hex "bebd27d13b443cca2f23f9cb87dbf6538d407513813c5e92119c48dabbd32f36") ); ( Hex.to_bytes (`Hex "ace34c79d08510600aff2e4269792b164d3218974b7c12fab06e18acba74eb05"), Hex.to_bytes (`Hex "d4dbad3776619cfa49c926965f987bd77a4ea634b7dee453cf93bb9131273311") ); ( Hex.to_bytes (`Hex "3416b40817fbc99692cb242d5ebca6a9703816fd2ba24c8399fc411112ae563e"), Hex.to_bytes (`Hex "939f3f16bc4dbb50933b60ff156f251e6b8a6cb66faa613ec0e3b80621dae200") ); ( Hex.to_bytes (`Hex "13b5b623798bdd429d779ab504bf85eadd721aa050faa9b0f41f7441380ba008"), Hex.to_bytes (`Hex "9bff1e3f14e0cb64b915e767f21245a111361b8dcc3afcd56bee6d7f1fcf1727") ); ( Hex.to_bytes (`Hex "3dc3db0c5e92e3117847c35134d48ebc319b43973c8504731d626c95d37ada1a"), Hex.to_bytes (`Hex "7b91727f05ed0f557860cd7315cf452321f99984debe0fc065332eebfc213539") ); ( Hex.to_bytes (`Hex "35f2a3163cccdc0a03ac858db3dc7626543f323206fac2b76c2668814ec0001b"), Hex.to_bytes (`Hex "8163b2c675f9b82289657f8721f5a064b2b246623439e40d68c967c8630dab10") ); ( Hex.to_bytes (`Hex "10cb4e059f4dff72533c7110c5c6cc28cf7b4036a13c4441e3dc4882548aa13c"), Hex.to_bytes (`Hex "a923f6c40786b574e8b42440ce86cf52b89ea98fde221f0c122817287c9dd106") ); ( Hex.to_bytes (`Hex "1ab4251acb9e2934534f0f43cde2204c8563fa5de78dacd3aa490d299f545d31"), Hex.to_bytes (`Hex "da0191737a7a0a95c515592b17446ed05b8a2cc36bd572884c64f9645da4281f") ); ( Hex.to_bytes (`Hex "5add9c3f2bb862ec0f2689bae068e453638a446640b871bfcaa60e3078257d1a"), Hex.to_bytes (`Hex "43345279e1ead2df433e58904b2853e7ecb23ee070e35038ca41b510421ef224") ); ( Hex.to_bytes (`Hex "6b0539d7f36960399ba90a247d25842f473e2e1d3e6abccb886cf560fd11f232"), Hex.to_bytes (`Hex "d601e7f30adc9389fb1f5f3d087f493c80402e76c398697c6249d84709cdff25") ); ( Hex.to_bytes (`Hex "05055ea07adfeb009a768d8afe73d7325dc794bae04ad7a0b86a19bf28688f02"), Hex.to_bytes (`Hex "3fcba1db6107401221c1ee5a097e39f485c0afcdbe26399a55d922226d6ed111") ); ( Hex.to_bytes (`Hex "fe505ea4c8ea43ebcae4b99f5531e176780d1b3f0471668fa53b2662a364c90d"), Hex.to_bytes (`Hex "ead9f79880a243242d18fc13119d73787e27df30846c2cd6ad77f029f2798139") ); ( Hex.to_bytes (`Hex "a6418be1e1833b3f0e1f99d4d0b779e8a4a357dc9152143a8d421ba5a3640611"), Hex.to_bytes (`Hex "7efc93d75d83cb9aac691d7bbcbb5e69eb774124efbf8d4131c66188590d030e") ); ( Hex.to_bytes (`Hex "174a793dbb1b6c6724180ba3b140f786cdd66e2c3881140488b8a9ac7a266024"), Hex.to_bytes (`Hex "a391dec2e4288e4be77290bbe623b90e4bd61895a1c9a58463f5fec74f852820") ); ( Hex.to_bytes (`Hex "dc5eb3b41b0b55ecf144a0a213e7d69b9b8415e22fd5b71b89e5a8605a4a3b2a"), Hex.to_bytes (`Hex "7b90f9470982db3737ecd0fe5fa90696912adb0691f4a5a47b96448a458ec32d") ); ( Hex.to_bytes (`Hex "6cebf9d9993440ac882ea1f3c4a76d026ba66718ff04fa7da91324e4294e8009"), Hex.to_bytes (`Hex "5f050a3a8c21b551bb346174fdc1dc5d00c453cff0cd9636200c8f7964139435") ); ( Hex.to_bytes (`Hex "4232cb25fc7ca7e688293788f5d7312c85ac07a494902e5680e12226fbefb13a"), Hex.to_bytes (`Hex "57657c59cfbd24b4192267baf948a3edcdd3f2637be31a8c9a092f5a5aedf726") ); ( Hex.to_bytes (`Hex "1272eddd3e8697d2bcbe363e7e2b1bf9b908bf0446d4ffae4ec77cabdd956724"), Hex.to_bytes (`Hex "04f775e9de5313c708044d643d0476b2adde7530ed7f78587aae9b2039e97127") ); ( Hex.to_bytes (`Hex "f9993d37d79add066afa08b65460738ab5339322d37e1134de0221208a7d332e"), Hex.to_bytes (`Hex "33d63ba7d016eec388b2652be9085fd2b9281a30ce086ac2be396f148f353539") ); ( Hex.to_bytes (`Hex "5bceeff60cb55b3f5d4c675fe4326db74bbbd72bf17fa1cab2064db9fdce8d1b"), Hex.to_bytes (`Hex "7820832c14b069a48f47582a69ae174d6b384769eec008cc51482d31a36b2814") ); ( Hex.to_bytes (`Hex "37031aa4e9b33d2f6da2673f237fa4035b35c3bfcffec22881f42ebd0a96bc2b"), Hex.to_bytes (`Hex "862121b1520911c353fcd5480152872e2cda6aa9f69f5c87e5a515d435492302") ); ( Hex.to_bytes (`Hex "fe56e2221584f03626f1b11c964c556dd60febdcc5e6beef0c187ad9ecb1e23d"), Hex.to_bytes (`Hex "669be6aa95ab04539379800c9338ed603e4af56f8d3eb4d99030ba16368efc18") ); ( Hex.to_bytes (`Hex "f069fe4d85d8220838dcf1cc451f5e50848bec7e0a648a62019cc814d3232701"), Hex.to_bytes (`Hex "3677d4d5cbf34e7eac5be5d6bd2f0b850296f318c23b2f6c1ff1dc2870133525") ); ( Hex.to_bytes (`Hex "fea6d23aeb9034a10a314d086311670b1316ca08cb15df8667611c8d67098621"), Hex.to_bytes (`Hex "43903d614b95de58de5c4a9d72a0df4c097500b958f0a4d2fb945ee8636d6026") ); ( Hex.to_bytes (`Hex "59302e5183c3ee1b31b535afef6de4756974fa896c86cb2535c69c70c8a90023"), Hex.to_bytes (`Hex "3addb6d80abafe307ba16c3c9a287bfe9505924f3f766a7a1cf87d78fee36906") ); ( Hex.to_bytes (`Hex "5afbc12b7eaf17237ac5760f3ca8a04ff42a18e950184dad24a709994e299530"), Hex.to_bytes (`Hex "ee1522c02b714cb05d3788c5200f18f193bf7d9fd2debdaa04dcf67f0ea10b17") ); ( Hex.to_bytes (`Hex "5d16116437ca1446ead2f21cff195efe9bf2b7752b7057fd1a32b54e963d1b2d"), Hex.to_bytes (`Hex "d794528cb16fb003af8358a6a7d282d24e25efb3bcb56d13eb9afe61f85e8c2e") ); ( Hex.to_bytes (`Hex "0ffed718aad5cc79c59f847f2ae4fb211cf9a4526bf3286a6904da2d72e61d01"), Hex.to_bytes (`Hex "9cdc532c3097074f85cf2bb009a79d6c53370827a1cdf06b60eb9645faa1ad02") ); ( Hex.to_bytes (`Hex "b7115ed426d9f174a287370e4b97481c08ee6025b1544f578bfa9bffcda6171a"), Hex.to_bytes (`Hex "dd6fc2180a43bd65b444ff5f26f2a706a6d40e3217270f606ba095ac954e3b0c") ); ( Hex.to_bytes (`Hex "6926e626c6af8bb10b297d40c890de340e6858fe7180c947164b20c9e0017412"), Hex.to_bytes (`Hex "45fc922fa5e72d339d1a6b68c6cd17c9688be072fe766cb80fb75a54ca394f0b") ); ( Hex.to_bytes (`Hex "4accb9bc703617c49221640bb8f15cbdfbc2098e026a97183287a4791a657e18"), Hex.to_bytes (`Hex "afc194527d5d69ae54bf13e84c653419ddc23d296fb22c6463da7b5131e02c09") ); ( Hex.to_bytes (`Hex "79bcc9ec078a6276b35ba6aa861fb28c26d2568a23cf09bb1a35a6197b5d1a1c"), Hex.to_bytes (`Hex "af715cfe31879ffecfc6607682808dddf6b47d6046bbfba2f402fa29c4de6c06") ); ( Hex.to_bytes (`Hex "b9facd4d9938bafee9b2a853e0be85016cda1967e34a182d8c4efc9743dede38"), Hex.to_bytes (`Hex "965a4997561a8caff83f6156ef43af1eedfcc444ce2c65fef4f2912d9bf6ca24") ); ( Hex.to_bytes (`Hex "8a88e83f15230e05daeafbd79475d65c9e16fa5fac899058770a79024edb7a2c"), Hex.to_bytes (`Hex "0b3189484c6fe5ac972da849e6a3cb36ef02724d715f3f0ad8b366ecc612e934") ); ( Hex.to_bytes (`Hex "38443c93a68c2d8d613ff35409b6f0d74cf9ed13cce73be986af556b4cbe4a11"), Hex.to_bytes (`Hex "b7221070f162371898a6a2d23d6b11488e18f3a37f8541ea4377ba653818b51f") ); ( Hex.to_bytes (`Hex "78f5a3d8608c82a08f6c3f654f68250a267766dcc49d4d2b1d6581d64820c836"), Hex.to_bytes (`Hex "9cc20a2396916ce21b0718bc7803fb0827a778c5448fa075109cdc249671ee15") ); ( Hex.to_bytes (`Hex "18ccf3d7bf76aafea5e92bffbed0707d99e89f81e3adb7bfa28901827f59800a"), Hex.to_bytes (`Hex "cbab735ef87c0c7cee0406c14039b0ef43ef143d88c5e485b7970a9db2fbfe27") ); ( Hex.to_bytes (`Hex "bebd4f6888a8c6477952190e44212754eaac9c842379b3f6f13433337341f334"), Hex.to_bytes (`Hex "d4daaad26918040a6fb6a6f74d9ca7343a6d1b12e9e17b7bbc09bbb1527f2124") ); ( Hex.to_bytes (`Hex "c040dc3de7fd01fede27e09ddf873167f9842421c80d5021d105bf4ffe906417"), Hex.to_bytes (`Hex "6027de83ccff963e9111696ecc6cd3fff71aa6545b95cee38618a0c2c1701d09") ); ( Hex.to_bytes (`Hex "75603ed1181b0cdf8ca27c6dcdd96036705a855e2a74dbc818b7defcdf635608"), Hex.to_bytes (`Hex "a94bcbbf443bc6dfa3e5dac67a07abe16f100a1df8314a2b1aba413c389de926") ); ( Hex.to_bytes (`Hex "b68ec82219b75ba5fd0176f7d993a92b55b99045c3389def8588b28ad8903c39"), Hex.to_bytes (`Hex "18dc98866c9c672377ed04e2891a75c3c542c02c0af6cca2c9eff531647e1a3b") ); ( Hex.to_bytes (`Hex "2812d8930320aa016a426561b4de65d519a2c323b2c85913eafb6d653b224117"), Hex.to_bytes (`Hex "1766d2998daaa2685ce0958ee3d548325ca9533664e24743402a9e0030ab6a3b") ); ( Hex.to_bytes (`Hex "b7d70bb8f5ca01c4e48dbcbb2f0675d44ed4a95522a388f84d46213bfb8b011a"), Hex.to_bytes (`Hex "8643d21c4e728f5dd4ef40865f53a378a15305490a29ce474c4a733bea7a912a") ); ( Hex.to_bytes (`Hex "096ef299dd894e03a962dae400bdb5451e2788baffdbf3eb0faf98ea9c2bc802"), Hex.to_bytes (`Hex "4fbd6865dea2ca3a4366ed3afccf44551d13592605d1f85234a548f244471f01") ); ( Hex.to_bytes (`Hex "8ea68351549c04e5fddd04fdd076d8b206fa1744da0c66e2ad662f29d1f5c02b"), Hex.to_bytes (`Hex "044de4c7c134fa98546a2cc95adff086866ac6e1bc258a4521745f9ab7ddc636") ); ( Hex.to_bytes (`Hex "f55df9eaceb89b3001eabaa40f4b490172d1e6cc654624a1cde45985eeac1234"), Hex.to_bytes (`Hex "9c03219937800ca029f92626f03fec261561c71e8451427f3fde1151a94d320d") ); ( Hex.to_bytes (`Hex "48c3268414492306aec2fb758a753b92183a1c8a9a4763852690306b89f12202"), Hex.to_bytes (`Hex "669f583a7ab8836304084cc0db22685d265ec8b80d30d53c817fa9f5af87d61e") ); ( Hex.to_bytes (`Hex "5ae0f423d9a976493750f38056d3a98979a6ff200bd8cefc2e8c72e56ac9aa2e"), Hex.to_bytes (`Hex "94a8b135c89e26e384f5d5385d6c34e36815b69e5b99d658ab2c1e183713133b") ); ( Hex.to_bytes (`Hex "5e22ab8f8c3c26d6d60c49c28aaf1161d6867c14296ceff2adc06239894ff527"), Hex.to_bytes (`Hex "86595c18353c42a8a3bf9c7750f8ae706eb7c81f88f428f6fa9d41fe92f29c0a") ); ( Hex.to_bytes (`Hex "3ff51c3ae1087c5361fc2b7b6542df78c635c6ea8aa5002523f199bcc2c9cf0f"), Hex.to_bytes (`Hex "4a1bbe8f470e4731b9e385b418e31e990ebb4230dd473d6327a5b09903816033") ); ( Hex.to_bytes (`Hex "726989f9171da2d72baad7306b6e8b5e05a397eeae735484e518c17c56211631"), Hex.to_bytes (`Hex "81df1eb19f5dcffc00b23ec05877122e2119aaeeb97d045f24f5b37745fc863a") ); ( Hex.to_bytes (`Hex "938448c1c81c939e92e3692513cf0f9022d0b548e9585e76c06469ef2ec3de2e"), Hex.to_bytes (`Hex "d4ebebbfaceb9556ff2164fda874cc9838323119cb5ed8273cda2354b5655310") ); ( Hex.to_bytes (`Hex "edd3702d189822f2ebfb8bb9db0d8edf0b55ef57c2a0ec443aa0994f8e83e212"), Hex.to_bytes (`Hex "71d98e8d7cb0556635c699f7e8b9549de00ab031abf7acd3b4ce9d0434b0b73d") ); ( Hex.to_bytes (`Hex "30f7c6c83a76ba107ac65091b48679ae74a911e4f280ed8289652c0bd622e004"), Hex.to_bytes (`Hex "e4c3ade8a2798c084fd6e160b2bfb1a2a803f550dfea532106c1451f95d77104") ); ( Hex.to_bytes (`Hex "2a1d0a543468afa07d3309a60b5322bc061292ff01747eb2487ace5f470b660f"), Hex.to_bytes (`Hex "911e345de40c2d0de57348629bedd65ea8046f8588b30ddbadec4d6be5130939") ); ( Hex.to_bytes (`Hex "858d3234f4eb1f938f77f313b4dfacb446475a06f0109821ac28eed0e6254b27"), Hex.to_bytes (`Hex "1e0df82acf5dff85aa6ad57375dacf4f17de55f6d610bffeaa3dfbe21eedc40f") ); ( Hex.to_bytes (`Hex "47fb07082b68882c33982a7661e272e5d6e297ddb794a592f19267ae080f0c29"), Hex.to_bytes (`Hex "f2e2bd9f2aa23e9f9d3f48b51ac1287849fc71604dbe9f88ff3134a42a232721") ); ( Hex.to_bytes (`Hex "d27f2fcd6a2750df094c32058a302162e499b63f543f281c03d93a0994bf9126"), Hex.to_bytes (`Hex "33978cffff82f06ac0d86ee3f0faf95f0f6088174af494ce9bc4351c5dd61813") ); ( Hex.to_bytes (`Hex "1cbb89be9a556391a7014977cfbf51521ecf9381e26dfb3e49695bfec3184219"), Hex.to_bytes (`Hex "e0ed3bccc0f4747187467f88c2e35b7320059756f43dab93518612f603d89d0d") ); ( Hex.to_bytes (`Hex "a4ecc31f33e0747f56c8075f48785fd579fd344f42553f4afc64bbe66477480a"), Hex.to_bytes (`Hex "a9537cb01bae467782f14eb5a826d80cf52ea7c790d5d2642fa719db7c9ae734") ); ( Hex.to_bytes (`Hex "fec674992c82e79e62dff8ece696796df04adff52e2b6332e53081b427bef910"), Hex.to_bytes (`Hex "3a62b28a170f72124808256f3bea50a0d4e647999584f10108b542e831d5253e") ); ( Hex.to_bytes (`Hex "cb38f28fac5d201cd70c4673717a0e4ce719494ca1b1b85c1ca36c7f43cc1710"), Hex.to_bytes (`Hex "abcfd7b02993a7c7ef572eb24e0510f99ae3f33ee29b7ea21c47a3ded38f1a22") ); ( Hex.to_bytes (`Hex "1d5156c1aac8a58d1995ad015029f53dd295fefec13c4e6594c5f3f7e8502618"), Hex.to_bytes (`Hex "cc27e24f9057146ade907f380a60dcdbbdd3068936a77fb48b5c5328f47a1929") ); ( Hex.to_bytes (`Hex "5ba192c29047600ec07002b53dbf8d56ded745bb35c9ae548ae5623cd956eb30"), Hex.to_bytes (`Hex "f414d7ce002e0f94bbc6d85d901ad0f38fec9c36b366882122f09e92603cad16") ); ( Hex.to_bytes (`Hex "1fc44664c3e5170c01315964b7ae36bcbb1c9ff82b22b3e6a6659426f707550a"), Hex.to_bytes (`Hex "7cc0b01302928e5d25ef53668020750c48ec719e9cc98a0a7a9c4812fc69ea0c") ); ( Hex.to_bytes (`Hex "e4bf672e25aaf76bb2ef643262dd38f6eb95b87addd3d9c50f40ead5416fcc19"), Hex.to_bytes (`Hex "24a43dc9ac31f9b50bab68f0e628690663851625f0d197aa7e021af4452ec912") ); ( Hex.to_bytes (`Hex "8c2d6f54f603cdb5ccd8b45f8ded8b00345e82de1386cbfb27bfa12774951d32"), Hex.to_bytes (`Hex "7ef65a5d71ef6ef469a9dfd7a56a180754650a724365d8cd4981212d38070901") ); ( Hex.to_bytes (`Hex "f26a1d2f14d00a3b14fc34d2da56d799fb5d4c45c4b1a84529f627ad774fe71e"), Hex.to_bytes (`Hex "0f5a92df64128ff3d718ac05c9818a1942edf424af1c50cc4038d1d41d539e39") ); ( Hex.to_bytes (`Hex "bf6bc8b89ab329b58e672de0daeb8f7d02838eca95d7ae7f2cac02e041a4ed31"), Hex.to_bytes (`Hex "bb6c5568f81e9d61d6ab81a3ed2f8cd8d0dd1f1ea142456893229ca3ca387107") ); ( Hex.to_bytes (`Hex "639cbef20a043c8ee2e1b041c4acfc0c3f36061f752852f7cce3812bbd713200"), Hex.to_bytes (`Hex "8061dc26dbaeadc38679772e137bd62a54de7b0263e0c62da404286ee5daf40a") ); ( Hex.to_bytes (`Hex "2edcd094c9537550a7269a6412400f94db7b07cb3d6f6291978e99ba61906c3c"), Hex.to_bytes (`Hex "453f32074bff78214837a7b4176cbdc73f1f36d3af307e56d29298dc2e0de00f") ); ( Hex.to_bytes (`Hex "8b8371fcf95e3e922fa740d235030f7d3ebbc71b954895194177388bc330ab21"), Hex.to_bytes (`Hex "b22c1c4db852a528f9c67ddb6bb67978c3c307b2a2e4cb66c21f7ece4e325e1c") ); ( Hex.to_bytes (`Hex "e35d6e7a378bea0b88c88f7bbefcade8441554ebff7d436408d798e00171e317"), Hex.to_bytes (`Hex "497518eaee163c5edc4fda5d7bd0bcce171365c361d0efca79f5b0c8acafba08") ); ( Hex.to_bytes (`Hex "60c3dcdfd364450c43b77a62dbd6343c7de5ceaeef66d619b87cb6d17c132c20"), Hex.to_bytes (`Hex "bc1a32c47fc6ee0d83874abc6845cbc50c55caec5114b186772e2048f709f00f") ); ( Hex.to_bytes (`Hex "8b3c05a9e2eb99f29da2df8901134d424b4a0d4964f328ea81d87f33a0a20825"), Hex.to_bytes (`Hex "33bca9168bbf5cd2f0d572a9edc1a1114e317d9dda8aef9cd32ed1badfb4a800") ); ( Hex.to_bytes (`Hex "73199d9aeb9bbe231a89bed69ca7cb0876ca9e0d746d6bfe72c7ad7c3d8af91c"), Hex.to_bytes (`Hex "6713a68ca948b537e9f7b5a96a85177738e385a677edc3bb4f827aa6ad1c2137") ); ( Hex.to_bytes (`Hex "b6906351ff2e8fecaab63570eb812b503e4dfa5df90df2c6495997c12b84190a"), Hex.to_bytes (`Hex "0d61be8f17a30b7605b3bd6a62d570034c2d186ebfae05b0276456ebda19fb0b") ); ( Hex.to_bytes (`Hex "5007fc60795c7e5727730dcaac4255efb2851bce26e1011f3ea8f14fd0424a2a"), Hex.to_bytes (`Hex "b615da054d59fb89676e92c2a7a89f40bcd7d8aa98181df5a1cc1dd54929a211") ); ( Hex.to_bytes (`Hex "fddd546c54ce3aa124c66b3bd0052f4fd6be1b6f2b34d824b0495830fddcf610"), Hex.to_bytes (`Hex "8b2c1eb16c77e445b19f31734078dd2191f3942c299a3d9b4909eb6bc1667624") ); ( Hex.to_bytes (`Hex "d197860f5ba74269b9ffde735535651e4f17cc147752a7ca3f9ed8fd523cd50b"), Hex.to_bytes (`Hex "562a7907ab85bdef09b6e05bd36dee94ad80604cf4ebe2e264f5a46db5f6e737") ); ( Hex.to_bytes (`Hex "2ca8f0da8c9385a71ae00f6b2c05f10f06d545969248a3a30ceee4259f4dfc35"), Hex.to_bytes (`Hex "d0eed5358713d81b102202442b6e3120c8188233e587e41d86acb77bef153926") ); ( Hex.to_bytes (`Hex "25af689d94537072128555bc683aec3145479041b9b22462927fa0bffbd2ae2b"), Hex.to_bytes (`Hex "e7179dc36ead8515e0300979315df4b3ab27ce6d93cff2105b5acca3dc25c73a") ); ( Hex.to_bytes (`Hex "d3e65e79fd99d5168d265a530c7e32a8a0c9d0a2f159f36613ef55c7cfb8430b"), Hex.to_bytes (`Hex "4f7393998cbb1e7778890e7ffa9e2be2f595aaa06e2847f8654ecbf0dc00ab3c") ); ( Hex.to_bytes (`Hex "d65e8193995b0e947284c94a32f958e4966bc6a4b2a97772ff6a7135bb1d9b2a"), Hex.to_bytes (`Hex "fa745f7c61851e1decbd5e2d57d9e004dd360e730f9f7f69ae296b7d63689631") ); ( Hex.to_bytes (`Hex "bace5dbe6a66ecf4703620625475554e56cb37a2b490c0c233e47ad98d22ae32"), Hex.to_bytes (`Hex "98a96ee7b36996ad7c7b57ed9f87e791d7946c9e839d411e0008e3a0ba948d04") ); ( Hex.to_bytes (`Hex "19766a579f7b906c20911c1d9f59b17b0ce929d44de82f3be95acc8aeafbd933"), Hex.to_bytes (`Hex "ec17ca4450ec9a54d22caedbee165d64effe8b9c276ab10af208ec6fb942e83c") ); ( Hex.to_bytes (`Hex "29bc9cb4eaabfe66d01a804ffd431b83779f5ba91fb86389dac8a9339f5bff3f"), Hex.to_bytes (`Hex "f6c0ce3eb3fd46b8c12d862ddeee8f02538483d7a0b8feb684f147ea3efbbf1e") ); ( Hex.to_bytes (`Hex "02d17e18a628d3db08c4b1fae1ba924d5c3fc44da98c36505e7f35919065e903"), Hex.to_bytes (`Hex "be3c645125102969539b56bcf39b88a413f4cd2ce6bf20f04687a20a405e2801") ); ( Hex.to_bytes (`Hex "b612a2b4af35248a8493fa3f8815325102b341c735b559ba145046c5e6794f02"), Hex.to_bytes (`Hex "bdb67d7444078d70b84a56999c0fa04b850d2b802686a1a65f9fbe83b3938011") ); ( Hex.to_bytes (`Hex "413386ac80e8814e52d05ceea5dd99b1bf409e2bdb9efb4b714e82bcf9ccf331"), Hex.to_bytes (`Hex "9aa34c4127ac7ec763802d3e0b9ae77583732c39291622069a54db01a6f93f00") ); ( Hex.to_bytes (`Hex "779919896efea319dc1f2a3aabdcaeca5db071b8fb6f085d0b54a210dad40910"), Hex.to_bytes (`Hex "d2d86ee50bb6523e02552052c062d1a1e240ff9e5f4b1edf5e7d75a483048339") ); ( Hex.to_bytes (`Hex "28fc3efd9e970e8a6889e0942d284949eb6b139c4b9fb2f278ca11f7f37bff10"), Hex.to_bytes (`Hex "2b9a6ffe39a7acf3e189093bdd32a42458889ce6ec37222f9f014864a5827e2d") ); ( Hex.to_bytes (`Hex "7c2fb2b2b425d90d2336b3a52ab2565f4ca891f2e09fd55714bef1302b97090d"), Hex.to_bytes (`Hex "b4d6f852c2d474333bd0d1bdb43c76c062c79bfad7ca75005f3b255a43c53132") ); ( Hex.to_bytes (`Hex "c65e1b365d397ed257aaa35f0bb465bf47d04c737ad4be6e0b525999cb49721c"), Hex.to_bytes (`Hex "38ef1f92e5b8a7da3fee05ad6d2aef96a4180bfce276f1c64d8a757081679f38") ); ( Hex.to_bytes (`Hex "e7ee3e9ee7ca19b7a015b11d780595711a10d4891ddff34bfeb288068a028011"), Hex.to_bytes (`Hex "fa8481c15b6ad4ea59d2d19ef14e2e750f6e42444e468769519e2d84024f760e") ); ( Hex.to_bytes (`Hex "fb7ae3e01b56c84f4381afb7cd7e224e6044303dccade5188a5b905c611e1d1c"), Hex.to_bytes (`Hex "02321afac99f4be89f97a5de738ad264e3acc452782ab7a188e090902e467631") ); ( Hex.to_bytes (`Hex "6e407d42c4583d0773b9a49d4ca6aeeafd989cce6a602bdbf0cf060661ab0d32"), Hex.to_bytes (`Hex "38b767e51760f5f6cf6d0dc8a42f8badc6eec5ac876776effd8cc20c02af4620") ); ( Hex.to_bytes (`Hex "e29345ea8cbee0df57a7012ce67125bfe4cd1f722abd46565adf5e0c6584562e"), Hex.to_bytes (`Hex "e03d23e79b1167c3e2d71983d36459a8b3447277064156bfe33f1cf9a3a0a705") ); ( Hex.to_bytes (`Hex "cfb1bd7eb91f57a1fb4a8494d45870adda34f9fd3e38ff2255a58d6236f5a803"), Hex.to_bytes (`Hex "df83358b60b5a689be3ab64b5b76d893ce395ec789c20766933c13d6c77a4608") ); ( Hex.to_bytes (`Hex "6d59f7c0a50abb09093f310a5e9db7c02ddfc86348aec725f5c4c85778710f34"), Hex.to_bytes (`Hex "5c17bde99909d658cc3d3669e3513c415fccbda5fb08bf4433721042ab43d909") ); ( Hex.to_bytes (`Hex "a3690b19b2e26076ba5a6812bde675a6a3615f344c46c3705c833a2069a2060c"), Hex.to_bytes (`Hex "b84a7f2fb881a95e956b025e6c890c2754791611eb6b0a413f41f9515df4cc25") ); ( Hex.to_bytes (`Hex "8fc26a1a9a8eb6832b8c5ee879902f25237d273f34a3d53d86d3febd7766001f"), Hex.to_bytes (`Hex "394b1ea07c59c221a83ab6ca79b295111c37d5895dc447599af6f27605bcfd0b") ); ( Hex.to_bytes (`Hex "aeaed6f6a5ccaa565d17565bedb6de0048ace3f620099ee9687050faf96d7019"), Hex.to_bytes (`Hex "fb93d8dc5201d168477fb3e51dc8ce05149c1f2c62e0837f357b05ed5d80cb31") ); ( Hex.to_bytes (`Hex "013cf584338940f7913a704bad855da6b49e169c51f188e93745509c6863b739"), Hex.to_bytes (`Hex "3c9d898f8128cc8fedb74e346776099aacb999109aff7ac7409a3fe528f2203c") ); ( Hex.to_bytes (`Hex "2f519904b6025f3e3e7efcb5d035aac677903b9954150d3198e5a7971caf2e3b"), Hex.to_bytes (`Hex "bf424c9b64cbebc719cef210912bf32b8ea2846868b8ebd068e9a495d6435e02") ); ( Hex.to_bytes (`Hex "a377e905ed3a21e589606e36c62391fec755bd4bbfb19dff8743eb7f09f80628"), Hex.to_bytes (`Hex "a33ffcd0d7f9cdf2b76ae8e99be77e274e9c3882f896c9373162adfacf9ed037") ); ( Hex.to_bytes (`Hex "65a13a3d2db1976d4307db9733bda03c4c2aec27f5cdebc6e2c87b5872777f37"), Hex.to_bytes (`Hex "652efd3f30f96325219b1aef2c47e7545249baa409b2f1fd3076ad0994bf5e28") ); ( Hex.to_bytes (`Hex "bb0a4ff8139e0d30d6c88d9c40776dd10597c402db6eb4886dd3dabafbe9c405"), Hex.to_bytes (`Hex "0276adbee85c51f1ae02229b28bb2839d938b5587680dd117479872c478fef0b") ); ( Hex.to_bytes (`Hex "234bdbac76508291015e522bb6aa1d5eab7e00cf94f648d356b02725bf10cc0f"), Hex.to_bytes (`Hex "51cb5892c9acf6804670481e316f5dc18a07ab8b8eb442301b5dab48cf7ff43c") ); ( Hex.to_bytes (`Hex "fd58ce49129e136ce8d9c723f981b004430de58839927a8fbea325b38d3bca1f"), Hex.to_bytes (`Hex "e1efc75b92f22f6995d802b18d355d377eee122146f17773cfacd3742acab922") ); ( Hex.to_bytes (`Hex "9477919458d38dda4b0577896de067e0993e35e8cf65e768c605607c76ae7b2c"), Hex.to_bytes (`Hex "4fe35e4e065d71bfebab4687e1a7999cc4cc165eebe91576faf7ab73b7848e32") ); ( Hex.to_bytes (`Hex "eeb8a37fcefc57fe7a68c2f78c44c2c9d4c2d3ef38bed26fa23c64ad02658802"), Hex.to_bytes (`Hex "5c4d3fb04198c14b0174b0dc82ea0b46b484576c5e4ab295929ca67deef8fb2b") ); ( Hex.to_bytes (`Hex "2c2315c430ac9fd38d41ac3b9ea7dd76bda803cc61506a14c845b0231be6d133"), Hex.to_bytes (`Hex "6761c1a0381d860a76fd253650d703341151fc4dd843145cb834ca436d16c411") ); ( Hex.to_bytes (`Hex "32dcf3730149d0596439c4fe5b8d05ba5ab9396616dd34e9e0cd03bbeac6bb2b"), Hex.to_bytes (`Hex "073d234518cf85eef33ca9e0b64c68eed021ee79ba3b6b25b97b7f0fec242219") ); ( Hex.to_bytes (`Hex "aee7702624420d5e127aa114153e2516eefe065d277719dcdd75053ec3e24519"), Hex.to_bytes (`Hex "347699720f153ad178d8b3aec05f54fbb9fa5b4f6d97f330c2574e96d68de239") ); ( Hex.to_bytes (`Hex "3113ef1de3943863f0177291d2dc8a178338e16b78381d66e22cc86f10a70834"), Hex.to_bytes (`Hex "3fed1bc7442e2c34d670ee09e142de960f8266dd91688985cf7b705d93874107") ); ( Hex.to_bytes (`Hex "1d89dcf2087e0bc11ed0e6d93c91685d03390b094c235ddd4db316a28d5bf015"), Hex.to_bytes (`Hex "57f27acfa0fa62797da452121c18b0aea5e2caf14b6f61122291bd1f04da2223") ); ( Hex.to_bytes (`Hex "54b51049d7d41f6afb2d4ea307118fe3a43e6b80cbf5c668da07568c11474a2b"), Hex.to_bytes (`Hex "2610aa01cbe383c799518f285426615cfd1a7a4ca75a08632cc693602cc5e02b") ); ( Hex.to_bytes (`Hex "3a6784b97f88d8cf7a842d57f54a457dfaca57e46b5eccb8316b14154a5bf005"), Hex.to_bytes (`Hex "dfb9663307b1839b83ad08626e4e647ebeec7f4f6bfff1e7a15a07e207475c31") ); ( Hex.to_bytes (`Hex "609bf47539a47f930087e54008b82b3068265d3f91c139b1558e383f47f7d037"), Hex.to_bytes (`Hex "af51bbe185dec885fea35467a65c8e2473c8f9d44a2ed6fcc7d5a76b6803ff33") ); ( Hex.to_bytes (`Hex "4304fbd5bcad5b5e136635958dd6c478f9ce25e81df93afc1c4f2de187cea70d"), Hex.to_bytes (`Hex "77d37460885ef07e9c60b55208af7f4a8689812fa233090b908655dec5bb6f0d") ); ( Hex.to_bytes (`Hex "32e1ecb5bf0391aa149c6c12ebaa041108666f57c639d50323e3b4c5d2a29722"), Hex.to_bytes (`Hex "bee79c2148c8d660b063cd00e1105ab0884b3f7b17ea9b42bae723f316c91d0c") ); ( Hex.to_bytes (`Hex "f48bb04155af917eb1d65fcef387b77e562bf14588a36d714d6f64ac986e630b"), Hex.to_bytes (`Hex "db133ea4d112b74abf274be2eb520ae6097f552ba5fb6c0536f2cd32f462ac1f") ); ( Hex.to_bytes (`Hex "31e6bdebb715fa2daf63c0a94df920b3376ae8501c60771b76380ad0f52f4c3d"), Hex.to_bytes (`Hex "bc26de4317342a27713c9249594ba5ae83b135c507e84d0ca771c7ae06c86527") ); ( Hex.to_bytes (`Hex "3ae1637b258fec55e89eec66d534fcd57882d09120e3c25623dc3d0e85219116"), Hex.to_bytes (`Hex "8d63e5be834948a1718b92c41beb798a4b9829d0fcd4dfd6e99a2f169836bd2c") ); ( Hex.to_bytes (`Hex "2073c4e3bc051b7a09847e293960a73297a98053e5442f734ea470e84aa32a20"), Hex.to_bytes (`Hex "e774314f6e6f6848e3a112ae5c57ff36a7501b582df49ae025f81c0a37491421") ); ( Hex.to_bytes (`Hex "021183b1772a42dbb19849101dc2f87bf975d69a9cb743ce218918a7c6789d34"), Hex.to_bytes (`Hex "0f089f690fba70308ac1b836e0f634d13faad22ca7d034da20b0c3373e7a4529") ); ( Hex.to_bytes (`Hex "4e771bd26666a16f7c766f0eb1c41fb90bdf6c410184af12a0d1c14ca3430f22"), Hex.to_bytes (`Hex "92f86eb20c062babe21038a5b18a80e50c57133372e46ff3b1593439733bf136") ); ( Hex.to_bytes (`Hex "88b47d94b2eb494e53c27dd9d3042c2417b0fdd7d8d8419fe081ffaddc523c01"), Hex.to_bytes (`Hex "d9ebca54ca7a290a099e34e4deabb0630bf249c78c94d051f4b0559ab08d9a06") ); ( Hex.to_bytes (`Hex "3280f7718ab26f402949fe8229b49e969520c853a124afb1a72365a155322a05"), Hex.to_bytes (`Hex "d2dcc35ab982f198a8f343bf0ced88b022db59c02dfe50f939d56fcdda064014") ); ( Hex.to_bytes (`Hex "1e3f9dacdffe59dab129983e4acb6a22dc8804a58833733a57a43b130af79138"), Hex.to_bytes (`Hex "1fd7f24bd86ec42537e7001be22ff1bf87873f1e7763dcaeacd5efc77cb2d10e") ); ( Hex.to_bytes (`Hex "81ccd3406d51d0c0c9437716160849a6d5c14342c4f442ca5e8b3db25b8fb323"), Hex.to_bytes (`Hex "23fac3dc2ca32aedc302f1fe6334da8c3cce33e406f05a6bb256847f05df2512") ); ( Hex.to_bytes (`Hex "4ce0a056730d9182f0668fc3ac73b6643209039d57f623ddcd7328038dcf912e"), Hex.to_bytes (`Hex "b3d6c0645085946cb0be0a5ed280297a5616b826fbe051b63215409640845a3b") ); ( Hex.to_bytes (`Hex "fbbb71952786dbba35885ea709484b12171c6147a700e7c9cd5b07f257b02009"), Hex.to_bytes (`Hex "696e577fd228f4ed38b4e92961b8db8193ec151ed3ee8efaed0b4e89be9f2611") ); ( Hex.to_bytes (`Hex "1f7f447c1dfef4b1fc5158979d25c4831b601ebfb52c7c11dd0054d9094cd922"), Hex.to_bytes (`Hex "2449d2b59f7d83d6190604f536263b31d648e00849fc632b9cac5305d2de4411") ); ( Hex.to_bytes (`Hex "945342a208b47c38d9534cb29b3679d0c3d4e9d908d0158f9df4c6e2bfc65031"), Hex.to_bytes (`Hex "9d72f7c18f7204048cfc5424bda46778e2128a3e2d53ce415ff38e46a902a31b") ); ( Hex.to_bytes (`Hex "c54eb3c9bf09b33dcc8bca20960f3350e02baa7658c0baa8eb7a53526cb14814"), Hex.to_bytes (`Hex "6f2ad80090ae39c1b54743e2a07682e85baf821e6e9cdd3db87020c01229f636") ); ( Hex.to_bytes (`Hex "8ffd61d8052b0214e6a9b650f589d7413223c86f5d6cd2872e56b695e235f802"), Hex.to_bytes (`Hex "d84af752063cb9be9dcde405c17219e6dd758f677f8d4a886f88c81c06607428") ); ( Hex.to_bytes (`Hex "f258b9c3ca75f1699839b5abeff147674cf44909534cec460e1ee146f2e7ba07"), Hex.to_bytes (`Hex "41dc190c5bd22110f4289794bd367aeaa7c8ea2ccde759a8903925f88c9afc0e") ); ( Hex.to_bytes (`Hex "7ba7a50db91fea5dc6bc4a13b83be1c0d4b2eac95cd338991fcd6ba112558322"), Hex.to_bytes (`Hex "7ead0f1bf3eae99bf971a10c522b91347eacb931008f21072f69c490e8f8740e") ); ( Hex.to_bytes (`Hex "b95fac26e40c4a6b7e7071e13123cf13a16ecd4f2e193985ab01036e53aa8c12"), Hex.to_bytes (`Hex "bafca743b38c6b6e3d3272643a35b2b4a261fda8710867484d1ccabdf8bcc811") ); ( Hex.to_bytes (`Hex "93760c6f6fbb8f8fda9e6f9f9f2ccda8fadaab011d1ef7f8dca11205e0411a30"), Hex.to_bytes (`Hex "8f86809d7b6c70cbf464035c79d2a6f243736bec48e12abfb859c4744b3b3f30") ); ( Hex.to_bytes (`Hex "3b8e07e0c8a5674ccb6b59f287f4115aaab898e4c826d452d6e14645ee81f91b"), Hex.to_bytes (`Hex "ce0ac4f3da9e5bb28ea6f95fe557d84caae50ba59542574c72ef139fd8bc5714") ); ( Hex.to_bytes (`Hex "2350f99a9681496e4dfd85da41adf4a979dadbfcf0d943f67562d62ddf617710"), Hex.to_bytes (`Hex "6ec7afb106bd32fa0ecba21da42f1ce6ede93c049c28704c91d3fbdd5ddd5620") ); ( Hex.to_bytes (`Hex "f48aeba511b3f7e63dc1284fa1decbbbc0486bc02afc2a83d139239a84c48418"), Hex.to_bytes (`Hex "7e1405cf27ea85ae7087d75a54d661a6021ecd23bdb5ff8cb087593d7aa14a0c") ); ( Hex.to_bytes (`Hex "d6c6d220712b0309c6cc6dd05d351f63966b4aef8cc77cf89d9f6fdcd1d7f83e"), Hex.to_bytes (`Hex "d2c9dd4849adce43fc9fca7c0774c32d8d3edb67bddd61acdcde3fd0b8f79702") ); ( Hex.to_bytes (`Hex "0da0baafb50e1c362582c8489c785180222d492616168798a2181f509066513d"), Hex.to_bytes (`Hex "26d13d84fb1b633a2205ebc4d0648c4af37615302e952491c810af798325001a") ); ( Hex.to_bytes (`Hex "436eee1e60d0b3d17c3dcbaf77f7c5c4414feecd65cf90586908a76ccd6dac3b"), Hex.to_bytes (`Hex "c60f7d9cc520f9dd3d2dfe6a0c3a860516f4179376e2d21497b0c7daba6e0a1b") ); ( Hex.to_bytes (`Hex "39aaaa46b64a96131bf354ae7a08ab63205303b98d90986de09ed66e93a5d038"), Hex.to_bytes (`Hex "2a57e3ae45dfad63fe96a83a42228bce075d24c76142c1dda21bf9d4d41c3535") ); ( Hex.to_bytes (`Hex "dde944a76fa0cab557d47056587fe338bb0b6f5467a4dfb494c3e9872118c301"), Hex.to_bytes (`Hex "6fa4861cf31d5c7384873095e7475ac315d7ad1784cd2d0baa2b3ab6e8df6c10") ); ( Hex.to_bytes (`Hex "bb0a070c6d026e1ab232b51562b5a9ac0af35c36955c1ed4dc36c08d02ca8d28"), Hex.to_bytes (`Hex "ed982385ed4d2c663d42121d0abed7b25c8120deb5e3c63e8faf24d061f41f29") ); ( Hex.to_bytes (`Hex "ec276cd166fa9fb02ad79385b022daa120eb54dc409232e68d6744e05479761a"), Hex.to_bytes (`Hex "2704a58509cdfae6b2f7dded988548d3c4bcc8086f30a2d759e41603d5fcf014") ); ( Hex.to_bytes (`Hex "4e6f645bf3c8328fef4deb88fc08aa21349a58de7f5901286604d62a17a4303a"), Hex.to_bytes (`Hex "ee1911e04095067d56731b737c5567c91d2fa483024c5adae0c172c9fb573a3d") ); ( Hex.to_bytes (`Hex "532ae0c3ccf6c1d36812c77edc5f47059d5b9ff1379600f081bd48cafddeff30"), Hex.to_bytes (`Hex "9ac215820994ae91f603eb20d05e3261dc18be0495c70279e2ff6bcb090dd22f") ); ( Hex.to_bytes (`Hex "dc7342d50ba6311a50b1b604c71c7fdb13d0210154c06118a3a5539173c16c20"), Hex.to_bytes (`Hex "d5fb755782cbe9e0dff72475cc49764315cd34210e08d27b717edae288def031") ); ( Hex.to_bytes (`Hex "a5d70b78738172fc5b06bfbc64d6ef7a55e32c0bb7a30bb0dbf5c928a7849936"), Hex.to_bytes (`Hex "17429f83051009cea3587cfec5dc95320ab6a0bd0906a35af2b0bbcd89cf4102") ); ( Hex.to_bytes (`Hex "b129ba9e3119001ba38df926557d16724f7599a705f7cfe72bdcf87050fd9029"), Hex.to_bytes (`Hex "993ec649c4c7ed1e445585ef3826f4bb2ea4f02396cb55f7971de35fe0b0ee01") ); ( Hex.to_bytes (`Hex "a354b1409e1f7ee36d0213ccf0232d65e87e491d9041868eb9b32507669f6406"), Hex.to_bytes (`Hex "f456c083bcdc7ef13f38c13dc3ce63bb36a54f8921613f8e7cb0601c8a2d113c") ); ( Hex.to_bytes (`Hex "12febb56797d3e1abe371d4c39caa9a72ea8c4c9af4a40978a377c3da035aa38"), Hex.to_bytes (`Hex "5dbbe08d5e7d31b6d069bcad179967dc6685f3c7fe71b968957a709989cd8919") ); ( Hex.to_bytes (`Hex "bb9692ba135020b276a7fa3675da582088c04af8e35b360432a00f3b2f7af41a"), Hex.to_bytes (`Hex "8fd5433d9647bf2af1f03d40750d35b25a3efe7706f721a0907b074cadcd2f32") ); ( Hex.to_bytes (`Hex "d4d5e5cb6caea906f6e6a503d7456baa3209bebe8ba7144621ec902cd26bcc18"), Hex.to_bytes (`Hex "b8a0d8fe8d717c964742b3317fbca7952cdae019af1f195a8f48381341c85b11") ); ( Hex.to_bytes (`Hex "85a45e9119ca511dafb71d25f877430b485aeae037fb2508bf9c8c3b2e074815"), Hex.to_bytes (`Hex "294b54abb86beb483aea75ec9cf266ae9cb47a16a24b95317b5f93dbaaaa573d") ); ( Hex.to_bytes (`Hex "974314d49033460cf680f04bdc5283b6450e37076158a1a641d3bcffaa810024"), Hex.to_bytes (`Hex "03a8b346cadfefbb7768040c850eddc364eceb2fe2e8e371fc39a5b5f7eaa908") ); ( Hex.to_bytes (`Hex "b4931bb3b1c2065e75dc20437ca313c37b6f122695a2fc7e4117bf403df8ff0a"), Hex.to_bytes (`Hex "4b1dc8fd4c8fcbc757840cf494fd505a2bf1741e9147d671707c80ee61664115") ); ( Hex.to_bytes (`Hex "615de989f2c3022884ea076cfb773cf33a14f40d0f32c9bb804fc09cdfa36c35"), Hex.to_bytes (`Hex "aa1dd89f2bfa454f6e619971595e477fb5df4ece29df3b7d871f27f96b8dae1d") ); ( Hex.to_bytes (`Hex "2f19947ede873f47b0441112889d93d3eac5101098e73b962ede23df9735ef17"), Hex.to_bytes (`Hex "76dbe355ac8d951e9ced2ed881c6d212cfe05e1d8416d5d34734ea9cdd26c90a") ); ( Hex.to_bytes (`Hex "088b0515c4895868af9713dbe4b0b76d77a75cf64815805b4b085e1444e8c70b"), Hex.to_bytes (`Hex "8a20793f8c4d38e55433fd29e1221f15db21ac275ca9907a55a6022245e4ed19") ); ( Hex.to_bytes (`Hex "893732eefc57d8de336f1d300faafe0b6dbf9b5dd3969cf36f97bffa09839d2a"), Hex.to_bytes (`Hex "6131ee53450f8c5293aa93efccd2ca6d6c99c92e8af004e73f2d0dccda16fd1b") ); ( Hex.to_bytes (`Hex "40360ce471848b18d0769706598601a271059d20e0578dd0ae6454e1bb63901a"), Hex.to_bytes (`Hex "96c097e549908d56c587aa87d07850ddf25e8771d973153cf4239eea1e698e38") ); ( Hex.to_bytes (`Hex "60157093c13fab40f540c82e90a2ce297bf9f7a9950b5dd713c6d8ab7979f00a"), Hex.to_bytes (`Hex "ed9c5305d2ca155c1b096b03430902c65e7f91e5ce782c4cf94ba3f5ffac5919") ); ( Hex.to_bytes (`Hex "b80fc07c6d878dfaa1196d78974a9c5ae9ae9b3b1581be123fd4948578290f1a"), Hex.to_bytes (`Hex "f78de8d4bc1497eda39ed80dd3c034e7f5e16dc859225decaf8f8857f3032213") ); ( Hex.to_bytes (`Hex "938f8404693bb59322cf8cdf0d8c3913424f66a52e116df44086d6f2f5e24100"), Hex.to_bytes (`Hex "607710bc790c05b6acad494bea1550ee6822f4228221e365adc0a9419469cc31") ); ( Hex.to_bytes (`Hex "ab8162eb7cabae94ab56f1d894ca28524e88b91693af5a476db13e6c4a0f8619"), Hex.to_bytes (`Hex "406d8ced8fe9dceb7f304e459782400503674a3f253224d0e35b7df5e4a0f11a") ); ( Hex.to_bytes (`Hex "34e65bb82ea936fa5088b7ea3ded4ab44bc17067d65832be4f636d814151ff35"), Hex.to_bytes (`Hex "2cbdaace1b0c0c502eef8af69b66d6f0729c399404f98dbdd369ad352cefb12d") ); ( Hex.to_bytes (`Hex "0cc1ff585d8bb4c0d28c8ea2be70cae5bdfbab87af9539f477d383d5f6823007"), Hex.to_bytes (`Hex "130d05d5a030621050c34bf3803c6a4b19a396302783fec6f089c20c7f633022") ); ( Hex.to_bytes (`Hex "09b08bc19191e825ad8aa1b2c529f98206972a6a2015853f7c73d71e6142fe25"), Hex.to_bytes (`Hex "f6023ed652c53783b45f100ba977cc738c7aad3b61e5db9440c49fa3b736e726") ); ( Hex.to_bytes (`Hex "4387c0b150b64609658cb81120c0b99d13fff8cbca4d3cfabc2413eb44c8e506"), Hex.to_bytes (`Hex "a170a3a8f9578f3caf1bfce0388bc5373b81c8af1535336b3a579f79f2f5821a") ); ( Hex.to_bytes (`Hex "9b270a42635ea1be1d3512892b28078e7dfd6ad899f78f40e4226ece8e7b8f07"), Hex.to_bytes (`Hex "dfecf1ce99d9bc88ec0be7d4449c3d338eb11a69bdfe35804811a57098a00714") ); ( Hex.to_bytes (`Hex "5faa8425de974c4599a8277a0694c7ee0247d38027d45509ffd643c15997351d"), Hex.to_bytes (`Hex "5c60f61530af16a843a99b68d6711007e1a83cc78a1402db77a765b7ec3ddd05") ); ( Hex.to_bytes (`Hex "2ffb6ad7eb3880db5d32881c9f0ac90df56c22161ec88ccf72a171a77b7c992a"), Hex.to_bytes (`Hex "2fe25521bdd9c2e8a9e98fbda025708a41e8281d92c1e95b3b9c8a5c6387ea12") ); ( Hex.to_bytes (`Hex "3c93b88498225c4e4c99a8b2a0867746305b23c30b90251318ccaea423461e2a"), Hex.to_bytes (`Hex "9bd44b6e2b516c565d0b2f1e1c0f4ea71d6e83553c5543cb46a3306975a1a413") ); ( Hex.to_bytes (`Hex "10222189f0483c50d0865d78327291edfa35fdb995adc2c0f617381e6aca030b"), Hex.to_bytes (`Hex "b6be3bf42e4c854c12c79707e38f25337fd1d771b2652b7bd7fecb59d2450826") ); ( Hex.to_bytes (`Hex "4216ca16659643514dad4f09c577a0faeb147daa69d8c1cb2510c2340a0ff22c"), Hex.to_bytes (`Hex "c6cd2199a9ee36ad410a7f290d371d2e419315096f0857c9af1d1ee210cfcc22") ); ( Hex.to_bytes (`Hex "4cad14c314e644fb7d61d8df0bdb248b269e6a3f6f197dd16477df32d6ffc827"), Hex.to_bytes (`Hex "dc420c39b443caa58b561b6a1f79a2d751b2639c221fa7989d77a9e7030da331") ); ( Hex.to_bytes (`Hex "0d552287e94cb4f4c80a3901228b93ddaaee275223f486fecbadb7adfe8dd231"), Hex.to_bytes (`Hex "dc7bbc74337fdb5a3086b82bb1d10fc11cf45b93e57c28ae9fa354807397202a") ); ( Hex.to_bytes (`Hex "6b14673d3e41e73bbd75172ea9cd57ade9ae71e3c4f95f2c494e332f0e7a811b"), Hex.to_bytes (`Hex "37276dcdfb8d5da1cb8f435f19ce492ad1cf1a1b521b384d3ca2285894ce930e") ); ( Hex.to_bytes (`Hex "a2ce76d45dce511fd4738421cf922fdd6b0b66c731926a66fbb35697aea91a2b"), Hex.to_bytes (`Hex "a3cc158cce9ca946aad960c4cebb85bf2110a44ab8a78a4e4ce52a6a1aa88017") ); ( Hex.to_bytes (`Hex "8ac06895506b7ae182fd4e9e60ae9f25dc4bc43e28d17fafad91a674d3de091c"), Hex.to_bytes (`Hex "d5a45135a3b9df7082c58711ccee2efe561421db26f48685ca0f5093a82ba626") ); ( Hex.to_bytes (`Hex "5866245623cdc35e7fb0fe146b69ab0b251b805b729a0ef780cdc6a17b98ff22"), Hex.to_bytes (`Hex "41ee7c8bb50f08789b9256b93dd84dcec4dd4da7ce39c8ea6da8062bea331723") ); ( Hex.to_bytes (`Hex "1ffe5d684667c8ae68511eb70a0c18c2fa70701a7669768ddb9cfc7ba2c80800"), Hex.to_bytes (`Hex "77ca7198363a4faa6f69adc1a10e4c7b80f9b0fa1052d84edb1b9cb412bd6c3e") ); ( Hex.to_bytes (`Hex "c87be147ea0c6a8f26af9107eb1f6428892b2ac779c1a360f3cbe07c3044ee10"), Hex.to_bytes (`Hex "63a4c0f497dbaa666d57d578dbd702e32f1ecb8794912d488118ad364a4a9a0e") ); ( Hex.to_bytes (`Hex "706498f8295c344c8060f7e1e047f4df70192c06bac0dbf977e27cac9361cd06"), Hex.to_bytes (`Hex "97357d3461a7046104e1a148a1fa80824737372f0a5d11a03bb79e82b850730c") ); ( Hex.to_bytes (`Hex "f003181da041987a30d09dea39a6cd9d14d4fcf21f8c1cd97f4dfc75597eb122"), Hex.to_bytes (`Hex "21dd745461f4eaca0e15354ee9493b9749bccb03e43e201a2c2c3d94e4401220") ); ( Hex.to_bytes (`Hex "51535614d933f175542887004f2196189deafe26e77cd40c6e280570f8266326"), Hex.to_bytes (`Hex "5ff37142263837171f7c0a6e40f9d8c75c9d7f7683d224597d5727310e0fb50e") ); ( Hex.to_bytes (`Hex "4cc139bd5e0fe268cb779fa956697b47ce9970a185983a3173dfa2041d5d861a"), Hex.to_bytes (`Hex "bb6552c1c40f230676e38127d472dd5235664e86f54918a40d2703eb9dc2fa10") ); ( Hex.to_bytes (`Hex "15fb644a95387da5e2ca21744ec609ca7ffe60ec2b5c17f07eac5ab0a1079501"), Hex.to_bytes (`Hex "ac77ab6327dd7560078ab77b9060a01a5f63688cdbbd6aef82f87a1be0b5091b") ); ( Hex.to_bytes (`Hex "c337e01aec724978bdd82647be69425ac76d65e1a219a75683d3da50789c1814"), Hex.to_bytes (`Hex "95eb53ca2bcd5b81f6db5177b4786c55c108201a13fd53f0d268abfe8cc78128") ); ( Hex.to_bytes (`Hex "9e7ae04a131906f3104a6bbd266f06d3fc519ac2ead830d2f0c0ead1f8d06c0e"), Hex.to_bytes (`Hex "b89becacbe27a49f7f69aa8050c22b2a95bd4ddb2f9cf7dbf54322866abb2800") ); ( Hex.to_bytes (`Hex "991896cc498413f06a87bf9e9dac9d373de9cd31d0997febfd08be19855b0b13"), Hex.to_bytes (`Hex "ebba2c42437eeda4f199d0cf65a5bd15088212efae3fe775bc1ff13c27b09611") ); ( Hex.to_bytes (`Hex "e5ba30559ef911c3c067982f9121965e1f7932087961c40ebcca1f79628cb83a"), Hex.to_bytes (`Hex "f346a3d1b2db0ce373d557211b880d3032b062af2b2962e3a1a3f426ea23c402") ); ( Hex.to_bytes (`Hex "155b4af182fb4472a0c580c8f8db161730d104fa0dbb4b131f9716ac4309802c"), Hex.to_bytes (`Hex "315c9a08cad28a97493f6301bd1be6e1d0cb42b6f3aa30332c3d6bbad2c6a109") ); ( Hex.to_bytes (`Hex "bed533bcf34fa5285c3948cf2eb1f63b43907c551bc72d225ba8741f658b4024"), Hex.to_bytes (`Hex "c052af0495086690d115c066f7e8e43584249f65299286a3c76bdf1198317d20") ); ( Hex.to_bytes (`Hex "54c07cd92b72d915f94539624004a4c09c98fd73e5376bb466913aace76c582b"), Hex.to_bytes (`Hex "efdb313f9d2dd6b9a5a7e6b716cd75724d7ad56d44c0858d050553dafca9860d") ); ( Hex.to_bytes (`Hex "27e71620bcc1c36c4b160a18d80d7b611e97619fde39d64ff027ba19d86f4a3d"), Hex.to_bytes (`Hex "d48b57aa0ee813349f76bb635e48167ba24a4c8c2159bb626f58aff857989810") ); ( Hex.to_bytes (`Hex "3de53a2ed2b7334da15a24b77eaf88e896b8760bf3f0e678618e50f8caf0f915"), Hex.to_bytes (`Hex "6acb33e20d4fcebe899bc3d0dfa93febc6cacb4358ff51b3303f20e91ba62a37") ); ( Hex.to_bytes (`Hex "26f2d5a50c4af774b67c03e752b8513791189a75fac8d19a42843424b7b6fd10"), Hex.to_bytes (`Hex "75e416672caad7fc92c3dece46229c4fe397b90136a4aa0610c07ed54b80260a") ); ( Hex.to_bytes (`Hex "364864f181f79f53c6a0993d87dcdcd1890bf18e9673e42d4c33ba82a967f10f"), Hex.to_bytes (`Hex "478e885191ab0db5cb88df97fa55e0c15d75dde0a1e347350aedfb9a5e73282d") ); ( Hex.to_bytes (`Hex "96d689c0098a78a21e710006d9cb29f53e52f81e7abb66cbac2beb34aa17b929"), Hex.to_bytes (`Hex "96bfa48539a67fed6486a4cea4b546bcde3f521691860b2c1774dc7dc243303d") ); ( Hex.to_bytes (`Hex "fcc6456512e76e3cb572649aa3601e3672375a6fc52bfaa44a845dab68096b20"), Hex.to_bytes (`Hex "08ad43ba876ec37cdcb1a6eceb2315f95a941f38dad1a92f43aa6c8ac657ff25") ); ( Hex.to_bytes (`Hex "e02bc2c1a3422677aedab77a08846150e4c3e38982d9ee677973e1123278401c"), Hex.to_bytes (`Hex "01ceb9fccbbe43aa524ab9eafd4a38e5ff33248d324b9c3ea224e5a2ff5a5700") ); ( Hex.to_bytes (`Hex "4f85e15417ce0eeac486c09f9460594466e73dc259675e834d48ecee41abe30b"), Hex.to_bytes (`Hex "e16b016209a6f94849d5b7ef63380919ce39cfacf28f592be9b1a1e57e849d38") ); ( Hex.to_bytes (`Hex "37656b6937c06a93a82813a3b4e560359028cbcfa4fe471f283c57494dbc6b0c"), Hex.to_bytes (`Hex "4687a6fb2f7ec62a38e5b195eed8e18019a39347f037f90f182771a68ba39410") ); ( Hex.to_bytes (`Hex "e3fab8b22cdfc78e89ef2c65e1cb40eb8518dfaa53a32da085e4cb845e88642c"), Hex.to_bytes (`Hex "77e226d9a706f9cc3e5cf557088f7e5df2d57217471b71df33b385f10c26a80c") ); ( Hex.to_bytes (`Hex "072399d91d50baefda860abcbfe2cecb580eca8c66c3a97b28fc3367da7be010"), Hex.to_bytes (`Hex "c3eb7ddf6fe6720ab975a22ad6676af16f2a84aa005ed20370cedbdfbc55c726") ); ( Hex.to_bytes (`Hex "ff2def9a647653181797a4104f4c947f99acf5b9ff8035e2524a7f5fb67f381d"), Hex.to_bytes (`Hex "9ec11fb406699fb56bd24bba26f2e36a0ccbe3d3ca2a7151250e5092abb31930") ); ( Hex.to_bytes (`Hex "ec97138d8cdb0574b2b4b844635c1f3acbea99df5b17163b6649615a36395c0e"), Hex.to_bytes (`Hex "ee263b2a4f822a3cc94d772e14c8b50cf6905fe4f67d48e679e40ae2c571373a") ); ( Hex.to_bytes (`Hex "a9082996a840510fc5c6374699d028ab7d59bbdf2d0c408d2398f2b463fe9a35"), Hex.to_bytes (`Hex "cc7542db14f0c41f3c500454d65f6d133a5286ce439c44088f094e036e007706") ); ( Hex.to_bytes (`Hex "930afcecb74bb57cafa1ba53543bfc64d5866a2e19e653c4179998ac5c033828"), Hex.to_bytes (`Hex "4086f8df39586e0fdf73bc7e824190128a7e1f4a6f3b35474c7f93caada1aa31") ); ( Hex.to_bytes (`Hex "4d532b6dc337439fc30be7ed39bbc43b558a4b10ae79382fc84f7ad971c1b013"), Hex.to_bytes (`Hex "21540c37fad1460d53b7be65287f9783d8df9ee47d7ef4639fa1f317bf468c11") ); ( Hex.to_bytes (`Hex "bf486989cea0ebb4f30c6d65d9982aad8a665c4d1d7451c66f4d42e984bf9e03"), Hex.to_bytes (`Hex "a2816c4778c895e00e689d6768bcc7edf12aed4e2b8563f71b6e8ee9b198e915") ); ( Hex.to_bytes (`Hex "218d282b189a668513da1f0a7f354493edb879a144d772375ab5c04e3485031b"), Hex.to_bytes (`Hex "2104b639ac8d6146b6013cb1885df54e3497c650477c155395037421076e3a2a") ); ( Hex.to_bytes (`Hex "913b994375b7171e3d6f03c4acec3728b48f4d660a0ab45654d5e4e7710f042f"), Hex.to_bytes (`Hex "69c28fb9de51f0cb9694887504a76a5cfebc9f29f8c5fa425b644978cdec4712") ); ( Hex.to_bytes (`Hex "40715f4dad3a3e16a5671074588192b6a28b9f506868b526ffa43f6a3d5cb105"), Hex.to_bytes (`Hex "c71dd0a8a864ab7c0736682d69f23b5b343987674884152aa139041c620f9a25") ); ( Hex.to_bytes (`Hex "f56dfbbdcfeada5b3da4b932d7566effc9aff9ef7b5d574560bb70b3253e5f11"), Hex.to_bytes (`Hex "aa8dc8dabddf75fab3fd396ef793302fff95c57d27e2c1c89d678c14c57ea13e") ); ( Hex.to_bytes (`Hex "d16a93998c5f4724c087781f6263ee5128f629abd0d15e47b7a03024aaff0303"), Hex.to_bytes (`Hex "9d18a5d552a9d21d71424150bfa0cc2227c62c625834b249897ff84036c23001") ); ( Hex.to_bytes (`Hex "281cd7ca5a9cf1aa58787a8b1829b18b6ad6dc922dcee723232f3a8e51374219"), Hex.to_bytes (`Hex "d9d43e4b66eb2ca37367b0f23e682beb073a6e391955f3a64cc31eb64db92b1d") ); ( Hex.to_bytes (`Hex "d90e0bed83de214d3b5ef2a5abdadfbdd5595e4986a4bc0bade3a69d68478516"), Hex.to_bytes (`Hex "256e59e0fb6a048788594a6f21ef4fbf9770215dd0e96a33e5028e75b013210a") ); ( Hex.to_bytes (`Hex "c24ef690194f2a1b6905025d9f84ab56eda9bff7aa071428418b06211ac90106"), Hex.to_bytes (`Hex "3dbc8e80dda015cb56d564c085f3de07d864931e285a6e2d54a19ecb0adc3910") ); ( Hex.to_bytes (`Hex "82ec8f2f05e90aedb25430e52cbd13c19b7703f3fca47a0c08a78ccd29287408"), Hex.to_bytes (`Hex "f0c39978872f8268b3679e5baba6961830636c35995249cd13b6dc3a29eea628") ); ( Hex.to_bytes (`Hex "b15c83355b4d5e4be448a9aa852a027c20d34b8d9b4a1f8ec63fa9a7db94173a"), Hex.to_bytes (`Hex "d359fee0e97255ddcb5a4a52c9d3107b7c64637b822dfdfdac01e5efb5119a0f") ); ( Hex.to_bytes (`Hex "dadf8af866db468a619114d930f11a234d0437a0b8b0fc9a7606d64378ba802f"), Hex.to_bytes (`Hex "acf9b0b386448b7b2a23ff035201b8e9272e6bbf3fb65231cd259a3bdd0a412c") ); ( Hex.to_bytes (`Hex "e59576bef0db6c346ad716ed6af6e367a3606387a2f16104d5a1919fce29180a"), Hex.to_bytes (`Hex "9283c86f2b9a7bf152fd5dbca2a74e2caca265532f0912f59656ceef6d2e5f2c") ); ( Hex.to_bytes (`Hex "d09b0d46f8e1c1a54222b6fbe1ce39b138258527a014e6f591df710923ce3b13"), Hex.to_bytes (`Hex "52daf70097cd9c18ce6547cbf079bf0e111d7d1eef449c7404c2e7bb99ad2f31") ); ( Hex.to_bytes (`Hex "e26b7a91bc8b52e752cf04251eabc20b3140ca092617483a9a527c0ae137e52c"), Hex.to_bytes (`Hex "792dc4f4ef9af76464ed928565dbd89faf9f8688da0442f80c861b3a5c987a37") ); ( Hex.to_bytes (`Hex "fa05d225c6bf3e5d3fffe620b3dafa10ca309ae263f684177396c53abb96692a"), Hex.to_bytes (`Hex "8804d6e6c2a9b63fbf7901a42192b590cbfa28754ba988dc899abd7fd6ee292c") ); ( Hex.to_bytes (`Hex "4cafa674822ca6fefe738c22cf7b8c38d7dd55e919eac7c0cac12b7b0246461e"), Hex.to_bytes (`Hex "013c9ce3e1e009cafcaf7e47ec201a706743e9798edba50fd1043ae7483cfc3c") ); ( Hex.to_bytes (`Hex "794133ebf5cc4cd8c7f8de15981823ce1f8eb57dea8d6ce78a9db4f69f47ca3a"), Hex.to_bytes (`Hex "607a23f16d24f117a62f2f8d8f9d172e4ff63e4213e6d032aec16e8b3d297c06") ); ( Hex.to_bytes (`Hex "198aa7170a0ccd8e88b1607fa67b36713ad6aad12cbf5affb5ed5ed19b095636"), Hex.to_bytes (`Hex "bc9ee2d16310dfc0b55af33deb45ec9aa1cb867b493f716eca5923b51d9f442e") ); ( Hex.to_bytes (`Hex "690ebaaf0e446ea51abe3e43c04afb106dee718d2c395fd9db75f48a9e08ef34"), Hex.to_bytes (`Hex "29eeaf4f6889de9c934645462b7c90d3ef6db29e45c058f89e1996fc3661592a") ); ( Hex.to_bytes (`Hex "4b09a068b88341d34fb224123063c5464b390bdc11ac9f9385ed5fb4dc5d9811"), Hex.to_bytes (`Hex "acbd238c52520345a831790478e28c81680abe33af058b4d4729fe0140b25428") ); ( Hex.to_bytes (`Hex "5727ba9d3b92ea21a4ba6772ee322d106dd95bff178d7ee044cb3b5992fe3905"), Hex.to_bytes (`Hex "da2c98a78ce7a68945fcc1c6ae986a77c520fb5e4eccc1a42cfe5389001e152f") ); ( Hex.to_bytes (`Hex "971db9834150231060ca77882abcfe814cbb3ffe495c2419f374f3e33fa1380d"), Hex.to_bytes (`Hex "de45a144311743d6875f57738bd795cde30929d33f6cd26e2a345fe880836009") ); ( Hex.to_bytes (`Hex "5ec02fbedb8c914295d466b1574acf9aab495ef423c999cae9a1b704ab33a13f"), Hex.to_bytes (`Hex "a04d4d5282a931d7721121038d87ec55cd9224e3edead548987167d157b9ff0c") ); ( Hex.to_bytes (`Hex "c2a429c48aad28f57e92cb8bcd859bd91df1cd3e3f6c3a85b0ec910de9d9b43f"), Hex.to_bytes (`Hex "70a78870bd5c37915dfc6340bd4673bc1ca33419a0b5ee523413c10d9b389735") ); ( Hex.to_bytes (`Hex "0238a3c6bde204db7809becec361964897f59ea4cc61f921422294b3b7c0c80f"), Hex.to_bytes (`Hex "d6be8a94569b858f47237cbba152b172d388b434d582dafcf7dcbfc10b044d3e") ); ( Hex.to_bytes (`Hex "4cfbf8f5d9d7a92464657ada2fe94ba8f69fac1bc0a2107cf99e702ebbec3d34"), Hex.to_bytes (`Hex "54e6fdd72e6438f54b582e43a6fa306dcc2b5628ad02f2181dd2522366710c1a") ); ( Hex.to_bytes (`Hex "6a3fd3141190e808a2288cf4ea62820d466550277b08fe89e6e8aaef7a2f9508"), Hex.to_bytes (`Hex "ad8455950f2863ca22d5a5e803a1bec791e4415413d995b732a0ab62ad13a23a") ); ( Hex.to_bytes (`Hex "a1af6da4e2e34d1541967caf7ecb1befb7489c0b3f1eccc42e2a991aa3147b22"), Hex.to_bytes (`Hex "614afb7190e2e2e7733b2c9efea7f4286ac825193680c82f6af9923d3d37de2c") ); ( Hex.to_bytes (`Hex "c8f4d6a74218196c703d393099ba1da37670063e266c14356b484646479a0338"), Hex.to_bytes (`Hex "c596825949d2af2752d2b2f5aab6f6fcecdf95741eb9225c0765a4df709b572d") ); ( Hex.to_bytes (`Hex "df64764311b1af5025536ffef472851a0e63cfea8bbf8813137609e199376b38"), Hex.to_bytes (`Hex "2ae143915b2f701d8d42f3c57eafc6aaf2521f55116bdc1793e735e8b0387c0f") ); ( Hex.to_bytes (`Hex "463ed49b75bde1c6af0be14152cca0b4abf66ec475ed779b03ff485229f9020c"), Hex.to_bytes (`Hex "25685609245045c41879e1b25cb69609a649b11e0f9f22ec875862442888640c") ); ( Hex.to_bytes (`Hex "18ba9727bd8b12c4085bd369041f47bd64236c84e60a1a027963eaf41e3b0d1e"), Hex.to_bytes (`Hex "789fab1cb28ebdd0e37472fe11e6fb1bded7e310158844f89693aca5bb000b15") ); ( Hex.to_bytes (`Hex "dec069912b2b2e7556162b5aeb7fe4f212794b313178f7616c143015bf36d529"), Hex.to_bytes (`Hex "720cff9a54bb90c82ab4db76e0a47d190652213842016f741e955a4c7ec51225") ); ( Hex.to_bytes (`Hex "6c68aac1456ae6e7671246bd74b4988cdf4cc14c14d4e18a678c5c94fa339f1b"), Hex.to_bytes (`Hex "216b6dad957402981b1bccce29edc8cc44703069510fc8743822063becd24b33") ); ( Hex.to_bytes (`Hex "42458ae44ae3e3e23a2372ee9d9da777993f975dcd2f90926bd87b5380df280e"), Hex.to_bytes (`Hex "9a5b98a1b7f557b2198fc2cb707eddad77bbd311df175bc34c985be8768af428") ); ( Hex.to_bytes (`Hex "837fa57ab964d2c1bad331107d69a7c8bac1c1d6c833541e957a857c6243281a"), Hex.to_bytes (`Hex "3b8038f60570005c3634d13310683c15cfc4ec65fa84ca39a12de3eb6973a536") ); ( Hex.to_bytes (`Hex "d188d61eb7fa3bcb7044dac3b1759d952b3d2e2188cf6bff996b0b99e50eb41a"), Hex.to_bytes (`Hex "438ee5d671ccfc18210d001ccfe1fa5225a2a442c19755feba13a372ab538a0a") ); ( Hex.to_bytes (`Hex "4b8e1654373acef44a4352ec6a54c761e857936866ac707dc8ef7d9a7544121c"), Hex.to_bytes (`Hex "5adb6ea9b62c5f3b4f5d592386e871efe0c9fd5a3674a2e5fe3e74271ff90a11") ); ( Hex.to_bytes (`Hex "95de77e62ae29568c33d7b933d9bbb9f66bdd5d4d9f4c10b8ae7ec1f7fb6f227"), Hex.to_bytes (`Hex "c4efbc50119434726203f5a853578eac6c4628e4418ce3f713cf4d5d5b645e31") ); ( Hex.to_bytes (`Hex "936908e894bb9454e8ef21c45b799a9033f4456b01cb8b03ddd6b6cb3646c42f"), Hex.to_bytes (`Hex "87bbbd0ce06f7fa3060508be06cbae0a6ff34de82fa180dd50e2f97ae084c81d") ); ( Hex.to_bytes (`Hex "0b0e6da5051da4da3c44eb13755ced6f50cdb1654c0e8b7aefb08bed8e7c4f21"), Hex.to_bytes (`Hex "16ea8118d5d949fe371334ed64dd5323d926f1d98e0cb256e80d2b4cb492222c") ); ( Hex.to_bytes (`Hex "bb047c9b4e964da7ec2dc04e5bbb5c339f329469ec7b848ad4c5e70d221ca71a"), Hex.to_bytes (`Hex "93f5f9d6a682b8c3e68a9f251b9ea79b26cc79bd63b7b68a40b7fa34af618321") ); ( Hex.to_bytes (`Hex "6136d55b795eb697388bdcf44bb20b56da1255c0c1dcce165b10f2b4ae6c7115"), Hex.to_bytes (`Hex "257f91aba4b41a3fc72e484e6ef197454b54789fe2b3c443591cbf26c2eebf0a") ); ( Hex.to_bytes (`Hex "d791b64139a7eb9ba3eb089d9be415cf6ebb9b4f652443d4f6b475590cf14225"), Hex.to_bytes (`Hex "1c22c7f3a6c20d411d8238f182ef649e50cb2adfe268073646a9a1a20c28f02a") ); ( Hex.to_bytes (`Hex "cc322525a44daa4018695068f52547a04ae1fcfe448696d085a1a99622ae9105"), Hex.to_bytes (`Hex "23c2e92d56ea9dc5f194628a851b4815a225b6c18da0ac0aa1ddce219acf050f") ); ( Hex.to_bytes (`Hex "cc727650d1b74bd1d53ace526f7f3063723024ad251ee57ca06e7cddac2bdc07"), Hex.to_bytes (`Hex "aeff407cd5c3365809aeb7449e81f54685979ce055fb96b7d15dd5557b73952d") ); ( Hex.to_bytes (`Hex "af821501bfa9dd86446b90361ee4d940a2bf8389aa208757fb8af11806171a2f"), Hex.to_bytes (`Hex "c6a8e4750993f809799f1cbe7d9685efd4bcb732ba18384ab75cb56395128f0a") ); ( Hex.to_bytes (`Hex "382a4ea80f85e5649228cba1d2f9a167dc1a3d6aa9e8b634c0a0d686e3306f2e"), Hex.to_bytes (`Hex "6aff658e173fd1b948785ae2200bfb4fd3e268e6d2dc2f6c9c23faa6549c931e") ); ( Hex.to_bytes (`Hex "f6e7ce796784163360c360557bd06efb5763ff55592f8f4a8d6d7593fc77fb28"), Hex.to_bytes (`Hex "1256cfb2781be2e3887622cbe270d4c84bf2d4e16e0c1b73c2551946ff02cd30") ); ( Hex.to_bytes (`Hex "2691eae5024a9c8edd965e4e8ef1b96f3111496874324c491209aa3524feb518"), Hex.to_bytes (`Hex "758dfc8d920a56497e26113b697b48c99f78421b1dda5e319abf739f0335d435") ); ( Hex.to_bytes (`Hex "622f969f21681000e7e2306b4d2d3139c6c236ad9ab2be94d27307c02853f436"), Hex.to_bytes (`Hex "b5d85d1e410bf3e4d8cb23486f1fe56599f2b6d0d33f7ff4be5651e9f88f2714") ); ( Hex.to_bytes (`Hex "15201ed9add04fe1abfda960d9ccbca272b51cf7b5aa5f718c8c3fe23bed6019"), Hex.to_bytes (`Hex "b075d93292e74d6d90449cf76fd8e0a0d9083c5f8eec7e94b6ee76f1d0f92a16") ); ( Hex.to_bytes (`Hex "4f4e4f64892abe77f81979f92ffdc2da6e33a40a5e412d48eadd5dc2678fb412"), Hex.to_bytes (`Hex "c2fd955456b34714bda646202d1586fa3034b696ee3c480e6b35049f69f90a31") ); ( Hex.to_bytes (`Hex "b290494b8f56d949ed0e436ce9521dffbc7fb60a7ec6ab9dd06bfcdaf0acb815"), Hex.to_bytes (`Hex "e1ebafc8bc2adb04deaeedb802438a851a378396dff97e85a956bcc59267d50e") ); ( Hex.to_bytes (`Hex "b829be97bbc4c88f8893fdc63aec3f720038ce14445b18cc8caf7ceda9310319"), Hex.to_bytes (`Hex "68170c82b08e486e49caf1982c5dcb7f25418e236689c632ccea65b15ed0ca06") ); ( Hex.to_bytes (`Hex "384c4299c073d6056cd3d86544e91c9b990b65f3f4c0924171b84d0885b38333"), Hex.to_bytes (`Hex "dc42b4ab62b1a341ed468325b0867f01b5a2ede383978e45816bd329cbe13e08") ); ( Hex.to_bytes (`Hex "7d767779439576e45f176cf62a7b9ced5ecd415788a533b82cd758cdfbb73d36"), Hex.to_bytes (`Hex "e302f8d9cb9313f38b07432b6c36ebe64e591232dcb4a3bc341b11df7819b108") ); ( Hex.to_bytes (`Hex "6c006f9e05a7ce77ab6608dc7ddb5ba3ea97f1562ef95a716ed8c40545936436"), Hex.to_bytes (`Hex "fccf1da168e4539c2c60dd68670f3e1c77455cd6b877a51be69af667b809421d") ); ( Hex.to_bytes (`Hex "80580fa180530a26e5045ab6ccb81b7a08238bd2fff9a827c3f3beac37fb323a"), Hex.to_bytes (`Hex "549974a3469b4a913581610cfcb9d9fe1ef272a1c93e45fe0fec7857fd909f1c") ); ( Hex.to_bytes (`Hex "083109c261a4109904909eb323d02e2c3b917fa2339b032cec4d779554690e0a"), Hex.to_bytes (`Hex "d89049453db7b9e6ed1e522367ddba4700cca58146e0be402d93ff1e1feab536") ); ( Hex.to_bytes (`Hex "a3f761469803e0d2e151e6097cc179ca38a50b41d34736785d9acb8aa4557c21"), Hex.to_bytes (`Hex "63e2fd046c0bd21b59a36ddc94b6c7021c9a1b8afc9c713abe9b485b2353ff3f") ); ( Hex.to_bytes (`Hex "d216fc66f6d25be2c2759cdba1b199f92d164f79cff6f6d0985f5253de326633"), Hex.to_bytes (`Hex "98e03092793a681ced042ca7257b7c8062e7080c050c4e53b0bab2881f1dc62b") ); ( Hex.to_bytes (`Hex "0638116d02ade16ef8c2690c86cf02c44879d47a980a431b7340e704b0ca2331"), Hex.to_bytes (`Hex "931174af1ec0ac28b5b2653e062c353dab522a3d8881a65d7a516955b34af238") ); ( Hex.to_bytes (`Hex "809a02271c34af6bc12226233dcfd731a37d6f4561e36bb59404475bc207d922"), Hex.to_bytes (`Hex "e1b22193ea081081c10e048b9cc1159e1a0ffda40c86b4c792cef29f5c5bb33f") ); ( Hex.to_bytes (`Hex "5d21c357e9cbb43e18205aaa301cbbe36acedf0464f329680235775eb89b4c1e"), Hex.to_bytes (`Hex "92b65ac3065427f9ebd2f843cfcab3ed8dfa2fe8416f045b2e77e11b90b4c216") ); ( Hex.to_bytes (`Hex "25b3f30db05bf2910e3114bf2e04a29f055ab18b068c0d44b65117115ae00a00"), Hex.to_bytes (`Hex "fc96dce852f2a971fc4748a9940ee9932265e4826d75bd35ad9022092d18d40d") ); ( Hex.to_bytes (`Hex "5a392e158a897dacda33b31a51883e8912181e79b18269f002d065cfc4f3b61f"), Hex.to_bytes (`Hex "38bca2bc04e1c56562a23f113c881bcd5ed4ae5849afbc9672a3b96ed2e74c3c") ); ( Hex.to_bytes (`Hex "ea0290ed0fb47f8676a7ba7c1b04a54098acc4c7a43706c2be8f460ea29d7025"), Hex.to_bytes (`Hex "53fdc04e9f681a6598e0ea4108301e4ad24983ca05ec4d9e9507c65731edcb2f") ); ( Hex.to_bytes (`Hex "d16f17e8601cb5a50f75b9bfe3218f2e41a9748b3ce55cf4997b4ae0361afd04"), Hex.to_bytes (`Hex "f9d45a9bc972a75ceeca93833daa3ceaa60b182820ad08350f072cc569cd7d1b") ); ( Hex.to_bytes (`Hex "0ed2f1b3264e76f0c8e925862e14c718e2dcde7d4f7df751223f2b2350bf7323"), Hex.to_bytes (`Hex "60c68c323dd6b8475dae050ec4f5feda8912c94765a9b5986c0a05099104ad01") ); ( Hex.to_bytes (`Hex "df947f9489a14411ba2210cd16df28e4a8c47634ead96575dcc36512e3a67020"), Hex.to_bytes (`Hex "46e1c9de7d7fdf91e7db9e341c8735910abbe8d0b4dcdb7e158d750509c9900c") ); ( Hex.to_bytes (`Hex "a61e1fb3189d7e49e3b0ec1b395e7a08648c446a9c4ddee8b82285dfad4a1d14"), Hex.to_bytes (`Hex "643caeb7776215ff3ca75b0f96b0553461e8f904e3cf5120d7d6e2528b6ff819") ); ( Hex.to_bytes (`Hex "a4460ceeac3cb29ed67ca7cb93c21ae6af30079c71650ec526d9c90d4f2c2522"), Hex.to_bytes (`Hex "3543202d108fee99d302f63b54c1d90919c5649ed0e3d761f3b827c2bcb83f1b") ); ( Hex.to_bytes (`Hex "3fcb65dfeaa49e6b27eb176722f8fec12c4ff3a02eb869fb4c6c2c92aff39425"), Hex.to_bytes (`Hex "aea9216ab7a231c4aa4c49a74efa4fbaf9c436ab08e34d351b71785dc7964b24") ); ( Hex.to_bytes (`Hex "92514265c3ed6847fefe47a38a8e3566ce73b9e5d5dff4b554f4bf25c551591a"), Hex.to_bytes (`Hex "8afdf58d9a04017edd19d2419028016b12e000e5893e4438776df54a34f2e02b") ); ( Hex.to_bytes (`Hex "3a216018fc741eae2cf286283a3ce43fe1c1beed1e9bfadeaf5f9f4eb65abc31"), Hex.to_bytes (`Hex "13852a5796b119bdc9f226f49be07242f7dd11ae75f82599630dfb539e5bb91f") ); ( Hex.to_bytes (`Hex "2673e80863a736b2a3dce8452eb07489d81033ff04b97505caef044f41ed4703"), Hex.to_bytes (`Hex "d80ab53289fdeb185d51d04e7455a2822a157703bfd635b180989abcdba11934") ); ( Hex.to_bytes (`Hex "00e4428c1407848c6783996172bd8aeed94c515ce9c34efe07cfc80b9a7f7d2b"), Hex.to_bytes (`Hex "d4df6830617f8fe5d47d927182d4c93174fe5edb901e9fa046b5547e57f9122e") ); ( Hex.to_bytes (`Hex "c11456ebf3c1253ddc5a91dbf02fb078bb1a45475a59e4526226285d2b81c020"), Hex.to_bytes (`Hex "7497ffa332e066c1c15c7f883f6121bfb3ac5ae4cc2366661554ae470a678a1f") ); ( Hex.to_bytes (`Hex "b31b94b298ea320e4b17d0d5f6f54000a4657132e7877c130ada9bf9658c1406"), Hex.to_bytes (`Hex "dc7e4df4065e4863ab0780b1a4372b3b6d3b23402e3096fed180caefda9d860c") ); ( Hex.to_bytes (`Hex "f11cd4173e30e374c1d145895650b5b9eec8b0bad6f3caf51618dcdccec0aa20"), Hex.to_bytes (`Hex "76a80cf84b2a5b46074930ebedde657fe277389f80c839cf3b74e57146a38602") ); ( Hex.to_bytes (`Hex "4bb07f1268a150fb03dff504e301f840eb5059c934c0e1b4075df7ca17932611"), Hex.to_bytes (`Hex "ad93be71bd97c5424b2e7df8271b20e234691ca8f5a2f211dfad5b1d530da725") ); ( Hex.to_bytes (`Hex "a43f8d1d12b6c3865ff1a40c83c71449eca786f9e64fea040c7b504a68f42620"), Hex.to_bytes (`Hex "eb667479f3505e4333000eb7b6735c8bbf184a14b64ad97e75d7a9fff091102b") ); ( Hex.to_bytes (`Hex "a585f215d6a5357353469a3755cee365f02a76cc4aed9cc5767f46602c7a2904"), Hex.to_bytes (`Hex "576286023fecf338c0a59ea410f0131eec2eca06bbe8f1da2d925a9bdb3d9d32") ); ( Hex.to_bytes (`Hex "881b3b11f0e70a40d90e9f725add0565c8b46182a6816df4203887e890845024"), Hex.to_bytes (`Hex "2186ea7f5b1eb835866a065ebd93b19ac38f66d2f11292861e0d542b70d0ea15") ); ( Hex.to_bytes (`Hex "da662ef46a8b8c95f5d6141c1f95cddf0af3546fdc07bcb5da56167049d6821d"), Hex.to_bytes (`Hex "f9016ea3e3a7be05be4718466cd9ab77f35f6797d316b5a7bee43ccc765e8517") ); ( Hex.to_bytes (`Hex "5a5ffbb40a310afd6fbb1846c2e15fd084e33d0167e04157f14b9c87d60e7323"), Hex.to_bytes (`Hex "165d4cb9bcf79f7e96fd769fb3565ed70fea6d25b13562556d05084fbe11cd3e") ); ( Hex.to_bytes (`Hex "a68cb7d23844043db0dcf35114db79a615bbb2a26c162b928a773d6e35380711"), Hex.to_bytes (`Hex "e2b73ed65da4ce9526d526e617c6f02a5dd931913735559d773a996b1a16840d") ); ( Hex.to_bytes (`Hex "915161f1c274f84df41f43089a0d97d289f85d529b4bc1669aed228a778a833b"), Hex.to_bytes (`Hex "aecacb06219686672bf63f43980bf2830e97114da9c205ff4c896c590c3fdb32") ); ( Hex.to_bytes (`Hex "b495b7c5176bd2186b3ddf314c019750476fa3a9b754bcc1a42c524249013f00"), Hex.to_bytes (`Hex "5d2b7168731704e7d06e2514173a2a01ba4dc8dae16a0f75ecdca90dace6fa39") ); ( Hex.to_bytes (`Hex "173096c14ffc2200f2a65ab791a86d6e4184c7d960aa658ea89f1a1881f1f02f"), Hex.to_bytes (`Hex "f374a0ea6a64ea0800bebb01ca0993e86424f75536c921004faf8cb3dc5f6f2e") ); ( Hex.to_bytes (`Hex "01c58457d657bf992cb58e7c72bd17705d8f322d1cd319e9b72ff5aaaf43cd0b"), Hex.to_bytes (`Hex "a8e2d4c3a35bd060d20252dff039a1038194e1216e8ac8e5a59b521da4d04a38") ); ( Hex.to_bytes (`Hex "fbc33b6953111fac6408f826543dcb95a717c2911f53c9acd6ba622bab65a037"), Hex.to_bytes (`Hex "98cc28d733285625867adc6be35f7a15966e0317befaa945fb6e843e9a2ea615") ); ( Hex.to_bytes (`Hex "7e7db5606609eb84b6699f6883c1b3bc8d7aa21a0c6b79c1e373776bb012471f"), Hex.to_bytes (`Hex "666fc4f30aa1002e1ee35849a4d9d2d46a6e8c9ff9c9e5aaaac34a6c9c5cfb0f") ); ( Hex.to_bytes (`Hex "3260aae67c42dfeb3acc8f88b0d884228dfef28366819c3fb0d26218d2c3e03b"), Hex.to_bytes (`Hex "82032578e34f68d08f533b56cf85a3296191b007c92a01b41606265fbefae43f") ); ( Hex.to_bytes (`Hex "9ac24d8da786c20b727ccb57c0ba08a8cdd6ade713e2711e110b96957c986b3d"), Hex.to_bytes (`Hex "5a471d7ed3cdace47ce99a8eb2afb1e61b7738dc42793cb41d58765b2c629f0a") ); ( Hex.to_bytes (`Hex "0dd215d3371c6d3432225997b633902f03fd46c49599fa1942fc67b3faa5970e"), Hex.to_bytes (`Hex "803a477b5878f9a4cc9b4858cf723a5c99a22124e4722b81f7be6d41ab99112b") ); ( Hex.to_bytes (`Hex "484e3ab7b3f1075e836b8f6f5f92b019b29c9a7fccc598cf1716399b410d1a0f"), Hex.to_bytes (`Hex "ecfd90f03ec82f6360d68ea15b0e3c2fbfcae74680d890ce59ea2ea40bfdad0c") ); ( Hex.to_bytes (`Hex "2350ab7674cf8c2335001bfb8a884a07eeecebefe856633754db5144971e3e20"), Hex.to_bytes (`Hex "b7d157d8cca85f2084724f279b3771a2fcd82f53668f473d71e7b956be886613") ); ( Hex.to_bytes (`Hex "6f741cbb3db5082bf9590e133263d6deb3110f89707d3eec71a5570594830b07"), Hex.to_bytes (`Hex "bcfe6c00852c20934d5bc63f93369f67e1062a0d30f012ea2c792f802347112e") ); ( Hex.to_bytes (`Hex "47e2672e5ce86f356d5f00a35e770d1d6cc1d0bbc664f880f0e94e11a0ed7a31"), Hex.to_bytes (`Hex "5504fc4b8945a6cd1f3c88ac763afcf9ec288d7908a2f661499bc2a8e91b022c") ); ( Hex.to_bytes (`Hex "89bec5f537a17a715b9802315953289050075a2c330bfc4f533a84ed9c2c9424"), Hex.to_bytes (`Hex "a74fae0c8d19dbfb29ae9f3366d61e30c1541f351b27dbe8da480ce41db8c61e") ); ( Hex.to_bytes (`Hex "e3614971b9ffad1feb6fe404273976a18d039120f8895d334a038ab6a50d5605"), Hex.to_bytes (`Hex "2931ef1561a0bc7c8d009cdb8de0198efb36a1b7b6ab45a74555de6b07b7cc2c") ); ( Hex.to_bytes (`Hex "401b886f9cc5ba666cf9c551861f9baee152dc9b007e8e6833d72e840e38e427"), Hex.to_bytes (`Hex "db788d61f347e81b7ff58b6c3dc6f1cbdc919fa3483bcb625285840b2b7ded0c") ); ( Hex.to_bytes (`Hex "ae9db1d347edc32b8068df2b5c232979aede234d6671c84e479692d729bf6a02"), Hex.to_bytes (`Hex "966b62524b205189d2fa72c6c729ba154c1380a4a79b490dce65544db1df7c39") ) |] let generators_zcash = Array.map (fun (x_bytes, y_bytes) -> Affine.of_bytes_exn (Bytes.concat Bytes.empty [x_bytes; y_bytes])) generators_zcash_coordinates
dune_site_private.ml
(* TODO already exists in stdune/bin.ml *) let path_sep = if Sys.win32 then ';' else ':' let dune_dir_locations_env_var = "DUNE_DIR_LOCATIONS" type entry = { package : string ; section : Dune_section.t ; dir : string } let decode_dune_dir_locations = let rec aux acc = function | [] -> Some (List.rev acc) | package :: section :: dir :: l -> let section = match Dune_section.of_string section with | None -> invalid_arg ("Dune-site: Unknown section " ^ section) | Some s -> s in aux ({ package; section; dir } :: acc) l | _ -> None in fun s -> let l = String.split_on_char path_sep s in aux [] l let encode_dune_dir_locations = let add b { package; section; dir } = Buffer.add_string b package; Buffer.add_char b path_sep; Buffer.add_string b (Dune_section.to_string section); Buffer.add_char b path_sep; Buffer.add_string b dir in let rec loop b = function | [] -> () | [ x ] -> add b x | x :: xs -> add b x; Buffer.add_char b path_sep; loop b xs in fun s -> let b = Buffer.create 16 in loop b s; Buffer.contents b
(* TODO already exists in stdune/bin.ml *) let path_sep = if Sys.win32 then ';' else ':'
ppparse.ml
exception Error of string let parse_channel ic = let lexbuf = Lexing.from_channel ic in try Ppyac.code_list Pplex.token lexbuf with | Pplex.Error s -> let loc_start = Lexing.lexeme_start lexbuf and loc_end = Lexing.lexeme_end lexbuf in raise (Error (Printf.sprintf "parse error at char %d, %d: %s" loc_start loc_end s)) | Parsing.Parse_error -> let loc_start = Lexing.lexeme_start lexbuf and loc_end = Lexing.lexeme_end lexbuf in raise (Error (Printf.sprintf "parse error at char %d, %d" loc_start loc_end)) ;;
(***********************************************************************) (* *) (* MLTk, Tcl/Tk interface of OCaml *) (* *) (* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *) (* projet Cristal, INRIA Rocquencourt *) (* Jacques Garrigue, Kyoto University RIMS *) (* *) (* Copyright 2002 Institut National de Recherche en Informatique et *) (* en Automatique and Kyoto University. All rights reserved. *) (* This file is distributed under the terms of the GNU Library *) (* General Public License, with the special exception on linking *) (* described in file LICENSE found in the OCaml source tree. *) (* *) (***********************************************************************)
irmin.ml
open! Import module Type = Repr module Diff = Diff module Content_addressable = Store.Content_addressable module Contents = Contents module Merge = Merge module Branch = Branch module Info = Info module Dot = Dot.Make module Hash = Hash module Path = Path module Perms = Perms exception Closed module CA_check_closed (CA : S.CONTENT_ADDRESSABLE_STORE_MAKER) : S.CONTENT_ADDRESSABLE_STORE_MAKER = functor (K : Hash.S) (V : Type.S) -> struct module S = CA (K) (V) type 'a t = { closed : bool ref; t : 'a S.t } type key = S.key type value = S.value let check_not_closed t = if !(t.closed) then raise Closed let mem t k = check_not_closed t; S.mem t.t k let find t k = check_not_closed t; S.find t.t k let add t v = check_not_closed t; S.add t.t v let unsafe_add t k v = check_not_closed t; S.unsafe_add t.t k v let batch t f = check_not_closed t; S.batch t.t (fun w -> f { t = w; closed = t.closed }) let v conf = let+ t = S.v conf in { closed = ref false; t } let close t = if !(t.closed) then Lwt.return_unit else ( t.closed := true; S.close t.t) let clear t = check_not_closed t; S.clear t.t end module AW_check_closed (AW : S.ATOMIC_WRITE_STORE_MAKER) : S.ATOMIC_WRITE_STORE_MAKER = functor (K : Type.S) (V : Type.S) -> struct module S = AW (K) (V) type t = { closed : bool ref; t : S.t } type key = S.key type value = S.value let check_not_closed t = if !(t.closed) then raise Closed let mem t k = check_not_closed t; S.mem t.t k let find t k = check_not_closed t; S.find t.t k let set t k v = check_not_closed t; S.set t.t k v let test_and_set t k ~test ~set = check_not_closed t; S.test_and_set t.t k ~test ~set let remove t k = check_not_closed t; S.remove t.t k let list t = check_not_closed t; S.list t.t type watch = S.watch let watch t ?init f = check_not_closed t; S.watch t.t ?init f let watch_key t k ?init f = check_not_closed t; S.watch_key t.t k ?init f let unwatch t w = check_not_closed t; S.unwatch t.t w let v conf = let+ t = S.v conf in { closed = ref false; t } let close t = if !(t.closed) then Lwt.return_unit else ( t.closed := true; S.close t.t) let clear t = check_not_closed t; S.clear t.t end module Maker_ext (CA : S.CONTENT_ADDRESSABLE_STORE_MAKER) (AW : S.ATOMIC_WRITE_STORE_MAKER) (N : Node.Maker) (CT : Commit.Maker) = struct type endpoint = unit module Make (M : S.METADATA) (C : Contents.S) (P : Path.S) (B : Branch.S) (H : Hash.S) = struct module CA = CA_check_closed (CA) module AW = AW_check_closed (AW) module X = struct module Hash = H module Contents = struct module CA = struct module Key = Hash module Val = C include CA (Key) (Val) end include Contents.Store (CA) end module Node = struct module CA = struct module Key = Hash module Val = N (H) (P) (M) include CA (Key) (Val) end include Node.Store (Contents) (P) (M) (CA) end module Commit = struct module CA = struct module Key = Hash module Val = CT (H) include CA (Key) (Val) end include Commit.Store (Node) (CA) end module Branch = struct module Key = B module Val = H include AW (Key) (Val) end module Slice = Slice.Make (Contents) (Node) (Commit) module Sync = Sync.None (H) (B) module Repo = struct type t = { config : Conf.t; contents : read Contents.t; nodes : read Node.t; commits : read Commit.t; branch : Branch.t; } let contents_t t = t.contents let node_t t = t.nodes let commit_t t = t.commits let branch_t t = t.branch let batch t f = Contents.CA.batch t.contents @@ fun c -> Node.CA.batch (snd t.nodes) @@ fun n -> Commit.CA.batch (snd t.commits) @@ fun ct -> let contents_t = c in let node_t = (contents_t, n) in let commit_t = (node_t, ct) in f contents_t node_t commit_t let v config = let* contents = Contents.CA.v config in let* nodes = Node.CA.v config in let* commits = Commit.CA.v config in let nodes = (contents, nodes) in let commits = (nodes, commits) in let+ branch = Branch.v config in { contents; nodes; commits; branch; config } let close t = Contents.CA.close t.contents >>= fun () -> Node.CA.close (snd t.nodes) >>= fun () -> Commit.CA.close (snd t.commits) >>= fun () -> Branch.close t.branch end end include Store.Make (X) end end module Make_ext (CA : S.CONTENT_ADDRESSABLE_STORE_MAKER) (AW : S.ATOMIC_WRITE_STORE_MAKER) (M : S.METADATA) (C : Contents.S) (P : Path.S) (B : Branch.S) (H : Hash.S) (N : Node.S with type metadata = M.t and type hash = H.t and type step = P.step) (CT : Commit.S with type hash = H.t) = struct module CA = CA_check_closed (CA) module AW = AW_check_closed (AW) module X = struct module Hash = H module Contents = struct module CA = struct module Key = Hash module Val = C include CA (Key) (Val) end include Contents.Store (CA) end module Node = struct module CA = struct module Key = Hash module Val = N include CA (Key) (Val) end include Node.Store (Contents) (P) (M) (CA) end module Commit = struct module CA = struct module Key = Hash module Val = CT include CA (Key) (Val) end include Commit.Store (Node) (CA) end module Branch = struct module Key = B module Val = H include AW (Key) (Val) end module Slice = Slice.Make (Contents) (Node) (Commit) module Sync = Sync.None (H) (B) module Repo = struct type t = { config : Conf.t; contents : read Contents.t; nodes : read Node.t; commits : read Commit.t; branch : Branch.t; } let contents_t t = t.contents let node_t t = t.nodes let commit_t t = t.commits let branch_t t = t.branch let batch t f = Contents.CA.batch t.contents @@ fun c -> Node.CA.batch (snd t.nodes) @@ fun n -> Commit.CA.batch (snd t.commits) @@ fun ct -> let contents_t = c in let node_t = (contents_t, n) in let commit_t = (node_t, ct) in f contents_t node_t commit_t let v config = let* contents = Contents.CA.v config in let* nodes = Node.CA.v config in let* commits = Commit.CA.v config in let nodes = (contents, nodes) in let commits = (nodes, commits) in let+ branch = Branch.v config in { contents; nodes; commits; branch; config } let close t = Contents.CA.close t.contents >>= fun () -> Node.CA.close (snd t.nodes) >>= fun () -> Commit.CA.close (snd t.commits) >>= fun () -> Branch.close t.branch end end include Store.Make (X) end module Make (CA : S.CONTENT_ADDRESSABLE_STORE_MAKER) (AW : S.ATOMIC_WRITE_STORE_MAKER) (M : S.METADATA) (C : Contents.S) (P : Path.S) (B : Branch.S) (H : Hash.S) = struct module N = Node.Make (H) (P) (M) module CT = Commit.Make (H) include Make_ext (CA) (AW) (M) (C) (P) (B) (H) (N) (CT) end module Of_private = Store.Make module type CONTENT_ADDRESSABLE_STORE = S.CONTENT_ADDRESSABLE_STORE module type APPEND_ONLY_STORE = S.APPEND_ONLY_STORE module type ATOMIC_WRITE_STORE = S.ATOMIC_WRITE_STORE module type TREE = Tree.S module type S = Store.S type config = Conf.t type 'a diff = 'a Diff.t module type CONTENT_ADDRESSABLE_STORE_MAKER = S.CONTENT_ADDRESSABLE_STORE_MAKER module type APPEND_ONLY_STORE_MAKER = S.APPEND_ONLY_STORE_MAKER module type ATOMIC_WRITE_STORE_MAKER = S.ATOMIC_WRITE_STORE_MAKER module type S_MAKER = Store.MAKER module type KV = S with type key = string list and type step = string and type branch = string module type KV_MAKER = functor (C : Contents.S) -> KV with type contents = C.t module Private = struct module Conf = Conf module Node = Node module Commit = Commit module Slice = Slice module Sync = Sync module Sigs = S module type S = Private.S module Watch = Watch module Lock = Lock module Lru = Lru end let version = Version.current module type SYNC = Sync_ext.SYNC_STORE module Sync = Sync_ext.Make type remote = S.remote = .. let remote_store (type t) (module M : S with type t = t) (t : t) = let module X : Store.S with type t = t = M in Sync_ext.remote_store (module X) t module Metadata = struct module type S = S.METADATA module None = Node.No_metadata end module Json_tree = Store.Json_tree module Export_for_backends = Export_for_backends
(* * Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
sha3-stubs.c
#include <caml/mlvalues.h> #include <caml/alloc.h> #include "sha3-ref.h" value sha3_size_of_context_ml(value unit_v) { return Val_int(sizeof(sha3_context)); } value sha3_init_ml(value ctx_v, value kind_v) { sha3_context* ctx = (sha3_context*)String_val(ctx_v); int kind = Int_val(kind_v); if(kind == 0) sha3_Init256( ctx ); else if(kind == 1) sha3_Init384( ctx ); else sha3_Init512( ctx ); return ctx_v; } value sha3_update_ml(value ctx_v, value input_v) { sha3_context* ctx = (sha3_context*)String_val(ctx_v); void *input = (void *)String_val(input_v); size_t inlen = caml_string_length(input_v); sha3_Update( ctx, input, inlen ); return Val_unit; } value sha3_final_ml(value ctx_v, value output_v) { sha3_context* ctx = (sha3_context*)String_val(ctx_v); void *output = (void *)String_val(output_v); void const * res = sha3_Finalize( ctx ); memcpy(output, res, caml_string_length(output_v)); return Val_unit; }
/**************************************************************************/ /* */ /* Copyright (c) 2017 . */ /* Fabrice Le Fessant, INRIA & OCamlPro SAS <fabrice@lefessant.net> */ /* */ /* All rights reserved. No warranty, explicit or implicit, provided. */ /* */ /**************************************************************************/
helpers_services.ml
open Alpha_context type error += Cannot_parse_operation (* `Branch *) let () = register_error_kind `Branch ~id:"operation.cannot_parse" ~title:"Cannot parse operation" ~description:"The operation is ill-formed or for another protocol version" ~pp:(fun ppf () -> Format.fprintf ppf "The operation cannot be parsed") Data_encoding.unit (function Cannot_parse_operation -> Some () | _ -> None) (fun () -> Cannot_parse_operation) let parse_operation (op : Operation.raw) = match Data_encoding.Binary.of_bytes Operation.protocol_data_encoding op.proto with | Some protocol_data -> ok {shell = op.shell; protocol_data} | None -> error Cannot_parse_operation let path = RPC_path.(open_root / "helpers") module Scripts = struct module S = struct open Data_encoding let path = RPC_path.(path / "scripts") let run_code_input_encoding = obj9 (req "script" Script.expr_encoding) (req "storage" Script.expr_encoding) (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "chain_id" Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" z) (dft "entrypoint" string "default") let trace_encoding = def "scripted.trace" @@ list @@ obj3 (req "location" Script.location_encoding) (req "gas" Gas.encoding) (req "stack" (list (obj2 (req "item" Script.expr_encoding) (opt "annot" string)))) let run_code = RPC_service.post_service ~description:"Run a piece of code in the current context" ~query:RPC_query.empty ~input:run_code_input_encoding ~output: (obj3 (req "storage" Script.expr_encoding) (req "operations" (list Operation.internal_operation_encoding)) (opt "big_map_diff" Contract.big_map_diff_encoding)) RPC_path.(path / "run_code") let trace_code = RPC_service.post_service ~description: "Run a piece of code in the current context, keeping a trace" ~query:RPC_query.empty ~input:run_code_input_encoding ~output: (obj4 (req "storage" Script.expr_encoding) (req "operations" (list Operation.internal_operation_encoding)) (req "trace" trace_encoding) (opt "big_map_diff" Contract.big_map_diff_encoding)) RPC_path.(path / "trace_code") let typecheck_code = RPC_service.post_service ~description:"Typecheck a piece of code in the current context" ~query:RPC_query.empty ~input:(obj2 (req "program" Script.expr_encoding) (opt "gas" z)) ~output: (obj2 (req "type_map" Script_tc_errors_registration.type_map_enc) (req "gas" Gas.encoding)) RPC_path.(path / "typecheck_code") let typecheck_data = RPC_service.post_service ~description: "Check that some data expression is well formed and of a given type \ in the current context" ~query:RPC_query.empty ~input: (obj3 (req "data" Script.expr_encoding) (req "type" Script.expr_encoding) (opt "gas" z)) ~output:(obj1 (req "gas" Gas.encoding)) RPC_path.(path / "typecheck_data") let pack_data = RPC_service.post_service ~description: "Computes the serialized version of some data expression using the \ same algorithm as script instruction PACK" ~input: (obj3 (req "data" Script.expr_encoding) (req "type" Script.expr_encoding) (opt "gas" z)) ~output:(obj2 (req "packed" bytes) (req "gas" Gas.encoding)) ~query:RPC_query.empty RPC_path.(path / "pack_data") let run_operation = RPC_service.post_service ~description:"Run an operation without signature checks" ~query:RPC_query.empty ~input: (obj2 (req "operation" Operation.encoding) (req "chain_id" Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") let entrypoint_type = RPC_service.post_service ~description:"Return the type of the given entrypoint" ~query:RPC_query.empty ~input: (obj2 (req "script" Script.expr_encoding) (dft "entrypoint" string "default")) ~output:(obj1 (req "entrypoint_type" Script.expr_encoding)) RPC_path.(path / "entrypoint") let list_entrypoints = RPC_service.post_service ~description:"Return the list of entrypoints of the given script" ~query:RPC_query.empty ~input:(obj1 (req "script" Script.expr_encoding)) ~output: (obj2 (dft "unreachable" (Data_encoding.list (obj1 (req "path" (Data_encoding.list Michelson_v1_primitives.prim_encoding)))) []) (req "entrypoints" (assoc Script.expr_encoding))) RPC_path.(path / "entrypoints") end let register () = let open Services_registration in let originate_dummy_contract ctxt script = let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in Contract.fresh_contract_from_current_nonce ctxt >>=? fun (ctxt, dummy_contract) -> let balance = match Tez.of_mutez 4_000_000_000_000L with | Some balance -> balance | None -> assert false in Contract.originate ctxt dummy_contract ~balance ~delegate:None ~script:(script, None) >>=? fun ctxt -> return (ctxt, dummy_contract) in register0 S.run_code (fun ctxt () ( code, storage, parameter, amount, chain_id, source, payer, gas, entrypoint ) -> let storage = Script.lazy_expr storage in let code = Script.lazy_expr code in originate_dummy_contract ctxt {storage; code} >>=? fun (ctxt, dummy_contract) -> let (source, payer) = match (source, payer) with | (Some source, Some payer) -> (source, payer) | (Some source, None) -> (source, source) | (None, Some payer) -> (payer, payer) | (None, None) -> (dummy_contract, dummy_contract) in let gas = match gas with | Some gas -> gas | None -> Constants.hard_gas_limit_per_operation ctxt in let ctxt = Gas.set_limit ctxt gas in let step_constants = let open Script_interpreter in {source; payer; self = dummy_contract; amount; chain_id} in Script_interpreter.execute ctxt Readable step_constants ~script:{storage; code} ~entrypoint ~parameter >>=? fun {Script_interpreter.storage; operations; big_map_diff; _} -> return (storage, operations, big_map_diff)) ; register0 S.trace_code (fun ctxt () ( code, storage, parameter, amount, chain_id, source, payer, gas, entrypoint ) -> let storage = Script.lazy_expr storage in let code = Script.lazy_expr code in originate_dummy_contract ctxt {storage; code} >>=? fun (ctxt, dummy_contract) -> let (source, payer) = match (source, payer) with | (Some source, Some payer) -> (source, payer) | (Some source, None) -> (source, source) | (None, Some payer) -> (payer, payer) | (None, None) -> (dummy_contract, dummy_contract) in let gas = match gas with | Some gas -> gas | None -> Constants.hard_gas_limit_per_operation ctxt in let ctxt = Gas.set_limit ctxt gas in let step_constants = let open Script_interpreter in {source; payer; self = dummy_contract; amount; chain_id} in Script_interpreter.trace ctxt Readable step_constants ~script:{storage; code} ~entrypoint ~parameter >>=? fun ( {Script_interpreter.storage; operations; big_map_diff; _}, trace ) -> return (storage, operations, trace, big_map_diff)) ; register0 S.typecheck_code (fun ctxt () (expr, maybe_gas) -> let ctxt = match maybe_gas with | None -> Gas.set_unlimited ctxt | Some gas -> Gas.set_limit ctxt gas in Script_ir_translator.typecheck_code ctxt expr >>=? fun (res, ctxt) -> return (res, Gas.level ctxt)) ; register0 S.typecheck_data (fun ctxt () (data, ty, maybe_gas) -> let ctxt = match maybe_gas with | None -> Gas.set_unlimited ctxt | Some gas -> Gas.set_limit ctxt gas in Script_ir_translator.typecheck_data ctxt (data, ty) >>=? fun ctxt -> return (Gas.level ctxt)) ; register0 S.pack_data (fun ctxt () (expr, typ, maybe_gas) -> let open Script_ir_translator in let ctxt = match maybe_gas with | None -> Gas.set_unlimited ctxt | Some gas -> Gas.set_limit ctxt gas in Lwt.return (parse_packable_ty ctxt ~legacy:true (Micheline.root typ)) >>=? fun (Ex_ty typ, ctxt) -> parse_data ctxt ~legacy:true typ (Micheline.root expr) >>=? fun (data, ctxt) -> Script_ir_translator.pack_data ctxt typ data >>=? fun (bytes, ctxt) -> return (bytes, Gas.level ctxt)) ; register0 S.run_operation (fun ctxt () ({shell; protocol_data = Operation_data protocol_data}, chain_id) -> (* this code is a duplicate of Apply without signature check *) let partial_precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) : context tzresult Lwt.t = let (Manager_operation {source; fee; counter; operation; gas_limit; storage_limit}) = op in Lwt.return (Gas.check_limit ctxt gas_limit) >>=? fun () -> let ctxt = Gas.set_limit ctxt gas_limit in Lwt.return (Fees.check_storage_limit ctxt storage_limit) >>=? fun () -> Contract.must_be_allocated ctxt (Contract.implicit_contract source) >>=? fun () -> Contract.check_counter_increment ctxt source counter >>=? fun () -> ( match operation with | Reveal pk -> Contract.reveal_manager_key ctxt source pk | Transaction {parameters; _} -> (* Here the data comes already deserialized, so we need to fake the deserialization to mimic apply *) let arg_bytes = Data_encoding.Binary.to_bytes_exn Script.lazy_expr_encoding parameters in let arg = match Data_encoding.Binary.of_bytes Script.lazy_expr_encoding arg_bytes with | Some arg -> arg | None -> assert false in (* Fail quickly if not enough gas for minimal deserialization cost *) Lwt.return @@ record_trace Apply.Gas_quota_exceeded_init_deserialize @@ Gas.check_enough ctxt (Script.minimal_deserialize_cost arg) >>=? fun () -> (* Fail if not enough gas for complete deserialization cost *) trace Apply.Gas_quota_exceeded_init_deserialize @@ Script.force_decode ctxt arg >>|? fun (_arg, ctxt) -> ctxt | Origination {script; _} -> (* Here the data comes already deserialized, so we need to fake the deserialization to mimic apply *) let script_bytes = Data_encoding.Binary.to_bytes_exn Script.encoding script in let script = match Data_encoding.Binary.of_bytes Script.encoding script_bytes with | Some script -> script | None -> assert false in (* Fail quickly if not enough gas for minimal deserialization cost *) Lwt.return @@ record_trace Apply.Gas_quota_exceeded_init_deserialize @@ ( Gas.consume ctxt (Script.minimal_deserialize_cost script.code) >>? fun ctxt -> Gas.check_enough ctxt (Script.minimal_deserialize_cost script.storage) ) >>=? fun () -> (* Fail if not enough gas for complete deserialization cost *) trace Apply.Gas_quota_exceeded_init_deserialize @@ Script.force_decode ctxt script.code >>=? fun (_code, ctxt) -> trace Apply.Gas_quota_exceeded_init_deserialize @@ Script.force_decode ctxt script.storage >>|? fun (_storage, ctxt) -> ctxt | _ -> return ctxt ) >>=? fun ctxt -> Contract.get_manager_key ctxt source >>=? fun _public_key -> (* signature check unplugged from here *) Contract.increment_counter ctxt source >>=? fun ctxt -> Contract.spend ctxt (Contract.implicit_contract source) fee >>=? fun ctxt -> return ctxt in let rec partial_precheck_manager_contents_list : type kind. Alpha_context.t -> kind Kind.manager contents_list -> context tzresult Lwt.t = fun ctxt contents_list -> match contents_list with | Single (Manager_operation _ as op) -> partial_precheck_manager_contents ctxt op | Cons ((Manager_operation _ as op), rest) -> partial_precheck_manager_contents ctxt op >>=? fun ctxt -> partial_precheck_manager_contents_list ctxt rest in let return contents = return ( Operation_data protocol_data, Apply_results.Operation_metadata {contents} ) in let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Contract.init_origination_nonce ctxt hash in let baker = Signature.Public_key_hash.zero in match protocol_data.contents with | Single (Manager_operation _) as op -> partial_precheck_manager_contents_list ctxt op >>=? fun ctxt -> Apply.apply_manager_contents_list ctxt Optimized baker chain_id op >>= fun (_ctxt, result) -> return result | Cons (Manager_operation _, _) as op -> partial_precheck_manager_contents_list ctxt op >>=? fun ctxt -> Apply.apply_manager_contents_list ctxt Optimized baker chain_id op >>= fun (_ctxt, result) -> return result | _ -> Apply.apply_contents_list ctxt chain_id Optimized shell.branch baker operation operation.protocol_data.contents >>=? fun (_ctxt, result) -> return result) ; register0 S.entrypoint_type (fun ctxt () (expr, entrypoint) -> let ctxt = Gas.set_unlimited ctxt in let legacy = false in let open Script_ir_translator in Lwt.return ( parse_toplevel ~legacy expr >>? fun (arg_type, _, _, root_name) -> parse_ty ctxt ~legacy ~allow_big_map:true ~allow_operation:false ~allow_contract:true arg_type >>? fun (Ex_ty arg_type, _) -> Script_ir_translator.find_entrypoint ~root_name arg_type entrypoint ) >>=? fun (_f, Ex_ty ty) -> unparse_ty ctxt ty >>=? fun (ty_node, _) -> return (Micheline.strip_locations ty_node)) ; register0 S.list_entrypoints (fun ctxt () expr -> let ctxt = Gas.set_unlimited ctxt in let legacy = false in let open Script_ir_translator in Lwt.return ( parse_toplevel ~legacy expr >>? fun (arg_type, _, _, root_name) -> parse_ty ctxt ~legacy ~allow_big_map:true ~allow_operation:false ~allow_contract:true arg_type >>? fun (Ex_ty arg_type, _) -> Script_ir_translator.list_entrypoints ~root_name arg_type ctxt ) >>=? fun (unreachable_entrypoint, map) -> return ( unreachable_entrypoint, Entrypoints_map.fold (fun entry (_, ty) acc -> (entry, Micheline.strip_locations ty) :: acc) map [] )) let run_code ctxt block code (storage, input, amount, chain_id, source, payer, gas, entrypoint) = RPC_context.make_call0 S.run_code ctxt block () (code, storage, input, amount, chain_id, source, payer, gas, entrypoint) let trace_code ctxt block code (storage, input, amount, chain_id, source, payer, gas, entrypoint) = RPC_context.make_call0 S.trace_code ctxt block () (code, storage, input, amount, chain_id, source, payer, gas, entrypoint) let typecheck_code ctxt block = RPC_context.make_call0 S.typecheck_code ctxt block () let typecheck_data ctxt block = RPC_context.make_call0 S.typecheck_data ctxt block () let pack_data ctxt block = RPC_context.make_call0 S.pack_data ctxt block () let run_operation ctxt block = RPC_context.make_call0 S.run_operation ctxt block () let entrypoint_type ctxt block = RPC_context.make_call0 S.entrypoint_type ctxt block () let list_entrypoints ctxt block = RPC_context.make_call0 S.list_entrypoints ctxt block () end module Forge = struct module S = struct open Data_encoding let path = RPC_path.(path / "forge") let operations = RPC_service.post_service ~description:"Forge an operation" ~query:RPC_query.empty ~input:Operation.unsigned_encoding ~output:bytes RPC_path.(path / "operations") let empty_proof_of_work_nonce = MBytes.of_string (String.make Constants_repr.proof_of_work_nonce_size '\000') let protocol_data = RPC_service.post_service ~description:"Forge the protocol-specific part of a block header" ~query:RPC_query.empty ~input: (obj3 (req "priority" uint16) (opt "nonce_hash" Nonce_hash.encoding) (dft "proof_of_work_nonce" (Fixed.bytes Alpha_context.Constants.proof_of_work_nonce_size) empty_proof_of_work_nonce)) ~output:(obj1 (req "protocol_data" bytes)) RPC_path.(path / "protocol_data") end let register () = let open Services_registration in register0_noctxt S.operations (fun () (shell, proto) -> return (Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding (shell, proto))) ; register0_noctxt S.protocol_data (fun () (priority, seed_nonce_hash, proof_of_work_nonce) -> return (Data_encoding.Binary.to_bytes_exn Block_header.contents_encoding {priority; seed_nonce_hash; proof_of_work_nonce})) module Manager = struct let operations ctxt block ~branch ~source ?sourcePubKey ~counter ~fee ~gas_limit ~storage_limit operations = Contract_services.manager_key ctxt block source >>= function | Error _ as e -> Lwt.return e | Ok revealed -> let ops = List.map (fun (Manager operation) -> Contents (Manager_operation { source; counter; operation; fee; gas_limit; storage_limit; })) operations in let ops = match (sourcePubKey, revealed) with | (None, _) | (_, Some _) -> ops | (Some pk, None) -> let operation = Reveal pk in Contents (Manager_operation { source; counter; operation; fee; gas_limit; storage_limit; }) :: ops in RPC_context.make_call0 S.operations ctxt block () ({branch}, Operation.of_list ops) let reveal ctxt block ~branch ~source ~sourcePubKey ~counter ~fee () = operations ctxt block ~branch ~source ~sourcePubKey ~counter ~fee ~gas_limit:Z.zero ~storage_limit:Z.zero [] let transaction ctxt block ~branch ~source ?sourcePubKey ~counter ~amount ~destination ?(entrypoint = "default") ?parameters ~gas_limit ~storage_limit ~fee () = let parameters = Option.unopt_map ~f:Script.lazy_expr ~default:Script.unit_parameter parameters in operations ctxt block ~branch ~source ?sourcePubKey ~counter ~fee ~gas_limit ~storage_limit [Manager (Transaction {amount; parameters; destination; entrypoint})] let origination ctxt block ~branch ~source ?sourcePubKey ~counter ~balance ?delegatePubKey ~script ~gas_limit ~storage_limit ~fee () = operations ctxt block ~branch ~source ?sourcePubKey ~counter ~fee ~gas_limit ~storage_limit [ Manager (Origination { delegate = delegatePubKey; script; credit = balance; preorigination = None; }) ] let delegation ctxt block ~branch ~source ?sourcePubKey ~counter ~fee delegate = operations ctxt block ~branch ~source ?sourcePubKey ~counter ~fee ~gas_limit:Z.zero ~storage_limit:Z.zero [Manager (Delegation delegate)] end let operation ctxt block ~branch operation = RPC_context.make_call0 S.operations ctxt block () ({branch}, Contents_list (Single operation)) let endorsement ctxt b ~branch ~level () = operation ctxt b ~branch (Endorsement {level}) let proposals ctxt b ~branch ~source ~period ~proposals () = operation ctxt b ~branch (Proposals {source; period; proposals}) let ballot ctxt b ~branch ~source ~period ~proposal ~ballot () = operation ctxt b ~branch (Ballot {source; period; proposal; ballot}) let seed_nonce_revelation ctxt block ~branch ~level ~nonce () = operation ctxt block ~branch (Seed_nonce_revelation {level; nonce}) let double_baking_evidence ctxt block ~branch ~bh1 ~bh2 () = operation ctxt block ~branch (Double_baking_evidence {bh1; bh2}) let double_endorsement_evidence ctxt block ~branch ~op1 ~op2 () = operation ctxt block ~branch (Double_endorsement_evidence {op1; op2}) let empty_proof_of_work_nonce = MBytes.of_string (String.make Constants_repr.proof_of_work_nonce_size '\000') let protocol_data ctxt block ~priority ?seed_nonce_hash ?(proof_of_work_nonce = empty_proof_of_work_nonce) () = RPC_context.make_call0 S.protocol_data ctxt block () (priority, seed_nonce_hash, proof_of_work_nonce) end module Parse = struct module S = struct open Data_encoding let path = RPC_path.(path / "parse") let operations = RPC_service.post_service ~description:"Parse operations" ~query:RPC_query.empty ~input: (obj2 (req "operations" (list (dynamic_size Operation.raw_encoding))) (opt "check_signature" bool)) ~output:(list (dynamic_size Operation.encoding)) RPC_path.(path / "operations") let block = RPC_service.post_service ~description:"Parse a block" ~query:RPC_query.empty ~input:Block_header.raw_encoding ~output:Block_header.protocol_data_encoding RPC_path.(path / "block") end let parse_protocol_data protocol_data = match Data_encoding.Binary.of_bytes Block_header.protocol_data_encoding protocol_data with | None -> failwith "Cant_parse_protocol_data" | Some protocol_data -> return protocol_data let register () = let open Services_registration in register0 S.operations (fun _ctxt () (operations, check) -> map_s (fun raw -> Lwt.return (parse_operation raw) >>=? fun op -> ( match check with | Some true -> return_unit (* FIXME *) (* I.check_signature ctxt *) (* op.protocol_data.signature op.shell op.protocol_data.contents *) | Some false | None -> return_unit ) >>|? fun () -> op) operations) ; register0_noctxt S.block (fun () raw_block -> parse_protocol_data raw_block.protocol_data) let operations ctxt block ?check operations = RPC_context.make_call0 S.operations ctxt block () (operations, check) let block ctxt block shell protocol_data = RPC_context.make_call0 S.block ctxt block () ({shell; protocol_data} : Block_header.raw) end module S = struct open Data_encoding type level_query = {offset : int32} let level_query : level_query RPC_query.t = let open RPC_query in query (fun offset -> {offset}) |+ field "offset" RPC_arg.int32 0l (fun t -> t.offset) |> seal let current_level = RPC_service.get_service ~description: "Returns the level of the interrogated block, or the one of a block \ located `offset` blocks after in the chain (or before when \ negative). For instance, the next block if `offset` is 1." ~query:level_query ~output:Level.encoding RPC_path.(path / "current_level") let levels_in_current_cycle = RPC_service.get_service ~description:"Levels of a cycle" ~query:level_query ~output: (obj2 (req "first" Raw_level.encoding) (req "last" Raw_level.encoding)) RPC_path.(path / "levels_in_current_cycle") end let register () = Scripts.register () ; Forge.register () ; Parse.register () ; let open Services_registration in register0 S.current_level (fun ctxt q () -> let level = Level.current ctxt in return (Level.from_raw ctxt ~offset:q.offset level.level)) ; register0 S.levels_in_current_cycle (fun ctxt q () -> let levels = Level.levels_in_current_cycle ctxt ~offset:q.offset () in match levels with | [] -> raise Not_found | _ -> let first = List.hd (List.rev levels) in let last = List.hd levels in return (first.level, last.level)) let current_level ctxt ?(offset = 0l) block = RPC_context.make_call0 S.current_level ctxt block {offset} () let levels_in_current_cycle ctxt ?(offset = 0l) block = RPC_context.make_call0 S.levels_in_current_cycle ctxt block {offset} ()
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
helpers.ml
module Generator = Generator module Server = Server
(*****************************************************************************) (* Open Source License *) (* Copyright (c) 2022-present Étienne Marais <etienne@maiste.fr> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
rfc.ml
open Core (* module RFC2822 = struct let unfold str = let lexbuf = Lexing.from_string str in let bigbuffer = Bigbuffer.create (String.length str) in Lexer.field_unstructured_unfold bigbuffer lexbuf; Bigbuffer.contents bigbuffer ;; let fold str = let lexbuf = Lexing.from_string str in let bigbuffer = Bigbuffer.create (String.length str) in Lexer.field_unstructured_fold bigbuffer lexbuf; Bigbuffer.contents bigbuffer ;; TEST_MODULE "Folding_and_unfolding" = struct TEST = (fold "a\n b\nc") = " a\n b\n c" TEST = (fold " a\n b\nc") = " a\n b\n c" TEST = (fold "\ta\n b\nc") = "\ta\n b\n c" TEST = (unfold " a\n b\nc d") = "a b c d" end end *) module RFC2045 = struct module Token = struct include (Mimestring.Case_insensitive : Mimestring.S) let is_valid str = (not (String.is_empty str)) && String.for_all str ~f:(function | '(' | ')' | '<' | '>' | '@' | ',' | ';' | ':' | '\\' | '"' | '/' | '[' | ']' | '?' | '=' -> false (* '\n', '\r', ' ' are excluded by the following: *) | '\033' .. '\126' -> true | _ -> false) ;; let is_valid_or_quote str = if is_valid str then str else Mimestring.quote str end end
Parsing_stat.mli
(* Type holding parsing stats and optionally AST stats. *) type ast_stat = { total_node_count : int; untranslated_node_count : int } type t = { filename : Common.filename; total_line_count : int; mutable error_line_count : int; mutable have_timeout : bool; (* used only for cpp for now, to help diagnose problematic macros, * see print_recurring_problematic_tokens below. *) mutable commentized : int; mutable problematic_lines : (string list * int) list; (* AST stats obtained by inspecting the resulting AST, if any. *) ast_stat : ast_stat option; } val default_stat : Common.filename -> t val bad_stat : Common.filename -> t val correct_stat : Common.filename -> t (* Print file name and number of lines and error lines in compact format suitable for logging. *) val summary_of_stat : t -> string val print_parsing_stat_list : ?verbose:bool -> t list -> unit val print_recurring_problematic_tokens : t list -> unit val aggregate_stats : t list -> int * int (* total * bad *) val print_regression_information : ext:string -> Common2.path list -> Common2.score -> unit
(* Type holding parsing stats and optionally AST stats. *)
init_storage.mli
(** Functions to setup storage. Used by [Alpha_context.prepare]. If you have defined a new type of storage, you should add relevant setups here. *) (* This is the genesis protocol: initialise the state *) val prepare_first_block : Chain_id.t -> Context.t -> typecheck: (Raw_context.t -> Script_repr.t -> ((Script_repr.t * Lazy_storage_diff.diffs option) * Raw_context.t) Error_monad.tzresult Lwt.t) -> level:int32 -> timestamp:Time.t -> (Raw_context.t, Error_monad.error Error_monad.trace) Pervasives.result Lwt.t val prepare : Context.t -> level:Int32.t -> predecessor_timestamp:Time.t -> timestamp:Time.t -> (Raw_context.t * Receipt_repr.balance_updates * Migration_repr.origination_result list) Error_monad.tzresult Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* Copyright (c) 2020-2021 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
parsing_hacks_js.ml
module Flag = Flag_parsing module PI = Parse_info module Ast = Ast_js module T = Parser_js module TH = Token_helpers_js module F = Ast_fuzzy let logger = Logging.get_logger [ __MODULE__ ] (*****************************************************************************) (* Prelude *) (*****************************************************************************) (* The goal for this module is to retag tokens * (e.g., a T_LPAREN in T_LPAREN_ARROW) * or insert tokens (e.g., T_VIRTUAL_SEMICOLON) to * help the grammar remains simple and unambiguous. See * lang_cpp/parsing/parsing_hacks.ml for more information about * this technique. * * This module inserts fake virtual semicolons, which is known as * Automatic Semicolon Insertion, or ASI for short. * Those semicolons can be ommitted by the user (but really should not). * ASI works in two steps: * - certain tokens can not be followed by a newline (e.g., continue) * and we detect those tokens in this file. * - we also insert semicolons during error recovery in parser_js.ml. After * all that was what the spec says. * Note that we need both techniques. See parse_js.ml comment for * the limitations of using just the second technique. * * reference: * -http://www.bradoncode.com/blog/2015/08/26/javascript-semi-colon-insertion * -http://www.ecma-international.org/ecma-262/6.0/index.html#sec-automatic-semicolon-insertion *) (*****************************************************************************) (* Helpers *) (*****************************************************************************) (* (* obsolete *) let is_toplevel_keyword = function | T.T_IMPORT _ | T.T_EXPORT _ | T.T_VAR _ | T.T_LET _ | T.T_CONST _ | T.T_FUNCTION _ -> true | _ -> false (* obsolete *) let rparens_of_if toks = let toks = Common.exclude TH.is_comment toks in let stack = ref [] in let rparens_if = ref [] in toks |> Common2.iter_with_previous_opt (fun prev x -> (match x with | T.T_LPAREN _ -> Common.push prev stack; | T.T_RPAREN info -> if !stack <> [] then begin let top = Common2.pop2 stack in (match top with | Some (T.T_IF _) -> Common.push info rparens_if | _ -> () ) end | _ -> () ) ); !rparens_if *) (* alt: could have instead a better Ast_fuzzy type instead of putting * everything in the Tok category? *) let is_identifier horigin (info : Parse_info.t) = match Hashtbl.find_opt horigin info with | Some (T.T_ID _) -> true | _ -> false (*****************************************************************************) (* Entry point *) (*****************************************************************************) (* retagging: * - '(' when part of an arrow expression * - '{' when first token in sgrep mode * - less: '<' when part of a polymorphic type (aka generic) * - less: { when part of a pattern before an assignment *) let fix_tokens toks = try let trees = Lib_ast_fuzzy.mk_trees { Lib_ast_fuzzy.tokf = TH.info_of_tok; kind = TH.token_kind_of_tok } toks in let horigin = toks |> Common.map (fun t -> (TH.info_of_tok t, t)) |> Common.hash_of_list in let retag_lparen_arrow = Hashtbl.create 101 in let retag_lparen_method = Hashtbl.create 101 in let retag_keywords = Hashtbl.create 101 in let retag_lbrace = Hashtbl.create 101 in (match trees with (* probably an object pattern * TODO: check that no stmt-like keywords inside body? *) | F.Braces (t1, _body, _) :: _ when !Flag_parsing.sgrep_mode -> Hashtbl.add retag_lbrace t1 true (* TODO: skip keywords, attributes that may be before the method id *) | F.Tok (_s, info) :: F.Parens (i1, _, _) :: F.Braces (_, _, _) :: _ when !Flag_parsing.sgrep_mode && is_identifier horigin info -> Hashtbl.add retag_lparen_method i1 true | _ -> ()); (* visit and tag *) let visitor = Lib_ast_fuzzy.mk_visitor { Lib_ast_fuzzy.default_visitor with Lib_ast_fuzzy.ktrees = (fun (k, _) xs -> (match xs with | F.Parens (i1, _, _) :: F.Tok ("=>", _) :: _res -> Hashtbl.add retag_lparen_arrow i1 true (* TODO: also handle typed arrows! *) | F.Tok ("import", i1) :: F.Parens _ :: _res -> Hashtbl.add retag_keywords i1 true | _ -> ()); k xs); } in visitor trees; (* use the tagged information and transform tokens *) toks |> Common.map (function | T.T_LPAREN info when Hashtbl.mem retag_lparen_arrow info -> T.T_LPAREN_ARROW info | T.T_LPAREN info when Hashtbl.mem retag_lparen_method info -> T.T_LPAREN_METHOD_SEMGREP info | T.T_LCURLY info when Hashtbl.mem retag_lbrace info -> T.T_LCURLY_SEMGREP info | T.T_IMPORT info when Hashtbl.mem retag_keywords info -> T.T_ID (PI.str_of_info info, info) | x -> x) with | Lib_ast_fuzzy.Unclosed (msg, info) -> if !Flag.error_recovery then toks else raise (Parse_info.Lexical_error (msg, info)) (*****************************************************************************) (* ASI (Automatic Semicolon Insertion) part 1 *) (*****************************************************************************) let fix_tokens_ASI xs = let res = ref [] in let rec aux prev f xs = match xs with | [] -> () | e :: l -> if TH.is_comment e then ( Common.push e res; aux prev f l) else ( f prev e; aux e f l) in let push_sc_before_x x = let info = TH.info_of_tok x in let fake = Ast.fakeInfoAttach info in logger#debug "ASI: insertion fake ';' before %s" (PI.string_of_info info); Common.push (T.T_VIRTUAL_SEMICOLON fake) res in let f prev x = (match (prev, x) with (* continue * <newline> *) | (T.T_CONTINUE _ | T.T_BREAK _), _ when TH.line_of_tok x <> TH.line_of_tok prev -> push_sc_before_x x (* x * ++ * * very conservative; should be any last(left_hand_side_expression) * but for that better to rely on ASI via parse-error recovery; * no ambiguity like for continue because * if(true) x * ++y; * is not valid. *) | (T.T_ID _ | T.T_FALSE _ | T.T_TRUE _), (T.T_INCR _ | T.T_DECR _) when TH.line_of_tok x <> TH.line_of_tok prev -> push_sc_before_x x (* Note that we would like to insert a ';' for semgrep patterns like: * xxxx() * ... * * But we can't because we also have patterns like * if($X) * ... * in which case we don't want the semicolon. * We need to rely on the parse-error-based ASI to handle this. * * Note that we used to support ellipsis in method chaining in semgrep * with a single '...' such as '$o.foo() ... .bar()' but when you wrote: * $APP = express() * ... * without the semicolon, it was interpreted as a method chaining * $APP = express() ... * where we accept any method calls after express(). * Before 0.35 we did not support this feature, so when the parser found * $APP = express() * ... * it internally first generated a parse error, and the ASI kicked in, * but after 0.35 we did not generate a parse error, * because it was a valid semgrep pattern, and so we don't get ASI * to trigger. * The only way to fix it is to change the syntax for method chaining * to require an extra dot, to disambiguate. * * old: does not work: * | (T.T_RPAREN _ | T.T_ID _), T.T_DOTS _ * when TH.line_of_tok x <> TH.line_of_tok prev &&!Flag_parsing.sgrep_mode * -> push_sc_before_x x; *) | _ -> ()); Common.push x res in (* (* obsolete *) let rparens_if = rparens_of_if xs in let hrparens_if = Common.hashset_of_list rparens_if in (* history: this had too many false positives, which forced * to rewrite the grammar to add extra virtual semicolons which * then make the whole thing worse *) let _fobsolete = (fun prev x -> match prev, x with (* { } or ; } TODO: source of many issues *) | (T.T_LCURLY _ | T.T_SEMICOLON _), T.T_RCURLY _ -> Common.push x res; (* <not } or ;> } *) | _, T.T_RCURLY _ -> push_sc_before_x x; Common.push x res; (* ; EOF *) | (T.T_SEMICOLON _), T.EOF _ -> Common.push x res; (* <not ;> EOF *) | _, T.EOF _ -> push_sc_before_x x; Common.push x res; (* } * <keyword> *) | T.T_RCURLY _, (T.T_ID _ | T.T_IF _ | T.T_SWITCH _ | T.T_FOR _ | T.T_VAR _ | T.T_FUNCTION _ | T.T_LET _ | T.T_CONST _ | T.T_RETURN _ | T.T_BREAK _ | T.T_CONTINUE _ (* todo: sure? *) | T.T_THIS _ | T.T_NEW _ ) when TH.line_of_tok x <> TH.line_of_tok prev -> push_sc_before_x x; Common.push x res (* ) * <keyword> *) (* this is valid only if the RPAREN is not the closing paren of an if*) | T.T_RPAREN info, (T.T_VAR _ | T.T_IF _ | T.T_THIS _ | T.T_FOR _ | T.T_RETURN _ | T.T_ID _ | T.T_CONTINUE _ ) when TH.line_of_tok x <> TH.line_of_tok prev && not (Hashtbl.mem hrparens_if info) -> push_sc_before_x x; Common.push x res; (* ] * <keyword> *) | T.T_RBRACKET _, (T.T_FOR _ | T.T_IF _ | T.T_VAR _ | T.T_ID _) when TH.line_of_tok x <> TH.line_of_tok prev -> push_sc_before_x x; Common.push x res; (* <literal> * <keyword> *) | (T.T_ID _ | T.T_NULL _ | T.T_STRING _ | T.T_REGEX _ | T.T_FALSE _ | T.T_TRUE _ ), (T.T_VAR _ | T.T_ID _ | T.T_IF _ | T.T_THIS _ | T.T_RETURN _ | T.T_BREAK _ | T.T_ELSE _ ) when TH.line_of_tok x <> TH.line_of_tok prev -> push_sc_before_x x; Common.push x res; (* } or ; or , or = * <keyword> col 0 *) | (T.T_RCURLY _ | T.T_SEMICOLON _ | T.T_COMMA _ | T.T_ASSIGN _), _ when is_toplevel_keyword x && TH.line_of_tok x <> TH.line_of_tok prev && TH.col_of_tok x = 0 -> Common.push x res; (* <no ; or }> * <keyword> col 0 *) | _, _ when is_toplevel_keyword x && TH.line_of_tok x <> TH.line_of_tok prev && TH.col_of_tok x = 0 -> push_sc_before_x x; Common.push x res; (* else *) | _, _ -> Common.push x res; ) in *) match xs with | [] -> [] | x :: _ -> let sentinel = let fake = Ast.fakeInfoAttach (TH.info_of_tok x) in T.T_SEMICOLON fake in aux sentinel f xs; List.rev !res
(* Yoann Padioleau * * Copyright (C) 2010, 2013 Facebook * Copyright (C) 2019 r2c * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation, with the * special exception on linking described in file license.txt. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file * license.txt for more details. *)