Bubble revert reasons in proxy initialization (#2454)

Co-authored-by: Hadrien Croubois <hadrien@openzeppelin.com>
pull/2456/head
Hadrien Croubois 4 years ago committed by GitHub
parent 9daa0d4d2f
commit 1e8cb4b4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      contracts/proxy/TransparentUpgradeableProxy.sol
  3. 4
      contracts/proxy/UpgradeableProxy.sol
  4. 12
      test/proxy/UpgradeableProxy.behaviour.js

@ -7,6 +7,7 @@
* `ERC20Permit`: added an implementation of the ERC20 permit extension for gasless token approvals. ([#2237](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237))
* Presets: added token presets with preminted fixed supply `ERC20PresetFixedSupply` and `ERC777PresetFixedSupply`. ([#2399](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2399))
* `Address`: added `functionDelegateCall`, similar to the existing `functionCall`. ([#2333](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2333))
* `UpgradeableProxy`: bubble revert reasons from initialization calls. ([#2454](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2454))
## 3.3.0 (2020-11-26)

@ -115,9 +115,7 @@ contract TransparentUpgradeableProxy is UpgradeableProxy {
*/
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
_upgradeTo(newImplementation);
// solhint-disable-next-line avoid-low-level-calls
(bool success,) = newImplementation.delegatecall(data);
require(success);
Address.functionDelegateCall(newImplementation, data);
}
/**

@ -25,9 +25,7 @@ contract UpgradeableProxy is Proxy {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
// solhint-disable-next-line avoid-low-level-calls
(bool success,) = _logic.delegatecall(_data);
require(success);
Address.functionDelegateCall(_logic, _data);
}
}

@ -210,5 +210,17 @@ module.exports = function shouldBehaveLikeUpgradeableProxy (createProxy, proxyAd
});
});
});
describe('reverting initialization', function () {
const initializeData = new DummyImplementation('').contract
.methods.reverts().encodeABI();
it('reverts', async function () {
await expectRevert(
createProxy(this.implementation, proxyAdminAddress, initializeData, { from: proxyCreator }),
'DummyImplementation reverted',
);
});
});
});
};

Loading…
Cancel
Save