Page MenuHomePhabricator

[electrum] refactor make_unsigned_transaction to not generate the unspent coins every call
ClosedPublic

Authored by PiRK on Jul 11 2023, 11:26.

Details

Summary

On wallets with many coins for few addresses, add_input_info is called a lot for the same addresses. Avoid costly and unnecessary get_address_unspent calls by caching the result for each addreess.

Remove the same optimization done for the coin consolidation tool and use the newly optimized wallet.add_input_info

Profiling:

Annotate AbstractWallet.make_unsigned_transaction with @profiler, run the application in verbose mode (./electrum-abc -v), open the IFP address wallet, select 500 coins and choose "Spend" in the dropdown menu, go to the send tab and type something in the Amount widget

Before:

[profiler] AbstractWallet.make_unsigned_transaction 33.5602
[profiler] AbstractWallet.make_unsigned_transaction 33.5048

After:

[profiler] AbstractWallet.make_unsigned_transaction 0.0926
[profiler] AbstractWallet.make_unsigned_transaction 0.0909

Depends on D14248

Test Plan

python test_runner.py

Test the coin consolidation tool, check that the output is the same before and after this diff.

Check that the gui freezing is much less severe on a wallet with thousands of inputs for a single address.

Enable cashfusion

Diff Detail

Repository
rABC Bitcoin ABC
Branch
optimize_get_coins
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24446
Build 48492: Build Diffelectrum-tests
Build 48491: arc lint + arc unit