diff --git a/README.md b/README.md index bdb431d..6ebcf62 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The contracts can be currently found here: * [GovernancePatchUpgrade](./contracts/v4-patch/GovernancePatchUpgrade.sol) * [PatchProposal](./contracts/v4-patch/PatchProposal.sol) -Inlined version of the `RelayerRegistry` and `TornadoStakingRewards` are also used. Check the `diffs` folder to see how much they deviate from the `relayer-registry` repository reconstruction. VSC will possibly show red as "added". +Inlined version of the `RelayerRegistry` and `TornadoStakingRewards` are also used. Check the `diffs` folder to see how much they deviate from the `relayer-registry` repository reconstruction. For testing resistance against metamorphic contracts, we use the contracts provided by: https://github.com/0age/metamorphic.git diff --git a/diffs/RelayerRegistry.diff b/diffs/RelayerRegistry.diff index d42c956..9164627 100644 --- a/diffs/RelayerRegistry.diff +++ b/diffs/RelayerRegistry.diff @@ -1,96 +1,96 @@ -10a11 -> import { ENSNamehash } from "./utils/ENSNamehash.sol"; -12c13,14 -< import { TornadoStakingRewards } from "./TornadoStakingRewards.sol"; +11d10 +< import { ENSNamehash } from "./utils/ENSNamehash.sol"; +13,14c12 +< import { TornadoStakingRewards } from "./staking/TornadoStakingRewards.sol"; +< import { IENS } from "./interfaces/IENS.sol"; --- -> import { TornadoStakingRewards } from "./staking/TornadoStakingRewards.sol"; -> import { IENS } from "./interfaces/IENS.sol"; -14,77c16,17 -< interface ITornadoInstance { -< function token() external view returns (address); -< -< function denomination() external view returns (uint256); -< -< function deposit(bytes32 commitment) external payable; -< -< function withdraw( -< bytes calldata proof, -< bytes32 root, -< bytes32 nullifierHash, -< address payable recipient, -< address payable relayer, -< uint256 fee, -< uint256 refund -< ) external payable; -< } -< -< interface IENS { -< function owner(bytes32 node) external view returns (address); -< } -< -< /* -< * @dev Solidity implementation of the ENS namehash algorithm. -< * -< * Warning! Does not normalize or validate names before hashing. -< * Original version can be found here https://github.com/JonahGroendal/ens-namehash/ -< */ -< library ENSNamehash { -< function namehash(bytes memory domain) internal pure returns (bytes32) { -< return namehash(domain, 0); -< } -< -< function namehash(bytes memory domain, uint256 i) internal pure returns (bytes32) { -< if (domain.length <= i) return 0x0000000000000000000000000000000000000000000000000000000000000000; -< -< uint256 len = labelLength(domain, i); -< -< return keccak256(abi.encodePacked(namehash(domain, i + len + 1), keccak(domain, i, len))); -< } -< -< function labelLength(bytes memory domain, uint256 i) private pure returns (uint256) { -< uint256 len; -< while (i + len != domain.length && domain[i + len] != 0x2e) { -< len++; -< } -< return len; -< } -< -< function keccak( -< bytes memory data, -< uint256 offset, -< uint256 len -< ) private pure returns (bytes32 ret) { -< require(offset + len <= data.length); -< assembly { -< ret := keccak256(add(add(data, 32), offset), len) -< } -< } -< } -< -< interface IFeeManager { -< function instanceFeeWithUpdate(ITornadoInstance _instance) external returns (uint160); -< } +> import { TornadoStakingRewards } from "./TornadoStakingRewards.sol"; +16,17c14,77 +< import "./tornado-proxy/TornadoRouter.sol"; +< import "./tornado-proxy/FeeManager.sol"; --- -> import "./tornado-proxy/TornadoRouter.sol"; -> import "./tornado-proxy/FeeManager.sol"; -106c46 -< IFeeManager public immutable feeManager; +> interface ITornadoInstance { +> function token() external view returns (address); +> +> function denomination() external view returns (uint256); +> +> function deposit(bytes32 commitment) external payable; +> +> function withdraw( +> bytes calldata proof, +> bytes32 root, +> bytes32 nullifierHash, +> address payable recipient, +> address payable relayer, +> uint256 fee, +> uint256 refund +> ) external payable; +> } +> +> interface IENS { +> function owner(bytes32 node) external view returns (address); +> } +> +> /* +> * @dev Solidity implementation of the ENS namehash algorithm. +> * +> * Warning! Does not normalize or validate names before hashing. +> * Original version can be found here https://github.com/JonahGroendal/ens-namehash/ +> */ +> library ENSNamehash { +> function namehash(bytes memory domain) internal pure returns (bytes32) { +> return namehash(domain, 0); +> } +> +> function namehash(bytes memory domain, uint256 i) internal pure returns (bytes32) { +> if (domain.length <= i) return 0x0000000000000000000000000000000000000000000000000000000000000000; +> +> uint256 len = labelLength(domain, i); +> +> return keccak256(abi.encodePacked(namehash(domain, i + len + 1), keccak(domain, i, len))); +> } +> +> function labelLength(bytes memory domain, uint256 i) private pure returns (uint256) { +> uint256 len; +> while (i + len != domain.length && domain[i + len] != 0x2e) { +> len++; +> } +> return len; +> } +> +> function keccak( +> bytes memory data, +> uint256 offset, +> uint256 len +> ) private pure returns (bytes32 ret) { +> require(offset + len <= data.length); +> assembly { +> ret := keccak256(add(add(data, 32), offset), len) +> } +> } +> } +> +> interface IFeeManager { +> function instanceFeeWithUpdate(ITornadoInstance _instance) external returns (uint160); +> } +46c106 +< FeeManager public immutable feeManager; --- -> FeeManager public immutable feeManager; -142,143c82,83 -< address _staking, -< address _feeManager +> IFeeManager public immutable feeManager; +82,83c142,143 +< bytes32 _staking, +< bytes32 _feeManager --- -> bytes32 _staking, -> bytes32 _feeManager -148,149c88,89 -< staking = TornadoStakingRewards(_staking); -< feeManager = IFeeManager(_feeManager); +> address _staking, +> address _feeManager +88,89c148,149 +< staking = TornadoStakingRewards(resolve(_staking)); +< feeManager = FeeManager(resolve(_feeManager)); --- -> staking = TornadoStakingRewards(resolve(_staking)); -> feeManager = FeeManager(resolve(_feeManager)); -384c324 +> staking = TornadoStakingRewards(_staking); +> feeManager = IFeeManager(_feeManager); +324c384 < } +\ No newline at end of file --- > } -\ No newline at end of file diff --git a/diffs/TornadoStakingRewards.diff b/diffs/TornadoStakingRewards.diff index 8f9bb17..21e424b 100644 --- a/diffs/TornadoStakingRewards.diff +++ b/diffs/TornadoStakingRewards.diff @@ -1,28 +1,28 @@ -11,20c11 -< -< interface ITornadoVault { -< function withdrawTorn(address recipient, uint256 amount) external; -< } -< -< interface ITornadoGovernance { -< function lockedBalance(address account) external view returns (uint256); -< -< function userVault() external view returns (ITornadoVault); -< } +11c11,20 +< import { ITornadoGovernance } from "../interfaces/ITornadoGovernance.sol"; --- -> import { ITornadoGovernance } from "../interfaces/ITornadoGovernance.sol"; -54d44 -< // Minor code change here we won't resolve the registry by ENS -58c48 -< address _relayerRegistry +> +> interface ITornadoVault { +> function withdrawTorn(address recipient, uint256 amount) external; +> } +> +> interface ITornadoGovernance { +> function lockedBalance(address account) external view returns (uint256); +> +> function userVault() external view returns (ITornadoVault); +> } +44a54 +> // Minor code change here we won't resolve the registry by ENS +48c58 +< bytes32 _relayerRegistry --- -> bytes32 _relayerRegistry -62c52 -< relayerRegistry = _relayerRegistry; +> address _relayerRegistry +52c62 +< relayerRegistry = resolve(_relayerRegistry); --- -> relayerRegistry = resolve(_relayerRegistry); -143c133 +> relayerRegistry = _relayerRegistry; +133c143 < } +\ No newline at end of file --- > } -\ No newline at end of file