Skip to content

Commit

Permalink
Merge pull request #110 from valory-xyz/guard_swap
Browse files Browse the repository at this point in the history
test: swapping the CM guard
  • Loading branch information
mariapiamo authored Jan 19, 2024
2 parents 2922ea2 + b130157 commit d42c4d4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ bd442a4d40914bfc4d062cc5625b5b3d532328d8:scripts/deployment/bridges/polygon/glob
bd442a4d40914bfc4d062cc5625b5b3d532328d8:scripts/deployment/bridges/polygon/globals_polygon_mumbai.json:generic-api-key:2
bd442a4d40914bfc4d062cc5625b5b3d532328d8:scripts/deployment/globals_goerli.json:generic-api-key:1
bd442a4d40914bfc4d062cc5625b5b3d532328d8:scripts/deployment/globals_goerli.json:generic-api-key:2
ad016dbb808b6fa8c8a6a689a7140d68e868414d:scripts/deployment/globals_goerli.json:generic-api-key:1
ad016dbb808b6fa8c8a6a689a7140d68e868414d:scripts/deployment/globals_goerli.json:generic-api-key:2
6 changes: 3 additions & 3 deletions docs/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
{
"name": "GuardCM",
"artifact": "abis/0.8.21/GuardCM.json",
"artifact": "abis/0.8.23/GuardCM.json",
"address": "0x1a0bADb278dE44E261DEC9f4225E3DD761336DA8"
},
{
Expand Down Expand Up @@ -86,8 +86,8 @@
},
{
"name": "GuardCM",
"artifact": "abis/0.8.21/GuardCM.json",
"address": "0x1F4C3134aFB97DE2BfBBF28894d24F58D0A95eFC"
"artifact": "abis/0.8.23/GuardCM.json",
"address": "0xe07949B74bED0dac21BA74B4371155520FE6a560"
},
{
"name": "BridgedERC20",
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment/globals_goerli.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"contractVerification":true,"useLedger":false,"valoryMultisig":"0x87cc0d34f6111c8A7A4Bdf758a9a715A3675f941","derivationPath":"m/44'/60'/2'/0/0","CM":"0x04C06323Fe3D53Deb7364c0055E1F68458Cc2570","providerName":"goerli","olasSaltString":"0x0001a5","timelockMinDelay":"5","veOlasSaltString":"0x7e01a5","initialVotingDelay":"20","initialVotingPeriod":"80","initialProposalThreshold":"1000000000000000000000","quorum":"1","initSupply":"526500000000000000000000000","timelockSupply":"100000000000000000000000000","saleSupply":"301500000000000000000000000","valorySupply":"125000000000000000000000000","GnosisSafe":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","GnosisSafeProxyFactory":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","MultiSendCallOnly":"0x40A2aCCbd92BCA938b02010E17A5b8929b49130D","deploymentFactory":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","olasAddress":"0xEdfc28215B1Eb6eb0be426f1f529cf691A5C2400","timelockAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","veOLASAddress":"0xf8B20e160557c747E8640CdcE77E1dd44bCaAfbB","governorAddress":"0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac","buOLASAddress":"0x397125902ED2cA2d42104F621f448A2cE1bC8Fb7","wveOLASAddress":"0xa2AA89938805836077aB0724f335142da7A27085","governorTwoAddress":"0x63b0f322837a7160B7E3d95C60aAaeB4EF1aECcb","treasuryAddress":"0x7bedCA17D29e53C8062d10902a6219F8d1E3B9B5","guardCMAddress":"0x1F4C3134aFB97DE2BfBBF28894d24F58D0A95eFC","fxRootAddress":"0x3d1d3E34f7fB6D26245E6640E1c50710eFFf15bA","checkpointManagerAddress":"0x2890bA17EfE978480615e330ecB65333b880928e","bridgedERC20Address":"0x0CF8ad7AD779157a253964036af0e95f625EA27c","fxERC20RootTunnelAddress":"0x7E335396a9804097Fd7c04F8b3adc314Ca9398A0","childTokenAddress":"0x93Cd3f6DcE64d67f4420939865A00aC89776D4b5","fxERC20ChildTunnelAddress":"0x5b5C7BA8424e6B48f92Ac02980FFc2531c3196DF"}
{"contractVerification":true,"useLedger":false,"valoryMultisig":"0x87cc0d34f6111c8A7A4Bdf758a9a715A3675f941","derivationPath":"m/44'/60'/2'/0/0","CM":"0x04C06323Fe3D53Deb7364c0055E1F68458Cc2570","providerName":"goerli","olasSaltString":"0x0001a5","timelockMinDelay":"5","veOlasSaltString":"0x7e01a5","initialVotingDelay":"20","initialVotingPeriod":"80","initialProposalThreshold":"1000000000000000000000","quorum":"1","initSupply":"526500000000000000000000000","timelockSupply":"100000000000000000000000000","saleSupply":"301500000000000000000000000","valorySupply":"125000000000000000000000000","GnosisSafe":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","GnosisSafeProxyFactory":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","MultiSendCallOnly":"0x40A2aCCbd92BCA938b02010E17A5b8929b49130D","deploymentFactory":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","olasAddress":"0xEdfc28215B1Eb6eb0be426f1f529cf691A5C2400","timelockAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","veOLASAddress":"0xf8B20e160557c747E8640CdcE77E1dd44bCaAfbB","governorAddress":"0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac","buOLASAddress":"0x397125902ED2cA2d42104F621f448A2cE1bC8Fb7","wveOLASAddress":"0xa2AA89938805836077aB0724f335142da7A27085","governorTwoAddress":"0x63b0f322837a7160B7E3d95C60aAaeB4EF1aECcb","treasuryAddress":"0x7bedCA17D29e53C8062d10902a6219F8d1E3B9B5","guardCMAddress":"0xe07949B74bED0dac21BA74B4371155520FE6a560","fxRootAddress":"0x3d1d3E34f7fB6D26245E6640E1c50710eFFf15bA","checkpointManagerAddress":"0x2890bA17EfE978480615e330ecB65333b880928e","bridgedERC20Address":"0x0CF8ad7AD779157a253964036af0e95f625EA27c","fxERC20RootTunnelAddress":"0x7E335396a9804097Fd7c04F8b3adc314Ca9398A0","childTokenAddress":"0x93Cd3f6DcE64d67f4420939865A00aC89776D4b5","fxERC20ChildTunnelAddress":"0x5b5C7BA8424e6B48f92Ac02980FFc2531c3196DF"}
40 changes: 40 additions & 0 deletions test/GuardCM.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,46 @@ describe("Community Multisig Guard", function () {
safeContracts.executeTx(multisig, txHashData, signMessageData, 0)
).to.be.revertedWithCustomError(guard, "NoDelegateCall");
});

it("Swapping the CM Guard by the Timelock", async function () {
// Add timelock as a module
let nonce = await multisig.nonce();
let txHashData = await safeContracts.buildContractCall(multisig, "enableModule", [timelock.address], nonce, 0, 0);
let signMessageData = new Array();
for (let i = 1; i <= safeThreshold; i++) {
signMessageData.push(await safeContracts.safeSignMessage(signers[i], multisig, txHashData, 0));
}
await safeContracts.executeTx(multisig, txHashData, signMessageData, 0);

// Setting the CM guard to make sure the module can still act on a multisig
nonce = await multisig.nonce();
txHashData = await safeContracts.buildContractCall(multisig, "setGuard", [guard.address], nonce, 0, 0);
signMessageData = new Array();
for (let i = 1; i <= safeThreshold; i++) {
signMessageData.push(await safeContracts.safeSignMessage(signers[i], multisig, txHashData, 0));
}
await safeContracts.executeTx(multisig, txHashData, signMessageData, 0);

// Deploy a new guard
const GuardCM = await ethers.getContractFactory("GuardCM");
const newGuard = await GuardCM.deploy(timelock.address, multisig.address, governor.address);
await newGuard.deployed();

// Construct the payload for the multisig to swap the guard by the Timelock
txHashData = await safeContracts.buildContractCall(multisig, "setGuard", [newGuard.address], nonce, 0, 0);

// Construct the timelock module transaction
const timelockPayload = multisig.interface.encodeFunctionData("execTransactionFromModule", [txHashData.to,
0, txHashData.data, txHashData.operation]);

// Execute the multisend call via the module
await timelock.execute(multisig.address, timelockPayload);

const guardStorageSlot = "0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8";
const curGuard = await ethers.provider.getStorageAt(multisig.address, guardStorageSlot);
const guardAddress = "0x" + curGuard.slice(26);
expect(guardAddress).to.equal(newGuard.address.toLowerCase());
});
});

context("Timelock manipulation via the CM across the bridge", async function () {
Expand Down

0 comments on commit d42c4d4

Please sign in to comment.