diff --git a/contracts/v4-patch/GovernancePatchUpgrade.sol b/contracts/v4-patch/GovernancePatchUpgrade.sol index 27dd8d6..02ec8c6 100644 --- a/contracts/v4-patch/GovernancePatchUpgrade.sol +++ b/contracts/v4-patch/GovernancePatchUpgrade.sol @@ -9,20 +9,24 @@ import "../v3-relayer-registry/GovernanceStakingUpgrade.sol"; contract GovernancePatchUpgrade is GovernanceStakingUpgrade { mapping(uint256 => bytes32) public proposalCodehashes; - // The stakingRewardsAddress sets the immutable to the new staking contract constructor( address stakingRewardsAddress, address gasCompLogic, address userVaultAddress ) public GovernanceStakingUpgrade(stakingRewardsAddress, gasCompLogic, userVaultAddress) {} + /// @notice Return the version of the contract function version() external pure virtual override returns (string memory) { return "4.patch-exploit"; } - // This should guarantee that the proposal extcodehashes are good + /** + * @notice Execute a proposal + * @dev This upgrade should protect against Metamorphic contracts by comparing the proposal's extcodehash with a stored one + * @param proposalId The proposal's ID + */ function execute(uint256 proposalId) public payable virtual override(Governance) { - require(msg.sender != address(this), "pseudo-external function"); + require(msg.sender != address(this), "Governance::propose: pseudo-external function"); Proposal storage proposal = proposals[proposalId]; @@ -39,7 +43,14 @@ contract GovernancePatchUpgrade is GovernanceStakingUpgrade { super.execute(proposalId); } - // This should store the proposal extcodehash + /** + * @notice Internal function called from propoese + * @dev This should store the extcodehash of the proposal contract + * @param proposer proposer address + * @param target smart contact address that will be executed as result of voting + * @param description description of the proposal + * @return proposalId new proposal id + */ function _propose( address proposer, address target, diff --git a/contracts/v4-patch/PatchProposal.sol b/contracts/v4-patch/PatchProposal.sol index f260d7b..2ca254d 100644 --- a/contracts/v4-patch/PatchProposal.sol +++ b/contracts/v4-patch/PatchProposal.sol @@ -16,9 +16,17 @@ interface Proxy { function upgradeTo(address newImplementation) external; } -// We will have to do this because of the contract size limit - +/** + * @notice Contract which should help the proposal deploy the necessary contracts. + */ contract PatchProposalContractsFactory { + /** + * @notice Create a new TornadoStakingRewards contract. + * @param governance The address of Tornado Cash Goveranance. + * @param torn The torn token address. + * @param registry The address of the relayer registry. + * @return The address of the new staking contract. + */ function createStakingRewards( address governance, address torn, @@ -27,6 +35,14 @@ contract PatchProposalContractsFactory { return address(new TornadoStakingRewards(governance, torn, registry)); } + /** + * @notice Create a new RelayerRegistry contract. + * @param torn The torn token address. + * @param governance The address of Tornado Cash Goveranance. + * @param ens The ens registrar address. + * @param staking The TornadoStakingRewards contract address. + * @return The address of the new registry contract. + */ function createRegistryContract( address torn, address governance, @@ -38,6 +54,9 @@ contract PatchProposalContractsFactory { } } +/** + * @notice Proposal which should patch governance against the metamorphic contract replacement vulnerability. + */ contract PatchProposal { using SafeMath for uint256; using Address for address; @@ -54,7 +73,7 @@ contract PatchProposal { patchProposalContractsFactory = PatchProposalContractsFactory(_patchProposalContractsFactory); } - // Aight lets do this sirs + /// @notice Function to execute the proposal. function executeProposal() external { // address(this) has to be governance address payable governance = payable(address(this)); diff --git a/diffs/RelayerRegistry.diff b/diffs/RelayerRegistry.diff index 9164627..d7e0a27 100644 --- a/diffs/RelayerRegistry.diff +++ b/diffs/RelayerRegistry.diff @@ -89,8 +89,3 @@ --- > staking = TornadoStakingRewards(_staking); > feeManager = IFeeManager(_feeManager); -324c384 -< } -\ No newline at end of file ---- -> } diff --git a/diffs/TornadoStakingRewards.diff b/diffs/TornadoStakingRewards.diff index 21e424b..f3a5c05 100644 --- a/diffs/TornadoStakingRewards.diff +++ b/diffs/TornadoStakingRewards.diff @@ -21,8 +21,3 @@ < relayerRegistry = resolve(_relayerRegistry); --- > relayerRegistry = _relayerRegistry; -133c143 -< } -\ No newline at end of file ---- -> } diff --git a/diffs/contracts/RelayerRegistry.sol b/diffs/contracts/RelayerRegistry.sol index 3f504b9..f8e851f 100644 --- a/diffs/contracts/RelayerRegistry.sol +++ b/diffs/contracts/RelayerRegistry.sol @@ -321,4 +321,4 @@ contract RelayerRegistry is Initializable, EnsResolve { function getRelayerBalance(address relayer) external view returns (uint256) { return relayers[workers[relayer]].balance; } -} \ No newline at end of file +} diff --git a/diffs/contracts/TornadoStakingRewards.sol b/diffs/contracts/TornadoStakingRewards.sol index c48935b..36a0f9f 100644 --- a/diffs/contracts/TornadoStakingRewards.sol +++ b/diffs/contracts/TornadoStakingRewards.sol @@ -130,4 +130,4 @@ contract TornadoStakingRewards is Initializable, EnsResolve { rewards = (accumulatedRewardPerTorn.sub(accumulatedRewardRateOnLastUpdate[account])).mul(amountLocked).div(ratioConstant); rewards = rewards.add(accumulatedRewards[account]); } -} \ No newline at end of file +}