Skip to content

Commit 268b7dd

Browse files
Merge branch 'check-recovery-guardians'
2 parents f874e4c + 5d6015a commit 268b7dd

File tree

3 files changed

+23
-73
lines changed

3 files changed

+23
-73
lines changed

contracts/modules/RecoveryManager.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ contract RecoveryManager is BaseModule, RelayerModuleV2 {
195195
function getRequiredSignatures(BaseWallet _wallet, bytes memory _data) public view returns (uint256) {
196196
bytes4 methodId = functionPrefix(_data);
197197
if (methodId == EXECUTE_RECOVERY_PREFIX) {
198-
return SafeMath.ceil(guardianStorage.guardianCount(_wallet), 2);
198+
uint walletGuardians = guardianStorage.guardianCount(_wallet);
199+
require(walletGuardians > 0, "RM: no guardians set on wallet");
200+
return SafeMath.ceil(walletGuardians, 2);
199201
}
200202
if (methodId == FINALIZE_RECOVERY_PREFIX) {
201203
return 0;

deployment/7_upgrade_1_6.js

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
const semver = require("semver");
22
const childProcess = require("child_process");
3-
const ApprovedTransfer = require("../build/ApprovedTransfer");
43
const RecoveryManager = require("../build/RecoveryManager");
54
const MultiSig = require("../build/MultiSigWallet");
65
const ModuleRegistry = require("../build/ModuleRegistry");
76
const Upgrader = require("../build/SimpleUpgrader");
87
const DeployManager = require("../utils/deploy-manager.js");
98
const MultisigExecutor = require("../utils/multisigexecutor.js");
10-
const TokenPriceProvider = require("../build/TokenPriceProvider");
11-
const MakerRegistry = require("../build/MakerRegistry");
12-
const ScdMcdMigration = require("../build/ScdMcdMigration");
13-
const MakerV2Manager = require("../build/MakerV2Manager");
14-
const TransferManager = require("../build/TransferManager");
159

1610
const utils = require("../utils/utilities.js");
1711

1812
const TARGET_VERSION = "1.6.0";
19-
const MODULES_TO_ENABLE = ["ApprovedTransfer", "RecoveryManager", "MakerV2Manager", "TransferManager"];
20-
const MODULES_TO_DISABLE = ["UniswapManager"];
13+
const MODULES_TO_ENABLE = ["RecoveryManager"];
14+
const MODULES_TO_DISABLE = [];
2115

22-
const BACKWARD_COMPATIBILITY = 1;
16+
const BACKWARD_COMPATIBILITY = 2;
2317

2418
const deploy = async (network) => {
2519
if (!["kovan", "kovan-fork", "staging", "prod"].includes(network)) {
@@ -50,33 +44,10 @@ const deploy = async (network) => {
5044
const MultiSigWrapper = await deployer.wrapDeployedContract(MultiSig, config.contracts.MultiSigWallet);
5145
const multisigExecutor = new MultisigExecutor(MultiSigWrapper, deploymentWallet, config.multisig.autosign, { gasPrice });
5246

53-
// //////////////////////////////////
54-
// Deploy infrastructure contracts
55-
// //////////////////////////////////
56-
57-
// Deploy and configure Maker Registry
58-
const ScdMcdMigrationWrapper = await deployer.wrapDeployedContract(ScdMcdMigration, config.defi.maker.migration);
59-
const vatAddress = await ScdMcdMigrationWrapper.vat();
60-
const MakerRegistryWrapper = await deployer.deploy(MakerRegistry, {}, vatAddress);
61-
const wethJoinAddress = await ScdMcdMigrationWrapper.wethJoin();
62-
const addCollateralTransaction = await MakerRegistryWrapper.contract.addCollateral(wethJoinAddress, { gasPrice });
63-
await MakerRegistryWrapper.verboseWaitForTransaction(addCollateralTransaction, `Adding join adapter ${wethJoinAddress} to the MakerRegistry`);
64-
const changeMakerRegistryOwnerTx = await MakerRegistryWrapper.contract.changeOwner(config.contracts.MultiSigWallet, { gasPrice });
65-
await MakerRegistryWrapper.verboseWaitForTransaction(changeMakerRegistryOwnerTx, "Set the MultiSig as the owner of the MakerRegistry");
66-
const TokenPriceProviderWrapper = await deployer.wrapDeployedContract(TokenPriceProvider, config.contracts.TokenPriceProvider);
67-
6847
// //////////////////////////////////
6948
// Deploy new modules
7049
// //////////////////////////////////
7150

72-
const ApprovedTransferWrapper = await deployer.deploy(
73-
ApprovedTransfer,
74-
{},
75-
config.contracts.ModuleRegistry,
76-
config.modules.GuardianStorage,
77-
);
78-
newModuleWrappers.push(ApprovedTransferWrapper);
79-
8051
const RecoveryManagerWrapper = await deployer.deploy(
8152
RecoveryManager,
8253
{},
@@ -89,58 +60,20 @@ const deploy = async (network) => {
8960
);
9061
newModuleWrappers.push(RecoveryManagerWrapper);
9162

92-
const MakerV2ManagerWrapper = await deployer.deploy(
93-
MakerV2Manager,
94-
{},
95-
config.contracts.ModuleRegistry,
96-
config.modules.GuardianStorage,
97-
config.defi.maker.migration,
98-
config.defi.maker.pot,
99-
config.defi.maker.jug,
100-
MakerRegistryWrapper.contractAddress,
101-
config.defi.uniswap.factory,
102-
);
103-
newModuleWrappers.push(MakerV2ManagerWrapper);
104-
105-
const TransferManagerWrapper = await deployer.deploy(
106-
TransferManager,
107-
{},
108-
config.contracts.ModuleRegistry,
109-
config.modules.TransferStorage,
110-
config.modules.GuardianStorage,
111-
TokenPriceProviderWrapper.contractAddress,
112-
config.settings.securityPeriod || 0,
113-
config.settings.securityWindow || 0,
114-
config.settings.defaultLimit || "1000000000000000000",
115-
["test", "staging", "prod"].includes(network) ? config.modules.TransferManager : "0x0000000000000000000000000000000000000000",
116-
);
117-
newModuleWrappers.push(TransferManagerWrapper);
118-
11963
// /////////////////////////////////////////////////
12064
// Update config and Upload ABIs
12165
// /////////////////////////////////////////////////
12266

12367
configurator.updateModuleAddresses({
124-
ApprovedTransfer: ApprovedTransferWrapper.contractAddress,
12568
RecoveryManager: RecoveryManagerWrapper.contractAddress,
126-
MakerV2Manager: MakerV2ManagerWrapper.contractAddress,
127-
TransferManager: TransferManagerWrapper.contractAddress,
128-
});
129-
130-
configurator.updateInfrastructureAddresses({
131-
MakerRegistry: MakerRegistryWrapper.contractAddress,
13269
});
13370

13471
const gitHash = childProcess.execSync("git rev-parse HEAD").toString("utf8").replace(/\n$/, "");
13572
configurator.updateGitHash(gitHash);
13673
await configurator.save();
13774

13875
await Promise.all([
139-
abiUploader.upload(ApprovedTransferWrapper, "modules"),
14076
abiUploader.upload(RecoveryManagerWrapper, "modules"),
141-
abiUploader.upload(MakerV2ManagerWrapper, "modules"),
142-
abiUploader.upload(TransferManagerWrapper, "modules"),
143-
abiUploader.upload(MakerRegistryWrapper, "contracts"),
14477
]);
14578

14679
// //////////////////////////////////
@@ -157,7 +90,6 @@ const deploy = async (network) => {
15790
// Deploy and Register upgraders
15891
// //////////////////////////////////
15992

160-
16193
let fingerprint;
16294
const versions = await versionUploader.load(BACKWARD_COMPATIBILITY);
16395
for (let idx = 0; idx < versions.length; idx += 1) {
@@ -208,7 +140,6 @@ const deploy = async (network) => {
208140
await versionUploader.upload(newVersion);
209141
};
210142

211-
212143
module.exports = {
213144
deploy,
214145
};

test/recoveryManager.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ describe("RecoveryManager", function () {
311311
});
312312

313313
describe("Execute Recovery", () => {
314+
it("should not allow recovery to be executed with no guardians", async () => {
315+
const noGuardians = [];
316+
await assert.revertWith(manager.relay(
317+
recoveryManager,
318+
"executeRecovery",
319+
[wallet.contractAddress, newowner.address],
320+
wallet,
321+
noGuardians,
322+
), "RM: no guardians set on wallet");
323+
324+
const isLocked = await lockManager.isLocked(wallet.contractAddress);
325+
assert.isFalse(isLocked, "should not be locked by recovery");
326+
327+
const walletOwner = await wallet.owner();
328+
assert.equal(walletOwner, owner.address, "owner should have not changed");
329+
});
330+
314331
describe("EOA Guardians: G = 2", () => {
315332
beforeEach(async () => {
316333
await addGuardians([guardian1, guardian2]);

0 commit comments

Comments
 (0)