Skip to content

Commit

Permalink
made generate_blob_transactions & generate_Transaction tasks more…
Browse files Browse the repository at this point in the history
… resilent against RPC errors
  • Loading branch information
pk910 committed Jan 15, 2024
1 parent 715430e commit b96e460
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
34 changes: 21 additions & 13 deletions pkg/coordinator/tasks/generate_blob_transactions/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,6 @@ func (t *Task) Execute(ctx context.Context) error {
totalCount := 0

for {
if pendingChan != nil {
select {
case <-ctx.Done():
return nil
case pendingChan <- true:
}
}

txIndex := t.txIndex
t.txIndex++

Expand All @@ -187,6 +179,14 @@ func (t *Task) Execute(ctx context.Context) error {
if err != nil {
t.logger.Errorf("error generating transaction: %v", err.Error())
} else {
if pendingChan != nil {
select {
case <-ctx.Done():
return nil
case pendingChan <- true:
}
}

perBlockCount++
totalCount++
}
Expand Down Expand Up @@ -319,13 +319,21 @@ func (t *Task) generateTransaction(ctx context.Context, transactionIdx uint64, c
}
}

client := clients[transactionIdx%uint64(len(clients))]
err = nil

for i := 0; i < len(clients); i++ {
client := clients[(transactionIdx+uint64(i))%uint64(len(clients))]

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx %v: %v", transactionIdx, tx.Hash().Hex())

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx %v: %v", transactionIdx, tx.Hash().Hex())
err = client.GetRPCClient().SendTransaction(ctx, tx)
if err == nil {
break
}
}

err = client.GetRPCClient().SendTransaction(ctx, tx)
if err != nil {
return err
}
Expand Down
18 changes: 13 additions & 5 deletions pkg/coordinator/tasks/generate_transaction/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,21 @@ func (t *Task) Execute(ctx context.Context) error {
}
}

client := clients[0]
err = nil

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx: %v", tx.Hash().Hex())
for i := 0; i < len(clients); i++ {
client := clients[i%len(clients)]

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx: %v", tx.Hash().Hex())

err = client.GetRPCClient().SendTransaction(ctx, tx)
if err == nil {
break
}
}

err = client.GetRPCClient().SendTransaction(ctx, tx)
if err != nil {
return err
}
Expand Down

0 comments on commit b96e460

Please sign in to comment.