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: update logic to check against controller permissions when setting its Allowed Calls or ERC725Y Data Keys #734

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

CJ42
Copy link
Member

@CJ42 CJ42 commented Oct 2, 2023

What does this PR introduce?

🐛 Bug + ♻️ Refactor

This PR solves a small user bug.

When setting the Allowed Calls or Allowed ERC725Y Data Keys of a controller, currently the logic to check if the permission needed to set these values between ADD_CONTROLLER or EDIT_PERMISSIONS is to check against the value for the data key being set. This data key can be:

  • AddressPermissions:AllowedCalls:<controller>
  • AddressPermissions:AllowedERC725YDataKeys:<controller>

Update this logic to check now if the controller is actually a controller with some permission, by checking under the AddressPermissions:Permissions:<controller> instead.

PR Checklist

  • Wrote Tests
  • Wrote & Generated Documentation (readme/natspec/dodoc)
  • Ran npm run lint && npm run lint:solidity (solhint)
  • Ran npm run format (prettier)
  • Ran npm run build
  • Ran npm run test

@Hugoo
Copy link
Contributor

Hugoo commented Oct 2, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

👋 Hello
⛽ I am the Gas Bot Reporter. I keep track of the gas costs of common interactions using Universal Profiles 🆙 !
📊 Here is a summary of the gas cost with the code introduced by this PR.

⛽📊 Gas Benchmark Report

Deployment Costs

Deployed contracts ⛽ Deployment cost
UniversalProfile 3000497 (0 )
KeyManager 3453452 (14,043 📈❌)
LSP1DelegateUP 1623804 (0 )
LSP7Mintable 2354082 (0 )
LSP8Mintable 2476554 (0 )

Runtime Costs

UniversalProfile owned by an 🔑 EOA

🔀 execute scenarios

execute scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Transfer 1 LYX to an EOA without data 37537 (0 )
Transfer 1 LYX to a UP without data 36639 (0 )
Transfer 1 LYX to an EOA with 256 bytes of data 42198 (-12 📉✅)
Transfer 1 LYX to a UP with 256 bytes of data 44843 (-12 📉✅)
Transfer 0.1 LYX to 3x EOA without data 70862 (0 )
Transfer 0.1 LYX to 3x UP without data 75680 (0 )
Transfer 0.1 LYX to 3x EOA with 256 bytes of data 84826 (-12 📉✅)
Transfer 0.1 LYX to 3x UPs with 256 bytes of data 100357 (0 )

🗄️ setData scenarios

setData scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Set a 20 bytes long value 49971 (0 )
Set a 60 bytes long value 95293 (12 📈❌)
Set a 160 bytes long value 164453 (0 )
Set a 300 bytes long value 279700 (12 📈❌)
Set a 600 bytes long value 484112 (-24 📉✅)
Change the value of a data key already set 32859 (0 )
Remove the value of a data key already set 27333 (0 )
Set 2 data keys of 20 bytes long value 78454 (12 📈❌)
Set 2 data keys of 100 bytes long value 260618 (0 )
Set 3 data keys of 20 bytes long value 105171 (0 )
Change the value of three data keys already set of 20 bytes long value 45471 (0 )
Remove the value of three data keys already set 41360 (0 )

🗄️ Tokens scenarios

Tokens scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Minting a LSP7Token to a UP (No Delegate) from an EOA 91982 (0 )
Minting a LSP7Token to an EOA from an EOA 59289 (0 )
Transferring an LSP7Token from a UP to another UP (No Delegate) 100092 (0 )
Minting a LSP8Token to a UP (No Delegate) from an EOA 159126 (0 )
Minting a LSP8Token to an EOA from an EOA 126433 (0 )
Transferring an LSP8Token from a UP to another UP (No Delegate) 148899 (0 )
UniversalProfile owned by a 🔒📄 LSP6KeyManager

🔀 execute scenarios

execute scenarios 👑 main controller 🛃 restricted controller
LYX transfer --> to an EOA 60408 (0 ) 73899 (0 )
LYX transfer --> to a UP 62010 (0 ) 76988 (0 )
LSP7 token transfer --> to an EOA 117832 (0 ) 132523 (0 )
LSP7 token transfer --> to a UP 254217 (0 ) 268908 (0 )
LSP8 NFT transfer --> to an EOA 182075 (0 ) 196743 (0 )
LSP8 NFT transfer --> to a UP 301707 (0 ) 316375 (0 )

🗄️ setData scenarios

setData scenarios 👑 main controller 🛃 restricted controller
Update Profile details (LSP3Profile Metadata) 68545 (0 ) 78544 (0 )
Add a new controller with permission to SET_DATA + 3x allowed data keys:
AddressPermissions[]
+ AddressPermissions[index]
+ AddressPermissions:Permissions:<controller>
+ AddressPermissions:AllowedERC725YDataKeys:<controller)
211942 (0 ) 222007 (425 📈❌)
Update permissions of previous controller. Allow it now to SUPER_SETDATA 53432 (0 ) 56415 (0 )
Remove a controller:
1. decrease AddressPermissions[] Array length
2. remove the controller address at AddressPermissions[index]
3. set "0x" for the controller permissions under AddressPermissions:Permissions:
80426 (0 ) 91651 (158 📈❌)
Write 5x new LSP12 Issued Assets 68098 (0 ) 102702 (0 )
Update 3x data keys (first 3) 127385 (0 ) 161466 (0 )
Update 3x data keys (middle 3) 107473 (0 ) 145620 (0 )
Update 3x data keys (last 3) 127385 (0 ) 170953 (0 )
Set 2 x new data keys + add 3x new controllers 815830 (0 ) 877377 (1,278 📈❌)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Changes to gas cost

