Skip to content

Commit 5cd4cfd

Browse files
committed
Attempt to run dev mode chaincode with tls
Signed-off-by: Jakub Dzikowski <jakub.t.dzikowski@gmail.com>
1 parent be5e462 commit 5cd4cfd

File tree

10 files changed

+432
-11
lines changed

10 files changed

+432
-11
lines changed

e2e-network/docker/test-01-v2-simple.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export FABLO_HOME
1010

1111
networkUp() {
1212
"$FABLO_HOME/fablo-build.sh"
13-
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" init node)
13+
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" init node dev)
1414
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up)
1515
}
1616

@@ -21,6 +21,8 @@ dumpLogs() {
2121
}
2222

2323
networkDown() {
24+
echo "type anything to continue"
25+
read -r
2426
rm -rf "$TEST_LOGS"
2527
(for name in $(docker ps --format '{{.Names}}'); do dumpLogs "$name"; done)
2628
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" down)
@@ -53,7 +55,7 @@ trap 'networkDown ; echo "Test failed" ; exit 1' ERR SIGINT
5355
networkUp
5456

5557
waitForContainer "orderer0.group1.orderer.example.com" "Created and started new.*my-channel1"
56-
waitForContainer "ca.org1.example.com" "Listening on http://0.0.0.0:7054"
58+
waitForContainer "ca.org1.example.com" "Listening on https://0.0.0.0:7054"
5759
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
5860
waitForContainer "peer1.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
5961
waitForContainer "peer0.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
@@ -62,6 +64,13 @@ waitForContainer "peer0.org1.example.com" "Membership view has changed. peers we
6264
waitForContainer "peer1.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
6365
waitForContainer "peer1.org1.example.com" "Membership view has changed. peers went online:.*peer0.org1.example.com:7041"
6466

67+
# Start chaincode in development mode
68+
cp "$FABLO_HOME/start-dev-tls.sh" "$TEST_TMP/chaincodes/chaincode-kv-node/start-dev-tls.sh"
69+
(cd "$TEST_TMP/chaincodes/chaincode-kv-node" && npm i && npm run start:dev:tls)
70+
71+
echo "Chaincode failed to start"
72+
exit 1
73+
6574
# Test simple chaincode
6675
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
6776
'{"Args":["KVContract:put", "name", "Willy Wonka"]}' \

inspect.json

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
{
2+
"Id": "1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35",
3+
"Created": "2025-10-15T20:42:09.075297711Z",
4+
"Path": "docker-entrypoint.sh",
5+
"Args": [
6+
"/bin/sh",
7+
"-c",
8+
"\nset -e\nif [ -x /chaincode/start.sh ]; then\n\t/chaincode/start.sh --peer.address peer1.org1.example.com:7050\nelse\n\tcd /usr/local/src\n\tnpm start -- --peer.address peer1.org1.example.com:7050\nfi\n"
9+
],
10+
"State": {
11+
"Status": "running",
12+
"Running": true,
13+
"Paused": false,
14+
"Restarting": false,
15+
"OOMKilled": false,
16+
"Dead": false,
17+
"Pid": 44951,
18+
"ExitCode": 0,
19+
"Error": "",
20+
"StartedAt": "2025-10-15T20:42:09.639895753Z",
21+
"FinishedAt": "0001-01-01T00:00:00Z"
22+
},
23+
"Image": "sha256:b12d900adfcfe2e747b5ce7c345e2adadc480aed18af45c4eaa55afeb67acf16",
24+
"ResolvConfPath": "/var/lib/docker/containers/1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35/resolv.conf",
25+
"HostnamePath": "/var/lib/docker/containers/1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35/hostname",
26+
"HostsPath": "/var/lib/docker/containers/1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35/hosts",
27+
"LogPath": "/var/lib/docker/containers/1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35/1305f1e8b8af8686fece6deb41020a8cf795620c64aa2503e732d308c32b6a35-json.log",
28+
"Name": "/dev-peer1.org1.example.com-my-channel1_chaincode1_0.0.1-aab33d7d10363632d349b01665ba35484f473aeb77bd1b622ee7ff3f8c97cc06",
29+
"RestartCount": 0,
30+
"Driver": "overlay2",
31+
"Platform": "linux",
32+
"MountLabel": "",
33+
"ProcessLabel": "",
34+
"AppArmorProfile": "",
35+
"ExecIDs": null,
36+
"HostConfig": {
37+
"Binds": null,
38+
"ContainerIDFile": "",
39+
"LogConfig": {
40+
"Type": "json-file",
41+
"Config": {
42+
"max-file": "5",
43+
"max-size": "50m"
44+
}
45+
},
46+
"NetworkMode": "fablo_network_202510152041_basic",
47+
"PortBindings": null,
48+
"RestartPolicy": {
49+
"Name": "",
50+
"MaximumRetryCount": 0
51+
},
52+
"AutoRemove": false,
53+
"VolumeDriver": "",
54+
"VolumesFrom": null,
55+
"CapAdd": null,
56+
"CapDrop": null,
57+
"CgroupnsMode": "private",
58+
"Dns": null,
59+
"DnsOptions": null,
60+
"DnsSearch": null,
61+
"ExtraHosts": null,
62+
"GroupAdd": null,
63+
"IpcMode": "private",
64+
"Cgroup": "",
65+
"Links": null,
66+
"OomScoreAdj": 0,
67+
"PidMode": "",
68+
"Privileged": false,
69+
"PublishAllPorts": false,
70+
"ReadonlyRootfs": false,
71+
"SecurityOpt": null,
72+
"UTSMode": "",
73+
"UsernsMode": "",
74+
"ShmSize": 67108864,
75+
"Runtime": "runc",
76+
"ConsoleSize": [
77+
0,
78+
0
79+
],
80+
"Isolation": "",
81+
"CpuShares": 0,
82+
"Memory": 2147483648,
83+
"NanoCpus": 0,
84+
"CgroupParent": "",
85+
"BlkioWeight": 0,
86+
"BlkioWeightDevice": null,
87+
"BlkioDeviceReadBps": null,
88+
"BlkioDeviceWriteBps": null,
89+
"BlkioDeviceReadIOps": null,
90+
"BlkioDeviceWriteIOps": null,
91+
"CpuPeriod": 0,
92+
"CpuQuota": 0,
93+
"CpuRealtimePeriod": 0,
94+
"CpuRealtimeRuntime": 0,
95+
"CpusetCpus": "",
96+
"CpusetMems": "",
97+
"Devices": null,
98+
"DeviceCgroupRules": null,
99+
"DeviceRequests": null,
100+
"KernelMemory": 0,
101+
"KernelMemoryTCP": 0,
102+
"MemoryReservation": 0,
103+
"MemorySwap": 4294967296,
104+
"MemorySwappiness": null,
105+
"OomKillDisable": null,
106+
"PidsLimit": null,
107+
"Ulimits": null,
108+
"CpuCount": 0,
109+
"CpuPercent": 0,
110+
"IOMaximumIOps": 0,
111+
"IOMaximumBandwidth": 0,
112+
"MaskedPaths": [
113+
"/proc/asound",
114+
"/proc/acpi",
115+
"/proc/kcore",
116+
"/proc/keys",
117+
"/proc/latency_stats",
118+
"/proc/timer_list",
119+
"/proc/timer_stats",
120+
"/proc/sched_debug",
121+
"/proc/scsi",
122+
"/sys/firmware"
123+
],
124+
"ReadonlyPaths": [
125+
"/proc/bus",
126+
"/proc/fs",
127+
"/proc/irq",
128+
"/proc/sys",
129+
"/proc/sysrq-trigger"
130+
]
131+
},
132+
"GraphDriver": {
133+
"Data": {
134+
"LowerDir": "/var/lib/docker/overlay2/6a95c348775de8014528a5a49e58552e1f3a16259e3dc788f786f71129789940-init/diff:/var/lib/docker/overlay2/be9383f6a128ffc483c72c83d5c66bc13d05c62e5ffd67af750a1c5bf0f9f85b/diff:/var/lib/docker/overlay2/8a51eb08f5c9f09ee3b0171488c96faf8874030e3c51ce5e7a548527edb814df/diff:/var/lib/docker/overlay2/eb6998f01685777afd04a8d9f2f99feacb563c4823a83b72a52b76dc20c4ce08/diff:/var/lib/docker/overlay2/ad518b9a67a16db87db6f3d1c8d3517cb42c35d909709c764d37652c5a0f523a/diff:/var/lib/docker/overlay2/0f5bfb71f252946d19c2f6563a75ecd43b588cde7ce7a252fdd4bf5d0a91db26/diff:/var/lib/docker/overlay2/69aea5601b2151f4e98cef8d6642668909d63fb7082874f03ee9a232fa3b479b/diff:/var/lib/docker/overlay2/fcef04739b9fff9b9ede15d1820ec4b6a0a86b17e9156449a83bb77f9cefd941/diff:/var/lib/docker/overlay2/863e6d7c01fb09eb3c1377f82a5d22aeb91ac0c1088611ede9c6fbd14da97594/diff",
135+
"MergedDir": "/var/lib/docker/overlay2/6a95c348775de8014528a5a49e58552e1f3a16259e3dc788f786f71129789940/merged",
136+
"UpperDir": "/var/lib/docker/overlay2/6a95c348775de8014528a5a49e58552e1f3a16259e3dc788f786f71129789940/diff",
137+
"WorkDir": "/var/lib/docker/overlay2/6a95c348775de8014528a5a49e58552e1f3a16259e3dc788f786f71129789940/work"
138+
},
139+
"Name": "overlay2"
140+
},
141+
"Mounts": [],
142+
"Config": {
143+
"Hostname": "1305f1e8b8af",
144+
"Domainname": "",
145+
"User": "",
146+
"AttachStdin": false,
147+
"AttachStdout": true,
148+
"AttachStderr": true,
149+
"Tty": false,
150+
"OpenStdin": false,
151+
"StdinOnce": false,
152+
"Env": [
153+
"CORE_CHAINCODE_ID_NAME=my-channel1_chaincode1_0.0.1:aab33d7d10363632d349b01665ba35484f473aeb77bd1b622ee7ff3f8c97cc06",
154+
"CORE_CHAINCODE_LOGGING_LEVEL=debug",
155+
"CORE_CHAINCODE_LOGGING_SHIM=debug",
156+
"CORE_CHAINCODE_LOGGING_FORMAT=%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}",
157+
"CORE_PEER_TLS_ENABLED=true",
158+
"CORE_TLS_CLIENT_KEY_PATH=/etc/hyperledger/fabric/client.key",
159+
"CORE_TLS_CLIENT_CERT_PATH=/etc/hyperledger/fabric/client.crt",
160+
"CORE_TLS_CLIENT_KEY_FILE=/etc/hyperledger/fabric/client_pem.key",
161+
"CORE_TLS_CLIENT_CERT_FILE=/etc/hyperledger/fabric/client_pem.crt",
162+
"CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/peer.crt",
163+
"CORE_PEER_LOCALMSPID=Org1MSP",
164+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
165+
"NODE_VERSION=22.12.0",
166+
"YARN_VERSION=1.22.22",
167+
"CORE_CHAINCODE_BUILDLEVEL=v2.5.12"
168+
],
169+
"Cmd": [
170+
"/bin/sh",
171+
"-c",
172+
"\nset -e\nif [ -x /chaincode/start.sh ]; then\n\t/chaincode/start.sh --peer.address peer1.org1.example.com:7050\nelse\n\tcd /usr/local/src\n\tnpm start -- --peer.address peer1.org1.example.com:7050\nfi\n"
173+
],
174+
"Image": "dev-peer1.org1.example.com-my-channel1_chaincode1_0.0.1-aab33d7d10363632d349b01665ba35484f473aeb77bd1b622ee7ff3f8c97cc06-15d8cd9ce2e9d0f3747287695d3746e7fd48157a0bda2de43abb80a125396e83",
175+
"Volumes": null,
176+
"WorkingDir": "/",
177+
"Entrypoint": [
178+
"docker-entrypoint.sh"
179+
],
180+
"OnBuild": null,
181+
"Labels": {
182+
"org.hyperledger.fabric.chaincode.type": "NODE",
183+
"org.hyperledger.fabric.version": "v2.5.12",
184+
"org.opencontainers.image.created": "2024-12-04T09:38:52.504Z",
185+
"org.opencontainers.image.description": "Hyperledger Fabric Node.js Smart Contracts",
186+
"org.opencontainers.image.licenses": "Apache-2.0",
187+
"org.opencontainers.image.revision": "b3720d0665328c8580a686b906012de3c8466c82",
188+
"org.opencontainers.image.source": "https://github.com/hyperledger/fabric-chaincode-node",
189+
"org.opencontainers.image.title": "fabric-chaincode-node",
190+
"org.opencontainers.image.url": "https://github.com/hyperledger/fabric-chaincode-node",
191+
"org.opencontainers.image.version": "2.5.8"
192+
}
193+
},
194+
"NetworkSettings": {
195+
"Bridge": "",
196+
"SandboxID": "d2f9ee3390f6cf92b8df9e151a832301584b49e98a2ee9c9f03c215b8b6c8b7a",
197+
"HairpinMode": false,
198+
"LinkLocalIPv6Address": "",
199+
"LinkLocalIPv6PrefixLen": 0,
200+
"Ports": {},
201+
"SandboxKey": "/var/run/docker/netns/d2f9ee3390f6",
202+
"SecondaryIPAddresses": null,
203+
"SecondaryIPv6Addresses": null,
204+
"EndpointID": "",
205+
"Gateway": "",
206+
"GlobalIPv6Address": "",
207+
"GlobalIPv6PrefixLen": 0,
208+
"IPAddress": "",
209+
"IPPrefixLen": 0,
210+
"IPv6Gateway": "",
211+
"MacAddress": "",
212+
"Networks": {
213+
"fablo_network_202510152041_basic": {
214+
"IPAMConfig": null,
215+
"Links": null,
216+
"Aliases": [
217+
"1305f1e8b8af"
218+
],
219+
"NetworkID": "830ae2e5aafa0afb66dc6e2a332f143926326dbdbf422ad50477d9206d429090",
220+
"EndpointID": "d7b920249955721988b31203a667489b689ee151c9714c7a1c2ea38c79a3ebca",
221+
"Gateway": "192.168.80.1",
222+
"IPAddress": "192.168.80.10",
223+
"IPPrefixLen": 20,
224+
"IPv6Gateway": "",
225+
"GlobalIPv6Address": "",
226+
"GlobalIPv6PrefixLen": 0,
227+
"MacAddress": "02:42:c0:a8:50:0a",
228+
"DriverOpts": null
229+
}
230+
}
231+
}
232+
}

samples/chaincodes/chaincode-kv-node/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"scripts": {
1010
"start": "fabric-chaincode-node start",
1111
"start:ccaas": "fabric-chaincode-node server --chaincode-address 0.0.0.0:7052 --chaincode-id \"$CHAINCODE_ID\"",
12-
"start:dev": "fabric-chaincode-node start --peer.address \"127.0.0.1:8541\" --chaincode-id-name \"chaincode1:0.0.1\" --tls.enabled false",
12+
"start:dev": "fabric-chaincode-node start --peer.address \"127.0.0.1:8541\" --chaincode-id \"$CHAINCODE_ID\" --tls.enabled false",
13+
"start:dev:tls": "./start-dev-tls.sh",
1314
"start:watch": "nodemon --exec \"npm run start:dev\"",
1415
"build": "echo \"No need to build the chaincode\"",
1516
"lint": "eslint . --fix --ext .js"

src/init/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ function getDefaultFabloConfig(): FabloConfigJson {
88
$schema: `https://github.com/hyperledger-labs/fablo/releases/download/${version}/schema.json`,
99
global: {
1010
fabricVersion: "2.5.12",
11-
tls: false,
12-
peerDevMode: false,
11+
tls: true,
12+
peerDevMode: true,
13+
monitoring: {
14+
loglevel: "debug",
15+
},
1316
},
1417
orgs: [
1518
{
@@ -79,6 +82,10 @@ export default class InitGenerator extends Generator {
7982
super(args, opts);
8083
}
8184

85+
async writing(): Promise<void> {
86+
await this.copySampleConfig();
87+
}
88+
8289
async copySampleConfig(): Promise<void> {
8390
let fabloConfigJson = getDefaultFabloConfig();
8491

src/setup-docker/templates/fabric-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -eu
3+
set -eux
44

55
FABLO_NETWORK_ROOT="$(cd "$(dirname "$0")" && pwd)"
66

src/setup-docker/templates/fabric-docker/commands-generated.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ installChaincodes() {
126126
<% chaincodes.forEach((chaincode) => { -%>
127127
if [ -n "$(ls "$CHAINCODES_BASE_DIR/<%= chaincode.directory %>")" ]; then
128128
<% if (global.peerDevMode) { -%>
129-
<%- include('commands-generated/chaincode-dev-v2.sh', { chaincode }); -%>
129+
<%- include('commands-generated/chaincode-dev-v2.sh', { chaincode, global }); -%>
130130
<% } else { -%>
131131
local version="<%= chaincode.version %>"
132132
<%- include('commands-generated/chaincode-install-v2.sh', { chaincode, global }); -%>

src/setup-docker/templates/fabric-docker/commands-generated/chaincode-dev-v2.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
*/-%>
77
<% chaincode.channel.orgs.forEach((org) => { -%>
88
printHeadline "Approving '<%= chaincode.name %>' for <%= org.name %> (dev mode)" "U1F60E"
9+
<% if (global.tls) { -%>
10+
echo "Generating chaincode dev certificates for <%= chaincode.name %>..."
11+
echo "FABLO_NETWORK_ROOT: $FABLO_NETWORK_ROOT"
12+
certsGenerateCCaaS "$FABLO_NETWORK_ROOT/fabric-config/crypto-config/" "<%= chaincode.name %>" "<%= org.domain %>" "<%= chaincode.name %>" "<%= org.headPeer.fullAddress %>"
13+
<% } -%>
914
chaincodeApprove <% -%>
1015
"<%= org.cli.address %>" <% -%>
1116
"<%= org.headPeer.fullAddress %>" <% -%>
@@ -15,7 +20,7 @@
1520
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
1621
"<%- chaincode.endorsement || '' %>" <% -%>
1722
"false" <% -%>
18-
"" <% -%>
23+
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
1924
"<%= chaincode.privateDataConfigFile || '' %>" <% -%>
2025
"" <% -%>
2126
""
@@ -30,7 +35,7 @@ chaincodeCommit <% -%>
3035
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
3136
"<%- chaincode.endorsement || '' %>" <% -%>
3237
"false" <% -%>
33-
"" <% -%>
38+
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
3439
"<%= chaincode.channel.orgs.map((o) => o.headPeer.fullAddress).join(',') %>" <% -%>
35-
"" <% -%>
40+
"<%= !global.tls ? '' : chaincode.channel.orgs.map(o => `crypto-peer/${o.headPeer.address}/tls/ca.crt`).join(',') %>" <% -%>
3641
"<%= chaincode.privateDataConfigFile || '' %>"

src/validate/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class ValidateGenerator extends Generator {
146146
this._validateChaincodes(capabilities, networkConfig.chaincodes);
147147
this._validateExplorer(networkConfig.global, networkConfig.orgs);
148148
this._validateExplorerWithFabricVersion(networkConfig.global, networkConfig.orgs);
149-
this._validateDevMode(networkConfig.global);
149+
// this._validateDevMode(networkConfig.global);
150150
this._verifyFabricVersion(networkConfig.global);
151151
}
152152

0 commit comments

Comments
 (0)