Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dashmate)!: update Core to version 22 #2384

Merged
merged 4 commits into from
Dec 13, 2024
Merged

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Dec 12, 2024

Issue being fixed or feature implemented

Update Platform to Core 22

What was done?

  • Updated Core to v22.0.0
  • Added config migration
  • Fixed status command
  • Fixed the local network setup

How Has This Been Tested?

Locally and devnet

Breaking Changes

Dashmate's local development network won't support Core version <22

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

    • Updated Docker image version for core configuration to dashpay/dashd:22.
    • Added migration for configuration file to support version 1.7.0 with updated Docker image.
    • Introduced new tasks in core configuration for wallet creation and masternode funding, along with v21 fork activation.
  • Bug Fixes

    • Simplified platform activation status reporting and improved error handling in platform status retrieval.
  • Refactor

    • Enhanced readability of function parameters and streamlined task management processes.

@shumkov shumkov self-assigned this Dec 12, 2024
Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Walkthrough

The changes in this pull request involve updates to the configuration and task management within the Dashmate project. Key modifications include updating the Docker image version for the core section to dashpay/dashd:22, introducing a new migration for configuration updates, and restructuring tasks in the configureCoreTaskFactory function. Additionally, the logic for platform activation status reporting has been simplified, enhancing clarity in error handling without altering core functionalities.

Changes

File Path Change Summary
packages/dashmate/configs/defaults/getBaseConfigFactory.js Updated Docker image version from 21 to 22 for dashpay/dashd in the core configuration.
packages/dashmate/configs/getConfigFileMigrationsFactory.js Added a new migration for version 1.7.0 to update core.docker.image to dashpay/dashd:22.
packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js Reformatted parameters for readability, removed tasks related to sporks, and introduced new tasks for wallet creation and fund generation. Adjusted activation heights for DIP3 and v21 fork.
packages/dashmate/src/status/scopes/platform.js Simplified platform activation status reporting and refined error handling for getDriveInfo.

Possibly related issues

Possibly related PRs

Suggested labels

dashmate, cleanup

Suggested reviewers

  • QuantumExplorer
  • lklimek

Poem

In the code where rabbits play,
We’ve updated Docker today!
From twenty-one to twenty-two,
A leap for all, a hop for you.
Tasks are clearer, errors bright,
Dashmate shines with all its might! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shumkov shumkov added this to the v1.7.0 milestone Dec 12, 2024
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

🧹 Outside diff range and nitpick comments (4)
packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js (3)

Line range hint 126-150: Refactor duplicated block generation logic into a reusable function

The code for generating blocks to reach a certain activation height is duplicated in both the 'Activating v19 and v20' and 'Activating v21 fork' tasks. Refactor this logic into a separate function to improve maintainability and reduce code duplication.

Consider creating a function like generateBlocksUntilHeight and reuse it in both tasks:

+ const generateBlocksUntilHeight = async (targetHeight, observer) => {
+   const blocksToGenerateInOneStep = 10;
+   let blocksGenerated = 0;
+   let { result: currentBlockHeight } = await ctx.coreService.getRpcClient().getBlockCount();
+
+   do {
+     ({ result: currentBlockHeight } = await ctx.coreService.getRpcClient().getBlockCount());
+     await generateBlocks(
+       ctx.coreService,
+       blocksToGenerateInOneStep,
+       NETWORK_LOCAL,
+       (blocks) => {
+         blocksGenerated += blocks;
+         observer.next(`${blocksGenerated} blocks generated`);
+       },
+     );
+   } while (targetHeight > currentBlockHeight);
+ };

Then update the tasks to use this function:

// In 'Activating v19 and v20' task
task: () => new Observable(async (observer) => {
- const dip3ActivationHeight = 901;
- const blocksToGenerateInOneStep = 10;
- let blocksGenerated = 0;
- let {
-   result: currentBlockHeight,
- } = await ctx.coreService.getRpcClient().getBlockCount();
-
- do {
-   ({
-     result: currentBlockHeight,
-   } = await ctx.coreService.getRpcClient().getBlockCount());
-
-   await generateBlocks(
-     ctx.coreService,
-     blocksToGenerateInOneStep,
-     NETWORK_LOCAL,
-     // eslint-disable-next-line no-loop-func
-     (blocks) => {
-       blocksGenerated += blocks;
-
-       observer.next(`${blocksGenerated} blocks generated`);
-     },
-   );
- } while (dip3ActivationHeight > currentBlockHeight);
+ await generateBlocksUntilHeight(901, observer);
  observer.complete();
  return this;
}),

// Similarly in 'Activating v21 fork' task
task: () => new Observable(async (observer) => {
- const dip3ActivationHeight = 1001;
+ await generateBlocksUntilHeight(1001, observer);
  observer.complete();
  return this;
}),

