Skip to content

Commit 2d242a8

Browse files
execution: avoid redundant WithHttpEndpoint when JWT is provided (#16032)
This change ensures FlagOptions in cmd/beacon-chain/execution/options.go appends only one endpoint option depending on whether a JWT secret is present. Previously the code always appended WithHttpEndpoint and then conditionally appended WithHttpEndpointAndJWTSecret which overwrote the first option, adding unnecessary allocations and cognitive overhead. Since WithHttpEndpointAndJWTSecret fully configures the endpoint, including URL and Bearer auth needed by the Engine API, the initial WithHttpEndpoint is redundant when a JWT is supplied. The refactor preserves behavior while simplifying option composition and avoiding redundant state churn. --------- Co-authored-by: james-prysm <[email protected]>
1 parent 6be1541 commit 2d242a8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Changed
2+
3+
- Avoid redundant WithHttpEndpoint when JWT is provided

cmd/beacon-chain/execution/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ func FlagOptions(c *cli.Context) ([]execution.Option, error) {
2424
}
2525
headers := strings.Split(c.String(flags.ExecutionEngineHeaders.Name), ",")
2626
opts := []execution.Option{
27-
execution.WithHttpEndpoint(endpoint),
2827
execution.WithEth1HeaderRequestLimit(c.Uint64(flags.Eth1HeaderReqLimit.Name)),
2928
execution.WithHeaders(headers),
3029
}
3130
if len(jwtSecret) > 0 {
3231
opts = append(opts, execution.WithHttpEndpointAndJWTSecret(endpoint, jwtSecret))
32+
} else {
33+
opts = append(opts, execution.WithHttpEndpoint(endpoint))
3334
}
3435
return opts, nil
3536
}

0 commit comments

Comments
 (0)