diff --git a/tests/reexecute/c/vm_reexecute_test.go b/tests/reexecute/c/vm_reexecute_test.go index 63b32eb2b80d..9cb3dc9028f8 100644 --- a/tests/reexecute/c/vm_reexecute_test.go +++ b/tests/reexecute/c/vm_reexecute_test.go @@ -335,9 +335,10 @@ type vmExecutorConfig struct { } type vmExecutor struct { - config vmExecutorConfig - vm block.ChainVM - metrics *consensusMetrics + config vmExecutorConfig + vm block.ChainVM + metrics *consensusMetrics + etaTracker *timer.EtaTracker } func newVMExecutor(vm block.ChainVM, config vmExecutorConfig) (*vmExecutor, error) { @@ -350,6 +351,10 @@ func newVMExecutor(vm block.ChainVM, config vmExecutorConfig) (*vmExecutor, erro vm: vm, metrics: metrics, config: config, + // ETA tracker uses a 10-sample moving window to smooth rate estimates, + // and a 1.2 slowdown factor to slightly pad ETA early in the run, + // tapering to 1.0 as progress approaches 100%. + etaTracker: timer.NewEtaTracker(10, 1.2), }, nil } @@ -386,6 +391,10 @@ func (e *vmExecutor) executeSequence(ctx context.Context, blkChan <-chan blockRe zap.Uint64("height", blk.Height()), ) + // Initialize ETA tracking with a baseline sample at 0 progress + totalWork := e.config.EndBlock - e.config.StartBlock + e.etaTracker.AddSample(0, totalWork, start) + if e.config.ExecutionTimeout > 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, e.config.ExecutionTimeout) @@ -398,15 +407,20 @@ func (e *vmExecutor) executeSequence(ctx context.Context, blkChan <-chan blockRe } if blkResult.Height%1000 == 0 { - eta := timer.EstimateETA( - start, - blkResult.Height-e.config.StartBlock, - e.config.EndBlock-e.config.StartBlock, - ) - e.config.Log.Info("executing block", - zap.Uint64("height", blkResult.Height), - zap.Duration("eta", eta), - ) + completed := blkResult.Height - e.config.StartBlock + etaPtr, progressPercentage := e.etaTracker.AddSample(completed, totalWork, time.Now()) + if etaPtr != nil { + e.config.Log.Info("executing block", + zap.Uint64("height", blkResult.Height), + zap.Float64("progress_pct", progressPercentage), + zap.Duration("eta", *etaPtr), + ) + } else { + e.config.Log.Info("executing block", + zap.Uint64("height", blkResult.Height), + zap.Float64("progress_pct", progressPercentage), + ) + } } if err := e.execute(ctx, blkResult.BlockBytes); err != nil { return err