From ac105dba411dfaa4da5d2cfdd6ae868a2d9fbb2f Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Mon, 7 Apr 2025 13:59:10 +0200 Subject: [PATCH 1/5] Packages/Debian: copy octez-baker* to octez-agnostic-baker* The packages are most likely the same, we start by copy-pasting the files so the differences are easier to review in the next commit. --- .../octez/debian/octez-agnostic-baker.config | 89 +++++++++++++++ .../octez/debian/octez-agnostic-baker.default | 7 ++ .../octez/debian/octez-agnostic-baker.install | 4 + .../octez-agnostic-baker.lintian-overrides | 2 + .../debian/octez-agnostic-baker.logrotate | 44 ++++++++ .../debian/octez-agnostic-baker.manpages | 2 + ...octez-agnostic-baker.octez-accuser.default | 2 + ...ctez-agnostic-baker.octez-accuser@.service | 21 ++++ .../debian/octez-agnostic-baker.postinst | 104 ++++++++++++++++++ .../octez/debian/octez-agnostic-baker.postrm | 38 +++++++ .../octez/debian/octez-agnostic-baker.preinst | 77 +++++++++++++ .../octez/debian/octez-agnostic-baker.prerm | 16 +++ .../octez/debian/octez-agnostic-baker.service | 22 ++++ .../debian/octez-agnostic-baker.templates | 41 +++++++ .../octez/docs/README.octez-agnostic-baker | 48 ++++++++ .../octez/manpages/octez-agnostic-baker.1 | 29 +++++ .../scripts/systemd-octez-agnostic-baker.sh | 34 ++++++ 17 files changed, 580 insertions(+) create mode 100755 scripts/packaging/octez/debian/octez-agnostic-baker.config create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.default create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.install create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.logrotate create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.manpages create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser.default create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser@.service create mode 100755 scripts/packaging/octez/debian/octez-agnostic-baker.postinst create mode 100755 scripts/packaging/octez/debian/octez-agnostic-baker.postrm create mode 100755 scripts/packaging/octez/debian/octez-agnostic-baker.preinst create mode 100755 scripts/packaging/octez/debian/octez-agnostic-baker.prerm create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.service create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.templates create mode 100644 scripts/packaging/octez/docs/README.octez-agnostic-baker create mode 100644 scripts/packaging/octez/manpages/octez-agnostic-baker.1 create mode 100755 scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.config b/scripts/packaging/octez/debian/octez-agnostic-baker.config new file mode 100755 index 000000000000..6b7d8a8d91b5 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.config @@ -0,0 +1,89 @@ +#!/bin/sh + +set -e + +echoerr() { echo "$@" 1>&2; } + +new=${2:-} + +# shellcheck disable=SC1091 +. /usr/share/debconf/confmodule +db_version 2.0 + +case "$new" in +"") + # fresh install + : nop + ;; +1:*) + echoerr "Upgrade from $new" + if [ -e /etc/default/octez-baker ]; then + #shellcheck disable=SC1091 + . /etc/default/octez-baker + db_set octez-baker/liquidity-vote "$LQVOTE" + db_set octez-baker/baker-key "$BAKER_KEY" + fi + ;; +*) + if [ -e /etc/octez/baker.conf ]; then + echoerr "Legacy upgrade from $new" + echoerr "Updating baker configuration from old /etc/octez/baker.conf" + # the values set here in debconf are going to be used in the + # postinst script to write the /etc/default/ files for this + # package + #shellcheck disable=SC1091 + . /etc/octez/baker.conf + + if [ -n "${lq_vote:-}" ]; then + echoerr "set lq_vote=$lq_vote" + #shellcheck disable=SC2154 + db_set octez-baker/liquidity-vote "$lq_vote" + fi + + if [ -n "${baking_key:-}" ]; then + echoerr "set baking_key=$baking_key" + #shellcheck disable=SC2154 + db_set octez-baker/baker-key "$baking_key" + fi + + if [ -n "${dalurl:-}" ]; then + echoerr "set dalurl=$dalurl" + if [ "$dalurl" = "" ]; then + #shellcheck disable=SC2154 + db_set octez-baker/dal-node false + else + db_set octez-baker/dal-node true + db_set octez-baker/dal-node-url "$dalurl" + fi + else + db_set octez-baker/dal-node true + fi + + #shellcheck disable=SC2119 + db_go + fi + ;; +esac + +db_input high octez-baker/liquidity-vote || true +# shellcheck disable=SC2119 +db_go || true + +db_input medium octez-baker/baker-key || true +# shellcheck disable=SC2119 +db_go || true + +db_input medium octez-baker/dal-node || true +# shellcheck disable=SC2119 +db_go || true + +db_get octez-baker/dal-node +if [ "$RET" = "true" ]; then + db_get octez-baker/dal-node-url + if [ -z "$RET" ]; then + db_set octez-baker/dal-node-url "http://127.0.0.1:10732" + fi + db_input low octez-baker/dal-node-url || true + # shellcheck disable=SC2119 + db_go || true +fi diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.default b/scripts/packaging/octez/debian/octez-agnostic-baker.default new file mode 100644 index 000000000000..1d5ddc13c9c9 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.default @@ -0,0 +1,7 @@ + +# Data Directory +# we use the datadir defined in /etc/default/octez-node + +# Other options +# Keep the daemon process alive +RUNTIME_OPTS="--keep-alive --dal-node http://127.0.0.1:10732" diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.install b/scripts/packaging/octez/debian/octez-agnostic-baker.install new file mode 100644 index 000000000000..ee247f4b8105 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.install @@ -0,0 +1,4 @@ +binaries/octez-baker-P* /usr/bin/ +binaries/octez-accuser-P* /usr/bin/ +scripts/wait-for-node-up.sh /usr/share/octez-baker/ +scripts/systemd-octez-bakers.sh /usr/share/octez-baker/ diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides new file mode 100644 index 000000000000..c556086abac6 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides @@ -0,0 +1,2 @@ +octez-baker: initial-upload-closes-no-bugs +octez-baker: malformed-question-in-templates diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate b/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate new file mode 100644 index 000000000000..ff95809e7497 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate @@ -0,0 +1,44 @@ +/var/log/tezos/baker-next.log{ + daily + # we use copytruncate to avoid stopping node. + copytruncate + rotate 5 + compress + minsize 1M +} + +/var/log/tezos/baker-active.log{ + daily + # we use copytruncate to avoid stopping node. + copytruncate + rotate 5 + compress + minsize 1M +} + +/var/log/tezos/accuser.log{ + daily + # we use copytruncate to avoid stopping node. + copytruncate + rotate 5 + compress + minsize 1M +} + +/var/log/tezos/accuser-next.log{ + daily + # we use copytruncate to avoid stopping node. + copytruncate + rotate 5 + compress + minsize 1M +} + +/var/log/tezos/accuser-active.log{ + daily + # we use copytruncate to avoid stopping node. + copytruncate + rotate 5 + compress + minsize 1M +} diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.manpages b/scripts/packaging/octez/debian/octez-agnostic-baker.manpages new file mode 100644 index 000000000000..24ddd9f55431 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.manpages @@ -0,0 +1,2 @@ +manpages/octez-baker.1 +manpages/octez-accuser.1 diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser.default b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser.default new file mode 100644 index 000000000000..ca9dff757782 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser.default @@ -0,0 +1,2 @@ +# Keep the daemon process alive: when the connection with the node is lost +RUNTIME_OPTS="--keep-alive" diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser@.service b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser@.service new file mode 100644 index 000000000000..53bde9abe77a --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-accuser@.service @@ -0,0 +1,21 @@ +[Unit] +Description=Octez accuser for protocol %i +Documentation=https://octez.tezos.com/docs/ +After=network.target + +[Service] +EnvironmentFile=-/etc/default/octez-baker +EnvironmentFile=-/etc/default/octez-accuser +WorkingDirectory=~ +Restart=on-failure +User=tezos +ExecStart=/bin/sh -c "/usr/bin/octez-accuser-%i run $RUNTIME_OPTS" + +ExecStartPre=+touch /var/log/tezos/accuser-%i.log +ExecStartPre=+chown tezos:tezos /var/log/tezos/accuser-%i.log + +StandardOutput=append:/var/log/tezos/accuser-%i.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.postinst b/scripts/packaging/octez/debian/octez-agnostic-baker.postinst new file mode 100755 index 000000000000..19d2317a4275 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.postinst @@ -0,0 +1,104 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +. /usr/share/debconf/confmodule + +echoerr() { echo "$@" 1>&2; } + +db_version 2.0 + +# work directory to store temporary files associated to this package +mkdir -p /run/octez-baker + +for file in /usr/bin/octez-baker-*; do + file=$(basename "$file") + suffix=$(echo "$file" | sed 's/^octez-baker-//') + if [ -z "$PROTO_CHOICES" ]; then + PROTO_CHOICES="$suffix" + else + PROTO_CHOICES="$PROTO_CHOICES $suffix" + fi +done + +case "${1}" in +configure) + # if $2 is empty, then we're doing a fresh install. + # if $DPKG_RUNNING_VERSION" is empty a reconfigure + # Otherwise we're upgrading + if [ -z "${2:-}" ] || [ -z "$DPKG_RUNNING_VERSION" ]; then + echoerr "Fresh installation (or reconfigure) of the Octez baker" + + db_get octez-baker/liquidity-vote + echo "LQVOTE=${RET}" > /etc/default/octez-baker + + db_get octez-baker/baker-key + echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker + + db_get octez-baker/dal-node + DAL=${RET} + case "$DAL" in + true) + db_get octez-baker/dal-node-url + DALURL=${RET} + echo "RUNTIME_OPTS=\"--keep-alive --dal-node $DALURL\"" >> /etc/default/octez-baker + ;; + false) + echo "RUNTIME_OPTS=--keep-alive --without-dal" >> /etc/default/octez-baker + ;; + esac + + mkdir -p /var/tezos/.tezos-client + chown tezos:tezos /var/tezos/.tezos-client + else + echoerr "Upgrading octez-baker from version $2 ( postinst )" + # the configure script is called with the version of the old + # package in case of upgrade. We display a message to the user + # in this case. See octez-node.postinst for a detailed explanation. + case "$2" in + 1:*) + : noop + ;; + *) + echoerr "Setting defaults in /etc/default/octez-baker-*" + echoerr "Migrating values when possible" + + db_get octez-baker/liquidity-vote + echo "LQVOTE=${RET}" >> /etc/default/octez-baker + echoerr "LQVOTE=${RET}" + + db_get octez-baker/baker-key + echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker + echoerr "BAKER_KEY=${RET}" + + db_get octez-baker/dal-node + DAL=${RET} + case "$DAL" in + true) + db_get octez-baker/dal-node-url + DALURL=${RET} + echo "RUNTIME_OPTS=\" --keep-alive --dal-node $DALURL\"" >> /etc/default/octez-baker + echoerr "RUNTIME_OPTS=--keep-alive --dal-node $DALURL" + ;; + false) + echo "RUNTIME_OPTS=--keep-alive --without-dal" >> /etc/default/octez-baker + echoerr "RUNTIME_OPTS=--keep-alive --without-dal" + ;; + esac + + db_input high octez-baker/upgrade_note_current || true + #shellcheck disable=SC2119 + db_go || true + ;; + esac + fi + ;; +*) + : nop + ;; +esac + +systemctl daemon-reload || true + +#DEBHELPER# diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.postrm b/scripts/packaging/octez/debian/octez-agnostic-baker.postrm new file mode 100755 index 000000000000..bfa58de28e6d --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.postrm @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +# Load debconf library +# shellcheck disable=SC1091 +. /usr/share/debconf/confmodule + +# systemctl should not be called directly. use this +# wrapper script if available +debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) + +case "${1}" in +remove) + rm -Rf /run/octez-baker + ;; +purge) + rm -Rf /run/octez-baker + # Purge debconf data for the package in any case + # shellcheck disable=SC2119 + db_purge || true + echo "Octez baker purged" + ;; +upgrade) + echo "Restarting Octez baker daemon: octez-baker" + $debsystemctl "start octez-baker.service" + ;; +failed-upgrade | abort-install | abort-upgrade | disappear) ;; +*) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# Clean up the temporary file +rm -f /run/octez-baker/*daemon_was_running + +#DEBHELPER# diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.preinst b/scripts/packaging/octez/debian/octez-agnostic-baker.preinst new file mode 100755 index 000000000000..0f5f7d667aaf --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.preinst @@ -0,0 +1,77 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +. /usr/share/debconf/confmodule + +db_version 2.0 + +# work directory to store temporary files associated to this package +mkdir -p /run/octez-baker + +case "${1}" in +install | upgrade) + # if $2 is empty, then we're doing a fresh install. + # Ohtwerwise we're upgrading + if [ -n "$2" ]; then + # the configure script is called with the version of the old + # package in case of upgrade. We display a message to the user + # in this case + echo "Upgrading Octez baker from version $2 ( preinst )" + case "$2" in + 1:*) + if [ -e /etc/default/octez-baker ]; then + #shellcheck disable=SC1091 + . /etc/default/octez-baker + db_set octez-baker/liquidity-vote "$LQVOTE" + db_set octez-baker/baker-key "$BAKER_KEY" + fi + ;; + *) + if [ -e /etc/octez/baker.conf ]; then + echo "Updating baker configuration from old /etc/octez/baker.conf" + # the values set here in debconf are going to be used in the + # postinst script to write the /etc/default/ files for this + # package + #shellcheck disable=SC1091 + . /etc/octez/baker.conf + + if [ -n "${lq_vote:-}" ]; then + echo "set lq_vote=$lq_vote" + #shellcheck disable=SC2154 + db_set octez-baker/liquidity-vote "$lq_vote" + fi + + if [ -n "${baking_key:-}" ]; then + echo "set baking_key=$baking_key" + #shellcheck disable=SC2154 + db_set octez-baker/baker-key "$baking_key" + fi + + if [ -n "${dalurl:-}" ]; then + echo "set dalurl=$dalurl" + if [ "$dalurl" = "" ]; then + #shellcheck disable=SC2154 + db_set octez-baker/dal-node false + else + db_set octez-baker/dal-node true + db_set octez-baker/dal-node-url "$dalurl" + fi + else + db_set octez-baker/dal-node true + fi + + #shellcheck disable=SC2119 + db_go + fi + ;; + esac + fi + ;; +*) + echo "preinst noop" + ;; +esac + +#DEBHELPER# diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.prerm b/scripts/packaging/octez/debian/octez-agnostic-baker.prerm new file mode 100755 index 000000000000..80e3be5dfc07 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.prerm @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +. /usr/share/debconf/confmodule + +# systemctl should not be called directly. use this +# wrapper script if available +debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) + +# Check if the old daemon is active before stopping it +if systemctl is-active --quiet "octez-baker.service"; then + echo "Stopping old octez-baker" + $debsystemctl stop "octez-baker.service" +fi diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.service b/scripts/packaging/octez/debian/octez-agnostic-baker.service new file mode 100644 index 000000000000..6562dd0263d6 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.service @@ -0,0 +1,22 @@ +[Unit] +Description=Octez baker service +After=network.target + +[Service] +Type=oneshot +RemainAfterExit=yes +Restart=on-failure +TimeoutStartSec=300 +TimeoutStopSec=300 + +EnvironmentFile=-/etc/default/octez-node +EnvironmentFile=-/etc/default/octez-baker + +# The baker is started only if the node is up and running +ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh + +ExecStart=/usr/share/octez-baker/systemd-octez-bakers.sh start +ExecStop=/usr/share/octez-baker/systemd-octez-bakers.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.templates b/scripts/packaging/octez/debian/octez-agnostic-baker.templates new file mode 100644 index 000000000000..0cbd464f5e5f --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.templates @@ -0,0 +1,41 @@ +Template: octez-baker/liquidity-vote +Description: Your choice for the liquidity vote: + Vote to continue or end the liquidity baking subsidy. The possible values for + this option are: "off" to request ending the subsidy, "on" to request + continuing or restarting the subsidy, and "pass" to abstain. + . + This option is mandatory to start the baker. +Type: select +Choices: off, on, pass + +Template: octez-baker/baker-key +Description: The baker key to associate to this baker: + Name of the delegate to attest and bake for or the name of the consensus key + signing on the delegate's behalf. The key is required to run the baker, but it + can also be added later while configuring the baker. +Type: string + +Template: octez-baker/dal-node +Type: boolean +Default: true +Description: Connect to the Octez DAL node ? + By default, the octez-dal-node package is installed alongside the octez-baker + package to participate to the DAL network. + . + Possible options: "--dal-node http://127.0.0.1:10732" or "--without-dal". + +Template: octez-baker/dal-node-url +Type: string +Default: http://127.0.0.1:10732 +Description: Specify the url of the RPC server of the Octez DAL node: + By default the octez-dal-node package is installed along side the octez-baker. + +Template: octez-baker/upgrade_note_current +Type: note +Description: Important upgrade information + This package has been upgraded to a new version. Please note that some changes + have been made that may affect your usage of the package. The configuration + of the package has been updated. If you did any customizations, please check + the configuration of the octez-baker + . + Please review the release notes for more information. diff --git a/scripts/packaging/octez/docs/README.octez-agnostic-baker b/scripts/packaging/octez/docs/README.octez-agnostic-baker new file mode 100644 index 000000000000..6bd26c059ae8 --- /dev/null +++ b/scripts/packaging/octez/docs/README.octez-agnostic-baker @@ -0,0 +1,48 @@ +# Octez Baker + +The octez baker should be configured to run along side a remote signer. + +This package provides systemd services for both the baker and the accuser +and for the active and next protocol. For example, you can start the +baker using + +``` +$ sudo systemctl start octez-baker +``` + +All services are enabled but not started by default. It's up to the user +to configure them. + +## Usage with a remote signer + +The remote signer can be located either on the same machine, or better +on a separate machine and connected to a ledger. + +This package does not make any assumption on how the final user will +configure its baker. We provide as an example some steps a user should +take to configure its baker service to communicate with a remote signer. + +We assume, for the sake of brevity, that the signer is configured to +answer on a local http connection running on localhost and will use +authentication. + +For example, assuming the octez-signer is already setup: +``` +$ octez-signer show address alice +Hash: tz1V7TgBR52wAjjqsh24w8y9CymFGdegt9qs +Public Key: edpkvGAz71r8SZomcvF7LGajXT3AnhYX9CrmK3JWgA2xk8rf8CudY8 + +# Tell the baker about this signer +$ sudo su tezos -c "octez-client -R tcp://localhost:7732 config update" + +# add the remote key to the baker +$ sudo su tezos -c "octez-client -R tcp://localhost:7732 import secret key alice remote:tz1V7TgBR52wAjjqsh24w8y9CymFGdegt9qs" + +# Check that everything is ok +# you should see the the operation in the logs of the signer +# journalctl --user-unit octez-signer +$ sudo su tezos -c "octez-client sign bytes 0x03 for alice" + +# Register your baking account +$ sudo su tezos -c "octez-client register key alice as delegate" +``` diff --git a/scripts/packaging/octez/manpages/octez-agnostic-baker.1 b/scripts/packaging/octez/manpages/octez-agnostic-baker.1 new file mode 100644 index 000000000000..c5bfc961967a --- /dev/null +++ b/scripts/packaging/octez/manpages/octez-agnostic-baker.1 @@ -0,0 +1,29 @@ +.TH OCTEZ-BAKER 1 "January 2024" "Octez Baker Manual" + +.SH NAME +octez-baker \- Octez Baker Daemon + +.SH SYNOPSIS +.B octez-baker +[\fIOPTION\fR]... \fI\fR [\fIARGS\fR]... + +.SH DESCRIPTION +.B octez-baker +includes the necessary tools and functionalities for participating in the +baking process, such as block creation, attestations, and protocol-specific +consensus mechanisms. + +.SH OPTIONS +.TP +.B \-h, \-\-help +Display help information. + +.TP +.B \-\-version +Display version information. + +.SH SEE ALSO +Online Octez Documentation: https://tezos.gitlab.io/shell/cli-commands.html + +.SH BUGS +Report bugs to: https://gitlab.com/tezos/tezos/-/issues diff --git a/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh b/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh new file mode 100755 index 000000000000..ee5e7d10b6a7 --- /dev/null +++ b/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# + +# Check if the argument is valid (start or stop) +if [ "$1" != "start" ] && [ "$1" != "stop" ]; then + echo "Usage: $0 {start|stop}" + exit 1 +fi + +# Loop through each file matching the pattern +# NB: we avoid selecting `-alpha` or `-next` bakers +for file in /usr/bin/octez-baker-P*; do + file=$(basename "$file") + proto=$(echo "$file" | sed 's/^octez-baker-//') + + # Enable or start/stop the systemd service based on the argument + if [ "$1" = "start" ]; then + if grep -q "\-\-dal-node" /etc/default/octez-baker; then + systemctl enable octez-dal-node + systemctl start octez-dal-node + fi + systemctl enable "octez-baker@$proto" + systemctl enable "octez-accuser@$proto" + systemctl start "octez-baker@$proto" + systemctl start "octez-accuser@$proto" + + elif [ "$1" = "stop" ]; then + systemctl stop "octez-baker@$proto" + systemctl stop "octez-accuser@$proto" + if grep -q "\-\-dal-node" /etc/default/octez-baker; then + systemctl stop octez-dal-node + fi + fi +done -- GitLab From dd85eda10efb76711ed2b90a147dff1ef6368c16 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Mon, 7 Apr 2025 14:12:40 +0200 Subject: [PATCH 2/5] Packages/Debian: agnostic baker package use agnostic baker --- scripts/packaging/octez/debian/control | 22 ++++++++++++ .../octez/debian/octez-agnostic-baker.config | 36 +++++++++---------- .../octez/debian/octez-agnostic-baker.install | 6 ++-- .../octez-agnostic-baker.lintian-overrides | 4 +-- .../debian/octez-agnostic-baker.logrotate | 11 +----- .../debian/octez-agnostic-baker.manpages | 2 +- ...tic-baker.octez-agnostic-baker-bin.service | 26 ++++++++++++++ .../debian/octez-agnostic-baker.postinst | 36 +++++++------------ .../octez/debian/octez-agnostic-baker.postrm | 12 +++---- .../octez/debian/octez-agnostic-baker.preinst | 26 +++++++------- .../octez/debian/octez-agnostic-baker.prerm | 6 ++-- .../octez/debian/octez-agnostic-baker.service | 6 ++-- .../debian/octez-agnostic-baker.templates | 16 ++++----- scripts/packaging/octez/debian/rules | 9 +++++ .../octez/docs/README.octez-agnostic-baker | 6 ++-- .../octez/manpages/octez-agnostic-baker.1 | 8 ++--- .../scripts/systemd-octez-agnostic-baker.sh | 11 +++--- 17 files changed, 141 insertions(+), 102 deletions(-) create mode 100644 scripts/packaging/octez/debian/octez-agnostic-baker.octez-agnostic-baker-bin.service diff --git a/scripts/packaging/octez/debian/control b/scripts/packaging/octez/debian/control index 87c4a37961d2..b743da2a7928 100644 --- a/scripts/packaging/octez/debian/control +++ b/scripts/packaging/octez/debian/control @@ -68,6 +68,28 @@ Description: Octez baking software for the Tezos blockchain. octez-dal-node to be installed as well. For key management it is recommended to install a remote signer on a different host. +Package: octez-agnostic-baker +Architecture: amd64 arm64 +Pre-Depends: + octez-client (= ${source:Version}), + debconf (>= 0.5) | debconf-2.0 +Depends: + ${misc:Depends}, ${shlibs:Depends}, + octez-node (= ${source:Version}), + curl, systemd +Recommends: + octez-signer (= ${source:Version}), + octez-dal-node (= ${source:Version}) +Description: Octez baking software for the Tezos blockchain. + The Octez baker includes the necessary tools and functionalities for + participating in the baking process, such as block creation, attestations, and + protocol-specific consensus mechanisms. + . + This package installs the baker, the accuser and the Octez node. By default, + installing this package causes the recommended packages octez-signer and + octez-dal-node to be installed as well. For key management it is recommended + to install a remote signer on a different host. + Package: octez-signer Architecture: amd64 arm64 Depends: ${misc:Depends}, ${shlibs:Depends}, octez-client (= ${source:Version}), diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.config b/scripts/packaging/octez/debian/octez-agnostic-baker.config index 6b7d8a8d91b5..87acf5ee5ccd 100755 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.config +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.config @@ -20,43 +20,43 @@ case "$new" in if [ -e /etc/default/octez-baker ]; then #shellcheck disable=SC1091 . /etc/default/octez-baker - db_set octez-baker/liquidity-vote "$LQVOTE" - db_set octez-baker/baker-key "$BAKER_KEY" + db_set octez-agnostic-baker/liquidity-vote "$LQVOTE" + db_set octez-agnostic-baker/baker-key "$BAKER_KEY" fi ;; *) - if [ -e /etc/octez/baker.conf ]; then + if [ -e /etc/octez/agnostic-baker.conf ]; then echoerr "Legacy upgrade from $new" - echoerr "Updating baker configuration from old /etc/octez/baker.conf" + echoerr "Updating baker configuration from old /etc/octez/agnostic-baker.conf" # the values set here in debconf are going to be used in the # postinst script to write the /etc/default/ files for this # package #shellcheck disable=SC1091 - . /etc/octez/baker.conf + . /etc/octez/agnostic-baker.conf if [ -n "${lq_vote:-}" ]; then echoerr "set lq_vote=$lq_vote" #shellcheck disable=SC2154 - db_set octez-baker/liquidity-vote "$lq_vote" + db_set octez-agnostic-baker/liquidity-vote "$lq_vote" fi if [ -n "${baking_key:-}" ]; then echoerr "set baking_key=$baking_key" #shellcheck disable=SC2154 - db_set octez-baker/baker-key "$baking_key" + db_set octez-agnostic-baker/baker-key "$baking_key" fi if [ -n "${dalurl:-}" ]; then echoerr "set dalurl=$dalurl" if [ "$dalurl" = "" ]; then #shellcheck disable=SC2154 - db_set octez-baker/dal-node false + db_set octez-agnostic-baker/dal-node false else - db_set octez-baker/dal-node true - db_set octez-baker/dal-node-url "$dalurl" + db_set octez-agnostic-baker/dal-node true + db_set octez-agnostic-baker/dal-node-url "$dalurl" fi else - db_set octez-baker/dal-node true + db_set octez-agnostic-baker/dal-node true fi #shellcheck disable=SC2119 @@ -65,25 +65,25 @@ case "$new" in ;; esac -db_input high octez-baker/liquidity-vote || true +db_input high octez-agnostic-baker/liquidity-vote || true # shellcheck disable=SC2119 db_go || true -db_input medium octez-baker/baker-key || true +db_input medium octez-agnostic-baker/baker-key || true # shellcheck disable=SC2119 db_go || true -db_input medium octez-baker/dal-node || true +db_input medium octez-agnostic-baker/dal-node || true # shellcheck disable=SC2119 db_go || true -db_get octez-baker/dal-node +db_get octez-agnostic-baker/dal-node if [ "$RET" = "true" ]; then - db_get octez-baker/dal-node-url + db_get octez-agnostic-baker/dal-node-url if [ -z "$RET" ]; then - db_set octez-baker/dal-node-url "http://127.0.0.1:10732" + db_set octez-agnostic-baker/dal-node-url "http://127.0.0.1:10732" fi - db_input low octez-baker/dal-node-url || true + db_input low octez-agnostic-baker/dal-node-url || true # shellcheck disable=SC2119 db_go || true fi diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.install b/scripts/packaging/octez/debian/octez-agnostic-baker.install index ee247f4b8105..2746bc188ed7 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.install +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.install @@ -1,4 +1,4 @@ -binaries/octez-baker-P* /usr/bin/ +binaries/octez-agnostic-baker /usr/bin/ binaries/octez-accuser-P* /usr/bin/ -scripts/wait-for-node-up.sh /usr/share/octez-baker/ -scripts/systemd-octez-bakers.sh /usr/share/octez-baker/ +scripts/wait-for-node-up.sh /usr/share/octez-agnostic-baker/ +scripts/systemd-octez-agnostic-baker.sh /usr/share/octez-agnostic-baker/ diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides index c556086abac6..168075b7ddba 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides @@ -1,2 +1,2 @@ -octez-baker: initial-upload-closes-no-bugs -octez-baker: malformed-question-in-templates +octez-agnostic-baker: initial-upload-closes-no-bugs +octez-agnostic-baker: malformed-question-in-templates diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate b/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate index ff95809e7497..ff3f5fae73de 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.logrotate @@ -1,13 +1,4 @@ -/var/log/tezos/baker-next.log{ - daily - # we use copytruncate to avoid stopping node. - copytruncate - rotate 5 - compress - minsize 1M -} - -/var/log/tezos/baker-active.log{ +/var/log/tezos/agnostic-baker.log{ daily # we use copytruncate to avoid stopping node. copytruncate diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.manpages b/scripts/packaging/octez/debian/octez-agnostic-baker.manpages index 24ddd9f55431..3f2d556c7342 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.manpages +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.manpages @@ -1,2 +1,2 @@ -manpages/octez-baker.1 +manpages/octez-agnostic-baker.1 manpages/octez-accuser.1 diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.octez-agnostic-baker-bin.service b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-agnostic-baker-bin.service new file mode 100644 index 000000000000..3f1fd1165d3a --- /dev/null +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.octez-agnostic-baker-bin.service @@ -0,0 +1,26 @@ +[Unit] +Description=Octez agnostic baker service +Documentation=https://octez.tezos.com/docs/ +After=network.target + +[Service] +Type=simple +Restart=on-failure +TimeoutStartSec=infinity +TimeoutStopSec=300 + +EnvironmentFile=-/etc/default/octez-node +EnvironmentFile=-/etc/default/octez-baker +WorkingDirectory=~ +User=tezos + +ExecStartPre=+touch /var/log/tezos/agnostic-baker.log +ExecStartPre=+chown tezos:tezos /var/log/tezos/agnostic-baker.log + +ExecStart=/bin/sh -c "/usr/bin/octez-agnostic-baker --base-dir $HOME/.tezos-client run with local node $DATADIR --liquidity-baking-toggle-vote $LQVOTE $RUNTIME_OPTS $BAKING_KEY" + +StandardOutput=append:/var/log/tezos/agnostic-baker.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.postinst b/scripts/packaging/octez/debian/octez-agnostic-baker.postinst index 19d2317a4275..8e5e8796ca61 100755 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.postinst +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.postinst @@ -10,17 +10,7 @@ echoerr() { echo "$@" 1>&2; } db_version 2.0 # work directory to store temporary files associated to this package -mkdir -p /run/octez-baker - -for file in /usr/bin/octez-baker-*; do - file=$(basename "$file") - suffix=$(echo "$file" | sed 's/^octez-baker-//') - if [ -z "$PROTO_CHOICES" ]; then - PROTO_CHOICES="$suffix" - else - PROTO_CHOICES="$PROTO_CHOICES $suffix" - fi -done +mkdir -p /run/octez-agnostic-baker case "${1}" in configure) @@ -28,19 +18,19 @@ configure) # if $DPKG_RUNNING_VERSION" is empty a reconfigure # Otherwise we're upgrading if [ -z "${2:-}" ] || [ -z "$DPKG_RUNNING_VERSION" ]; then - echoerr "Fresh installation (or reconfigure) of the Octez baker" + echoerr "Fresh installation (or reconfigure) of the Octez agnostic baker" - db_get octez-baker/liquidity-vote + db_get octez-agnostic-baker/liquidity-vote echo "LQVOTE=${RET}" > /etc/default/octez-baker - db_get octez-baker/baker-key + db_get octez-agnostic-baker/baker-key echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker - db_get octez-baker/dal-node + db_get octez-agnostic-baker/dal-node DAL=${RET} case "$DAL" in true) - db_get octez-baker/dal-node-url + db_get octez-agnostic-baker/dal-node-url DALURL=${RET} echo "RUNTIME_OPTS=\"--keep-alive --dal-node $DALURL\"" >> /etc/default/octez-baker ;; @@ -52,7 +42,7 @@ configure) mkdir -p /var/tezos/.tezos-client chown tezos:tezos /var/tezos/.tezos-client else - echoerr "Upgrading octez-baker from version $2 ( postinst )" + echoerr "Upgrading octez-agnostic-baker from version $2 ( postinst )" # the configure script is called with the version of the old # package in case of upgrade. We display a message to the user # in this case. See octez-node.postinst for a detailed explanation. @@ -61,22 +51,22 @@ configure) : noop ;; *) - echoerr "Setting defaults in /etc/default/octez-baker-*" + echoerr "Setting defaults in /etc/default/octez-baker" echoerr "Migrating values when possible" - db_get octez-baker/liquidity-vote + db_get octez-agnostic-baker/liquidity-vote echo "LQVOTE=${RET}" >> /etc/default/octez-baker echoerr "LQVOTE=${RET}" - db_get octez-baker/baker-key + db_get octez-agnostic-baker/baker-key echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker echoerr "BAKER_KEY=${RET}" - db_get octez-baker/dal-node + db_get octez-agnostic-baker/dal-node DAL=${RET} case "$DAL" in true) - db_get octez-baker/dal-node-url + db_get octez-agnostic-baker/dal-node-url DALURL=${RET} echo "RUNTIME_OPTS=\" --keep-alive --dal-node $DALURL\"" >> /etc/default/octez-baker echoerr "RUNTIME_OPTS=--keep-alive --dal-node $DALURL" @@ -87,7 +77,7 @@ configure) ;; esac - db_input high octez-baker/upgrade_note_current || true + db_input high octez-agnostic-baker/upgrade_note_current || true #shellcheck disable=SC2119 db_go || true ;; diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.postrm b/scripts/packaging/octez/debian/octez-agnostic-baker.postrm index bfa58de28e6d..08c87c94ca10 100755 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.postrm +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.postrm @@ -12,18 +12,18 @@ debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) case "${1}" in remove) - rm -Rf /run/octez-baker + rm -Rf /run/octez-agnostic-baker ;; purge) - rm -Rf /run/octez-baker + rm -Rf /run/octez-agnostic-baker # Purge debconf data for the package in any case # shellcheck disable=SC2119 db_purge || true - echo "Octez baker purged" + echo "Octez agnostic baker purged" ;; upgrade) - echo "Restarting Octez baker daemon: octez-baker" - $debsystemctl "start octez-baker.service" + echo "Restarting Octez agnostic baker daemon: octez-agnostic-baker" + $debsystemctl "start octez-agnostic-baker.service" ;; failed-upgrade | abort-install | abort-upgrade | disappear) ;; *) @@ -33,6 +33,6 @@ failed-upgrade | abort-install | abort-upgrade | disappear) ;; esac # Clean up the temporary file -rm -f /run/octez-baker/*daemon_was_running +rm -f /run/octez-agnostic-baker/*daemon_was_running #DEBHELPER# diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.preinst b/scripts/packaging/octez/debian/octez-agnostic-baker.preinst index 0f5f7d667aaf..0449ad9d7b75 100755 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.preinst +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.preinst @@ -8,7 +8,7 @@ set -e db_version 2.0 # work directory to store temporary files associated to this package -mkdir -p /run/octez-baker +mkdir -p /run/octez-agnostic-baker case "${1}" in install | upgrade) @@ -18,48 +18,48 @@ install | upgrade) # the configure script is called with the version of the old # package in case of upgrade. We display a message to the user # in this case - echo "Upgrading Octez baker from version $2 ( preinst )" + echo "Upgrading Octez agnostic baker from version $2 ( preinst )" case "$2" in 1:*) if [ -e /etc/default/octez-baker ]; then #shellcheck disable=SC1091 . /etc/default/octez-baker - db_set octez-baker/liquidity-vote "$LQVOTE" - db_set octez-baker/baker-key "$BAKER_KEY" + db_set octez-agnostic-baker/liquidity-vote "$LQVOTE" + db_set octez-agnostic-baker/baker-key "$BAKER_KEY" fi ;; *) - if [ -e /etc/octez/baker.conf ]; then - echo "Updating baker configuration from old /etc/octez/baker.conf" + if [ -e /etc/octez/agnostic-baker.conf ]; then + echo "Updating baker configuration from old /etc/octez/agnostic-baker.conf" # the values set here in debconf are going to be used in the # postinst script to write the /etc/default/ files for this # package #shellcheck disable=SC1091 - . /etc/octez/baker.conf + . /etc/octez/agnostic-baker.conf if [ -n "${lq_vote:-}" ]; then echo "set lq_vote=$lq_vote" #shellcheck disable=SC2154 - db_set octez-baker/liquidity-vote "$lq_vote" + db_set octez-agnostic-baker/liquidity-vote "$lq_vote" fi if [ -n "${baking_key:-}" ]; then echo "set baking_key=$baking_key" #shellcheck disable=SC2154 - db_set octez-baker/baker-key "$baking_key" + db_set octez-agnostic-baker/baker-key "$baking_key" fi if [ -n "${dalurl:-}" ]; then echo "set dalurl=$dalurl" if [ "$dalurl" = "" ]; then #shellcheck disable=SC2154 - db_set octez-baker/dal-node false + db_set octez-agnostic-baker/dal-node false else - db_set octez-baker/dal-node true - db_set octez-baker/dal-node-url "$dalurl" + db_set octez-agnostic-baker/dal-node true + db_set octez-agnostic-baker/dal-node-url "$dalurl" fi else - db_set octez-baker/dal-node true + db_set octez-agnostic-baker/dal-node true fi #shellcheck disable=SC2119 diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.prerm b/scripts/packaging/octez/debian/octez-agnostic-baker.prerm index 80e3be5dfc07..e71b77c6bde3 100755 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.prerm +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.prerm @@ -10,7 +10,7 @@ set -e debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) # Check if the old daemon is active before stopping it -if systemctl is-active --quiet "octez-baker.service"; then - echo "Stopping old octez-baker" - $debsystemctl stop "octez-baker.service" +if systemctl is-active --quiet "octez-agnostic-baker.service"; then + echo "Stopping old octez-agnostic-baker" + $debsystemctl stop "octez-agnostic-baker.service" fi diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.service b/scripts/packaging/octez/debian/octez-agnostic-baker.service index 6562dd0263d6..4e8cd41a2d64 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.service +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.service @@ -13,10 +13,10 @@ EnvironmentFile=-/etc/default/octez-node EnvironmentFile=-/etc/default/octez-baker # The baker is started only if the node is up and running -ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh +ExecStartPre=/usr/share/octez-agnostic-baker/wait-for-node-up.sh -ExecStart=/usr/share/octez-baker/systemd-octez-bakers.sh start -ExecStop=/usr/share/octez-baker/systemd-octez-bakers.sh stop +ExecStart=/usr/share/octez-agnostic-baker/systemd-octez-agnostic-baker.sh start +ExecStop=/usr/share/octez-agnostic-baker/systemd-octez-agnostic-baker.sh stop [Install] WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.templates b/scripts/packaging/octez/debian/octez-agnostic-baker.templates index 0cbd464f5e5f..630d70d81a7a 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.templates +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.templates @@ -1,4 +1,4 @@ -Template: octez-baker/liquidity-vote +Template: octez-agnostic-baker/liquidity-vote Description: Your choice for the liquidity vote: Vote to continue or end the liquidity baking subsidy. The possible values for this option are: "off" to request ending the subsidy, "on" to request @@ -8,34 +8,34 @@ Description: Your choice for the liquidity vote: Type: select Choices: off, on, pass -Template: octez-baker/baker-key +Template: octez-agnostic-baker/baker-key Description: The baker key to associate to this baker: Name of the delegate to attest and bake for or the name of the consensus key signing on the delegate's behalf. The key is required to run the baker, but it can also be added later while configuring the baker. Type: string -Template: octez-baker/dal-node +Template: octez-agnostic-baker/dal-node Type: boolean Default: true Description: Connect to the Octez DAL node ? - By default, the octez-dal-node package is installed alongside the octez-baker + By default, the octez-dal-node package is installed alongside the octez-agnostic-baker package to participate to the DAL network. . Possible options: "--dal-node http://127.0.0.1:10732" or "--without-dal". -Template: octez-baker/dal-node-url +Template: octez-agnostic-baker/dal-node-url Type: string Default: http://127.0.0.1:10732 Description: Specify the url of the RPC server of the Octez DAL node: - By default the octez-dal-node package is installed along side the octez-baker. + By default the octez-dal-node package is installed along side the octez-agnostic-baker. -Template: octez-baker/upgrade_note_current +Template: octez-agnostic-baker/upgrade_note_current Type: note Description: Important upgrade information This package has been upgraded to a new version. Please note that some changes have been made that may affect your usage of the package. The configuration of the package has been updated. If you did any customizations, please check - the configuration of the octez-baker + the configuration of the octez-agnostic-baker . Please review the release notes for more information. diff --git a/scripts/packaging/octez/debian/rules b/scripts/packaging/octez/debian/rules index ec275fd93cfd..0241714319ba 100755 --- a/scripts/packaging/octez/debian/rules +++ b/scripts/packaging/octez/debian/rules @@ -21,12 +21,15 @@ override_dh_installman: do \ ln -s debian/octez-baker/usr/share/man/man1/octez-accuser.1.gz \ debian/octez-baker/usr/share/man/man1/$$bin.1.gz ; \ + ln -s debian/octez-agnostic-baker/usr/share/man/man1/octez-accuser.1.gz \ + debian/octez-agnostic-baker/usr/share/man/man1/$$bin.1.gz ; \ done override_dh_installdocs: dh_installdocs dh_installdocs -p octez-node docs/README.octez-node dh_installdocs -p octez-baker docs/README.octez-baker + dh_installdocs -p octez-agnostic-baker docs/README.octez-agnostic-baker dh_installdocs -p octez-signer docs/octez-signer.service dh_installdocs -p octez-signer docs/README.octez-signer @@ -36,15 +39,21 @@ override_dh_installsystemd: dh_installsystemd -p octez-smart-rollup-node --no-start dh_installsystemd -p octez-baker --no-start dh_installsystemd -p octez-baker --no-enable --no-start --name octez-accuser@ + dh_installsystemd -p octez-agnostic-baker --no-start + dh_installsystemd -p octez-agnostic-baker --no-enable --no-start --name octez-accuser@ + dh_installsystemd -p octez-agnostic-baker --no-enable --no-start --name octez-agnostic-baker-bin override_dh_installlogrotate: dh_installlogrotate --package=octez-node dh_installlogrotate --package=octez-baker + dh_installlogrotate --package=octez-agnostic-baker override_dh_install: dh_install mkdir -p debian/octez-baker/etc/default/ cp debian/octez-baker.octez-accuser.default debian/octez-baker/etc/default/octez-accuser + mkdir -p debian/octez-agnostic-baker/etc/default/ + cp debian/octez-agnostic-baker.octez-accuser.default debian/octez-agnostic-baker/etc/default/octez-accuser dh_installdebconf override_dh_fixperms: diff --git a/scripts/packaging/octez/docs/README.octez-agnostic-baker b/scripts/packaging/octez/docs/README.octez-agnostic-baker index 6bd26c059ae8..79f246a70b20 100644 --- a/scripts/packaging/octez/docs/README.octez-agnostic-baker +++ b/scripts/packaging/octez/docs/README.octez-agnostic-baker @@ -1,13 +1,13 @@ -# Octez Baker +# Octez Agnostic Baker -The octez baker should be configured to run along side a remote signer. +The octez agnostic baker should be configured to run along side a remote signer. This package provides systemd services for both the baker and the accuser and for the active and next protocol. For example, you can start the baker using ``` -$ sudo systemctl start octez-baker +$ sudo systemctl start octez-agnostic-baker ``` All services are enabled but not started by default. It's up to the user diff --git a/scripts/packaging/octez/manpages/octez-agnostic-baker.1 b/scripts/packaging/octez/manpages/octez-agnostic-baker.1 index c5bfc961967a..cd5597596f25 100644 --- a/scripts/packaging/octez/manpages/octez-agnostic-baker.1 +++ b/scripts/packaging/octez/manpages/octez-agnostic-baker.1 @@ -1,14 +1,14 @@ -.TH OCTEZ-BAKER 1 "January 2024" "Octez Baker Manual" +.TH OCTEZ-AGNOSTIC-BAKER 1 "January 2024" "Octez Agnostic Baker Manual" .SH NAME -octez-baker \- Octez Baker Daemon +octez-agnostic-baker \- Octez Baker Daemon .SH SYNOPSIS -.B octez-baker +.B octez-agnostic-baker [\fIOPTION\fR]... \fI\fR [\fIARGS\fR]... .SH DESCRIPTION -.B octez-baker +.B octez-agnostic-baker includes the necessary tools and functionalities for participating in the baking process, such as block creation, attestations, and protocol-specific consensus mechanisms. diff --git a/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh b/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh index ee5e7d10b6a7..9656c12e1ad1 100755 --- a/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh +++ b/scripts/packaging/octez/scripts/systemd-octez-agnostic-baker.sh @@ -9,9 +9,9 @@ fi # Loop through each file matching the pattern # NB: we avoid selecting `-alpha` or `-next` bakers -for file in /usr/bin/octez-baker-P*; do +for file in /usr/bin/octez-accuser-P*; do file=$(basename "$file") - proto=$(echo "$file" | sed 's/^octez-baker-//') + proto=$(echo "$file" | sed 's/^octez-accuser-//') # Enable or start/stop the systemd service based on the argument if [ "$1" = "start" ]; then @@ -19,16 +19,17 @@ for file in /usr/bin/octez-baker-P*; do systemctl enable octez-dal-node systemctl start octez-dal-node fi - systemctl enable "octez-baker@$proto" + systemctl enable "octez-agnostic-baker-bin" + systemctl start "octez-agnostic-baker-bin" systemctl enable "octez-accuser@$proto" - systemctl start "octez-baker@$proto" systemctl start "octez-accuser@$proto" elif [ "$1" = "stop" ]; then - systemctl stop "octez-baker@$proto" systemctl stop "octez-accuser@$proto" if grep -q "\-\-dal-node" /etc/default/octez-baker; then systemctl stop octez-dal-node fi fi done + +echo "systemd-octez-agnostic-baker.sh done" -- GitLab From ee4741da5300660cd8aa3beae77ae70600e9fe99 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Wed, 9 Apr 2025 10:49:10 +0200 Subject: [PATCH 3/5] Packages/Debian: remove malformed-question-in-templates --- .../octez/debian/octez-agnostic-baker.lintian-overrides | 1 - scripts/packaging/octez/debian/octez-agnostic-baker.templates | 2 +- scripts/packaging/octez/debian/octez-baker.lintian-overrides | 1 - scripts/packaging/octez/debian/octez-baker.templates | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides index 168075b7ddba..07cf7978d2f6 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.lintian-overrides @@ -1,2 +1 @@ octez-agnostic-baker: initial-upload-closes-no-bugs -octez-agnostic-baker: malformed-question-in-templates diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.templates b/scripts/packaging/octez/debian/octez-agnostic-baker.templates index 630d70d81a7a..79558692cb5f 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.templates +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.templates @@ -18,7 +18,7 @@ Type: string Template: octez-agnostic-baker/dal-node Type: boolean Default: true -Description: Connect to the Octez DAL node ? +Description: Connect to the Octez DAL node? By default, the octez-dal-node package is installed alongside the octez-agnostic-baker package to participate to the DAL network. . diff --git a/scripts/packaging/octez/debian/octez-baker.lintian-overrides b/scripts/packaging/octez/debian/octez-baker.lintian-overrides index c556086abac6..b6af5634c937 100644 --- a/scripts/packaging/octez/debian/octez-baker.lintian-overrides +++ b/scripts/packaging/octez/debian/octez-baker.lintian-overrides @@ -1,2 +1 @@ octez-baker: initial-upload-closes-no-bugs -octez-baker: malformed-question-in-templates diff --git a/scripts/packaging/octez/debian/octez-baker.templates b/scripts/packaging/octez/debian/octez-baker.templates index 0cbd464f5e5f..23f57c2dbf96 100644 --- a/scripts/packaging/octez/debian/octez-baker.templates +++ b/scripts/packaging/octez/debian/octez-baker.templates @@ -18,7 +18,7 @@ Type: string Template: octez-baker/dal-node Type: boolean Default: true -Description: Connect to the Octez DAL node ? +Description: Connect to the Octez DAL node? By default, the octez-dal-node package is installed alongside the octez-baker package to participate to the DAL network. . -- GitLab From 4cc5994832f0f98aab9cc3facfd16f85ef1ddab7 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Wed, 9 Apr 2025 11:02:13 +0200 Subject: [PATCH 4/5] Packages/Debian: typo suggested by coderabbit --- scripts/packaging/octez/debian/octez-agnostic-baker.templates | 2 +- scripts/packaging/octez/debian/octez-baker.preinst | 2 +- scripts/packaging/octez/debian/octez-baker.templates | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/packaging/octez/debian/octez-agnostic-baker.templates b/scripts/packaging/octez/debian/octez-agnostic-baker.templates index 79558692cb5f..b15d336fae27 100644 --- a/scripts/packaging/octez/debian/octez-agnostic-baker.templates +++ b/scripts/packaging/octez/debian/octez-agnostic-baker.templates @@ -28,7 +28,7 @@ Template: octez-agnostic-baker/dal-node-url Type: string Default: http://127.0.0.1:10732 Description: Specify the url of the RPC server of the Octez DAL node: - By default the octez-dal-node package is installed along side the octez-agnostic-baker. + By default the octez-dal-node package is installed alongside the octez-agnostic-baker. Template: octez-agnostic-baker/upgrade_note_current Type: note diff --git a/scripts/packaging/octez/debian/octez-baker.preinst b/scripts/packaging/octez/debian/octez-baker.preinst index 0f5f7d667aaf..adb81b1e927a 100755 --- a/scripts/packaging/octez/debian/octez-baker.preinst +++ b/scripts/packaging/octez/debian/octez-baker.preinst @@ -13,7 +13,7 @@ mkdir -p /run/octez-baker case "${1}" in install | upgrade) # if $2 is empty, then we're doing a fresh install. - # Ohtwerwise we're upgrading + # Otherwise we're upgrading if [ -n "$2" ]; then # the configure script is called with the version of the old # package in case of upgrade. We display a message to the user diff --git a/scripts/packaging/octez/debian/octez-baker.templates b/scripts/packaging/octez/debian/octez-baker.templates index 23f57c2dbf96..06dbcc8e0d7b 100644 --- a/scripts/packaging/octez/debian/octez-baker.templates +++ b/scripts/packaging/octez/debian/octez-baker.templates @@ -28,7 +28,7 @@ Template: octez-baker/dal-node-url Type: string Default: http://127.0.0.1:10732 Description: Specify the url of the RPC server of the Octez DAL node: - By default the octez-dal-node package is installed along side the octez-baker. + By default the octez-dal-node package is installed alongside the octez-baker. Template: octez-baker/upgrade_note_current Type: note -- GitLab From 99549e70f2beac8bd3e693accafbb3da689ca13d Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Wed, 9 Apr 2025 11:28:24 +0200 Subject: [PATCH 5/5] Packages/Debian: modify test to support agnostic baker --- .../ci/pipelines/debian_repository_full.yml | 33 +++++++++++++++++ .../pipelines/debian_repository_partial.yml | 33 +++++++++++++++++ .../debian_repository_partial_auto.yml | 33 +++++++++++++++++ ci/bin/debian_repository.ml | 24 +++++++++++++ .../packaging/tests/deb/install-bin-deb.sh | 28 +++++++++++++-- .../packaging/tests/systemd-docker-test.sh | 10 +++++- .../tests/tests-systemd-common.inc.sh | 35 ++++++++++++++----- 7 files changed, 184 insertions(+), 12 deletions(-) diff --git a/.gitlab/ci/pipelines/debian_repository_full.yml b/.gitlab/ci/pipelines/debian_repository_full.yml index a21909683c26..b954c92d6e60 100644 --- a/.gitlab/ci/pipelines/debian_repository_full.yml +++ b/.gitlab/ci/pipelines/debian_repository_full.yml @@ -699,6 +699,39 @@ oc.install_bin_debian_bookworm_systemd_custom_datadir: - stuck_or_timeout_failure - runner_system_failure +oc.install_bin_debian_bookworm_systemd_agnostic_baker: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + allow_failure: true + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + AGNOSTIC_BAKER: "true" + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/.gitlab/ci/pipelines/debian_repository_partial.yml b/.gitlab/ci/pipelines/debian_repository_partial.yml index 97a09c2ac08e..b6a9ec24ea73 100644 --- a/.gitlab/ci/pipelines/debian_repository_partial.yml +++ b/.gitlab/ci/pipelines/debian_repository_partial.yml @@ -423,6 +423,39 @@ oc.install_bin_debian_bookworm_systemd_custom_datadir: - stuck_or_timeout_failure - runner_system_failure +oc.install_bin_debian_bookworm_systemd_agnostic_baker: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + allow_failure: true + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + AGNOSTIC_BAKER: "true" + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/.gitlab/ci/pipelines/debian_repository_partial_auto.yml b/.gitlab/ci/pipelines/debian_repository_partial_auto.yml index 97a09c2ac08e..b6a9ec24ea73 100644 --- a/.gitlab/ci/pipelines/debian_repository_partial_auto.yml +++ b/.gitlab/ci/pipelines/debian_repository_partial_auto.yml @@ -423,6 +423,39 @@ oc.install_bin_debian_bookworm_systemd_custom_datadir: - stuck_or_timeout_failure - runner_system_failure +oc.install_bin_debian_bookworm_systemd_agnostic_baker: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + allow_failure: true + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + AGNOSTIC_BAKER: "true" + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/ci/bin/debian_repository.ml b/ci/bin/debian_repository.ml index ec8f44558f28..cdf571c92a51 100644 --- a/ci/bin/debian_repository.ml +++ b/ci/bin/debian_repository.ml @@ -556,6 +556,30 @@ let jobs pipeline_type = scripts/packaging/tests/deb/install-bin-deb.sh \ images/packages/debian-systemd-tests.Dockerfile"; ]; + job_install_systemd_bin + ~__POS__ + ~name:"oc.install_bin_debian_bookworm_systemd_agnostic_baker" + ~allow_failure:Yes + ~dependencies: + (Dependent + [ + Job job_docker_systemd_test_debian_dependencies; + Job job_apt_repo_debian; + ]) + ~variables: + (variables + ~kind:"systemd-tests" + [ + ("PREFIX", ""); + ("DISTRIBUTION", "debian"); + ("RELEASE", "bookworm"); + ("AGNOSTIC_BAKER", "true"); + ]) + [ + "./scripts/ci/systemd-packages-test.sh \ + scripts/packaging/tests/deb/install-bin-deb.sh \ + images/packages/debian-systemd-tests.Dockerfile"; + ]; job_install_systemd_bin ~__POS__ ~name:"oc.upgrade_bin_debian_bookworm-systemd" diff --git a/scripts/packaging/tests/deb/install-bin-deb.sh b/scripts/packaging/tests/deb/install-bin-deb.sh index 901537ee51dc..7c1438c49461 100755 --- a/scripts/packaging/tests/deb/install-bin-deb.sh +++ b/scripts/packaging/tests/deb/install-bin-deb.sh @@ -6,7 +6,26 @@ set -x REPO="https://storage.googleapis.com/${GCP_LINUX_PACKAGES_BUCKET:-tezos-linux-repo}/$CI_COMMIT_REF_NAME" DISTRO=$1 RELEASE=$2 -DATADIR=${3:-} + +shift 2 +DATADIR= +AGNOSTIC_BAKER= +while [ $# -gt 0 ]; do + case "$1" in + --data-dir) + DATADIR="$2" + shift 2 + ;; + --agnostic-baker) + AGNOSTIC_BAKER="$2" + shift 2 + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac +done # include apt-get function with retry . scripts/packaging/tests/tests-common.inc.sh @@ -37,6 +56,7 @@ octez-node octez-node/purge_warning boolean true octez-node octez-node/snapshot-import boolean true octez-node octez-node/snapshot-no-check boolean true octez-baker octez-baker/liquidity-vote select on +octez-agnostic-baker octez-baker/liquidity-vote select on debconf debconf/frontend select Noninteractive EOF # preseed the package @@ -46,7 +66,11 @@ EOF sudo debconf-get-selections | grep octez fi -apt-get install -y octez-baker +if [ "${AGNOSTIC_BAKER:-}" = "true" ]; then + apt-get install -y octez-agnostic-baker +else + apt-get install -y octez-baker +fi if [ -n "$DATADIR" ]; then echo "Setup Custom data dir" diff --git a/scripts/packaging/tests/systemd-docker-test.sh b/scripts/packaging/tests/systemd-docker-test.sh index 1746858d1fda..8a33ce287af6 100755 --- a/scripts/packaging/tests/systemd-docker-test.sh +++ b/scripts/packaging/tests/systemd-docker-test.sh @@ -50,6 +50,14 @@ while ! docker inspect -f '{{.State.Running}}' systemd 2> /dev/null | grep -q tr elapsed=$((elapsed + 1)) done +ARGS="" +if [ -n "${DATADIR:-}" ]; then + ARGS="$ARGS --data-dir $DATADIR" +fi +if [ -n "${AGNOSTIC_BAKER:-}" ]; then + ARGS="$ARGS --agnostic-baker $AGNOSTIC_BAKER" +fi + # Execute the command inside the container docker exec \ -e "PREFIX=$PREFIX" \ @@ -62,7 +70,7 @@ docker exec \ -e "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA" \ -e "GCP_LINUX_PACKAGES_BUCKET=$GCP_LINUX_PACKAGES_BUCKET" \ -i systemd \ - /bin/sh -c "$TESTFILE $DISTRIBUTION $RELEASE ${DATADIR:-}" + /bin/sh -c "$TESTFILE $DISTRIBUTION $RELEASE $ARGS" # Capture exit status EXIT=$? diff --git a/scripts/packaging/tests/tests-systemd-common.inc.sh b/scripts/packaging/tests/tests-systemd-common.inc.sh index 76dff7855d36..d70de7a0b00f 100644 --- a/scripts/packaging/tests/tests-systemd-common.inc.sh +++ b/scripts/packaging/tests/tests-systemd-common.inc.sh @@ -6,13 +6,21 @@ systemctl start octez-node.service # give some time to the node to create the identity # otherwise the octez-client call below will give an error -/usr/share/octez-baker/wait-for-node-up.sh +if [ "${AGNOSTIC_BAKER:-}" = "true" ]; then + /usr/share/octez-agnostic-baker/wait-for-node-up.sh +else + /usr/share/octez-baker/wait-for-node-up.sh +fi su tezos -c "octez-client gen keys alice" key=$(su tezos -c "octez-client show address alice" | grep Hash: | awk '{ print $2 }') echo "BAKER_KEY=$key" >> /etc/default/octez-baker -systemctl start octez-baker.service +if [ "${AGNOSTIC_BAKER:-}" = "true" ]; then + systemctl start octez-agnostic-baker.service +else + systemctl start octez-baker.service +fi su tezos -c "octez-node config show" @@ -27,15 +35,24 @@ echo "Log: /var/log/tezos/node.log" echo "-----------------------" tail /var/log/tezos/node.log -systemctl status octez-baker.service +if [ "${AGNOSTIC_BAKER:-}" = "true" ]; then + systemctl status octez-agnostic-baker.service + systemctl status octez-agnostic-baker-bin.service -for logfile in /var/log/tezos/baker-P*.log; do - proto=$(basename "$logfile" | sed -E 's/baker-(P[^.]+).log/\1/') - systemctl status "octez-baker@$proto.service" - echo "Log: $logfile" + echo "Log: /var/log/tezos/agnostic-baker.log" echo "-----------------------" - tail "$logfile" -done + tail /var/log/tezos/agnostic-baker.log +else + systemctl status octez-baker.service + + for logfile in /var/log/tezos/baker-P*.log; do + proto=$(basename "$logfile" | sed -E 's/baker-(P[^.]+).log/\1/') + systemctl status "octez-baker@$proto.service" + echo "Log: $logfile" + echo "-----------------------" + tail "$logfile" + done +fi for logfile in /var/log/tezos/accuser-P*.log; do proto=$(basename "$logfile" | sed -E 's/accuser-(P[^.]+).log/\1/') -- GitLab