-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c4: gas optimization fixes #742
Changes from 6 commits
2c4ac9d
76865a4
18afb3a
ee5d3cb
71314dd
d5aece4
2ad9f4e
e0440a8
3805ca9
54157a7
7d29d6d
534d224
0b7ad55
d091781
1f85e12
27902cc
e3a668e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,14 @@ contract Managed { | |
mapping(bytes32 => address) private addressCache; | ||
uint256[10] private __gap; | ||
|
||
// Immutables | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to be immutable than const? as there are no parametrization happening There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in this case it's the same as we are using I went with |
||
bytes32 immutable CURATION = keccak256("Curation"); | ||
tmigone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bytes32 immutable EPOCH_MANAGER = keccak256("EpochManager"); | ||
bytes32 immutable REWARDS_MANAGER = keccak256("RewardsManager"); | ||
bytes32 immutable STAKING = keccak256("Staking"); | ||
bytes32 immutable GRAPH_TOKEN = keccak256("GraphToken"); | ||
bytes32 immutable GRAPH_TOKEN_GATEWAY = keccak256("GraphTokenGateway"); | ||
|
||
// -- Events -- | ||
|
||
event ParameterUpdated(string param); | ||
|
@@ -50,7 +58,7 @@ contract Managed { | |
} | ||
|
||
function _onlyGovernor() internal view { | ||
require(msg.sender == controller.getGovernor(), "Caller must be Controller governor"); | ||
require(msg.sender == controller.getGovernor(), "Only Controller governor"); | ||
} | ||
|
||
function _onlyController() internal view { | ||
|
@@ -111,47 +119,47 @@ contract Managed { | |
* @return Curation contract registered with Controller | ||
*/ | ||
function curation() internal view returns (ICuration) { | ||
return ICuration(_resolveContract(keccak256("Curation"))); | ||
return ICuration(_resolveContract(CURATION)); | ||
} | ||
|
||
/** | ||
* @dev Return EpochManager interface. | ||
* @return Epoch manager contract registered with Controller | ||
*/ | ||
function epochManager() internal view returns (IEpochManager) { | ||
return IEpochManager(_resolveContract(keccak256("EpochManager"))); | ||
return IEpochManager(_resolveContract(EPOCH_MANAGER)); | ||
} | ||
|
||
/** | ||
* @dev Return RewardsManager interface. | ||
* @return Rewards manager contract registered with Controller | ||
*/ | ||
function rewardsManager() internal view returns (IRewardsManager) { | ||
return IRewardsManager(_resolveContract(keccak256("RewardsManager"))); | ||
return IRewardsManager(_resolveContract(REWARDS_MANAGER)); | ||
} | ||
|
||
/** | ||
* @dev Return Staking interface. | ||
* @return Staking contract registered with Controller | ||
*/ | ||
function staking() internal view returns (IStaking) { | ||
return IStaking(_resolveContract(keccak256("Staking"))); | ||
return IStaking(_resolveContract(STAKING)); | ||
} | ||
|
||
/** | ||
* @dev Return GraphToken interface. | ||
* @return Graph token contract registered with Controller | ||
*/ | ||
function graphToken() internal view returns (IGraphToken) { | ||
return IGraphToken(_resolveContract(keccak256("GraphToken"))); | ||
return IGraphToken(_resolveContract(GRAPH_TOKEN)); | ||
} | ||
|
||
/** | ||
* @dev Return GraphTokenGateway (L1 or L2) interface. | ||
* @return Graph token gateway contract registered with Controller | ||
*/ | ||
function graphTokenGateway() internal view returns (ITokenGateway) { | ||
return ITokenGateway(_resolveContract(keccak256("GraphTokenGateway"))); | ||
return ITokenGateway(_resolveContract(GRAPH_TOKEN_GATEWAY)); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to delay this check after the next line as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, noted to be added in a future PR