Commit 11a6a988 authored by Conner Fromknecht's avatar Conner Fromknecht

feat: consolidate batch_build_time benchmarking code

parent b64628ec
......@@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"strings"
"time"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/scc"
......@@ -167,8 +166,6 @@ func (d *Driver) CraftBatchTx(
log.Info(name+" crafting batch tx", "start", start, "end", end,
"nonce", nonce)
batchTxBuildStart := time.Now()
var (
stateRoots [][stateRootSize]byte
totalStateRootSize uint64
......@@ -188,8 +185,6 @@ func (d *Driver) CraftBatchTx(
stateRoots = append(stateRoots, block.Root())
}
batchTxBuildTime := float64(time.Since(batchTxBuildStart) / time.Millisecond)
d.metrics.BatchTxBuildTime.Set(batchTxBuildTime)
d.metrics.NumElementsPerBatch.Observe(float64(len(stateRoots)))
log.Info(name+" batch constructed", "num_state_roots", len(stateRoots))
......
......@@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"strings"
"time"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc"
"github.com/ethereum-optimism/optimism/go/batch-submitter/drivers"
......@@ -164,8 +163,6 @@ func (d *Driver) CraftBatchTx(
log.Info(name+" crafting batch tx", "start", start, "end", end,
"nonce", nonce)
batchTxBuildStart := time.Now()
var (
batchElements []BatchElement
totalTxSize uint64
......@@ -223,9 +220,6 @@ func (d *Driver) CraftBatchTx(
continue
}
// Record the batch_tx_build_time.
batchTxBuildTime := float64(time.Since(batchTxBuildStart) / time.Millisecond)
d.metrics.BatchTxBuildTime.Set(batchTxBuildTime)
d.metrics.NumElementsPerBatch.Observe(float64(len(batchElements)))
d.metrics.BatchPruneCount.Set(float64(pruneCount))
......
......@@ -171,6 +171,7 @@ func (s *Service) eventLoop() {
}
nonce := new(big.Int).SetUint64(nonce64)
batchTxBuildStart := time.Now()
tx, err := s.cfg.Driver.CraftBatchTx(
s.ctx, start, end, nonce,
)
......@@ -179,6 +180,8 @@ func (s *Service) eventLoop() {
"err", err)
continue
}
batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond
s.metrics.BatchTxBuildTime.Set(float64(batchTxBuildTime))
// Construct the transaction submission clousure that will attempt
// to send the next transaction at the given nonce and gas price.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment