Skip to content

fix(ckdoge): correct 1000x underestimate of minter fee in minimum withdrawal amount - #11609

Draft
claude[bot] wants to merge 2 commits into
masterfrom
fix-ckdoge-minter-fee-underestimate
Draft

claude[bot] wants to merge 2 commits into
masterfrom
fix-ckdoge-minter-fee-underestimate

Conversation

@claude

@claude claude Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

<!-- ccr-slack-attribution -->
Requested by Grégory Demay · Slack thread

Before: DogecoinFeeEstimator::fee_based_minimum_withdrawal_amount budgeted a PER_REQUEST_MINTER_FEE_BOUND of 326_000 koinu for the minter fee of a typical (2-input, 2-output) withdrawal transaction. The actual minter fee for such a transaction, computed by evaluate_minter_fee(2, 2) (146_000_000 * 2 + 4_000_000 * 2 + 26_000_000), is 326_000_000 koinu — 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_BOUND is replaced by self.evaluate_minter_fee(2, 2), so the fee bound used in fee_based_minimum_withdrawal_amount is 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_tx in rs/dogecoin/ckdoge/minter/src/fees/tests.rs, which uses a small retrieve_doge_min_amount to 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.

  • Before the fix: test fails — minimum withdrawal amount 700002 does not cover the actual minter fee 326000000 for a typical (2 inputs, 2 outputs) transaction.
  • After the fix: test passes, along with the rest of the crate's test suite (cargo test -p ic-ckdoge-minter, 25/25 lib tests passing, including the existing fees::tests::test_fee_range proptest).
  • cargo clippy -p ic-ckdoge-minter --all-targets and cargo fmt --check are clean.

🤖 Generated with Claude Code


Generated by Claude Code

…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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Comment thread rs/dogecoin/ckdoge/minter/src/fees/mod.rs Outdated
Comment thread rs/dogecoin/ckdoge/minter/src/fees/tests.rs Outdated
Comment thread rs/dogecoin/ckdoge/minter/src/fees/tests.rs Outdated
- 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
@claude
claude Bot requested a review from gregorydemay September 17, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants