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

refactor!: Emit full DataChanged Event in LSP0 and LSP7, LSP8 #814

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

YamenMerhi
Copy link
Member

@YamenMerhi YamenMerhi commented Nov 29, 2023

What does this PR introduce?

⚠️ BREAKING CHANGES

  • Increase minimum solc version to ^0.8.12 for LSP8IdentifiableDigitalAsset contracts
  • This PR has no impact on the Event signatures of DataChanged event in LSP0, LSP7, LSP8 and LSP9. However, interfaces and listeners need to expect the full emission of data rather than just the first 256 bytes.

♻️ Refactor

  • Emit the full data in the DataChanged event.

The decision was backed by the fact that 256 is very limiting and users already storing big amount of data wouldn't mind a little bump in the gas cost due to the emission of the whole data, which can be very useful for interfaces to detect on the fly and for historical reasons.

The test branch is available with the name testGasCost with running this test file to check the gas cost:
https://github.com/lukso-network/lsp-smart-contracts/blob/testGasCost/tests/Mocks/DataChanged.test.ts

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

👋 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 3168335 (-11,270 📉✅)
KeyManager 3659015 (0 )
LSP1DelegateUP 1637510 (0 )
LSP7Mintable 2407823 (-86,074 📉✅)
LSP8Mintable 2809909 (-97,092 📉✅)

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 37572 (0 )
Transfer 1 LYX to a UP without data 46265 (0 )
Transfer 1 LYX to an EOA with 256 bytes of data 42245 (24 📈❌)
Transfer 1 LYX to a UP with 256 bytes of data 57198 (12 📈❌)
Transfer 0.1 LYX to 3x EOA without data 70898 (0 )
Transfer 0.1 LYX to 3x UP without data 104489 (0 )
Transfer 0.1 LYX to 3x EOA with 256 bytes of data 84862 (0 )
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 49921 (-30 📉✅)
Set a 60 bytes long value 95243 (-30 📉✅)
Set a 160 bytes long value 164415 (-18 📉✅)
Set a 300 bytes long value 279296 (-372 📉✅)
Set a 600 bytes long value 486692 (2,588 📈❌)
Change the value of a data key already set 32809 (-30 📉✅)
Remove the value of a data key already set 27283 (-30 📉✅)
Set 2 data keys of 20 bytes long value 78440 (-60 📉✅)
Set 2 data keys of 100 bytes long value 260604 (-60 📉✅)
Set 3 data keys of 20 bytes long value 105128 (-90 📉✅)
Change the value of three data keys already set of 20 bytes long value 45416 (-102 📉✅)
Remove the value of three data keys already set 41325 (-72 📉✅)

🗄️ Tokens scenarios

Tokens scenarios - UP owned by 🔑 EOA ⛽ Gas Usage
Minting a LSP7Token to a UP (No Delegate) from an EOA 93114 (0 )
Minting a LSP7Token to an EOA from an EOA 59390 (0 )
Transferring an LSP7Token from a UP to another UP (No Delegate) 102367 (0 )
Minting a LSP8Token to a UP (No Delegate) from an EOA 159961 (0 )
Minting a LSP8Token to an EOA from an EOA 126238 (0 )
Transferring an LSP8Token from a UP to another UP (No Delegate) 151061 (0 )
UniversalProfile owned by a 🔒📄 LSP6KeyManager

🔀 execute scenarios

execute scenarios 👑 main controller 🛃 restricted controller
LYX transfer --> to an EOA 64365 (0 ) 75316 (0 )
LYX transfer --> to a UP 78508 (0 ) 93410 (0 )
LSP7 token transfer --> to an EOA 116872 (0 ) 131622 (0 )
LSP7 token transfer --> to a UP 250518 (-90 📉✅) 265268 (-90 📉✅)
LSP8 NFT transfer --> to an EOA 180937 (0 ) 195687 (0 )
LSP8 NFT transfer --> to a UP 297763 (-90 📉✅) 312513 (-90 📉✅)

🗄️ setData scenarios

