Skip to content

feat: implement a fork to double withdrawals limit #6662

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented May 7, 2025

Issue being fixed or feature implemented

Implements dashpay/dips#165

What was done?

Bump the limit via new fork, add tests

How Has This Been Tested?

run test

Breaking Changes

n/a

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 made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@UdjinM6 UdjinM6 added this to the 23 milestone May 7, 2025
Copy link

coderabbitai bot commented May 7, 2025

Walkthrough

The changes introduce a new deployment condition, DEPLOYMENT_V23, into the asset unlock transaction logic within the credit pool management system. A new static limit constant, LimitAmountV23 set to 4000 * COIN, is added to the CCreditPoolManager class. The calculation of the currentLimit for asset unlocks now prioritizes the activation of DEPLOYMENT_V23 over previous deployment conditions, applying the new limit and logic when active. Corresponding functional tests are updated and expanded: a new test for the 'v23' fork is added, and the existing withdrawal fork test is renamed and adjusted for consistency.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 355b2ec and 994635b.

📒 Files selected for processing (3)
  • src/evo/creditpool.cpp (1 hunks)
  • src/evo/creditpool.h (1 hunks)
  • test/functional/feature_asset_locks.py (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/evo/creditpool.h
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/evo/creditpool.cpp
  • test/functional/feature_asset_locks.py
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: arm-linux-build / Build source
  • GitHub Check: linux64_ubsan-build / Build source
  • GitHub Check: linux64-build / Build source
  • GitHub Check: linux64_fuzz-build / Build source
  • GitHub Check: linux64_sqlite-build / Build source
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: x86_64-apple-darwin / Build depends
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

Copy link

@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: 0

🧹 Nitpick comments (6)
src/evo/creditpool.h (1)

122-122: Add new withdrawal limit LimitAmountV23.
The constant LimitAmountV23 = 4000 * COIN correctly extends the withdrawal limit tiers. Consider adding an inline comment referencing DEPLOYMENT_WITHDRAWALS2 to clarify its usage context for future maintainers.

src/evo/creditpool.cpp (1)

186-188: Withdrawal-limit math looks correct but consider guarding against future constant regressions

The new branch correctly caps currentLimit with
max(0, min(currentLimit, LimitAmountV23 ‑ latelyUnlocked)), which keeps the result non-negative even if the sliding-window total already exceeds the v23 cap.

Two small follow-ups you might want to consider:

  1. Add a short comment explaining why the max(0, …) is required (negative values mean the full window is already consumed). This will help future maintainers avoid “fixing” it away.
  2. Consider extracting the deployment/limit selection logic into a helper (e.g. CalcWithdrawalsLimit) to avoid another cascade of if/else blocks when v24 comes along.
src/chainparams.cpp (1)

220-228: DRY-up candidate – repeated parameter blocks

The per-network initialisation for DEPLOYMENT_WITHDRAWALS2 duplicates the 7-line block four times with only the start/timeout/window numbers changing.
Moving this into a small helper (e.g. InitWithdrawals2Deployment(consensus, start, timeout, window)) would eliminate copy-paste and lower the risk of propagating typos to only one network.

test/functional/feature_asset_locks.py (3)

650-704: High duplication between v22 and v23 fork tests

test_withdrawals_fork and test_withdrawals2_fork are nearly identical except for the activation height, cap (2 000 → 4 000 COIN) and index ranges. Extracting the common logic into a parametrised helper would shrink the file and make future caps trivial to add.

-    def test_withdrawals_fork(self, ...):
-        cap = 2000 * COIN
-        self._generic_withdrawals_fork('withdrawals', 1750, cap, 501)
-
-    def test_withdrawals2_fork(self, ...):
-        cap = 4000 * COIN
-        self._generic_withdrawals_fork('withdrawals2', 1750, cap, 601)
+    def _generic_withdrawals_fork(self, name, act_height, cap, index_start, ...):
+        ...

This would also prevent subtle drift between the two test suites.


706-763: Hard-coded 4 000 COIN magic number

The test encodes the v23 cap (4000 * COIN) directly. If the constant LimitAmountV23 ever changes, the test will silently become incorrect. Suggest querying the node for getblockchaininfo()["softforks"]["withdrawals2"]["limit"] (once exposed) or importing the value from the C++ header via ctypes/pybind11, or at least defining it once at the top of the file.

WITHDRAWALS2_LIMIT = 4000 * COIN  # TODO: keep in sync with LimitAmountV23

718-744: Potentially long-running while-loop in CI

The loop advances by mining whole quorums until asset_unlock_tx becomes invalid; on slow CI machines this can add minutes. Consider imposing a hard iteration limit and failing early if the condition is never met to avoid indefinite hangs.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e14a8bd and b4e6268.

📒 Files selected for processing (8)
  • src/chainparams.cpp (4 hunks)
  • src/consensus/params.h (1 hunks)
  • src/deploymentinfo.cpp (1 hunks)
  • src/evo/creditpool.cpp (1 hunks)
  • src/evo/creditpool.h (1 hunks)
  • src/rpc/blockchain.cpp (1 hunks)
  • test/functional/feature_asset_locks.py (3 hunks)
  • test/functional/rpc_blockchain.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/evo/creditpool.cpp (2)
src/evo/creditpool.h (2)
  • block_index (136-136)
  • block_index (139-140)
src/chainparams.cpp (2)
  • Params (1382-1385)
  • Params (1382-1382)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: win64-build / Build source
  • GitHub Check: mac-build / Build source
  • GitHub Check: linux64_sqlite-build / Build source
  • GitHub Check: linux64_ubsan-build / Build source
  • GitHub Check: linux64-build / Build source
  • GitHub Check: linux64_fuzz-build / Build source
  • GitHub Check: arm-linux-build / Build source
  • GitHub Check: linux64_nowallet-build / Build source
🔇 Additional comments (6)
src/deploymentinfo.cpp (1)

18-21: New version bits deployment registration for withdrawals2 looks correct.
The entry for "withdrawals2" with gbt_force=true matches the corresponding consensus parameter addition in src/consensus/params.h and aligns with the version bits registration elsewhere.

src/consensus/params.h (1)

43-43: Register new deployment DEPLOYMENT_WITHDRAWALS2 in the enum.
The new enum value is placed correctly right after DEPLOYMENT_WITHDRAWALS, and the existing note reminds to update VersionBitsDeploymentInfo. The ValidDeployment check will include the new entry.

src/rpc/blockchain.cpp (1)

1545-1547: Include DEPLOYMENT_WITHDRAWALS2 in RPC softfork reporting.
The getblockchaininfo RPC now processes DEPLOYMENT_WITHDRAWALS2 alongside the other EHF deployments, ensuring the "withdrawals2" softfork appears with correct status and parameters.

test/functional/rpc_blockchain.py (1)

228-238: Update expected softforks to include "withdrawals2".
The functional test for getblockchaininfo now asserts the presence and correct structure of the "withdrawals2" entry, aligning test expectations with the implementation changes.

src/chainparams.cpp (2)

426-434: Missing min_activation_height comment

For the first withdrawals fork (DEPLOYMENT_WITHDRAWALS) we left the default min_activation_height = 0.
If the intent for WITHDRAWALS2 is the same, adding an explicit comment might avoid doubts later.
If we actually want an activation delay (like Taproot’s 2016-block rule in Bitcoin), set min_activation_height now to avoid mainnet surprises.

Also applies to: 607-615, 852-860


220-228:

✅ Verification successful

Bit 12 re-use check

Bit 12 is now assigned to DEPLOYMENT_WITHDRAWALS2. Please double-check that no other deployments or legacy soft-forks already use this bit (even in dead/test code). A quick repository-wide scan would avoid a hard-to-debug version-bits collision.


🏁 Script executed:

#!/usr/bin/env bash
# Search all consensus deployments for bit = 12 (except the four blocks just introduced).
fd -e cpp -e h | xargs grep -n "bit *= *12" | grep -v "WITHDRAWALS2" || true

Length of output: 75


No version-bits collision found for bit 12
A repository-wide search for other bit = 12 assignments (in .cpp/.h files) returned no matches besides DEPLOYMENT_WITHDRAWALS2. You can safely proceed with using bit 12.

Copy link
Collaborator

@kwvg kwvg left a comment

Choose a reason for hiding this comment

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

Consider renaming DEPLOYMENT_WITHDRAWALS2 to something more generic to avoid needing to introduce a second deployment like 1852fa2 from dash#6665 (comment)

@kxcd
Copy link

kxcd commented May 12, 2025

Recommend we don't make this change, the current daily limit of 2000 Dash is very sufficient and almost never gets hit. This just reduces the protections in place of a credit pool drain. https://mnowatch.org/evonodes/

@PastaPastaPasta
Copy link
Member

@kxcd Please make conceptual objections here: dashpay/dips#165. This PR should be reserved for implementation details.

PastaPastaPasta added a commit that referenced this pull request May 15, 2025
… featureset

98749a7 feat: define BIP 9 fork `DEPLOYMENT_V23` for new version featureset (Kittywhiskers Van Gogh)

Pull request description:

  ## Motivation

  Should handle the deployment needs for [dash#6662](#6662) and [dash#6665](#6665) as they're expected to be shipped in the same major version.

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 98749a7
  PastaPastaPasta:
    utACK 98749a7

Tree-SHA512: b61302a0bcf236f06661a4a53f1d7b3ab0f65659c1c9ab2fcb782457a25eb1e6bdc942647dca6a4e22686e0c7cc83405e099e1fa790cf007d2bee3eedc456d5f
Copy link

This pull request has conflicts, please rebase.

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