Page MenuHomePhabricator

[Cashtab] [utxo optimization part 1] Add function isExcludedUtxo
ClosedPublic

Authored by bytesofman on Feb 11 2022, 21:43.

Details

Summary

T1683

See D11039 for a working alpha of the end goal of this series of diffs.

X Add function isExcludedUtxo with unit tests (determines if a given utxo is in an array of utxos)
_ Add function whichUtxosWereAdded with unit tests
_ Add function whichUtxosWereRemoved with unit tests
_ Add function addNewHydratedUtxos with unit tests
_ Add function removeConsumedUtxos with unit tests
_ Add function validateIncrementedHydratedUtxoDetails with unit tests
_ Using the above functions, modify the update function in useBCH.js to only hydrate (that is, collect eToken info about) the utxos that changed since the last time update ran
_ Reduce the interval between calls to update, speeding up Cashtab refresh rate

Current state of Cashtab:
hydratedUtxoDetails is recreated each time the utxo set changes. This requires a series of slow API calls to SLPDB.

Cashtab after this series of diffs lands:
Only new incoming utxos are parsed by API calls to SLPDB. These are added to hydratedUtxoDetails. Consumed utxos are removed. The resulting hydratedUtxoDetails is then validated to ensure it includes all utxos in the wallet. In testing, this reduces Cashtab UI locktime after sending a tx by about 60%.

Test Plan
  1. Review the new function isExcludedUtxo
  2. Review the unit tests. Confirm no others are required, or suggest some others.
  3. Note: this new function is not used anywhere in Cashtab. This diff does not alter the behavior of the app.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested changes to this revision.Feb 13 2022, 00:02
emack added a subscriber: emack.
emack added inline comments.
web/cashtab/src/utils/cashMethods.js
515–517 ↗(On Diff #32354)

Will there ever be a scenario where the txid, txPos or the value coming from the utxo being undefined? Because it would cause this function to return a false positive due to skipping the if block conditions.

This revision now requires changes to proceed.Feb 13 2022, 00:02

Adding function + unit tests for isValidUtxo

High level, plan is to revert to the old way of processing utxos (hydrate all of them) if any errors are thrown in this new way. The isValidUtxo function will be either included with isExcludedUtxo or included with the functions that identify whether or not a utxo has been consumed / is added. So, it's implementation will be in a future diff -- this diff only includes the function.

This revision is now accepted and ready to land.Feb 14 2022, 22:37