Skip to content

keep-frost-net: split KfpMessage::validate into per-variant validators#824

Merged
kwsantiago merged 1 commit into
mainfrom
refactor/frost-net-validate-split
Jul 16, 2026
Merged

keep-frost-net: split KfpMessage::validate into per-variant validators#824
kwsantiago merged 1 commit into
mainfrom
refactor/frost-net-validate-split

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

KfpMessage::validate was a 552-line match carrying the wire-validation checks (size caps, index bounds, charset/prefix checks, derivation-path rules, xpub parsing, etc.) for every message variant inline. This splits each variant's checks into its own validator.

Changes

  • Each non-trivial arm's body becomes a private free function validate_<variant>(p: &<Variant>Payload) -> Result<(), &'static str> (28 of them).
  • validate (552 → 33 lines) is now a dispatch match returning each validator's result, with _ => Ok(()) for the variants that carry no checks (SignatureComplete, DuressBeacon, Ping, Pong).

Every resulting function is under 100 lines (largest: validate_psbt_propose at 80).

Behavior

Pure code motion. Every check, threshold constant, error string, and helper call (decode_pcr_values, is_valid_fingerprint, Xpub::parse, the nonce-ref/sentinel logic, etc.) is unchanged. The _ => Ok(()) catch-all preserves the original _ => {} + trailing Ok(()) behavior for the four variants that were already validation-free; RefreshRound1 and RefreshRound2, which DO carry checks, are dispatched explicitly (not folded into the catch-all).

Verification

  • cargo clippy -p keep-frost-net --all-targets: clean.
  • keep-frost-net unit suite: 434 passed.
  • multinode integration suite (--features testing --test multinode_test): 40 passed.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kwsantiago, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ee026f3-5b4a-4f82-8b3d-62077ebd22cf

📥 Commits

Reviewing files that changed from the base of the PR and between b382711 and ba1f58b.

📒 Files selected for processing (1)
  • keep-frost-net/src/protocol.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/frost-net-validate-split

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.

@kwsantiago kwsantiago merged commit f468f81 into main Jul 16, 2026
9 checks passed
@kwsantiago kwsantiago deleted the refactor/frost-net-validate-split branch July 16, 2026 03:12
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.

1 participant