Baking: split daemons into 3 different binaries

This commit is contained in:
Vincent Botbol 2018-06-13 11:05:20 +02:00 committed by Grégoire Henry
parent efee9df1c7
commit 0512ff55ce
20 changed files with 354 additions and 61 deletions

2
.gitignore vendored
View File

@ -17,6 +17,8 @@ __pycache__
/tezos-client
/tezos-admin-client
/tezos-alpha-baker
/tezos-alpha-endorser
/tezos-alpha-accuser
/tezos-signer
/scripts/opam-test-all.sh.DONE

View File

@ -180,12 +180,12 @@ test:p2p:banned_peers:
# test:client_alpha:transaction:
# <<: *test_definition
# script:
# - jbuilder build @src/proto_alpha/lib_baking/runtest_transaction
# - jbuilder build @src/proto_alpha/lib_delegate/runtest_transaction
# test:client_alpha:origination:
# <<: *test_definition
# script:
# - jbuilder build @src/proto_alpha/lib_baking/runtest_origination
# - jbuilder build @src/proto_alpha/lib_delegate/runtest_origination
test:client_alpha:endorsement:
<<: *test_definition
@ -490,46 +490,71 @@ opam:49:tezos-shell:
variables:
package: tezos-shell
opam:50:tezos-client:
opam:50:tezos-endorser-alpha-commands:
<<: *opam_definition
variables:
package: tezos-endorser-alpha-commands
opam:51:tezos-client:
<<: *opam_definition
variables:
package: tezos-client
opam:51:ocplib-ezresto-directory:
opam:52:tezos-endorser-alpha:
<<: *opam_definition
variables:
package: tezos-endorser-alpha
opam:53:tezos-accuser-alpha-commands:
<<: *opam_definition
variables:
package: tezos-accuser-alpha-commands
opam:54:ocplib-ezresto-directory:
<<: *opam_definition
variables:
package: ocplib-ezresto-directory
opam:52:tezos-baker-alpha:
opam:55:tezos-accuser-alpha:
<<: *opam_definition
variables:
package: tezos-accuser-alpha
opam:56:tezos-baker-alpha:
<<: *opam_definition
variables:
package: tezos-baker-alpha
opam:53:tezos-protocol-demo:
opam:57:tezos-protocol-demo:
<<: *opam_definition
variables:
package: tezos-protocol-demo
opam:54:tezos-signer:
opam:58:tezos-signer:
<<: *opam_definition
variables:
package: tezos-signer
opam:55:ledgerwallet-tezos:
opam:59:ledgerwallet-tezos:
<<: *opam_definition
variables:
package: ledgerwallet-tezos
opam:56:tezos-node:
opam:60:tezos-node:
<<: *opam_definition
variables:
package: tezos-node
opam:57:ocplib-json-typed-browser:
opam:59:ocplib-json-typed-browser:
<<: *opam_definition
variables:
package: ocplib-json-typed-browser
opam:60:tezos-baker-alpha-commands:
<<: *opam_definition
variables:
package: tezos-baker-alpha-commands
##END_OPAM##

View File

@ -16,13 +16,17 @@ all:
src/bin_client/main_admin.exe \
src/bin_signer/main_signer.exe \
src/lib_protocol_compiler/main_native.exe \
src/proto_alpha/bin_baker/main_baker_alpha.exe
src/proto_alpha/bin_baker/main_baker_alpha.exe \
src/proto_alpha/bin_endorser/main_endorser_alpha.exe \
src/proto_alpha/bin_accuser/main_accuser_alpha.exe
@cp _build/default/src/bin_node/main.exe tezos-node
@cp _build/default/src/bin_client/main_client.exe tezos-client
@cp _build/default/src/bin_client/main_admin.exe tezos-admin-client
@cp _build/default/src/bin_signer/main_signer.exe tezos-signer
@cp _build/default/src/lib_protocol_compiler/main_native.exe tezos-protocol-compiler
@cp _build/default/src/proto_alpha/bin_baker/main_baker_alpha.exe tezos-alpha-baker
@cp _build/default/src/proto_alpha/bin_endorser/main_endorser_alpha.exe tezos-alpha-endorser
@cp _build/default/src/proto_alpha/bin_accuser/main_accuser_alpha.exe tezos-alpha-accuser
all.pkg:
@jbuilder build ${DEV} \
@ -78,7 +82,9 @@ clean:
tezos-client \
tezos-admin-client \
tezos-protocol-compiler \
tezos-alpha-baker
tezos-alpha-baker \
tezos-alpha-endorser \
tezos-alpha-accuser
@-${MAKE} -C docs clean
.PHONY: all test build-deps docker-image clean

