From 571774f480305b8e83d3885e56084edd3e70bb62 Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Wed, 27 Mar 2024 15:10:44 +0000 Subject: [PATCH] add fork_observer graph property --- src/graphs/default.graphml | 7 +++++++ src/schema/graph_schema.json | 4 ++++ src/warnet/tank.py | 7 +++++-- src/warnet/warnet.py | 25 +++++++++++++------------ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/graphs/default.graphml b/src/graphs/default.graphml index 5f0a28985..1803ba9ed 100644 --- a/src/graphs/default.graphml +++ b/src/graphs/default.graphml @@ -5,6 +5,7 @@ + @@ -12,28 +13,33 @@ -uacomment=w0 true true + true 26.0 -uacomment=w1 true true + true bitcoindevproject/bitcoin:26.0 -uacomment=w2 -debug=mempool true true + true 26.0 -uacomment=w3 true + true 26.0 -uacomment=w4 true + true 26.0 @@ -63,6 +69,7 @@ 26.0 -uacomment=w11 + true diff --git a/src/schema/graph_schema.json b/src/schema/graph_schema.json index 6f25828db..4160bda5a 100644 --- a/src/schema/graph_schema.json +++ b/src/schema/graph_schema.json @@ -23,6 +23,10 @@ "type": "boolean", "default": false, "comment": "Whether to collect Bitcoin Core debug logs with Promtail"}, + "fork_observer": { + "type": "boolean", + "default": false, + "comment": "Whether it should be monitored with Fork Observer."}, "build_args": { "type": "string", "default": "", diff --git a/src/warnet/tank.py b/src/warnet/tank.py index dd950e273..30e25eec3 100644 --- a/src/warnet/tank.py +++ b/src/warnet/tank.py @@ -30,8 +30,7 @@ "-rpcallowip=0.0.0.0/0", "-rpcbind=0.0.0.0", "-fallbackfee=0.00001000", - "-listen=1", - "-rest" + "-listen=1" ]) class Tank: @@ -61,6 +60,7 @@ def __init__(self, index: int, warnet): # index of integers imported from graph file # indicating which tanks to initially connect to self.init_peers = [] + self.fork_observer = False def _parse_version(self, version): if not version: @@ -96,6 +96,9 @@ def parse_graph_node(self, node): } self.lnnode = LNNode(self.warnet, self, self.warnet.container_interface, options) + if self.fork_observer: + self.bitcoin_config += " -rest" + logger.debug( f"Parsed graph node: {self.index} with attributes: {[f'{key}={value}' for key, value in graph_properties.items()]}" ) diff --git a/src/warnet/warnet.py b/src/warnet/warnet.py index b912242d1..e68f24330 100644 --- a/src/warnet/warnet.py +++ b/src/warnet/warnet.py @@ -181,18 +181,19 @@ def write_fork_observer_config(self): shutil.copy(TEMPLATES / FO_CONF_NAME, self.fork_observer_config) with open(self.fork_observer_config, "a") as f: for tank in self.tanks: - f.write( - f""" - [[networks.nodes]] - id = {tank.index} - name = "Node {tank.index}" - description = "Warnet tank {tank.index}" - rpc_host = "{tank.ipv4}" - rpc_port = {tank.rpc_port} - rpc_user = "{tank.rpc_user}" - rpc_password = "{tank.rpc_password}" - """ - ) + if tank.fork_observer: + f.write( + f""" + [[networks.nodes]] + id = {tank.index} + name = "Node {tank.index}" + description = "Warnet tank {tank.index}" + rpc_host = "{tank.ipv4}" + rpc_port = {tank.rpc_port} + rpc_user = "{tank.rpc_user}" + rpc_password = "{tank.rpc_password}" + """ + ) logger.info(f"Wrote file: {self.fork_observer_config}") def export(self, subdir):