Weekly Dev Update #45
THORChain Weekly Dev Update for Week 26–30 May 2020
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 type2-in-3-outso 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 RUNEvalueInRune(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-outso around 300 bytes, so the total amount is4500 BTC.BTCwhich 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 to4500 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.
- [bugfix] removing native tx relay from msg send
- [refactor] refactor how to do kvstore migration
- [refactor] break memo into its own package
- [bugfix] add pruning
- [refactor] move keeper to its own sub packages
- Resolve “[REMOVE] remove old events”
- [bugfix] patches discovered through testnet
- [bugfix] update binance broadcast parsing
- 492-issue add processIn and processOut property back
- [bugfix] fix double handler bug
- [bugfix] remove old pubkeys from pubkey manager in bifrost
- 490-issue a little bit code clean up
- [bugfix] chain block height takes priority over current store position
- [documentation] remove old ‘setup’ documentaiton, its no longer used
- [bugfix] unstaking requires 24 hrs
Chain Work
- [admin] mimir has the power to change the emission curve
- Fix entrypoint keyring
- Resolve “Update Constants endpoint”
- 487-issue add rune address to stake event
- Resolve “[ADD] Dynamic network fees”
Midgard
- Resolve “Fix dateCreated”
- Resolve “Make event handler unit tests deterministic”
- Resolve “Delivery layer clean up”
- Resolve “Build html document in docker build”
- Resolve “ADD: rune address to stake event”
- Resolve “Add eth and btc address”
- Resolve “ADD: totalEarned”
- Fix cross chain duplicate IDs
- Resolve “”thorchain” package cleanup”
- [testnet deploy] updates testnet docker image
- Resolve “Invalid input tx for stake event”
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.
- RESOLVES: Issue15b — Refactor Binance
- Upgrade to latest dependencies, misc. quick fixes
- Fix return type of `getBalance`
- FIX LINTING
- Fix build of the library
- Add calc for XYK formula
- ADD: slip on stake method
- RESOLVE: Issue2 — getSwapSlip
- RESOLVE: ISSUE3 — IMPORT TOKEN HELPERS
ASGARDEX-ELECTRON
The wallet work continues to bring in the main components.
- Feature/addkeys accountdata
- Install `asgardex-binance` from branch
- Feature/sort import order
- Fix build actions and usage of `BinanceClient`
- Feature/ui component
- Issue 104/add mobile header
- Feature/ui component
- Feature/addressinput
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:
- Twitter: https://twitter.com/thorchain_org
- Telegram Community: https://t.me/thorchain_org
- Telegram Announcements: https://t.me/thorchain
- Reddit: https://reddit.com/r/thorchain
- Github: https://github.com/thorchain
- Medium: https://medium.com/thorchain