Skip to content

Commit 9caca24

Browse files
author
justin j. moses
authored
SIP-44 and SIP-46 audit remediations (Synthetixio#476)
1 parent cffec48 commit 9caca24

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

contracts/FeePool.sol

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import "./FeePoolState.sol";
1717
import "./FeePoolEternalStorage.sol";
1818
import "./DelegateApprovals.sol";
1919

20+
2021
// https://docs.synthetix.io/contracts/FeePool
2122
contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
2223
using SafeMath for uint;
@@ -79,6 +80,7 @@ contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
7980
bytes32 private constant CONTRACT_SYNTHETIXSTATE = "SynthetixState";
8081
bytes32 private constant CONTRACT_REWARDESCROW = "RewardEscrow";
8182
bytes32 private constant CONTRACT_DELEGATEAPPROVALS = "DelegateApprovals";
83+
bytes32 private constant CONTRACT_REWARDSDISTRIBUTION = "RewardsDistribution";
8284

8385
bytes32[24] private addressesToCache = [
8486
CONTRACT_SYSTEMSTATUS,
@@ -90,7 +92,8 @@ contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
9092
CONTRACT_ISSUER,
9193
CONTRACT_SYNTHETIXSTATE,
9294
CONTRACT_REWARDESCROW,
93-
CONTRACT_DELEGATEAPPROVALS
95+
CONTRACT_DELEGATEAPPROVALS,
96+
CONTRACT_REWARDSDISTRIBUTION
9497
];
9598

9699
/* ========== ETERNAL STORAGE CONSTANTS ========== */
@@ -155,6 +158,11 @@ contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
155158
return DelegateApprovals(requireAndGetAddress(CONTRACT_DELEGATEAPPROVALS, "Missing DelegateApprovals address"));
156159
}
157160

161+
function rewardsDistribution() internal view returns (IRewardsDistribution) {
162+
return
163+
IRewardsDistribution(requireAndGetAddress(CONTRACT_REWARDSDISTRIBUTION, "Missing RewardsDistribution address"));
164+
}
165+
158166
function recentFeePeriods(uint index)
159167
external
160168
view
@@ -245,7 +253,7 @@ contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
245253
* @notice The RewardsDistribution contract informs us how many SNX rewards are sent to RewardEscrow to be claimed.
246254
*/
247255
function setRewardsToDistribute(uint amount) external {
248-
address rewardsAuthority = resolver.getAddress("RewardsDistribution");
256+
address rewardsAuthority = rewardsDistribution();
249257
require(messageSender == rewardsAuthority || msg.sender == rewardsAuthority, "Caller is not rewardsAuthority");
250258
// Add the amount of SNX rewards to distribute on top of any rolling unclaimed amount
251259
_recentFeePeriodsStorage(0).rewardsToDistribute = _recentFeePeriodsStorage(0).rewardsToDistribute.add(amount);
@@ -539,7 +547,6 @@ contract FeePool is Proxyable, SelfDestructible, LimitedSetup, MixinResolver {
539547
// return _value;
540548
// }
541549
// return fee;
542-
543550
}
544551

545552
/**

contracts/MixinResolver.sol

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ contract MixinResolver is Owned {
1414

1515
uint public constant MAX_ADDRESSES_FROM_RESOLVER = 24;
1616

17-
constructor(address _owner, address _resolver, bytes32[24] _addressesToCache) public Owned(_owner) {
17+
constructor(address _owner, address _resolver, bytes32[MAX_ADDRESSES_FROM_RESOLVER] _addressesToCache)
18+
public
19+
Owned(_owner)
20+
{
1821
for (uint i = 0; i < _addressesToCache.length; i++) {
1922
if (_addressesToCache[i] != bytes32(0)) {
2023
resolverAddressesRequired.push(_addressesToCache[i]);
24+
} else {
25+
// End early once an empty item is found - assumes there are no empty slots in
26+
// _addressesToCache
27+
break;
2128
}
2229
}
2330
resolver = AddressResolver(_resolver);
@@ -70,7 +77,7 @@ contract MixinResolver is Owned {
7077
}
7178

7279
/* ========== INTERNAL FUNCTIONS ========== */
73-
function updateAddressCache(bytes32 name) internal {
80+
function appendToAddressCache(bytes32 name) internal {
7481
resolverAddressesRequired.push(name);
7582
require(resolverAddressesRequired.length < MAX_ADDRESSES_FROM_RESOLVER, "Max resolver cache size met");
7683
// Because this is designed to be called internally in constructors, we don't

contracts/MultiCollateralSynth.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract MultiCollateralSynth is Synth {
2222
) public Synth(_proxy, _tokenState, _tokenName, _tokenSymbol, _owner, _currencyKey, _totalSupply, _resolver) {
2323
multiCollateralKey = _multiCollateralKey;
2424

25-
updateAddressCache(multiCollateralKey);
25+
appendToAddressCache(multiCollateralKey);
2626
}
2727

2828
/* ========== VIEWS ======================= */

contracts/PurgeableSynth.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ contract PurgeableSynth is Synth {
2727
uint _totalSupply,
2828
address _resolver
2929
) public Synth(_proxy, _tokenState, _tokenName, _tokenSymbol, _owner, _currencyKey, _totalSupply, _resolver) {
30-
updateAddressCache(CONTRACT_EXRATES);
30+
appendToAddressCache(CONTRACT_EXRATES);
3131
}
3232

3333
/* ========== VIEWS ========== */

contracts/Synth.sol

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "./interfaces/IExchanger.sol";
88
import "./interfaces/IIssuer.sol";
99
import "./MixinResolver.sol";
1010

11+
1112
// https://docs.synthetix.io/contracts/Synth
1213
contract Synth is ExternStateToken, MixinResolver {
1314
/* ========== STATE VARIABLES ========== */

contracts/SystemStatus.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pragma solidity 0.4.25;
22

33
import "./Owned.sol";
44

5+
56
// https://docs.synthetix.io/contracts/SystemStatus
67
contract SystemStatus is Owned {
78
struct Status {
@@ -151,7 +152,7 @@ contract SystemStatus is Owned {
151152
delete synthSuspension[currencyKey];
152153
}
153154

154-
/* ========== INTERNL FUNCTIONS ========== */
155+
/* ========== INTERNAL FUNCTIONS ========== */
155156

156157
function _requireAccessToSuspend(bytes32 section) internal view {
157158
require(accessControl[section][msg.sender].canSuspend, "Restricted to access control list");

0 commit comments

Comments
 (0)