scope require comment, natspec, update diffs (no change)

Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
AlienTornadosaurusHex 2023-05-23 21:41:03 +00:00
parent dfbd1be6ab
commit 75cf27d7d4
6 changed files with 39 additions and 19 deletions

View File

@ -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,

View File

@ -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));

View File

@ -89,8 +89,3 @@
---
> staking = TornadoStakingRewards(_staking);
> feeManager = IFeeManager(_feeManager);
324c384
< }
\ No newline at end of file
---
> }

View File

@ -21,8 +21,3 @@
< relayerRegistry = resolve(_relayerRegistry);
---
> relayerRegistry = _relayerRegistry;
133c143
< }
\ No newline at end of file
---
> }

View File

@ -321,4 +321,4 @@ contract RelayerRegistry is Initializable, EnsResolve {
function getRelayerBalance(address relayer) external view returns (uint256) {
return relayers[workers[relayer]].balance;
}
}
}

View File

@ -130,4 +130,4 @@ contract TornadoStakingRewards is Initializable, EnsResolve {
rewards = (accumulatedRewardPerTorn.sub(accumulatedRewardRateOnLastUpdate[account])).mul(amountLocked).div(ratioConstant);
rewards = rewards.add(accumulatedRewards[account]);
}
}
}