Also applies to: 312-338


230-231: Address the TODO comment: Rename function for clarity

There's a TODO comment indicating that the function waitForMasternodesSync should be renamed, possibly to better reflect its functionality. Updating the function name will improve code readability and maintainability.

Would you like assistance in renaming the function and updating references throughout the codebase? I can help generate the necessary changes or open a GitHub issue to track this task.


291-293: Enhance error message for masternode status check

The error message 'Not all masternodes are enabled' could be more informative by specifying which masternodes are not enabled. This can aid in debugging and expedite issue resolution.

Consider modifying the error handling to include the IDs or statuses of the non-enabled masternodes:

if (hasNotEnabled) {
- throw new Error('Not all masternodes are enabled');
+ const disabledMNs = Object.entries(masternodesStatus)
+   .filter(([, status]) => status !== 'ENABLED')
+   .map(([proTxHash, status]) => `${proTxHash}: ${status}`);
+ throw new Error(`The following masternodes are not enabled:\n${disabledMNs.join('\n')}`);
}
packages/dashmate/src/status/scopes/platform.js (1)

316-316: Update platform activation message for better user feedback

When the platform activation is pending, enhancing the activation message with additional context can improve user experience and clarity.

Consider including the current block height and the number of blocks remaining until activation:

if (mnRRSoftFork.active) {
  scope.platformActivation = `Activated (at height ${mnRRSoftFork.height})`;
} else {
+ const { result: currentBlockHeight } = await rpcClient.getBlockCount();
+ const blocksRemaining = mnRRSoftFork.height - currentBlockHeight;
+ scope.platformActivation = `Waiting for activation at height ${mnRRSoftFork.height} (current height: ${currentBlockHeight}, ${blocksRemaining} blocks remaining)`;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bdae90c and fda6dd7.

⛔ Files ignored due to path filters (1)
  • packages/dashmate/templates/core/dash.conf.dot is excluded by !**/*.dot
📒 Files selected for processing (4)
  • packages/dashmate/configs/defaults/getBaseConfigFactory.js (1 hunks)
  • packages/dashmate/configs/getConfigFileMigrationsFactory.js (1 hunks)
  • packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js (12 hunks)
  • packages/dashmate/src/status/scopes/platform.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/dashmate/configs/defaults/getBaseConfigFactory.js
🔇 Additional comments (1)
packages/dashmate/configs/getConfigFileMigrationsFactory.js (1)

1051-1057: Verify compatibility with Core version 22

Updating the Core Docker image to dashpay/dashd:22 requires ensuring compatibility with existing configurations and RPC methods. It's important to verify that all features and RPC calls used in Dashmate are supported in Core version 22.

Please run the following script to check for any deprecated or altered RPC methods that might affect Dashmate:

This script will help identify any RPC methods that have been added, removed, or changed between versions, allowing you to adjust Dashmate accordingly.

✅ Verification successful

Let me try a different approach to verify the compatibility by analyzing the codebase for RPC method usage.

This script will help us:

  1. Identify files that make RPC calls
  2. See the actual RPC methods being used
  3. Find any version-specific code or compatibility checks

This will give us a better understanding of how Dashmate interacts with Core and any version-specific handling that might be in place.


Let me analyze the RPC usage in the codebase to generate a final response.

Core version 22 update appears safe to proceed

Based on the codebase analysis:

  1. The RPC usage in Dashmate is focused on basic Core functionality that remains stable across versions:
    • Network status checks (getinfo, getblockchaininfo)
    • Node management (stop, reindex)
    • Configuration and authentication
  2. No usage of deprecated or version-specific RPC methods was found
  3. The codebase already handles version detection and compatibility through extractCoreVersion.js

The migration to Core v22 appears to be a safe update as the RPC interfaces used by Dashmate are fundamental ones that maintain backward compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare RPC methods between Core versions 21 and 22 to identify changes.

# Pull Docker images if not already present
docker pull dashpay/dashd:21 > /dev/null
docker pull dashpay/dashd:22 > /dev/null

# Get list of RPC methods from Core version 21
docker run --rm dashpay/dashd:21 dash-cli help > rpc_methods_v21.txt

# Get list of RPC methods from Core version 22
docker run --rm dashpay/dashd:22 dash-cli help > rpc_methods_v22.txt

# Compare the lists to find differences
diff rpc_methods_v21.txt rpc_methods_v22.txt > rpc_methods_diff.txt

# Output the differences
echo "Differences in RPC methods between Core v21 and Core v22:"
cat rpc_methods_diff.txt

Length of output: 747


Script:

#!/bin/bash
# Search for RPC method calls in the codebase
echo "Files containing RPC method calls:"
rg -l "\.rpc\." --type js

echo -e "\nDetailed RPC method usage:"
rg "\.rpc\." -A 2 --type js

echo -e "\nSearch for Core version references:"
rg -i "core.*version|dashd.*version" --type js

Length of output: 24894

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

🧹 Outside diff range and nitpick comments (2)
packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js (2)

116-124: Add validation and progress reporting for funds generation

Consider these improvements:

  1. Validate that the seed node has sufficient mining power before starting
  2. Add progress reporting to track fund generation
  3. Add a timeout mechanism to prevent infinite waiting
 title: 'Generating funds to use as a collateral for masternodes',
-task: () => {
+task: () => new Observable(async (observer) => {
   const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length;
+  observer.next(`Generating ${amount} DASH for ${configGroup.length} masternodes`);
+
+  const timeout = setTimeout(() => {
+    throw new Error('Fund generation timed out after 10 minutes');
+  }, 10 * 60 * 1000);
+
   return generateToAddressTask(
     configGroup.find((c) => c.getName() === 'local_seed'),
     amount,
-  );
-},
+  ).finally(() => {
+    clearTimeout(timeout);
+    observer.complete();
+  });
+}),

Line range hint 126-338: Refactor duplicate block generation logic

The block generation logic is duplicated between v19/v20 and v21 activation tasks. Consider extracting this into a reusable function.

+async function generateUntilHeight(targetHeight, ctx, observer) {
+  const blocksToGenerateInOneStep = 10;
+  let blocksGenerated = 0;
+  
+  let { result: currentBlockHeight } = await ctx.coreService.getRpcClient().getBlockCount();
+  
+  while (targetHeight > currentBlockHeight) {
+    ({ result: currentBlockHeight } = await ctx.coreService.getRpcClient().getBlockCount());
+    
+    await generateBlocks(
+      ctx.coreService,
+      blocksToGenerateInOneStep,
+      NETWORK_LOCAL,
+      (blocks) => {
+        blocksGenerated += blocks;
+        observer.next(`${blocksGenerated} blocks generated`);
+      },
+    );
+  }
+}

 // Usage in tasks:
 {
   title: 'Activating v19 and v20',
   task: () => new Observable(async (observer) => {
     await generateUntilHeight(901, ctx, observer);
     observer.complete();
     return this;
   }),
 },
 // ... other tasks ...
 {
   title: 'Activating v21 fork',
   task: () => new Observable(async (observer) => {
     await generateUntilHeight(1001, ctx, observer);
     observer.complete();
     return this;
   }),
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f89516 and 84626d5.

📒 Files selected for processing (1)
  • packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js (3 hunks)
🔇 Additional comments (1)
packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js (1)

95-114: Consider adding error handling for wallet creation

The createWallet RPC call may fail due to various reasons (e.g., wallet already exists, RPC connection issues). It's recommended to add error handling to catch and handle potential exceptions.

task: () => new Observable(async (observer) => {
const dip3ActivationHeight = 1000;
const dip3ActivationHeight = 901;
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 13, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the search results, I can now provide a final response as we have clear evidence about the activation heights in the code.

The activation heights in the code are incorrect

The code shows two different activation heights:

  • DIP3 activation height is set to 901 for v19/v20 activation
  • DIP3 activation height is set to 1001 for v21 fork activation

This appears to be inconsistent as it sets two different DIP3 activation heights. Additionally, from the configuration template found earlier (packages/dashmate/templates/core/dash.conf.dot), we see that the testnet activation height for mn_rr is set to 1000, which suggests these values need to be aligned.

🔗 Analysis chain

Verify activation heights for Core v22

Please verify that the activation heights (901 for DIP3 and 1001 for v21) are correct for Core v22. These values seem to have changed from previous versions.

Also applies to: 314-314


Let me analyze the search results. I notice that the code in configureCoreTaskFactory.js shows different activation heights than what's in the review comment. Let me verify this further by searching for more specific context around these values.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for activation height references in Core v22 codebase
# Expected: Find references to activation heights in Core v22 configuration or documentation

# Search for activation height references
rg -A 2 "activation.*height|height.*activation" 

# Search for DIP3 and v21 specific configurations
rg -A 2 "DIP0003|v21.*fork"

Length of output: 9401


Script:

#!/bin/bash
# Search for specific context around activation heights in configureCoreTaskFactory.js
rg -A 5 -B 5 "dip3ActivationHeight|v21.*fork" packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js

# Also search for any configuration or documentation files that might contain these values
fd -e md -e txt -e conf -e yaml -e json | xargs rg "DIP3.*height|v21.*height|activation.*height"

Length of output: 1689

Copy link
Member Author

Choose a reason for hiding this comment

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

This code will be changed soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

@shumkov, understood. Thank you for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants