Page MenuHomePhabricator

[Cashtab] remove hydratedUtxoDetails from wallet state
AbandonedPublic

Authored by hungsam on Dec 3 2021, 05:31.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Summary

T2048

  • hydratedUtxoDetails stored in the wallet state is not being used anywhere else in the code.
  • this infomation can be derived from slpBalancesAndUtxos
  • there is no need to store it separately
  • this will help to maintain a single source of truth
Test Plan
  • cd web/cashtab
  • npm start
  • make sure everything still works
  • make sure hydratedUtxoDetails is removed from the wallet state

Diff Detail

Repository
rABC Bitcoin ABC
Branch
remove-hydratedUtxoDetails (branched from master)
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 17522
Build 34870: Build Diffcashtab-tests
Build 34869: arc lint + arc unit

Event Timeline

hungsam requested review of this revision.Dec 3 2021, 05:31
bytesofman requested changes to this revision.Dec 3 2021, 23:08

App still works for me but also hydratedUtxoDetails does not disappear from localStorage. I tried sending tx to the wallet to force a refresh of the utxo set and also changing wallets -- in both cases, the field stayed there. So I think as it stands, this may only work for newly created wallets.

Do you think it's necessary to add this removal to migrateLegacyWallet function, or use some other approach to ensure it is removed?

If the goal is to clean up the storage and improve code readability, we probably should make sure it happens for all users and not just new users.

This revision now requires changes to proceed.Dec 3 2021, 23:08
  • Weird. I just retest and can confirm that sending tx will remove the hydratedUtxoDetails from from both the sending and receiving wallets.
  • The test plan should have more details (my bad, sorry)
  • Here are the steps I did
    • inspect localstorage and verify that hydratedUtxoDetails exists
    • send some xec to another wallet
    • wait for utxos to refresh (10s)
    • refresh the localstorage
    • verify that hydratedUtxoDetails was removed
    • switch to the receiving wallet
    • wait for utxos to refresh (10s)
    • refresh the localstorage
    • verify that hydratedUtxoDetails was removed
  • When utxos change is detected, the update() will create a new wallet state (with hydratedUtxoDetails removed) and update the existing wallet state. This should be enough to remove the hydratedUtxoDetails.
  • Make sure you refresh the localstorage data as well. Otherwise you will be looking at the old data.

I'm still seeing some weird behavior here.

I am able to see hydratedUtxoDetails disappear from wallet.state in local storage, but only after sending a transaction.

After receiving a transaction, which does update the utxo set and state --- it's still there.

I'm also seeing this:

  1. Create a new wallet
  2. It's created with hydratedUtxoDetails in wallet.state (observed in local storage)
  3. Receive 10,000 XEC and then send it all back; hydratedUtxoDetails still in local storage

Need to do some more digging on why we are seeing these behaviors. Otherwise, the perceived benefit of getting rid of this is negligible to the potential risk.

will not be needed after we introduce State Management library such as Redux