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

fix_: make member use wallet tokens during permission checking #5268

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

kounkou
Copy link
Contributor

@kounkou kounkou commented May 31, 2024

Description

During the checking of permissions that happens either on edit shared addresses or during the blurred screen when joining a community, the member will perform some permissions checking. Currently the permission checking is done by fetching tokens from the chain which is wasteful in terms of resources. These changes aims at using the cached tokens from the wallet which improves the speed of tokens retrieval and improve the user experience.

fixes #14913

Acceptance criteria

  • the channel and join permission screens work as before, same with the shared addresses popup. The UI/UX should't be affected at all. If anything, it should be faster
  • members no longer call the providers
  • Ensure that no integration breaking changes In progress

Important changes:

  • Add a switch to differentiate fetching token by member and owner
  • Add API to fetch tokens from the wallet db

Closes status-im/status-desktop#14913

Manual testing

Please notince how fast the evaluation is compared to before

Before

Screencast.from.2024-06-02.01-17-01.webm

After

Screencast.from.2024-06-02.01-59-40.webm

@kounkou kounkou self-assigned this May 31, 2024
@status-im-auto
Copy link
Member

status-im-auto commented May 31, 2024

Jenkins Builds

Click to see older builds (71)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ bd23113 #1 2024-05-31 05:13:13 ~2 min tests 📄log
✔️ bd23113 #1 2024-05-31 05:14:19 ~4 min linux 📦zip
✔️ bd23113 #1 2024-05-31 05:16:22 ~6 min android 📦aar
✔️ bd23113 #1 2024-05-31 05:17:39 ~7 min ios 📦zip
✖️ de05a06 #2 2024-05-31 05:36:27 ~1 min tests 📄log
✔️ de05a06 #2 2024-05-31 05:37:16 ~2 min android 📦aar
✔️ de05a06 #2 2024-05-31 05:37:27 ~2 min linux 📦zip
✔️ de05a06 #2 2024-05-31 05:38:43 ~3 min ios 📦zip
✖️ 2419df0 #3 2024-05-31 05:58:45 ~1 min tests 📄log
✔️ 2419df0 #3 2024-05-31 05:59:44 ~2 min linux 📦zip
✔️ 2419df0 #3 2024-05-31 05:59:45 ~2 min android 📦aar
✔️ 2419df0 #3 2024-05-31 06:00:57 ~3 min ios 📦zip
✖️ 23c60f8 #4 2024-05-31 06:01:54 ~1 min tests 📄log
✔️ 23c60f8 #4 2024-05-31 06:03:08 ~2 min linux 📦zip
✔️ 23c60f8 #4 2024-05-31 06:05:06 ~3 min ios 📦zip
✔️ 23c60f8 #4 2024-05-31 06:06:26 ~5 min android 📦aar
✖️ 76d5222 #5 2024-05-31 06:12:08 ~1 min tests 📄log
✔️ 76d5222 #5 2024-05-31 06:13:08 ~2 min linux 📦zip
✔️ 76d5222 #5 2024-05-31 06:13:22 ~2 min android 📦aar
✔️ 76d5222 #5 2024-05-31 06:14:23 ~3 min ios 📦zip
✔️ fa1c7eb #6 2024-05-31 06:33:54 ~2 min android 📦aar
✔️ fa1c7eb #6 2024-05-31 06:36:24 ~4 min ios 📦zip
✔️ fa1c7eb #6 2024-05-31 06:38:09 ~6 min linux 📦zip
✔️ fa1c7eb #6 2024-05-31 07:13:42 ~41 min tests 📄log
✔️ 7b73915 #7 2024-05-31 07:17:07 ~2 min linux 📦zip
✔️ 7b73915 #7 2024-05-31 07:17:19 ~2 min android 📦aar
✔️ 7b73915 #7 2024-05-31 07:18:32 ~3 min ios 📦zip
✔️ 7b73915 #7 2024-05-31 07:54:50 ~40 min tests 📄log
✔️ af6910a #8 2024-06-01 06:47:57 ~2 min android 📦aar
✔️ af6910a #8 2024-06-01 06:48:11 ~2 min linux 📦zip
✔️ af6910a #8 2024-06-01 06:49:39 ~4 min ios 📦zip
✔️ af6910a #8 2024-06-01 07:27:52 ~42 min tests 📄log
✖️ bc1b378 #9 2024-06-02 08:28:13 ~1 min tests 📄log
✔️ bc1b378 #9 2024-06-02 08:29:14 ~2 min android 📦aar
✔️ bc1b378 #9 2024-06-02 08:29:21 ~2 min linux 📦zip
✔️ bc1b378 #9 2024-06-02 08:30:58 ~4 min ios 📦zip
✖️ cc89855 #10 2024-06-02 08:36:57 ~1 min tests 📄log
✔️ cc89855 #10 2024-06-02 08:37:31 ~1 min android 📦aar
✔️ cc89855 #10 2024-06-02 08:38:03 ~2 min linux 📦zip
✔️ cc89855 #10 2024-06-02 08:39:08 ~3 min ios 📦zip
✔️ a402d70 #11 2024-06-02 08:41:23 ~1 min android 📦aar
✔️ a402d70 #11 2024-06-02 08:41:59 ~2 min linux 📦zip
✔️ a402d70 #11 2024-06-02 08:43:24 ~3 min ios 📦zip
✔️ 4853508 #12 2024-06-02 08:59:41 ~2 min android 📦aar
✔️ 4853508 #12 2024-06-02 08:59:50 ~2 min linux 📦zip
✔️ 4853508 #12 2024-06-02 09:01:23 ~4 min ios 📦zip
✔️ a402d70 #11 2024-06-02 09:20:20 ~40 min tests 📄log
✔️ 4853508 #12 2024-06-02 10:01:08 ~40 min tests 📄log
✔️ 316b50c #13 2024-06-03 18:56:18 ~2 min linux 📦zip
✔️ 316b50c #13 2024-06-03 18:56:36 ~2 min android 📦aar
✔️ 316b50c #13 2024-06-03 18:57:38 ~3 min ios 📦zip
✔️ 316b50c #13 2024-06-03 19:34:34 ~40 min tests 📄log
✔️ 7ba2a68 #14 2024-06-10 08:48:56 ~3 min ios 📦zip
✔️ 7ba2a68 #14 2024-06-10 08:49:09 ~4 min linux 📦zip
✔️ 7ba2a68 #14 2024-06-10 08:50:06 ~5 min android 📦aar
✖️ 7ba2a68 #14 2024-06-10 08:51:38 ~6 min tests 📄log
✖️ 7ba2a68 #15 2024-06-10 09:36:26 ~35 min tests 📄log
✔️ a5f0f70 #15 2024-06-10 11:32:54 ~1 min android 📦aar
✔️ a5f0f70 #15 2024-06-10 11:34:50 ~3 min linux 📦zip
✔️ a5f0f70 #15 2024-06-10 11:35:17 ~4 min ios 📦zip
✖️ a5f0f70 #16 2024-06-10 12:08:08 ~37 min tests 📄log
✖️ a5f0f70 #17 2024-06-10 18:25:47 ~34 min tests 📄log
✖️ a5f0f70 #18 2024-06-10 19:08:56 ~34 min tests 📄log
✔️ 8151b35 #16 2024-06-10 19:45:57 ~2 min android 📦aar
✔️ 8151b35 #16 2024-06-10 19:46:07 ~2 min linux 📦zip
✔️ 8151b35 #16 2024-06-10 19:47:13 ~3 min ios 📦zip
✔️ 8151b35 #19 2024-06-10 20:24:50 ~40 min tests 📄log
✖️ 3363e81 #20 2024-06-11 18:33:56 ~1 min tests 📄log
✔️ 3363e81 #17 2024-06-11 18:35:00 ~2 min linux 📦zip
✔️ 3363e81 #17 2024-06-11 18:35:43 ~3 min ios 📦zip
✔️ 3363e81 #17 2024-06-11 18:36:58 ~4 min android 📦aar
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ b896f0a #18 2024-06-11 18:51:24 ~2 min android 📦aar
✔️ b896f0a #18 2024-06-11 18:51:39 ~2 min linux 📦zip
✔️ b896f0a #18 2024-06-11 18:52:25 ~3 min ios 📦zip
✔️ b896f0a #21 2024-06-11 19:29:55 ~40 min tests 📄log

