Skip to content

Commit 3d98334

Browse files
author
justin j. moses
authored
SIP-109 Additional update access control as batch (Synthetixio#1072)
1 parent 5305bb2 commit 3d98334

File tree

4 files changed

+1076
-882
lines changed

4 files changed

+1076
-882
lines changed

contracts/SystemStatus.sol

+18-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ contract SystemStatus is Owned, ISystemStatus {
2727

2828
mapping(bytes32 => Suspension) public synthSuspension;
2929

30-
constructor(address _owner) public Owned(_owner) {
31-
_internalUpdateAccessControl(SECTION_SYSTEM, _owner, true, true);
32-
_internalUpdateAccessControl(SECTION_ISSUANCE, _owner, true, true);
33-
_internalUpdateAccessControl(SECTION_EXCHANGE, _owner, true, true);
34-
_internalUpdateAccessControl(SECTION_SYNTH_EXCHANGE, _owner, true, true);
35-
_internalUpdateAccessControl(SECTION_SYNTH, _owner, true, true);
36-
}
30+
constructor(address _owner) public Owned(_owner) {}
3731

3832
/* ========== VIEWS ========== */
3933
function requireSystemActive() external view {
@@ -133,6 +127,23 @@ contract SystemStatus is Owned, ISystemStatus {
133127
_internalUpdateAccessControl(section, account, canSuspend, canResume);
134128
}
135129

130+
function updateAccessControls(
131+
bytes32[] calldata sections,
132+
address[] calldata accounts,
133+
bool[] calldata canSuspends,
134+
bool[] calldata canResumes
135+
) external onlyOwner {
136+
require(
137+
sections.length == accounts.length &&
138+
accounts.length == canSuspends.length &&
139+
canSuspends.length == canResumes.length,
140+
"Input array lengths must match"
141+
);
142+
for (uint i = 0; i < sections.length; i++) {
143+
_internalUpdateAccessControl(sections[i], accounts[i], canSuspends[i], canResumes[i]);
144+
}
145+
}
146+
136147
function suspendSystem(uint256 reason) external {
137148
_requireAccessToSuspend(SECTION_SYSTEM);
138149
systemSuspension.suspended = true;

publish/src/commands/deploy.js

+18
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,24 @@ const deploy = async ({
534534
args: [account],
535535
});
536536

537+
if (network !== 'mainnet' && systemStatus) {
538+
// On testnet, give the deployer the rights to update status
539+
await runStep({
540+
contract: 'SystemStatus',
541+
target: systemStatus,
542+
read: 'accessControl',
543+
readArg: [toBytes32('System'), account],
544+
expected: ({ canSuspend } = {}) => canSuspend,
545+
write: 'updateAccessControls',
546+
writeArg: [
547+
['System', 'Issuance', 'Exchange', 'SynthExchange', 'Synth'].map(toBytes32),
548+
[account, account, account, account, account],
549+
[true, true, true, true, true],
550+
[true, true, true, true, true],
551+
],
552+
});
553+
}
554+
537555
const exchangeRates = await deployer.deployContract({
538556
name: 'ExchangeRates',
539557
source: useOvm ? 'ExchangeRatesWithoutInvPricing' : 'ExchangeRates',

0 commit comments

Comments
 (0)