Proposal init
This commit is contained in:
parent
bb2ee952bc
commit
d994c6eead
|
@ -0,0 +1,3 @@
|
|||
[submodule "tornado-anonymity-mining"]
|
||||
path = tornado-anonymity-mining
|
||||
url = https://github.com/tornadocash/tornado-anonymity-mining
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
This proposal introduces a registery for relayers where anyone can stake TORN and become relayer.
|
||||
|
||||
More info: https://torn.community/t/
|
||||
*/
|
||||
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol";
|
||||
|
||||
import "./TornadoProxyV3.sol";
|
||||
import "./RelayerRegistry.sol";
|
||||
|
||||
interface IProposal4 {
|
||||
function getInstances() external view returns (TornadoProxy.Tornado[] memory instances);
|
||||
}
|
||||
|
||||
interface TornadoTrees is ITornadoTrees {
|
||||
function setTornadoProxyContract(address _tornadoProxy) external;
|
||||
}
|
||||
|
||||
// TODO should we add SWAP and CLAIM operations here as well?
|
||||
contract Proposal {
|
||||
TornadoProxy public constant tornadoProxyV2 = TornadoProxy(0x722122dF12D4e14e13Ac3b6895a86e84145b6967);
|
||||
TornadoTrees public constant tornadoTrees = TornadoTrees(0x527653eA119F3E6a1F5BD18fbF4714081D7B31ce);
|
||||
IProposal4 public constant proposal4 = IProposal4(0x4B6C07B8940a7602fE4332AFa915b366e56eAce5);
|
||||
address public constant governance = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce;
|
||||
uint256 public constant txFee = 0.01 ether;
|
||||
uint256 public constant minStake = 500 ether;
|
||||
|
||||
event DeploymentOf(string name, address addr);
|
||||
|
||||
function executeProposal() public {
|
||||
TornadoProxy.Tornado[] memory instances = getInstances();
|
||||
// disabling all instances on current tornadoProxy
|
||||
for (uint256 i = 0; i < instances.length; i++) {
|
||||
tornadoProxyV2.updateInstance(TornadoProxy.Tornado({
|
||||
addr: instances[i].addr,
|
||||
instance: TornadoProxy.Instance({
|
||||
isERC20: false,
|
||||
token: IERC20(0),
|
||||
state: TornadoProxy.InstanceState.DISABLED
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
// deploying Relayer registry upgradable proxy and its implementation
|
||||
RelayerRegistry registry = new RelayerRegistry();
|
||||
TransparentUpgradeableProxy registryProxy = new TransparentUpgradeableProxy(address(registry), governance, "");
|
||||
|
||||
// deploying the new tornadoProxy
|
||||
TornadoProxyV3 tornadoProxyV3 = new TornadoProxyV3(
|
||||
address(tornadoProxyV2.tornadoTrees()),
|
||||
tornadoProxyV2.governance(),
|
||||
instances,
|
||||
address(registryProxy)
|
||||
);
|
||||
|
||||
// initializing Relayer registry
|
||||
registry = RelayerRegistry(address(registryProxy));
|
||||
registry.initialize(address(tornadoProxyV3), txFee, minStake);
|
||||
|
||||
// registering the new tornadoProxy contract in tornadoTrees
|
||||
tornadoTrees.setTornadoProxyContract(address(tornadoProxyV3));
|
||||
}
|
||||
|
||||
/// @dev Returns actuall all supported instances with actual state
|
||||
function getInstances() public view returns (TornadoProxy.Tornado[] memory instances) {
|
||||
instances = proposal4.getInstances();
|
||||
|
||||
for(uint i = 0; i < instances.length; i++) {
|
||||
(bool isERC20, IERC20 token, TornadoProxy.InstanceState state) = tornadoProxyV2.instances(instances[i].addr);
|
||||
require(instances[i].instance.isERC20 == isERC20, "Incorrect instance state (isERC20)");
|
||||
require(instances[i].instance.token == token, "Incorrect instance token");
|
||||
instances[i].instance.state = state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,17 +4,18 @@ pragma solidity ^0.7.0;
|
|||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/math/SafeMath.sol";
|
||||
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
|
||||
|
||||
interface IENS {
|
||||
function owner(bytes32 node) external view returns (address);
|
||||
}
|
||||
|
||||
contract RelayerRegistry is Ownable {
|
||||
contract RelayerRegistry is Ownable, Initializable {
|
||||
using SafeMath for uint256;
|
||||
|
||||
IERC20 public constant TORN = IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C);
|
||||
IENS public constant ENS = IENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
|
||||
address public immutable withdrawalProxy;
|
||||
address public withdrawalProxy;
|
||||
|
||||
mapping(address => Relayer) public relayers;
|
||||
uint256 public txFee;
|
||||
|
@ -40,7 +41,7 @@ contract RelayerRegistry is Ownable {
|
|||
mapping(address => bool) addresses;
|
||||
}
|
||||
|
||||
constructor (address _withdrawalProxy, uint256 _txFee, uint256 _minStake) {
|
||||
function initialize(address _withdrawalProxy, uint256 _txFee, uint256 _minStake) external initializer {
|
||||
withdrawalProxy = _withdrawalProxy;
|
||||
txFee = _txFee;
|
||||
minStake = _minStake;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../tornado-anonymity-mining/contracts/TornadoProxy.sol";
|
||||
import "./RelayerRegistry.sol";
|
||||
|
||||
// TODO should we make it upgradable as well?
|
||||
contract TornadoProxyV3 is TornadoProxy {
|
||||
RelayerRegistry public registry;
|
||||
|
||||
constructor(
|
||||
address _tornadoTrees,
|
||||
address _governance,
|
||||
Tornado[] memory _instances,
|
||||
address _registry
|
||||
) TornadoProxy(_tornadoTrees, _governance, _instances) {
|
||||
registry = RelayerRegistry(_registry);
|
||||
}
|
||||
|
||||
function withdraw(
|
||||
ITornadoInstance _tornado,
|
||||
bytes calldata _proof,
|
||||
bytes32 _root,
|
||||
bytes32 _nullifierHash,
|
||||
address payable _recipient,
|
||||
address payable _relayer,
|
||||
uint256 _fee,
|
||||
uint256 _refund
|
||||
) public payable override {
|
||||
super.withdraw(_tornado, _proof, _root, _nullifierHash, _recipient, _relayer, _fee, _refund);
|
||||
registry.transaction(msg.sender, _relayer);
|
||||
}
|
||||
}
|
|
@ -7,7 +7,9 @@ require('hardhat-etherscan-abi')
|
|||
* @type import('hardhat/config').HardhatUserConfig
|
||||
*/
|
||||
module.exports = {
|
||||
solidity: '0.7.6',
|
||||
solidity: {
|
||||
compilers: [{ version: '0.7.6' }, { version: '0.6.12' }],
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
"@nomiclabs/hardhat-etherscan": "^2.1.4",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.0",
|
||||
"@openzeppelin/contracts": "^3.3.0",
|
||||
"@openzeppelin/contracts-upgradeable": "3.4.1",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^7.32.0",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9f095bfcb20b486bf50277f3a1c4cf10f1ac90f5
|
|
@ -654,6 +654,11 @@
|
|||
"@types/sinon-chai" "^3.2.3"
|
||||
"@types/web3" "1.0.19"
|
||||
|
||||
"@openzeppelin/contracts-upgradeable@3.4.1":
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-3.4.1.tgz#38dfdfa86fda0a088c6fcdebe6870cfaf897b471"
|
||||
integrity sha512-wBGlUzEkOxcj/ghtcF2yKc8ZYh+PTUtm1mK38zoENulJ6aplij7eH8quo3lMugfzPJy+V6V5qI8QhdQmCn7hkQ==
|
||||
|
||||
"@openzeppelin/contracts@^3.3.0":
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1.tgz#03c891fec7f93be0ae44ed74e57a122a38732ce7"
|
||||
|
|
Loading…
Reference in New Issue