-
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
fix: [L-01] Return bytes
directly in LSP6 _executePayload
, to prevent data loss
#784
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changes to gas cost
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
…cuteRelayCallBatch`
CJ42
force-pushed
the
fix/lsp6-return-bytes
branch
from
November 2, 2023 11:00
3773c85
to
49e2248
Compare
👋 Hello ⛽📊 Gas Benchmark ReportDeployment Costs
Runtime CostsUniversalProfile owned by an 🔑 EOA🔀
|
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 | 42209 (-24 📉✅) |
Transfer 1 LYX to a UP with 256 bytes of data | 57310 (-24 📉✅) |
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 | 137689 (36 📈❌) |
🗄️ setData
scenarios
setData scenarios - UP owned by 🔑 EOA |
⛽ Gas Usage |
---|---|
Set a 20 bytes long value | 49971 (0 ) |
Set a 60 bytes long value | 95293 (0 ) |
Set a 160 bytes long value | 164465 (0 ) |
Set a 300 bytes long value | 279700 (24 📈❌) |
Set a 600 bytes long value | 484148 (-12 📉✅) |
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 | 78442 (-12 📉✅) |
Set 2 data keys of 100 bytes long value | 260606 (-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 | 45459 (-12 📉✅) |
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 | 92724 (0 ) |
Minting a LSP7Token to an EOA from an EOA | 59377 (0 ) |
Transferring an LSP7Token from a UP to another UP (No Delegate) | 101577 (0 ) |
Minting a LSP8Token to a UP (No Delegate) from an EOA | 159593 (0 ) |
Minting a LSP8Token to an EOA from an EOA | 126247 (0 ) |
Transferring an LSP8Token from a UP to another UP (No Delegate) | 150271 (0 ) |
UniversalProfile owned by a 🔒📄 LSP6KeyManager
🔀 execute
scenarios
execute scenarios |
👑 main controller | 🛃 restricted controller |
---|---|---|
LYX transfer --> to an EOA | 64336 (0 ) | 75148 (0 ) |
LYX transfer --> to a UP | 78488 (0 ) | 93210 (0 ) |
LSP7 token transfer --> to an EOA | 116353 (0 ) | 131067 (0 ) |
LSP7 token transfer --> to a UP | 249627 (0 ) | 264341 (0 ) |
LSP8 NFT transfer --> to an EOA | 180440 (0 ) | 195154 (0 ) |
LSP8 NFT transfer --> to a UP | 296916 (0 ) | 311630 (0 ) |
🗄️ setData
scenarios
setData scenarios |
👑 main controller | 🛃 restricted controller |
---|---|---|
Update Profile details (LSP3Profile Metadata) | 67338 (0 ) | 77360 (0 ) |
Add a new controller with permission to SET_DATA + 3x allowed data keys: AddressPermissions[] + AddressPermissions[index] + AddressPermissions:Permissions:<controller> + AddressPermissions:AllowedERC725YDataKeys:<controller ) |
209610 (0 ) | 219767 (0 ) |
Update permissions of previous controller. Allow it now to SUPER_SETDATA |
52366 (0 ) | 55372 (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: |
78842 (0 ) | 90140 (0 ) |
Write 5x new LSP12 Issued Assets | 67032 (0 ) | 101659 (0 ) |
Update 3x data keys (first 3) | 125476 (0 ) | 159580 (0 ) |
Update 3x data keys (middle 3) | 105564 (0 ) | 143734 (0 ) |
Update 3x data keys (last 3) | 125476 (0 ) | 169067 (0 ) |
Set 2 x new data keys + add 3x new controllers | 810447 (0 ) | 872247 (0 ) |
skimaharvey
approved these changes
Nov 2, 2023
YamenMerhi
approved these changes
Nov 2, 2023
b00ste
approved these changes
Nov 2, 2023
This was referenced Nov 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR introduce?
🐛 Bug Fix
Current Behaviour
In the Key Manager, when calling
executeBatch
function on the LSP0 linked contract via:LSP6KeyManager.execute(...)
LSP6KeyManager.executeBatch(...)
LSP6KeyManager.executeRelayCall(...)
LSP6KeyManager.executeRelayCallBatch(...)
When the callData (or one of the callData in the batch functions) is
executeBatch
, the internal_executePayload
incorrectly decodes it asbytes
, while the type returned isbytes[]
.For example, when calling
executeBatch
with two payloads that call a view function that should return:Instead of returning an abi-encoded array of
bytes[]
as shown in screenshot below:It decodes as
bytes
, which results in data loss and return the following:The reason for this incorrect decoding is because the
abi.decode(result, (bytes))
treats incorrectly the first 2 x 32 bytes word of the return data.The line with the ternary operator:
lsp-smart-contracts/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol
Line 519 in dceee16
thinks treat as it was decoding a
byte
of length2
, when in fact2
is the length of the array ofbytes[]
.This is the reason why in the screenshot above,
0x0000
is returned, because it takes the 2 bytes that follow which are0000
.New Behaviour
Return the byte as raw abi-encoded
bytes
.Decoding immediately as
bytes
is not possible anymore since the addition of theexecuteBatch
path in the Key Manager. This data should then be decoded on the client side first asbytes
orbytes[]
if the functionexecuteRelayCall
was called on the Key Manager for instance.PR Checklist
npm run lint
&&npm run lint:solidity
(solhint)npm run format
(prettier)npm run build
npm run test