Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayer): revert func WaitConfirmations should not wait forever for ethereum.NotFound #16554

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/relayer/processor/process_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (p *Processor) processMessage(

slog.Info("waiting for confirmations",
"msgHash", common.BytesToHash(msgBody.Event.MsgHash[:]).Hex(),
"txHash", msgBody.Event.Raw.TxHash,
)

if err := p.waitForConfirmations(ctx, msgBody.Event.Raw.TxHash, msgBody.Event.Raw.BlockNumber); err != nil {
Expand Down
14 changes: 2 additions & 12 deletions packages/relayer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ var (

// WaitConfirmations won't return before N blocks confirmations have been seen
// on destination chain, or context is cancelled.
// txHash is from Raw.TxHash in event or SignalServiceChainDataSynced.
func WaitConfirmations(ctx context.Context, confirmer confirmer, confirmations uint64, txHash common.Hash) error {
notFoundCount := 0

checkConfs := func() error {
receipt, err := confirmer.TransactionReceipt(ctx, txHash)
if err != nil {
Expand All @@ -86,7 +83,7 @@ func WaitConfirmations(ctx context.Context, confirmer confirmer, confirmations u
want := receipt.BlockNumber.Uint64() + confirmations

if latest < want {
slog.Info("waiting for confirmations", "latestBlockNum", latest, "wantBlockNum", want, "txHash", txHash.Hex())
slog.Info("waiting for confirmations", "latestBlockNum", latest, "wantBlockNum", want)

return errStillWaiting
}
Expand All @@ -110,14 +107,7 @@ func WaitConfirmations(ctx context.Context, confirmer confirmer, confirmations u
return ctx.Err()
case <-ticker.C:
if err := checkConfs(); err != nil {
if err == ethereum.NotFound {
notFoundCount++
if notFoundCount >= 10 {
return err
}

continue
} else if err == errStillWaiting {
if err == ethereum.NotFound || err == errStillWaiting {
continue
}

Expand Down
Loading