hermes crashes on clear packets when full node indexing #851
Closed
Description
Crate
relayer
Summary of Bug
When hermes is started immediately after a packet send, it is possible that query_tx()
does not find the Tx for the send or ack packets if full node indexing is not finished. This bug was introduced by informalsystems/ibc-rs#827.
Version
master
Steps to Reproduce
- setup a channel using
hermes create channel...
betweenibc-0
andibc-1
- from one terminal issue
hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 150 -n 1
- from another terminal
hermes start ibc-0 ibc-1 -p transfer -c channel-0
time between 2 and 3 should be very small, otherwise the bug cannot be reproduced. The logs look like this:
Apr 26 19:15:13.046 INFO ibc_relayer::link: [ibc-1 -> ibc-0] clearing old packets
Apr 26 19:15:13.052 DEBUG ibc_relayer::link: [ibc-1 -> ibc-0] packets that have acknowledgments on ibc-1 [1, 15, 2]
Apr 26 19:15:13.054 DEBUG ibc_relayer::link: [ibc-1 -> ibc-0] ack packets to send out to ibc-0 of the ones with acknowledgments on ibc-1: [Sequence(15)]
The application panicked (crashed).
Message: index out of bounds: the len is 0 but the index is 0
Location: relayer/src/chain/cosmos.rs:1001
Acceptance Criteria
- hermes should not crash. A quick try with the diffs below avoids the crash
+++ b/relayer/src/chain/cosmos.rs
@@ -992,6 +992,10 @@ impl Chain for CosmosSdkChain {
"packet_from_tx_search_response: unexpected number of txs"
);
+ if response.txs.is_empty() {
+ continue;
+ }
+
if let Some(event) = packet_from_tx_search_response(
self.id(),
&request,
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate milestone (priority) applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned