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
a664fb1e
Commit
a664fb1e
authored
Apr 19, 2021
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code comments in ERC1967._upgradeToAndCallSecure
(cherry picked from commit
2e6ef745
)
parent
df7996b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
ERC1967Upgrade.sol
contracts/proxy/ERC1967/ERC1967Upgrade.sol
+7
-7
No files found.
contracts/proxy/ERC1967/ERC1967Upgrade.sol
View file @
a664fb1e
...
...
@@ -61,16 +61,17 @@ abstract contract ERC1967Upgrade is ERC1967Storage {
*/
function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
address oldImplementation = _getImplementation();
// do inital upgrade
// Initial upgrade and setup call
_setImplementation(newImplementation);
// do setup call
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
// check if nested in an upgrade check
// Perform rollback test if not already in progress
StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
if (!rollbackTesting.value) {
//
trigger upgrade check with flag set to true
//
Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true;
Address.functionDelegateCall(
newImplementation,
...
...
@@ -80,11 +81,10 @@ abstract contract ERC1967Upgrade is ERC1967Storage {
)
);
rollbackTesting.value = false;
//
check upgrade
was effective
//
Check rollback
was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
//
reset
upgrade
//
Finally reset to the new implementation and log the
upgrade
_setImplementation(newImplementation);
// emit event
emit Upgraded(newImplementation);
}
}
...
...
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