View File

@ -318,6 +318,10 @@ The Final Executables
environment to interact with a sandboxed node.
- :package:`tezos-baker-alpha` provides the ``tezos-alpha-baker``
binary.
- :package:`tezos-endorser-alpha` provides the ``tezos-alpha-endorser``
binary.
- :package:`tezos-accuser-alpha` provides the ``tezos-alpha-accuser``
binary.
- :package:`tezos-protocol-compiler` provides the
``tezos-protocol-compiler`` binary that is used by the node to
compile new protocols on the fly, and that can be used for

View File

@ -48,4 +48,7 @@ _tezos-alphanet_complete()
# Register _pss_complete to provide completion for the following commands
complete -F _tezos-client_complete tezos-client
complete -F _tezos-client_complete tezos-admin-client
complete -F _tezos-client_complete tezos-alpha-baker
complete -F _tezos-client_complete tezos-alpha-endorser
complete -F _tezos-client_complete tezos-alpha-accuser
complete -F _tezos-alphanet_complete alphanet.sh

View File

@ -17,10 +17,16 @@ init_sandboxed_client() {
client="$local_client -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
admin_client="$local_admin_client -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_baker="$local_alpha_baker -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_endorser="$local_alpha_endorser -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_accuser="$local_alpha_accuser -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
signer="$local_signer -S -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
else
client="$local_client -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
admin_client="$local_admin_client -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_baker="$local_alpha_baker -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_endorser="$local_alpha_endorser -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
alpha_accuser="$local_alpha_accuser -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
signer="$local_signer -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
fi
parameters_file="${parameters_file:-$client_dir/protocol_parameters.json}"
@ -94,9 +100,9 @@ may_create_identity() {
## Baker ###################################################################
check_baker() {
pids=$(pgrep -x tezos-client 2>/dev/null)
pids=$(pgrep -x tezos-alpha-baker 2>/dev/null)
for pid in $pids; do
if grep -- "-baking" "/proc/$pid/cmdline" >/dev/null 2>&1 ; then
if grep -- "-max-priority" "/proc/$pid/cmdline" >/dev/null 2>&1 ; then
return 0
fi
done
@ -109,13 +115,13 @@ run_baker() {
exit 1
fi
echo "Start baker..."
exec $client launch daemon -baking -max-priority 64 "$@" > "$client_dir/baker.log"
exec $alpha_baker launch daemon -max-priority 64 "$@" > "$client_dir/baker.log"
}
stop_baker() {
pids=$(pgrep -x tezos-client 2>/dev/null)
pids=$(pgrep -x tezos-alpha-baker 2>/dev/null)
for pid in $pids; do
if grep -- "-baking" "/proc/$pid/cmdline" >/dev/null 2>&1 ; then
if grep -- "-max-priority" "/proc/$pid/cmdline" >/dev/null 2>&1 ; then
echo "Killing the baker..."
kill "$pid"
fi
@ -140,9 +146,9 @@ log_baker() {
## Endorser ################################################################
check_endorser() {
pids=$(pgrep -x tezos-client 2>/dev/null)
pids=$(pgrep -x tezos-alpha-endorser 2>/dev/null)
for pid in $pids; do
if grep -- "-endorsement" "/proc/$pid/cmdline" > /dev/null 2>&1 ; then
if grep -- "tezos-alpha-endorser" "/proc/$pid/cmdline" > /dev/null 2>&1 ; then
return 0
fi
done
@ -155,13 +161,13 @@ run_endorser() {
exit 1
fi
echo "Start endorser..."
exec $client launch daemon -endorsement "$@" > "$client_dir/endorser.log"
exec $alpha_endorser launch daemon"$@" > "$client_dir/endorser.log"
}
stop_endorser() {
pids=$(pgrep -x tezos-client 2>/dev/null)
pids=$(pgrep -x tezos-alpha-endorser 2>/dev/null)
for pid in $pids; do
if grep -- "-endorsement" "/proc/$pid/cmdline" > /dev/null 2>&1 ; then
if grep -- "tezos-alpha-endorser" "/proc/$pid/cmdline" > /dev/null 2>&1 ; then
kill "$pid"
fi
done
@ -247,12 +253,16 @@ main () {
local_admin_client="${local_admin_client:-$bin_dir/../../_build/default/src/bin_client/main_admin.exe}"
local_alpha_baker="${local_alpha_baker:-$bin_dir/../../_build/default/src/proto_alpha/bin_baker/main_baker_alpha.exe}"
local_signer="${local_signer:-$bin_dir/../../_build/default/src/bin_signer/main_signer.exe}"
local_alpha_endorser="${local_alpha_endorser:-$bin_dir/../../_build/default/src/proto_alpha/bin_endorser/main_endorser_alpha.exe}"
local_alpha_accuser="${local_alpha_accuser:-$bin_dir/../../_build/default/src/proto_alpha/bin_accuser/main_accuser_alpha.exe}"
parameters_file="${parameters_file:-$bin_dir/../../scripts/protocol_parameters.json}"
else
# we assume a clean install with tezos-(admin-)client in the path
local_client="${local_client:-$(which tezos-client)}"
local_admin_client="${local_admin_client:-$(which tezos-admin-client)}"
local_alpha_baker="${local_alpha_baker:-$(which tezos-alpha-baker)}"
local_alpha_endorser="${local_alpha_endorser:-$(which tezos-alpha-endorser)}"
local_alpha_accuser="${local_alpha_accuser:-$(which tezos-alpha-accuser)}"
local_signer="${local_signer:-$(which tezos-signer)}"
fi
@ -279,6 +289,14 @@ main () {
echo "exec $alpha_baker \"\$@\"" >> $client_dir/bin/tezos-alpha-baker
chmod +x $client_dir/bin/tezos-alpha-baker
echo '#!/bin/sh' > $client_dir/bin/tezos-alpha-endorser
echo "exec $alpha_endorser \"\$@\"" >> $client_dir/bin/tezos-alpha-endorser
chmod +x $client_dir/bin/tezos-alpha-endorser
echo '#!/bin/sh' > $client_dir/bin/tezos-alpha-accuser
echo "exec $alpha_accuser \"\$@\"" >> $client_dir/bin/tezos-alpha-accuser
chmod +x $client_dir/bin/tezos-alpha-accuser
echo '#!/bin/sh' > $client_dir/bin/tezos-signer
echo "exec $signer \"\$@\"" >> $client_dir/bin/tezos-signer
chmod +x $client_dir/bin/tezos-signer

View File

@ -0,0 +1,20 @@
(jbuild_version 1)
(executable
((name main_accuser_alpha)
(public_name tezos-accuser-alpha)
(libraries (tezos-client-base-unix
tezos-client-commands
tezos-baking-alpha-commands))
(flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Tezos_base__TzPervasives
-open Tezos_client_alpha
-open Tezos_client_commands
-open Tezos_baking_alpha_commands
-open Tezos_client_base_unix))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml{,i})))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))

View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let () =
Client_commands.register Proto_alpha.hash @@
List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@
Delegate_commands.accuser_commands ()
let select_commands _ _ =
return
(List.map
(Clic.map_command (new Proto_alpha.wrap_full))
(Delegate_commands.accuser_commands ()))
let () = Client_main_run.run select_commands

View File

@ -0,0 +1,23 @@
opam-version: "1.2"
version: "dev"
maintainer: "contact@tezos.com"
authors: [ "Tezos devteam" ]
homepage: "https://www.tezos.com/"
bug-reports: "https://gitlab.com/tezos/tezos/issues"
dev-repo: "https://gitlab.com/tezos/tezos.git"
license: "unreleased"
depends: [
"ocamlfind" { build }
"jbuilder" { build & = "1.0+beta20" }
"tezos-base"
"tezos-client-base"
"tezos-client-genesis"
"tezos-client-alpha"
"tezos-client-commands"
"tezos-client-base-unix"
"tezos-baking-alpha"
"tezos-baking-alpha-commands"
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]
]

View File

@ -4,11 +4,13 @@
((name main_baker_alpha)
(public_name tezos-baker-alpha)
(libraries (tezos-client-base-unix
tezos-client-commands
tezos-baking-alpha-commands))
(flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Tezos_base__TzPervasives
-open Tezos_client_alpha
-open Tezos_client_commands
-open Tezos_baking_alpha_commands
-open Tezos_client_base_unix))))

View File

@ -7,10 +7,15 @@
(* *)
(**************************************************************************)
let () =
Client_commands.register Proto_alpha.hash @@
List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@
Delegate_commands.delegate_commands ()
let select_commands _ _ =
return
(List.map
(Clic.map_command (new Proto_alpha.wrap_full))
(Delegate_commands.commands ()))
(Delegate_commands.baker_commands ()))
let () = Client_main_run.run select_commands

View File

@ -0,0 +1,20 @@
(jbuild_version 1)
(executable
((name main_endorser_alpha)
(public_name tezos-endorser-alpha)
(libraries (tezos-client-base-unix
tezos-client-commands
tezos-baking-alpha-commands))
(flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Tezos_base__TzPervasives
-open Tezos_client_alpha
-open Tezos_client_commands
-open Tezos_baking_alpha_commands
-open Tezos_client_base_unix))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml{,i})))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))

View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let () =
Client_commands.register Proto_alpha.hash @@
List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@
Delegate_commands.delegate_commands ()
let select_commands _ _ =
return
(List.map
(Clic.map_command (new Proto_alpha.wrap_full))
(Delegate_commands.endorser_commands ()))
let () = Client_main_run.run select_commands

View File

@ -0,0 +1,23 @@
opam-version: "1.2"
version: "dev"
maintainer: "contact@tezos.com"
authors: [ "Tezos devteam" ]
homepage: "https://www.tezos.com/"
bug-reports: "https://gitlab.com/tezos/tezos/issues"
dev-repo: "https://gitlab.com/tezos/tezos.git"
license: "unreleased"
depends: [
"ocamlfind" { build }
"jbuilder" { build & = "1.0+beta20" }
"tezos-base"
"tezos-client-base"
"tezos-client-genesis"
"tezos-client-alpha"
"tezos-client-commands"
"tezos-client-base-unix"
"tezos-baking-alpha"
"tezos-baking-alpha-commands"
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]
]

View File

@ -14,44 +14,9 @@ let group =
{ Clic.name = "delegate" ;
title = "Commands related to delegate operations." }
let commands () =
let delegate_commands () =
let open Clic in
[
command ~group ~desc: "Launch a daemon that handles delegate operations."
(args1 max_priority_arg)
(prefixes [ "launch" ; "baker" ]
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun max_priority delegates cctxt ->
Client_daemon.Baker.run cctxt
?max_priority
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
(List.map snd delegates)
) ;
command ~group ~desc: "Launch the accuser daemon"
no_options
(prefixes [ "launch" ; "accuser" ]
@@ stop)
(fun () cctxt -> Client_daemon.Accuser.run cctxt) ;
command ~group ~desc: "Launch the endorser daemon"
(args1 endorsement_delay_arg )
(prefixes [ "launch" ; "endorser" ]
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun endorsement_delay delegates cctxt ->
Client_daemon.Endorser.run cctxt
~delay:endorsement_delay
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
(List.map snd delegates)
) ;
command ~group ~desc: "Forge and inject an endorsement operation."
no_options
(prefixes [ "endorse"; "for" ]
@@ Client_keys.Public_key_hash.source_param
~name:"baker" ~desc: "name of the delegate owning the endorsement right"
@@ stop)
(fun () delegate cctxt -> endorse_block cctxt delegate) ;
command ~group ~desc: "Forge and inject block using the delegate rights."
(args3 max_priority_arg force_switch minimal_timestamp_switch)
(prefixes [ "bake"; "for" ]
@ -73,4 +38,63 @@ let commands () =
@@ stop)
(fun () cctxt ->
reveal_nonces cctxt ()) ;
command ~group ~desc: "Forge and inject an endorsement operation."
no_options
(prefixes [ "endorse"; "for" ]
@@ Client_keys.Public_key_hash.source_param
~name:"baker" ~desc: "name of the delegate owning the endorsement right"
@@ stop)
(fun () delegate cctxt -> endorse_block cctxt delegate) ;
]
let baker_commands () =
let open Clic in
let group =
{ Clic.name = "delegate.baker" ;
title = "Commands related to the baker daemon." }
in
[
command ~group ~desc: "Launch a daemon that handles delegate operations."
(args1 max_priority_arg)
(prefixes [ "launch" ]
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun max_priority delegates cctxt ->
Client_daemon.Baker.run cctxt
?max_priority
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
(List.map snd delegates)
)
]
let endorser_commands () =
let open Clic in
let group =
{ Clic.name = "delegate.endorser" ;
title = "Commands related to endorser daemon." }
in
[
command ~group ~desc: "Launch the endorser daemon"
(args1 endorsement_delay_arg )
(prefixes [ "launch" ]
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun endorsement_delay delegates cctxt ->
Client_daemon.Endorser.run cctxt
~delay:endorsement_delay
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
(List.map snd delegates)
)
]
let accuser_commands () =
let open Clic in
let group =
{ Clic.name = "delegate.accuser" ;
title = "Commands related to the accuser daemon." }
in
[
command ~group ~desc: "Launch the accuser daemon"
no_options
(prefixes [ "launch" ]
@@ stop)
(fun () cctxt -> Client_daemon.Accuser.run cctxt) ;
]

View File

@ -7,4 +7,8 @@
(* *)
(**************************************************************************)
val commands: unit -> Proto_alpha.full Clic.command list
val delegate_commands : unit -> Proto_alpha.full Clic.command list
val baker_commands : unit -> Proto_alpha.full Clic.command list
val endorser_commands : unit -> Proto_alpha.full Clic.command list
val accuser_commands : unit -> Proto_alpha.full Clic.command list

View File

@ -10,4 +10,4 @@
let () =
Client_commands.register Proto_alpha.hash @@
List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@
Delegate_commands.commands ()
Delegate_commands.delegate_commands ()

View File

@ -0,0 +1,24 @@
opam-version: "1.2"
version: "dev"
maintainer: "contact@tezos.com"
authors: [ "Tezos devteam" ]
homepage: "https://www.tezos.com/"
bug-reports: "https://gitlab.com/tezos/tezos/issues"
dev-repo: "https://gitlab.com/tezos/tezos.git"
license: "unreleased"
depends: [
"ocamlfind" { build }
"jbuilder" { build & = "1.0+beta20" }
"tezos-base"
"tezos-protocol-environment"
"tezos-protocol-alpha"
"tezos-shell-services"
"tezos-client-base"
"tezos-client-commands"
"tezos-client-alpha"
"tezos-baking-alpha"
"tezos-signer-backends" { test }
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]
]

View File

@ -0,0 +1,24 @@
opam-version: "1.2"
version: "dev"
maintainer: "contact@tezos.com"
authors: [ "Tezos devteam" ]
homepage: "https://www.tezos.com/"
bug-reports: "https://gitlab.com/tezos/tezos/issues"
dev-repo: "https://gitlab.com/tezos/tezos.git"
license: "unreleased"
depends: [
"ocamlfind" { build }
"jbuilder" { build & = "1.0+beta20" }
"tezos-base"
"tezos-protocol-environment"
"tezos-protocol-alpha"
"tezos-shell-services"
"tezos-client-base"
"tezos-client-commands"
"tezos-client-alpha"
"tezos-baking-alpha"
"tezos-signer-backends" { test }
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]
]

View File

@ -0,0 +1,24 @@
opam-version: "1.2"
version: "dev"
maintainer: "contact@tezos.com"
authors: [ "Tezos devteam" ]
homepage: "https://www.tezos.com/"
bug-reports: "https://gitlab.com/tezos/tezos/issues"
dev-repo: "https://gitlab.com/tezos/tezos.git"
license: "unreleased"
depends: [
"ocamlfind" { build }
"jbuilder" { build & = "1.0+beta20" }
"tezos-base"
"tezos-protocol-environment"
"tezos-protocol-alpha"
"tezos-shell-services"
"tezos-client-base"
"tezos-client-commands"
"tezos-client-alpha"
"tezos-baking-alpha"
"tezos-signer-backends" { test }
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]
]