[feature] Memoless Transactions
Summary
Whenever a transaction is observed on THORChain, that transaction's memo is parsed and derived the intent of those funds. This memo requirement causes a handful of issues
- Not all wallets support writing memos (ie OP_RETURN on Bitcoin). This results in not every wallet can be used to swap with THORChain. Special work needs to be done on a per-wallet basis to support THORChain and its protocols
- Some memos can limit their length. For example, Bitcoin will not allow more than 80 bytes in length. This length limitation can cause issues with more complex trades or actions.
- One of the requirements THORChain places on blockchains that it integrates is support for memos (which maybe not all do support). This limits which chains can or cannot be added to THORChain.
This issue introduces "memoless transactions", which has been a feature that has been considered for quite a long time (#719 (closed)). Supporting memoless transactions allows any wallet in the world to be able to interact THORChain and utilize its protocols, expanding its available market.
How it Works
A new msg type is added to THORChain where someone can request a "reference" which is a number that is 5 characters long.
type MsgReferenceMemo struct {
Chain common.Chain
Memo string
}
TC will generate a ref code, 5 digits long, associated with that long memo. This code can now be used as a short memo, or for memo-less, simply the last 5 digits of the amount. The user can query thornode via their transaction hash to retrieve their "reference" code. The memo is added to the transaction and continues through the network.
eg:
long memo: =:BNB.BNB:bnb1z2eh9wj29jkt3qqwjgqaxw7u6gve6fwcxh4u4s:97961079:tw:0
short memo: 23456
added to amount: 1_0002_3456 (1 BTC)
Time to Live
There is a TTL (time to live) on these reference memos which is controlled by mimir; launch TTL will be 24hrs.
Reference Numbers
There will be a range of numbers that can be used for this purpose. The starting recommendation is 20k(+1)-30k. This is because 10k-20k is utilized by savers withdrawals. And 20k specifically should be reserved for savers deposits.
This would mean the network has 10k references available per chain per 24 hours.
If the space is too large, it is more difficult for shrimps to interact with the network (depending on the value of the asset). Too small and can run out references or be more subject to provider DoS attacks.
Limits
If BTC is $100k, then 20k-30k is $20-$30, so memoless tx's would always have a minimum amount that can be swapped. This figure is currently within reason.
But alternatively, interactions can add a memo to a "memoless txn" which would reference the 5 digit reference code in the memo instead of the token amount. This would look something like
ref:12345
While this does reintroduce the memo back in (which seemingly is self defeating), there is a good use case for this. In the event that a wallet wants to use a very large memo, and the source chain (ie Bitcoin) can't support a memo of that size, they can use this feature to have a long memo on a Bitcoin transaction.
Memo to save a Memo
THORChain tx using MsgDeposit, with:
r:<chain>:<memo>
request:<chain>:<memo>
This can only be used on THORChain directly as this is fast, cheap and external network observations are 100x more expensive for the network than native transactions.
API Endpoints
/thorchain/memohash/<txhash>
/thorchain/memo/<chain>/<ref>
Mimirs
- MemolessTxnTTL - number of blocks before the reference memo expires
- MemolessTxnStartRef - starting reference number (20,001 is suggested)
- MemolessTxnEndRef - ending reference number (30k is suggested)