Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: some limits for wallet section #15989

Merged
merged 2 commits into from
Aug 8, 2024
Merged

feat: some limits for wallet section #15989

merged 2 commits into from
Aug 8, 2024

Conversation

saledjenic
Copy link
Contributor

@saledjenic saledjenic commented Aug 5, 2024

Related status-go PR:

Added limitations:

  • allowed adding of max 20 accounts
  • allowed adding of max 3 watch only accounts
  • allowed adding of max 5 key pairs (including the profile key pair)
  • allowed adding of max 20 saved addresses per mode

Limits applied when running keycard flows that add new key pairs/accounts

Closes #15934

Accounts/keypairs flow:

LimitAccounts.mov

Keycard flow:

LimitKeycardImportFlow.mov

@status-im-auto
Copy link
Member

status-im-auto commented Aug 5, 2024

Jenkins Builds

Click to see older builds (21)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ d2651c2 #1 2024-08-05 13:58:49 ~6 min tests/nim 📄log
✔️ d2651c2 #1 2024-08-05 14:02:15 ~10 min macos/x86_64 🍎dmg
✔️ d2651c2 #1 2024-08-05 14:04:20 ~12 min macos/aarch64 🍎dmg
✔️ d2651c2 #1 2024-08-05 14:06:33 ~14 min linux-nix/x86_64 📦tgz
✔️ d2651c2 #1 2024-08-05 14:07:01 ~15 min tests/ui 📄log
✔️ d2651c2 #1 2024-08-05 14:09:22 ~17 min linux/x86_64 📦tgz
✔️ d2651c2 #1 2024-08-05 14:28:01 ~35 min windows/x86_64 💿exe
✔️ 556900d #2 2024-08-06 06:28:43 ~6 min tests/nim 📄log
✔️ 556900d #2 2024-08-06 06:30:48 ~8 min macos/aarch64 🍎dmg
✔️ 556900d #2 2024-08-06 06:32:32 ~10 min macos/x86_64 🍎dmg
✔️ 556900d #2 2024-08-06 06:34:26 ~12 min linux-nix/x86_64 📦tgz
✔️ 556900d #2 2024-08-06 06:36:00 ~13 min tests/ui 📄log
✔️ 556900d #2 2024-08-06 06:39:38 ~17 min linux/x86_64 📦tgz
✔️ 556900d #2 2024-08-06 06:51:15 ~28 min windows/x86_64 💿exe
✔️ c1fd1bf #3 2024-08-06 13:51:06 ~6 min tests/nim 📄log
✔️ c1fd1bf #3 2024-08-06 13:53:36 ~9 min macos/aarch64 🍎dmg
✔️ c1fd1bf #3 2024-08-06 13:57:12 ~12 min macos/x86_64 🍎dmg
✔️ c1fd1bf #3 2024-08-06 13:57:14 ~12 min linux-nix/x86_64 📦tgz
✔️ c1fd1bf #3 2024-08-06 13:58:27 ~13 min tests/ui 📄log
✔️ c1fd1bf #3 2024-08-06 13:59:05 ~14 min linux/x86_64 📦tgz
✔️ c1fd1bf #3 2024-08-06 14:16:40 ~32 min windows/x86_64 💿exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ afcfb42 #4 2024-08-07 07:09:57 ~6 min tests/nim 📄log
✔️ afcfb42 #4 2024-08-07 07:10:56 ~7 min macos/aarch64 🍎dmg
✔️ afcfb42 #4 2024-08-07 07:11:43 ~8 min macos/x86_64 🍎dmg
✔️ afcfb42 #4 2024-08-07 07:15:49 ~12 min linux-nix/x86_64 📦tgz
✔️ afcfb42 #4 2024-08-07 07:15:53 ~12 min tests/ui 📄log
✔️ afcfb42 #4 2024-08-07 07:18:48 ~15 min linux/x86_64 📦tgz
✔️ afcfb42 #4 2024-08-07 07:35:04 ~31 min windows/x86_64 💿exe
✔️ 3b40090 #5 2024-08-08 07:10:54 ~6 min tests/nim 📄log
✔️ 3b40090 #5 2024-08-08 07:12:27 ~8 min macos/aarch64 🍎dmg
✔️ 3b40090 #5 2024-08-08 07:12:46 ~8 min macos/x86_64 🍎dmg
✔️ 3b40090 #5 2024-08-08 07:16:44 ~12 min linux-nix/x86_64 📦tgz
✔️ 3b40090 #5 2024-08-08 07:18:55 ~14 min tests/ui 📄log
✔️ 3b40090 #5 2024-08-08 07:20:13 ~15 min linux/x86_64 📦tgz
✔️ 3b40090 #5 2024-08-08 07:36:01 ~31 min windows/x86_64 💿exe

Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Glad to see some limits here!

