[BUG] Add Tx to signer cache only when broadcast successfully

Related to #1288 (closed) There are two issues on terra client

  1. Some outbound transactions are stuck in outbound queue, as bifrost signer cache refuse to double sign it. The root cause for this issue is because bifrost will consider Code: 19, tx already in mempool and Code: 32,incorrect account sequence as broadcast success, thus add the transaction into signer cache , after that bifrost won't sign the same transaction again.

But in reality , when Code:32 , highly likely the transaction is not success , thus should be retried. The solution for this one ,is only add transaction to signer cache when broadcast has code:0 , which means is success.

  1. It often hit an issue with incorrect account sequence issue.

The root cause for this issue is Terra is having about 6 seconds block , and everytime when bifrost sign a transaction , it will fetch account sequence from terra daemon, however if transaction is in mempool , the sequence no is not increased yet , thus on chain sequence # can be lower than what is real , thus override local sequence # , cause the next transaction to fail.

The solution for this issue is , only override local sequence # when on chain sequence # is larger than local, otherwise consider there are transaction in mempool

Edited by Heimdall

Merge request reports

Loading