From 167297f83b7975b802f6b047d44635d53a034175 Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Wed, 22 Jul 2026 11:58:14 -0700 Subject: [PATCH] devtool: complete raced round initialization fix The prior fix in #3970 only handled transactions that reverted after submission. Also tolerate initializeRound failures during gas estimation when another initializer has already completed the round. --- cmd/devtool/devtool/devtool_utils.go | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/cmd/devtool/devtool/devtool_utils.go b/cmd/devtool/devtool/devtool_utils.go index af9d76b8d9..530c24939e 100644 --- a/cmd/devtool/devtool/devtool_utils.go +++ b/cmd/devtool/devtool/devtool_utils.go @@ -283,28 +283,34 @@ func (d *Devtool) InitializeRound() error { // ErrRoundInitialized if err != nil { if err.Error() != "ErrRoundInitialized" { - glog.Errorf("Error initializing round: %v", err) - return err + return tolerateInitializedRound(d.Client, err) } } else { err = d.Client.CheckTx(tx) if err != nil { - initialized, initErr := d.Client.CurrentRoundInitialized() - if initErr == nil && initialized { - glog.Infof("Round initialized despite failed transaction: %v", err) - return nil - } - if initErr != nil { - glog.Errorf("Error checking initialized round after failed transaction: %v", initErr) - } - glog.Errorf("Error initializing round: %v", err) - return err + return tolerateInitializedRound(d.Client, err) } } glog.Info("Done initializing round.") return nil } +// tolerateInitializedRound treats a failed initialization as successful when +// another initializer completed the same round concurrently. The transaction +// can fail either during gas estimation or after it has been mined. +func tolerateInitializedRound(client eth.LivepeerEthClient, initErr error) error { + initialized, err := client.CurrentRoundInitialized() + if err == nil && initialized { + glog.Infof("Round initialized despite failed transaction: %v", initErr) + return nil + } + if err != nil { + glog.Errorf("Error checking initialized round after failed transaction: %v", err) + } + glog.Errorf("Error initializing round: %v", initErr) + return initErr +} + func (d *Devtool) RegisterOrchestrator(cfg DevtoolConfig) error { glog.Info("Activating orchestrator") // curl -d "blockRewardCut=10&feeShare=5&amount=500" --data-urlencode "serviceURI=https://$transcoderServiceAddr" \