Weekly Dev Update #40
THORChain Weekly Dev Update for Week 21–29 Apr 2020

Summary
THORChain Benchmarks
The team are now working out how to optimise THORChain after completing initial benchmarks.

THORChain (without any optimisation) is able to process:
- 180 swaps per minute
- 2400 stakes per minute
Given connections with Bitcoin, Ethereum and Binance Chain, it could process the following:

The following are the assumptions:
- Bifrost capacity is split between the three chains
- 75% of inbound transactions are swaps, 25% is stakes
- Real-world throughput taken as of 27 April 2020
The results show that THORChain can handle (at the same time) over 50% of every transaction on Bitcoin, 25% of every transaction on Ethereum and over 3 times the full current throughput of Binance Chain.
In reality, THORChain is likely to only receive a level of demand at most 1/10th this theoretical capacity. This position is taken from looking at how many arbitrage transactions are made on average through UniSwap’s contracts. Thus, THORChain has plenty of spare capacity.
Optimising State
As part of optimisations, the team began optimising how state is queried and saved in the state-machine to minimise key-writes. As an example, if a single pool is to be updated, it is not necessary to store them all in a large array of pool objects, and then re-write them all when just one pool needs to be modified. The solution is to break each pool into its own query, so it can be read and updated much faster.
Removing Outbound Memos
The team also implemented a change that removes all outbound memos from the network. This minimises complexity in handling outbound transactions, enable better batching and reduces how much on-chain meta-data is left behind.
THORChain instead takes a hash of the txOut
object (which should be unique) and compares that in order to find which outgoing txOut
corresponds with each observed transaction.
Double signing
CosmosSDK natively includes a module that is able to process evidence submitted of double-signing a block and slash bonds. The team spent the week hooking up this functionality into the existing THORChain node module since it processes bond differently.
Double-signing a block is bad, because it can lead to consensus breakdowns fast if nodes become confused which chain is correct. If everyone is punished for trying to sign more than one block at once, then nobody will and the only chain will be the correct one — this results in instant finality.
Chain-specify Ragnarök
The last feature the team implemented was the ability for nodes to signal support of connected chains. If more than 2/3rds signal they want to stop supporting a chain, the chain is immediately purged and all assets returned to whoever was staking on that chain.
This will be useful for contentious hard forks, or a catastrophic bug on an external chain. The end result is that all funds are returned and if the chain is to be re-added by the community later, it can be.
THORNode
The following merge requests were made to the THORNode repo:
- [feature] add stake errata support
- [feature] manage supported chains
- [feature] Ragnarok chain
- [config] set no cross chain blocking for unstaking assets
- [feature] slash for double signing a block
- Resolve “Update Bifrost BTC observer with new outbound observing”
- 439-issue add logic to sum total UTXOs
- Resolve “Update block scanner to use config on discovery block back off sleep time”
- Resolve “Fix pools endpoint”
- Resolve “Node accounts endpoint should not return nodes with zero bond”
- Resolve “Hotfix bitcoin mock startup”
- 433-issue fix the problem that thornode keep generating empty gas event
- 432-issue fix gas management for BTC and ETH
- [bugfix] majority patch
- [bugfix] allow multiple ygg returns
- [cleanup] remove chains keeper
- [bugfix] high performance improvements
- [cleanup] remove pool index
- [cleanup] remove old cli queries
- [cleanup] remove staker pool
- 446-issue remove some unused method
- 441-issue remove ValidateMetadata
- [refactor] remove list all node accounts
Midgard
The following merge requests were made to maintain the Midgard repo:
- Resolve “Implement Usecase layer”
- Resolve “Remove unused code from api package”
- Resolve “Order by date option for `/v1/txs` endpoint”
- Resolve “Implement parallel Thorchain Scanner”
- Resolve “Fix /v1/txs count and add tests”
Clients
The clients are being prepared to be merged into one: ASGARDEX. This will be a desktop electron app connects via the THORChain Byzantine module to the network.

- Fix Midgard IP in Header + bump Byzantine
- Resolve “BUG: Swap price calc is not correct”
- Resolve “BUG: hot fix for swap calc — master”
- Resolve “FIX: Can’t stake into pool.”
- Resolve “Hot fix — Can’t stake into pool -> master”
- Byzantine v.0.1.1 — master
- Resolve “Create Dark Theme”
- Resolve “Hotfix: Prevent user from swapping an unlisted asset -> master”
Audit
Code Review: Complete
Economic Review: Completed most of THORChain's economic architecture
TSS Audit: kickoff
Next Milestones
The updated testnet is in the final stages of testing. 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