Weekly Dev Update #42
THORChain Weekly Dev Update for Week 05–11 May 2020
Summary
Native Rune
The team with feedback from the community, have decided to target Native RUNE THOR.RUNE
for mainnet for the following reasons:
- Better asset security. Since
THOR.RUNE
is not managed by TSS, it is instead managed by THORNode block validation via tendermint consensus, which means an attacker cannot steal the bond without super-majority consensus. - Better node scalability. Since the Network Bond is not bound by TSS committee limits, it is bound by tendermint consensus limits of theoretically 200–300 nodes.
- Better asset flexibility. Native assets means THORChain can control mint/burn and this will lay the groundwork for CDPs and more. Additionally it means transferrable staking units (similar to Uniswap liquidity tokens).
- Better independence. THORChain will no longer rely on an external network to manage asset accounting.
ASGARDEX will have support for native rune, and will allow incredibly easy entry and exit of THOR.RUNE
from all other asset types with one single transaction.
More details about native Rune will be released in time.
Mímir Administration
Once the public testnet is complete, THORChain will move to a Chaosnet with capped funds set to around $10k. This will limit liability and act as a public bounty to find bugs. At regular stages, the team will increase the fund limit of Chaosnet to increase the network’s utility. At some point in the future, the team will then Ragnarok the Chaosnet and move to mainnet.
This requires the team to have an ability to unilaterally change some THORChain’s constants:
DesireValidatorSet // max number of validators
RotatePerBlockHeight // num of blocks for each churn
BadValidatorRate // how often THORNode marks validators to be kicked out for bad behavior
OldValidatorRate // how often THORNode marks mark validators to be kicked out for age
MinimumBondInRune // min bond
MaxBondInRune // max bond
MaximumStakeRune // max rune to be staked on the network
FundMigrationInterval // num of blocks, interval to migrate funds
ArtificialRagnarokBlockHeight // block height to trigger artificial ragnarok
TradingHalt // true/false, enable disable swaps/staking, but unstaking will still be allowed
The important ones being MaximumStakeRune
and ArtificialRagnarokBlockHeight
. Mainnet will launch without any Mímir administration.
The name Mímir is a figure in Norse mythology, renowned for their knowledge and wisdom, who is beheaded during the Æsir-Vanir War. Mímir gives the team god-like powers over the chain, but will end in its head getting chopped off, and thus giving up that ability.
Swap Queuing
Swap Queuing is an important ability for the chain to prioritise certain swaps over another. This is important:
- stops any pools becoming locked up
- stops the chain being DoS’d
- prevents traders exploiting the path-dependent nature of CLPs (breaking their trades up into many small ones)
- maximises revenue for the system
The following are the Swap Queue Rules:
- Each swap is scored with fee and slip metrics, then summed and ordered
- 50% of all swaps are processed each block, with the highest swap scores completing first
- A minimum of 10 and a maximum of 100 swaps are always completed
- The swap with the highest score in each direction in each pool is processed first
This means:
- In normal operation with less than 10 swaps, all swaps are processed
- In periods of demand (more than 10 swaps, less than 100), only 50% of the swaps are completed, so traders need to maximise fee + slip scores
- In periods of peak demand, only the top 100 swaps are completed (20 swap/second), which limits overhead and maximises chain revenue
- Shallow pools don’t get locked up (due to high slip swaps)
- Deep pools don’t get locked up (due to high revenue swaps)
- Medium pools with Medium fees (implying low volatility) will be prioritised last once the demand clears.
THORNode Merge Requests
Cleanup, bugfixes, maintenance, new features.
- [cleanup] Remove supplementals
- [bugfix] break handler into external/internal handlers
- [cleanup] merge txout store V2 -> V1
- [cleanup] remove end pool handler
- [bugfix] fix tss handler unit test
- [bugfix] verify destination matches target asset chain
- [cleanup] remove txout store mutex
- [cleanup] cleanup more unit test tweaks
- [maint] upgrade to latest TSS
- [bugfix] fixes discovered during real world testing
- [bugfix] update mock leave script to newer mock-binance structure
- [feature] mimir administration
- [feature] Prioritized swap queue
Refactoring in the new Event Manager:
- Resolve “[ADD] remove block event and emit event using sdk’s event manager”
- Resolve “[ADD] move stake events to use new event manager”
- 471-issue add reserve event
- Resolve “[ADD] add swap events to event manager”
- 472-issue add reward events
- 473-issue add unstake event
- Resolve “[ADD] add refund and bond event to event manager”
- 464-issue add errata events
Finalising Ethereum integration:
Native Rune support:
- [feature] Adds the ability to switch BEP2 Rune ←> Native Rune
- [feature] Add send handler
- [cleanup] set thor to be default asset chain
- [cleanup] tss chains should have rune chain
- [refactor] use rune addr generator in tests
- [refactor] refactor unstake unit test
- [cleanup] refactor unit tests to not assume rune is BEP2 asset
- [feature] trigger user transactions via native chain
- [feature] Native outbound transactions
- [feature] add additional reserve option, for native rune
- [feature] native rune bonding/staking/unstaking
- [testing] refactor unit testing to work for both BEP2 and Native rune
Midgard
Work continues to mature out the Midgard API. It will need to be refactored soon to handle the new event manager.
- Resolve “ADD: cache layer to thorchain client”
- Resolve “Move GetStats logic to usecase layer”
- Resolve “Generalize timespan functions”
- Resolve “Fix chain name”
Clients
ASGARDEX is now at the following repo:
The team are working to build it out and port in the BEPSwap and Asgard Wallet components:
- MidgardContext + MidgardService
- Generate Midgard API types
- Add ThemeContext
- GH actions for running unit tests + ESLint
- Update README w/ latest technology we use
- Add I18nContext
- Feature/first wallet view
- Introduce themes
ASGARDEX-Common
This is a npm package that contains the Binance Client, ASGARDEX theme and will soon include the Bitcoin, Ethereum and the THORChain wallet client:
The clients will be built to comply with the following interface (example, BitcoinClient):
export interface BitcoinClient {
init(net: Network): any
getNet(net: string): Bitcoin.networks.Network
setPhrase(mnemonic: string): any
getAddress(): string
validateAddress(address: string): boolean
scanUTXOs(address: string): Promise<any>
getBalance(UTXOS: any[]): number
vaultTx(addressVault: string, valueOut: number, memo: string): Promise<string>
normalTx(addressTo: string, valueOut: number): Promise<string>
}
Audit
Code Review: Complete
Economic Review: Completed most of THORChain's economic architecture
TSS Audit: begun work
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