Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data:
bitcoin-rpcconnect={{ include "bitcoincore.fullname" . }}
bitcoin-rpcport={{ index .Values.global .Values.global.chain "RPCPort" }}
bitcoin-rpcpassword={{ .Values.global.rpcpassword }}
alias={{ include "cln.fullname" . }}
alias={{ include "cln.fullname" . }}.{{ .Release.Namespace }}
announce-addr=dns:{{ include "cln.fullname" . }}:{{ .Values.P2PPort }}
database-upgrade=true
bitcoin-retry-timeout=600
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create a hex-encoded RGB color derived from the namespace
*/}}
{{- define "namespace.color" -}}
{{- $hash := sha256sum .Release.Namespace -}}
{{- printf "#%s" (substr 0 6 $hash) -}}
{{- end -}}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ data:
bitcoind.rpchost={{ include "bitcoincore.fullname" . }}:{{ index .Values.global .Values.global.chain "RPCPort" }}
bitcoind.zmqpubrawblock=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQBlockPort }}
bitcoind.zmqpubrawtx=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQTxPort }}
alias={{ include "lnd.fullname" . }}
alias={{ include "lnd.fullname" . }}.{{ .Release.Namespace }}
color={{ include "namespace.color" . }}
externalhosts={{ include "lnd.fullname" . }}
tlsextradomain={{ include "lnd.fullname" . }}
tls.cert: |
Expand Down
8 changes: 6 additions & 2 deletions resources/scenarios/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
WARNET["tanks"].append(
{
"tank": pod.metadata.name,
"namespace": pod.metadata.namespace,
"chain": pod.metadata.labels["chain"],
"rpc_host": pod.status.pod_ip,
"rpc_port": int(pod.metadata.labels["RPCPort"]),
Expand All @@ -104,10 +105,13 @@
if pod.metadata.labels["mission"] == "lightning":
if "lnd" in pod.metadata.labels["app.kubernetes.io/name"]:
lnnode = LND(
pod.metadata.name, pod.status.pod_ip, pod.metadata.annotations["adminMacaroon"]
pod.metadata.name,
pod.metadata.namespace,
pod.status.pod_ip,
pod.metadata.annotations["adminMacaroon"],
)
if "cln" in pod.metadata.labels["app.kubernetes.io/name"]:
lnnode = CLN(pod.metadata.name, pod.status.pod_ip)
lnnode = CLN(pod.metadata.name, pod.metadata.namespace, pod.status.pod_ip)
assert lnnode
WARNET["lightning"].append(lnnode)

Expand Down
19 changes: 9 additions & 10 deletions resources/scenarios/ln_framework/ln.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def to_lnd_chanpolicy(self, capacity):

class LNNode(ABC):
@abstractmethod
def __init__(self, pod_name, ip_address):
def __init__(self, pod_name, pod_namespace, ip_address):
self.name = pod_name
self.namespace = pod_namespace
self.ip_address = ip_address
self.log = logging.getLogger(pod_name)
handler = logging.StreamHandler()
Expand Down Expand Up @@ -152,16 +153,16 @@ def update(self, txid_hex: str, policy: dict, capacity: int) -> dict:


class CLN(LNNode):
def __init__(self, pod_name, ip_address):
super().__init__(pod_name, ip_address)
def __init__(self, pod_name, pod_namespace, ip_address):
super().__init__(pod_name, pod_namespace, ip_address)
self.conn = None
self.headers = {}
self.impl = "cln"
self.reset_connection()

def reset_connection(self):
self.conn = http.client.HTTPSConnection(
host=self.name, port=3010, timeout=60, context=INSECURE_CONTEXT
host=f"{self.name}.{self.namespace}", port=3010, timeout=60, context=INSECURE_CONTEXT
)

def setRune(self, rune):
Expand Down Expand Up @@ -285,11 +286,9 @@ def update(self, txid_hex: str, policy: dict, capacity: int) -> dict:


class LND(LNNode):
def __init__(self, pod_name, ip_address, admin_macaroon_hex):
super().__init__(pod_name, ip_address)
self.conn = http.client.HTTPSConnection(
host=pod_name, port=8080, timeout=5, context=INSECURE_CONTEXT
)
def __init__(self, pod_name, pod_namespace, ip_address, admin_macaroon_hex):
super().__init__(pod_name, pod_namespace, ip_address)
self.conn = None
self.admin_macaroon_hex = admin_macaroon_hex
self.headers = {
"Grpc-Metadata-macaroon": admin_macaroon_hex,
Expand All @@ -299,7 +298,7 @@ def __init__(self, pod_name, ip_address, admin_macaroon_hex):

def reset_connection(self):
self.conn = http.client.HTTPSConnection(
host=self.name, port=8080, timeout=60, context=INSECURE_CONTEXT
host=f"{self.name}.{self.namespace}", port=8080, timeout=60, context=INSECURE_CONTEXT
)

def get(self, uri):
Expand Down
2 changes: 1 addition & 1 deletion src/warnet/ln.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def rpc(pod: str, method: str, params: str, namespace: Optional[str]):


def _rpc(pod_name: str, method: str, params: str = "", namespace: Optional[str] = None):
pod = get_pod(pod_name)
namespace = get_default_namespace_or(namespace)
pod = get_pod(pod_name, namespace)
chain = pod.metadata.labels["chain"]
ln_client = "lncli"
if "cln" in pod.metadata.labels["app.kubernetes.io/name"]:
Expand Down
4 changes: 2 additions & 2 deletions test/ln_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def test_admin_macaroons(self):
info = json.loads(
self.warnet("ln rpc tank-0001-ln --rpcserver=tank-0002-ln.default:10009 getinfo")
)
assert info["alias"] == "tank-0002-ln"
assert info["alias"] == "tank-0002-ln.default"
info = json.loads(
self.warnet("ln rpc tank-0002-ln --rpcserver=tank-0005-ln.default:10009 getinfo")
)
assert info["alias"] == "tank-0005-ln"
assert info["alias"] == "tank-0005-ln.default"

self.log.info("Testing lnd nodes with unique macaroon root key can NOT query each other")
# These tanks are configured with unique macaroon root keys
Expand Down
Loading