Skip to content

Commit 2243a84

Browse files
authored
Search for write_acknowledgement instead of recv_packet to avoid duplicated ibc packets (#1490)
1 parent 179ecff commit 2243a84

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

wormhole-connect/src/routes/cosmosGateway/utils/getMessage.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,14 @@ function getIbcTransferLog(
321321
for (const log of logs) {
322322
for (const ev of log.events) {
323323
// find an ibc received packet event
324-
if (ev.type !== 'recv_packet') continue;
324+
if (ev.type !== 'write_acknowledgement') continue;
325325

326326
// check that this packet is the one that matches the source ibc transfer
327327
// if not, skip this msg log entirely and proceed to the next one
328-
const logIbcInfo = getIBCTransferInfoFromLogs([log], 'recv_packet');
328+
const logIbcInfo = getIBCTransferInfoFromLogs(
329+
[log],
330+
'write_acknowledgement',
331+
);
329332

330333
if (
331334
logIbcInfo.sequence !== ibcTransfer.sequence ||

wormhole-connect/src/routes/cosmosGateway/utils/transaction.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { IBCTransferInfo } from '../types';
99

1010
export function getTransactionIBCTransferInfo(
1111
tx: IndexedTx,
12-
event: 'send_packet' | 'recv_packet',
12+
event: 'send_packet' | 'write_acknowledgement',
1313
): IBCTransferInfo {
1414
const logs = cosmosLogs.parseRawLog(tx.rawLog);
1515
return getIBCTransferInfoFromLogs(logs, event);
1616
}
1717

1818
export function getIBCTransferInfoFromLogs(
1919
logs: readonly cosmosLogs.Log[],
20-
event: 'send_packet' | 'recv_packet',
20+
event: 'send_packet' | 'write_acknowledgement',
2121
): IBCTransferInfo {
2222
const packetSeq = searchCosmosLogs(`${event}.packet_sequence`, logs);
2323
const packetTimeout = searchCosmosLogs(
@@ -57,10 +57,19 @@ export async function findDestinationIBCTransferTx(
5757
): Promise<IndexedTx | undefined> {
5858
const wormchainClient = await getCosmWasmClient(destChain);
5959
const destTx = await wormchainClient.searchTx([
60-
{ key: 'recv_packet.packet_sequence', value: ibcInfo.sequence },
61-
{ key: 'recv_packet.packet_timeout_timestamp', value: ibcInfo.timeout },
62-
{ key: 'recv_packet.packet_src_channel', value: ibcInfo.srcChannel },
63-
{ key: 'recv_packet.packet_dst_channel', value: ibcInfo.dstChannel },
60+
{ key: 'write_acknowledgement.packet_sequence', value: ibcInfo.sequence },
61+
{
62+
key: 'write_acknowledgement.packet_timeout_timestamp',
63+
value: ibcInfo.timeout,
64+
},
65+
{
66+
key: 'write_acknowledgement.packet_src_channel',
67+
value: ibcInfo.srcChannel,
68+
},
69+
{
70+
key: 'write_acknowledgement.packet_dst_channel',
71+
value: ibcInfo.dstChannel,
72+
},
6473
]);
6574
if (destTx.length === 0) {
6675
return undefined;

0 commit comments

Comments
 (0)