Skip to content

Conversation

@gregorydemay
Copy link
Contributor

@gregorydemay gregorydemay commented Dec 8, 2025

Improve the efficiency of the endpoint estimate_withdrawal_fee by removing the cloning of the UTXO set, which can be quite large (around 60k entries for ckBTC).

The cloning is not necessary because the endpoint estimate_withdrawal_fee is a query endpoint, so that event though the underlying logic (the methods estimate_retrieve_btc_fee and estimate_retrieve_doge_fee) needs a mutable reference to the UTXO set (to remove selected UTXOs), any state change will be reverted. This PR also introduces a benchmark for the ckBTC minter endpoint to measure the exact gains.

Bench Before After Reduction factor
build_estimate_retrieve_btc_fee_1_50k_sats 40,813,570 2,689,868 15

@github-actions github-actions bot added the perf label Dec 8, 2025
@gregorydemay gregorydemay changed the title perf(ckbtc): remove unnecessary clone perf(ckbtc): avoid cloning the UTXOs set in estimate_withdrawal_fee Dec 8, 2025
@gregorydemay gregorydemay marked this pull request as ready for review December 8, 2025 13:45
@gregorydemay gregorydemay requested a review from a team as a code owner December 8, 2025 13:45
@gregorydemay gregorydemay requested a review from ninegua December 8, 2025 13:45
Copy link
Member

@ninegua ninegua left a comment

Choose a reason for hiding this comment

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

Nice improvement! Thanks

@gregorydemay gregorydemay added this pull request to the merge queue Dec 8, 2025
Merged via the queue into master with commit 37e6df7 Dec 8, 2025
45 checks passed
@gregorydemay gregorydemay deleted the gdemay/DEFI-2518-remove-clone branch December 8, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants