Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
- uses: azure/[email protected]
- uses: medyagh/setup-minikube@master
with:
cpus: max
memory: 10000m
mount-path: ${{ github.workspace }}:/mnt/src
- uses: actions/download-artifact@v4
with:
Expand Down
79 changes: 54 additions & 25 deletions src/warnet/backend/kubernetes_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,33 +384,62 @@ def create_bitcoind_container(self, tank: Tank) -> client.V1Container:
bitcoind_options = tank.get_bitcoin_conf(peers)
container_env = [client.V1EnvVar(name="BITCOIN_ARGS", value=bitcoind_options)]

bitcoind_container = client.V1Container(
name=container_name,
image=container_image,
env=container_env,
liveness_probe=client.V1Probe(
failure_threshold=3,
initial_delay_seconds=5,
period_seconds=5,
timeout_seconds=1,
_exec=client.V1ExecAction(command=["pidof", "bitcoind"]),
),
readiness_probe=client.V1Probe(
failure_threshold=1,
initial_delay_seconds=0,
period_seconds=1,
timeout_seconds=1,
tcp_socket=client.V1TCPSocketAction(port=tank.rpc_port),
),
security_context=client.V1SecurityContext(
privileged=True,
capabilities=client.V1Capabilities(add=["NET_ADMIN", "NET_RAW"]),
),
if tank.resources:
resources = client.V1ResourceRequirements(
requests=tank.resources["requests"],
limits=tank.resources["limits"],
)
else:
resources = client.V1ResourceRequirements()

liveness_probe = client.V1Probe(
failure_threshold=3,
initial_delay_seconds=5,
period_seconds=5,
timeout_seconds=1,
_exec=client.V1ExecAction(command=["pidof", "bitcoind"]),
)
self.log.debug(
f"Created bitcoind container for tank {tank.index} using {bitcoind_options=:}"
readiness_probe = client.V1Probe(
failure_threshold=1,
initial_delay_seconds=0,
period_seconds=1,
timeout_seconds=1,
tcp_socket=client.V1TCPSocketAction(port=tank.rpc_port),
)
return bitcoind_container
security_context = client.V1SecurityContext(
privileged=True,
capabilities=client.V1Capabilities(add=["NET_ADMIN", "NET_RAW"]),
)
if tank.resources:
bitcoind_container = client.V1Container(
name=container_name,
image=container_image,
env=container_env,
liveness_probe=liveness_probe,
readiness_probe=readiness_probe,
security_context=security_context,
resources=client.V1ResourceRequirements(
requests=tank.resources["requests"],
limits=tank.resources["limits"],
),
)
self.log.debug(
f"Created bitcoind container for tank {tank.index} using {bitcoind_options=:}"
)
return bitcoind_container
else:
bitcoind_container = client.V1Container(
name=container_name,
image=container_image,
env=container_env,
liveness_probe=liveness_probe,
readiness_probe=readiness_probe,
security_context=security_context,
)
self.log.debug(
f"Created bitcoind container for tank {tank.index} using {bitcoind_options=:}"
)
return bitcoind_container

def create_prometheus_container(self, tank) -> client.V1Container:
env = [
Expand Down
5 changes: 4 additions & 1 deletion src/warnet/cli/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def create(number: int, outfile: Path, version: str, bitcoin_conf: Path, random:
@click.option("--outfile", type=click.Path())
@click.option("--cb", type=str)
@click.option("--ln_image", type=str)
def import_json(infile: Path, outfile: Path, cb: str, ln_image: str):
@click.option("--ci", is_flag=True)
def import_json(infile: Path, outfile: Path, cb: str, ln_image: str, ci: bool = False):
"""
Create a cycle graph with nodes imported from lnd `describegraph` JSON file,
and additionally include 7 extra random outbounds per node. Include lightning
Expand All @@ -64,6 +65,8 @@ def import_json(infile: Path, outfile: Path, cb: str, ln_image: str):
graph.nodes[n]["ln_cb_image"] = cb
if ln_image:
graph.nodes[n]["ln_image"] = ln_image
if ci:
graph.nodes[n]["resources"] = "{}"

# Save a map of LN pubkey -> Tank index
ln_ids = {}
Expand Down
59 changes: 36 additions & 23 deletions src/warnet/graph_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,79 @@
"node": {
"type": "object",
"properties": {
"version": {
"type": "string",
"comment": "Bitcoin Core version with an available Warnet tank image on Dockerhub. May also be a GitHub repository with format user/repository:branch to build from source code"},
"image": {
"type": "string",
"comment": "Bitcoin Core Warnet tank image on Dockerhub with the format repository/image:tag"},
"default": "bitcoindevproject/bitcoin:27.0",
"comment": "Bitcoin Core Warnet tank image on Dockerhub with the format repository/image:tag"
},
"bitcoin_config": {
"type": "string",
"default": "",
"comment": "A string of Bitcoin Core options in command-line format, e.g. '-debug=net -blocksonly'"},
"comment": "A string of Bitcoin Core options in command-line format, e.g. '-debug=net -blocksonly'"
},
"tc_netem": {
"type": "string",
"comment": "A tc-netem command as a string beginning with 'tc qdisc add dev eth0 root netem'"},
"comment": "A tc-netem command as a string beginning with 'tc qdisc add dev eth0 root netem'"
},
"exporter": {
"type": "boolean",
"default": false,
"comment": "Whether to attach a Prometheus data exporter to the tank"},
"comment": "Whether to attach a Prometheus data exporter to the tank"
},
"metrics": {
"type": "string",
"comment": "A space-separated string of RPC queries to scrape by Prometheus"},
"comment": "A space-separated string of RPC queries to scrape by Prometheus"
},
"collect_logs": {
"type": "boolean",
"default": false,
"comment": "Whether to collect Bitcoin Core debug logs with Promtail"},
"default": true,
"comment": "Whether to collect Bitcoin Core debug logs with Promtail"
},
"build_args": {
"type": "string",
"default": "",
"comment": "A string of configure options used when building Bitcoin Core from source code, e.g. '--without-gui --disable-tests'"},
"comment": "A string of configure options used when building Bitcoin Core from source code, e.g. '--without-gui --disable-tests'"
},
"ln": {
"type": "string",
"comment": "Attach a lightning network node of this implementation (currently only supports 'lnd' or 'cln')"},
"comment": "Attach a lightning network node of this implementation (currently only supports 'lnd' or 'cln')"
},
"ln_image": {
"type": "string",
"comment": "Specify a lightning network node image from Dockerhub with the format repository/image:tag"},
"comment": "Specify a lightning network node image from Dockerhub with the format repository/image:tag"
},
"ln_cb_image": {
"type": "string",
"comment": "Specify a lnd Circuit Breaker image from Dockerhub with the format repository/image:tag"},
"comment": "Specify a lnd Circuit Breaker image from Dockerhub with the format repository/image:tag"
},
"ln_config": {
"type": "string",
"comment": "A string of arguments for the lightning network node in command-line format, e.g. '--protocol.wumbo-channels --bitcoin.timelockdelta=80'"}
"comment": "A string of arguments for the lightning network node in command-line format, e.g. '--protocol.wumbo-channels --bitcoin.timelockdelta=80'"
},
"resources": {
"type": "string",
"comment": "Kubernetes resource requests and limits for the node",
"default": "{'requests':{'cpu':'500m', 'memory':'500Mi'}, 'limits':{'cpu':'1000m', 'memory':'1500Mi'}}"
}
},
"additionalProperties": false,
"oneOf": [
{"required": ["version"]},
{"required": ["image"]}
],
"additionalProperties": false,
"required": []
},
"edge": {
"type": "object",
"properties": {
"channel_open": {
"type": "string",
"comment": "Indicate that this edge is a lightning channel with these arguments passed to lnd openchannel"},
"comment": "Indicate that this edge is a lightning channel with these arguments passed to lnd openchannel"
},
"source_policy": {
"type": "string",
"comment": "Update the channel originator policy by passing these arguments passed to lnd updatechanpolicy"},
"comment": "Update the channel originator policy by passing these arguments passed to lnd updatechanpolicy"
},
"target_policy": {
"type": "string",
"comment": "Update the channel partner policy by passing these arguments passed to lnd updatechanpolicy"}
"comment": "Update the channel partner policy by passing these arguments passed to lnd updatechanpolicy"
}
},
"additionalProperties": false,
"required": []
Expand Down
6 changes: 5 additions & 1 deletion src/warnet/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, index: int, warnet):
self.bitcoin_network = warnet.bitcoin_network
self.version: str = ""
self.image: str = ""
self.resources: dict = dict()
self.bitcoin_config = ""
self.netem = None
self.exporter = False
Expand Down Expand Up @@ -81,7 +82,10 @@ def parse_graph_node(self, node):
value = node.get(property, specs.get("default"))
if property == "version":
self._parse_version(value)
setattr(self, property, value)
if property == "resources":
setattr(self, property, eval(value))
else:
setattr(self, property, value)
graph_properties[property] = value

if self.version and self.image:
Expand Down
11 changes: 2 additions & 9 deletions src/warnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,8 @@ def create_cycle_graph(n: int, version: str, bitcoin_conf: str | None, random_ve
conf_contents = dump_bitcoin_conf(conf_dict, for_graph=True)

# populate our custom fields
for i, node in enumerate(graph.nodes()):
if random_version:
graph.nodes[node]["version"] = random.choice(WEIGHTED_TAGS)
else:
# One node demoing the image tag
if i == 1:
graph.nodes[node]["image"] = f"bitcoindevproject/bitcoin:{version}"
else:
graph.nodes[node]["version"] = version
for node in graph.nodes():
graph.nodes[node]["image"] = f"bitcoindevproject/bitcoin:{version}"
graph.nodes[node]["bitcoin_config"] = conf_contents
graph.nodes[node]["tc_netem"] = ""
graph.nodes[node]["build_args"] = ""
Expand Down
2 changes: 1 addition & 1 deletion test/dag_connection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DAGConnectionTest(TestBase):
def __init__(self):
super().__init__()
self.graph_file_path = (
Path(os.path.dirname(__file__)) / "data" / "ten_semi_unconnected.graphml"
Path(os.path.dirname(__file__)) / "data" / "six_semi_unconnected.graphml"
)

def run_test(self):
Expand Down
45 changes: 7 additions & 38 deletions test/data/12_node_ring.graphml → test/data/6_node_ring.graphml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<key id="services" attr.name="services" attr.type="string" for="graph" />
<key id="version" attr.name="version" attr.type="string" for="node" />
<key id="image" attr.name="image" attr.type="string" for="node" />
<key id="bitcoin_config" attr.name="bitcoin_config" attr.type="string" for="node" />
<key id="tc_netem" attr.name="tc_netem" attr.type="string" for="node" />
Expand All @@ -17,51 +16,27 @@
<key id="target_policy" attr.name="target_policy" attr.type="string" for="edge" />
<graph edgedefault="directed">
<node id="0">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w0 -debug=validation</data>
</node>
<node id="1">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w1 -debug=validation</data>
</node>
<node id="2">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w2 -debug=validation</data>
</node>
<node id="3">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w3</data>
</node>
<node id="4">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w4</data>
</node>
<node id="5">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w5</data>
</node>
<node id="6">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w6</data>
</node>
<node id="7">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w7</data>
</node>
<node id="8">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w8</data>
</node>
<node id="9">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w9</data>
</node>
<node id="10">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w10</data>
</node>
<node id="11">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<!-- no bitcoin_config to test unused options -->
</node>
<!-- connect the nodes in a ring to start -->
Expand All @@ -70,12 +45,6 @@
<edge id="13" source="2" target="3"></edge>
<edge id="14" source="3" target="4"></edge>
<edge id="15" source="4" target="5"></edge>
<edge id="16" source="5" target="6"></edge>
<edge id="17" source="6" target="7"></edge>
<edge id="18" source="7" target="8"></edge>
<edge id="19" source="8" target="9"></edge>
<edge id="20" source="9" target="10"></edge>
<edge id="21" source="10" target="11"></edge>
<edge id="21" source="11" target="0"></edge>
<edge id="16" source="5" target="0"></edge>
</graph>
</graphml>
13 changes: 6 additions & 7 deletions test/data/ln.graphml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<key id="services" attr.name="services" attr.type="string" for="graph" />
<key id="version" attr.name="version" attr.type="string" for="node" />
<key id="image" attr.name="image" attr.type="string" for="node" />
<key id="bitcoin_config" attr.name="bitcoin_config" attr.type="string" for="node" />
<key id="tc_netem" attr.name="tc_netem" attr.type="string" for="node" />
Expand All @@ -18,34 +17,34 @@
<graph edgedefault="directed">
<data key="services">simln</data>
<node id="0">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w0</data>
<data key="ln">lnd</data>
<data key="ln_image">lightninglabs/lnd:v0.17.5-beta</data>
<data key="collect_logs">true</data>
</node>
<node id="1">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w1</data>
<data key="ln">lnd</data>
<data key="ln_cb_image">pinheadmz/circuitbreaker:278737d</data>
<data key="collect_logs">true</data>
</node>
<node id="2">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w2</data>
<data key="ln">lnd</data>
<data key="ln_cb_image">pinheadmz/circuitbreaker:278737d</data>
<data key="ln_config">--bitcoin.timelockdelta=33</data>
</node>
<node id="3">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w2</data>
<data key="ln">cln</data>
<data key="ln_config">--cltv-delta=33</data>
</node>
<node id="4">
<data key="version">27.0</data>
<data key="image">bitcoindevproject/bitcoin:27.0</data>
<data key="bitcoin_config">-uacomment=w3</data>
</node>
<edge id="1" source="0" target="1"></edge>
Expand All @@ -68,4 +67,4 @@
<data key="source_policy"> feebase=5500 feeppm=3</data>
</edge>
</graph>
</graphml>
</graphml>
Loading