From 1dcb546f30156cecbe7bbb71cbff71a4fecdd802 Mon Sep 17 00:00:00 2001 From: Dante Sanchez Date: Mon, 20 Nov 2023 11:30:46 -0500 Subject: [PATCH 1/4] add jq patch to sort coins --- cosmos_genesis_tinker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cosmos_genesis_tinker.py b/cosmos_genesis_tinker.py index 1cc7732..102a569 100755 --- a/cosmos_genesis_tinker.py +++ b/cosmos_genesis_tinker.py @@ -389,6 +389,13 @@ def replace_validator(self, old_validator: Validator, new_validator: Validator): self.preprocessing_file], check=True) + # Sort coins in bank balances + self.log_step("Sorting balances coins") + subprocess.run(f"jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' {self.preprocessing_file} > sorted.json", + check=True, shell=True) + subprocess.run(f"mv sorted.json {self.preprocessing_file}", + check=True, shell=True) + def load_file(self, path): """ Loads a genesis file from the given path From 6f54ec3fb38b46d16ad1ab8907c83e095170b777 Mon Sep 17 00:00:00 2001 From: Dante Sanchez Date: Mon, 20 Nov 2023 11:32:56 -0500 Subject: [PATCH 2/4] add jq requirement --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e74c677..6922081 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Use this tool to test how the network reacts to a given scenario. The available ### Requirements +* `jq` * Python 3.10 1. Clone from github: `git clone git@github.com:hyphacoop/cosmos-genesis-tinkerer.git` From 0c268e0c6ea5289336628560b6b3b0d4828f19d4 Mon Sep 17 00:00:00 2001 From: Dante Sanchez Date: Mon, 20 Nov 2023 11:34:14 -0500 Subject: [PATCH 3/4] fix long line --- cosmos_genesis_tinker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cosmos_genesis_tinker.py b/cosmos_genesis_tinker.py index 102a569..ca84183 100755 --- a/cosmos_genesis_tinker.py +++ b/cosmos_genesis_tinker.py @@ -391,7 +391,8 @@ def replace_validator(self, old_validator: Validator, new_validator: Validator): # Sort coins in bank balances self.log_step("Sorting balances coins") - subprocess.run(f"jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' {self.preprocessing_file} > sorted.json", + subprocess.run(f"jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' " + \ + f"{self.preprocessing_file} > sorted.json", check=True, shell=True) subprocess.run(f"mv sorted.json {self.preprocessing_file}", check=True, shell=True) From 09198248d4394c00f0b84ae59c5d8b6c95ab636f Mon Sep 17 00:00:00 2001 From: Dante Sanchez Date: Mon, 20 Nov 2023 11:35:25 -0500 Subject: [PATCH 4/4] fix pylint --- cosmos_genesis_tinker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cosmos_genesis_tinker.py b/cosmos_genesis_tinker.py index ca84183..f952fda 100755 --- a/cosmos_genesis_tinker.py +++ b/cosmos_genesis_tinker.py @@ -391,8 +391,8 @@ def replace_validator(self, old_validator: Validator, new_validator: Validator): # Sort coins in bank balances self.log_step("Sorting balances coins") - subprocess.run(f"jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' " + \ - f"{self.preprocessing_file} > sorted.json", + subprocess.run("jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' " + \ + f"{self.preprocessing_file} > sorted.json", check=True, shell=True) subprocess.run(f"mv sorted.json {self.preprocessing_file}", check=True, shell=True)