Skip to content

Conversation

@pauldelucia
Copy link

@pauldelucia pauldelucia commented Jul 28, 2025

Description by Korbit AI

What change is being made?

Introduce the spv functionality 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.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

quantum and others added 30 commits July 9, 2025 17:42
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>
pauldelucia and others added 8 commits July 21, 2025 15:08
- 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>
@korbit-ai
Copy link

korbit-ai bot commented Jul 28, 2025

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 /korbit-review.

Your admin can change your review schedule in the Korbit Console

@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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 skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@pauldelucia
Copy link
Author

/korbit-review

Copy link

@korbit-ai korbit-ai bot left a 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
Documentation Clean up debug logging ▹ view ✅ Fix detected
Documentation Missing context for ServiceUnavailable error ▹ view
Readability Debug Logging Obscures Core Logic ▹ view
Logging Temporary Debug Markers in Logs ▹ view ✅ Fix detected
Readability Inconsistent String Parameter Types ▹ view
Design Inappropriate NotImplemented Error in Domain Error Type ▹ view
Performance Inefficient Single UTXO Lookup ▹ view
Functionality Unused Height Parameter in Filter Header Storage ▹ view
Performance Sequential Lock Acquisitions ▹ view
Documentation 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.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +438 to +447
// 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)
};
Copy link

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 category Documentation

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +114 to +115
#[error("Storage service unavailable")]
ServiceUnavailable,
Copy link

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 category Documentation

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +117 to +118
#[error("Not implemented: {0}")]
NotImplemented(&'static str),
Copy link

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 category Design

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines 111 to 118
#[error("Lock poisoned: {0}")]
LockPoisoned(String),

#[error("Storage service unavailable")]
ServiceUnavailable,

#[error("Not implemented: {0}")]
NotImplemented(&'static str),
Copy link

Choose a reason for hiding this comment

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

Inconsistent String Parameter Types category Readability

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

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.

Comment on lines +112 to +115
async fn get_utxo(&self, outpoint: &OutPoint) -> StorageResult<Option<Utxo>> {
let utxos = self.inner.get_all_utxos().await?;
Ok(utxos.get(outpoint).cloned())
}
Copy link

Choose a reason for hiding this comment

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

Inefficient Single UTXO Lookup category Performance

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines 66 to 68
async fn store_filter_header(&mut self, header: &FilterHeader, height: u32) -> StorageResult<()> {
self.inner.store_filter_headers(&[*header]).await
}
Copy link

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 category Functionality

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines 32 to 38
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.

Comment on lines +402 to +403
let by_height = self.chain_locks_by_height.read().await;
let by_hash = self.chain_locks_by_hash.read().await;
Copy link

Choose a reason for hiding this comment

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

Sequential Lock Acquisitions category Performance

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines 100 to 114
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
);
}
Copy link

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 category Readability

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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

@PastaPastaPasta PastaPastaPasta force-pushed the feat/mempool-bloom-filters-chain-management branch from 408b997 to 18154d3 Compare July 30, 2025 15:24
@pauldelucia pauldelucia marked this pull request as ready for review August 5, 2025 03:17
@korbit-ai
Copy link

korbit-ai bot commented Aug 5, 2025

Korbit doesn't automatically review large (3000+ lines changed) pull requests such as this one. If you want me to review anyway, use /korbit-review.

@PastaPastaPasta PastaPastaPasta force-pushed the feat/mempool-bloom-filters-chain-management branch 2 times, most recently from 85c4502 to 5466f97 Compare August 12, 2025 03:46
@DCG-Claude DCG-Claude force-pushed the feat/mempool-bloom-filters-chain-management branch 2 times, most recently from 8180b4f to 1caa7b6 Compare August 12, 2025 14:06
@PastaPastaPasta PastaPastaPasta force-pushed the feat/mempool-bloom-filters-chain-management branch from ec29139 to 4fd651f Compare August 12, 2025 15:32
@QuantumExplorer QuantumExplorer deleted the feat/spv-in-det branch October 20, 2025 08:28
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.

2 participants