Skip to content

Conversation

@lklimek
Copy link
Contributor

@lklimek lklimek commented Oct 27, 2025

Issue being fixed or feature implemented

Commands like dashmate stop --platform, dashmate reset --platform -f don't stop dapi and/or rs-dapi, leading to orphaned containers.

What was done?

Fixed code with Codex:

In https://github.com/dashpay/platform/blob/v2.2-dev/packages/dashmate/docker-compose.yml , you have profiles assigned to various services. To support deprecated DAPI (in case someone has trouble with RS-DAPI), rs-dapi has:
profiles:
- platform-dapi-rs
and JS dapi has:
profiles:
- platform-dapi-deprecated

This PR adjusts Dashmate to use these profiles.

How Has This Been Tested?

On local network, changing deprecated flag and restarting / resetting

Breaking Changes

None

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

  • Refactor

    • Restructured platform profile management using a centralized factory pattern for improved configuration flexibility
    • Unified platform-specific profile handling across node operations (reset, start, stop)
    • Enhanced dependency injection for better configuration modularity
  • Documentation

    • Minor technical documentation updates

@lklimek lklimek marked this pull request as ready for review October 27, 2025 11:31
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new factory function getPlatformProfilesFactory is introduced to centralize platform profile resolution, then integrated into the DI container as getPlatformProfiles. Three task factories—resetNodeTaskFactory, startNodeTaskFactory, and stopNodeTaskFactory—are refactored to accept this external dependency instead of managing profiles internally or via getConfigProfiles. Objective-C protobuf documentation is also updated with minor formatting changes.

Changes

Cohort / File(s) Summary
Objective-C Platform Protobuf Documentation
packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h
Comment formatting and wording adjustments for GetFinalizedEpochInfosResponse, GetFinalizedEpochInfosResponse_GetFinalizedEpochInfosResponseV0_FinalizedEpochInfos, and GetTokenPerpetualDistributionLastClaimRequest_GetTokenPerpetualDistributionLastClaimRequestV0 fields; no functional changes.
Platform Profiles Factory
packages/dashmate/src/config/getPlatformProfilesFactory.js
New factory function that returns a configurable platform profile resolver supporting filtered profiles from config or full predefined profiles.
DI Container Integration
packages/dashmate/src/createDIContainer.js
Registers getPlatformProfiles as a singleton in the DI container via getPlatformProfilesFactory.
Task Factory Refactoring
packages/dashmate/src/listr/tasks/resetNodeTaskFactory.js, packages/dashmate/src/listr/tasks/startNodeTaskFactory.js, packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js
Replace hardcoded profile arrays and internal profile logic with externally-provided getPlatformProfiles dependency; update method signatures and profile computation across multiple task steps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Signature changes: Three task factories change their parameter from getConfigProfiles to getPlatformProfiles; verify all call sites are updated consistently
  • Logic migration: Internal platform profile resolution logic is moved to the central factory; ensure filtering logic (esp. the includeAll parameter in stopNodeTaskFactory) behaves correctly across all use cases
  • Integration points: Confirm DI container registration and factory method signatures align with actual usage in task factories
  • Edge cases: Review platform-only reset and stop scenarios where { includeAll: true } is passed to ensure correct profile selection

Poem

🐰 Through factories profiles flow, clean and bright,
Dependencies injected—configuration takes flight,
No more hardcoded chains in each little task,
The container orchestrates, all we need ask,
A refactor most dapper, quite nimble and spry! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix(dashmate): rs-dapi not stopped when dashmate reset --platform -f is called" is specific, descriptive, and directly addresses the primary issue being resolved. The changes in the pull request support this fix by refactoring the platform profile selection logic across multiple task factories (resetNodeTaskFactory, stopNodeTaskFactory, startNodeTaskFactory), extracting it into a reusable factory function, and updating these tasks to use the external getPlatformProfiles function with proper configuration. The title clearly identifies the problem (rs-dapi not being stopped) and the specific command context, making it easy for reviewers to understand the main intent of the changeset without ambiguity.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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 requested a review from shumkov October 27, 2025 11:33
@lklimek lklimek added this to the v2.1.x milestone Oct 27, 2025
@lklimek
Copy link
Contributor Author

lklimek commented Oct 27, 2025

@coderabbitai review all

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

@lklimek: I'll review all the changes in this PR.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 (5)
packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h (3)

3365-3366: Nit: align “proof” wording with other messages for clarity

Suggest clarifying that the proof is optional and of the response data, not “the epoch” generically.

Apply this comment-only diff:

-/** Cryptographic proof of the finalized epoch */
+/** Cryptographic proof of the finalized epoch info, if requested */

