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

feat: allow sending value when using setData(..) through the LSP6 #725

Merged
merged 4 commits into from
Oct 10, 2023

Conversation

b00ste
Copy link
Member

@b00ste b00ste commented Sep 20, 2023

What does this PR introduce?

🚀 Feature

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

@github-actions
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.

⛽📊 See Gas Benchmark report of Using UniversalProfile owned by an EOA

🔀 execute scenarios

execute scenarios - 👑 UP Owner ⛽ Gas Usage
Transfer 1 LYX to an EOA without data 37537
Transfer 1 LYX to a UP without data 36639
Transfer 1 LYX to an EOA with 256 bytes of data 42210
Transfer 1 LYX to a UP with 256 bytes of data 44855
Transfer 0.1 LYX to 3x EOA without data 70862
Transfer 0.1 LYX to 3x UP without data 75680
Transfer 0.1 LYX to 3x EOA with 256 bytes of data 84850
Transfer 0.1 LYX to 3x EOA with 256 bytes of data 100321

🗄️ setData scenarios

setData scenarios - 👑 UP Owner ⛽ Gas Usage
Set a 20 bytes long value 49971
Set a 60 bytes long value 95293
Set a 160 bytes long value 164465
Set a 300 bytes long value 279688
Set a 600 bytes long value 484148
Change the value of a data key already set 32859
Remove the value of a data key already set 27333
Set 2 data keys of 20 bytes long value 78428
Set 2 data keys of 100 bytes long value 260580
Set 3 data keys of 20 bytes long value 105145
Change the value of three data keys already set of 20 bytes long value 45445
Remove the value of three data keys already set 41339

🗄️ Tokens scenarios

Tokens scenarios - 👑 UP Owner ⛽ Gas Usage
Minting a LSP7Token to a UP (No Delegate) from an EOA 92016
Minting a LSP7Token to an EOA from an EOA 59323
Transferring an LSP7Token from a UP to another UP (No Delegate) 100102
Minting a LSP8Token to a UP (No Delegate) from an EOA 158946
Minting a LSP8Token to an EOA from an EOA 126253
Transferring an LSP8Token from a UP to another UP (No Delegate) 148671

📝 Notes

  • The execute and setData 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 60466
transfer LYX to a UP 62068
transfer tokens (LSP7) to an EOA (no data) 107986
transfer tokens (LSP7) to a UP (no data) 244403
transfer a NFT (LSP8) to a EOA (no data) 171855
transfer a NFT (LSP8) to a UP (no data) 291519

🛃 restricted controller

execute scenarios - 🛃 restricted controller ⛽ Gas Usage
transfer some LYXes to an EOA - restricted to 1 x allowed address only (TRANSFERVALUE + 1x AllowedCalls) 71658
transfers some tokens (LSP7) to an EOA - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) 122677
transfers some tokens (LSP7) to an other UP - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) 259094
transfers a NFT (LSP8) to an EOA - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) 186511
transfers a NFT (LSP8) to an other UP - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data) 306175

🗄️ setData scenarios

👑 unrestricted controller

setData scenarios - 👑 main controller ⛽ Gas Usage
updates profile details (LSP3Profile metadata) 136859
give permissions to a controller (AddressPermissions[] + AddressPermissions[index] + AddressPermissions:Permissions:) 132994
restrict a controller to some specific ERC725Y Data Keys 139266
restrict a controller to interact only with 3x specific addresses 161970
remove a controller (its permissions + its address from the AddressPermissions[] array) 67973
write 5x LSP12 Issued Assets 233237

🛃 restricted controller

setData scenarios - 🛃 restricted controller ⛽ Gas Usage
setData(bytes32,bytes) -> updates 1x data key 102760
setData(bytes32[],bytes[]) -> updates 3x data keys (first x3) 161499
setData(bytes32[],bytes[]) -> updates 3x data keys (middle x3) 145653
setData(bytes32[],bytes[]) -> updates 3x data keys (last x3) 170986
setData(bytes32[],bytes[]) -> updates 2x data keys + add 3x new controllers (including setting the array length + indexes under AddressPermissions[index]) 250985

📝 Notes

  • The execute and setData scenarios are executed on a fresh UniversalProfile and LSP6KeyManager smart contracts, deployed as standard contracts (not as proxy behind a base contract implementation).

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2023

Changes to gas cost

Generated at commit: 4cb2b042a6df77618120d2ae1a0ae673af938909, 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)

@b00ste b00ste marked this pull request as ready for review September 21, 2023 12:20
@b00ste b00ste force-pushed the feat/lsp6-setdata-payable branch 3 times, most recently from dae3572 to 1d5a637 Compare September 21, 2023 13:45
@b00ste b00ste force-pushed the feat/lsp6-setdata-payable branch 4 times, most recently from d265fd8 to 570367d Compare September 27, 2023 08:27
Copy link
Member

@CJ42 CJ42 left a comment

Choose a reason for hiding this comment

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

If we allow to send native tokens while setting data, we need now to add the permission check of TRANSFERVALUE while setting data + tests for it.

Sorry my bad, I got confused 🫠

I suggest we park this PR on the side and put it as draft for now until we have discussed and agreed on the decision with @frozeman

@@ -544,7 +546,6 @@ abstract contract LSP6KeyManagerCore is

// ERC725Y.setData(bytes32,bytes)
if (erc725Function == IERC725Y.setData.selector) {
if (msgValue != 0) revert CannotSendValueToSetData();
Copy link
Member

Choose a reason for hiding this comment

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

Since we are removing the custom error, we need to check for permission TRANSFERVALUE in addition to check for the permission SETDATA below via _verifyCanSetData(...).

Copy link
Member

Choose a reason for hiding this comment

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

why? It is just founding the account when setting data? not transfering?

Copy link
Member

Choose a reason for hiding this comment

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

Yes indeed. Got it wrong

@CJ42 CJ42 marked this pull request as draft October 2, 2023 15:34
@b00ste b00ste marked this pull request as ready for review October 10, 2023 09:01
@b00ste b00ste force-pushed the feat/lsp6-setdata-payable branch 2 times, most recently from 415a708 to 489b3ba Compare October 10, 2023 09:12
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 624c4a6 into develop Oct 10, 2023
27 checks passed
@CJ42 CJ42 deleted the feat/lsp6-setdata-payable branch October 10, 2023 10:04
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