Wave 12-M: fix 22 engine Kani drift failures (unwind bump) - #108
Conversation
…roofs All 22 proofs in proofs_invariants.rs that used `#[kani::unwind(2)]` were failing with "unwinding assertion loop 0" at `RiskEngine::new_with_market` (src/percolator.rs:2121). Under `cfg(kani)` MAX_ACCOUNTS=4 so the free-list initialization loop runs 3 iterations, but `unwind(2)` rejects after just 2 unrolls. Bumping to `unwind(5)` (margin of 1) admits the loop while keeping verification tight. ## Fixed harnesses (22) - `proof_recovery_reason_*` (6): validators_reject_non_live_market, oracle_policy_unavailable_is_wrapper_only, account_b_settlement_is_global_unauthorized, explicit_loss_overflow_requires_saturation_flag, counter_or_epoch_overflow_requires_saturation, b_index_headroom_exhausted_requires_saturation - `proof_b_tracking_*` (5): shape_rejects_saturated_flag_out_of_range, shape_rejects_social_dust_at_or_above_denominator, shape_rejects_social_remainder_at_or_above_denominator, loss_weight_sum_overflow_rejects, shape_holds_at_genesis - `proof_validate_engine_state_shape_*` (3): delegates_to_bankrupt_close, delegates_to_b_tracking, holds_at_genesis - `proof_permissionless_progress_*` (3): rejects_non_live_non_resolved, rejects_when_active_close_present, resolved_routes_to_resolved_close - `proof_phantom_dust_certified_*` (2): gt_potential_rejects, le_potential_at_genesis - `proof_force_close_resolved_cursor_*` (2): rejects_zero_scan_limit, rejects_live_market - `proof_clear_active_bankrupt_close_state_zeros_all_fields` (1) ## Verification Spot-tested 5 of 22 harnesses individually after the unwind bump — all 5 now report VERIFICATION:- SUCCESSFUL: - proof_b_tracking_shape_holds_at_genesis ✓ - proof_b_tracking_loss_weight_sum_overflow_rejects ✓ - proof_validate_engine_state_shape_holds_at_genesis ✓ - proof_recovery_reason_validators_reject_non_live_market ✓ - proof_force_close_resolved_cursor_rejects_live_market ✓ - proof_phantom_dust_certified_le_potential_at_genesis ✓ Full re-run of all 366 engine harnesses in progress. ## Why this matters This drift was pre-existing on main BEFORE the Wave 12 sync work. The 22 harnesses were failing for at least the last several sessions but were never investigated because the failure mode looked like a real correctness issue (FAILURE on `unwinding assertion`). The actual cause was simple: the harnesses' `#[kani::unwind(2)]` annotation became incompatible with the engine's constructor loop after the `prev_free`/`next_free` doubly-linked free list was added in v12.18.1 (commit 498543d). The 21 sibling harnesses that use `#[kani::unwind(34)]` never had the issue. The 14 using `#[kani::unwind(2)]` (and one using `unwind(1)`) all needed at least `unwind(4)` to admit the MAX_ACCOUNTS=4 loop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates Kani bounded model checker unwind bounds from 2 to 5 across 25 proof harnesses in ChangesKani proof unwind bound updates
Possibly related PRs
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Adds 3 small Kani harnesses from upstream that fork was missing: ## proofs_v1131.rs (+2 harnesses) - proof_keeper_crank_accepts_positive_boundary_funding_rate_on_prod_code - proof_keeper_crank_accepts_negative_boundary_funding_rate_on_prod_code Both verify that `keeper_crank_not_atomic` accepts the configured funding-rate boundary (±max_abs_funding_e9_per_slot) cleanly. Pins the boundary-inclusive contract — off-by-one at the bound would have no other proof to catch it. ## proofs_instructions.rs (+1 harness) - proof_dynamic_trade_fee_above_cap_rejects_before_mutation Verifies that `execute_trade_not_atomic` rejects atomically when trade_fee_bps > params.max_trading_fee_bps, leaving all of vault, c_tot, insurance, both account capitals, and both position basis_q unchanged. ## Verification All 3 harnesses run individually post-port and report `VERIFICATION:- SUCCESSFUL`: - proof_keeper_crank_accepts_positive_boundary_...: 4.64s - proof_keeper_crank_accepts_negative_boundary_... (in v2 sweep) - proof_dynamic_trade_fee_above_cap_rejects_before_mutation: 5.15s Reduces upstream-only gap from 85 → 82 harnesses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Bumps `#[kani::unwind(2)]` → `#[kani::unwind(5)]` on 22 proofs in `tests/proofs_invariants.rs` that were failing with "unwinding assertion loop 0" at `RiskEngine::new_with_market`.
Root cause
Under `cfg(kani)` MAX_ACCOUNTS=4 (src/percolator.rs:67), so the free-list init loop at L2121 runs 3 iterations. `unwind(2)` rejects after 2 unrolls — needs ≥4. Pre-existing drift on main from before this session; not introduced by Wave 12 work.
The 21 sibling harnesses already use `#[kani::unwind(34)]` and never had this issue. The 14 using `unwind(2)` all needed the bump.
Categories fixed (22 total)
Verification
Spot-tested 6 of 22 harnesses individually post-fix — all 6 now report `VERIFICATION:- SUCCESSFUL`. Full 366-harness re-run in progress.
🤖 Generated with Claude Code
Summary by CodeRabbit
Note: This update is internal testing infrastructure with no user-facing changes.