2023-05-27 14:30:29 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
import { MockProposal } from "./MockProposal.sol";
|
|
|
|
import { console2 } from "@forge-std/console2.sol";
|
|
|
|
import { GovernancePatchUpgrade } from "@root/v4-patch/GovernancePatchUpgrade.sol";
|
|
|
|
|
|
|
|
contract TestProxyUpdating is MockProposal {
|
|
|
|
function isContract(address _addr) private view returns (bool) {
|
|
|
|
uint32 size;
|
|
|
|
assembly {
|
|
|
|
size := extcodesize(_addr)
|
|
|
|
}
|
|
|
|
return (size > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAddressFromSlot(address _contract, bytes32 slot) internal view returns (address) {
|
|
|
|
bytes32 slotData = vm.load(_contract, slot);
|
|
|
|
return address(uint256(slotData));
|
|
|
|
}
|
|
|
|
|
|
|
|
function getUpgradeableProxyImplementationAddress(address proxy) internal view returns (address) {
|
2023-05-27 18:29:13 +03:00
|
|
|
bytes32 proxyImplementationSlot =
|
|
|
|
bytes32(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
return getAddressFromSlot(proxy, proxyImplementationSlot);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRelayerRegistryImplementationAddress() internal view returns (address) {
|
|
|
|
return getUpgradeableProxyImplementationAddress(getRelayerRegistryProxyAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStakingImplementationAddress() internal view returns (address) {
|
|
|
|
return getUpgradeableProxyImplementationAddress(getStakingProxyAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGovernanceStakingProxyUpdated() public {
|
|
|
|
address stakingProxyAddressBeforeExecution = getStakingProxyAddress();
|
2023-05-27 18:29:13 +03:00
|
|
|
console2.log(
|
|
|
|
"Staking proxy address before proposal execution: %s", stakingProxyAddressBeforeExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
createAndExecuteProposal();
|
|
|
|
|
|
|
|
address stakingProxyAddressAfterExecution = getStakingProxyAddress();
|
|
|
|
console2.log("Staking proxy address after proposal execution: %s", stakingProxyAddressAfterExecution);
|
|
|
|
|
2023-05-27 18:29:13 +03:00
|
|
|
require(
|
|
|
|
stakingProxyAddressBeforeExecution != stakingProxyAddressAfterExecution,
|
|
|
|
"Staking proxy address didn't changed"
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
require(isContract(stakingProxyAddressAfterExecution));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGovernanceStakingImplementationUpdated() public {
|
|
|
|
address stakingImplementationAddressBeforeExecution = getStakingImplementationAddress();
|
2023-05-27 18:29:13 +03:00
|
|
|
console2.log(
|
|
|
|
"Staking implementation address before proposal execution: %s",
|
|
|
|
stakingImplementationAddressBeforeExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
createAndExecuteProposal();
|
|
|
|
|
|
|
|
address stakingImplementationAddressAfterExecution = getStakingImplementationAddress();
|
2023-05-27 18:29:13 +03:00
|
|
|
console2.log(
|
|
|
|
"Staking implementation address after proposal execution: %s",
|
|
|
|
stakingImplementationAddressAfterExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
require(
|
|
|
|
stakingImplementationAddressBeforeExecution != stakingImplementationAddressAfterExecution,
|
|
|
|
"Staking implementation address didn't changed"
|
|
|
|
);
|
|
|
|
require(isContract(stakingImplementationAddressAfterExecution));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRelayerRegistryImplementationUpdated() public {
|
2023-05-27 18:29:13 +03:00
|
|
|
address relayerRegistryImplementationAddressBeforeExecution =
|
|
|
|
getRelayerRegistryImplementationAddress();
|
2023-05-27 14:30:29 +03:00
|
|
|
console2.log(
|
2023-05-27 18:29:13 +03:00
|
|
|
"Relayer registry implementation address before proposal execution: %s",
|
|
|
|
relayerRegistryImplementationAddressBeforeExecution
|
2023-05-27 14:30:29 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
createAndExecuteProposal();
|
|
|
|
|
|
|
|
address relayerRegistryImplementationAddressAfterExecution = getRelayerRegistryImplementationAddress();
|
|
|
|
console2.log(
|
2023-05-27 18:29:13 +03:00
|
|
|
"Relayer registry implementation address after proposal execution: %s",
|
|
|
|
relayerRegistryImplementationAddressAfterExecution
|
2023-05-27 14:30:29 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
require(
|
2023-05-27 18:29:13 +03:00
|
|
|
relayerRegistryImplementationAddressBeforeExecution
|
|
|
|
!= relayerRegistryImplementationAddressAfterExecution,
|
2023-05-27 14:30:29 +03:00
|
|
|
"Relayer registry implementation address didn't changed"
|
|
|
|
);
|
|
|
|
require(isContract(relayerRegistryImplementationAddressAfterExecution));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGovernanceImplementationUpdated() public {
|
2023-05-27 18:29:13 +03:00
|
|
|
address governanceImplementationAddressBeforeExecution =
|
|
|
|
getUpgradeableProxyImplementationAddress(_governanceAddress);
|
|
|
|
console2.log(
|
|
|
|
"Governance implementation address before proposal execution: %s",
|
|
|
|
governanceImplementationAddressBeforeExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
createAndExecuteProposal();
|
|
|
|
|
2023-05-27 18:29:13 +03:00
|
|
|
address governanceImplementationAddressAfterExecution =
|
|
|
|
getUpgradeableProxyImplementationAddress(_governanceAddress);
|
|
|
|
console2.log(
|
|
|
|
"Governance implementation address after proposal execution: %s",
|
|
|
|
governanceImplementationAddressAfterExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
require(
|
|
|
|
governanceImplementationAddressBeforeExecution != governanceImplementationAddressAfterExecution,
|
|
|
|
"Governance implementation address didn't changed"
|
|
|
|
);
|
|
|
|
require(isContract(governanceImplementationAddressAfterExecution));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRelayerRegistryProxyNotUpdated() public {
|
|
|
|
address relayerRegistryProxyAddressBeforeExecution = getRelayerRegistryProxyAddress();
|
2023-05-27 18:29:13 +03:00
|
|
|
console2.log(
|
|
|
|
"Relayer registry proxy before proposal execution: %s", relayerRegistryProxyAddressBeforeExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
createAndExecuteProposal();
|
|
|
|
|
|
|
|
address relayerRegistryProxyAddressAfterExecution = getRelayerRegistryProxyAddress();
|
2023-05-27 18:29:13 +03:00
|
|
|
console2.log(
|
|
|
|
"Relayer registry proxyafter proposal execution: %s", relayerRegistryProxyAddressAfterExecution
|
|
|
|
);
|
2023-05-27 14:30:29 +03:00
|
|
|
|
|
|
|
require(
|
|
|
|
relayerRegistryProxyAddressBeforeExecution == relayerRegistryProxyAddressAfterExecution,
|
|
|
|
"Relayer registry proxy address changed"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|