Skip to content

fix(dash-spv): remove overly-strict is_synced gate from broadcast#656

Open
QuantumExplorer wants to merge 1 commit intov0.42-devfrom
fix/spv-broadcast-is-synced-gate
Open

fix(dash-spv): remove overly-strict is_synced gate from broadcast#656
QuantumExplorer wants to merge 1 commit intov0.42-devfrom
fix/spv-broadcast-is-synced-gate

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 17, 2026

Summary

The dispatch_local gate added in #626 rejected broadcast_transaction whenever sync_progress().is_synced() returned false. is_synced() is the aggregate of every sync manager (headers / filter_headers / filters / blocks / masternodes) — any single manager briefly transitioning to WaitForEvents (e.g. the blocks manager reacting to a new chain tip) flips the aggregate and blocks broadcasts.

In end-to-end tests this surfaced as intermittent SpvBroadcastFailed { detail: "Client is not synced" } errors well after initial sync had completed. The gate also doesn't protect anything the peer-level broadcast path doesn't already handle — peers reject unfit-for-propagation txs on their own. Drop it.

Extracted from

This commit was cherry-picked from feat/platform-wallet2 (the in-progress platform-wallet branch, draft PR #655). Pulling it into its own PR so it can land independently.

Test plan

  • cargo build -p dash-spv --all-features
  • cargo test -p dash-spv --all-features --lib — 370 passed / 0 failed
  • Single-file change (dash-spv/src/client/transactions.rs, −5 / +1).

🤖 Extracted with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Transactions can now be broadcast without requiring full client synchronization; only an active peer connection is needed to proceed.

The `dispatch_local` fix in #626 added a gate that rejected
`broadcast_transaction` whenever `sync_progress().is_synced()`
returned false. `is_synced()` requires *every* sync manager
(headers / filter_headers / filters / blocks / masternodes) to be in
`SyncState::Synced` simultaneously — any manager transitioning to
`WaitForEvents` (e.g. the blocks manager briefly reacting to a new
chain tip) flips the aggregate to "not synced" and blocks
broadcasts.

In end-to-end tests this manifested as intermittent
`SpvBroadcastFailed { detail: "Client is not synced" }` errors in
the middle of normal operation, hours after initial sync had
completed. The gate served no purpose the underlying broadcast
protocol doesn't already handle — peers themselves reject
unfit-for-propagation txs. Drop it.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 319d0a33-911c-4f1d-ba7a-15a38baf2935

📥 Commits

Reviewing files that changed from the base of the PR and between e15ea34 and 0b7395b.

📒 Files selected for processing (1)
  • dash-spv/src/client/transactions.rs

📝 Walkthrough

Walkthrough

The broadcast_transaction function in the DashSPV client no longer performs a synchronization state check before broadcasting. Instead, it directly validates peer connectivity and proceeds with transaction broadcasting and injection into the message pipeline, reducing preliminary validation steps.

Changes

Cohort / File(s) Summary
Transaction Broadcasting
dash-spv/src/client/transactions.rs
Removed sync status check from broadcast_transaction; function now directly validates connected peers exist before broadcasting and injecting transaction into message pipeline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A sync check takes a hop away,
Now peers connect without delay,
Transactions flow, no waiting stage,
The network speaks on center stage! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: removing the overly-strict is_synced gate from the broadcast_transaction function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/spv-broadcast-is-synced-gate

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.05%. Comparing base (e15ea34) to head (0b7395b).

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #656      +/-   ##
=============================================
- Coverage      68.08%   68.05%   -0.04%     
=============================================
  Files            319      319              
  Lines          67646    67643       -3     
=============================================
- Hits           46057    46032      -25     
- Misses         21589    21611      +22     
Flag Coverage Δ
core 75.52% <ø> (ø)
ffi 37.77% <ø> (-0.18%) ⬇️
rpc 20.00% <ø> (ø)
spv 85.82% <ø> (-0.04%) ⬇️
wallet 68.08% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/client/transactions.rs 90.00% <ø> (+5.38%) ⬆️

... and 4 files with indirect coverage changes

@github-actions github-actions bot added the ready-for-review CodeRabbit has approved this PR label Apr 18, 2026
Copy link
Copy Markdown
Collaborator

@ZocoLini ZocoLini left a comment

Choose a reason for hiding this comment

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

I believe I asked Kevin for this check in the past and he gave me a reason for its existence, I would like to wait for him to approve this. About the intermittent errors after sync completed, I have never experienced that situation, but if it is a possibility, it means we have a bug and is_synced is returning false after sync, would you be able to share a case where this can happen??

@xdustinface
Copy link
Copy Markdown
Collaborator

It will return false temporarily for incremental sync updates. I think instead of removing this check it would be better to make it so that we check if the initial sync was done rather. I will not block on this PR if you wanna get it in do it but i dont think its a good idea because the underlying issue it might cause is not handled.

@QuantumExplorer
Copy link
Copy Markdown
Member Author

There's no reason not to broadcast a transaction while we are syncing. The worst thing that could happen is that you haven't fully synced and the transaction will be rejected. Generally this will only happen on imported wallets, and imo should be a different wallet level check on new imported wallets.

@xdustinface
Copy link
Copy Markdown
Collaborator

There is a reason. In this path we inject the broadcasted transactions back into our network message queue as local message since there is no mempool rejection reponse and the peers wont relay our own tx back to us. Which means we will process the transaction and store it in the wallet even though the utxos used in there might already be spent in chain or mempool which then is not recoverable because this cases are not handled internally.

Yes having this check doesnt solve all the issues but its a small safe guard to at least avoid some. Anyway, i just thought it would be good to least put some thougts into all this before just removing this check.

In my opinion a wallet always should be synced before it can be used. Same for creating transactions and anything else. Synced should be a requirement not an option since having it optional just increases lots of weird edge cases and compexity that needs to be handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants