Page MenuHomePhabricator

[Cashtab] Only hydrate changed utxos part 6 of 8
ClosedPublic

Authored by bytesofman on Feb 23 2022, 21:27.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC960a967f95b0: [Cashtab] Only hydrate changed utxos part 6 of 8
Summary

T1683

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

Note: After review, I'm not sure we really need the isValidUtxo function introduced in D11045. All of these functions are comparing API responses from the same endpoint a few seconds apart from each other. We do not have any experience of bch-api occasionally returning a valid utxos response with the exception of some utxos missing parameters.

However, I'll leave it there until we get to the end of this series of diffs -- then pull it out if it is not used.

X Add function isExcludedUtxo with unit tests (determines if a given utxo is in an array of utxos)
X Add function whichUtxosWereAdded with unit tests
X Add function whichUtxosWereRemoved with unit tests
X Add function addNewHydratedUtxos with unit tests
X Add function removeConsumedUtxos with unit tests
X Add function areAllUtxosIncludedInIncrementallyHydratedUtxos 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 areAllUtxosIncludedInIncrementallyHydratedUtxos and its dependency, getUtxoCount. Note: these functions are specific to the data structures returned by bch-api and are not expected to work with invalid data.
  2. Review the unit tests. Confirm no others are required, or suggest some others.

Note: these new functions are 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 24 2022, 08:59
emack added a subscriber: emack.
emack added inline comments.
web/cashtab/src/utils/cashMethods.js
797 ↗(On Diff #32511)

When this is called by areAllUtxosIncludedInIncrementallyHydratedUtxos on lines 874 and 875 for subsequent comparison on 876, there were no null checks made beforehand. Also, this is very reusable by future diffs unrelated to this optimization series so would be good to add a nullcheck here so it won't need to rely on an assumption of upstream functions making this check.
Everything else looks good.

This revision now requires changes to proceed.Feb 24 2022, 08:59

Add validation function for utxo set from bch-api and include it in getUtxoCount()

This revision is now accepted and ready to land.Feb 24 2022, 23:17