THORChain
Published in

THORChain

Post-mortem: ETH Router Upgrade

The ERC-777 re-entrancy bug, trading halt, Router Upgrade, USDT rescue, return to solvency and operational, improvements

Summary

Details

ERC-777 Re-entrancy

Fix: Add a reentrancy guard

Trading Halt

Testnet Issues

Router Issues

USDT does not return a bool
The fix in Router V2

USDT Recovery

  1. Ragnarok all USDT LPs and migrate with no USDT
  2. Recover the USDT to a treasury address, migrate manually
  3. Recover the USDT to a smart contract, migrate trustlessly (anyone could call the subsequent deposit)

Migration Coordinator

If new router, then migrate
1. Mimir set `StopFundYggdrasil` to `1`  , this will stop funding yggdrasil vaults 
2. Mimir set `MimirRecallFund` to `1` , this thet network will ask yggdrasil to send all their fund back to asgard on ETH chain
3. Double check all yggdrasil vaults return their erc20 tokens , if all yggdrasil vault only has dust ETH left in it , then go to step 4)
4. Mimir set `MimirWithdrawUSDT` to `1` to extract USDT , this will trigger the USDT outbound, make sure the outbound has been send all USDT to designate address
5. Mimir set `MimirUpgradeContract` to `1` , this will trigger the network to upgrade contract to new one
6. Make sure all yggdrasil contract has been updated to the new contract address
7. Mimir set `ChurnInterval` back to 43200 so node churn can be kicked off
8. Once churn kicked off , make sure the new asgard has the new contract, and migrate is migrating fund to new contract
9. When churn finished , credit USDT and XRUNE back to new asgard, new contract using memo `noop`
10. Mimir set `StopFundYggdrasil` to 0 , the network will go ahead to fund yggdrasil vaults
11. Once ygg funded, Mimir set `HaltTrading` to 0 , the network will be available for swaps

Return to Operations

Improvements

  1. RouterV2 has a re-entrancy guard, compatible with ERC-20s that are non-standard, and has a new function requested by the community to expire deposits
  2. THORChain community has validated the Router Upgrade logic and will be prepared to more readily migrate to Router V3 (with more advanced logic).
  3. THORNode will have a chain-specific trading halt logic, which would have kept the network mostly operational
  4. Re-establish Testnet and engage with high-quality node operators to run the testnet.

Community

--

--

A decentralised liquidity network.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
THORChain

The official team for THORChain — the decentralized liquidity network.