Add desktop handlers for XpubAnnounced and DescriptorAcked events#279
Add desktop handlers for XpubAnnounced and DescriptorAcked events#279kwsantiago merged 5 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
⌛ 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 (2)
WalkthroughThis PR adds DescriptorAcked and XpubAnnounced events, propagates ack/expected-ack counts through descriptor finalization, updates FROST event handling in the desktop client, and improves reconnection cleanup and descriptor progress reporting. (48 words) Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
keep-frost-net/src/node/descriptor.rs (1)
753-785:⚠️ Potential issue | 🟠 MajorSuppress duplicate ACK progress events to prevent stale downstream state updates.
add_ackis idempotent for duplicate senders, but this block still emitsDescriptorAcked(and can re-emitDescriptorComplete) when no new ACK was added. That creates redundant/noisy progress events and can cause UI state regressions after completion.Proposed fix
- let (is_complete, ack_count, expected_acks) = { + let (is_complete, ack_count, expected_acks, progressed) = { let mut sessions = self.descriptor_sessions.write(); let session = sessions .get_session_mut(&payload.session_id) .ok_or_else(|| FrostNetError::Session("unknown descriptor session".into()))?; + let before = session.ack_count(); session.add_ack( share_index, payload.descriptor_hash, &payload.key_proof_psbt, )?; + let ack_count = session.ack_count(); ( session.is_complete(), - session.ack_count(), + ack_count, session.expected_ack_count(), + ack_count > before, ) }; + + if !progressed { + return Ok(()); + } info!( session_id = %hex::encode(payload.session_id), share_index, ack_count, expected_acks, complete = is_complete, "Received descriptor ACK" );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@keep-frost-net/src/node/descriptor.rs` around lines 753 - 785, Summary: avoid emitting DescriptorAcked/DescriptorComplete when add_ack was idempotent and no new ACK was added. Fix: inside the block that locks descriptor_sessions and obtains session via get_session_mut(&payload.session_id), read the session's current ack count and completion state (e.g., let prev_ack_count = session.ack_count(); let prev_complete = session.is_complete()) before calling session.add_ack(...); call session.add_ack(...); then compute the new ack_count, expected_acks, and is_complete and only send KfpNodeEvent::DescriptorAcked if ack_count > prev_ack_count; likewise only emit DescriptorComplete when is_complete is true and prev_complete was false. Reference symbols: descriptor_sessions, get_session_mut, add_ack, ack_count, is_complete, expected_ack_count, KfpNodeEvent::DescriptorAcked, DescriptorComplete.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@keep-frost-net/src/node/descriptor.rs`:
- Around line 753-785: Summary: avoid emitting
DescriptorAcked/DescriptorComplete when add_ack was idempotent and no new ACK
was added. Fix: inside the block that locks descriptor_sessions and obtains
session via get_session_mut(&payload.session_id), read the session's current ack
count and completion state (e.g., let prev_ack_count = session.ack_count(); let
prev_complete = session.is_complete()) before calling session.add_ack(...); call
session.add_ack(...); then compute the new ack_count, expected_acks, and
is_complete and only send KfpNodeEvent::DescriptorAcked if ack_count >
prev_ack_count; likewise only emit DescriptorComplete when is_complete is true
and prev_complete was false. Reference symbols: descriptor_sessions,
get_session_mut, add_ack, ack_count, is_complete, expected_ack_count,
KfpNodeEvent::DescriptorAcked, DescriptorComplete.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
keep-desktop/src/frost.rskeep-desktop/src/message.rskeep-desktop/src/screen/wallet.rskeep-frost-net/src/descriptor_session.rskeep-frost-net/src/node/descriptor.rskeep-frost-net/src/node/mod.rs
3ec41f6 to
1cfd519
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@keep-desktop/src/frost.rs`:
- Around line 966-968: handle_reconnect_relay currently resets
frost_node/pending state but omits clearing self.active_coordinations, which can
leak stale sessions; update handle_reconnect_relay to mirror the disconnect-path
cleanup by acquiring the same lock(s) and clearing or reinitializing
self.active_coordinations (and any related pending coordination structures
touched in the 969-976 block) so no old coordination entries survive the
reconnect cycle.
In `@keep-frost-net/src/node/descriptor.rs`:
- Around line 903-906: The current logic in seen_xpub_announces that returns
Ok(()) when seen.len() >= 10_000 drops incoming announces and allows easy
saturation; instead, evict the oldest entry from the dedupe cache before
inserting the new announce so the cache stays capped but continues accepting
messages. Locate the capacity check around seen_xpub_announces (the block that
does if seen.len() >= 10_000 { tracing::warn!(...) ; return Ok(()); }) and
replace the early return with an eviction operation on the underlying data
structure (e.g., remove or pop the oldest key/entry) and then proceed to insert
the new announce, keeping the warn log to record the eviction event.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
keep-desktop/src/frost.rskeep-desktop/src/message.rskeep-desktop/src/screen/wallet.rskeep-frost-net/src/descriptor_session.rskeep-frost-net/src/node/descriptor.rskeep-frost-net/src/node/mod.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- keep-desktop/src/screen/wallet.rs
Summary
Summary by CodeRabbit
New Features
Bug Fixes