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

feat(relayer): configurable conf timeout, increase default #17880

Merged
merged 3 commits into from
Aug 6, 2024
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
10 changes: 10 additions & 0 deletions packages/relayer/cmd/flags/indexer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package flags

import (
"time"

"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -107,6 +109,13 @@ var (
Value: 0,
EnvVars: []string{"MIN_FEE_TO_INDEX"},
}
WaitForConfirmationTimeout = &cli.DurationFlag{
Name: "waitForConfirmationTimeout",
Usage: "Timeout waiting for confirmations",
Value: 5 * time.Minute,
Category: indexerCategory,
EnvVars: []string{"WAIT_FOR_CONFIRMATION_TIMEOUT"},
}
)

var IndexerFlags = MergeFlags(CommonFlags, QueueFlags, []cli.Flag{
Expand All @@ -124,4 +133,5 @@ var IndexerFlags = MergeFlags(CommonFlags, QueueFlags, []cli.Flag{
EventName,
MinFeeToIndex,
TargetBlockNumber,
WaitForConfirmationTimeout,
})
2 changes: 2 additions & 0 deletions packages/relayer/indexer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Config struct {
MinFeeToIndex uint64
OpenQueueFunc func() (queue.Queue, error)
OpenDBFunc func() (db.DB, error)
ConfirmationTimeout time.Duration
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -87,6 +88,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
BackOffMaxRetries: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
MinFeeToIndex: c.Uint64(flags.MinFeeToIndex.Name),
ConfirmationTimeout: c.Duration(flags.WaitForConfirmationTimeout.Name),
TargetBlockNumber: func() *uint64 {
if c.IsSet(flags.TargetBlockNumber.Name) {
value := c.Uint64(flags.TargetBlockNumber.Name)
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/indexer/handle_chain_data_synced_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (i *Indexer) handleChainDataSyncedEvent(

// we need to wait for confirmations to confirm this event is not being reverted,
// removed, or reorged now.
confCtx, confCtxCancel := context.WithTimeout(ctx, defaultCtxTimeout)
confCtx, confCtxCancel := context.WithTimeout(ctx, i.cfg.ConfirmationTimeout)

defer confCtxCancel()

Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/indexer/handle_message_processed_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (i *Indexer) handleMessageProcessedEvent(
if waitForConfirmations {
// we need to wait for confirmations to confirm this event is not being reverted,
// removed, or reorged now.
confCtx, confCtxCancel := context.WithTimeout(ctx, defaultCtxTimeout)
confCtx, confCtxCancel := context.WithTimeout(ctx, i.cfg.ConfirmationTimeout)

defer confCtxCancel()

Expand Down
4 changes: 1 addition & 3 deletions packages/relayer/indexer/handle_message_sent_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"math/big"
"time"

"log/slog"

Expand All @@ -17,7 +16,6 @@ import (
)

var (
defaultCtxTimeout = 3 * time.Minute
defaultConfirmations = 5
)

Expand Down Expand Up @@ -56,7 +54,7 @@ func (i *Indexer) handleMessageSentEvent(
if waitForConfirmations {
// we need to wait for confirmations to confirm this event is not being reverted,
// removed, or reorged now.
confCtx, confCtxCancel := context.WithTimeout(ctx, defaultCtxTimeout)
confCtx, confCtxCancel := context.WithTimeout(ctx, i.cfg.ConfirmationTimeout)

defer confCtxCancel()

Expand Down
Loading