Skip to content
Open
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 resources/graphs/default.graphml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
<key id="channel_open" attr.name="channel_open" attr.type="string" for="edge" />
<key id="source_policy" attr.name="source_policy" attr.type="string" for="edge" />
<key id="target_policy" attr.name="target_policy" attr.type="string" for="edge" />
<key id="profile" attr.name="profile" attr.type="string" for="edge" />
<graph edgedefault="directed">
<node id="0">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w0</data>
<data key="exporter">true</data>
<data key="collect_logs">true</data>
<data key="profile">laptop</data>
</node>
<node id="1">
<data key="version">27.0</data>
Expand Down
6 changes: 6 additions & 0 deletions src/warnet/backend/kubernetes_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from warnet.status import RunningStatus
from warnet.tank import Tank
from warnet.utils import parse_raw_messages
from warnet.resources import resource_profiles

DOCKER_REGISTRY_CORE = "bitcoindevproject/bitcoin"
LOCAL_REGISTRY = "warnet/bitcoin-core"
Expand Down Expand Up @@ -384,6 +385,7 @@ 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)]

resources = resource_profiles[tank.profile]
bitcoind_container = client.V1Container(
name=container_name,
image=container_image,
Expand All @@ -406,6 +408,10 @@ def create_bitcoind_container(self, tank: Tank) -> client.V1Container:
privileged=True,
capabilities=client.V1Capabilities(add=["NET_ADMIN", "NET_RAW"]),
),
resources=client.V1ResourceRequirements(
requests=resources["requests"],
limits=resources["limits"],
),
)
self.log.debug(
f"Created bitcoind container for tank {tank.index} using {bitcoind_options=:}"
Expand Down
1 change: 1 addition & 0 deletions src/warnet/cli/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def create(number: int, outfile: Path, version: str, bitcoin_conf: Path, random:
Returns XML file as string with or without --outfile option
"""
graph = create_cycle_graph(number, version, bitcoin_conf, random)
validate_graph_schema(graph)

if outfile:
file_path = Path(outfile)
Expand Down
6 changes: 5 additions & 1 deletion src/warnet/graph_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
"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'"},
"profile": {
"type": "string",
"default": "default",
"comment": "A resource profile for the node'"}
},
"additionalProperties": false,
"oneOf": [
Expand Down
23 changes: 23 additions & 0 deletions src/warnet/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# node resource profile presets
resource_profiles = {
"default": {
"requests": {"cpu": "500m", "memory": "500Mi"},
"limits": {"cpu": "1000m", "memory": "1500Mi"},
},
"raspberry_pi": {
"requests": {"cpu": "100m", "memory": "128Mi"},
"limits": {"cpu": "400m", "memory": "512Mi"},
},
"laptop": {
"requests": {"cpu": "500m", "memory": "1Gi"},
"limits": {"cpu": "2000m", "memory": "4Gi"},
},
"desktop": {
"requests": {"cpu": "1000m", "memory": "2Gi"},
"limits": {"cpu": "4000m", "memory": "8Gi"},
},
"server": {
"requests": {"cpu": "2000m", "memory": "4Gi"},
"limits": {"cpu": "8000m", "memory": "16Gi"},
},
}
2 changes: 2 additions & 0 deletions src/warnet/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ def __init__(self, index: int, warnet):
self.bitcoin_network = warnet.bitcoin_network
self.version: str = ""
self.image: str = ""
self.profile: str = "default"
self.bitcoin_config = ""
self.netem = None
self.exporter = False
self.metrics = None
self.collect_logs = False
self.resource_profile = "default"
self.build_args = ""
self.lnnode: LNNode | None = None
self.rpc_port = 18443
Expand Down
1 change: 1 addition & 0 deletions src/warnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def create_cycle_graph(n: int, version: str, bitcoin_conf: str | None, random_ve
graph.nodes[node]["build_args"] = ""
graph.nodes[node]["exporter"] = False
graph.nodes[node]["collect_logs"] = False
graph.nodes[node]["profile"] = "default"

convert_unsupported_attributes(graph)
return graph
Expand Down