Skip to content

Conversation

@knst
Copy link
Collaborator

@knst knst commented Apr 23, 2025

Issue being fixed or feature implemented

The functional test feature_llmq_simplepose.py is the slowest one and its run alone is taking longer time than all other functional tests all together (running in simultaneous jobs).

Remaining jobs: [feature_llmq_simplepose.py]
285/285 - feature_llmq_simplepose.py passed, Duration: 294 s

...
feature_llmq_simplepose.py                         | ✓ Passed  | 294 s
...
    
ALL                                                | ✓ Passed  | 6078 s (accumulated)

Runtime: 294 s

What was done?

Done 2 major refactors that improved performance:

  1. split functional test to 2 version: with spork23 activated and spork23 disabled
  2. checks "there's no pose ban or no pose punishement" are done now for each successfully generated quorum in mine_quorum helper instead dedicated quorum generations in feature_llmq_simplepose.py

It should also increase reliability of feature_llmq_simplepose.py because it generate less quorums in each run and in total.

How Has This Been Tested?

Total time of test-suite is dropped from 294seconds to just 249seconds (while running locally in 30 parallel jobs -j30 built with -O3):

267/286 - rpc_help.py passed, Duration: 2 s
Remaining jobs: [feature_llmq_data_recovery.py, feature_block.py, p2p_quorum_data.py, feature_llmq_simplepose.py, feature_governance.py --legacy-wallet, feature_governance.py --descriptors, feature_csv_activation.py, p2p_addr_relay.py, p2p_compactblocks.py, p2p_add_connections.py, p2p_blockfilters.py, p2p_sendtxrcncl.py, feature_anchors.py, p2p_node_network_limited.py --v1transport, p2p_node_network_limited.py --v2transport, p2p_permissions.py, feature_config_args.py, feature_settings.py, feature_dirsymlinks.py]
268/286 - feature_llmq_simplepose.py passed, Duration: 195 s

... 
feature_llmq_simplepose.py                         | ✓ Passed  | 195 s
feature_llmq_simplepose.py --disable-spork23       | ✓ Passed  | 105 s
... 
ALL                                                | ✓ Passed  | 5998 s (accumulated)
Runtime: 249 s

Also there's no more outsiders amongs functional tests: the slowest functional tests are even slow:

feature_llmq_simplepose.py --disable-spork23       | ✓ Passed  | 105 s
feature_llmq_connections.py                        | ✓ Passed  | 106 s
p2p_sendheaders_compressed.py                      | ✓ Passed  | 114 s
p2p_sendheaders.py                                 | ✓ Passed  | 117 s
feature_llmq_chainlocks.py                         | ✓ Passed  | 122 s
p2p_addr_relay.py                                  | ✓ Passed  | 128 s
feature_csv_activation.py                          | ✓ Passed  | 130 s
p2p_tx_download.py                                 | ✓ Passed  | 137 s
feature_llmq_is_retroactive.py                     | ✓ Passed  | 139 s
feature_asset_locks.py                             | ✓ Passed  | 142 s
feature_governance.py --descriptors                | ✓ Passed  | 180 s
feature_governance.py --legacy-wallet              | ✓ Passed  | 181 s
feature_maxuploadtarget.py                         | ✓ Passed  | 190 s
feature_llmq_simplepose.py                         | ✓ Passed  | 195 s
feature_block.py                                   | ✓ Passed  | 196 s
feature_llmq_data_recovery.py                      | ✓ Passed  | 199 s
p2p_quorum_data.py                                 | ✓ Passed  | 209 s

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

knst added 4 commits April 23, 2025 22:20
…h test

It used to be tested only in feature_llmq_simplepose.py

The functional test feature_llmq_simplepose.py one of the slowest and mining 3 quorums less make it significantly faster
@github-actions
Copy link

This pull request has conflicts, please rebase.

@coderabbitai
Copy link

coderabbitai bot commented Apr 23, 2025

Walkthrough

The updates introduce several coordinated changes across functional test scripts and supporting test framework modules. In the masternode test framework, two new utility functions, check_punished and check_banned, are added to facilitate checking masternode punishment and ban status. The feature_llmq_simplepose.py test is refactored to use these new helpers, removes its own redundant checking methods, and adds a command-line option to toggle the SPORK_23_QUORUM_POSE spork, allowing conditional execution of PoSe banning tests based on spork state. The test_no_banning method signature is updated, and test logic is adjusted to reflect the new spork toggle. The mine_quorum method in the main test framework now asserts that all valid masternodes are neither punished nor banned after quorum mining. Additionally, the test runner is updated to include a new test entry that runs the feature_llmq_simplepose.py script with the spork23 disabling option. The feature_llmq_dkgerrors.py test is also updated to pass a filtered list of valid masternodes to quorum mining calls.


📜 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 9e3a0d6 and 7057df4.