suggestion: WDYT of unifying the code for the limit popup in Popups.qml? Would remove some of the redundancy.

issue: Looks like the source of truth for the accounts nb might not be correct in some situations (please see the video below). I'm wondering if the limit is correctly computed for synced/imported Status accounts. I think it won't be correctly computed for accounts that migrate from an older version where we didn't had the wallet DB.
Repro:

  1. Started with 5 accounts (2 status accounts + 3 watch only) and a fresh wallet db. Had to delete the older one because the app started freezing after adding a few accounts. But this might simulate scenarios where users sync/import/migrate the Status account and the app starts with a new wallet DB.
  2. Add new accounts to hit the limit (limit was reached to 23 accounts + 3 watch only).
  3. Immediately after the first limit warning I've started deleting the accounts one by one.
  4. The limit warning was removed only after deleting the 18th account (still had other 3 watch only)
Screen.Recording.2024-08-06.at.11.08.08.mov

question: From the video above looks like the accounts limit is also including the watch only accounts. Is this intended? E.g. The user is allowed to add 17 accounts and 3 watch only accounts.

thought: Have you considered defining the wallet limits in the backend and provide the limits to nim/qml as a constant value. E.g. getAccountsLimit would return 20. It would reduce the status-go traffic

active: false
asynchronous: true

sourceComponent: StatusModal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatusModal is deprecated and will be removed in the future. It's better to use the StatusDialog

limitPopup.active = true
}

sourceComponent: StatusModal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. StatusDialog is better 😄

@saledjenic
Copy link
Contributor Author

WDYT of unifying the code for the limit popup in Popups.qml? Would remove some of the redundancy.

I was thinking but didn't want to get with having a separate qml file just for limit warnings since the popup contains only title and a single message as the content of it.

Looks like the source of truth for the accounts nb might not be correct in some situations (please see the video below).

We're checking for capacity on the statusgo side (there are new endpoints for returning the correct capacity), looking at the video you provided, not sure how you get into this situation. How did you add 23 accounts?

I think it won't be correctly computed for accounts that migrate from an older version where we didn't had the wallet DB.

Yes, we cannot delete accounts if the user already has more than the limit, but every time he tries to add a new account we should display the message that the limit of 20 (for wallet accs + wo accs) is reached until he removes enough accounts to get under that limit.

Add new accounts to hit the limit (limit was reached to 23 accounts + 3 watch only).

So you started from an empty Status folder, created a new account, and added 23 accounts? If so, very weird, cause I tested that and was not able to add more than 20 anyhow, will check again.

question: From the video above looks like the accounts limit is also including the watch only accounts. Is this intended? E.g. The user is allowed to add 17 accounts and 3 watch only accounts.

Yes, the user can add max 20 accounts in total, watch-only + wallet accounts.

thought: Have you considered defining the wallet limits in the backend and provide the limits to nim/qml as a constant value. E.g. getAccountsLimit would return 20. It would reduce the status-go traffic

Why do we need that? We already have statusgo calls we do when about to add a new account, those are:

  • RemainingAccountCapacity
  • RemainingKeypairCapacity
  • RemainingWatchOnlyAccountCapacity
  • RmaininngCapacityForSavedAddresses

@alexjba thanks a lot for testing this, I will try to reproduce the issue you mentioned above.

@alexjba
Copy link
Contributor

alexjba commented Aug 6, 2024

So you started from an empty Status folder, created a new account, and added 23 accounts? If so, very weird, cause I tested that and was not able to add more than 20 anyhow, will check again.

Not an empty Status folder, but I didn't have the wallet DB. The Status account had already 5 accounts (3 of them watch -only). Reached this configuration by accident, but I was thinking this flow might be relevant for people restoring from seed, syncing profiles or migrating from older Status versions.

thought: Have you considered defining the wallet limits in the backend and provide the limits to nim/qml as a constant value. E.g. getAccountsLimit would return 20. It would reduce the status-go traffic

Why do we need that? We already have statusgo calls we do when about to add a new account, those are:

