hyperledger-labs / hyperledger-labs/fablo
Anchor peer update uses hardcoded peer0 prefix, ignores custom peer prefix config
- Dominant language
- Shell
- Stars
- 238
- Forks
- 113
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 10
Description
## Summary
`notifyOrgAboutNewChannel` and `notifyOrgAboutNewChannelTls` in `commands-generated.sh` are hardcoding `peer0.` as the peer address instead of using the `peer.prefix` from the config. Everything else in the same file handles the prefix correctly, so this one just got missed.
You can see it clearly if you run:
1. Set up a config with `"peer": { "instances": 2, "prefix": "node" }`
2. Run `fablo generate fablo-config.json`
3. Check: `grep "notifyOrgAboutNewChannel" fablo-target/fabric-docker/commands-generated.sh`
All other operations will show `node0.org1.example.com` but `notifyOrgAboutNewChannel` is still pointing at `peer0.org1.example.com`.
## Root Cause
Lines 219 and 226 in `src/setup-docker/templates/fabric-docker/commands-generated.sh` have the peer address hardcoded:
```
"peer0.<%= org.domain %>"
```
It should be `org.headPeer.address` which is already prefix-aware. `org.headPeer` is computed from the peer list in `extendOrgsConfig.ts:258` (`headPeer: peers[0]`) and the exact same pattern is already being used correctly in `chaincode-install-v2.sh` (lines 33, 66, 89, 90) and `chaincode-dev-v2.sh` (lines 11, 26, 34).
## Impact
Any network with a custom peer prefix will fail at anchor peer update. The CLI looks for `peer0.org1.example.com` which doesn't exist as a container, Docker DNS resolution fails, and the error gives no hint that the prefix config is being ignored. Took a while to track down.
## Suggested Fix
Two lines need updating in `src/setup-docker/templates/fabric-docker/commands-generated.sh`:
```diff
- "peer0.<%= org.domain %>" <% -%>
+ "<%= org.headPeer.address %>" <% -%>
```
Line 219 is the non-TLS case, line 226 is the TLS variant.
Opened PR for this fix.
Contributor guide
Assessment
This issue has not been assessed yet.