Skip to content

Commit

Permalink
chore: packet timeout after relayer update
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksharmapoudel committed Jun 30, 2023
1 parent 4b4ccfb commit 3c913ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
1 change: 0 additions & 1 deletion relayer/chains/archway/helper_debug_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func jsonDumpDataFile(filename string, bufs interface{}) {
os.Exit(1)
}

fmt.Printf("Successfully created or appended JSON in %s \n", filename)
}

func readExistingData(filename string, opPointer interface{}) error {
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/archway/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ func (ap *ArchwayProvider) QueryPacketReceipt(ctx context.Context, height int64,
}

pktReceipt, err := ap.QueryIBCHandlerContract(ctx, pktReceiptParams)
if err != nil && !strings.Contains(err.Error(), "PacketCommitmentNotFound") {
if err != nil && !strings.Contains(err.Error(), "PacketReceiptNotFound") {
return nil, err
}

Expand Down
8 changes: 5 additions & 3 deletions relayer/chains/archway/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ func (ap *ArchwayProvider) SendMessagesToMempool(
ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, false)
}

//uncomment for saving msg
SaveMsgToFile(ArchwayDebugMessagePath, msgs)

return nil

}
Expand Down Expand Up @@ -1004,6 +1007,8 @@ func (ap *ArchwayProvider) BroadcastTx(
ap.log.Info("Submitted transaction",
zap.String("chain_id", ap.PCfg.ChainID),
zap.String("txHash", res.TxHash),
zap.Int64("Height", res.Height),
zap.Any("Methods called", msgTypesField(msgs)),
)

if shouldWait {
Expand Down Expand Up @@ -1046,9 +1051,6 @@ func (ap *ArchwayProvider) waitForTx(
return
}

//uncomment for saving msg
SaveMsgToFile(ArchwayDebugMessagePath, msgs)

rlyResp := &provider.RelayerTxResponse{
Height: res.Height,
TxHash: res.TxHash,
Expand Down
26 changes: 14 additions & 12 deletions relayer/processor/path_processor_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages(
deletePreInitIfMatches(info)
toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq)
toDeleteSrc[chantypes.EventTypeTimeoutPacket] = append(toDeleteSrc[chantypes.EventTypeTimeoutPacket], seq)
toDeleteSrc[common.EventTimeoutRequest] = append(toDeleteSrc[common.EventTimeoutRequest], seq)
toDeleteDst[common.EventTimeoutRequest] = append(toDeleteDst[common.EventTimeoutRequest], seq)
if info.ChannelOrder == chantypes.ORDERED.String() {
// Channel is now closed on src.
// enqueue channel close init observation to be handled by channel close correlation
Expand All @@ -206,16 +206,6 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages(

processRemovals()

for _, msgTimeoutRequest := range pathEndPacketFlowMessages.DstMsgRequestTimeout {
timeoutMsg := packetIBCMessage{
eventType: chantypes.EventTypeTimeoutPacket,
info: msgTimeoutRequest,
}
msgs = append(msgs, timeoutMsg)
}

// todo: need removals ?

for seq, info := range pathEndPacketFlowMessages.DstMsgRecvPacket {
deletePreInitIfMatches(info)
toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq)
Expand All @@ -234,6 +224,17 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages(

processRemovals()

for seq, msgTimeoutRequest := range pathEndPacketFlowMessages.DstMsgRequestTimeout {
toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq)
toDeleteDst[common.EventTimeoutRequest] = append(toDeleteDst[common.EventTimeoutRequest], seq)
timeoutMsg := packetIBCMessage{
eventType: chantypes.EventTypeTimeoutPacket,
info: msgTimeoutRequest,
}
msgs = append(msgs, timeoutMsg)
}
processRemovals()

for _, info := range pathEndPacketFlowMessages.SrcMsgTransfer {
deletePreInitIfMatches(info)

Expand All @@ -244,6 +245,7 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages(
var timeoutOnCloseErr *provider.TimeoutOnCloseError

if pathEndPacketFlowMessages.Dst.chainProvider.Type() == common.IconModule {

switch {
case errors.As(err, &timeoutHeightErr) || errors.As(err, &timeoutTimestampErr):
timeoutRequestMsg := packetIBCMessage{
Expand All @@ -258,7 +260,7 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages(
zap.Error(err),
)
}

continue
}

switch {
Expand Down

0 comments on commit 3c913ac

Please sign in to comment.