Skip to content

Commit a99b4d2

Browse files
committed
har- code node-defaults values and remove the need for extra yaml file
1 parent c9dcc86 commit a99b4d2

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

resources/networks/fork_observer/node-defaults.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/warnet/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class AnnexMember(Enum):
4848

4949
PLUGIN_ANNEX = "annex"
5050

51+
DEFAULT_IMAGE_REPO="bitcoindevproject/bitcoin"
52+
53+
# Bitcoin Core config
54+
FORK_OBSERVER_RPCAUTH="forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c"
55+
# Fork Observer config
56+
FORK_OBSERVER_RPC_USER="forkobserver"
57+
FORK_OBSERVER_RPC_PASSWORD="tabconf2024"
5158

5259
# Directories and files for non-python assets, e.g., helm charts, example scenarios, default configs
5360
SRC_DIR = files("warnet")

src/warnet/deploy.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
AnnexMember,
3030
HookValue,
3131
WarnetContent,
32+
FORK_OBSERVER_RPC_USER,
33+
FORK_OBSERVER_RPC_PASSWORD,
3234
)
3335
from .control import _logs, _run
3436
from .k8s import (
@@ -331,8 +333,8 @@ def deploy_fork_observer(directory: Path, debug: bool) -> bool:
331333
description = "{node_name}.{default_namespace}.svc:{int(p2pport)}"
332334
rpc_host = "{node_name}.{default_namespace}.svc"
333335
rpc_port = {int(rpcport)}
334-
rpc_user = "forkobserver"
335-
rpc_password = "tabconf2024"
336+
rpc_user = "{FORK_OBSERVER_RPC_USER}"
337+
rpc_password = "{FORK_OBSERVER_RPC_PASSWORD}"
336338
"""
337339

338340
override_string += node_config

src/warnet/graph.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
import random
44
import sys
5-
from importlib.resources import files
65
from pathlib import Path
76

87
import click
@@ -11,7 +10,12 @@
1110

1211
from resources.scenarios.ln_framework.ln import Policy
1312

14-
from .constants import DEFAULT_TAG, SUPPORTED_TAGS
13+
from .constants import (
14+
DEFAULT_TAG,
15+
SUPPORTED_TAGS,
16+
FORK_OBSERVER_RPCAUTH,
17+
DEFAULT_IMAGE_REPO,
18+
)
1519

1620

1721
@click.group(name="graph", hidden=True)
@@ -41,7 +45,7 @@ def custom_graph(
4145
connections = set()
4246

4347
for i in range(num_nodes):
44-
node = {"name": f"tank-{i:04d}", "addnode": [], "image": {"tag": version}}
48+
node = {"name": f"tank-{i:04d}", "addnode": []}
4549

4650
# Add round-robin connection
4751
next_node = (i + 1) % num_nodes
@@ -77,11 +81,19 @@ def custom_graph(
7781
yaml.dump(network_yaml_data, f, default_flow_style=False)
7882

7983
# Generate node-defaults.yaml
80-
default_yaml_path = (
81-
files("resources.networks").joinpath("fork_observer").joinpath("node-defaults.yaml")
82-
)
83-
with open(str(default_yaml_path)) as f:
84-
defaults_yaml_content = yaml.safe_load(f)
84+
defaults_yaml_content = {
85+
"chain": "regtest",
86+
"image": {
87+
"repository": DEFAULT_IMAGE_REPO,
88+
"pullPolicy": "IfNotPresent",
89+
"tag": version
90+
},
91+
"defaultConfig":
92+
f"rpcauth={FORK_OBSERVER_RPCAUTH}\n" +
93+
"rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n" +
94+
"rpcwhitelistdefault=0\n" +
95+
"debug=rpc\n"
96+
}
8597

8698
# Configure logging
8799
defaults_yaml_content["collectLogs"] = logging

0 commit comments

Comments
 (0)