-
Notifications
You must be signed in to change notification settings - Fork 0
feat: spv working in det #1
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: feat/mempool-bloom-filters-chain-management
Are you sure you want to change the base?
feat: spv working in det #1
Conversation
Remove hardcoded localhost addresses from mainnet and testnet seed lists. These were causing unnecessary connection attempts during initial sync
- Add DetailedSyncProgress struct with performance metrics - Headers per second, bytes per second, ETA calculation - Sync stage tracking (Connecting, Querying, Downloading, etc.) - Add SyncStage enum for granular progress states - Add filter_sync_available field to track peer capabilities - Add supports_compact_filters() helper to PeerInfo - Add progress channel to DashSpvClient for real-time updates - Add is_filter_sync_available() method to check peer support This enables better progress reporting and performance monitoring for SPV sync operations.
- Add intermediate handshake states for better debugging: - VersionReceivedVerackSent: Version received, verack sent - VerackReceived: Verack received from peer - Add tracking flags for version_received, verack_received, version_sent - Improve logging throughout handshake process - Better error messages with handshake state information This makes handshake debugging easier and provides clearer state transitions during peer connection establishment.
- Reduce header sync timeout from 10s to 4s for faster failure detection - Change status update interval from 5s to 500ms for smoother progress - Add detailed logging for sync process including locator info - Improve empty locator handling for genesis sync These changes provide more responsive sync behavior and better real-time progress feedback.
- Enhanced status display with better formatting and metrics - Improved network connection handling and error recovery - Updated network constants for better peer management - Enhanced multi-peer connection logic with better peer selection - Improved filter sync with better error handling - General sync module improvements for reliability These changes collectively improve the stability and performance of the SPV client's network and synchronization operations.
Change header sync timeout from 4 seconds to 500 milliseconds for more responsive timeout detection during sync operations.
- Add Swift SDK package with comprehensive Dash Core functionality - Implement SPV client FFI bindings with async/await support - Add HD wallet integration via key-wallet-ffi - Create example iOS app demonstrating wallet and SPV features - Include persistent wallet storage and transaction management - Add network FFI bindings for Swift integration - Update CLAUDE.md with build instructions and project structure - Include build scripts for iOS targets (arm64, x86_64) - Add comprehensive documentation and implementation plans 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add env_logger dependency for better debugging - Add FFIDetailedSyncProgress struct with comprehensive sync metrics - Add FFISyncStage enum for granular sync state tracking - Add sync-specific callbacks for progress and completion events - Add test_sync function for verifying sync functionality - Update cbindgen configuration to exclude internal callback types - Enhance FFI client with sync progress channels and callbacks - Update tests to handle new sync progress features This enables FFI consumers to track detailed sync progress including headers per second, ETA, sync stages, and real-time updates.
- Add detailed project overview and structure - Include build commands for Rust and FFI targets - Add test commands and environment variables - Document development commands (linting, formatting, docs) - Include key features (Dash-specific and architecture) - Add code style guidelines and constraints - Document Git workflow and current status - Add security considerations and API stability notes - Include known limitations This provides comprehensive guidance for Claude Code when working with the rust-dashcore repository.
- Simplify DashSPVFFI.swift by removing empty namespace enum - Update dash_spv_ffi.h with new FFI types matching Rust implementation - Add FFISyncStage, FFIDetailedSyncProgress types - Update function signatures for enhanced sync tracking - Add invalidArgument error case to DashSDKError - Provides better error handling for invalid inputs - Includes helpful error messages and recovery suggestions These changes align the Swift SDK with the updated Rust FFI layer and improve error handling capabilities.
Add documentation file to provide Claude Code with context and guidance when working with the Swift SDK package. This helps maintain consistency and understanding of the SDK structure.
- Add EnhancedSyncProgressView for detailed sync progress display - Add SettingsView for app configuration - Add ModelContainerHelper for SwiftData management - Update project configuration and build scripts - Improve wallet services with better error handling - Enhanced UI with platform-specific colors and layouts - Add comprehensive documentation: - DEBUG_SUMMARY.md for debugging tips - IOS_APP_SETUP_GUIDE.md for setup instructions - LINKING_FIX.md for resolving linking issues - SPM_LINKING_SOLUTION.md for Swift Package Manager setup - Add DashSPVFFI.xcframework support - Update build phase script for better library management - Improve wallet models with better persistence support This provides a more complete example app demonstrating HD wallet functionality with SPV sync capabilities and improved user experience.
Remove libdash_spv_ffi.a from version control. Binary artifacts should be built locally and not committed to the repository.
- Build and copy key_wallet_ffi libraries for both simulator and device - Create symlinks for both dash_spv_ffi and key_wallet_ffi libraries - Default symlinks point to simulator versions for development - Improve output messages with detailed library information This enables the iOS example app to use both SPV and wallet FFI functionality with proper library management.
- Add mempool_filter module for transaction filtering - Implement mempool transaction storage and callbacks - Add mempool transaction types and event handling - Update storage layer to support mempool transactions - Add FFI bindings for mempool events - Add Swift types for mempool transactions This enables SPV clients to track and filter mempool transactions, providing real-time transaction updates before blockchain confirmation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Enhance block processor for better balance updates - Update FFI wallet bindings with improved error handling - Add immature balance tracking to Swift Balance model - Improve persistent wallet management with better error handling - Add comprehensive balance calculations in WalletManager 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add SPV client verification methods and retry management - Implement comprehensive mempool support in Swift SDK - Add WatchStatusView for monitoring address watch status - Enhance WalletService with improved SPV integration - Update FFI bridge with new callback handlers - Improve error handling and state management - Add support for mempool transactions in example app - Update build script with improved error handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update root CLAUDE.md with recent development notes - Add mempool implementation details to dash-spv CLAUDE.md - Update dash-spv README with mempool features - Enhance Swift SDK documentation with new features - Update BUILD.md with improved build instructions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Enhance address derivation with better error handling - Update BIP32 implementation for improved compatibility - Refactor DIP9 address derivation methods - Update Dash network constants and checkpoint data - Improve examples and test coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add mempool configuration options to client config - Enhance consistency checks and filter sync - Improve network connection and message handling - Add comprehensive chainlock and instantlock validation - Refactor sync module for better modularity - Update multi-peer connection management - Add new error types for mempool operations - Update dependencies and test configurations This improves the overall reliability and performance of the SPV client with better error handling and validation mechanisms. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add terminal block data to support deterministic masternode list synchronization. Terminal blocks contain masternode list snapshots at specific heights, enabling efficient sync without downloading all intermediate blocks. - Add mainnet terminal blocks (heights 1088640-2000000) - Add testnet terminal blocks (heights 387480-900000) - Implement terminal block loading and validation - Add tests and examples for terminal block usage - Include script for fetching terminal block data from nodes This enables SPV clients to quickly sync masternode lists by jumping to known terminal blocks instead of processing every block from genesis. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add common library file extensions to prevent build artifacts from being committed: - *.a (static libraries) - *.so (Linux shared libraries) - *.dylib (macOS dynamic libraries) - *.dll (Windows dynamic libraries) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add simple example that verifies genesis block generation for mainnet and testnet networks. This helps ensure the genesis block constants are correctly defined. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Enhanced sync managers for headers and masternodes - Improved error handling and logging in sync components - Added support for sequential sync coordination - Better timeout and retry logic for sync operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move implementation documentation to organized structure - Add bloom filter specification - Document sequential sync design - Include peer reputation system documentation - Document fixes and implementation summaries 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add multi-peer connection management - Improve handshake protocol handling - Enhanced message routing and error handling - Better connection resilience and retry logic - Add peer reputation tracking foundation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ntegration - Add mempool transaction tracking with configurable strategies - Implement balance calculations including unconfirmed transactions - Enhanced wallet address management and UTXO tracking - Improved error handling with specific error types - Add transaction relevance checking for watched addresses 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add mempool tracking configuration to FFI - Implement mempool-specific event callbacks - Add balance queries including mempool transactions - Enhanced error handling with specific error codes - Support for recording sent transactions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add BIP37 bloom filter message type definitions - Define bloom filter constants (max size, hash functions) - Add bloom filter update flags enum - Update network protocol with bloom filter support - Prepare for future bloom filter implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add mempool transaction tracking to Swift SDK - Implement mempool event types and callbacks - Enhanced balance calculations with unconfirmed transactions - Improved transaction model with mempool state - Add error handling types for better debugging - Update example app to demonstrate mempool features 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move diff count increment to success case only to ensure accurate tracking - Add debug logging for diff completion checks and state tracking - Handle storage height exceeding tip gracefully by adjusting to available data - Fix phase completion logic to verify target height is actually reached - Re-start masternode sync if it reports complete but hasn't reached target - Add masternode engine state logging after applying diffs This improves sync reliability when dealing with partial syncs, phase transitions, and edge cases where the requested height exceeds available data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
/korbit-review |
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Clean up debug logging ▹ view | ✅ Fix detected | |
| Missing context for ServiceUnavailable error ▹ view | ||
| Debug Logging Obscures Core Logic ▹ view | ||
| Temporary Debug Markers in Logs ▹ view | ✅ Fix detected | |
| Inconsistent String Parameter Types ▹ view | ||
| Inappropriate NotImplemented Error in Domain Error Type ▹ view | ||
| Inefficient Single UTXO Lookup ▹ view | ||
| Unused Height Parameter in Filter Header Storage ▹ view | ||
| Sequential Lock Acquisitions ▹ view | ||
| Unclear Block Version Change Rationale ▹ view |
Files scanned
Due to the exceptionally large size of this PR, I've limited my review to the following files:
| File Path | Reviewed |
|---|---|
| dash-spv/src/lib.rs | ✅ |
| dash-spv/src/network/pool.rs | ✅ |
| dash-spv/examples/sync_progress_demo.rs | ✅ |
| dash-spv/src/error.rs | ✅ |
| dash/src/sml/masternode_list/quorum_helpers.rs | ✅ |
| dash-spv/src/sync/terminal_block_data/mod.rs | ✅ |
| dash-spv/src/storage/mod.rs | ✅ |
| dash-spv/src/storage/disk_backend.rs | ✅ |
| dash/src/sml/llmq_type/mod.rs | ✅ |
| dash-spv/src/client/status_display.rs | ✅ |
| dash-spv/src/sync/sequential/transitions.rs | ✅ |
| dash-spv/src/storage/memory_backend.rs | ✅ |
| dash-spv/src/main.rs | ✅ |
| dash-spv/src/client/builder.rs | ✅ |
| dash-spv/src/chain/checkpoints.rs | ✅ |
| dash-spv/src/chain/reorg.rs | ✅ |
| dash-spv/src/chain/chainlock_manager.rs | ✅ |
| dash-spv/src/storage/compat.rs | ✅ |
| dash-spv/src/network/connection.rs | ✅ |
| dash-spv/src/types.rs | ✅ |
| dash-spv/src/storage/service.rs | ✅ |
| dash/src/sml/masternode_list_engine/mod.rs | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| // Determine version based on height | ||
| let version = if height == 0 { | ||
| 1 // Genesis block version | ||
| } else if height < 750000 { | ||
| 2 // Pre-v0.12 blocks | ||
| } else if height < 1700000 { | ||
| 536870912 // v0.12+ blocks (0x20000000) | ||
| } else { | ||
| 536870912 // v0.14+ blocks (0x20000000) | ||
| }; |
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.
Unclear Block Version Change Rationale 
Tell me more
What is the issue?
The block version determination logic contains unclear inline comments that don't explain why these specific heights trigger version changes.
Why this matters
Without understanding the rationale behind version changes at specific heights, future maintainers might modify these values incorrectly during network upgrades.
Suggested change ∙ Feature Preview
// Block version transitions based on historical network upgrades:
let version = if height == 0 {
1 // Original protocol genesis block
} else if height < 750000 {
2 // Initial block version before HD wallet upgrade
} else if height < 1700000 {
536870912 // Version bits activated after v0.12.0 fork (0x20000000)
} else {
536870912 // Maintained same version after v0.14.0 upgrade (0x20000000)
};
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| #[error("Storage service unavailable")] | ||
| ServiceUnavailable, |
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.
Missing context for ServiceUnavailable error 
Tell me more
What is the issue?
The newly added ServiceUnavailable variant lacks a description of when this error occurs, unlike other variants in the enum.
Why this matters
Without context about when this error occurs, developers will have difficulty handling this error case appropriately in their code.
Suggested change ∙ Feature Preview
/// Indicates the storage service is temporarily unavailable or cannot be reached
#[error("Storage service unavailable")]
ServiceUnavailable,
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| #[error("Not implemented: {0}")] | ||
| NotImplemented(&'static str), |
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.
Inappropriate NotImplemented Error in Domain Error Type 
Tell me more
What is the issue?
Using NotImplemented error variant in StorageError enum is a design smell. Storage errors should represent actual storage-related failures rather than implementation status.
Why this matters
This mixes implementation details with domain errors, violating the Single Responsibility Principle. NotImplemented is a development status rather than a storage error condition.
Suggested change ∙ Feature Preview
Remove NotImplemented from StorageError and handle unimplemented features either through compile-time mechanisms like unimplemented!() macro or a separate development-specific error type.
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| #[error("Lock poisoned: {0}")] | ||
| LockPoisoned(String), | ||
|
|
||
| #[error("Storage service unavailable")] | ||
| ServiceUnavailable, | ||
|
|
||
| #[error("Not implemented: {0}")] | ||
| NotImplemented(&'static str), |
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.
Inconsistent String Parameter Types 
Tell me more
What is the issue?
Inconsistent string parameter types across error variants within StorageError - mixing String and &'static str.
Why this matters
Mixing string parameter types makes error handling code less predictable and requires different handling approaches for different variants.
Suggested change ∙ Feature Preview
Standardize on using String for all error variants:
#[error("Lock poisoned: {0}")]
LockPoisoned(String),
#[error("Storage service unavailable")]
ServiceUnavailable,
#[error("Not implemented: {0}")]
NotImplemented(String),Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
dash-spv/src/storage/disk_backend.rs
Outdated
| impl StorageBackend for DiskStorageBackend { | ||
| // Header operations | ||
| async fn store_header(&mut self, header: &BlockHeader, height: u32) -> StorageResult<()> { | ||
| tracing::debug!("[HANG DEBUG] DiskStorageBackend::store_header called for height {}", height); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| async fn get_utxo(&self, outpoint: &OutPoint) -> StorageResult<Option<Utxo>> { | ||
| let utxos = self.inner.get_all_utxos().await?; | ||
| Ok(utxos.get(outpoint).cloned()) | ||
| } |
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.
Inefficient Single UTXO Lookup 
Tell me more
What is the issue?
The get_utxo function inefficiently loads all UTXOs just to find a single one, which could significantly impact performance when dealing with a large number of UTXOs.
Why this matters
Loading the entire UTXO set into memory for each single UTXO lookup wastes resources and could cause performance bottlenecks in production environments.
Suggested change ∙ Feature Preview
Implement a direct single UTXO lookup in the inner DiskStorageManager instead of loading all UTXOs:
async fn get_utxo(&self, outpoint: &OutPoint) -> StorageResult<Option<Utxo>> {
self.inner.get_utxo(outpoint).await
}Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
dash-spv/src/storage/disk_backend.rs
Outdated
| async fn store_filter_header(&mut self, header: &FilterHeader, height: u32) -> StorageResult<()> { | ||
| self.inner.store_filter_headers(&[*header]).await | ||
| } |
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.
Unused Height Parameter in Filter Header Storage 
Tell me more
What is the issue?
The height parameter in store_filter_header is not being used when calling store_filter_headers, which could lead to filter headers being stored at incorrect heights.
Why this matters
Without using the height parameter, the system might store filter headers at incorrect positions in the chain, potentially corrupting the filter header chain.
Suggested change ∙ Feature Preview
Pass the height to the inner implementation:
async fn store_filter_header(&mut self, header: &FilterHeader, height: u32) -> StorageResult<()> {
self.inner.store_filter_headers_at_height(&[*header], height).await
}Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| async fn store_header(&mut self, header: &BlockHeader, height: u32) -> StorageResult<()> { | ||
| tracing::debug!("[HANG DEBUG] DiskStorageBackend::store_header called for height {}", height); | ||
| // Use store_headers_from_height to specify the exact height | ||
| let result = self.inner.store_headers_from_height(&[*header], height).await; | ||
| tracing::debug!("[HANG DEBUG] DiskStorageBackend::store_header completed for height {}: {:?}", height, result.is_ok()); | ||
| result | ||
| } |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| let by_height = self.chain_locks_by_height.read().await; | ||
| let by_hash = self.chain_locks_by_hash.read().await; |
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.
Sequential Lock Acquisitions 
Tell me more
What is the issue?
Multiple sequential read locks are acquired for both height and hash maps when a single lock duration could cover both operations.
Why this matters
Sequential lock acquisitions increase lock contention and total lock hold time, potentially reducing concurrent performance.
Suggested change ∙ Feature Preview
Combine sequential read lock operations under a single lock acquisition:
let (highest_height, total_locks) = {
let by_height = self.chain_locks_by_height.read().await;
let by_hash = self.chain_locks_by_hash.read().await;
(by_height.keys().max().cloned(), by_height.len())
};Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| tracing::debug!( | ||
| "Looking for quorum hash {} in {} quorums of type {:?}", | ||
| quorum_hash, | ||
| quorums_of_type.len(), | ||
| llmq_type | ||
| ); | ||
|
|
||
| // Log all stored hashes for comparison | ||
| for (stored_hash, _) in quorums_of_type { | ||
| tracing::debug!( | ||
| " Stored quorum hash: {} (matches: {})", | ||
| stored_hash, | ||
| stored_hash == &quorum_hash | ||
| ); | ||
| } |
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.
Debug Logging Obscures Core Logic 
Tell me more
What is the issue?
Verbose debug logging in the middle of core business logic makes the function's primary purpose harder to understand at a glance.
Why this matters
Debug logging mixed with business logic increases cognitive load when reading the code. It obscures the main flow and makes maintenance more difficult.
Suggested change ∙ Feature Preview
Move the debug logging to a separate private method:
fn log_quorum_search(&self, llmq_type: LLMQType, quorum_hash: &QuorumHash, quorums_of_type: &HashMap<QuorumHash, QualifiedQuorumEntry>) {
tracing::debug!(/* ... */);
for (stored_hash, _) in quorums_of_type {
tracing::debug!(/* ... */);
}
}Then call it before the actual lookup in the main function.
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
408b997 to
18154d3
Compare
85c4502 to
5466f97
Compare
8180b4f to
1caa7b6
Compare
ec29139 to
4fd651f
Compare
Description by Korbit AI
What change is being made?
Introduce the
spvfunctionality in the Dash Ecosystem with significant updates across the codebase including enhancements to FFI bindings, addition of mempool tracking capabilities, and documentation improvements.Why are these changes being made?
These changes integrate the Simplified Payment Verification (SPV) client into the dash network FFI, enabling more robust interaction capabilities with the Dash network. Enhancements include improved library size management through Unified SDK for iOS, updated callback mechanisms for event handling, and comprehensive test suites to ensure reliability across SPV modules. This is part of an ongoing effort to improve code modularity and usability, especially for mobile platforms.