From 5e20fb3442c0e56a6b805abcccae0aa6ec634061 Mon Sep 17 00:00:00 2001 From: Ilona Prikule Date: Fri, 3 Jun 2022 15:22:14 +0200 Subject: [PATCH 1/4] [#464] Query toggle vote in setup wizard Problem: in anticipation of jakarta on mainnet, we need to properly support the liquidity baking toggle vote option that is now mandatory. The Setup Wizard needs to ask for the user's preference. Solution: added a step that queries the user's preference. There seems to be no good way to provide this option for our systemd service, so we modify the service's config file on each wizard invocation. --- docker/package/tezos_setup_wizard.py | 35 ++++++++++++++++++++++++++-- docker/package/wizard_structure.py | 26 +++++++++++++++------ 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/docker/package/tezos_setup_wizard.py b/docker/package/tezos_setup_wizard.py index 353f7c3ae..b7a80054d 100644 --- a/docker/package/tezos_setup_wizard.py +++ b/docker/package/tezos_setup_wizard.py @@ -51,6 +51,12 @@ "archive": "Store all the chain data, very storage-demanding", } +toggle_vote_modes = { + "pass": "Abstain from voting", + "off": "Request to end the subsidy", + "on": "Request to continue or restart the subsidy", +} + TMP_SNAPSHOT_LOCATION = "/tmp/tezos_node.snapshot" @@ -126,6 +132,17 @@ def is_full_snapshot(import_mode): validator=Validator(enum_range_validator(systemd_enable)), ) +liquidity_toggle_vote_query = Step( + id="liquidity_toggle_vote", + prompt="Would you like to request to end the Liquidity Baking subsidy?", + help="Tezos chain offers a Liquidity Baking subsidy mechanism to incentivise exchange\n" + "between tez and tzBTC. You can ask to end this subsidy, ask to continue it, or abstain.\n" + "\nYou can read more about this in the here:\n" + "https://tezos.gitlab.io/jakarta/liquidity_baking.html", + options=toggle_vote_modes, + validator=Validator(enum_range_validator(toggle_vote_modes)), +) + # We define this step as a function to better tailor snapshot options to the chosen history mode def get_snapshot_mode_query(modes): return Step( @@ -333,7 +350,7 @@ def bootstrap_node(self): "time, as the node needs a node identity to be generated." ) - self.systemctl_start_action("node") + self.systemctl_simple_action("start", "node") print("Waiting for the node service to start...") @@ -408,8 +425,20 @@ def register_baker(self): "to see the baker status and baking rights of your account." ) + # There is no changing the toggle vote option at a glance, + # so we need to change the config every time + def set_liquidity_toggle_vote(self): + self.query_step(liquidity_toggle_vote_query) + + config_filepath = self.get_baking_config_filepath() + replace_in_service_config( + config_filepath, + "LIQUIDITY_BAKING_TOGGLE_VOTE", + f"\"{self.config['liquidity_toggle_vote']}\"", + ) + def start_baking(self): - self.systemctl_start_action("baking") + self.systemctl_simple_action("restart", "baking") def run_setup(self): @@ -447,6 +476,8 @@ def run_setup(self): continue executed = True + self.set_liquidity_toggle_vote() + print() print("Starting the baking instance") self.start_baking() diff --git a/docker/package/wizard_structure.py b/docker/package/wizard_structure.py index ff47ece25..b144d64d4 100644 --- a/docker/package/wizard_structure.py +++ b/docker/package/wizard_structure.py @@ -363,6 +363,18 @@ def search_json_with_default(json_filepath, field, default): return json_dict.pop(field, default) +def replace_in_service_config(config_filepath, field, value): + with open(config_filepath, "r") as f: + config_contents = f.read() + + old = re.search(f"{field}=.*", config_contents) + if old is None: + return None + else: + new = f"{field}={value}" + proc_call(f"sudo sed -i 's/{old.group(0)}/{new}/' {config_filepath}") + + class Step: def __init__( self, @@ -548,9 +560,9 @@ def query_step(self, step: Step): validated = True self.config[step.id] = answer - def systemctl_start_action(self, service): + def systemctl_simple_action(self, action, service): proc_call( - f"sudo systemctl start tezos-{service}-{self.config['network']}.service" + f"sudo systemctl {action} tezos-{service}-{self.config['network']}.service" ) def systemctl_enable(self): @@ -560,10 +572,7 @@ def systemctl_enable(self): self.config["mode"], self.config["network"] ) ) - proc_call( - f"sudo systemctl enable tezos-{self.config['mode']}-" - f"{self.config['network']}.service" - ) + self.systemctl_simple_action("enable", self.config["mode"]) else: print("The services won't restart on boot.") @@ -584,7 +593,7 @@ def query_and_update_config(self, query): f"{self.config['tezos_client_options']} config update" ) - def fill_baking_config(self): + def get_baking_config_filepath(self): net = self.config["network"] output = get_proc_output(f"systemctl show tezos-baking-{net}.service").stdout config_filepath = re.search(b"EnvironmentFiles=(.*) ", output) @@ -596,7 +605,10 @@ def fill_baking_config(self): config_filepath = f"/etc/default/tezos-baking-{net}" else: config_filepath = config_filepath.group(1).decode().strip() + return config_filepath + def fill_baking_config(self): + config_filepath = self.get_baking_config_filepath() with open(config_filepath, "r") as f: config_contents = f.read() self.config["client_data_dir"] = search_baking_service_config( From 2696aff4f5bf5ec2adbe333af53f88ddff230f25 Mon Sep 17 00:00:00 2001 From: Ilona Prikule Date: Fri, 3 Jun 2022 16:54:41 +0200 Subject: [PATCH 2/4] [#464] Add a post-install message to tezos-baking Problem: it would be nice to notify the users about the liquidity baking toggle vote option, as it's an important breaking change. Solution: added a post-install step to tezos-baking debian package that should print a notification upon installation of update. --- docker/package/model.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docker/package/model.py b/docker/package/model.py index 2bc2a1ca6..cf70175ff 100644 --- a/docker/package/model.py +++ b/docker/package/model.py @@ -577,7 +577,11 @@ def __init__( custom_unit.poststop_script = "tezos-baking-custom-poststop" custom_unit.instances = [] self.systemd_units.append(custom_unit) - self.postinst_steps = "" + # TODO: we will likely need to remove this once toggle vote isn't new anymore + self.postinst_steps = """echo "Please note that the liquidity baking toggle vote option" +echo "is now mandatory when baking. You can read more about it here:" +echo "https://tezos.gitlab.io/jakarta/liquidity_baking.html#toggle-vote" +""" self.postrm_steps = "" def fetch_sources(self, out_dir): @@ -684,3 +688,16 @@ def gen_rules(self, out): def gen_license(self, out): shutil.copy(f"{os.path.dirname(__file__)}/../../LICENSE", out) + + def gen_postinst(self, out): + postinst_contents = f"""#!/bin/sh + +set -e + +#DEBHELPER# + +{self.postinst_steps} +""" + postinst_contents = postinst_contents.replace(self.name, self.name.lower()) + with open(out, "w") as f: + f.write(postinst_contents) From f68701a2a5d1d363f9ab648e0f40e43db9af9970 Mon Sep 17 00:00:00 2001 From: Ilona Prikule Date: Tue, 21 Jun 2022 02:05:51 +0200 Subject: [PATCH 3/4] [#464] Update baking docs Problem: there's a new mandatory liquidity baking toggle vote option, but we don't mention it in the docs. Solution: added a subsection explaining the default and how to change it. --- docs/baking.md | 20 ++++++++++++++++++++ docs/tests/voting.md | 1 + 2 files changed, 21 insertions(+) diff --git a/docs/baking.md b/docs/baking.md index e8bf8b47f..7a6e5caed 100644 --- a/docs/baking.md +++ b/docs/baking.md @@ -155,6 +155,26 @@ sudo -u tezos tezos-client bootstrapped By default `tezos-baking-.service` will use the `baker` alias for the key that will be used for baking and endorsing. +### Setting the Liquidity Baking toggle vote option + +Since `013-PtJakart`, the `--liquidity-baking-toggle-vote` command line option for +`tezos-baker` is now mandatory. In our systemd services, it is set to `pass` by +default. You can change it as desired in the service config file at +`/etc/defaults/tezos-baking-`. + +If the baking service is running already, changing this options requires a restart. +You can do so manually by running: +```bash +sudo systemctl restart tezos-baking-.service +``` + +If using this option on Ithaca, the format in our configuration files stays the same +but is transformed to the Ithaca-specific format: `off` is transformed to the +`--liquidity-baking-escape-vote` command line options, whereas `pass` and `on` result +in no command line argument and will only affect baking upon switching to Jakarta. + +You can also use the [Setup Wizard](#using-the-wizard) which will handle everything for you. + ### Importing the baker key diff --git a/docs/tests/voting.md b/docs/tests/voting.md index c4fed1b4a..1f3eaca59 100644 --- a/docs/tests/voting.md +++ b/docs/tests/voting.md @@ -41,6 +41,7 @@ NODE_RPC_ENDPOINT="http://localhost:8732" BAKER_ADDRESS_ALIAS="baker" CUSTOM_NODE_CONFIG="" RESET_ON_STOP="" +LIQUIDITY_BAKING_TOGGLE_VOTE="pass" ``` Additionally, you can set `RESET_ON_STOP="true"` to enable automatic node directory removal which will From 7047eee700083b1e99349df63d52c21c62423944 Mon Sep 17 00:00:00 2001 From: Ilona Prikule Date: Tue, 21 Jun 2022 15:10:34 +0200 Subject: [PATCH 4/4] [Chore] Bump release number for jakartanet switch prep Problem: we're going to need to make a new release in the scope of the same upstream release, so we need to bump various versions. Solution: bumped the release number, added the letter version because of changes to the setup wizard, also added jakarta to the list of mainnet protos. --- docker/package/model.py | 4 ++-- docker/package/packages.py | 2 +- meta.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/package/model.py b/docker/package/model.py index cf70175ff..c260414ad 100644 --- a/docker/package/model.py +++ b/docker/package/model.py @@ -494,7 +494,7 @@ class TezosBakingServicesPackage(AbstractPackage): # native releases, so we append an extra letter to the version of # the package. # This should be reset to "" whenever the native version is bumped. - letter_version = "" + letter_version = "a" buildfile = "setup.py" @@ -669,7 +669,7 @@ def gen_buildfile(self, out): setup( name='tezos-baking', packages=['tezos_baking'], - version={self.meta.version}, + version='{self.meta.version}', entry_points=dict( console_scripts=[ 'tezos-setup-wizard=tezos_baking.tezos_setup_wizard:main', diff --git a/docker/package/packages.py b/docker/package/packages.py index 90df75e7a..6860d205d 100644 --- a/docker/package/packages.py +++ b/docker/package/packages.py @@ -20,7 +20,7 @@ "jakartanet": "jakartanet", } networks_protos = { - "mainnet": ["012-Psithaca"], + "mainnet": ["012-Psithaca", "013-PtJakart"], "ithacanet": ["012-Psithaca"], "jakartanet": ["013-PtJakart"], } diff --git a/meta.json b/meta.json index 2773b2261..17d4a094c 100644 --- a/meta.json +++ b/meta.json @@ -1,4 +1,4 @@ { - "release": "1", + "release": "2", "maintainer": "Serokell " }