Skip to content

Commit

Permalink
kickOffMining concurrent again
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam committed Sep 12, 2024
1 parent c604da0 commit 0b78ba9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"sort"
"strings"
"sync"

"github.com/ethereum-optimism/supersim/anvil"
"github.com/ethereum-optimism/supersim/config"
Expand Down Expand Up @@ -168,12 +169,22 @@ func (o *Orchestrator) kickOffMining(ctx context.Context) error {
if err := o.l1Chain.SetIntervalMining(ctx, nil, 2); err != nil {
return errors.New("failed to start interval mining on l1")
}
for _, chain := range o.l2Chains {
if err := chain.SetIntervalMining(ctx, nil, 2); err != nil {
return fmt.Errorf("failed to start interval mining for chain %s", chain.Config().Name)
}

var wg sync.WaitGroup
wg.Add(len(o.l2Chains))

errs := make([]error, len(o.l2Chains))
for i, chain := range o.l2Chains {
go func(i uint64) {
if err := chain.SetIntervalMining(ctx, nil, 2); err != nil {
errs[i] = fmt.Errorf("failed to start interval mining for chain %s", chain.Config().Name)
}

wg.Done()
}(i)
}
return nil

return errors.Join(errs...)
}

func (o *Orchestrator) L1Chain() config.Chain {
Expand Down

0 comments on commit 0b78ba9

Please sign in to comment.