Skip to content

Commit

Permalink
Fix retrier logic for monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 11, 2024
1 parent b920238 commit 23ef837
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions zetaclient/zetacore/client_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Client) MonitorVoteOutboundResult(
}()

call := func() error {
return c.monitorVoteOutboundResult(ctx, zetaTxHash, retryGasLimit, msg)
return retry.Retry(c.monitorVoteOutboundResult(ctx, zetaTxHash, retryGasLimit, msg))
}

err := retryWithBackoff(call, monitorRetryCount, monitorInterval/2, monitorInterval)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (c *Client) MonitorVoteInboundResult(
}()

call := func() error {
return c.monitorVoteInboundResult(ctx, zetaTxHash, retryGasLimit, msg)
return retry.Retry(c.monitorVoteInboundResult(ctx, zetaTxHash, retryGasLimit, msg))
}

err := retryWithBackoff(call, monitorRetryCount, monitorInterval/2, monitorInterval)
Expand Down
19 changes: 13 additions & 6 deletions zetaclient/zetacore/client_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/zeta-chain/zetacore/pkg/retry"
"github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
zctx "github.com/zeta-chain/zetacore/zetaclient/context"
)

// PostVoteBlockHeader posts a vote on an observed block header
Expand Down Expand Up @@ -171,9 +172,12 @@ func (c *Client) PostVoteOutbound(
}

go func() {
// Ideally we need to bump go to v1.21+ and use context.WithoutCancel(...)
anotherCtx := context.Background()
_ = c.MonitorVoteOutboundResult(anotherCtx, zetaTxHash, retryGasLimit, msg)
ctxForWorker := zctx.Copy(ctx, context.Background())

errMonitor := c.MonitorVoteOutboundResult(ctxForWorker, zetaTxHash, retryGasLimit, msg)
if errMonitor != nil {
c.logger.Error().Err(err).Msg("PostVoteOutbound: failed to monitor vote outbound result")
}
}()

return zetaTxHash, ballotIndex, nil
Expand Down Expand Up @@ -215,9 +219,12 @@ func (c *Client) PostVoteInbound(
}

go func() {
// Ideally we need to bump go to v1.21+ and use context.WithoutCancel(...)
anotherCtx := context.Background()
_ = c.MonitorVoteInboundResult(anotherCtx, zetaTxHash, retryGasLimit, msg)
ctxForWorker := zctx.Copy(ctx, context.Background())

errMonitor := c.MonitorVoteInboundResult(ctxForWorker, zetaTxHash, retryGasLimit, msg)
if errMonitor != nil {
c.logger.Error().Err(err).Msg("PostVoteInbound: failed to monitor vote inbound result")
}
}()

return zetaTxHash, ballotIndex, nil
Expand Down

0 comments on commit 23ef837

Please sign in to comment.