From a631aebcadf69efc48405af404908f3b209f1462 Mon Sep 17 00:00:00 2001 From: filipdjokic Date: Mon, 8 Dec 2025 14:53:06 +0100 Subject: [PATCH 1/4] ci: Remove mempool app-layer mempool declaration from configuration --- installer/installer.py | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/installer/installer.py b/installer/installer.py index abe58b338..984c6ad83 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -1200,6 +1200,9 @@ def configure_node_settings(self) -> bool: else: logging.debug("Log format not set by user. Skipping...") + # Remove [mempool] section from app.toml + self.remove_mempool_section(app_toml_path) + # Set ownership of configuration directory to cheqd:cheqd logging.info(f"Setting ownership of {self.cheqd_config_dir} to {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER}") self.exec(f"chown -R {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER} {self.cheqd_config_dir}") @@ -1210,6 +1213,57 @@ def configure_node_settings(self) -> bool: logging.exception(f"Failed to configure cheqd-noded settings. Reason: {e}") return False + def remove_mempool_section(self, app_toml_path: str) -> bool: + # Remove or comment out the [mempool] section from app.toml + # This section is deprecated in newer Cosmos SDK versions + try: + if not os.path.exists(app_toml_path): + logging.debug(f"app.toml not found at {app_toml_path}. Skipping mempool section removal...") + return True + + with open(app_toml_path, "r") as file: + lines = file.readlines() + + # Find and comment out the [mempool] section + in_mempool_section = False + modified_lines = [] + + for line in lines: + stripped = line.strip() + + # Check if we're entering the [mempool] section + if stripped == "[mempool]" or stripped == "#[mempool]": + in_mempool_section = True + # Comment out the section header if not already commented + if not stripped.startswith("#"): + modified_lines.append("# " + line.lstrip()) + else: + modified_lines.append(line) + continue + + # Check if we're exiting the [mempool] section (next section starts) + if in_mempool_section and stripped.startswith("[") and not stripped.startswith("#"): + in_mempool_section = False + + # Comment out lines within the [mempool] section + if in_mempool_section: + # Only comment out non-empty, non-commented lines + if stripped and not stripped.startswith("#"): + modified_lines.append("# " + line.lstrip()) + else: + modified_lines.append(line) + else: + modified_lines.append(line) + + # Write the modified content back to the file + with open(app_toml_path, "w") as file: + file.writelines(modified_lines) + + logging.info(f"Successfully removed [mempool] section from {app_toml_path}") + return True + except Exception as e: + logging.exception(f"Failed to remove [mempool] section from app.toml. Reason: {e}") + return False def _get_latest_block_height(self, rpc_endpoint: str) -> int: try: From d12779c2acaea2fcec4466a6ae17fc9c17408959 Mon Sep 17 00:00:00 2001 From: filipdjokic Date: Mon, 8 Dec 2025 14:56:19 +0100 Subject: [PATCH 2/4] comments --- installer/installer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/installer/installer.py b/installer/installer.py index 984c6ad83..563660a86 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -1215,7 +1215,6 @@ def configure_node_settings(self) -> bool: def remove_mempool_section(self, app_toml_path: str) -> bool: # Remove or comment out the [mempool] section from app.toml - # This section is deprecated in newer Cosmos SDK versions try: if not os.path.exists(app_toml_path): logging.debug(f"app.toml not found at {app_toml_path}. Skipping mempool section removal...") From f28d83073905e5c29c0566c5dadde66d497d452e Mon Sep 17 00:00:00 2001 From: filipdjokic Date: Mon, 8 Dec 2025 15:08:27 +0100 Subject: [PATCH 3/4] fix linter errors --- installer/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/installer.py b/installer/installer.py index 563660a86..f6c4e8482 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -1231,7 +1231,7 @@ def remove_mempool_section(self, app_toml_path: str) -> bool: stripped = line.strip() # Check if we're entering the [mempool] section - if stripped == "[mempool]" or stripped == "#[mempool]": + if stripped in {"[mempool]", "#[mempool]"}: in_mempool_section = True # Comment out the section header if not already commented if not stripped.startswith("#"): From da90d4d4ef117bd098d6c2715aba02db581ee188 Mon Sep 17 00:00:00 2001 From: filipdjokic Date: Mon, 15 Dec 2025 10:03:00 +0100 Subject: [PATCH 4/4] Address review comments --- installer/installer.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/installer/installer.py b/installer/installer.py index f6c4e8482..6eed979b3 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -1201,7 +1201,9 @@ def configure_node_settings(self) -> bool: logging.debug("Log format not set by user. Skipping...") # Remove [mempool] section from app.toml - self.remove_mempool_section(app_toml_path) + if not self.remove_mempool_section(app_toml_path): + logging.error("Failed to remove [mempool] section from app.toml.") + return False # Set ownership of configuration directory to cheqd:cheqd logging.info(f"Setting ownership of {self.cheqd_config_dir} to {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER}") @@ -1235,7 +1237,9 @@ def remove_mempool_section(self, app_toml_path: str) -> bool: in_mempool_section = True # Comment out the section header if not already commented if not stripped.startswith("#"): - modified_lines.append("# " + line.lstrip()) + # Preserve original indentation + leading_space = line[:len(line) - len(line.lstrip())] + modified_lines.append(leading_space + "# " + line.lstrip()) else: modified_lines.append(line) continue @@ -1248,7 +1252,9 @@ def remove_mempool_section(self, app_toml_path: str) -> bool: if in_mempool_section: # Only comment out non-empty, non-commented lines if stripped and not stripped.startswith("#"): - modified_lines.append("# " + line.lstrip()) + # Preserve original indentation + leading_space = line[:len(line) - len(line.lstrip())] + modified_lines.append(leading_space + "# " + line.lstrip()) else: modified_lines.append(line) else: @@ -1258,10 +1264,10 @@ def remove_mempool_section(self, app_toml_path: str) -> bool: with open(app_toml_path, "w") as file: file.writelines(modified_lines) - logging.info(f"Successfully removed [mempool] section from {app_toml_path}") + logging.info(f"Successfully commented out [mempool] section in {app_toml_path}") return True except Exception as e: - logging.exception(f"Failed to remove [mempool] section from app.toml. Reason: {e}") + logging.exception(f"Failed to comment out [mempool] section in app.toml. Reason: {e}") return False def _get_latest_block_height(self, rpc_endpoint: str) -> int: