From 9aebb55bc1f7bf877889cbdd409c615aacab1004 Mon Sep 17 00:00:00 2001 From: Theo Date: Sun, 21 May 2023 20:21:59 +0300 Subject: [PATCH] v4 patch --- contracts/v4-patch/GovernancePatchUpgrade.sol | 33 +++++++++++++++++++ contracts/v4-patch/PatchProposal.sol | 0 2 files changed, 33 insertions(+) create mode 100644 contracts/v4-patch/GovernancePatchUpgrade.sol create mode 100644 contracts/v4-patch/PatchProposal.sol diff --git a/contracts/v4-patch/GovernancePatchUpgrade.sol b/contracts/v4-patch/GovernancePatchUpgrade.sol new file mode 100644 index 0000000..237e30a --- /dev/null +++ b/contracts/v4-patch/GovernancePatchUpgrade.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; + +import "../v1/Governance.sol"; +import "../v3-relayer-registry/GovernanceStakingUpgrade.sol"; + +contract GovernancePatchProposal is GovernanceStakingUpgrade { + mapping(uint256 => bytes32) public _proposalCodeHashes; + + event CodeHashDifferent(address target, bytes32 oldHash, bytes32 newHash); + + function execute(uint256 proposalId) external payable virtual override(Governance) { + Proposal storage proposal = proposals[proposalId]; + + if (proposal.target.codehash == _proposalCodeHashes[proposalId]) { + super.execute(proposalId); + } else { + proposal.executed = true; + emit CodeHashDifferent(proposal.target, _proposalCodeHashes[proposalId], proposal.target.codehash); + } + } + + function _propose( + address proposer, + address target, + string memory description + ) internal virtual override(Governance) { + uint256 proposalId = super._propose(proposer, target, description); + _proposalCodeHashes[proposalId] = target.codeHash; + } +} diff --git a/contracts/v4-patch/PatchProposal.sol b/contracts/v4-patch/PatchProposal.sol new file mode 100644 index 0000000..e69de29