Skip to content

Comments

fix: add iteration limit to SPV fee calculation loop#620

Open
thepastaclaw wants to merge 1 commit intodashpay:v1.0-devfrom
thepastaclaw:fix/spv-fee-loop-limit
Open

fix: add iteration limit to SPV fee calculation loop#620
thepastaclaw wants to merge 1 commit intodashpay:v1.0-devfrom
thepastaclaw:fix/spv-fee-loop-limit

Conversation

@thepastaclaw
Copy link
Collaborator

@thepastaclaw thepastaclaw commented Feb 22, 2026

Replace unbounded loop with a capped for loop (max 50 iterations) in the SPV fee calculation to prevent potential infinite loops.

Problem

The fee estimation loop in build_transaction_for_spv_wallet uses an unbounded loop that adjusts a scale factor to find a valid transaction. If the scale factor converges without meeting either exit condition (successful build or InsufficientFunds with no progress), the loop runs forever.

Fix

Cap the loop at 50 iterations and return a clear error if no valid transaction is found within that budget. 50 iterations is generous — in practice, convergence happens within 2-3 iterations.

Cherry-picked from ralph/improvements (commit 557acb2).

Validation

What was tested:

  • cargo clippy --all-features --all-targets -- -D warnings — lint check
  • cargo test --all-features --workspace — full workspace test suite

Results:

  • All local commands passed
  • Clippy CI check — pass (5m27s)
  • Test Suite CI check — pass (7m1s)

Environment: Local macOS arm64; GitHub Actions CI (ubuntu-latest)

Replace unbounded loop with a capped for loop (max 50 iterations)
in the SPV fee calculation to prevent potential infinite loops when
the scale factor converges but never meets the exit condition.

Cherry-picked from ralph/improvements (commit 557acb2).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

Warning

Rate limit exceeded

@thepastaclaw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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

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

@thepastaclaw
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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