3387-3389: Nit: avoid mid-sentence line break; add period

Keep the short sentence on one line and terminate with a period for readability.

Apply this comment-only diff:

-/** 
- * FinalizedEpochInfos holds a collection of finalized epoch information
- * entries
- **/
+/**
+ * FinalizedEpochInfos holds a collection of finalized epoch information entries.
+ **/

6442-6446: Clarify what setting contractInfo does

Make it explicit that this targets a specific contract token type and what fields are expected.

Apply this comment-only diff:

-/**
- * This should be set if you wish to get back the last claim info as a
- * specific type
- **/
+/**
+ * Set to request last-claim info for a specific contract token type.
+ * Provide contractId and tokenContractPosition in contractInfo.
+ **/
packages/dashmate/src/listr/tasks/startNodeTaskFactory.js (1)

94-96: Confirm behavior with stale/inactive DAPI containers

Using active profiles here is fine since you forcibly remove the inactive DAPI stack later. Please verify that on nodes with leftover deprecated DAPI containers running, the “Remove inactive DAPI stack” step succeeds on all platforms (Docker Desktop/macOS/Windows) without needing an additional pre-check.

Also applies to: 149-152

packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (1)

32-35: Stopping with includeAll profiles fixes orphaned rs-dapi

The includeAll flag ensures both DAPI stacks are covered during platform-only stop. Consider extracting a tiny helper inside the factory to compute profiles from ctx to avoid duplication.

+  const selectProfiles = (ctx, config) =>
+    ctx.platformOnly ? getPlatformProfiles(config, { includeAll: true }) : [];
@@
-          const profiles = ctx.platformOnly
-            ? getPlatformProfiles(config, { includeAll: true })
-            : [];
+          const profiles = selectProfiles(ctx, config);
@@
-          const profiles = ctx.platformOnly
-            ? getPlatformProfiles(config, { includeAll: true })
-            : [];
+          const profiles = selectProfiles(ctx, config);

Also applies to: 74-77

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cdcdec0 and e4b8e32.

📒 Files selected for processing (6)
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h (3 hunks)
  • packages/dashmate/src/config/getPlatformProfilesFactory.js (1 hunks)
  • packages/dashmate/src/createDIContainer.js (2 hunks)
  • packages/dashmate/src/listr/tasks/resetNodeTaskFactory.js (5 hunks)
  • packages/dashmate/src/listr/tasks/startNodeTaskFactory.js (2 hunks)
  • packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (3 hunks)
🔇 Additional comments (6)
packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h (1)

1-2: Confirm changes are generated from .proto, not hand-edited

This file is generated (“DO NOT EDIT!”). Please confirm these doc updates were made in platform.proto comments and the Objective‑C stubs were re‑generated, to avoid drift across languages. If not, move the edits to the .proto and re-generate.

packages/dashmate/src/createDIContainer.js (1)

120-120: DI wiring for getPlatformProfiles looks correct

Import and singleton registration align with existing patterns and InjectionMode.CLASSIC param names. Please add/extend a lightweight container-resolution test to assert container.getPlatformProfiles is callable and returns expected profiles for a sample config.

Also applies to: 173-174

packages/dashmate/src/listr/tasks/startNodeTaskFactory.js (1)

22-22: Adopted DI for getPlatformProfiles — good move

Signature and JSDoc updated consistently. This aligns start with stop/reset for profile sourcing.

Also applies to: 34-35

packages/dashmate/src/listr/tasks/resetNodeTaskFactory.js (1)

75-82: Profiles handling for platform-only reset looks correct

Using getPlatformProfiles(config, { includeAll: true }) ensures both deprecated DAPI and rs-dapi are targeted. Good coverage.

Also applies to: 107-123

packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (1)

10-11: Good switch to injected getPlatformProfiles

Factory signature and docs updated consistently.

Also applies to: 17-18

packages/dashmate/src/config/getPlatformProfilesFactory.js (1)

1-32: PLATFORM_PROFILES verified in sync with docker-compose.yml

Confirmed: All three profiles declared in docker-compose.yml (platform, platform-dapi-deprecated, platform-dapi-rs) match the PLATFORM_PROFILES constant exactly. Code is clean and composable.

Copy link
Collaborator

@shumkov shumkov left a comment

Choose a reason for hiding this comment

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

👍

@lklimek lklimek merged commit 87a6ebf into master Oct 27, 2025
69 checks passed
@lklimek lklimek deleted the fix/dashmate-reset-rs-sdk branch October 27, 2025 12:15
lklimek added a commit that referenced this pull request Nov 28, 2025
lklimek added a commit that referenced this pull request Nov 28, 2025
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.

3 participants