Generated at commit: 04433dbf54f1f28dfacf62e5dbedb4a8347b8185, compared to commit: b8eca3c5696acf85239130ef67edec9e8c134bfa

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
LSP6ExecuteRestrictedController transferLYXToUP +11,283 ❌ +35.82%
LSP6ExecuteUnrestrictedController transferLYXToUP +10,883 ❌ +32.49%
LSP6SetDataRestrictedController execute +6,096 ❌ +21.36%
LSP6SetDataUnrestrictedController execute +6,096 ❌ +21.36%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
LSP6ExecuteRestrictedController 2,914,951 (+39,260) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,682 (-214)
62,532 (+6,367)
42,779 (+11,283)
146,341 (+15,572)
254,966 (+15,652)
76,501 (+2,809)
211,403 (+2,244)
-1.44%
+11.34%
+35.82%
+11.91%
+6.54%
+3.81%
+1.07%
16,881 (-151)
62,532 (+6,367)
42,779 (+11,283)
146,341 (+15,572)
254,966 (+15,652)
76,501 (+2,809)
211,403 (+2,244)
-0.89%
+11.34%
+35.82%
+11.91%
+6.54%
+3.81%
+1.07%
17,614 (-131)
62,532 (+6,367)
42,779 (+11,283)
146,341 (+15,572)
254,966 (+15,652)
76,501 (+2,809)
211,403 (+2,244)
-0.74%
+11.34%
+35.82%
+11.91%
+6.54%
+3.81%
+1.07%
17,614 (-131)
62,532 (+6,367)
42,779 (+11,283)
146,341 (+15,572)
254,966 (+15,652)
76,501 (+2,809)
211,403 (+2,244)
-0.74%
+11.34%
+35.82%
+11.91%
+6.54%
+3.81%
+1.07%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6ExecuteUnrestrictedController 2,914,951 (+39,260) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,682 (-214)
63,036 (+6,241)
44,379 (+10,883)
145,090 (+15,572)
253,715 (+15,652)
75,250 (+3,122)
209,839 (+2,244)
-1.44%
+10.99%
+32.49%
+12.02%
+6.57%
+4.33%
+1.08%
16,881 (-151)
63,036 (+6,241)
44,379 (+10,883)
145,090 (+15,572)
253,715 (+15,652)
75,250 (+3,122)
209,839 (+2,244)
-0.89%
+10.99%
+32.49%
+12.02%
+6.57%
+4.33%
+1.08%
17,614 (-131)
63,036 (+6,241)
44,379 (+10,883)
145,090 (+15,572)
253,715 (+15,652)
75,250 (+3,122)
209,839 (+2,244)
-0.74%
+10.99%
+32.49%
+12.02%
+6.57%
+4.33%
+1.08%
17,614 (-131)
63,036 (+6,241)
44,379 (+10,883)
145,090 (+15,572)
253,715 (+15,652)
75,250 (+3,122)
209,839 (+2,244)
-0.74%
+10.99%
+32.49%
+12.02%
+6.57%
+4.33%
+1.08%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6SetDataRestrictedController 2,899,735 (+39,267) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,774 (+12,284)
122,906 (+2,272)
141,615 (+2,731)
+66.44%
+1.88%
+1.97%
34,631 (+6,096)
122,906 (+2,272)
141,615 (+2,731)
+21.36%
+1.88%
+1.97%
34,631 (+6,096)
122,906 (+2,272)
141,615 (+2,731)
+21.36%
+1.88%
+1.97%
38,488 (-93)
122,906 (+2,272)
141,615 (+2,731)
-0.24%
+1.88%
+1.97%
2 (0)
1 (0)
1 (0)
LSP6SetDataUnrestrictedController 2,899,735 (+39,267) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,774 (+12,284)
128,906 (+2,272)
150,115 (+2,731)
+66.44%
+1.79%
+1.85%
34,631 (+6,096)
128,906 (+2,272)
150,115 (+2,731)
+21.36%
+1.79%
+1.85%
34,631 (+6,096)
128,906 (+2,272)
150,115 (+2,731)
+21.36%
+1.79%
+1.85%
38,488 (-93)
128,906 (+2,272)
150,115 (+2,731)
-0.24%
+1.79%
+1.85%
2 (0)
1 (0)
1 (0)

@CJ42 CJ42 force-pushed the DEV-3453 branch 2 times, most recently from db9bb0d to 9114dec Compare October 2, 2023 15:06
Copy link
Member

@skimaharvey skimaharvey left a comment

Choose a reason for hiding this comment

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

LGTM

@CJ42 CJ42 merged commit 0d43077 into develop Oct 5, 2023
26 checks passed
@CJ42 CJ42 deleted the DEV-3453 branch October 5, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants