-
Notifications
You must be signed in to change notification settings - Fork 0
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
Switch from callcode
to delegatecall
#222
Conversation
@@ -137,32 +137,3 @@ sequenceDiagram title: Execute Quark Operation with Callback | |||
S -->> S: [14] Run Script | |||
S -->> T: [15] Erc20 Transfer "Repay" [sender=User Wallet] | |||
``` | |||
|
|||
## Upgrade Quark Wallet |
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.
Interesting to see this. I guess there was a point in time when we were using a fully upgradeable proxy for the Quark wallet.
bffc5ee
to
8e664aa
Compare
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.
looks good. trying to think if this could break anything, but generally, it seems like a safer alternative to the previous strategy.
// Note: CALLCODE is used to set the QuarkWallet as the `msg.sender` | ||
success := | ||
callcode(gas(), scriptAddress, /* value */ 0, add(scriptCalldata, 0x20), scriptCalldataLen, 0x0, 0) | ||
success := delegatecall(gas(), scriptAddress, add(scriptCalldata, 0x20), scriptCalldataLen, 0x0, 0) |
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.
To be clear, we don't want to use msg.value
here still, right?
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.
msg.value
will always be 0 because none of the executeQuarkOperation
functions are payable
.
8e664aa
to
09f8e8d
Compare
Now that we use
tstore/tload
for reentrancy guards, theonlyWallet
modifier is no longer needed. This is was pretty much the only remaining reason for usingcallcode
overdelegatecall
to execute a Quark script. Sincecallcode
is a deprecated opcode, it is better to switch over todelegatecall
.The one side effect of this switch-over is that scripts have to use
address(this)
instead ofmsg.sender
to refer to the Quark wallet's address. Surprisingly, all our existing core scripts were already usingaddress(this)
, so the only changes we have to make are to the test scripts.