diff --git a/e2e-polybft/framework/test-cluster.go b/e2e-polybft/framework/test-cluster.go index 47526249e1..6b532af931 100644 --- a/e2e-polybft/framework/test-cluster.go +++ b/e2e-polybft/framework/test-cluster.go @@ -378,14 +378,15 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T var err error config := &TestClusterConfig{ - t: t, - WithLogs: isTrueEnv(envLogsEnabled), - WithStdout: isTrueEnv(envStdoutEnabled), - Binary: resolveBinary(), - EpochSize: 10, - EpochReward: 1, - BlockGasLimit: 1e7, // 10M - StakeAmounts: []string{}, + t: t, + WithLogs: isTrueEnv(envLogsEnabled), + WithStdout: isTrueEnv(envStdoutEnabled), + Binary: resolveBinary(), + EpochSize: 10, + EpochReward: 1, + BlockGasLimit: 1e7, // 10M + StakeAmounts: []string{}, + NumBlockConfirmations: 1, } if config.ValidatorPrefix == "" { diff --git a/tracker/event_tracker.go b/tracker/event_tracker.go index 2a2895c02e..6ecca5c926 100644 --- a/tracker/event_tracker.go +++ b/tracker/event_tracker.go @@ -12,6 +12,8 @@ import ( "github.com/umbracle/ethgo/tracker" ) +const minBlockMaxBacklog = 96 + type eventSubscription interface { AddLog(log *ethgo.Log) } @@ -63,7 +65,11 @@ func (e *EventTracker) Start(ctx context.Context) error { return err } - blockMaxBacklog := e.numBlockConfirmations*2 + 1 + blockMaxBacklog := e.numBlockConfirmations * 2 + if blockMaxBacklog < minBlockMaxBacklog { + blockMaxBacklog = minBlockMaxBacklog + } + blockTracker := blocktracker.NewBlockTracker(provider.Eth(), blocktracker.WithBlockMaxBacklog(blockMaxBacklog)) go func() { @@ -74,18 +80,24 @@ func (e *EventTracker) Start(ctx context.Context) error { // Init and start block tracker concurrently, retrying indefinitely go common.RetryForever(ctx, time.Second, func(context.Context) error { + start := time.Now().UTC() + if err := blockTracker.Init(); err != nil { e.logger.Error("failed to init blocktracker", "error", err) return err } + elapsed := time.Now().UTC().Sub(start) // Calculate the elapsed time + if err := blockTracker.Start(); err != nil { e.logger.Error("failed to start blocktracker", "error", err) return err } + e.logger.Info("Block tracker has been started", "max backlog", blockMaxBacklog, "init time", elapsed) + return nil })