📒 Files selected for processing (2)
  • test/functional/feature_llmq_simplepose.py (7 hunks)
  • test/functional/test_framework/masternodes.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/functional/test_framework/masternodes.py
  • test/functional/feature_llmq_simplepose.py
✨ 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.
    • 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.
  • @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 (4)
test/functional/test_framework/masternodes.py (2)

7-11: Simplify the function using a direct boolean return

The function can be simplified by returning the boolean expression directly.

def check_punished(node, mn):
    info = node.protx('info', mn.proTxHash)
-    if info['state']['PoSePenalty'] > 0:
-        return True
-    return False
+    return info['state']['PoSePenalty'] > 0
🧰 Tools
🪛 Ruff (0.8.2)

9-11: Return the condition info['state']['PoSePenalty'] > 0 directly

Replace with return info['state']['PoSePenalty'] > 0

(SIM103)


13-17: Simplify the function using a direct boolean return

Similarly, this function can also be simplified by returning the boolean expression directly.

def check_banned(node, mn):
    info = node.protx('info', mn.proTxHash)
-    if info['state']['PoSeBanHeight'] != -1:
-        return True
-    return False
+    return info['state']['PoSeBanHeight'] != -1
🧰 Tools
🪛 Ruff (0.8.2)

15-17: Return the condition info['state']['PoSeBanHeight'] != -1 directly

Replace with return info['state']['PoSeBanHeight'] != -1

(SIM103)

test/functional/feature_llmq_simplepose.py (2)

21-21: Remove unnecessary f-string prefix.

The f-string on line 21 doesn't contain any placeholders, so the f prefix can be removed.

- self.extra_args = [[ f'-testactivationheight=dip0024@9999' ]] * 6
+ self.extra_args = [[ '-testactivationheight=dip0024@9999' ]] * 6
🧰 Tools
🪛 Ruff (0.8.2)

21-21: f-string without any placeholders

Remove extraneous f prefix

(F541)


28-28: Fix help text for --disable-spork23 option.

The help text incorrectly mentions spork21 instead of spork23.

- help="Test with spork21 enabled")
+ help="Test with spork23 disabled")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db5d000 and d82c39c.

📒 Files selected for processing (5)
  • test/functional/feature_llmq_dkgerrors.py (2 hunks)
  • test/functional/feature_llmq_simplepose.py (7 hunks)
  • test/functional/test_framework/masternodes.py (1 hunks)
  • test/functional/test_framework/test_framework.py (2 hunks)
  • test/functional/test_runner.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
test/functional/feature_llmq_dkgerrors.py (1)
test/functional/test_framework/test_framework.py (1)
  • mine_quorum (1827-1913)
test/functional/test_framework/test_framework.py (1)
test/functional/test_framework/masternodes.py (2)
  • check_banned (13-17)
  • check_punished (7-11)
🪛 Ruff (0.8.2)
test/functional/feature_llmq_simplepose.py

21-21: f-string without any placeholders

Remove extraneous f prefix

(F541)

test/functional/test_framework/masternodes.py

9-11: Return the condition info['state']['PoSePenalty'] > 0 directly

Replace with return info['state']['PoSePenalty'] > 0

(SIM103)


15-17: Return the condition info['state']['PoSeBanHeight'] != -1 directly

Replace with return info['state']['PoSeBanHeight'] != -1

(SIM103)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: linux64_tsan-build / Build source
  • 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_nowallet-build / Build source
  • GitHub Check: win64-build / Build source
🔇 Additional comments (13)
test/functional/test_runner.py (1)

129-129: LGTM: Properly added spork23-disabled test variant

The new test variant with spork23 disabled is correctly added to the test suite. This supports the PR objective of splitting the test into two versions.

test/functional/test_framework/test_framework.py (2)

29-29: LGTM: Properly imported masternode utility functions

The new masternode utility functions are correctly imported from the new module.


1909-1912: LGTM: Added validation for masternode states after quorum mining

This enhancement ensures that after mining a quorum, all masternodes that should be valid are not punished or banned. This improves test validation and aligns with the PR objective of enhancing the mine_quorum helper.

test/functional/feature_llmq_dkgerrors.py (2)

27-28: LGTM: Defined valid masternodes for testing

Good addition of the mninfos_valid variable that excludes the first masternode (which will be simulating errors) from the validation checks.


31-31: LGTM: Consistently added valid masternode list to all quorum mining calls

All mine_quorum calls have been consistently updated to include the mninfos_valid parameter, ensuring that masternodes simulating errors aren't checked for punishment or banning inappropriately.

Also applies to: 37-37, 42-42, 51-51, 58-58, 64-64, 70-70

test/functional/feature_llmq_simplepose.py (8)

15-15: Good use of shared helper functions.

Importing external helper functions for checking masternode state improves code reuse and consistency across test files. This aligns well with the PR's goal of making the test more maintainable.