Yes, I've seen the calls. I was thinking that it might have 2 benefits. Reduce status-go traffic and we wouldn't see issues the one in the video because the limit would also be imposed by QML/nim based on the data we display (E.g. Receive from status-go the max number of accounts and compare with the accounts model count whenever the user clicks on add account). Just a thought to consider if it's difficult to fix the issue in the video with the current approach.

not sure how you get into this situation. How did you add 23 accounts?

Added more repro steps in the initial comment. But long story short:
I've deleted the wallet DB for a Status account that already had 5 accounts and then added 18 more. It's probably the same scenario when someone migrates from old Status versions. I'm not 100% confident it's a valid point though since my case is quite artificial. Up to you to decide if it's worth more time.

@saledjenic
Copy link
Contributor Author

Not an empty Status folder, but I didn't have the wallet DB.

Maybe that's the case, accounts, watch-only accounts and keypairs are not part of the wallet db, maybe somethings got corrupted that way.

The Status account had already 5 accounts (3 of them watch -only).

Before opening this PR I tested all that and all worked fine. Also tested it just now and all was good.

Reached this configuration by accident, but I was thinking this flow might be relevant for people restoring from seed, syncing profiles or migrating from older Status versions.

In case the user has more than 3 watch-only accounts added and more than 20 accounts added in total and more than 5 keypairs added in total, we do nothing, like we don't delete any of them on our own. Instead when user tries to add any new, we display popup saying "You reached the limit of X ...", which is ok, what we want. Once user deletes enough accounts/keypairs that they are under the limit, the app will allows him to add more, till then he can just edit.

Yes, I've seen the calls. I was thinking that it might have 2 benefits. Reduce status-go traffic and we wouldn't see issues the one in the video because the limit would also be imposed by QML/nim based on the data we display (E.g. Receive from status-go the max number of accounts and compare with the accounts model count whenever the user clicks on add account). Just a thought to consider if it's difficult to fix the issue in the video with the current approach.

Statusgo is part of the app, so there is no problem in traffic between nim and statusgo, we opted for that approach/technologies and that's it, having the same on the client side will just duplicate the code. Also, that's something shared between desktop and mobile app. Regarding second point, it must not be the difference between the UI and what we have on the statusgo side.

But long story short: I've deleted the wallet DB for a Status account that already had 5 accounts and then added 18 more...

Well, accounts are not stored in the wallet db, so from that point I don't think it's related, but what I do think is that the db was somehow corrupted, maybe due to syncing or whatever, cause otherwise because of conditions we have you shouldn't be able to get available capacity from the statusgo side to reach to 23 added accounts. Very weird. I've tried, but on my side all was fine.

@alexjba I've checked all you stated above and tested once more, but all was good on my side.

@status-im-auto
Copy link
Member

@alexjba
Copy link
Contributor

alexjba commented Aug 7, 2024

@saledjenic Thanks for checking this! Indeed it seems the issue is not the wallet DB! Sorry, got confused by all the workarounds needed to keep my account alive 😄

Had a look on this issue and it seems that the limit is checked onClick, but not on key press. The Add account action can be triggered by hitting Enter key as well.
Here's a recording of click vs enter

Screen.Recording.2024-08-07.at.09.19.17.mov

@saledjenic
Copy link
Contributor Author

@alexjba yes, that's right! Thanks a lot, updating now.

@saledjenic
Copy link
Contributor Author

@alexjba fixed, thanks.

@anastasiyaig
Copy link
Contributor

just to confirm, are we bringing watched addresses back in this PR with a limit of 3 addresses or we still want to hide the possibility to add watched addresses in UI? @alexjba @saledjenic

Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you! Tested

@alexjba
Copy link
Contributor

alexjba commented Aug 8, 2024

just to confirm, are we bringing watched addresses back in this PR with a limit of 3 addresses or we still want to hide the possibility to add watched addresses in UI? @alexjba @saledjenic

AFAIK these are 2 independent decisions.

@saledjenic
Copy link
Contributor Author

@anastasiyaig adding watch-only addresses is disabled in production, limits added here are added for watch-only addresses as well.

Added limitations:
- allowed adding of max 20 accounts
- allowed adding of max 3 watch only accounts
- allowed adding of max 5 key pairs (including the profile key pair)
- allowed adding of max 20 saved addresses per mode

Closes #15934
@saledjenic saledjenic merged commit 2d0c62b into master Aug 8, 2024
9 checks passed
@saledjenic saledjenic deleted the feat/issue-15934 branch August 8, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some limits for Wallet section
4 participants