Skip to content

Commit

Permalink
fix: PRT- fix routine getting stuck forever (#1314)
Browse files Browse the repository at this point in the history
* fix routine getting stuck forever

* fix labeler

* remove changes to labeler

* Update protocol/statetracker/tx_sender.go
  • Loading branch information
ranlavanet authored Mar 20, 2024
1 parent b98c2a0 commit 1f099f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion protocol/statetracker/tx_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 1f099f7

Please sign in to comment.