Skip to content

Commit 80e2b17

Browse files
committed
chore: refactored wiring to use bool
1 parent c5d7c41 commit 80e2b17

File tree

4 files changed

+332
-43
lines changed

4 files changed

+332
-43
lines changed

apps/evm/cmd/run.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"net/http"
87
"os"
98
"path/filepath"
109
"time"
1110

1211
"github.com/ethereum/go-ethereum/common"
13-
gethrpc "github.com/ethereum/go-ethereum/rpc"
1412
"github.com/ipfs/go-datastore"
1513
"github.com/rs/zerolog"
1614
"github.com/spf13/cobra"
1715

16+
"github.com/evstack/ev-node/apps/evm/server"
1817
"github.com/evstack/ev-node/block"
1918
"github.com/evstack/ev-node/core/execution"
2019
coresequencer "github.com/evstack/ev-node/core/sequencer"
@@ -31,9 +30,6 @@ import (
3130
"github.com/evstack/ev-node/pkg/sequencers/based"
3231
"github.com/evstack/ev-node/pkg/sequencers/single"
3332
"github.com/evstack/ev-node/pkg/store"
34-
"github.com/evstack/ev-node/pkg/telemetry"
35-
36-
"github.com/evstack/ev-node/apps/evm/server"
3733
)
3834

