Weekly Dev Update #23
THORChain Weekly Dev Update for Week 21–29 Dec 2019
Changes
Global Slip Limit
Global Slip Limit (which was 30%) has been removed to reduce complexity and query times during processing swaps. This is part of the codebase-wide effort to reduce complexity along key logic paths. Clients that interact with THORChain should have validation to prevent traders experiencing large slips (or at least warn them), however THORChain has no opinion on what should or shouldn’t be processed from a swap perspective.
Ending Base Pool
THORChain requires BNB as gas to process transactions, so the system considers that BNB is a fundament asset to ensure network availability. If $RUNE is ever moved to another chain, (or even to its own chain), then the gas asset will also change. Additionally the base asset for each connected chain (ETH for Ethereum etc) also becomes a critical asset to ensure availability on those chains.
As part of edge case testing, the team encountered cascading complexity when handling these base assets. As a simple fix, the team have removed the ability to “end” the pool for a base asset. This means that if there is a mass liquidity withdrawal for a base asset pool (BNB, BTC, ETH), the system will prevent the last staker from leaving because it requires the base asset to pay for gas. If the chain is subsequently Ragnaröked, then the funds will be returned as normal to this staker.
In future a better solution may be added, but for now this solution passes the complexity/utility tradeoff.
Genesis Nodes
Bootstrapping a decentralised network via a centralised deployment is unavoidable. Satoshi Nakamoto even had to deal with this for Bitcoin, but mitigated it by requiring that the first block could only be mined once a peer was discovered on the network. This was the reason why the first block took 6 days to be generated, because the network was waiting for the software to be released and a peer to join (likely Hal Finney).
The Genesis Nodes are used merely to give birth to the network and are hard-coded into the first genesis file. They do not bond any Rune. Once peers are churned in, the network becomes operational and can accept funds. To ensure this, the team have also hard-coded that the Genesis Nodes never receive any rewards.
Reference Price
A notable change has been that all USD pricing has been removed from the codebase and UI. This is important because the team consider that USD pricing is purely subjective, and a peer to a plethora of other pricing options. Indeed, in future not only will USD be considered a peer pricing option, but there will be many flavours of USD, due to the many USD stablecoin implementations. The team did build an elaborate module that looked for any asset containing “USD” in the asset description and built out an array of depth-weighted pricing feeds, then took the median of this, but this rabbit-hole created more questions than it answered.
Going forward, the only native pricing option (and the default) will be in $RUNE. If a user wishes to localise to another price option, they can select this from a dropdown. This price now becomes the “Reference Price” and is shown client-wide. To calculate this, the depths are just divided:
priceAsset(inReference) = (assetDepthReference / runeDepthReference) * (runeDepth / assetDepth)
The Rune unit is then cancelled out, leaving the asset to be priced solely in the reference asset.
THORChain
Refactoring
Work continues to refactor the codebase towards a much more testable interface. Refactoring will likely continue for a few more weeks as the system is tested and validated.
- [Refactor] Ragnarok Stage 2
- Resolve “ADD: Move all Constants into Constants.go”
- 286-issue update block height to use int64
- Minor fix for validator manager
- Resolve “[Refactor] Outbound handler”
- 297-issue remove /thorchain/keygen/:height endpoint
Implementation
Other features as discussed above were added, including some of the remainder to achieve a fully-functional network. Some bugs as discovered in testing were also fixed.
- 273-issue remove global slip limit
- Ragnarok bond/reserve refunds
- [Tests] Ragnarok unit tests
- Resolve “should not end pool of base token”
- use home for tss
- 288-issue prevent from pay reward to node that doesn’t have bond ,usually it is the genesis nodes
- [infra] add reset commands
- [Bug] first event id is zero
- generate vault before genesis
- [bug] Genesis fullstack tweaks
- 296-isse move the genesis move creation logic to vault manager
BEPSwap
BEPSwap has been operational in an internal testnet for the preceding week, allowing the team to find and fix bugs. Pricing options are now available in a header drop-down (similiar to CoinMarketCap).
- Resolve “UPDATE: Midgard & Thorchain API Integration”
- Resolve “Implement price base token dropdown UI”
- use https not https for localhost
- Resolve “BUG: Remove warnings and issues”
Audit
The code review has now commenced. More details around this will be discussed in a separate blog.
Milestones
The updated testnet should be available later this week. Audit, ChaosNet and Mainnet milestones will be treated in separate blog.
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