Add Tron chain client
-
Add Tron chain client to Bifrost
-
Add extra block scanner config option
ApiHost:TronClient mostly uses the Tron "wallet" API, but needs the json_rpc API endpoint for smart contract interaction (which uses
RpcHost) -
Add an exception for Tron txs with zero gas used to
x/thorchain/helpers.go:addGasFees()
Caveats:
-
Zero gas transactions
Tron uses bandwidth and energy for its transaction fees. These resources fill up over time until a specific threshold. If an account does just a few transactions, gas fees can be payed from the account's bandwidth & energy without using TRX. TRX is only used if the accounts bandwidth or energy is not sufficient or for special fees like initial account activation. Therefore the scanner will observe txs with 0 gas. Because txs need to have gas, the scanner sets a fake value of 1e-8 TRX, which is handled (ignored)
addGasFees()inx/thorchain/helpers.go. -
Expensive TRC-20 fees
Fee calculation is different for TRX only or if TRC-20 tokens are enabled (if there is at least one token whitelisted). Tx fees differ between each TRC-20 token due to the variable penalty multiplier for extensive usage of contracts. Therefore the client always uses the fees for the most expensive enabled TRC-20 token, which is also applied for TRX. This can be quite much especially when USDT is enabled.
Tests on public testnet:
Pool creation, vault migration and ragnarok for TRX tested in mainnet (TRC tokens only testet in public testnet):
- Deposit: https://tronscan.io/#/transaction/e1cd4454d71d8973e89155bc2c2a91aa56fd470c8ce64547ce8c69c789c21f0c
- Ragnarok: https://tronscan.io/#/transaction/fbb940ddd79ca1cfba67d638782d870b9e37162e0136cc6916ff9ef87fc1959c
If you don't want to register with tronscan, you can get the memos with something like:
txid=e1cd4454d71d8973e89155bc2c2a91aa56fd470c8ce64547ce8c69c789c21f0c
curl -sX POST https://api.trongrid.io/wallet/gettransactionbyid \
--data "{\"value\": \"$txid\", \"visible\": true}" |\
jq -r ".raw_data.data" | xxd -r -p