[bug] manage_thorname failures cause asgard insolvency
Failed thorname transactions cause a rune insolvency on the asgard module. Rune sent for the thorname fee is transferred to the reserve. On failure, that rune is refunded properly but it transfers the native outbound fee from asgard to the reserve (when it should actually do nothing). This is only the case for thornames and reserve contributions (and only thorname can actually err).
Here's the code: https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L651-659
Think the else should be changed to else if toi.ModuleName == AsgardName
or maybe change to send from toi.ModuleName to ReserveName.
The funds remain safe on the protocol, they are just on the wrong module.
{{ template "default-state.yaml" }}
---
{{ template "btc-eth-pool-state.yaml" }}
---
type: create-blocks
count: 1
---
type: tx-deposit
description: invalid memo for thorname causes asgard break
signer: {{ addr_thor_fox }}
coins:
- amount: "5000000000"
asset: "rune"
memo: "~:"
---
type: create-blocks
count: 1
---
type: check
description: ensure asgard invariant
endpoint: http://localhost:1317/thorchain/invariant/asgard
asserts:
- .broken == false
5:39PM INF ../../x/thorchain/handler_deposit.go:60 > receive MsgDeposit coins=[{"amount":"5000000000","asset":"THOR.RUNE"}] from=tthor13wrmhnh2qe98rjse30pl7u6jxszjjwl4f6yycr memo=~:
5:39PM ERR ../../x/thorchain/handler.go:259 > fail to parse memo error="MEMO: ~:\nPARSE FAILURE(S): cannot parse '' as a chain: chain id len is less than 3-not enough parameters: 2/3"
5:39PM ERR ../../x/thorchain/handler_deposit.go:156 > fail to process native inbound tx error="MEMO: ~:\nPARSE FAILURE(S): cannot parse '' as a chain: chain id len is less than 3-not enough parameters: 2/3" tx hash=C294B2457D6DC79E4E862BEA52607AFCBC8E568F74D793410DD0CDA359ACE786
5:39PM ERR ../../x/thorchain/manager_txout_current.go:576 > fail to get vault error="vault with pubkey() doesn't exist: vault not found"
5:39PM INF ../../x/thorchain/handler_refund.go:30 > receive MsgRefund tx ID=C294B2457D6DC79E4E862BEA52607AFCBC8E568F74D793410DD0CDA359ACE786
5:39PM INF ../../../go/pkg/mod/github.com/tendermint/tendermint@v0.34.14/state/execution.go:235 > committed state app_hash=4632852271BE207D6D5CEC28ADB30F0EBA6A15B62350A0F5E13D694CD584716B height=2 module=state num_txs=1
5:39PM INF cmd/run.go:275 > >>> [6] check line=19
Operation:
type: check
description: ensure asgard invariant
endpoint: http://localhost:1317/thorchain/invariant/asgard
params: {}
status: 200
asserts:
- .broken == false
Failed Assert: .broken == false
Endpoint Response:
{
"broken": true,
"invariant": "asgard",
"msg": "insolvent: 2000000rune\n"
}
Edited by akrokr