ckb-cell / rgbpp-sdk

Utilities for Bitcoin and RGB++ asset integration
ISC License
53 stars 15 forks source link

feat(btc): batch queries to improve transaction build time #200

Closed ShookLyngs closed 1 month ago

ShookLyngs commented 1 month ago

Changes

Test

Dawn-githup commented 1 month ago

Performance Comparison Data

The following table shows the time taken by the sendRgbppUtxos() function to construct a transaction on different branches. The data compares the develop branch and the feat/batch-queries branch.

With 39 Cells

Branch genBtcTransferCkbVirtualTx Time sendRgbppUtxos Time Total Time
develop 2.082s 130.531s 132.613s
develop 1.116s 111.526s 112.642s
develop 1.436s 126.264s 127.700s
PR #184 1.116s 121.187s 122.303s
PR #184 0.932s 112.381s 113.313s
PR #184 2.443s 116.837s 119.280s
feat/batch-queries 1.267s 52.193s 53.460s
feat/batch-queries 2.889s 59.937s 62.826s
feat/batch-queries 3.018s 63.788s 66.806s

Mitigating Network Fluctuations

Branch genBtcTransferCkbVirtualTx Time sendRgbppUtxos Time Total Time
develop 0.489s 50.055s 50.544s
develop 0.450s 47.480s 47.930s
develop 0.406s 55.443s 55.849s
develop 0.426s 51.939s 52.365s
develop 0.439s 50.629s 51.068s
feat/batch-queries 0.450s 22.098s 22.548s
feat/batch-queries 0.428s 27.098s 27.526s
feat/batch-queries 0.555s 22.291s 22.846s
feat/batch-queries 0.467s 28.528s 28.995s
feat/batch-queries 0.467s 28.833s 29.300s

Conclusion

From the above data, it's clear that the feat/batch-queries branch has significantly optimized the transaction construction time. When compared to the develop branch, using batch requests has drastically reduced the execution time of the sendRgbppUtxos() function.

This optimization has reduced the transaction construction time from approximately 50 seconds on the develop branch to about 22 seconds on the feat/batch-queries branch, resulting in more than a twofold performance improvement.