Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable fork observer on compose #325

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/graphs/default.graphml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@
<key attr.name="build_args" attr.type="string" for="node" id="build_args"/>
<key attr.name="exporter" attr.type="boolean" for="node" id="exporter"/>
<key attr.name="collect_logs" attr.type="boolean" for="node" id="collect_logs"/>
<key attr.name="fork_observer" attr.type="boolean" for="node" id="fork_observer"/>
<key attr.name="image" attr.type="string" for="node" id="image"/>
<graph edgedefault="directed">
<node id="0">
<data key="version">26.0</data>
<data key="bitcoin_config">-uacomment=w0</data>
<data key="exporter">true</data>
<data key="collect_logs">true</data>
<data key="fork_observer">true</data>
</node>
<node id="1">
<data key="version">26.0</data>
<data key="bitcoin_config">-uacomment=w1</data>
<data key="exporter">true</data>
<data key="collect_logs">true</data>
<data key="fork_observer">true</data>
</node>
<node id="2">
<data key="image">bitcoindevproject/bitcoin:26.0</data>
<data key="bitcoin_config">-uacomment=w2 -debug=mempool</data>
<data key="exporter">true</data>
<data key="collect_logs">true</data>
<data key="fork_observer">true</data>
</node>
<node id="3">
<data key="version">26.0</data>
<data key="bitcoin_config">-uacomment=w3</data>
<data key="exporter">true</data>
<data key="fork_observer">true</data>
</node>
<node id="4">
<data key="version">26.0</data>
<data key="bitcoin_config">-uacomment=w4</data>
<data key="exporter">true</data>
<data key="fork_observer">true</data>
</node>
<node id="5">
<data key="version">26.0</data>
Expand Down Expand Up @@ -63,6 +69,7 @@
<node id="11">
<data key="version">26.0</data>
<data key="bitcoin_config">-uacomment=w11</data>
<data key="fork_observer">true</data>
</node>
<!-- connect the nodes in a ring to start -->
<edge id="1" source="0" target="1"></edge>
Expand Down
4 changes: 4 additions & 0 deletions src/schema/graph_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
4 changes: 4 additions & 0 deletions src/warnet/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,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:
Expand Down Expand Up @@ -95,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()]}"
)
Expand Down
25 changes: 13 additions & 12 deletions src/warnet/warnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading