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

perf: remove double _exist check in LSP8Core #736

Merged
merged 1 commit into from
Oct 10, 2023
Merged

perf: remove double _exist check in LSP8Core #736

merged 1 commit into from
Oct 10, 2023

Conversation

CJ42
Copy link
Member

@CJ42 CJ42 commented Oct 9, 2023

What does this PR introduce?

⚡️ Performance

Reduce double check for _exist inside LSP8 Core internal _mint function.

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 9, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 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 3007205 (0 )
KeyManager 3491003 (0 )
LSP1DelegateUP 1623804 (0 )
LSP7Mintable 2354082 (0 )
LSP8Mintable 2469323 (-7,231 📉✅)

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 42186 (-12 📉✅)
Transfer 1 LYX to a UP with 256 bytes of data 44831 (-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 (-48 📉✅)
Transfer 0.1 LYX to 3x UPs with 256 bytes of data 100357 (72 📈❌)

🗄️ setData scenarios

setData scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Set a 20 bytes long value 49971 (0 )
Set a 60 bytes long value 95281 (-12 📉✅)
Set a 160 bytes long value 164441 (0 )
Set a 300 bytes long value 279676 (0 )
Set a 600 bytes long value 484088 (-72 📉✅)
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 (0 )
Set 2 data keys of 100 bytes long value 260582 (-12 📉✅)
Set 3 data keys of 20 bytes long value 105171 (12 📈❌)
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 158922 (-204 📉✅)
Minting a LSP8Token to an EOA from an EOA 126229 (-204 📉✅)
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 66106 (0 ) 76899 (0 )
LYX transfer --> to a UP 67388 (0 ) 79370 (0 )
LSP7 token transfer --> to an EOA 120156 (0 ) 134847 (0 )
LSP7 token transfer --> to a UP 256711 (0 ) 271402 (0 )
LSP8 NFT transfer --> to an EOA 184399 (0 ) 199067 (0 )
LSP8 NFT transfer --> to a UP 304201 (0 ) 318869 (0 )

🗄️ setData scenarios

setData scenarios 👑 main controller 🛃 restricted controller
Update Profile details (LSP3Profile Metadata) 68714 (0 ) 78713 (0 )
Add a new controller with permission to SET_DATA + 3x allowed data keys:
AddressPermissions[]
+ AddressPermissions[index]
+ AddressPermissions:Permissions:<controller>
+ AddressPermissions:AllowedERC725YDataKeys:<controller)
212112 (0 ) 222177 (0 )
Update permissions of previous controller. Allow it now to SUPER_SETDATA 53601 (0 ) 56584 (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:
80562 (0 ) 91787 (0 )
Write 5x new LSP12 Issued Assets 68267 (0 ) 102871 (0 )
Update 3x data keys (first 3) 127555 (0 ) 161636 (0 )
Update 3x data keys (middle 3) 107643 (0 ) 145790 (0 )
Update 3x data keys (last 3) 127555 (0 ) 171123 (0 )
Set 2 x new data keys + add 3x new controllers 816000 (0 ) 877547 (0 )

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

Changes to gas cost

Generated at commit: e58d58917d93e9545783388ec8cfe5301e9b50f3, compared to commit: b8eca3c5696acf85239130ef67edec9e8c134bfa

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
LSP6ExecuteRestrictedController transferLYXToUP +11,279 ❌ +35.81%
LSP6ExecuteUnrestrictedController transferLYXToUP +10,879 ❌ +32.48%
LSP6SetDataRestrictedController execute +6,081 ❌ +21.31%
LSP6SetDataUnrestrictedController execute +6,081 ❌ +21.31%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
LSP6ExecuteRestrictedController 2,898,727 (+23,036) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,657 (-239)
62,528 (+6,363)
42,775 (+11,279)
146,317 (+15,548)
254,922 (+15,608)
76,497 (+2,805)
211,373 (+2,214)
-1.60%
+11.33%
+35.81%
+11.89%
+6.52%
+3.81%
+1.06%
16,856 (-176)
62,528 (+6,363)
42,775 (+11,279)
146,317 (+15,548)
254,922 (+15,608)
76,497 (+2,805)
211,373 (+2,214)
-1.03%
+11.33%
+35.81%
+11.89%
+6.52%
+3.81%
+1.06%
17,589 (-156)
62,528 (+6,363)
42,775 (+11,279)
146,317 (+15,548)
254,922 (+15,608)
76,497 (+2,805)
211,373 (+2,214)
-0.88%
+11.33%
+35.81%
+11.89%
+6.52%
+3.81%
+1.06%
17,589 (-156)
62,528 (+6,363)
42,775 (+11,279)
146,317 (+15,548)
254,922 (+15,608)
76,497 (+2,805)
211,373 (+2,214)
-0.88%
+11.33%
+35.81%
+11.89%
+6.52%
+3.81%
+1.06%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6ExecuteUnrestrictedController 2,898,727 (+23,036) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,657 (-239)
63,032 (+6,237)
44,375 (+10,879)
145,066 (+15,548)
253,671 (+15,608)
75,246 (+3,118)
209,809 (+2,214)
-1.60%
+10.98%
+32.48%
+12.00%
+6.56%
+4.32%
+1.07%
16,856 (-176)
63,032 (+6,237)
44,375 (+10,879)
145,066 (+15,548)
253,671 (+15,608)
75,246 (+3,118)
209,809 (+2,214)
-1.03%
+10.98%
+32.48%
+12.00%
+6.56%
+4.32%
+1.07%
17,589 (-156)
63,032 (+6,237)
44,375 (+10,879)
145,066 (+15,548)
253,671 (+15,608)
75,246 (+3,118)
209,809 (+2,214)
-0.88%
+10.98%
+32.48%
+12.00%
+6.56%
+4.32%
+1.07%
17,589 (-156)
63,032 (+6,237)
44,375 (+10,879)
145,066 (+15,548)
253,671 (+15,608)
75,246 (+3,118)
209,809 (+2,214)
-0.88%
+10.98%
+32.48%
+12.00%
+6.56%
+4.32%
+1.07%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6SetDataRestrictedController 2,883,512 (+23,044) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,770 (+12,280)
122,881 (+2,247)
141,590 (+2,706)
+66.41%
+1.86%
+1.95%
34,616 (+6,081)
122,881 (+2,247)
141,590 (+2,706)
+21.31%
+1.86%
+1.95%
34,616 (+6,081)
122,881 (+2,247)
141,590 (+2,706)
+21.31%
+1.86%
+1.95%
38,463 (-118)
122,881 (+2,247)
141,590 (+2,706)
-0.31%
+1.86%
+1.95%
2 (0)
1 (0)
1 (0)
LSP6SetDataUnrestrictedController 2,883,512 (+23,044) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,770 (+12,280)
128,881 (+2,247)
150,090 (+2,706)
+66.41%
+1.77%
+1.84%
34,616 (+6,081)
128,881 (+2,247)
150,090 (+2,706)
+21.31%
+1.77%
+1.84%
34,616 (+6,081)
128,881 (+2,247)
150,090 (+2,706)
+21.31%
+1.77%
+1.84%
38,463 (-118)
128,881 (+2,247)
150,090 (+2,706)
-0.31%
+1.77%
+1.84%
2 (0)
1 (0)
1 (0)

@CJ42 CJ42 merged commit 1b92517 into develop Oct 10, 2023
27 checks passed
@CJ42 CJ42 deleted the DEV-5240 branch October 10, 2023 11:28
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.

4 participants