tendermint / liquidity

Cosmos SDK Liquidity module
Apache License 2.0
135 stars 56 forks source link

Accessing swap status after a batch has been processed #427

Open konnov opened 3 years ago

konnov commented 3 years ago

Summary

It is hard to access the status of a swap (or deposit, or withdrawal) after the corresponding batch has been processed.

Surfaced from @informalsystems audit of v1.2.8.

Problem Definition

The liquidity module allows the user to place swap orders (as well as deposit and withdrawal orders) in the command line. However, once an order has been placed, the status of this order is not shown in the corresponding transaction. Indeed, the orders are processed in a batch. The user can query the order status with gaiad query liquidity swaps <pool-id>. This works until the order is processed within the corresponding batch. There is a very short time window of one block, when the user can observe that the order has been executed. Once the order has been processed, it cannot be found any longer.

This is aggravated by the fact that the orders are processed in EndBlocker and cannot be queried with gaiad query txs. The only working solution (suggested by the team) is to find the block, where the order has been processed, e.g.,

http://localhost:26657/block_search?query=%22swap_transacted.msg_index=%271%27%20AND%20swap_transacted.pool_id=%271%27%22

and then inspect end_block_events by querying http://localhost:26657/block_results?height=....

While this approach works, it makes testing and debugging error-prone. Basically, one has to write a script to retrieve end_block_events, decode base64, etc.

Proposal

Make the status of the orders accessible via the command line interface. As events may be periodically pruned by nodes, it is probably hard to guarantee that the status would be accessible on every node. However, the status could be made accessible without a reasonable time window. Also, it could be accessible on an archival node.


For Admin Use