docs/book/general/guides/relayer.md

123 lines
7.0 KiB
Markdown
Raw Permalink Normal View History

2022-06-30 18:30:02 +00:00
# How to become a relayer?
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
Following the execution of [proposal #10](https://etherscan.io/address/0xEC2412368be52107Fa549c3fb78DE1e3e6bF18EB#code), anyone can become a relayer for Tornado Cash users.
2022-02-25 05:43:40 +00:00
{% hint style="success" %}
The first condition to be included on the Tornado Cash UI is to lock a min. of `2000 TORN`\*. To remain listed, it is needed to keep enough TORN locked to be able to pay back the transaction fee to the staking contract.
2022-02-25 05:43:40 +00:00
{% endhint %}
2022-04-17 10:04:19 +00:00
\*_This minimum stake can be changed by a governance vote at any time._
2022-02-25 05:43:40 +00:00
Relayers form an essential & necessary part of the Tornado Cash ecosystem. Their use guarantees privacy as they solve the “fee payment dilemma” : how to pay fees for token withdrawals from a pool while maintaining anonymity?
2022-02-25 05:43:40 +00:00
Therefore, relayers act as third parties and manage the entire withdrawal. They pay for transaction fees by deducting them directly from the transferred amount. They also charge an additional fee for their services.
2022-02-25 05:43:40 +00:00
Since the implementation of the [relayer registry proposal](https://etherscan.io/address/0xEC2412368be52107Fa549c3fb78DE1e3e6bF18EB#code), lockers in the Governance contract collect a fee directly from the relayers staked balance through the `TornadoStakingRewards` contract for each withdrawal. This fee percentage may vary from one pool to another and is also subject to change through on-chain governance.
2022-02-26 15:10:24 +00:00
Currently, it is fixed at `0.3%` . Some pools remain without fees, either because the instance is too small to assign a fee (0.1 ETH, 100 DAI/USDT, 1000 DAI/USDT), or because there is not enough liquidity on Uni v3 (all cDAI instances).
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
## How to become a relayer?
2022-02-25 05:43:40 +00:00
2023-02-18 23:32:18 +00:00
Anyone can become a relayer for the protocol in **6 simple steps** through the relayer registry user interface [relayers-network.tornadocash.eth](https://app.ens.domains/name/relayers-network.tornadocash.eth/details).
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
### 1. Disclaimer
2022-02-25 05:43:40 +00:00
Before you commit to sharing part of your journey with Tornado Cash users as a relayer, you need to understand & accept all potential risks of being a relayer for the protocol (see section 6).
2022-03-09 20:39:40 +01:00
#### 1. The `relayer-selection system` (how a relayer is chosen by frontends)
2022-03-09 20:39:40 +01:00
The formula for designating a relayer is as follows:
2024-01-19 04:50:45 +00:00
- The list of all registered relayers is retrieved from the Relayer Registry smart contract.
- For each relayer, calculate a score based on its staked TORN and its fee. The higher the stake, the higher the score is; the higher the fee, the lower the score is. For Ethereum mainnet, the formula used to calculate the score is `stake * [1 - 25*(fee-0.33)^2]`; for sidechains, the formula is `stake * [1 - 11.89*(fee-0.01)^2]`.
- Then randomly pick a relayer, weighted by its calculated score.
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
### 2. Set up relayer
2022-02-25 05:43:40 +00:00
The first concrete step is to run the Tornado Cash Relayer software for Ethereum Mainnet on your computer. All steps are outlined in the protocol's github. To complete this task successfully, you will have to carefully follow [these instructions](https://git.tornado.ws/tornadocash/classic-relayer).
2022-02-25 05:43:40 +00:00
Once completed, you will need to insert your url in the input box.
2022-02-25 05:43:40 +00:00
2024-01-19 04:50:45 +00:00
![](../../.gitbook/assets/set-relayer-link.png)
2022-02-25 05:43:40 +00:00
{% hint style="warning" %}
It is strongly recommended that you use your own RPC nodes. Instructions on how to run full nodes can be found [here](https://github.com/feshchenkod/rpc-nodes).
{% endhint %}
2022-02-25 05:43:40 +00:00
### 3. Set Up ENS Subdomain
The next steps entail:
2022-02-25 05:43:40 +00:00
2024-01-19 04:50:45 +00:00
- Creating an [ENS domain](https://ens.domains/) for your relayer.
- Unwrap domain in settings on app.ens.domains or by calling [this function](https://etherscan.io/address/0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401#writeContract#F23).
- Setting up its mainnet subdomain.
- Adding a TXT record with the Relayer URL to the mainnet subdomain according to this specific format:
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
#### **Ethereum relayers (Mandatory)**
2022-02-25 05:43:40 +00:00
| TXT record |
| ----------------------- |
| mainnet-tornado.xxx.eth |
| goerli-tornado.xxx.eth |
2023-01-28 16:55:19 +00:00
#### **Sidechains relayers (Optional)**
2022-02-25 05:43:40 +00:00
You also have the option to add subdomains with their corresponding TXT records to support chains other than Ethereum. Sidechains relayers use a different version of the Relayer software. The complete requirements with instructions are found [here](https://github.com/tornadocash/tornado-relayer/blob/light/README.md).
2022-02-25 05:43:40 +00:00
| TXT record |
| ------------------------- |
| bsc-tornado.xxx.eth |
| gnosis-tornado.xxx.eth |
| polygon-tornado.xxx.eth |
| optimism-tornado.xxx.eth |
| arbitrum-tornado.xxx.eth |
| avalanche-tornado.xxx.eth |
2023-01-28 16:55:19 +00:00
#### **Nova relayer (Optional)**
2022-02-25 05:43:40 +00:00
Tornado Cash Nova uses its own version of the software. If you wish to become a relayer for Tornado Cash Nova, you will find instructions to follow [here](https://github.com/tornadocash/tornado-pool-relayer#deploy-with-docker-compose).
| TXT record |
| ------------------- |
| gnosis-nova.xxx.eth |
![](../../.gitbook/assets/check-relayer-ens-subdomains.png)
2022-02-25 05:43:40 +00:00
2023-01-28 16:55:19 +00:00
### **4. Set up workers**
2022-02-25 05:43:40 +00:00
Workers are the addresses that will allow your relayer to send ZK-proofs to users. By default, the first worker is the ENS domain owner's address.
To ensure an extra level of security, we advise you to set up more than one worker.
Only the mainnet requires you to register workers. All other networks do not require the use of registered workers.
2022-02-25 05:43:40 +00:00
![](../../.gitbook/assets/set-up-relayer-workers.png)
2022-02-25 05:43:40 +00:00
2022-03-03 09:49:44 +00:00
### 5. Stake
2022-02-25 05:43:40 +00:00
With the implementation of a decentralized relayer registry, a staking condition has been introduced as a requirement to become listed on Tornado Cash UI. Keep in mind **staking TORN is now necessary to be added to the recommended list of relayers.**
2022-02-25 05:43:40 +00:00
2024-01-19 04:50:45 +00:00
The minimum staked amount is currently set by Tornado Cash governance at **`5000 TORN`**. This threshold can be changed by Tornado Cash governance at any time.
2022-02-25 05:43:40 +00:00
When a relayer is used in the Tornado Cash pool, a small amount of TORN is automatically collected from this staked balance by the `StakingReward` contract. This element is essential to keep in mind as relayers will need to keep enough TORN locked (\~`500 TORN` at the moment in June 2023) to be able to pay back the transaction fee to the staking contract.
2022-02-25 05:43:40 +00:00
2023-02-18 23:32:18 +00:00
The collected fees are subsequently distributed among DAO members with locked TORN tokens. TORN are usually locked to participate in on-chain governance (submitting & voting on proposals). You can find more information both on the _[Staking documentation page](../general/token/staking.md)_.
2022-02-25 05:43:40 +00:00
{% hint style="warning" %}
2023-01-31 22:26:47 +00:00
Your staked TORN amount is not claimable, and it is non-refundable
2022-02-25 05:43:40 +00:00
{% endhint %}
![](../../.gitbook/assets/relayer-stake-permit.png)
2022-02-25 05:43:40 +00:00
### 6. Slashing (nullification risk)
Similarly to how Ethereum validators are slashed if they behave in a way which Ethereum defines as malicious behaviour, so too are relayers slashed (nullified) if they attempt to game the `relayer-selection system`.
In future, the selection mechanism will be redesigned to remove the need for nullifications.
### 7. Final verification and registration
2022-02-25 05:43:40 +00:00
2023-01-31 22:26:47 +00:00
Last but not least, we advise you to **double-check all information** displayed in the summary before registering.
2022-02-25 05:43:40 +00:00
![](../../.gitbook/assets/register-relayer-summary.png)