Skip to content

Commit 836ecd1

Browse files
committed
Merge remote-tracking branch 'origin' into tobi/add-aws
2 parents 6dfc2b1 + e41fdd7 commit 836ecd1

File tree

28 files changed

+689
-246
lines changed

28 files changed

+689
-246
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/charmbracelet/huh v0.7.0
1010
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1111
github.com/ethereum-optimism/optimism v1.13.3
12-
github.com/ethereum/go-ethereum v1.15.11
12+
github.com/ethereum/go-ethereum v1.16.0
1313
github.com/holiman/uint256 v1.3.2
1414
github.com/pkg/errors v0.9.1
1515
github.com/prometheus/common v0.62.0

report/src/metricDefinitions.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ChartConfig } from "./types"; // Import from types.ts
2-
32
export const CHART_CONFIG: Record<string, ChartConfig> = {
43
"latency/send_txs": {
54
type: "line",
@@ -137,4 +136,60 @@ export const CHART_CONFIG: Record<string, ChartConfig> = {
137136
description: "Shows the median gas per block",
138137
unit: "gas",
139138
},
139+
reth_sync_execution_execution_duration: {
140+
type: "line",
141+
title: "Reth Sync Execution Duration",
142+
description: "Shows the time taken for execution during reth sync",
143+
unit: "s",
144+
},
145+
reth_sync_block_validation_state_root_duration: {
146+
type: "line",
147+
title: "Reth Sync Block Validation State Root Duration",
148+
description:
149+
"Shows the time taken for state root validation during reth sync",
150+
unit: "s",
151+
},
152+
reth_op_rbuilder_block_built_success: {
153+
type: "line",
154+
title: "Reth OP RBuilder Block Built Success",
155+
description: "Indicates whether the RBuilder successfully built a block",
156+
unit: "count",
157+
},
158+
reth_op_rbuilder_flashblock_count_avg: {
159+
type: "line",
160+
title: "Reth OP RBuilder Flashblock Count",
161+
description: "Shows the number of flashblocks built by RBuilder",
162+
unit: "count",
163+
},
164+
reth_op_rbuilder_total_block_built_duration_avg: {
165+
type: "line",
166+
title: "Reth OP RBuilder Total Block Built Duration",
167+
description: "Shows the total time taken to build a block by RBuilder",
168+
unit: "s",
169+
},
170+
reth_op_rbuilder_flashblock_build_duration_avg: {
171+
type: "line",
172+
title: "Reth OP RBuilder Flashblock Build Duration",
173+
description: "Shows the time taken to build a flashblock by RBuilder",
174+
unit: "s",
175+
},
176+
reth_op_rbuilder_state_root_calculation_duration_avg: {
177+
type: "line",
178+
title: "Reth OP RBuilder State Root Calculation Duration",
179+
description: "Shows the time taken to calculate the state root by RBuilder",
180+
unit: "s",
181+
},
182+
reth_op_rbuilder_sequencer_tx_duration_avg: {
183+
type: "line",
184+
title: "Reth OP RBuilder Sequencer Tx Duration",
185+
description: "Shows the time taken for sequencer transactions in RBuilder",
186+
unit: "s",
187+
},
188+
reth_op_rbuilder_payload_tx_simulation_duration_avg: {
189+
type: "line",
190+
title: "Reth OP RBuilder Payload Tx Simulation Duration",
191+
description:
192+
"Shows the time taken for payload transaction simulation in RBuilder",
193+
unit: "s",
194+
},
140195
};

report/src/types.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export interface ChartConfig {
4040
title: string;
4141
description: string;
4242
type: "line";
43-
unit?: "ns" | "us" | "ms" | "s" | "bytes" | "gas" | "count" | "gas/s"; // Add 'gas/s', ensure 's' is present
43+
unit?:
44+
| "ns"
45+
| "us"
46+
| "ms"
47+
| "s"
48+
| "bytes"
49+
| "gas"
50+
| "count"
51+
| "gas/s"
52+
| "blocks"; // Add 'gas/s', ensure 's' is present
4453
}
4554

4655
export interface BenchmarkRun {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package portmanager
2+
3+
import (
4+
"fmt"
5+
"net"
6+
"time"
7+
)
8+
9+
type PortPurpose uint64
10+
11+
const (
12+
ELPortPurpose PortPurpose = iota
13+
AuthELPortPurpose
14+
ELMetricsPortPurpose
15+
BuilderMetricsPortPurpose
16+
)
17+
18+
type PortManager interface {
19+
AcquirePort(nodeType string, purpose PortPurpose) uint64
20+
ReleasePort(portNumber uint64)
21+
}
22+
23+
type portManager struct {
24+
// ports is a map of node type to a map of port purpose to port number.
25+
ports map[uint64]struct{}
26+
}
27+
28+
func NewPortManager() PortManager {
29+
return &portManager{
30+
ports: make(map[uint64]struct{}),
31+
}
32+
}
33+
34+
func (p *portManager) AcquirePort(nodeType string, purpose PortPurpose) uint64 {
35+
// find the next available port number
36+
for port := uint64(10000); port < 65535; port++ {
37+
if _, exists := p.ports[port]; !exists {
38+
// check if port is already in use
39+
if conn, err := net.DialTimeout("tcp", fmt.Sprintf("localhost:%d", port), 100*time.Millisecond); err == nil {
40+
_ = conn.Close()
41+
continue // port is in use, try the next one
42+
}
43+
44+
p.ports[port] = struct{}{}
45+
return port
46+
}
47+
}
48+
49+
panic(fmt.Sprintf("no available ports for node type %s and purpose %d", nodeType, purpose))
50+
}
51+
52+
func (p *portManager) ReleasePort(portNumber uint64) {
53+
if _, exists := p.ports[portNumber]; !exists {
54+
return
55+
}
56+
57+
delete(p.ports, portNumber)
58+
}

runner/benchmark/result_metadata.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
package benchmark
22

3-
import "time"
3+
import (
4+
"time"
45

5-
type SequencerKeyMetrics struct {
6-
CommonKeyMetrics
7-
AverageFCULatency float64 `json:"forkChoiceUpdated"`
8-
AverageGetPayloadLatency float64 `json:"getPayload"`
9-
AverageSendTxsLatency float64 `json:"sendTxs"`
10-
}
11-
12-
type ValidatorKeyMetrics struct {
13-
CommonKeyMetrics
14-
AverageNewPayloadLatency float64 `json:"newPayload"`
15-
}
16-
17-
type CommonKeyMetrics struct {
18-
AverageGasPerSecond float64 `json:"gasPerSecond"`
19-
}
6+
"github.com/base/base-bench/runner/network/types"
7+
)
208

219
type RunResult struct {
22-
Success bool `json:"success"`
23-
Complete bool `json:"complete"`
24-
SequencerMetrics SequencerKeyMetrics `json:"sequencerMetrics"`
25-
ValidatorMetrics ValidatorKeyMetrics `json:"validatorMetrics"`
10+
Success bool `json:"success"`
11+
Complete bool `json:"complete"`
12+
SequencerMetrics types.SequencerKeyMetrics `json:"sequencerMetrics"`
13+
ValidatorMetrics types.ValidatorKeyMetrics `json:"validatorMetrics"`
2614
}
2715

2816
// Run is the output JSON metadata for a benchmark run.
File renamed without changes.

runner/clients/geth/client.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"net/http"
99
"os"
1010
"os/exec"
11-
"strconv"
1211
"strings"
1312
"time"
1413

@@ -18,9 +17,11 @@ import (
1817
"github.com/ethereum/go-ethereum/rpc"
1918
"github.com/pkg/errors"
2019

20+
"github.com/base/base-bench/runner/benchmark/portmanager"
2121
"github.com/base/base-bench/runner/clients/common"
2222
"github.com/base/base-bench/runner/clients/types"
2323
"github.com/base/base-bench/runner/config"
24+
"github.com/base/base-bench/runner/metrics"
2425
"github.com/ethereum/go-ethereum/ethclient"
2526
)
2627

@@ -34,18 +35,30 @@ type GethClient struct {
3435
authClient client.RPC
3536
process *exec.Cmd
3637

38+
ports portmanager.PortManager
39+
metricsPort uint64
40+
rpcPort uint64
41+
authRPCPort uint64
42+
3743
stdout io.WriteCloser
3844
stderr io.WriteCloser
45+
46+
metricsCollector metrics.Collector
3947
}
4048

4149
// NewGethClient creates a new client for geth.
42-
func NewGethClient(logger log.Logger, options *config.InternalClientOptions) types.ExecutionClient {
50+
func NewGethClient(logger log.Logger, options *config.InternalClientOptions, ports portmanager.PortManager) types.ExecutionClient {
4351
return &GethClient{
4452
logger: logger,
4553
options: options,
54+
ports: ports,
4655
}
4756
}
4857

58+
func (g *GethClient) MetricsCollector() metrics.Collector {
59+
return g.metricsCollector
60+
}
61+
4962
// Run runs the geth client with the given runtime config.
5063
func (g *GethClient) Run(ctx context.Context, cfg *types.RuntimeConfig) error {
5164

@@ -78,17 +91,20 @@ func (g *GethClient) Run(ctx context.Context, cfg *types.RuntimeConfig) error {
7891
}
7992
}
8093

81-
8294
args = make([]string, 0)
8395
args = append(args, "--datadir", g.options.DataDirPath)
8496
args = append(args, "--http")
8597

98+
g.rpcPort = g.ports.AcquirePort("geth", portmanager.ELPortPurpose)
99+
g.authRPCPort = g.ports.AcquirePort("geth", portmanager.AuthELPortPurpose)
100+
g.metricsPort = g.ports.AcquirePort("geth", portmanager.ELMetricsPortPurpose)
101+
86102
// TODO: allocate these dynamically eventually
87-
args = append(args, "--http.port", strconv.Itoa(g.options.GethHttpPort))
88-
args = append(args, "--authrpc.port", strconv.Itoa(g.options.GethAuthRpcPort))
103+
args = append(args, "--http.port", fmt.Sprintf("%d", g.rpcPort))
104+
args = append(args, "--authrpc.port", fmt.Sprintf("%d", g.authRPCPort))
89105
args = append(args, "--metrics")
90106
args = append(args, "--metrics.addr", "localhost")
91-
args = append(args, "--metrics.port", strconv.Itoa(g.options.GethMetricsPort))
107+
args = append(args, "--metrics.port", fmt.Sprintf("%d", g.metricsPort))
92108

93109
// Set mempool size to 100x default
94110
args = append(args, "--txpool.globalslots", "10000000")
@@ -136,7 +152,7 @@ func (g *GethClient) Run(ctx context.Context, cfg *types.RuntimeConfig) error {
136152
return err
137153
}
138154

139-
g.clientURL = fmt.Sprintf("http://127.0.0.1:%d", g.options.GethHttpPort)
155+
g.clientURL = fmt.Sprintf("http://127.0.0.1:%d", g.rpcPort)
140156
rpcClient, err := rpc.DialOptions(ctx, g.clientURL, rpc.WithHTTPClient(&http.Client{
141157
Timeout: 30 * time.Second,
142158
}))
@@ -145,13 +161,14 @@ func (g *GethClient) Run(ctx context.Context, cfg *types.RuntimeConfig) error {
145161
}
146162

147163
g.client = ethclient.NewClient(rpcClient)
164+
g.metricsCollector = newMetricsCollector(g.logger, g.client, int(g.metricsPort))
148165

149166
err = common.WaitForRPC(ctx, g.client)
150167
if err != nil {
151168
return errors.Wrap(err, "geth rpc failed to start")
152169
}
153170

154-
l2Node, err := client.NewRPC(ctx, g.logger, fmt.Sprintf("http://127.0.0.1:%d", g.options.GethAuthRpcPort), client.WithGethRPCOptions(rpc.WithHTTPAuth(node.NewJWTAuth(jwtSecret))), client.WithCallTimeout(30*time.Second))
171+
l2Node, err := client.NewRPC(ctx, g.logger, fmt.Sprintf("http://127.0.0.1:%d", g.authRPCPort), client.WithGethRPCOptions(rpc.WithHTTPAuth(node.NewJWTAuth(jwtSecret))), client.WithCallTimeout(30*time.Second))
155172
if err != nil {
156173
return err
157174
}
@@ -181,6 +198,10 @@ func (g *GethClient) Stop() {
181198
_ = g.stdout.Close()
182199
_ = g.stderr.Close()
183200

201+
g.ports.ReleasePort(g.rpcPort)
202+
g.ports.ReleasePort(g.authRPCPort)
203+
g.ports.ReleasePort(g.metricsPort)
204+
184205
g.stdout = nil
185206
g.stderr = nil
186207
g.process = nil
@@ -202,5 +223,5 @@ func (g *GethClient) AuthClient() client.RPC {
202223
}
203224

204225
func (r *GethClient) MetricsPort() int {
205-
return r.options.GethMetricsPort
226+
return int(r.metricsPort)
206227
}

runner/metrics/geth_metrics.go renamed to runner/clients/geth/metrics.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
package metrics
1+
package geth
22

33
import (
44
"context"
55
"encoding/json"
66
"fmt"
77
"net/http"
88

9+
"github.com/base/base-bench/runner/metrics"
910
"github.com/ethereum/go-ethereum/ethclient"
1011
"github.com/ethereum/go-ethereum/log"
1112
)
1213

13-
type GethMetricsCollector struct {
14+
type metricsCollector struct {
1415
log log.Logger
1516
client *ethclient.Client
16-
metrics []BlockMetrics
17+
metrics []metrics.BlockMetrics
1718
metricsPort int
1819
}
1920

20-
func NewGethMetricsCollector(log log.Logger, client *ethclient.Client, metricsPort int) *GethMetricsCollector {
21-
return &GethMetricsCollector{
21+
func newMetricsCollector(log log.Logger, client *ethclient.Client, metricsPort int) metrics.Collector {
22+
return &metricsCollector{
2223
log: log,
2324
client: client,
2425
metricsPort: metricsPort,
25-
metrics: make([]BlockMetrics, 0),
26+
metrics: make([]metrics.BlockMetrics, 0),
2627
}
2728
}
2829

29-
func (g *GethMetricsCollector) GetMetricTypes() map[string]bool {
30+
func (g *metricsCollector) GetMetricTypes() map[string]bool {
3031
return map[string]bool{
3132
"chain/account/reads.50-percentile": true,
3233
"chain/execution.50-percentile": true,
@@ -45,15 +46,15 @@ func (g *GethMetricsCollector) GetMetricTypes() map[string]bool {
4546
}
4647
}
4748

48-
func (g *GethMetricsCollector) GetMetricsEndpoint() string {
49+
func (g *metricsCollector) GetMetricsEndpoint() string {
4950
return fmt.Sprintf("http://127.0.0.1:%d/debug/metrics", g.metricsPort)
5051
}
5152

52-
func (g *GethMetricsCollector) GetMetrics() []BlockMetrics {
53+
func (g *metricsCollector) GetMetrics() []metrics.BlockMetrics {
5354
return g.metrics
5455
}
5556

56-
func (g *GethMetricsCollector) Collect(ctx context.Context, metrics *BlockMetrics) error {
57+
func (g *metricsCollector) Collect(ctx context.Context, metrics *metrics.BlockMetrics) error {
5758
resp, err := http.Get(g.GetMetricsEndpoint())
5859
if err != nil {
5960
return fmt.Errorf("failed to get metrics: %w", err)
@@ -77,6 +78,6 @@ func (g *GethMetricsCollector) Collect(ctx context.Context, metrics *BlockMetric
7778
}
7879
}
7980

80-
g.metrics = append(g.metrics, *metrics)
81+
g.metrics = append(g.metrics, *metrics.Copy())
8182
return nil
8283
}

runner/clients/geth/options/options.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ package options
33
// GethOptions are options that are specified at runtime for the geth client.
44
type GethOptions struct {
55
// GethBin is the path to the geth binary to use in tests.
6-
GethBin string
7-
GethHttpPort int
8-
GethAuthRpcPort int
9-
GethMetricsPort int
10-
SkipInit bool
6+
GethBin string
7+
SkipInit bool
118
}

0 commit comments

Comments
 (0)