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