Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
4eb8d2bb
Commit
4eb8d2bb
authored
Jul 30, 2020
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "feat: use extcodesize for isContract to reduce gas (#2311)"
This reverts commit
c801c8d2
.
parent
04fc3570
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
CHANGELOG.md
CHANGELOG.md
+0
-5
Address.sol
contracts/utils/Address.sol
+7
-7
No files found.
CHANGELOG.md
View file @
4eb8d2bb
# 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)
### New features
...
...
contracts/utils/Address.sol
View file @
4eb8d2bb
...
...
@@ -24,14 +24,14 @@ library Address {
* ====
*/
function isContract(address account) internal view returns (bool) {
//
This method relies in extcodesize, which returns 0 for contracts in
//
construction, since the code is only stored at the end of the
//
constructor execution.
uint256 size
;
//
According to EIP-1052, 0x0 is the value returned for not-yet created accounts
//
and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
//
for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize
(account) }
return
size > 0
;
assembly {
codehash := extcodehash
(account) }
return
(codehash != accountHash && codehash != 0x0)
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment