Commit 4eb8d2bb by Francisco Giordano

Revert "feat: use extcodesize for isContract to reduce gas (#2311)"

This reverts commit c801c8d2.
parent 04fc3570
# Changelog # Changelog
## 3.1.1 (Unreleased)
### Improvements
* `Address.isContract`: switched from `extcodehash` to `extcodesize` for less gas usage. ([#2311](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2311))
## 3.1.0 (2020-06-23) ## 3.1.0 (2020-06-23)
### New features ### New features
......
...@@ -24,14 +24,14 @@ library Address { ...@@ -24,14 +24,14 @@ library Address {
* ==== * ====
*/ */
function isContract(address account) internal view returns (bool) { function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// construction, since the code is only stored at the end of the // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// constructor execution. // for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
uint256 size; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly // solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) } assembly { codehash := extcodehash(account) }
return size > 0; return (codehash != accountHash && codehash != 0x0);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment