Skip to content

Commit 141850d

Browse files
authored
Merge pull request #338 from rsksmart/feat-GBI-2702-tenderly
feat: Multisig migration tenderly test | GBI-2702
2 parents 0b55744 + d00cabb commit 141850d

4 files changed

Lines changed: 132 additions & 2 deletions

File tree

addresses.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@
4646
"deployed": false
4747
}
4848
},
49+
"tenderly": {
50+
"SignatureValidator": {
51+
"address": "0xb107cc96A5CfC4Be502e9BBB1208dE4792044ba7",
52+
"deployed": true
53+
},
54+
"Quotes": {
55+
"address": "0xecfF1feFa8814c980330ca1000B067BBC9D2ee25",
56+
"deployed": true
57+
},
58+
"BtcUtils": {
59+
"address": "0x48841b09CD720355F8EE5164DEeFbB30535d825a",
60+
"deployed": true
61+
},
62+
"LiquidityBridgeContract": {
63+
"address": "0xAA9cAf1e3967600578727F975F283446A3Da6612",
64+
"deployed": true
65+
},
66+
"Migrations": {
67+
"address": "0x22183DB087d1Fed621435d00aa9cac4B5CdC9aE1",
68+
"deployed": true
69+
},
70+
"QuotesV2": {
71+
"address": "0x0123eF8Ae46F9FCBF67c706f73d46bCCE3df44F7",
72+
"deployed": true
73+
}
74+
},
4975
"rskMainnet": {
5076
"SignatureValidator": {
5177
"address": "0xb107cc96A5CfC4Be502e9BBB1208dE4792044ba7",

e2e/multisig-migration.test.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
LiquidityBridgeContractV2,
1212
} from "../typechain-types";
1313
import { deployUpgradeLibraries } from "../scripts/deployment-utils/upgrade-proxy";
14+
import hre from "hardhat";
1415

1516
type MultisigInfo = Record<
1617
string,
@@ -50,6 +51,12 @@ describe("Should change LBC owner to the multisig.ts", function () {
5051
await helpers.impersonateAccount(lbcOwner);
5152
const impersonatedSigner = await ethers.getSigner(lbcOwner);
5253

54+
const desiredBalance = ethers.toQuantity(ethers.parseEther("100"));
55+
await ethers.provider.send("hardhat_setBalance", [
56+
impersonatedSigner.address,
57+
desiredBalance,
58+
]);
59+
5360
await expect(
5461
changeMultisigOwner(safeAddress, networkName, impersonatedSigner)
5562
).to.not.be.reverted;
@@ -107,6 +114,82 @@ describe("Should change LBC owner to the multisig.ts", function () {
107114
);
108115
await expect(newLbc.version()).to.eventually.be.equal("1.3.0");
109116
});
117+
118+
it("Should change the owner using Tenderly", async () => {
119+
await checkForkedNetwork();
120+
const deploymentNetwork = hre.network.name;
121+
const multisigAddress = multsigInfo[deploymentNetwork].address;
122+
if (!multisigAddress || multisigAddress === "")
123+
throw new Error("Multisig address not found for current network");
124+
125+
// Get the current owner of LiquidityBridgeContract
126+
const deploymentData = read()[deploymentNetwork];
127+
const proxyAddress = deploymentData.LiquidityBridgeContract.address;
128+
if (!proxyAddress)
129+
throw new Error(
130+
`LiquidityBridgeContract address not found on network ${deploymentNetwork}`
131+
);
132+
133+
const contract = await ethers.getContractAt(
134+
"LiquidityBridgeContractV2",
135+
proxyAddress
136+
);
137+
const currentOwner = await contract.owner();
138+
console.info(`Current owner: ${currentOwner}`);
139+
140+
// Impersonate the current owner account
141+
await helpers.impersonateAccount(currentOwner);
142+
const impersonatedSigner = await ethers.getSigner(currentOwner);
143+
144+
// Set balance for the impersonated account
145+
const desiredBalance = ethers.toQuantity(ethers.parseEther("100"));
146+
await ethers.provider.send("hardhat_setBalance", [
147+
impersonatedSigner.address,
148+
desiredBalance,
149+
]);
150+
151+
console.info(`Impersonated account: ${impersonatedSigner.address}`);
152+
153+
// Call changeMultisigOwner and ensure the Promise is fulfilled
154+
await expect(
155+
changeMultisigOwner(
156+
multisigAddress,
157+
deploymentNetwork,
158+
impersonatedSigner
159+
)
160+
).to.eventually.be.fulfilled;
161+
162+
const newOwner = await contract.owner();
163+
console.info(`New owner: ${newOwner}`);
164+
165+
// Verify ownership change
166+
expect(newOwner.toLowerCase()).to.equal(multisigAddress.toLowerCase());
167+
168+
// Verify old owner can no longer perform owner functions
169+
const adminAddress = await upgrades.erc1967.getAdminAddress(proxyAddress);
170+
171+
// Get the ProxyAdmin contract instance
172+
const proxyAdminContract = await ethers.getContractAt(
173+
"LiquidityBridgeContractAdmin",
174+
adminAddress
175+
);
176+
177+
// Attempt an upgrade with the former owner to ensure permissions were revoked
178+
const adminContract = proxyAdminContract.connect(impersonatedSigner);
179+
await expect(
180+
adminContract.upgrade(proxyAddress, multisigAddress)
181+
).to.be.revertedWith("Ownable: caller is not the owner");
182+
183+
// Verify the ProxyAdmin owner was also updated
184+
const proxyAdminOwner = await proxyAdminContract.owner();
185+
expect(proxyAdminOwner.toLowerCase()).to.equal(
186+
multisigAddress.toLowerCase()
187+
);
188+
189+
console.info(
190+
`Ownership of LiquidityBridgeContract proxy changed to multisig in ${deploymentNetwork}`
191+
);
192+
});
110193
});
111194

112195
async function checkForkedNetwork() {

hardhat.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ const config: HardhatUserConfig = {
5454
chainId: 30,
5555
accounts: getAccounts("mainnet"),
5656
},
57+
...(process.env.FORK_NETWORK_URL && {
58+
tenderly: {
59+
url: process.env.FORK_NETWORK_URL,
60+
chainId: 30,
61+
timeout: rpcDefaultTimeout,
62+
},
63+
}),
5764
hardhat: {
5865
...(forkEnabled
5966
? {

multisig-owners.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,22 @@
2020
]
2121
},
2222
"rskMainnet": {
23-
"address": "",
24-
"owners": []
23+
"address": "0x633d1233ed6251108b61a8365ceed271bf3e3c9b",
24+
"owners": [
25+
"0xd50c4c5577229c81b19fe1c7d413c2d79ccf7901",
26+
"0x15105d3e5f7752f0f7ea0e7b1f3b113701080355",
27+
"0xa420af120ec6515870b65e811fa7ce147d491402",
28+
"0xa3fd0eedca5ba7504e19b7e0660f21d25fefe77f"
29+
]
30+
},
31+
"tenderly": {
32+
"address": "0x633d1233ed6251108b61a8365ceed271bf3e3c9b",
33+
"owners": [
34+
"0xd50c4c5577229c81b19fe1c7d413c2d79ccf7901",
35+
"0x15105d3e5f7752f0f7ea0e7b1f3b113701080355",
36+
"0xa420af120ec6515870b65e811fa7ce147d491402",
37+
"0xa3fd0eedca5ba7504e19b7e0660f21d25fefe77f"
38+
]
2539
},
2640
"hardhat": {
2741
"address": "",

0 commit comments

Comments
 (0)