fix(ckdoge): correct 1000x underestimate of minter fee in minimum withdrawal amount - #11609
Draft
claude[bot] wants to merge 2 commits into
Draft
claude[bot] wants to merge 2 commits into
claude[bot] wants to merge 2 commits into
Conversation
…hdrawal amount fee_based_minimum_withdrawal_amount() used a hardcoded PER_REQUEST_MINTER_FEE_BOUND of 326_000 koinu as the budgeted minter fee for a typical (2 input, 2 output) transaction. The actual minter fee for such a transaction, per evaluate_minter_fee(2, 2), is 326_000_000 koinu (146_000_000 * 2 + 4_000_000 * 2 + 26_000_000), a 1000x difference. Replace the hardcoded constant with a call to evaluate_minter_fee(2, 2) so the bound stays derived from the actual fee-computation logic instead of drifting out of sync with it. Added a regression test that isolates the fee budget from retrieve_doge_min_amount and asserts it covers the actual two-input minter fee; it fails against the old constant (700_002 < 326_000_000) and passes with the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JY8x7iMNPGW52tSwyvR7M7
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The shared fee calculation is used consistently and the regression test directly covers the reported error.
Pull request overview
Corrects ckDOGE’s minimum withdrawal calculation to include the actual typical transaction minter fee.
Changes:
- Derives the fee bound from
evaluate_minter_fee(2, 2). - Adds regression coverage for the previous 1000× underestimate.
File summaries
| File | Description |
|---|---|
rs/dogecoin/ckdoge/minter/src/fees/mod.rs |
Corrects the minter fee bound. |
rs/dogecoin/ckdoge/minter/src/fees/tests.rs |
Adds regression coverage. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Extract evaluate_minter_fee's computation into an inherent const fn (DogecoinFeeEstimator::minter_fee), since the trait method itself cannot be const on stable Rust (trait impls cannot declare const fns). This lets PER_REQUEST_MINTER_FEE_BOUND go back to being a const, as it was before the fix. - Remove a now-redundant explanatory comment in fee_based_minimum_withdrawal_amount_should_cover_actual_minter_fee_for_typical_tx. - Convert that test into a proptest that varies the fee rate, matching the existing proptest style used elsewhere in this test module. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JY8x7iMNPGW52tSwyvR7M7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<!-- ccr-slack-attribution -->
Requested by Grégory Demay · Slack thread
Before:
DogecoinFeeEstimator::fee_based_minimum_withdrawal_amountbudgeted aPER_REQUEST_MINTER_FEE_BOUNDof326_000koinu for the minter fee of a typical (2-input, 2-output) withdrawal transaction. The actual minter fee for such a transaction, computed byevaluate_minter_fee(2, 2)(146_000_000 * 2 + 4_000_000 * 2 + 26_000_000), is326_000_000koinu — exactly 1000x higher. Because the minimum withdrawal amount is derived from this budget, ckDOGE underestimated how much minter fee a withdrawal at the minimum amount would actually incur.After:
PER_REQUEST_MINTER_FEE_BOUNDis replaced byself.evaluate_minter_fee(2, 2), so the fee bound used infee_based_minimum_withdrawal_amountis always derived from the same fee-computation logic that actually charges the minter fee, instead of a separately hardcoded literal that can drift out of sync with it.Verification: Added
fee_based_minimum_withdrawal_amount_should_cover_actual_minter_fee_for_typical_txinrs/dogecoin/ckdoge/minter/src/fees/tests.rs, which uses a smallretrieve_doge_min_amountto isolate the fee budget from the min-amount term (which otherwise dominates the sum and hides an undersized budget) and asserts the computed minimum withdrawal amount exceeds the actual two-input minter fee.minimum withdrawal amount 700002 does not cover the actual minter fee 326000000 for a typical (2 inputs, 2 outputs) transaction.cargo test -p ic-ckdoge-minter, 25/25 lib tests passing, including the existingfees::tests::test_fee_rangeproptest).cargo clippy -p ic-ckdoge-minter --all-targetsandcargo fmt --checkare clean.🤖 Generated with Claude Code
Generated by Claude Code