Skip to content

Commit b7ca295

Browse files
committed
upgrades: sensitive functions inherited in implementations
GraphUpgradeable is meant to be inherited from contracts that will be implementations of the upgradeable pattern. As GraphUpgradeable was in turn inheriting GraphProxyStorage it was exposing some functions meant only to be used by the GraphProxy. Remove the GraphProxyStorage link to GraphUpgradeable and only expose the read-only required function to query the implementation address.
1 parent 0e36a39 commit b7ca295

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

contracts/upgrades/GraphUpgradeable.sol

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
pragma solidity ^0.6.12;
22

33
import "./IGraphProxy.sol";
4-
import "./GraphProxyStorage.sol";
54

65
/**
76
* @title Graph Upgradeable
87
* @dev This contract is intended to be inherited from upgradeable contracts.
9-
* This contract should NOT define storage as it is managed by GraphProxyStorage.
108
*/
11-
contract GraphUpgradeable is GraphProxyStorage {
9+
contract GraphUpgradeable {
10+
/**
11+
* @dev Storage slot with the address of the current implementation.
12+
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
13+
* validated in the constructor.
14+
*/
15+
bytes32
16+
internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
17+
1218
/**
1319
* @dev Check if the caller is the proxy admin.
1420
*/
@@ -25,6 +31,17 @@ contract GraphUpgradeable is GraphProxyStorage {
2531
_;
2632
}
2733

34+
/**
35+
* @dev Returns the current implementation.
36+
* @return impl Address of the current implementation
37+
*/
38+
function _implementation() internal view returns (address impl) {
39+
bytes32 slot = IMPLEMENTATION_SLOT;
40+
assembly {
41+
impl := sload(slot)
42+
}
43+
}
44+
2845
/**
2946
* @dev Admin function for new implementation to accept its role as implementation.
3047
*/

0 commit comments

Comments
 (0)