@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch 6 times, most recently from fa1c7eb to 7b73915 Compare May 31, 2024 07:14
@kounkou kounkou requested review from jrainville and mprakhov May 31, 2024 14:20
Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Great job! Just small comments.
I'll also wait for the others to review since they know this code better.

FYI, @osmaczko did a PR also on that code. Hopefully it's doesn't conflict too much.
I don't think you need to also implement the getOwnersForCollection function from cache, since it's only for control nodes, but it's worth noting.

protocol/communities/permission_checker.go Outdated Show resolved Hide resolved
services/wallet/api.go Outdated Show resolved Hide resolved
@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch 5 times, most recently from a402d70 to 4853508 Compare June 2, 2024 08:57
@@ -396,6 +398,61 @@ func (o *OwnershipDB) Update(chainID w_common.ChainID, ownerAddress common.Addre
return
}

func (o *OwnershipDB) FetchCachedCollectibleOwnersByContractAddress(chainID w_common.ChainID, contractAddress common.Address) (*thirdparty.CollectibleContractOwnership, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please add a test for this fn... what should we get, when info is not found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, please note that this is exactly the same behavior as for FetchBalancesByOwnerAndContractAddress. Instead of looking on chain we just get the data in cache, but let me have a look if I can add a test that makes sense if not already implemented somewhere.

Copy link
Contributor

@mprakhov mprakhov left a comment

Choose a reason for hiding this comment

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

LGTM

@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch from 4853508 to 316b50c Compare June 3, 2024 18:53
Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@osmaczko
Copy link
Contributor

osmaczko commented Jun 5, 2024

FYI, @osmaczko did #5256 also on that code. Hopefully it's doesn't conflict too much.

It conflicts pretty heavily as far as I can see 😢

@anastasiyaig
Copy link
Contributor

@kounkou hey, is it the change you wanted to be tested? If so, please create corresponding PR in desktop repo

@kounkou
Copy link
Contributor Author

kounkou commented Jun 7, 2024

@kounkou hey, is it the change you wanted to be tested? If so, please create corresponding PR in desktop repo

Hey @anastasiyaig please let me follow up with you once I have completed the merging of changes from @osmaczko PR. Should be achieve early next week.

PR : status-im/status-desktop#15117

@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch from 316b50c to 7ba2a68 Compare June 10, 2024 08:44
@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch from 7ba2a68 to a5f0f70 Compare June 10, 2024 11:30
@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch 2 times, most recently from 8151b35 to 3363e81 Compare June 11, 2024 18:32
@kounkou kounkou force-pushed the fix-make-member-use-wallet-for-permission-checking branch from 3363e81 to b896f0a Compare June 11, 2024 18:48
@kounkou
Copy link
Contributor Author

kounkou commented Jun 11, 2024

During the testing, @glitchminer saw a problem, but it's actually not caused by this pr, it is already known issue when trying to use the same collectible multiple times when creating a permission :

status-im/status-desktop#15122

@kounkou kounkou merged commit 892fcff into develop Jun 11, 2024
12 checks passed
@kounkou kounkou deleted the fix-make-member-use-wallet-for-permission-checking branch June 11, 2024 21:00
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.

Members should use the wallet tokens instead of checking the chain when checking permissions
6 participants