Skip to content

Commit 9de24ac

Browse files
committed
bitcoin tanks now connect to each other
1 parent 9f437e8 commit 9de24ac

File tree

8 files changed

+117
-60
lines changed

8 files changed

+117
-60
lines changed

networks/6_node_bitcoin/defaults.yaml

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
chain: regtest
2+
13
collectLogs: true
24
metricsExport: true
35

@@ -19,23 +21,5 @@ image:
1921
# Overrides the image tag whose default is the chart appVersion.
2022
tag: "27.0"
2123

22-
config: |2+
23-
regtest=1
24-
checkmempool=0
25-
acceptnonstdtxn=1
26-
debuglogfile=0
27-
logips=1
28-
logtimemicros=1
29-
capturemessages=1
30-
fallbackfee=0.00001000
31-
listen=1
32-
33-
[regtest]
34-
rpcuser=user
35-
rpcpassword=password
36-
rpcport=18443
37-
rpcallowip=0.0.0.0/0
38-
rpcbind=0.0.0.0
39-
40-
zmqpubrawblock=tcp://0.0.0.0:28332
41-
zmqpubrawtx=tcp://0.0.0.0:28333
24+
config: |
25+
dns=1

networks/6_node_bitcoin/network.yaml

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
nodes:
22
- name: tank-0001
3-
config:
4-
image:
5-
tag: "26.0"
3+
image:
4+
tag: "26.0"
5+
connect:
6+
- tank-0002
7+
- tank-0003
68
- name: tank-0002
9+
resources:
10+
limits:
11+
cpu: 100m
12+
memory: 128Mi
13+
requests:
14+
cpu: 100m
15+
memory: 128Mi
16+
connect:
17+
- tank-0003
18+
- tank-0004
719
- name: tank-0003
20+
connect:
21+
- tank-0004
22+
- tank-0005
823
- name: tank-0004
24+
connect:
25+
- tank-0005
26+
- tank-0006
927
- name: tank-0005
28+
connect:
29+
- tank-0006
30+
- tank-0007
1031
- name: tank-0006

resources/charts/bitcoincore/templates/_helpers.tpl

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ If release name contains chart name it will be used as a full name.
1414
{{- if .Values.fullnameOverride }}
1515
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1616
{{- else }}
17-
{{- $name := default .Chart.Name .Values.nameOverride }}
18-
{{- if contains $name .Release.Name }}
19-
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20-
{{- else }}
21-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22-
{{- end }}
17+
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
2318
{{- end }}
2419
{{- end }}
2520

resources/charts/bitcoincore/templates/configmap.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ metadata:
55
labels:
66
{{- include "bitcoincore.labels" . | nindent 4 }}
77
data:
8-
bitcoin-conf: |
9-
{{ tpl .Values.config . | nindent 2 }}
8+
bitcoin.conf: |
9+
{{- if eq .Values.chain "regtest" }}
10+
{{- tpl .Values.regtestConfig . | nindent 4 }}
11+
{{- end }}
12+
{{- .Values.baseConfig | nindent 4 }}
13+
{{- .Values.config | nindent 4 }}
14+
{{- range .Values.connect }}
15+
{{- print "connect=" . | nindent 4}}
16+
{{- end }}

