fix(dashmate)!: differentiate service ports between networks to avoid conflicts#3085
fix(dashmate)!: differentiate service ports between networks to avoid conflicts#3085
Conversation
📝 WalkthroughWalkthroughAdds per-network (local/testnet) port entries across configs and docs and implements migration-time port remapping for local/testnet to avoid shared-port conflicts when multiple networks run on the same host. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3a5d2b0 to
7ee6419
Compare
Multiple services shared identical default ports across mainnet, testnet, and local networks, causing port binding failures when running multiple networks on the same machine. Assign unique ports per network for all 9 affected services (Dashmate Helper, Core Insight, Gateway Metrics/Admin, Rate Limiter Metrics, Quorum List API, Drive Tokio Console/Metrics/GroveDB Visualizer) and add config migration with cloneDeep to avoid shared reference mutation from earlier migrations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7ee6419 to
acefa21
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/dashmate/configs/getConfigFileMigrationsFactory.js`:
- Around line 1413-1414: The detection for local/testnet uses both
options.network and name (isLocal/isTestnet) but
getDefaultConfigByNetwork(options.network) ignores name; update the logic so the
network passed to getDefaultConfigByNetwork reflects the inferred network from
name when options.network is not set or mismatches (e.g., derive const
resolvedNetwork = isLocal ? NETWORK_LOCAL : isTestnet ? NETWORK_TESTNET :
options.network and call getDefaultConfigByNetwork(resolvedNetwork)), ensuring
functions/variables referenced include isLocal, isTestnet, name,
options.network, and getDefaultConfigByNetwork so the default config chosen
matches the earlier detection.
🧹 Nitpick comments (1)
packages/dashmate/docs/services/index.md (1)
78-78: Port documentation is comprehensive and conflict-free.The localhost-only services table correctly documents all per-network port assignments. Verification confirms:
- No port conflicts within any single network preset (mainnet/testnet/local)
- All ports consistent with PR summary and other documentation files
- Core ZMQ port references align with configuration documentation
💡 Optional: Consider improving table readability
Line 78 is over 600 characters long, which may affect maintainability. Consider reformatting the localhost-only row into a multi-line table entry or breaking it into sub-rows by service category for easier maintenance:
| **Localhost-only** | Core RPC (9998)<br>Insight UI (3001 mainnet / 13001 testnet / 23001 local) | 127.0.0.1 (local) | | | Dashmate Helper (9100 mainnet / 19100 testnet / 29100 local) | " | | | Platform metrics & admin endpoints... | " |However, the current format works correctly and is a minor style preference.
Also applies to: 83-84
| const isLocal = options.network === NETWORK_LOCAL || name === 'local'; | ||
| const isTestnet = options.network === NETWORK_TESTNET || name === 'testnet'; |
There was a problem hiding this comment.
Potential mismatch between isLocal/isTestnet detection and getDefaultConfigByNetwork.
Lines 1413–1414 detect local/testnet by name or network, but line 1437 resolves the default config using only options.network. If a config has name === 'local' but options.network is not NETWORK_LOCAL (e.g., a misconfigured or legacy config), getDefaultConfigByNetwork falls back to 'base', and the migration would overwrite the port with the base default instead of the local one — effectively a no-op or worse, a silent mismatch.
Consider also checking name when resolving the network config, consistent with lines 1413–1414:
Suggested fix
- const networkConfig = getDefaultConfigByNetwork(options.network);
+ let effectiveNetwork = options.network;
+ if (name === 'local') effectiveNetwork = NETWORK_LOCAL;
+ else if (name === 'testnet') effectiveNetwork = NETWORK_TESTNET;
+ const networkConfig = getDefaultConfigByNetwork(effectiveNetwork);Also applies to: 1437-1437
🤖 Prompt for AI Agents
In `@packages/dashmate/configs/getConfigFileMigrationsFactory.js` around lines
1413 - 1414, The detection for local/testnet uses both options.network and name
(isLocal/isTestnet) but getDefaultConfigByNetwork(options.network) ignores name;
update the logic so the network passed to getDefaultConfigByNetwork reflects the
inferred network from name when options.network is not set or mismatches (e.g.,
derive const resolvedNetwork = isLocal ? NETWORK_LOCAL : isTestnet ?
NETWORK_TESTNET : options.network and call
getDefaultConfigByNetwork(resolvedNetwork)), ensuring functions/variables
referenced include isLocal, isTestnet, name, options.network, and
getDefaultConfigByNetwork so the default config chosen matches the earlier
detection.
Issue being fixed or feature implemented
Fixes #3002 — running both mainnet and testnet dashmate nodes on the same machine caused port binding failures because several services shared identical default port numbers across all network presets.
What was done?
Differentiated default ports for 9 services between mainnet, testnet, and local presets so multiple networks can coexist on the same host without port conflicts.
Changed default ports
core.insight.portdashmate.helper.api.portplatform.gateway.metrics.portplatform.gateway.admin.portplatform.gateway.rateLimiter.metrics.portplatform.quorumList.api.portplatform.drive.abci.tokioConsole.portplatform.drive.abci.metrics.portplatform.drive.abci.grovedbVisualizer.portMainnet ports remain unchanged (inherited from base config). Testnet and local presets get unique port offsets.
Changes:
getTestnetConfigFactory.jsandgetLocalConfigFactory.jswith unique ports per servicegetConfigFileMigrationsFactory.js(v3.1.0 migration) — only updates ports that still match the old base defaults, preserving any custom overridesHow Has This Been Tested?
Breaking Changes
Default ports for 9 services now differ between mainnet, testnet, and local presets. This may affect:
Existing dashmate configs are migrated automatically — ports that still match the old base defaults are updated to the new network-specific values. Custom port overrides are preserved.
Checklist:
Summary by CodeRabbit
New Features
Documentation