Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Reduce asm in Proxy.sol #1487

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions packages/lib/contracts/upgradeability/Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,10 @@ contract Proxy {
* @param implementation Address to delegate.
*/
function _delegate(address implementation) internal {
(bool success, bytes memory data) = implementation.delegatecall(msg.data);
require(success, string(data));
frangio marked this conversation as resolved.
Show resolved Hide resolved
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize)

// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)

// Copy the returned data.
returndatacopy(0, 0, returndatasize)

switch result
// delegatecall returns 0 on error.
case 0 { revert(0, returndatasize) }
default { return(0, returndatasize) }
return(add(data, 32), returndatasize)
}
}

Expand Down