-
Notifications
You must be signed in to change notification settings - Fork 50
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: save gas by not reading target
storage when controller has both permissions already
#588
Conversation
👋 Hello ⛽📊 See Gas Benchmark report of Using UniversalProfile owned by an EOA🔀
|
execute scenarios - 👑 UP Owner |
⛽ Gas Usage |
---|---|
Transfer 1 LYX to an EOA without data | 37570 |
Transfer 1 LYX to a UP without data | 36672 |
Transfer 1 LYX to an EOA with 256 bytes of data | 42243 |
Transfer 1 LYX to a UP with 256 bytes of data | 44795 |
Transfer 0.1 LYX to 3x EOA without data | 70967 |
Transfer 0.1 LYX to 3x UP without data | 75785 |
Transfer 0.1 LYX to 3x EOA with 256 bytes of data | 84955 |
Transfer 0.1 LYX to 3x EOA with 256 bytes of data | 100075 |
🗄️ setData
scenarios
setData scenarios - 👑 UP Owner |
⛽ Gas Usage |
---|---|
Set a 20 bytes long value | 49996 |
Set a 60 bytes long value | 95318 |
Set a 160 bytes long value | 164468 |
Set a 300 bytes long value | 279693 |
Set a 600 bytes long value | 484141 |
Change the value of a data key already set | 32884 |
Remove the value of a data key already set | 27348 |
Set 2 data keys of 20 bytes long value | 78466 |
Set 2 data keys of 100 bytes long value | 260630 |
Set 3 data keys of 20 bytes long value | 105196 |
Change the value of three data keys already set of 20 bytes long value | 45520 |
Remove the value of three data keys already set | 41380 |
🗄️ Tokens
scenarios
Tokens scenarios - 👑 UP Owner |
⛽ Gas Usage |
---|---|
Minting a LSP7Token to a UP (No Delegate) from an EOA | 91352 |
Minting a LSP7Token to an EOA from an EOA | 59209 |
Transferring an LSP7Token from a UP to another UP (No Delegate) | 98998 |
Minting a LSP8Token to a UP (No Delegate) from an EOA | 158331 |
Minting a LSP8Token to an EOA from an EOA | 126188 |
Transferring an LSP8Token from a UP to another UP (No Delegate) | 147520 |
📝 Notes
- The
execute
andsetData
scenarios are executed on a fresh UniversalProfile smart contract, deployed as standard contracts (not as proxy behind a base contract implementation).
⛽📊 See Gas Benchmark report of Using UniversalProfile owned by an LSP6KeyManager
This document contains the gas usage for common interactions and scenarios when using UniversalProfile smart contracts.
🔀 execute
scenarios
👑 unrestricted controller
execute scenarios - 👑 main controller |
⛽ Gas Usage |
---|---|
transfer LYX to an EOA | 60786 |
transfer LYX to a UP | 62388 |
transfer tokens (LSP7) to an EOA (no data) | 107673 |
transfer tokens (LSP7) to a UP (no data) | 243935 |
transfer a NFT (LSP8) to a EOA (no data) | 171495 |
transfer a NFT (LSP8) to a UP (no data) | 291110 |
🛃 restricted controller
execute scenarios - 🛃 restricted controller |
⛽ Gas Usage |
---|---|
transfer some LYXes to an EOA - restricted to 1 x allowed address only (TRANSFERVALUE + 1x AllowedCalls) | 73025 |
transfers some tokens (LSP7) to an EOA - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) | 123479 |
transfers some tokens (LSP7) to an other UP - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) | 259741 |
transfers a NFT (LSP8) to an EOA - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) | 187289 |
transfers a NFT (LSP8) to an other UP - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) | 306904 |
🗄️ setData
scenarios
👑 unrestricted controller
setData scenarios - 👑 main controller |
⛽ Gas Usage |
---|---|
updates profile details (LSP3Profile metadata) | 137154 |
give permissions to a controller (AddressPermissions[] + AddressPermissions[index] + AddressPermissions:Permissions:) | 133229 |
restrict a controller to some specific ERC725Y Data Keys | 139498 |
restrict a controller to interact only with 3x specific addresses | 162202 |
remove a controller (its permissions + its address from the AddressPermissions[] array) | 68186 |
write 5x LSP12 Issued Assets | 233651 |
🛃 restricted controller
setData scenarios - 🛃 restricted controller |
⛽ Gas Usage |
---|---|
setData(bytes32,bytes) -> updates 1x data key |
102880 |
setData(bytes32[],bytes[]) -> updates 3x data keys (first x3) |
161780 |
setData(bytes32[],bytes[]) -> updates 3x data keys (middle x3) |
145823 |
setData(bytes32[],bytes[]) -> updates 3x data keys (last x3) |
171008 |
setData(bytes32[],bytes[]) -> updates 2x data keys + add 3x new controllers (including setting the array length + indexes under AddressPermissions[index]) |
250352 |
📝 Notes
- The
execute
andsetData
scenarios are executed on a fresh UniversalProfile and LSP6KeyManager smart contracts, deployed as standard contracts (not as proxy behind a base contract implementation).
Changes to gas cost
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one 👍
What does this PR introduce?
⚡️ Performance
Reduce gas cost of setting data keys related to:
AddressPermissions:Permissions:<address>
) or controllers list (AddressPermissions[]
)This is done by avoiding multiple storage read via
getData(...)
if the controller making the request already has both permissions required.Based on idea suggestion from @YamenMerhi in the LIP repo.
lukso-network/LIPs#110 (comment)
🛢️ Gas Saved for
setData(...)
🛢️ Changes in deployment cost
PR Checklist
npm run linter
(solhint)npm run format
(prettier)npm run build
npm run test