26-28: Well-structured CLI option for test splitting.

Adding the --disable-spork23 option enables running the test in two distinct modes, which is the key to the 33% speedup mentioned in the PR objectives. This approach allows testing both with and without PoSe banning while reducing the number of quorums generated per run.


31-34: Clear spork configuration based on CLI option.

The implementation properly sets SPORK_23_QUORUM_POSE to either disabled (far future timestamp) or enabled (0) based on the command-line option. This is a clean way to control the test behavior.


50-56: Effective conditional test execution.

This conditional logic ensures appropriate test paths are executed based on the spork state, which helps achieve the performance improvements mentioned in the PR objectives. When the spork is disabled, the test verifies that no banning occurs for non-reachable nodes.


61-65: Logical test flow for outdated protocol nodes.

Similar to the non-reachable node tests, this ensures appropriate testing paths for outdated protocol nodes based on the spork state. This conditional execution helps reduce unnecessary quorum generations when testing with spork disabled.


91-92: Good function signature enhancement.

The updated signature for test_no_banning makes the function more flexible by accepting an invalidate_proc parameter, allowing it to be used with different node invalidation strategies. This reduces code duplication.


160-162: Good defensive programming.

Adding assertions to verify that all nodes start in a non-punished, non-banned state ensures the test begins from a clean, known state. This helps prevent misleading test results and improves reliability.


182-182: Consistent use of helper functions.

The code consistently uses the imported check_banned and check_punished helper functions throughout the test, improving maintainability and code reuse. This aligns with good software engineering practices.

Also applies to: 195-195, 204-204, 224-224

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: 1

🔭 Outside diff range comments (1)
test/functional/test_framework/masternodes.py (1)

11-14: ⚠️ Potential issue

Fix syntax error in return statement.

There's a syntax error on line 13 - a colon (:) after the return condition is invalid in Python syntax.

-    return info['state']['PoSeBanHeight'] != -1:
+    return info['state']['PoSeBanHeight'] != -1
🧰 Tools
🪛 Ruff (0.8.2)

13-13: SyntaxError: Expected a statement


13-14: SyntaxError: Expected a statement

🧹 Nitpick comments (1)
test/functional/test_framework/masternodes.py (1)

1-14: Consider adding error handling for RPC calls.

The functions assume that the protx('info', proTxHash) call will always succeed and the expected fields will be present in the response. Consider adding error handling to make these functions more robust.

 def check_punished(node, mn):
-    info = node.protx('info', mn.proTxHash)
-    return info['state']['PoSePenalty'] > 0
+    try:
+        info = node.protx('info', mn.proTxHash)
+        return info['state'].get('PoSePenalty', 0) > 0
+    except Exception as e:
+        node.log.error(f"Error checking punishment status: {str(e)}")
+        return False

 def check_banned(node, mn):
-    info = node.protx('info', mn.proTxHash)
-    return info['state']['PoSeBanHeight'] != -1
+    try:
+        info = node.protx('info', mn.proTxHash)
+        return info['state'].get('PoSeBanHeight', -1) != -1
+    except Exception as e:
+        node.log.error(f"Error checking ban status: {str(e)}")
+        return False
🧰 Tools
🪛 Ruff (0.8.2)

9-9: SyntaxError: Expected a statement


9-10: SyntaxError: Expected a statement


13-13: SyntaxError: Expected a statement


13-14: SyntaxError: Expected a statement

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d82c39c and dd130a3.

📒 Files selected for processing (2)
  • test/functional/feature_llmq_simplepose.py (7 hunks)
  • test/functional/test_framework/masternodes.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/functional/feature_llmq_simplepose.py
🧰 Additional context used
🪛 Ruff (0.8.2)
test/functional/test_framework/masternodes.py

9-9: SyntaxError: Expected a statement


9-10: SyntaxError: Expected a statement


13-13: SyntaxError: Expected a statement

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_multiprocess / Build depends
🔇 Additional comments (1)
test/functional/test_framework/masternodes.py (1)

1-6: LGTM: Good documentation and license header.

The file header with license information and the docstring clearly explain the purpose of these utility functions.

@knst knst force-pushed the test-feature-llmq-simplepose branch from dd130a3 to 9e3a0d6 Compare April 23, 2025 15:41
@knst knst requested review from PastaPastaPasta and UdjinM6 April 23, 2025 17:10
@knst knst force-pushed the test-feature-llmq-simplepose branch from 9e3a0d6 to 7057df4 Compare April 24, 2025 14:40
@knst knst requested a review from UdjinM6 April 24, 2025 14:48
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 7057df4

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.

utACK 7057df4

@PastaPastaPasta PastaPastaPasta merged commit 351a753 into dashpay:develop Apr 28, 2025
33 of 34 checks passed
@UdjinM6 UdjinM6 added this to the 23 milestone Apr 30, 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