From 286278b69072478f2d6ee9aa29d8243046cbd359 Mon Sep 17 00:00:00 2001 From: Ron Kuris Date: Thu, 25 Sep 2025 17:16:21 -0700 Subject: [PATCH 1/2] feat: Use the new ETA tracker for load tests Replaced the deprecated EstimateETA function with EtaTracker. --- tests/reexecute/c/vm_reexecute_test.go | 39 ++++++++++++++++---------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tests/reexecute/c/vm_reexecute_test.go b/tests/reexecute/c/vm_reexecute_test.go index 63b32eb2b80d..4584d3641f51 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) { @@ -347,9 +348,10 @@ func newVMExecutor(vm block.ChainVM, config vmExecutorConfig) (*vmExecutor, erro } return &vmExecutor{ - vm: vm, - metrics: metrics, - config: config, + vm: vm, + metrics: metrics, + config: config, + etaTracker: timer.NewEtaTracker(10, 1.2), }, nil } @@ -386,6 +388,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 +404,18 @@ 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, _ := e.etaTracker.AddSample(completed, totalWork, time.Now()) + if etaPtr != nil { + e.config.Log.Info("executing block", + zap.Uint64("height", blkResult.Height), + zap.Duration("eta", *etaPtr), + ) + } else { + e.config.Log.Info("executing block", + zap.Uint64("height", blkResult.Height), + ) + } } if err := e.execute(ctx, blkResult.BlockBytes); err != nil { return err From 0fdfb2c4ecf0549e93d9e71fb1e53a49a6f0966c Mon Sep 17 00:00:00 2001 From: Ron Kuris Date: Thu, 25 Sep 2025 17:23:12 -0700 Subject: [PATCH 2/2] Copilot comments addressed --- tests/reexecute/c/vm_reexecute_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/reexecute/c/vm_reexecute_test.go b/tests/reexecute/c/vm_reexecute_test.go index 4584d3641f51..9cb3dc9028f8 100644 --- a/tests/reexecute/c/vm_reexecute_test.go +++ b/tests/reexecute/c/vm_reexecute_test.go @@ -348,9 +348,12 @@ func newVMExecutor(vm block.ChainVM, config vmExecutorConfig) (*vmExecutor, erro } return &vmExecutor{ - vm: vm, - metrics: metrics, - config: config, + 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 } @@ -405,15 +408,17 @@ func (e *vmExecutor) executeSequence(ctx context.Context, blkChan <-chan blockRe if blkResult.Height%1000 == 0 { completed := blkResult.Height - e.config.StartBlock - etaPtr, _ := e.etaTracker.AddSample(completed, totalWork, time.Now()) + 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), ) } }