resources/charts/bitcoincore/templates/pod.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@ spec:
2222
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
2323
imagePullPolicy: {{ .Values.image.pullPolicy }}
2424
ports:
25-
- name: http
26-
containerPort: {{ .Values.service.port }}
25+
- name: rpc
26+
containerPort: {{ .Values.regtest.RPCPort }}
27+
protocol: TCP
28+
- name: p2p
29+
containerPort: {{ .Values.regtest.P2PPort }}
30+
protocol: TCP
31+
- name: zmq-tx
32+
containerPort: {{ .Values.regtest.ZMQTxPort }}
33+
protocol: TCP
34+
- name: zmq-block
35+
containerPort: {{ .Values.regtest.ZMQBlockPort }}
2736
protocol: TCP
2837
livenessProbe:
2938
{{- toYaml .Values.livenessProbe | nindent 8 }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "bitcoincore.fullname" . }}
5+
labels:
6+
{{- include "bitcoincore.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.regtest.RPCPort }}
11+
targetPort: rpc
12+
protocol: TCP
13+
name: rpc
14+
- port: {{ .Values.regtest.P2PPort }}
15+
targetPort: p2p
16+
protocol: TCP
17+
name: p2p
18+
- port: {{ .Values.regtest.ZMQTxPort }}
19+
targetPort: zmq-tx
20+
protocol: TCP
21+
name: zmq-tx
22+
- port: {{ .Values.regtest.ZMQBlockPort }}
23+
targetPort: zmq-block
24+
protocol: TCP
25+
name: zmq-block
26+
selector:
27+
{{- include "bitcoincore.selectorLabels" . | nindent 4 }}

resources/charts/bitcoincore/values.yaml

+34-21
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ securityContext: {}
3838

3939
service:
4040
type: ClusterIP
41-
port: 80
41+
42+
regtest:
43+
RPCPort: 18443
44+
P2PPort: 18444
45+
ZMQTxPort: 28333
46+
ZMQBlockPort: 28332
4247

4348
ingress:
4449
enabled: false
@@ -107,23 +112,31 @@ tolerations: []
107112

108113
affinity: {}
109114

110-
config: |2+
111-
regtest=1
112-
checkmempool=0
113-
acceptnonstdtxn=1
114-
debuglogfile=0
115-
logips=1
116-
logtimemicros=1
117-
capturemessages=1
118-
fallbackfee=0.00001000
119-
listen=1
120-
121-
[regtest]
122-
rpcuser=user
123-
rpcpassword=password
124-
rpcport=18443
125-
rpcallowip=0.0.0.0/0
126-
rpcbind=0.0.0.0
127-
128-
zmqpubrawblock=tcp://0.0.0.0:28332
129-
zmqpubrawtx=tcp://0.0.0.0:28333
115+
chain: regtest
116+
117+
regtestConfig: |
118+
regtest=1
119+
120+
[regtest]
121+
rpcuser=user
122+
rpcpassword=password
123+
rpcport=18443
124+
rpcallowip=0.0.0.0/0
125+
rpcbind=0.0.0.0
126+
127+
baseConfig: |
128+
checkmempool=0
129+
acceptnonstdtxn=1
130+
debuglogfile=0
131+
logips=1
132+
logtimemicros=1
133+
capturemessages=1
134+
fallbackfee=0.00001000
135+
listen=1
136+
137+
zmqpubrawblock=tcp://0.0.0.0:28332
138+
zmqpubrawtx=tcp://0.0.0.0:28333
139+
140+
config: ""
141+
142+
connect: []

src/warnet/cli/network2.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66
import yaml
77

8-
from .process import run_command
8+
from .process import stream_command
99

1010
NETWORK_DIR = Path("networks")
1111
DEFAULT_NETWORK = "6_node_bitcoin"
@@ -40,7 +40,8 @@ def start2(network_name: str, logging: bool, network: str):
4040
try:
4141
temp_override_file_path = ""
4242
node_name = node.get("name")
43-
node_config_override = node.get("config")
43+
# all the keys apart from name
44+
node_config_override = {k: v for k, v in node.items() if k != "name"}
4445

4546
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {NAMESPACE} -f {defaults_file_path}"
4647

@@ -52,12 +53,12 @@ def start2(network_name: str, logging: bool, network: str):
5253
temp_override_file_path = temp_file.name
5354
cmd = f"{cmd} -f {temp_override_file_path}"
5455

55-
if not run_command(cmd, stream_output=True):
56+
if not stream_command(cmd):
5657
print(f"Failed to run Helm command: {cmd}")
5758
return
5859
except Exception as e:
5960
print(f"Error: {e}")
6061
return
61-
finally:
62-
if temp_override_file_path:
63-
Path(temp_override_file_path).unlink()
62+
# finally:
63+
# if temp_override_file_path:
64+
# Path(temp_override_file_path).unlink()

0 commit comments

Comments
 (0)