Skip to content

Commit

Permalink
[#453] Package for fedora and ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
krendelhoff2 committed Aug 15, 2022
1 parent f93bb7b commit 73ca37e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docker/package/defaults/tezos-rollup-node.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# vim: ft=sh
# SPDX-FileCopyrightText: 2022 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

# shellcheck disable=SC2034
DATA_DIR="/var/lib/tezos/.tezos-client"
NODE_RPC_ENDPOINT="http://localhost:8732"
ROLLUP_NODE_RPC_ENDPOINT="127.0.0.1:8472"
MODE="observer"
ROLLUP_ALIAS="rollup"
63 changes: 60 additions & 3 deletions docker/package/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def mk_node_unit(
daemon_postinst_common = (
postinst_steps_common
+ "\nmkdir -p /var/lib/tezos/.tezos-client\nchown -R tezos:tezos /var/lib/tezos/.tezos-client\n"
)
) + ledger_udev_postinst


for proto in active_protocols:
Expand Down Expand Up @@ -388,7 +388,7 @@ def mk_node_unit(
),
],
target_proto=proto,
postinst_steps=daemon_postinst_common + ledger_udev_postinst,
postinst_steps=daemon_postinst_common,
additional_native_deps=[
"tezos-sapling-params",
"tezos-client",
Expand Down Expand Up @@ -421,7 +421,7 @@ def mk_node_unit(
],
target_proto=proto,
additional_native_deps=["udev"],
postinst_steps=daemon_postinst_common + ledger_udev_postinst,
postinst_steps=daemon_postinst_common,
dune_filepath=f"src/proto_{proto_snake_case}/bin_accuser/main_accuser_{proto_snake_case}.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
Expand All @@ -439,3 +439,60 @@ def mk_node_unit(
meta=packages_meta,
)
)


def mk_rollup_packages():

def mk_units(type, proto):
startup_script = "/usr/bin/tezos-rollup-node-start"
service_file = ServiceFile(
Unit(after=["network.target"], description=f"Tezos {type} rollup node"),
Service(
environment_file=f"/etc/default/tezos-{type}-rollup-node-{proto.lower()}",
environment=[f"PROTOCOL={proto}"],
exec_start_pre=[
"+/usr/bin/setfacl -m u:tezos:rwx /run/systemd/ask-password"
],
exec_start=startup_script,
exec_stop_post=["+/usr/bin/setfacl -x u:tezos /run/systemd/ask-password"],
state_directory="tezos",
user="tezos",
type_="forking",
keyring_mode="shared",
),
Install(wanted_by=["multi-user.target"]),
)
return [
SystemdUnit(
service_file=service_file,
startup_script=startup_script.split("/")[-1],
startup_script_source="tezos-rollup-node-start",
config_file="tezos-rollup-node.conf",
),
]

def mk_rollup_package(name, type, proto):
proto_snake_case = proto.replace("-", "_")
return TezosBinaryPackage(
f"tezos-{type}-rollup-{name}-{proto}",
f"Tezos {type} rollup {name} using {proto}",
meta=packages_meta,
systemd_units=mk_units(type, proto) if name == "node" else [],
target_proto=proto,
additional_native_deps=["tezos-client", "tezos-node", "tezos-sapling-params"],
postinst_steps=daemon_postinst_common,
dune_filepath=f"src/proto_{proto_snake_case}/bin_{type}_rollup_{name}/main_{type}_rollup_{name}_{proto_snake_case}.exe",
)

# for future sc
types = ["tx"]
packages = ["node", "client"]
return [
mk_rollup_package(name, type, proto)
for name in packages
for type in types
for proto in active_protocols
]


packages.extend(mk_rollup_packages())
22 changes: 22 additions & 0 deletions docker/package/scripts/tezos-rollup-node-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

set -euo pipefail

# $PROTOCOL should be defined in the system unit environment
node="/usr/bin/tezos-tx-rollup-node-$PROTOCOL"
tezos_client="/usr/bin/tezos-client"

"$node" init "$MODE" config \
for "$ROLLUP_ALIAS" \
--data-dir "$DATA_DIR" \
--rpc-addr "$ROLLUP_NODE_RPC_ENDPOINT" \
--force

# Waiting till node start to respond
while ! "$tezos_client" --endpoint "$NODE_RPC_ENDPOINT" rpc list &> /dev/null; do sleep 1; done

"$node" --endpoint "$NODE_RPC_ENDPOINT" \
run "$MODE" for "$ROLLUP_ALIAS" \
--data-dir "$DATA_DIR" &

0 comments on commit 73ca37e

Please sign in to comment.