Skip to content

Commit f1d7b39

Browse files
committed
revert -lnd changes based on comments
reverse LN_10.json sequence change
1 parent 6355e85 commit f1d7b39

File tree

10 files changed

+43
-40
lines changed

10 files changed

+43
-40
lines changed

docs/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ plugins:
3434
postDeploy: # Plugins will run after all the `deploy` code has run.
3535
simln:
3636
entrypoint: "../plugins/simln"
37-
activity: '[{"source": "tank-0003-lnd", "destination": "tank-0005-cln", "interval_secs": 1, "amount_msat": 2000}]'
37+
activity: '[{"source": "tank-0003-ln", "destination": "tank-0005-ln", "interval_secs": 1, "amount_msat": 2000}]'
3838
hello:
3939
entrypoint: "../plugins/hello"
4040
podName: "hello-post-deploy"

resources/plugins/hello/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ nodes:
6262
- id:
6363
block: 300
6464
index: 1
65-
target: tank-0004-lnd
65+
target: tank-0004-ln
6666
capacity: 100000
6767
push_amt: 50000
6868

@@ -76,7 +76,7 @@ nodes:
7676
- id:
7777
block: 300
7878
index: 2
79-
target: tank-0005-lnd
79+
target: tank-0005-ln
8080
capacity: 50000
8181
push_amt: 25000
8282

@@ -99,7 +99,7 @@ plugins: # Each plugin section has a number of hooks available (preDeploy, post
9999
helloTo: "postDeploy!"
100100
simln: # You can have multiple plugins per hook
101101
entrypoint: "../../plugins/simln"
102-
activity: '[{"source": "tank-0003-lnd", "destination": "tank-0005-lnd", "interval_secs": 1, "amount_msat": 2000}]'
102+
activity: '[{"source": "tank-0003-ln", "destination": "tank-0005-ln", "interval_secs": 1, "amount_msat": 2000}]'
103103
preNode: # preNode plugins run before each node is deployed
104104
hello:
105105
entrypoint: "../../plugins/hello"

resources/scenarios/commander.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@
7070
)
7171

7272
if pod.metadata.labels["mission"] == "lightning":
73-
WARNET["lightning"].append(pod.metadata.name)
73+
lnnode = LND(pod.metadata.name)
74+
if "cln" in pod.metadata.labels["app.kubernetes.io/name"]:
75+
lnnode = CLN(pod.metadata.name)
76+
WARNET["lightning"].append(lnnode)
7477

7578
for cm in cmaps.items:
7679
if not cm.metadata.labels or "channels" not in cm.metadata.labels:
@@ -225,11 +228,8 @@ def setup(self):
225228
self.tanks[tank["tank"]] = node
226229

227230
for ln in WARNET["lightning"]:
228-
# create the correct implementation based on pod name
229-
if "-cln" in ln:
230-
self.lns[ln] = CLN(ln, self.log)
231-
else:
232-
self.lns[ln] = LND(ln, self.log)
231+
ln.setLogger(self.log)
232+
self.lns[ln.name] = ln
233233

234234
self.num_nodes = len(self.nodes)
235235

resources/scenarios/ln_framework/ln.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ def to_lnd_chanpolicy(self, capacity):
112112

113113
class LNNode(ABC):
114114
@abstractmethod
115-
def __init__(self, pod_name, logger):
116-
self.log = logger
115+
def __init__(self, pod_name):
116+
self.log = None
117117
self.name = pod_name
118118

119+
def setLogger(self, logger):
120+
self.log = logger
121+
119122
@staticmethod
120123
def param_dict_to_list(params: dict) -> list[str]:
121124
return [f"{k}={v}" for k, v in params.items()]
@@ -161,8 +164,8 @@ def update(self, txid_hex: str, policy: dict, capacity: int) -> dict:
161164

162165

163166
class CLN(LNNode):
164-
def __init__(self, pod_name, logger):
165-
super().__init__(pod_name, logger)
167+
def __init__(self, pod_name):
168+
super().__init__(pod_name)
166169
self.headers = {}
167170
self.impl = "cln"
168171

