diff --git a/src/lib_protocol_compiler/compiler.ml b/src/lib_protocol_compiler/compiler.ml index b16e99e22..a305752ab 100644 --- a/src/lib_protocol_compiler/compiler.ml +++ b/src/lib_protocol_compiler/compiler.ml @@ -171,7 +171,7 @@ let main { compile_ml ; pack_objects ; link_shared } = (* Generate the 'functor' *) let functor_file = build_dir // "functor.ml" in let oc = open_out functor_file in - Packer.dump oc + Packer.dump oc hash (Array.map begin fun { Protocol.name } -> let name_lowercase = String.uncapitalize_ascii name in diff --git a/src/lib_protocol_compiler/main_packer.ml b/src/lib_protocol_compiler/main_packer.ml index 16315e5fc..e60577183 100644 --- a/src/lib_protocol_compiler/main_packer.ml +++ b/src/lib_protocol_compiler/main_packer.ml @@ -20,14 +20,14 @@ let () = match List.rev !anonymous with | [ source_dir ] -> source_dir | _ -> Arg.usage args_spec usage_msg ; Pervasives.exit 1 in - let _hash, protocol = + let hash, protocol = match Lwt_main.run (Lwt_utils_unix.Protocol.read_dir source_dir) with | Ok v -> v | Error err -> Format.kasprintf Pervasives.failwith "Failed to read TEZOS_PROTOCOL: %a" pp_print_error err in (* Generate the 'functor' *) - Packer.dump stdout + Packer.dump stdout hash (Array.map begin fun { Protocol.name ; _ } -> let name_lowercase = String.uncapitalize_ascii name in diff --git a/src/lib_protocol_compiler/packer.ml b/src/lib_protocol_compiler/packer.ml index 918b112de..ba270a8f9 100644 --- a/src/lib_protocol_compiler/packer.ml +++ b/src/lib_protocol_compiler/packer.ml @@ -46,12 +46,14 @@ let opened_modules = [ "Logging" ; ] -let dump oc files = +let dump oc hash files = Printf.fprintf oc "module Make (Tezos_protocol_environment : Tezos_protocol_environment_sigs__V1.T) = struct\n" ; Printf.fprintf oc "[@@@ocaml.warning \"-33\"]\n" ; List.iter (Printf.fprintf oc "open %s\n") opened_modules ; Printf.fprintf oc "[@@@ocaml.warning \"+33\"]\n" ; + Printf.fprintf oc "let hash = Protocol_hash.of_b58check_exn %S;;\n" + (Protocol_hash.to_b58check hash) ; for i = 0 to Array.length files - 1 do include_ml oc files.(i) ; done ; @@ -60,6 +62,3 @@ let dump oc files = (Filename.basename (Filename.chop_extension files.(Array.length files - 1)))) ; Printf.fprintf oc "end\n%!" - -let main () = - dump stdout (Array.sub Sys.argv 1 (Array.length Sys.argv - 2)) diff --git a/src/lib_protocol_compiler/packer.mli b/src/lib_protocol_compiler/packer.mli index a318cfe34..afa540e72 100644 --- a/src/lib_protocol_compiler/packer.mli +++ b/src/lib_protocol_compiler/packer.mli @@ -7,6 +7,4 @@ (* *) (**************************************************************************) -val dump: out_channel -> string array -> unit - -val main: unit -> unit +val dump: out_channel -> Protocol_hash.t -> string array -> unit diff --git a/src/proto_alpha/lib_client/proto_alpha.ml b/src/proto_alpha/lib_client/proto_alpha.ml index 0aa7b6686..443a02ab9 100644 --- a/src/proto_alpha/lib_client/proto_alpha.ml +++ b/src/proto_alpha/lib_client/proto_alpha.ml @@ -11,10 +11,6 @@ module Name = struct let name = "alpha" end module Alpha_environment = Tezos_protocol_environment_faked.MakeV1(Name)() include Tezos_protocol_alpha.Functor.Make(Alpha_environment) -let hash = - Protocol_hash.of_b58check_exn - "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" - class type rpc_context = object inherit RPC_context.json inherit [Block_services.block] Alpha_environment.RPC_context.simple