From 1f099f7e572bc20f8d390a2eccf0685dc1a7346c Mon Sep 17 00:00:00 2001 From: Ran Mishael <106548467+ranlavanet@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:05:42 +0100 Subject: [PATCH] fix: PRT- fix routine getting stuck forever (#1314) * fix routine getting stuck forever * fix labeler * remove changes to labeler * Update protocol/statetracker/tx_sender.go --- protocol/statetracker/tx_sender.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/protocol/statetracker/tx_sender.go b/protocol/statetracker/tx_sender.go index 8712c1927d..4049efafc5 100644 --- a/protocol/statetracker/tx_sender.go +++ b/protocol/statetracker/tx_sender.go @@ -215,9 +215,14 @@ func (ts *TxSender) waitForTxCommit(resultData common.TxResultData) (common.TxRe txResultChan := make(chan *coretypes.ResultTx) guid := utils.GenerateUniqueIdentifier() // check consumer session manager + timeOutReached := false go func() { for { - ctx, cancel := context.WithTimeout(utils.WithUniqueIdentifier(context.Background(), guid), 3*time.Second) + if timeOutReached { + utils.LavaFormatWarning("Timeout waiting for transaction", nil, utils.LogAttr("hash", resultData.Txhash)) + return + } + ctx, cancel := context.WithTimeout(utils.WithUniqueIdentifier(context.Background(), guid), 5*time.Second) result, err := clientCtx.Client.Tx(ctx, resultData.Txhash, false) cancel() if err == nil { @@ -242,6 +247,7 @@ func (ts *TxSender) waitForTxCommit(resultData common.TxResultData) (common.TxRe utils.LavaFormatDebug("Tx Hash found on blockchain", utils.LogAttr("Txhash", hex.EncodeToString(resultData.Txhash)), utils.LogAttr("Code", resultData.Code)) break case <-time.After(5 * time.Minute): + timeOutReached = true return common.TxResultData{}, utils.LavaFormatError("failed sending tx, wasn't found after timeout", nil, utils.Attribute{Key: "hash", Value: hex.EncodeToString(resultData.Txhash)}) } // we found the tx on chain and it failed