ZKP Tree updates proposal
TORN Mining is currently stuck because nobody is paying for the gas cost of updating the Merkle tree. This proposal would introduce a new Merkle tree leveraging Zero Knowledge proof that would be an order of magnitude cheaper to update and would therefore unstuck mining. The proposal is live at https://app.tornado.cash/governance/4 vote now if you support it.
Back in December 2020 the Tornado Cash team annouced a governance layer for the Tornado.cash ecosystem. This system came with a very novel way of incentivising Tornado cash usage to create a strong anonymity set. Up to 10% of the total supply of TORN can be “mined” by user depositing funds in the anonymity pools. The system works by first earning AP (Anonymity Points) proportionally to the amount of time spent in the pool. Once the AP is earned they need to be claimed for each individual pool withdrawal. After the claim, the last step is to swap the AP for TORN in an AMM.
Because the anonymity of the miners have to be preserved this system works by having a third party, updating the Merkle tree that allows people to claim. You can only update the the deposit+withdrawal in the tree in the order they were made. Meaning that if 100 withdrawals are ahead of me in the tree queue, I would have to update and pay gas for these 100 withdrawals before mine can be added to the tree.
Problem: There is currently no incentive to update the tree and therefore, nobody is doing it. Gas costs are a lot higher than anticipated by the TCash team when they designed the system. The result is that people can’t claim AP reward. This is the message that you likely see if you try to claim AP:
Currently, there is more than 12000 withdrawals with and 15000 deposits in the Tree queue waiting to be included. To update 60 deposits or withdrawals, it cost around 5 millions gas, at 120 Gwei that’s 0.6 ETH or around $1000 at current price. That means that to update all pending withdrawals and deposits it would cost around $450k for 2-3 months of withdrawals. I would estimate that almost $100k of gas per month is needed to keep the tree updated assuming a gas price between 100 and 200 Gwei.
This proposal introduce a new system that will drastically reduce the cost of updating the Merkle tree by leveraging Zero Knowledge Proof. Zero Knowledge Proofs allow to verify the correctness of a function output without actually doing the computation (therefore reducing gas cost!). ZKP is already a core technology making Tornado Cash anonymity pool possible. They would be reused here but to achieve a different purpose. This update require a new Tornado Cash proxy contract.
ZKP tree contract
The new tree contract code can be found here (In
The proposal contract setting up and configuring the new tree contract can be found here (In
The update functions
updateWithdrawalTree will load exactly 256 deposits leafs or 256 withdrawals leafs at once. Along with those you have to pass the new Merkle root and the ZKP of the root calculation.
Like before, a repo is provided with a script creating the ZKP and calling the update function. This script can be found on this repo, (be sure to be on the
snark branch): GitHub - tornadocash/tornado-root-updater at snark
One call to one of the update function cost around 1,065,929 gas thefore reducing the gas cost by a factor of 13.
Some additional considerations on the tree contract:
- It is proxy upgradable by governance
New Tornado Cash proxy
A new Tornado Proxy was required because it is the proxy that adds withdrawals and deposits to the Tree queue. It therfore needs to point to a new tree contract.
The proxy also introduce one new feature, the support for ERC20 anonymity pools. Up to now, ERC20 pools were not going through the proxy. Users were interacting directly with the pool contract. Now users will have a choice to go through the proxy. The benefit of going to the proxy is that ERC20 pool can be used for anonymity mining.
Important: That does not mean that ERC20 pool will have mining activated but that they can be activated in the future by governance.
updateInstance has an
onlyGovernance modifier and will allow governance to add and remove instances (= pools) from the proxy but also to activate/deactivate mining for an instance.
Additional consideration for the proxy contract:
- The UI will now have to point to the new proxy
- Relayers will have to upgrade to point to the new proxy
The proposal will deploy configure the new Proxy and Tree contracts described above. This how the system reconfigured for these contracts to work:
The tree contract is initialized with the latest Merkle root of the old tree contract. The new tree takes over from here. That means that if you are currently farming AP, you are not affected, you will be able to claim AP as expected once the tree is updated
The proposal will register the following pools with mining enabled:
- 0.1 ETH
- 1 ETH
- 10 ETH
- 100 ETH
- 0.1 ETH
The proposal will register the following pools with mining disabled:
- 100 DAI
- 1k DAI
- 10k DAI
- 100k DAI
- 5k cDAI
- 50k cDAI
- 500k cDAI
- 5m cDAI
- 100 USDC
- 1000 USDC
- 100 USDT
- 1000 USDT
- 0.1 WBTC
- 1 WBTC
- 10 WBTC
Note that the ETH pools are the already existing pools. The ERC20 pools are the pools that already existed before (long before TORN was introduced) plus the recently deployed pools. See: New Tornado.cash pools are here! DAI, cDAI and WBTC - #2 by gewitet
- 100 DAI
The miner contract will be configured to point to the new tree contract.
Here’s a smart contract address for this proposal Proposal | 0x4b6c07b8940a7602fe4332afa915b366e56eace5
Now someone with 1000 TORN needs to submit this proposal contract to Tornado Cash Governance for voting
Update: The proposal is live at https://app.tornado.cash/governance/4 vote now if you support it.