From d74f80c5c5080cd78794cec53be59beed2b66094 Mon Sep 17 00:00:00 2001 From: Vivien Date: Sat, 10 Aug 2024 11:02:53 +0200 Subject: [PATCH] wip --- .gitignore | 1 + dune-project | 1 + manifest/product_octez.ml | 28 +++++++++++ opam/octez-starflour-baker.opam | 25 ++++++++++ script-inputs/experimental-executables | 1 + src/bin_starflour/dune | 26 ++++++++++ src/bin_starflour/main.ml | 67 ++++++++++++++++++++++++++ 7 files changed, 149 insertions(+) create mode 100644 opam/octez-starflour-baker.opam create mode 100644 src/bin_starflour/dune create mode 100644 src/bin_starflour/main.ml diff --git a/.gitignore b/.gitignore index f4d1ac83ecd4..2ac4b55c9ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ __pycache__ /octez-admin-client /tezos-baker-* /octez-baker-* +/octez-starflour-baker /tezos-endorser-* /octez-endorser-* /tezos-accuser-* diff --git a/dune-project b/dune-project index 57dc3a669710..63a7f1d05df9 100644 --- a/dune-project +++ b/dune-project @@ -82,6 +82,7 @@ (package (name octez-smart-rollup-wasm-debugger-lib)) (package (name octez-smart-rollup-wasm-debugger-plugin)) (package (name octez-snoop)) +(package (name octez-starflour-baker)) (package (name octez-store-tests)(allow_empty)) (package (name octez-testnet-scenarios)) (package (name octez-version)) diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index c2d09e1c22d7..fa54782761e7 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -6981,6 +6981,34 @@ let hash = Protocol.hash List.map get_targets_for_protocol all |> List.flatten |> List.map optional end +let _octez_starflour_baker = + let protocol_deps = + List.map + (fun proto -> + match Protocol.baking_commands_registration proto with + | None -> + failwith + ("protocol " ^ Protocol.name_dash proto + ^ " has no baking commands") + | Some deps -> deps) + Protocol.active + in + public_exe + "octez-starflour-baker" + ~path:"src/bin_starflour" + ~internal_name:"main" + ~release_status:Experimental + ~synopsis:"Tezos protocol agnostic baker" + ~deps: + ([ + octez_base |> open_ ~m:"TzPervasives"; + octez_stdlib_unix |> open_; + octez_protocol_environment; + octez_client_base |> open_; + octez_client_base_unix |> open_; + ] + @ protocol_deps) + (* TESTS THAT USE PROTOCOLS *) let _octez_micheline_rewriting_tests = diff --git a/opam/octez-starflour-baker.opam b/opam/octez-starflour-baker.opam new file mode 100644 index 000000000000..a7e91ace3173 --- /dev/null +++ b/opam/octez-starflour-baker.opam @@ -0,0 +1,25 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.11.1" } + "ocaml" { >= "4.14" } + "octez-libs" { = version } + "octez-proto-libs" { = version } + "octez-shell-libs" { = version } + "octez-protocol-020-PsParisC-libs" { = version } + "octez-protocol-beta-libs" { = version } + "octez-protocol-alpha-libs" { = version } +] +build: [ + ["rm" "-r" "vendors" "contrib"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Tezos protocol agnostic baker" diff --git a/script-inputs/experimental-executables b/script-inputs/experimental-executables index 4afc86093061..5b8f398d20a1 100644 --- a/script-inputs/experimental-executables +++ b/script-inputs/experimental-executables @@ -1,3 +1,4 @@ +octez-starflour-baker octez-accuser-alpha octez-baker-alpha octez-accuser-beta diff --git a/src/bin_starflour/dune b/src/bin_starflour/dune new file mode 100644 index 000000000000..197c13dc74a8 --- /dev/null +++ b/src/bin_starflour/dune @@ -0,0 +1,26 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(executable + (name main) + (public_name octez-starflour-baker) + (package octez-starflour-baker) + (instrumentation (backend bisect_ppx)) + (libraries + octez-libs.base + octez-libs.stdlib-unix + octez-proto-libs.protocol-environment + octez-shell-libs.client-base + octez-shell-libs.client-base-unix + octez-protocol-020-PsParisC-libs.baking-commands.registration + octez-protocol-beta-libs.baking-commands.registration + octez-protocol-alpha-libs.baking-commands.registration) + (link_flags + (:standard) + (:include %{workspace_root}/static-link-flags.sexp)) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_stdlib_unix + -open Tezos_client_base + -open Tezos_client_base_unix)) diff --git a/src/bin_starflour/main.ml b/src/bin_starflour/main.ml new file mode 100644 index 000000000000..f7fe0b6b6480 --- /dev/null +++ b/src/bin_starflour/main.ml @@ -0,0 +1,67 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* SPDX-FileCopyrightText: TODO[year(s)] [Holder ] *) +(* *) +(*****************************************************************************) + +type error += No_argument + +let () = + register_error_kind + `Temporary + ~id:"Starflour.no_argument" + ~title:"No arqument" + ~description:"There is no argument passed to the executable." + ~pp:(fun fmt () -> + Format.fprintf fmt "There is no argument passed to the executable") + Data_encoding.empty + (function No_argument -> Some () | _ -> None) + (fun () -> No_argument) + +let run _cctxt = + let open Lwt_result_syntax in + let*? args = + let open Result_syntax in + let* args = + match Array.to_list Sys.argv with + | [] -> tzfail No_argument + | _ :: t -> return t + in + return (String.concat " " args) + in + Format.eprintf "./octez-baker-alpha %s@." args ; + let _ = Sys.command ("./octez-baker-alpha " ^ args) in + return_unit + +module Config = struct + include Daemon_config + + let default_daily_logs_path = Some "octez-starflourbaker" +end + +let commands () = + let open Tezos_clic in + let group = + { + Tezos_clic.name = "delegate.baker"; + title = "Commands related to the baker daemon."; + } + in + [ + command + ~group + ~desc:"Launch the baker daemon." + Tezos_clic.no_options + (prefixes ["run"; "with"; "local"; "node"] @@ stop) + (fun () cctxt -> run cctxt); + ] + +let select_commands _ _ = + let open Lwt_result_syntax in + return + (List.map + (Tezos_clic.map_command (new Client_context.proxy_context)) + (commands ())) + +let () = Client_main_run.run (module Config) ~select_commands -- GitLab