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

feat: consolidate batch_build_time benchmarking code

parent b64628ec
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"strings" "strings"
"time"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc" "github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/scc" "github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/scc"
...@@ -167,8 +166,6 @@ func (d *Driver) CraftBatchTx( ...@@ -167,8 +166,6 @@ func (d *Driver) CraftBatchTx(
log.Info(name+" crafting batch tx", "start", start, "end", end, log.Info(name+" crafting batch tx", "start", start, "end", end,
"nonce", nonce) "nonce", nonce)
batchTxBuildStart := time.Now()
var ( var (
stateRoots [][stateRootSize]byte stateRoots [][stateRootSize]byte
totalStateRootSize uint64 totalStateRootSize uint64
...@@ -188,8 +185,6 @@ func (d *Driver) CraftBatchTx( ...@@ -188,8 +185,6 @@ func (d *Driver) CraftBatchTx(
stateRoots = append(stateRoots, block.Root()) stateRoots = append(stateRoots, block.Root())
} }
batchTxBuildTime := float64(time.Since(batchTxBuildStart) / time.Millisecond)
d.metrics.BatchTxBuildTime.Set(batchTxBuildTime)
d.metrics.NumElementsPerBatch.Observe(float64(len(stateRoots))) d.metrics.NumElementsPerBatch.Observe(float64(len(stateRoots)))
log.Info(name+" batch constructed", "num_state_roots", len(stateRoots)) log.Info(name+" batch constructed", "num_state_roots", len(stateRoots))
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"strings" "strings"
"time"
"github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc" "github.com/ethereum-optimism/optimism/go/batch-submitter/bindings/ctc"
"github.com/ethereum-optimism/optimism/go/batch-submitter/drivers" "github.com/ethereum-optimism/optimism/go/batch-submitter/drivers"
...@@ -164,8 +163,6 @@ func (d *Driver) CraftBatchTx( ...@@ -164,8 +163,6 @@ func (d *Driver) CraftBatchTx(
log.Info(name+" crafting batch tx", "start", start, "end", end, log.Info(name+" crafting batch tx", "start", start, "end", end,
"nonce", nonce) "nonce", nonce)
batchTxBuildStart := time.Now()
var ( var (
batchElements []BatchElement batchElements []BatchElement
totalTxSize uint64 totalTxSize uint64
...@@ -223,9 +220,6 @@ func (d *Driver) CraftBatchTx( ...@@ -223,9 +220,6 @@ func (d *Driver) CraftBatchTx(
continue 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.NumElementsPerBatch.Observe(float64(len(batchElements)))
d.metrics.BatchPruneCount.Set(float64(pruneCount)) d.metrics.BatchPruneCount.Set(float64(pruneCount))
......
...@@ -171,6 +171,7 @@ func (s *Service) eventLoop() { ...@@ -171,6 +171,7 @@ func (s *Service) eventLoop() {
} }
nonce := new(big.Int).SetUint64(nonce64) nonce := new(big.Int).SetUint64(nonce64)
batchTxBuildStart := time.Now()
tx, err := s.cfg.Driver.CraftBatchTx( tx, err := s.cfg.Driver.CraftBatchTx(
s.ctx, start, end, nonce, s.ctx, start, end, nonce,
) )
...@@ -179,6 +180,8 @@ func (s *Service) eventLoop() { ...@@ -179,6 +180,8 @@ func (s *Service) eventLoop() {
"err", err) "err", err)
continue continue
} }
batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond
s.metrics.BatchTxBuildTime.Set(float64(batchTxBuildTime))
// Construct the transaction submission clousure that will attempt // Construct the transaction submission clousure that will attempt
// to send the next transaction at the given nonce and gas price. // 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