3935
const (
@@ -59,13 +55,8 @@ var RunCmd = &cobra.Command{
5955
return err
6056
}
6157

62-
var rpcOpts []gethrpc.ClientOption
63-
if nodeConfig.Instrumentation.IsTracingEnabled() {
64-
// if tracing is enabled, we wrap the http client and inject W3C headers.
65-
rpcOpts = append(rpcOpts, gethrpc.WithHTTPClient(telemetry.NewPropagatingHTTPClient(http.DefaultTransport)))
66-
}
67-
68-
executor, err := createExecutionClient(cmd, datastore, rpcOpts...)
58+
tracingEnabled := nodeConfig.Instrumentation.IsTracingEnabled()
59+
executor, err := createExecutionClient(cmd, datastore, tracingEnabled)
6960
if err != nil {
7061
return err
7162
}
@@ -210,7 +201,7 @@ func createSequencer(
210201
return sequencer, nil
211202
}
212203

213-
func createExecutionClient(cmd *cobra.Command, db datastore.Batching, rpcOpts ...gethrpc.ClientOption) (execution.Executor, error) {
204+
func createExecutionClient(cmd *cobra.Command, db datastore.Batching, tracingEnabled bool) (execution.Executor, error) {
214205
// Read execution client parameters from flags
215206
ethURL, err := cmd.Flags().GetString(evm.FlagEvmEthURL)
216207
if err != nil {
@@ -255,7 +246,7 @@ func createExecutionClient(cmd *cobra.Command, db datastore.Batching, rpcOpts ..
255246
genesisHash := common.HexToHash(genesisHashStr)
256247
feeRecipient := common.HexToAddress(feeRecipientStr)
257248

258-
return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, genesisHash, feeRecipient, db, rpcOpts...)
249+
return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, genesisHash, feeRecipient, db, tracingEnabled)
259250
}
260251

261252
// addFlags adds flags related to the EVM execution client

execution/evm/execution.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/rs/zerolog"
2424

2525
"github.com/evstack/ev-node/core/execution"
26+
"github.com/evstack/ev-node/pkg/telemetry"
2627
)
2728

2829
const (
@@ -157,20 +158,29 @@ type EngineClient struct {
157158
// The db parameter is required for ExecMeta tracking which enables idempotent
158159
// execution and crash recovery. The db is wrapped with a prefix to isolate
159160
// EVM execution data from other ev-node data.
161+
// When tracingEnabled is true, the client will inject W3C trace context headers
162+
// and wrap Engine API calls with OpenTelemetry spans.
160163
func NewEngineExecutionClient(
161164
ethURL,
162165
engineURL string,
163166
jwtSecret string,
164167
genesisHash common.Hash,
165168
feeRecipient common.Address,
166169
db ds.Batching,
167-
rpcOpts ...rpc.ClientOption,
170+
tracingEnabled bool,
168171
) (*EngineClient, error) {
169172
if db == nil {
170173
return nil, errors.New("db is required for EVM execution client")
171174
}
172175

173-
// Create ETH RPC client with optional custom HTTP client, then ethclient from it
176+
var rpcOpts []rpc.ClientOption
177+
// If tracing enabled, add W3C header propagation to rpcOpts
178+
if tracingEnabled {
179+
rpcOpts = append(rpcOpts, rpc.WithHTTPClient(
180+
telemetry.NewPropagatingHTTPClient(http.DefaultTransport)))
181+
}
182+
183+
// Create ETH RPC client with HTTP options
174184
ethRPC, err := rpc.DialOptions(context.Background(), ethURL, rpcOpts...)
175185
if err != nil {
176186
return nil, err

execution/evm/go.mod

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24.6
44

55
require (
66
github.com/ethereum/go-ethereum v1.16.7
7+
github.com/evstack/ev-node v1.0.0-beta.10
78
github.com/evstack/ev-node/core v1.0.0-beta.5
89
github.com/golang-jwt/jwt/v5 v5.3.0
910
github.com/ipfs/go-datastore v0.9.0
@@ -18,8 +19,10 @@ require (
1819
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
1920
github.com/StackExchange/wmi v1.2.1 // indirect
2021
github.com/bits-and-blooms/bitset v1.20.0 // indirect
22+
github.com/celestiaorg/go-square/v3 v3.0.2 // indirect
23+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
24+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2125
github.com/consensys/gnark-crypto v0.18.0 // indirect
22-
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
2326
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
2427
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
2528
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -29,33 +32,76 @@ require (
2932
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
3033
github.com/ethereum/go-verkle v0.2.2 // indirect
3134
github.com/ferranbt/fastssz v0.1.4 // indirect
35+
github.com/fsnotify/fsnotify v1.9.0 // indirect
36+
github.com/go-logr/logr v1.4.3 // indirect
37+
github.com/go-logr/stdr v1.2.2 // indirect
3238
github.com/go-ole/go-ole v1.3.0 // indirect
39+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
40+
github.com/goccy/go-yaml v1.19.0 // indirect
3341
github.com/gofrs/flock v0.12.1 // indirect
3442
github.com/golang/snappy v1.0.0 // indirect
3543
github.com/google/uuid v1.6.0 // indirect
3644
github.com/gorilla/websocket v1.5.3 // indirect
45+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
3746
github.com/holiman/uint256 v1.3.2 // indirect
47+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
48+
github.com/ipfs/go-cid v0.6.0 // indirect
3849
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
3950
github.com/mattn/go-colorable v0.1.14 // indirect
4051
github.com/mattn/go-isatty v0.0.20 // indirect
4152
github.com/mattn/go-runewidth v0.0.15 // indirect
4253
github.com/minio/sha256-simd v1.0.1 // indirect
4354
github.com/mitchellh/mapstructure v1.5.0 // indirect
55+
github.com/mr-tron/base58 v1.2.0 // indirect
56+
github.com/multiformats/go-base32 v0.1.0 // indirect
57+
github.com/multiformats/go-base36 v0.2.0 // indirect
58+
github.com/multiformats/go-multiaddr v0.16.1 // indirect
59+
github.com/multiformats/go-multibase v0.2.0 // indirect
60+
github.com/multiformats/go-multihash v0.2.3 // indirect
61+
github.com/multiformats/go-varint v0.1.0 // indirect
4462
github.com/olekukonko/tablewriter v0.0.5 // indirect
63+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
4564
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4665
github.com/rivo/uniseg v0.2.0 // indirect
47-
github.com/rogpeppe/go-internal v1.14.1 // indirect
4866
github.com/rs/cors v1.11.1 // indirect
67+
github.com/sagikazarmark/locafero v0.11.0 // indirect
4968
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
69+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
70+
github.com/spaolacci/murmur3 v1.1.0 // indirect
71+
github.com/spf13/afero v1.15.0 // indirect
72+
github.com/spf13/cast v1.10.0 // indirect
73+
github.com/spf13/cobra v1.10.2 // indirect
74+
github.com/spf13/pflag v1.0.10 // indirect
75+
github.com/spf13/viper v1.21.0 // indirect
76+
github.com/subosito/gotenv v1.6.0 // indirect
5077
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
5178
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
5279
github.com/tklauser/go-sysconf v0.3.12 // indirect
5380
github.com/tklauser/numcpus v0.6.1 // indirect
81+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
82+
go.opentelemetry.io/otel v1.39.0 // indirect
83+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
84+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
85+
go.opentelemetry.io/otel/metric v1.39.0 // indirect
86+
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
87+
go.opentelemetry.io/otel/trace v1.39.0 // indirect
88+
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
89+
go.yaml.in/yaml/v3 v3.0.4 // indirect
5490
golang.org/x/crypto v0.46.0 // indirect
91+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
92+
golang.org/x/net v0.48.0 // indirect
5593
golang.org/x/sync v0.19.0 // indirect
5694
golang.org/x/sys v0.39.0 // indirect
95+
golang.org/x/text v0.32.0 // indirect
96+
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect
97+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
98+
google.golang.org/grpc v1.75.0 // indirect
5799
gopkg.in/yaml.v2 v2.4.0 // indirect
58100
gopkg.in/yaml.v3 v3.0.1 // indirect
101+
lukechampine.com/blake3 v1.4.1 // indirect
59102
)
60103

61-
replace github.com/evstack/ev-node/core => ../../core
104+
replace (
105+
github.com/evstack/ev-node => ../../
106+
github.com/evstack/ev-node/core => ../../core
107+
)

0 commit comments

Comments
 (0)