-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: implement automatic detection of clsigs in blocks and process them #6236
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
base: develop
Are you sure you want to change the base?
feat: implement automatic detection of clsigs in blocks and process them #6236
Conversation
This pull request has conflicts, please rebase. |
- Add 13 unit tests covering chainlock construction, serialization, edge cases - Add functional test for automatic coinbase chainlock processing - Add test utilities for LLMQ testing infrastructure - Fix compilation errors and add proper error handling - Add edge case validation for height overflow and invalid data All tests pass successfully, resolving WIP status.
1dd9573
to
b15ed7e
Compare
|
…dBlockFromDisk - Add GetCoinbaseChainlock() that extracts chainlock directly from CBlock - Refactor GetNonNullCoinbaseChainlock() to use new function for backward compatibility - Update CChainLocksHandler::BlockConnected() to use efficient GetCoinbaseChainlock() - Add unit tests for both functions - Eliminates expensive ReadBlockFromDisk() call in hot path since CBlock is already available Performance improvement: Avoids disk I/O in automatic chainlock detection during block processing.
… type safety - Create CCoinbaseChainlock struct with signature and heightDiff members - Replace std::optional<std::pair<CBLSSignature, uint32_t>> with std::optional<CCoinbaseChainlock> - Update all usage sites across specialtxman, chainlocks, utils, miner, RPC, and simplifiedmns - Add comprehensive unit tests for new structure - Improve code readability and type safety Benefits: - Self-documenting structure (clear what signature/heightDiff represent) - Type-safe (prevents parameter swapping) - Consistent with existing chainlock patterns - Easier to maintain and extend
- Fix unsigned comparison error in chainlocks.cpp by changing clsig_height to int32_t - Remove trailing whitespace from test files - Fix executable permissions on feature_llmq_chainlocks_automatic.py These changes address the critical build failure and linting issues preventing CI from passing.
|
||
class LLMQChainLocksAutomaticTest(DashTestFramework): | ||
def set_test_params(self): | ||
self.set_dash_test_params(6, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider ab42708
firstly, you don't need to test masternode functionality, only just "some" chainlocks. Single-node-quorum speed up this functional test significantly.
Secondly, you should not isolate masternode for this functional test, because it adds instability in case if this masternode is in quorum. Instead, isolate regular node.
It takes only 18 seconds to run with my changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe even 71db9ad
it uses 1 less node and just 10 seconds to run
…solate node-1 (NOT Masternode) to avoid intermittent random failures
Warning Rate limit exceeded@github-actions[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 21 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (16)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This pull request has conflicts, please rebase. |
❌ Backport Verification - Issues DetectedOriginal Bitcoin commit: N/A (Dash-specific feature) Note: This is a Dash-specific feature implementing automatic chainlock signature detection, not a Bitcoin backport. Issues found and attempted fixes:
❌ Applied Fixes (Push Failed)diff --git a/test/functional/feature_llmq_chainlocks_automatic.py b/test/functional/feature_llmq_chainlocks_automatic.py
index 43d0928cfe..50a687a4ed 100755
--- a/test/functional/feature_llmq_chainlocks_automatic.py
+++ b/test/functional/feature_llmq_chainlocks_automatic.py
@@ -12,9 +12,8 @@ signatures embedded in coinbase transactions are automatically processed when
blocks are connected.
'''
-import time
from test_framework.test_framework import DashTestFramework
-from test_framework.util import assert_equal, assert_raises_rpc_error, force_finish_mnsync, wait_until_helper
+from test_framework.util import assert_equal
class LLMQChainLocksAutomaticTest(DashTestFramework):
@@ -127,7 +126,6 @@ class LLMQChainLocksAutomaticTest(DashTestFramework):
self.wait_for_chainlocked_block_all_nodes(block_hash)
# Verify that the chainlock system is still working normally
- final_height = self.nodes[0].getblockcount()
final_best_cl = self.nodes[0].getbestchainlock()
assert final_best_cl.get("height", -1) >= initial_height, \
@@ -145,7 +143,7 @@ class LLMQChainLocksAutomaticTest(DashTestFramework):
# Isolate node 1 and mine some blocks
self.isolate_node(1)
- isolated_blocks = self.generate(self.nodes[1], 2, sync_fun=self.no_op)
+ self.generate(self.nodes[1], 2, sync_fun=self.no_op)
# Reconnect and see if automatic detection still works
self.reconnect_isolated_node(1, 0)
diff --git a/test/functional/feature_llmq_singlenode.py b/test/functional/feature_llmq_singlenode.py
index acf93420f4..563921a088 100755
--- a/test/functional/feature_llmq_singlenode.py
+++ b/test/functional/feature_llmq_singlenode.py
@@ -6,13 +6,11 @@
'''
feature_llmq_singlenode.py
-Checks creating LLMQs signle node quorum creation and signing
+Checks creating LLMQs single node quorum creation and signing
This functional test is similar to feature_llmq_signing.py but difference are big enough to make implementation common.
'''
-import time
-
from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import (
DashTestFramework, Manual Fix Required: Remaining Issues:
|
Issue being fixed or feature implemented
This PR implements automatic detection and processing of chainlock signatures (CLSIGs) embedded in coinbase transactions. Currently, chainlock signatures in coinbase transactions are only stored but not automatically processed when blocks are connected. This enhancement enables automatic detection and processing of these signatures, improving the efficiency of the chainlock system.
What was done?
CChainLocksHandler
to automatically detect chainlock signatures from coinbase transactions usingGetNonNullCoinbaseChainlock()
How Has This Been Tested?
Unit Tests: 13 comprehensive test cases in
src/test/llmq_chainlock_tests.cpp
covering:Functional Tests: End-to-end test in
test/functional/feature_llmq_chainlocks_automatic.py
covering:All tests pass successfully: Unit tests (13/13) and functional tests complete without errors
No performance regression: Tested with existing chainlock functionality
Backward compatibility: Maintains compatibility with existing chainlock processing
Breaking Changes
None. This is a backward-compatible enhancement that extends existing functionality without modifying existing behavior.
Checklist: