Skip to content

Commit bdf49f1

Browse files
authored
chore: misc qol improvements (#140)
1 parent 3cf2d5f commit bdf49f1

4 files changed

Lines changed: 41 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ coverage/
1919
node_modules
2020
yarn-debug.log*
2121
yarn-error.log*
22+
.env*.local

runner/benchmark/definition.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path"
9+
"path/filepath"
910
"strings"
1011

1112
"github.com/base/base-bench/runner/payload"
@@ -63,7 +64,9 @@ func (s SnapshotDefinition) CreateSnapshot(nodeType string, outputDir string) er
6364
return fmt.Errorf("failed to get absolute path of outputDir: %w", err)
6465
}
6566

66-
outputDir = path.Join(currentDir, outputDir)
67+
if !filepath.IsAbs(outputDir) {
68+
outputDir = path.Join(currentDir, outputDir)
69+
}
6770

6871
var cmdBin string
6972
var args []string

runner/network/consensus/sequencer_consensus.go

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/ethereum/go-ethereum/log"
2727
"github.com/ethereum/go-ethereum/rpc"
2828
"github.com/pkg/errors"
29+
"golang.org/x/sync/errgroup"
2930
)
3031

3132
// SequencerConsensusClient is a fake consensus client that generates blocks on a timer.
@@ -208,28 +209,42 @@ func (f *SequencerConsensusClient) Propose(ctx context.Context, blockMetrics *me
208209
sendCallsPerBatch := 100
209210
batches := (len(sendTxs) + sendCallsPerBatch - 1) / sendCallsPerBatch
210211

211-
for i := 0; i < batches; i++ {
212-
batch := sendTxs[i*sendCallsPerBatch : min((i+1)*sendCallsPerBatch, len(sendTxs))]
213-
results := make([]interface{}, len(batch))
214-
215-
batchCall := make([]rpc.BatchElem, len(batch))
216-
for j, tx := range batch {
217-
batchCall[j] = rpc.BatchElem{
218-
Method: "eth_sendRawTransaction",
219-
Args: []interface{}{hexutil.Encode(tx)},
220-
Result: &results[j],
221-
}
212+
// Process batches in parallel, 4 at a time
213+
parallelBatches := 4
214+
for i := 0; i < batches; i += parallelBatches {
215+
g, gCtx := errgroup.WithContext(ctx)
216+
217+
for j := 0; j < parallelBatches && i+j < batches; j++ {
218+
batchIdx := i + j
219+
g.Go(func() error {
220+
batch := sendTxs[batchIdx*sendCallsPerBatch : min((batchIdx+1)*sendCallsPerBatch, len(sendTxs))]
221+
results := make([]interface{}, len(batch))
222+
223+
batchCall := make([]rpc.BatchElem, len(batch))
224+
for k, tx := range batch {
225+
batchCall[k] = rpc.BatchElem{
226+
Method: "eth_sendRawTransaction",
227+
Args: []interface{}{hexutil.Encode(tx)},
228+
Result: &results[k],
229+
}
230+
}
231+
232+
err := f.client.Client().BatchCallContext(gCtx, batchCall)
233+
if err != nil {
234+
return errors.Wrap(err, "failed to send transactions")
235+
}
236+
237+
for _, tx := range batchCall {
238+
if tx.Error != nil {
239+
return errors.Wrapf(tx.Error, "failed to send transaction %#v", tx.Args[0])
240+
}
241+
}
242+
return nil
243+
})
222244
}
223245

224-
err := f.client.Client().BatchCallContext(ctx, batchCall)
225-
if err != nil {
226-
return nil, errors.Wrap(err, "failed to send transactions")
227-
}
228-
229-
for _, tx := range batchCall {
230-
if tx.Error != nil {
231-
return nil, errors.Wrapf(tx.Error, "failed to send transaction %#v", tx.Args[0])
232-
}
246+
if err := g.Wait(); err != nil {
247+
return nil, err
233248
}
234249
}
235250

runner/network/consensus/validator_consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (f *SyncingConsensusClient) propose(ctx context.Context, payload *engine.Ex
3333

3434
root := crypto.Keccak256Hash([]byte("fake-beacon-block-root"), big.NewInt(1).Bytes())
3535

36-
f.log.Info("Validate payload", "payload_index", payload.Number)
36+
f.log.Info("Validate payload", "payload_index", payload.Number, "num_txs", len(payload.Transactions))
3737
startTime := time.Now()
3838
err := f.newPayload(ctx, payload, root)
3939
if err != nil {

0 commit comments

Comments
 (0)