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

docs: Improve natspec for LSP0 #794

Merged
merged 4 commits into from
Nov 7, 2023
Merged

docs: Improve natspec for LSP0 #794

merged 4 commits into from
Nov 7, 2023

Conversation

YamenMerhi
Copy link
Member

What does this PR introduce?

📄 Documentation

docs: Improve natspec for LSP0

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

Copy link
Contributor

github-actions bot commented Nov 6, 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 3185468 (0 )
KeyManager 3659015 (0 )
LSP1DelegateUP 1637510 (0 )
LSP7Mintable 2333123 (0 )
LSP8Mintable 2423070 (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 37560 (0 )
Transfer 1 LYX to a UP without data 46253 (0 )
Transfer 1 LYX to an EOA with 256 bytes of data 42233 (12 📈❌)
Transfer 1 LYX to a UP with 256 bytes of data 57186 (0 )
Transfer 0.1 LYX to 3x EOA without data 70862 (0 )
Transfer 0.1 LYX to 3x UP without data 104453 (0 )
Transfer 0.1 LYX to 3x EOA with 256 bytes of data 84862 (24 📈❌)
Transfer 0.1 LYX to 3x UPs with 256 bytes of data 137245 (0 )

🗄️ setData scenarios

setData scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Set a 20 bytes long value 49951 (0 )
Set a 60 bytes long value 95273 (12 📈❌)
Set a 160 bytes long value 164445 (12 📈❌)
Set a 300 bytes long value 279668 (12 📈❌)
Set a 600 bytes long value 484140 (12 📈❌)
Change the value of a data key already set 32839 (0 )
Remove the value of a data key already set 27313 (0 )
Set 2 data keys of 20 bytes long value 78500 (12 📈❌)
Set 2 data keys of 100 bytes long value 260652 (12 📈❌)
Set 3 data keys of 20 bytes long value 105218 (0 )
Change the value of three data keys already set of 20 bytes long value 45518 (0 )
Remove the value of three data keys already set 41397 (0 )

🗄️ Tokens scenarios

Tokens scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Minting a LSP7Token to a UP (No Delegate) from an EOA 92680 (0 )
Minting a LSP7Token to an EOA from an EOA 59355 (0 )
Transferring an LSP7Token from a UP to another UP (No Delegate) 101556 (0 )
Minting a LSP8Token to a UP (No Delegate) from an EOA 159571 (0 )
Minting a LSP8Token to an EOA from an EOA 126247 (0 )
Transferring an LSP8Token from a UP to another UP (No Delegate) 150249 (0 )
UniversalProfile owned by a 🔒📄 LSP6KeyManager

🔀 execute scenarios

execute scenarios 👑 main controller 🛃 restricted controller
LYX transfer --> to an EOA 64356 (0 ) 75306 (0 )
LYX transfer --> to a UP 78489 (0 ) 93386 (0 )
LSP7 token transfer --> to an EOA 116353 (0 ) 131103 (0 )
LSP7 token transfer --> to a UP 249583 (0 ) 264333 (0 )
LSP8 NFT transfer --> to an EOA 180461 (0 ) 195188 (0 )
LSP8 NFT transfer --> to a UP 296915 (0 ) 311642 (0 )

🗄️ setData scenarios

setData scenarios 👑 main controller 🛃 restricted controller
Update Profile details (LSP3Profile Metadata) 67294 (0 ) 77316 (0 )
Add a new controller with permission to SET_DATA + 3x allowed data keys:
AddressPermissions[]
+ AddressPermissions[index]
+ AddressPermissions:Permissions:<controller>
+ AddressPermissions:AllowedERC725YDataKeys:<controller)
209636 (0 ) 219793 (0 )
Update permissions of previous controller. Allow it now to SUPER_SETDATA 52322 (0 ) 55328 (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:
78861 (0 ) 90160 (0 )
Write 5x new LSP12 Issued Assets 66989 (0 ) 101616 (0 )
Update 3x data keys (first 3) 125501 (0 ) 159605 (0 )
Update 3x data keys (middle 3) 105589 (0 ) 143759 (0 )
Update 3x data keys (last 3) 125501 (0 ) 169092 (0 )
Set 2 x new data keys + add 3x new controllers 810481 (0 ) 872281 (0 )

Copy link
Contributor

github-actions bot commented Nov 6, 2023

Changes to gas cost

Generated at commit: 4c162619533cd3692936d3af033c3b600eac7945, compared to commit: 1f92ca530fb56cf2b626b0feae311d6c4737b8a0

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
LSP6ExecuteRestrictedController lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
-22 ✅
-210 ✅
-385 ✅
-358 ✅
-356 ✅
-308 ✅
-494 ✅
-0.13%
-0.34%
-0.69%
-0.25%
-0.14%
-0.41%
-0.24%
LSP6ExecuteUnrestrictedController lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
-22 ✅
-350 ✅
-385 ✅
-386 ✅
-385 ✅
-337 ✅
-530 ✅
-0.13%
-0.56%
-0.67%
-0.27%
-0.16%
-0.45%
-0.26%
LSP6SetDataRestrictedController execute
givePermissionsToController
restrictControllerToERC725YKeys
-208 ✅
+3 ❌
+112 ❌
-0.60%
+0.00%
+0.08%
LSP6SetDataUnrestrictedController execute
restrictControllerToERC725YKeys
-208 ✅
+112 ❌
-0.60%
+0.07%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
LSP6ExecuteRestrictedController 3,047,114 (+2,807) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,751 (-22)
62,198 (-210)
55,354 (-385)
143,010 (-358)
248,632 (-356)
75,009 (-308)
205,696 (-494)
-0.15%
-0.34%
-0.69%
-0.25%
-0.14%
-0.41%
-0.24%
16,974 (-22)
62,198 (-210)
55,354 (-385)
143,010 (-358)
248,632 (-356)
75,009 (-308)
205,696 (-494)
-0.13%
-0.34%
-0.69%
-0.25%
-0.14%
-0.41%
-0.24%
17,716 (-22)
62,198 (-210)
55,354 (-385)
143,010 (-358)
248,632 (-356)
75,009 (-308)
205,696 (-494)
-0.12%
-0.34%
-0.69%
-0.25%
-0.14%
-0.41%
-0.24%
17,716 (-22)
62,198 (-210)
55,354 (-385)
143,010 (-358)
248,632 (-356)
75,009 (-308)
205,696 (-494)
-0.12%
-0.34%
-0.69%
-0.25%
-0.14%
-0.41%
-0.24%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6ExecuteUnrestrictedController 3,047,114 (+2,807) lsp20VerifyCall
transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
14,751 (-22)
62,585 (-350)
56,954 (-385)
141,754 (-386)
247,376 (-385)
73,753 (-337)
204,126 (-530)
-0.15%
-0.56%
-0.67%
-0.27%
-0.16%
-0.45%
-0.26%
16,974 (-22)
62,585 (-350)
56,954 (-385)
141,754 (-386)
247,376 (-385)
73,753 (-337)
204,126 (-530)
-0.13%
-0.56%
-0.67%
-0.27%
-0.16%
-0.45%
-0.26%
17,716 (-22)
62,585 (-350)
56,954 (-385)
141,754 (-386)
247,376 (-385)
73,753 (-337)
204,126 (-530)
-0.12%
-0.56%
-0.67%
-0.27%
-0.16%
-0.45%
-0.26%
17,716 (-22)
62,585 (-350)
56,954 (-385)
141,754 (-386)
247,376 (-385)
73,753 (-337)
204,126 (-530)
-0.12%
-0.56%
-0.67%
-0.27%
-0.16%
-0.45%
-0.26%
8 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6SetDataRestrictedController 3,035,099 (+2,808) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,328 (-352)
122,689 (+3)
141,585 (+112)
-1.15%
+0.00%
+0.08%
34,306 (-208)
122,689 (+3)
141,585 (+112)
-0.60%
+0.00%
+0.08%
34,306 (-208)
122,689 (+3)
141,585 (+112)
-0.60%
+0.00%
+0.08%
38,284 (-65)
122,689 (+3)
141,585 (+112)
-0.17%
+0.00%
+0.08%
2 (0)
1 (0)
1 (0)
LSP6SetDataUnrestrictedController 3,035,099 (+2,808) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,328 (-352)
128,689 (+3)
150,085 (+112)
-1.15%
+0.00%
+0.07%
34,306 (-208)
128,689 (+3)
150,085 (+112)
-0.60%
+0.00%
+0.07%
34,306 (-208)
128,689 (+3)
150,085 (+112)
-0.60%
+0.00%
+0.07%
38,284 (-65)
128,689 (+3)
150,085 (+112)
-0.17%
+0.00%
+0.07%
2 (0)
1 (0)
1 (0)

contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol Outdated Show resolved Hide resolved
contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol Outdated Show resolved Hide resolved
contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol Outdated Show resolved Hide resolved
@@ -120,6 +128,8 @@ abstract contract LSP0ERC725AccountCore is
*
* 2. If the data sent to this function is of length less than 4 bytes (not a function selector), return.
*
* Whenever the call is associated with native tokens, the function will delegate internally the handling of native tokens to the {universalReceiver} function passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and the calldata as received data, except when the native token will be sent directly to the extension.
Copy link
Member

Choose a reason for hiding this comment

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

Also worth mentioning when receiving less than 4 bytes of data.

Copy link
Member

Choose a reason for hiding this comment

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

except when the native token will be sent directly to the extension.

This last sentence makes it hard to understand. The only exception according to the code is when:

  • you receive some native tokens
  • you receive some data that is more than 4 bytes.

In this case, the associated LSP17 extension is called.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is generic saying all the time when native token is associated (even when data is less than 4 bytes), the universalReceiver is invoked, unless the native token is being forwarded to the extension, but happy to add a suggestion if you have one

Whenever the call is associated with native tokens, the function will delegate internally the handling of native tokens to the {universalReceiver} function passing _TYPEID_LSP0_VALUE_RECEIVED as typeId and the calldata as received data, except when the native token will be sent directly to the extension.

@CJ42 CJ42 merged commit 6594f67 into develop Nov 7, 2023
25 checks passed
@CJ42 CJ42 deleted the natspec/lsp0 branch November 7, 2023 08:14
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.

2 participants