Skip to content

fix: intermittent error in feature_dip3_v19.py #6703

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 4 commits into
base: develop
Choose a base branch
from

Conversation

knst
Copy link
Collaborator

@knst knst commented Jun 2, 2025

Issue being fixed or feature implemented

#6702

It can happen on Regtest or Devnet if v20 is just activated but the best chainlock is still in legacy (pre-v19) scheme.

It causes errors on CI similar to this one:

2025-05-31T10:28:49.821000Z TestFramework (INFO): Checking that protxs with duplicate EvoNodes fields are rejected
2025-05-31T10:29:50.653000Z TestFramework (INFO): dynamically_prepare_masternode failed
2025-05-31T10:30:50.784000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "DASH/test/functional/test_framework/test_framework.py", line 162, in main
    self.run_test()
  File "DASH/test/functional/feature_dip3_v19.py", line 87, in run_test
    self.dynamically_evo_update_service(evo_info_0, 8)
  File "DASH/test/functional/test_framework/test_framework.py", line 1384, in dynamically_evo_update_service
    tip = self.generate(self.nodes[0], 1)[0]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "DASH/test/functional/test_framework/test_framework.py", line 805, in generate
    sync_fun() if sync_fun else self.sync_all()
                                ^^^^^^^^^^^^^^^
  File "DASH/test/functional/test_framework/test_framework.py", line 874, in sync_all
    self.sync_blocks(nodes)
  File "DASH/test/functional/test_framework/test_framework.py", line 840, in sync_blocks
    raise AssertionError("Block sync timed out after {}s:{}".format(
AssertionError: Block sync timed out after 60s:
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
  '0ade04ee0ae89d1168792a65c28956557c9f2991d141180b9faf7a9ae986cf24'
2025-05-31T10:30:50.837000Z TestFramework (INFO): Stopping nodes

While underlying error is bad-cbtx-invalid-clsig:

 2025-05-31T10:28:49.932591Z [util/system.h:57] [error] ERROR: ConnectBlock(DASH): ProcessSpecialTxsInBlock for block 4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9 failed with bad-cbtx-invalid-clsig
 2025-05-31T10:28:49.932632Z [validationinterface.cpp:254] [BlockChecked] [validation] BlockChecked: block hash=4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9 state=bad-cbtx-invalid-clsig
 2025-05-31T10:28:49.932660Z [validation.cpp:1634] [InvalidChainFound] InvalidChainFound: invalid block=4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9  height=202  log2_work=8.665336  date=2014-12-04T17:46:38Z
 2025-05-31T10:28:49.932667Z [validation.cpp:1639] [InvalidChainFound] InvalidChainFound:  current best=0ade04ee0ae89d1168792a65c28956557c9f2991d141180b9faf7a9ae986cf24  height=201  log2_work=8.658211  date=2014-12-04T17:36:30Z

What was done?

Chainlocks in CbTx can be only in Basic scheme.
This PR splits activation of v19 and v20 to different blocks and wait until the best chainlocks will be formed in BASIC scheme.

How Has This Been Tested?

Run functional test feature_dip3_v19.py multiple times.

Breaking Changes

On RegTest v20 is enforced to be activated after v19. In practice, any chainlocks in CbTx formed without v19 activated will stop the chain. Added assert for regtest to be sure that combination of various -testactivationheight won't stop chain

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

Copy link

coderabbitai bot commented Jun 2, 2025

Walkthrough

The changes introduce clarifying comments in the CRegTestParams constructor regarding consensus activation height assertions. In the test suite, the TestChainV19BeforeActivationSetup struct now sets activation heights for "v19", "v20", and "mn_rr" deployments at block 500, instead of only "v19". The checkpoint hash for block height 494 is updated in the TestChainSetup constructor. In CalcCbTxBestChainlock, a new condition prevents legacy BLS ChainLocks from being used in coinbase transactions by checking the chainlock height against the v19 activation height and returning early if it is below that threshold. No public API signatures are changed.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cb42761 and d1e820f.

📒 Files selected for processing (1)
  • src/evo/cbtx.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/evo/cbtx.cpp
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / 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 (1)
test/functional/feature_dip3_v19.py (1)

108-112: Fix logging format and line length issues.

The chainlock synchronization logic is correct and implements the necessary sequencing to prevent "bad-cbtx-invalid-clsig" errors. However, there are style issues to address:

Apply this diff to fix the pylint warnings:

-        self.log.info("Chainlocks in CbTx can be only in Basic scheme. Wait one...")
+        self.log.info("Chainlocks in CbTx can be only in Basic scheme. Wait one...")
         self.wait_until(lambda: self.nodes[0].getbestchainlock()['height'] > 200)
-        self.log.info(f"block {self.nodes[0].getbestchainlock()['height']} is chainlocked after v19 activation")
+        height = self.nodes[0].getbestchainlock()['height']
+        self.log.info("block %d is chainlocked after v19 activation", height)

This addresses:

  • Line length violation by breaking the f-string formatting
  • Lazy logging format by using % formatting instead of f-strings
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 110-110: Line too long (112/100)

(C0301)


[warning] 110-110: Use lazy % formatting in logging functions

(W1203)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ef4783 and 63a0b20.

📒 Files selected for processing (3)
  • src/chainparams.cpp (1 hunks)
  • src/evo/cbtx.h (1 hunks)
  • test/functional/feature_dip3_v19.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/functional/feature_dip3_v19.py (1)
test/functional/test_framework/test_framework.py (3)
  • delay_v20_and_mn_rr (1219-1221)
  • wait_until (904-905)
  • activate_by_name (1223-1262)
🪛 Pylint (3.3.7)
test/functional/feature_dip3_v19.py

[convention] 110-110: Line too long (112/100)

(C0301)


[warning] 110-110: Use lazy % formatting in logging functions

(W1203)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: mac-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: win64-build / Build source
🔇 Additional comments (3)
src/evo/cbtx.h (1)

54-56: LGTM! Excellent documentation of a critical issue.

This comment effectively documents the BLS signature scheme transition issue that can cause "Invalid Block errors" on devnet/regtest networks. It provides valuable context for understanding why the broader changes in this PR are necessary to prevent chainlock signature scheme conflicts.

src/chainparams.cpp (1)

928-933: Excellent addition of critical safety assertions.

These assertions enforce the proper ordering of consensus activation heights and will prevent the configuration errors that lead to "bad-cbtx-invalid-clsig" failures. The explanatory comments clearly document the technical dependencies:

  • V20's chainlock signatures in coinbase transactions require V19's BLS scheme changes to be active first
  • V20's coinbase transaction features require masternodes (DIP0003) to be operational
  • MN_RR's credit pool reallocation depends on V20's credit pool infrastructure

This proactive validation will catch misconfigurations during initialization rather than allowing intermittent runtime failures.

test/functional/feature_dip3_v19.py (1)

50-50: Good implementation of activation delay.

The call to delay_v20_and_mn_rr(height=260) properly implements the fix by ensuring V20 and MN_RR activation is delayed until block 260. This respects the new ordering constraints enforced in src/chainparams.cpp and prevents the timing issues that cause test failures.

@knst knst added this to the 23 milestone Jun 2, 2025
@PastaPastaPasta
Copy link
Member

@knst CI fails

It can happen on Regtest or Devnet if v20 is just activated but the best
chainlock is still in legacy (pre-v19) scheme.

It causes errors on CI similar to this one:

    2025-05-31T10:28:49.821000Z TestFramework (INFO): Checking that protxs with duplicate EvoNodes fields are rejected
    2025-05-31T10:29:50.653000Z TestFramework (INFO): dynamically_prepare_masternode failed
    2025-05-31T10:30:50.784000Z TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "DASH/test/functional/test_framework/test_framework.py", line 162, in main
        self.run_test()
      File "DASH/test/functional/feature_dip3_v19.py", line 87, in run_test
        self.dynamically_evo_update_service(evo_info_0, 8)
      File "DASH/test/functional/test_framework/test_framework.py", line 1384, in dynamically_evo_update_service
        tip = self.generate(self.nodes[0], 1)[0]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "DASH/test/functional/test_framework/test_framework.py", line 805, in generate
        sync_fun() if sync_fun else self.sync_all()
                                    ^^^^^^^^^^^^^^^
      File "DASH/test/functional/test_framework/test_framework.py", line 874, in sync_all
        self.sync_blocks(nodes)
      File "DASH/test/functional/test_framework/test_framework.py", line 840, in sync_blocks
        raise AssertionError("Block sync timed out after {}s:{}".format(
    AssertionError: Block sync timed out after 60s:
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '4227eea732e686fcf608bcbc5525a02336bb69c2eed70e8a59d6439b2122190f'
      '0ade04ee0ae89d1168792a65c28956557c9f2991d141180b9faf7a9ae986cf24'
    2025-05-31T10:30:50.837000Z TestFramework (INFO): Stopping nodes

While underlying error is `bad-cbtx-invalid-clsig`:

     2025-05-31T10:28:49.932591Z [util/system.h:57] [error] ERROR: ConnectBlock(DASH): ProcessSpecialTxsInBlock for block 4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9 failed with bad-cbtx-invalid-clsig
     2025-05-31T10:28:49.932632Z [validationinterface.cpp:254] [BlockChecked] [validation] BlockChecked: block hash=4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9 state=bad-cbtx-invalid-clsig
     2025-05-31T10:28:49.932660Z [validation.cpp:1634] [InvalidChainFound] InvalidChainFound: invalid block=4f8767d0ad2e7c8882ba4b2819a1d8eb29fbc608ff8201ed1c857d6d3ec51cc9  height=202  log2_work=8.665336  date=2014-12-04T17:46:38Z
     2025-05-31T10:28:49.932667Z [validation.cpp:1639] [InvalidChainFound] InvalidChainFound:  current best=0ade04ee0ae89d1168792a65c28956557c9f2991d141180b9faf7a9ae986cf24  height=201  log2_work=8.658211  date=2014-12-04T17:36:30Z
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 (1)
test/functional/feature_dip3_v19.py (1)

108-111: Address code style issues in chainlock waiting logic.

The chainlock waiting logic is correct and necessary for the fix, but there are style issues to address:

  1. Line 110 exceeds the 100-character limit (112 characters)
  2. Use lazy % formatting in logging functions

Apply this diff to fix the style issues:

-        self.log.info("Chainlocks in CbTx can be only in Basic scheme. Wait one...")
-        self.wait_until(lambda: self.nodes[0].getbestchainlock()['height'] > 200)
-        self.log.info(f"block {self.nodes[0].getbestchainlock()['height']} is chainlocked after v19 activation")
+        self.log.info("Chainlocks in CbTx can be only in Basic scheme. Wait one...")
+        self.wait_until(lambda: self.nodes[0].getbestchainlock()['height'] > 200)
+        chainlock_height = self.nodes[0].getbestchainlock()['height']
+        self.log.info("block %d is chainlocked after v19 activation", chainlock_height)
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 110-110: Line too long (112/100)

(C0301)


[warning] 110-110: Use lazy % formatting in logging functions

(W1203)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 63a0b20 and 63f509d.

📒 Files selected for processing (5)
  • src/chainparams.cpp (1 hunks)
  • src/evo/cbtx.h (1 hunks)
  • src/test/evo_deterministicmns_tests.cpp (1 hunks)
  • src/test/util/setup_common.cpp (1 hunks)
  • test/functional/feature_dip3_v19.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/test/util/setup_common.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/evo/cbtx.h
  • src/chainparams.cpp
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/functional/feature_dip3_v19.py (1)
test/functional/test_framework/test_framework.py (3)
  • delay_v20_and_mn_rr (1219-1221)
  • wait_until (904-905)
  • activate_by_name (1223-1262)
🪛 GitHub Actions: Clang Diff Format Check
src/test/evo_deterministicmns_tests.cpp

[error] 866-867: Clang format differences found. Code formatting does not match the expected style. Please run clang-format to fix formatting issues.

🪛 Pylint (3.3.7)
test/functional/feature_dip3_v19.py

[convention] 110-110: Line too long (112/100)

(C0301)


[warning] 110-110: Use lazy % formatting in logging functions

(W1203)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: mac-build / Build source
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: win64-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: linux64_nowallet-build / Build source
  • GitHub Check: arm-linux-build / Build source
🔇 Additional comments (4)
src/test/evo_deterministicmns_tests.cpp (2)

869-869: LGTM! Test setup extension aligns with PR objectives.

The addition of -testactivationheight=v20@500 and -testactivationheight=mn_rr@500 parameters creates a test scenario where v19, v20, and mn_rr activate simultaneously at block 500. This complements the functional test approach and helps validate the activation order constraints added in the chainparams.


866-867:

❓ Verification inconclusive

Fix code formatting issue.

The pipeline failure indicates clang-format differences on these lines. Please run clang-format to fix the formatting issues.


🏁 Script executed:

#!/bin/bash
# Check the specific formatting issue around line 869
echo "Current formatting around the constructor:"
sed -n '866,870p' src/test/evo_deterministicmns_tests.cpp

echo -e "\nRunning clang-format to show expected formatting:"
clang-format --lines=866:870 src/test/evo_deterministicmns_tests.cpp

Length of output: 664


Run clang-format locally to fix the formatting mismatch

The CI failure shows a clang-format diff around the constructor initializer list in src/test/evo_deterministicmns_tests.cpp (approx. lines 866–870):

TestChainV19BeforeActivationSetup::TestChainV19BeforeActivationSetup() :
    TestChainSetup(494, {"-testactivationheight=v19@500", "-testactivationheight=v20@500", "-testactivationheight=mn_rr@500"})
{

Please install or invoke clang-format using the project’s style configuration on this file, review the resulting diff in your local environment, and commit the formatted code.
Once you’ve applied and verified the formatting locally, update the PR.

🧰 Tools
🪛 GitHub Actions: Clang Diff Format Check

[error] 866-867: Clang format differences found. Code formatting does not match the expected style. Please run clang-format to fix formatting issues.

test/functional/feature_dip3_v19.py (2)

50-50: LGTM! Proper delay of v20 and MN_RR activation.

The delay_v20_and_mn_rr(height=260) call effectively separates v20 and MN_RR activation from v19 activation (at height 200), creating a 60-block gap. This aligns perfectly with the PR objective to fix intermittent errors by ensuring chainlocks are established using the BASIC scheme before v20 activation proceeds.


112-112: LGTM! Explicit v20 activation completes the fix.

The explicit activation of v20 at height 260 completes the fix by ensuring that:

  1. v19 has been active for 60 blocks (200-260)
  2. Chainlocks using the BASIC scheme have been established
  3. v20 activation won't encounter the "bad-cbtx-invalid-clsig" error

This should effectively resolve the intermittent CI failures described in the PR objectives.

PastaPastaPasta
PastaPastaPasta previously approved these changes Jun 2, 2025
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

p2p_node_network_limited.py --v2transport is flakey it appears too, based on the CI here.

ACK 63f509d, tests ran 20 times locally w/o error

@knst
Copy link
Collaborator Author

knst commented Jun 3, 2025

p2p_node_network_limited.py --v2transport is flakey it appears too, based on the CI here.

yeah, it's know issue. I have particular solution, but it's still flakey. I will create PR soon

@knst knst requested a review from UdjinM6 June 5, 2025 19:41
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK d1e820f

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