Skip to content

Conversation

@lklimek
Copy link
Contributor

@lklimek lklimek commented Oct 27, 2025

Issue being fixed or feature implemented

When an user has both testnet and mainnet (or testnet and local) on the same host, there is a port conflict.
Dashmate reports message like this:

[FAILED] Error response from daemon: driver failed programming external connectivity on endpoint dashmate_XXXXXXXX_testnet-rs_dapi-1  Bind for 127.0.0.1:9091 failed: port is already allocated

What was done?

  1. Added platform.dapi.rsDapi.metrics.enabled flag that defaults to false, to disable metrics for people who don't need them.
  2. Adjusted default ports for zmq and rs-dapi metrics.

How Has This Been Tested?

NOT TESTED YET

Breaking Changes

ZMQ port

ZMQ port was changed:

  • mainnet: 29998
  • testnet: 39998
  • local: 49998

RS-Dapi metrics

Previously metrics were enabled by default. Now they are disabled by default.

To enable, dashmate config set platform.dapi.rsDapi.metrics.enabled true

RS-DAPI metrics port was changed:

  • mainnet: 9091
  • testnet: 19091
  • local: 29091

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Per-environment default ports for ZMQ and rs‑dapi metrics (mainnet/testnet/local) and an option to disable rs‑dapi metrics.
  • Documentation

    • Docs updated to list per-network port presets and guidance on avoiding port conflicts and ZMQ exposure risks.
  • Chores

    • Migration added to normalize existing configs to the new ZMQ/metrics defaults while preserving custom ports.
  • Bug Fixes

    • Removed automatic exposure of rs‑dapi metrics in the compose setup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Walkthrough

Adds network-specific default ports for ZMQ and rs-dapi metrics, an explicit metrics.enabled flag, a migration to backfill/normalize configs, Docker compose removal of rs_dapi metrics exposure, a schema refactor for metrics, and env logic to zero the metrics port when disabled.

Changes

Cohort / File(s) Summary
Configuration Defaults
packages/dashmate/configs/defaults/getBaseConfigFactory.js, packages/dashmate/configs/defaults/getLocalConfigFactory.js, packages/dashmate/configs/defaults/getTestnetConfigFactory.js
Adds platform.dapi.rsDapi.metrics.enabled and per-preset defaults: core.zmq.port (mainnet 29998, testnet 39998, local 49998) and platform.dapi.rsDapi.metrics.port (mainnet 9091, testnet 19091, local 29091).
Configuration Migration
packages/dashmate/configs/getConfigFileMigrationsFactory.js
Adds migration 2.2.0-dev.1 that ensures platform.dapi.rsDapi, rsDapi.metrics, and core.zmq exist for each config, backfills ports from defaults when appropriate, and sets default metrics.enabled when undefined while preserving customized ports.
Docker & Env generation
packages/dashmate/docker-compose.yml, packages/dashmate/src/config/generateEnvsFactory.js
Removes rs_dapi metrics exposure/port mapping from docker-compose.yml. Adds logic to set PLATFORM_DAPI_RS_DAPI_METRICS_PORT='0' when platform.dapi.rsDapi.metrics.enabled is present and false.
Configuration Schema
packages/dashmate/src/config/configJsonSchema.js
Replaces inline rsDapi.metrics schema with a $ref to shared enabledHostPort, making enabled part of the validated/required shape.
Documentation
packages/dashmate/docs/config/core.md, packages/dashmate/docs/config/dapi.md, packages/dashmate/docs/services/core.md, packages/dashmate/docs/services/index.md, packages/dashmate/docs/services/platform.md
Updates docs/tables to list per-network defaults and explain Dashmate's port-offset strategy for ZMQ and rs-dapi metrics (mainnet/testnet/local presets).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant ConfigFile as Config files
  participant Migration as Migration(2.2.0-dev.1)
  participant Defaults as Base defaults
  participant EnvGen as generateEnvsFactory
  participant Docker as docker-compose

  ConfigFile->>Migration: iterate and normalize each config
  Migration->>Defaults: ensure rsDapi, rsDapi.metrics, core.zmq (clone defaults if missing)
  Migration->>ConfigFile: backfill ports / set metrics.enabled when undefined (preserve custom ports)

  ConfigFile->>EnvGen: build environment variables
  alt metrics.enabled == false
    EnvGen->>EnvGen: set PLATFORM_DAPI_RS_DAPI_METRICS_PORT = "0"
  end
  EnvGen->>Docker: output runtime envs

  note right of Docker #DDEBF7: docker-compose updated — rs_dapi metrics exposure removed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check migration 2.2.0-dev.1 for edge cases: cloning defaults vs. preserving user overrides and port comparison logic.
  • Verify configJsonSchema.js $ref change does not unintentionally break validation or CI schema checks.
  • Confirm consistency of port numbers across defaults, docs, migration, and env generation.

Poem

🐇 I hopped through ports, three nests aligned,
Main, test, and local — no clashes to find.
A tiny flag whispers "silent, please" for metrics,
Ports set zero where the rabbit says nix 'em.
Cheers from my burrow — configs all refined!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix(dashmate)!: port conflicts with mainnet and testnet on the same host" directly and accurately describes the primary objective of the changeset. The title identifies the main problem being solved (port conflicts when running multiple environments on the same host), specifically referencing the affected environments. The changes across configuration files, migration logic, schema updates, and documentation all support this central goal of resolving port conflicts through environment-specific port assignments and disabling metrics by default. The title is concise, specific, and uses appropriate conventional commit formatting with a breaking change indicator.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dashmate-disable-rs-dapi-metrics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lklimek lklimek changed the title feat(dashmate): option to disable rs-dapi metrics feat(dashmate)!: option to disable rs-dapi metrics Oct 27, 2025
@lklimek lklimek changed the title feat(dashmate)!: option to disable rs-dapi metrics fix(dashmate)!: port conflicts when mainnet and testnet node deployed on the same host Oct 28, 2025
@lklimek lklimek changed the title fix(dashmate)!: port conflicts when mainnet and testnet node deployed on the same host fix(dashmate)!: port conflicts with mainnet and testnet on the same host Oct 28, 2025
@lklimek lklimek added this to the v2.2.0 milestone Oct 28, 2025
@lklimek lklimek marked this pull request as ready for review October 28, 2025 09:06
@lklimek lklimek force-pushed the feat/dashmate-disable-rs-dapi-metrics branch from 5ace9e2 to 7baf9ef Compare October 28, 2025 09:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/dashmate/configs/getConfigFileMigrationsFactory.js (1)

1279-1285: Document the hardcoded port value.

The hardcoded 29998 on line 1282 represents the previous default ZMQ port before network-specific defaults were introduced. Adding a comment would clarify this for future maintainers.

Apply this diff to add documentation:

+            // Check if ZMQ port matches base default or previous default (29998)
+            // to identify non-customized configs that should be migrated
             if (
               !Number.isNaN(targetZmqPort)
               && targetZmqPort !== configuredZmqPort
               && (configuredZmqPort === baseZmqPortNumber || configuredZmqPort === 29998)
             ) {
               options.core.zmq.port = targetZmqPort;
             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7baf9ef and 8630a14.

📒 Files selected for processing (1)
  • packages/dashmate/configs/getConfigFileMigrationsFactory.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
packages/**/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/**/**/*.{js,ts,jsx,tsx}: Adhere to ESLint with Airbnb/TypeScript configs for JS/TS code
Use camelCase for JS/TS variables and functions
Use PascalCase for JS/TS classes
Prefer kebab-case filenames within JS packages

Files:

  • packages/dashmate/configs/getConfigFileMigrationsFactory.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (1)
packages/dashmate/configs/getConfigFileMigrationsFactory.js (1)

1229-1289: Migration logic correctly preserves user customizations.

The conditional port updates (lines 1271-1285) appropriately check whether ports match known defaults before updating them, ensuring that user customizations are preserved while migrating non-customized configs to network-specific defaults.

@lklimek lklimek merged commit a8994c7 into v2.2-dev Oct 28, 2025
24 checks passed
@lklimek lklimek deleted the feat/dashmate-disable-rs-dapi-metrics branch October 28, 2025 11:07
@bezibalazs bezibalazs modified the milestones: v2.2.0, v3.0.0 Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants