Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cmd/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ func generateReport(ctx context.Context, ec *ethrpc.Client, report *BlockReport,
// Start worker goroutines
var wg sync.WaitGroup
for range concurrency {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for req := range blockChan {
// Check if worker context is canceled
if workerCtx.Err() != nil {
Expand Down Expand Up @@ -329,7 +327,7 @@ func generateReport(ctx context.Context, ec *ethrpc.Client, report *BlockReport,
close(retryChan) // No more retries needed
}
}
}()
})
}

// Monitor goroutine to close blockChan when all work is done
Expand Down
24 changes: 8 additions & 16 deletions loadtest/gasmanager/gas_vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ func TestGasVault_ConcurrentAccess(t *testing.T) {

// Spawn multiple goroutines trying to spend gas concurrently
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
err := vault.SpendOrWaitAvailableBudget(ctx, spendAmount)
if err != nil {
errors <- err
}
}()
})
}

wg.Wait()
Expand Down Expand Up @@ -229,24 +227,20 @@ func TestGasVault_ConcurrentAddAndSpend(t *testing.T) {

// Adders
for i := 0; i < numAdders; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
vault.AddGas(addAmount)
}()
})
}

// Spenders
errors := make(chan error, numSpenders)
for i := 0; i < numSpenders; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
err := vault.SpendOrWaitAvailableBudget(ctx, spendAmount)
if err != nil {
errors <- err
}
}()
})
}

wg.Wait()
Expand Down Expand Up @@ -278,14 +272,12 @@ func TestGasVault_MultipleSpendersWaiting(t *testing.T) {

// Start multiple spenders that will all wait
for i := 0; i < numSpenders; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
err := vault.SpendOrWaitAvailableBudget(ctx, spendAmount)
if err == nil {
successCount <- 1
}
}()
})
}

// Give goroutines time to start waiting
Expand Down
12 changes: 4 additions & 8 deletions loadtest/preconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ func (pt *PreconfTracker) Track(txHash common.Hash) {
var preconfStatus bool
var preconfError error
var preconfDuration time.Duration
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {

preconfStartTime := time.Now()
defer func() {
preconfDuration = time.Since(preconfStartTime)
}()

preconfStatus, preconfError = util.WaitPreconf(context.Background(), pt.client, txHash, time.Minute)
}()
})

// wait for receipt
var receipt *types.Receipt
var receiptError error
var receiptDuration time.Duration
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {

time.Sleep(100 * time.Millisecond)

Expand All @@ -129,7 +125,7 @@ func (pt *PreconfTracker) Track(txHash common.Hash) {
}()

receipt, receiptError = util.WaitReceiptWithTimeout(context.Background(), pt.client, txHash, time.Minute)
}()
})

wg.Wait()

Expand Down