setData scenarios 👑 main controller 🛃 restricted controller
Update Profile details (LSP3Profile Metadata) 67264 (-30 📉✅) 77286 (-30 📉✅)
Add a new controller with permission to SET_DATA + 3x allowed data keys:
AddressPermissions[]
+ AddressPermissions[index]
+ AddressPermissions:Permissions:<controller>
+ AddressPermissions:AllowedERC725YDataKeys:<controller)
209516 (-120 📉✅) 219673 (-120 📉✅)
Update permissions of previous controller. Allow it now to SUPER_SETDATA 52292 (-30 📉✅) 55298 (-30 📉✅)
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:
78765 (-96 📉✅) 90064 (-96 📉✅)
Write 5x new LSP12 Issued Assets 66959 (-30 📉✅) 101586 (-30 📉✅)
Update 3x data keys (first 3) 125411 (-90 📉✅) 159515 (-90 📉✅)
Update 3x data keys (middle 3) 105499 (-90 📉✅) 143669 (-90 📉✅)
Update 3x data keys (last 3) 125411 (-90 📉✅) 169002 (-90 📉✅)
Set 2 x new data keys + add 3x new controllers 810121 (-360 📉✅) 871921 (-360 📉✅)

Copy link
Contributor

github-actions bot commented Nov 29, 2023

Changes to gas cost

Generated at commit: c68e0578ab43c65a5bf2bfd529512f8c7de8adfd, compared to commit: 6594f678c362bf26882023aa1a108bfd8188924d

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
LSP6ExecuteUnrestrictedController transferTokensToRandomEOA
transferTokensToRandomUP
+327 ❌
+761 ❌
+0.44%
+0.37%
LSP6ExecuteRestrictedController transferTokensToRandomEOA +327 ❌ +0.44%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
LSP6ExecuteUnrestrictedController 3,047,114 (0) transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
62,566 (-19)
56,893 (-61)
142,035 (+281)
247,939 (+563)
74,080 (+327)
204,887 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,566 (-19)
56,893 (-61)
142,035 (+281)
247,939 (+563)
74,080 (+327)
204,887 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,566 (-19)
56,893 (-61)
142,035 (+281)
247,939 (+563)
74,080 (+327)
204,887 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,566 (-19)
56,893 (-61)
142,035 (+281)
247,939 (+563)
74,080 (+327)
204,887 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6ExecuteRestrictedController 3,047,114 (0) transferLYXToEOA
transferLYXToUP
transferNFTToRandomEOA
transferNFTToRandomUP
transferTokensToRandomEOA
transferTokensToRandomUP
62,179 (-19)
55,293 (-61)
143,291 (+281)
249,195 (+563)
75,336 (+327)
206,457 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,179 (-19)
55,293 (-61)
143,291 (+281)
249,195 (+563)
75,336 (+327)
206,457 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,179 (-19)
55,293 (-61)
143,291 (+281)
249,195 (+563)
75,336 (+327)
206,457 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
62,179 (-19)
55,293 (-61)
143,291 (+281)
249,195 (+563)
75,336 (+327)
206,457 (+761)
-0.03%
-0.11%
+0.20%
+0.23%
+0.44%
+0.37%
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
LSP6SetDataRestrictedController 3,035,099 (0) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,309 (-19)
122,599 (-90)
141,525 (-60)
-0.06%
-0.07%
-0.04%
34,281 (-25)
122,599 (-90)
141,525 (-60)
-0.07%
-0.07%
-0.04%
34,281 (-25)
122,599 (-90)
141,525 (-60)
-0.07%
-0.07%
-0.04%
38,254 (-30)
122,599 (-90)
141,525 (-60)
-0.08%
-0.07%
-0.04%
2 (0)
1 (0)
1 (0)
LSP6SetDataUnrestrictedController 3,035,099 (0) execute
givePermissionsToController
restrictControllerToERC725YKeys
30,309 (-19)
128,599 (-90)
150,025 (-60)
-0.06%
-0.07%
-0.04%
34,281 (-25)
128,599 (-90)
150,025 (-60)
-0.07%
-0.07%
-0.04%
34,281 (-25)
128,599 (-90)
150,025 (-60)
-0.07%
-0.07%
-0.04%
38,254 (-30)
128,599 (-90)
150,025 (-60)
-0.08%
-0.07%
-0.04%
2 (0)
1 (0)
1 (0)

@YamenMerhi YamenMerhi merged commit 6a5ea06 into develop Nov 29, 2023
25 checks passed
@YamenMerhi YamenMerhi deleted the removeEventLimit branch November 29, 2023 16:00
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.

None yet

3 participants