@@ -326,8 +329,8 @@ def update(self, txid_hex: str, policy: dict, capacity: int, max_tries=2) -> dic
326329

327330

328331
class LND(LNNode):
329-
def __init__(self, pod_name, logger):
330-
super().__init__(pod_name, logger)
332+
def __init__(self, pod_name):
333+
super().__init__(pod_name)
331334
self.conn = http.client.HTTPSConnection(
332335
host=pod_name, port=8080, timeout=5, context=INSECURE_CONTEXT
333336
)

src/warnet/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _import_network(graph_file_path, output_path):
269269
source = pk_to_tank[edge["node1_pub"]]
270270
channel = {
271271
"id": {"block": block, "index": index},
272-
"target": pk_to_tank[edge["node2_pub"]] + "-lnd",
272+
"target": pk_to_tank[edge["node2_pub"]] + "-ln",
273273
"capacity": int(edge["capacity"]),
274274
"push_amt": int(edge["capacity"]) // 2,
275275
"source_policy": Policy.from_lnd_describegraph(edge["node1_policy"]).to_dict(),

test/data/LN_10.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@
987987
{
988988
"node1_pub": "02b705ad9fff5b30e69dd3810d100372332c1a750db5a50edf7353c77ab486643e",
989989
"node2_pub": "037659a0ac8eb3b8d0a720114efc861d3a940382dcfa1403746b4f8f6b2e8810ba",
990-
"channel_id": "908655100992880641",
990+
"channel_id": "891818279431438336",
991991
"chan_point": "316bc4974bc4382554b80ba30eaaecf18c3f45f03fed41f99e9600d1c5dd3029:0",
992992
"last_update": 1710800025,
993993
"capacity": "2000000",
@@ -1016,7 +1016,7 @@
10161016
{
10171017
"node1_pub": "02b705ad9fff5b30e69dd3810d100372332c1a750db5a50edf7353c77ab486643e",
10181018
"node2_pub": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
1019-
"channel_id": "891818279431438336",
1019+
"channel_id": "908655100992880641",
10201020
"chan_point": "0acfd2470db4eb06268b3f22b4c45c0fdcc11d10b6519577662e54823a0f264e:1",
10211021
"last_update": 1710841427,
10221022
"capacity": "10000000",

test/data/ln/network.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nodes:
1818
- id:
1919
block: 300
2020
index: 1
21-
target: tank-0004-lnd
21+
target: tank-0004-ln
2222
capacity: 100000
2323
push_amt: 50000
2424
- name: tank-0004
@@ -29,7 +29,7 @@ nodes:
2929
- id:
3030
block: 300
3131
index: 2
32-
target: tank-0005-lnd
32+
target: tank-0005-ln
3333
capacity: 50000
3434
push_amt: 25000
3535
- name: tank-0005

test/data/ln_mixed/network.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ nodes:
99
- id:
1010
block: 300
1111
index: 4
12-
target: tank-0003-lnd
12+
target: tank-0003-ln
1313
capacity: 50001
1414
push_amt: 25003
1515
- name: tank-0002
@@ -22,7 +22,7 @@ nodes:
2222
- id:
2323
block: 300
2424
index: 5
25-
target: tank-0001-cln
25+
target: tank-0001-ln
2626
capacity: 50002
2727
push_amt: 25001
2828
- name: tank-0003
@@ -35,7 +35,7 @@ nodes:
3535
- id:
3636
block: 300
3737
index: 1
38-
target: tank-0004-lnd
38+
target: tank-0004-ln
3939
capacity: 100003
4040
push_amt: 50004
4141
- name: tank-0004
@@ -48,7 +48,7 @@ nodes:
4848
- id:
4949
block: 300
5050
index: 2
51-
target: tank-0005-lnd
51+
target: tank-0005-ln
5252
capacity: 50004
5353
push_amt: 25005
5454
- name: tank-0005
@@ -61,6 +61,6 @@ nodes:
6161
- id:
6262
block: 300
6363
index: 3
64-
target: tank-0002-cln
64+
target: tank-0002-ln
6565
capacity: 100005
6666
push_amt: 50002

test/ln_mixed_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def __init__(self):
1717
self.network_dir = Path(os.path.dirname(__file__)) / "data" / "ln_mixed"
1818
self.scen_dir = Path(os.path.dirname(__file__)).parent / "resources" / "scenarios"
1919
self.lns = [
20-
CLN("tank-0001-cln", self.log),
21-
CLN("tank-0002-cln", self.log),
22-
LND("tank-0003-lnd", self.log),
23-
LND("tank-0004-lnd", self.log),
24-
LND("tank-0005-lnd", self.log),
20+
CLN("tank-0001-ln"),
21+
CLN("tank-0002-ln"),
22+
LND("tank-0003-ln"),
23+
LND("tank-0004-ln"),
24+
LND("tank-0005-ln"),
2525
]
2626

2727
def node(self, name: str) -> LNNode:
@@ -39,15 +39,15 @@ def run_test(self):
3939
f"{self.lns[0]} has does not have a wallet balance"
4040
)
4141
# Send a payment across channels opened automatically by ln_init
42-
self.pay_invoice_rpc(sender="tank-0003-lnd", recipient="tank-0001-cln")
43-
# self.pay_invoice_node(sender="tank-0001-cln", recipient="tank-0003-lnd")
42+
self.pay_invoice_rpc(sender="tank-0003-ln", recipient="tank-0001-ln")
43+
# self.pay_invoice_node(sender="tank-0001-ln", recipient="tank-0003-ln")
4444

4545
# Manually open more channels between first three nodes
4646
# and send a payment using warnet RPC
4747
self.manual_open_channels()
4848
# FIXME: need to decide how to interact with LND via REST outside cluster
4949
# self.wait_for_gossip_sync(self.lns, 5)
50-
# self.pay_invoice(sender="tank-0004-lnd", recipient="tank-0002-cln")
50+
# self.pay_invoice(sender="tank-0004-ln", recipient="tank-0002-ln")
5151

5252
finally:
5353
self.cleanup()
@@ -63,13 +63,13 @@ def wait_for_txs(self, count):
6363

6464
def manual_open_channels(self):
6565
# 1 -> 4
66-
pk1 = self.warnet("ln pubkey tank-0004-lnd") # prefer -> self.node("tank-0004-lnd").uri()
67-
channel = self.node("tank-0001-cln").channel(pk1, 444444, 200000, 5000)
66+
pk1 = self.warnet("ln pubkey tank-0004-ln") # prefer -> self.node("tank-0004-ln").uri()
67+
channel = self.node("tank-0001-ln").channel(pk1, 444444, 200000, 5000)
6868
assert "txid" in channel, "Failed to create channel between CLN and LND"
6969
self.log.info(f"Channel txid {channel['txid']}")
7070

7171
# 4 -> 2
72-
# channel = self.node("tank-0004-lnd").channel(
72+
# channel = self.node("tank-0004-ln").channel(
7373
# self.lns[1].uri(), 333333, 150000, 5000
7474
# )
7575
# assert "txid" in channel, "Failed to create channel between LND and CLN"

test/ln_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_channel_policies(self):
4343
self.log.info("Ensuring node-level channel policy settings")
4444
graphs = []
4545
for n in range(10):
46-
ln = f"tank-{n:04d}-lnd"
46+
ln = f"tank-{n:04d}-ln"
4747
res = self.warnet(f"ln rpc {ln} describegraph")
4848
graphs.append(json.loads(res)["edges"])
4949

@@ -73,8 +73,8 @@ def check_policy(node: int, index: int, field: str, values: tuple):
7373

7474
def test_payments(self):
7575
def get_and_pay(src, tgt):
76-
src = f"tank-{src:04d}-lnd"
77-
tgt = f"tank-{tgt:04d}-lnd"
76+
src = f"tank-{src:04d}-ln"
77+
tgt = f"tank-{tgt:04d}-ln"
7878
invoice = json.loads(self.warnet(f"ln rpc {tgt} addinvoice --amt 230118"))[
7979
"payment_request"
8080
]

0 commit comments

Comments
 (0)