2023-05-21 22:51:14 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
pragma solidity ^0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
|
2023-05-26 03:48:44 +03:00
|
|
|
import { LoopbackProxy } from "../v1/LoopbackProxy.sol";
|
|
|
|
import { AdminUpgradeableProxy } from "./proxy/AdminUpgradeableProxy.sol";
|
|
|
|
|
2023-05-21 22:51:14 +03:00
|
|
|
import { GovernancePatchUpgrade } from "./GovernancePatchUpgrade.sol";
|
|
|
|
import { TornadoStakingRewards } from "./TornadoStakingRewards.sol";
|
2023-05-22 04:44:30 +03:00
|
|
|
import { RelayerRegistry } from "./RelayerRegistry.sol";
|
2023-05-21 22:51:14 +03:00
|
|
|
|
2023-05-24 00:41:03 +03:00
|
|
|
/**
|
|
|
|
* @notice Proposal which should patch governance against the metamorphic contract replacement vulnerability.
|
|
|
|
*/
|
2023-05-22 04:44:30 +03:00
|
|
|
contract PatchProposal {
|
2023-05-27 18:12:47 +03:00
|
|
|
// Address of the old staking proxy
|
2023-05-27 18:03:25 +03:00
|
|
|
address public constant oldStakingProxyAddress = 0x2FC93484614a34f26F7970CBB94615bA109BB4bf;
|
2023-05-25 02:59:14 +03:00
|
|
|
|
|
|
|
// Address of the registry proxy
|
|
|
|
address public constant registryProxyAddress = 0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2;
|
2023-05-21 22:51:14 +03:00
|
|
|
|
2023-05-25 02:59:14 +03:00
|
|
|
// Address of the gas compensation vault
|
|
|
|
address public constant gasCompensationVaultAddress = 0xFA4C1f3f7D5dd7c12a9Adb82Cd7dDA542E3d59ef;
|
2023-05-22 04:44:30 +03:00
|
|
|
|
2023-05-27 18:12:47 +03:00
|
|
|
// Address of the user vault
|
2023-05-25 02:59:14 +03:00
|
|
|
address public constant userVaultAddress = 0x2F50508a8a3D323B91336FA3eA6ae50E55f32185;
|
|
|
|
|
|
|
|
// Address of the governance proxy
|
|
|
|
address payable public constant governanceProxyAddress = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce;
|
|
|
|
|
|
|
|
// Torn token
|
2023-05-21 22:51:14 +03:00
|
|
|
IERC20 public constant TORN = IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C);
|
|
|
|
|
2023-05-27 18:12:47 +03:00
|
|
|
// The staking proxy (pointing to a new implementation (with same code)) that we've deployed
|
2023-05-27 18:01:23 +03:00
|
|
|
address public immutable deployedStakingProxyContractAddress;
|
2023-05-27 18:12:47 +03:00
|
|
|
|
|
|
|
// The registry implementation (with same code) that we've deployed
|
2023-05-25 02:59:14 +03:00
|
|
|
address public immutable deployedRelayerRegistryImplementationAddress;
|
2023-05-21 22:51:14 +03:00
|
|
|
|
2023-05-27 18:01:23 +03:00
|
|
|
constructor(
|
|
|
|
address _deployedStakingProxyContractAddress,
|
|
|
|
address _deployedRelayerRegistryImplementationAddress
|
|
|
|
) public {
|
|
|
|
deployedStakingProxyContractAddress = _deployedStakingProxyContractAddress;
|
2023-05-25 02:59:14 +03:00
|
|
|
deployedRelayerRegistryImplementationAddress = _deployedRelayerRegistryImplementationAddress;
|
2023-05-21 22:51:14 +03:00
|
|
|
}
|
|
|
|
|
2023-05-24 00:41:03 +03:00
|
|
|
/// @notice Function to execute the proposal.
|
2023-05-21 22:51:14 +03:00
|
|
|
function executeProposal() external {
|
|
|
|
// Get the old staking contract
|
2023-05-27 18:03:25 +03:00
|
|
|
TornadoStakingRewards oldStaking = TornadoStakingRewards(oldStakingProxyAddress);
|
2023-05-21 22:51:14 +03:00
|
|
|
|
2023-05-22 04:44:30 +03:00
|
|
|
// Get the small amount of TORN left
|
2023-05-21 22:51:14 +03:00
|
|
|
oldStaking.withdrawTorn(TORN.balanceOf(address(oldStaking)));
|
|
|
|
|
2023-05-22 04:44:30 +03:00
|
|
|
// Upgrade the registry proxy
|
2023-05-27 18:01:23 +03:00
|
|
|
AdminUpgradeableProxy(payable(registryProxyAddress)).upgradeTo(
|
|
|
|
deployedRelayerRegistryImplementationAddress
|
|
|
|
);
|
2023-05-21 22:51:14 +03:00
|
|
|
|
2023-05-27 18:03:25 +03:00
|
|
|
// Now upgrade the governance implementation to the vulnerability resistant one
|
2023-05-25 02:59:14 +03:00
|
|
|
LoopbackProxy(governanceProxyAddress).upgradeTo(
|
2023-05-27 18:01:23 +03:00
|
|
|
address(
|
|
|
|
new GovernancePatchUpgrade(
|
|
|
|
deployedStakingProxyContractAddress,
|
|
|
|
gasCompensationVaultAddress,
|
|
|
|
userVaultAddress
|
|
|
|
)
|
|
|
|
)
|
2023-05-25 02:59:14 +03:00
|
|
|
);
|
2023-05-27 16:14:05 +03:00
|
|
|
|
|
|
|
// Transfer TORN in compensation to the staking proxy
|
2023-05-27 18:01:23 +03:00
|
|
|
TORN.transfer(deployedStakingProxyContractAddress, 94_092 ether);
|
2023-05-21 22:51:14 +03:00
|
|
|
}
|
|
|
|
}
|