Weekly Dev Update #45

THORChain Weekly Dev Update for Week 26–30 May 2020

Weekly Dev Update #45

Summary

The team successfully Ragnarok’ed the existing network which was useful in identifying some issues that had to be fixed. The testnet will be re-deployed with these fixes to the public shortly. An additional testnet will also be deployed soon for potential THORNode validators to practice joining and leaving.

Dynamic Network Fees

A feature that was added was “Dynamic Network Fees”. This monitors all reported gas fees on incoming transactions (both fee-amount and fee-rate) and saves to the chain. Transactions are charged an amount 3 times the trailing average for the gas for each chain, and the actual gas used by the nodes is 1.5 times the incoming. This means outbound transactions are always prioritised *more* than incoming, and the gas used is always subsidised. An example is:

  • The average of incoming Bitcoin fees is 10 sats/byte, with average amount 4000 sats used. ( feeAmount = 4000, feeRate = 10, feeCoin = BTC.BTC ). (Incoming Bitcoin transactions will likely be of type 2-in-3-out so around 400 bytes).
  • The user who is swapping to Bitcoin is charged 3 * 4000 BTC.BTC = 12000 BTC.BTC . This is taken from them as RUNE valueInRune(12000, BTC.BTC) (since all transactions go via RUNE at some point) and paid into the TotalReserve.
  • Nodes then use a rate of 15 sats/byte to pay the outbound transaction. Most likely the outbound transaction is a 2-in-2-out so around 300 bytes, so the total amount is 4500 BTC.BTC which is taken from the Bitcoin vault balance.
  • This transaction is then observed and reported back into THORChain and the Bitcoin pool is paid an amount equal to twice the fee (9000 BTC.BTC ) but in RUNE. This cause arbitrage and the Bitcoin pool is topped up by the market at an amount at least equal to 4500 BTC.BTC .

While appearing complex, this mechanism has the following simple characteristics:

  • Fee rates are responsive to short-term fluctuations and should be high enough to always be processed in their respective mempools.
  • The fee mechanisms is standard across all chains, no matter the fee-type.
  • Liquidity stakers are providing the capital for gas, but should always be reimbursed.
  • The network makes a small margin on every swap.

THORNode

Bugfixes & Refactoring

All issues identified from the testnet has been merged back into the main binary.

Chain Work

Midgard

ASGARDEX

ASGARDEX-COMMON

Work continues to abstract out most of the main chain features so that the heavy lifting can be done by a standardised NPM package. This includes all of the CLP arithmetic.

ASGARDEX-ELECTRON

The wallet work continues to bring in the main components.

Audit

  • Code Review: Complete
  • Economic Review: Preparing Final Review
  • TSS Audit: 58%
  • Infra Audit: scoping

Next Milestones

The testnet is being re-deployed and will be made public soon. Chaosnet is expected once testnet has been fully-validated in several environments. There currently isn’t any known blockers to Chaosnet release.

Community

To keep up to date, please monitor community channels, particularly Telegram and Twitter: