Skip to content

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Oct 16, 2025

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Adds a new --beacon-rest-api-headers flag that allows to specify custom HTTP headers that will be sent to the beacon node with each validator client request. This feature is supported in grpc through the --grpc-headers flag.

Which issues(s) does this PR fix?

Fixes #14528

Other notes for review

Tested in Kurtosis

Acknowledgements

}
// BeaconRESTApiHeaders defines a list of headers to send with all HTTP requests to the beacon node.
BeaconRESTApiHeaders = &cli.StringFlag{
Name: "beacon-rest-api-headers",
Copy link
Contributor Author

@rkapka rkapka Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a little verbose but I wanted to keep it aligned with the --beacon-rest-api-provider flag

Comment on lines +648 to +649
// Skip malformed pairs
continue
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still allows for some weird malformed data like key===val=ue but I don't think it's that important to handle all edge cases

Copy link
Contributor

@Inspector-Butters Inspector-Butters Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add some tests for this function (parseBeaconApiHeaders())

@rkapka rkapka changed the title Rest custom headers Allow custom headers in validator client HTTP requests Oct 16, 2025
func (*nodeConnection) dummy() {}

func NewNodeConnection(grpcConn *grpc.ClientConn, beaconApiUrl string, beaconApiTimeout time.Duration) NodeConnection {
func NewNodeConnection(grpcConn *grpc.ClientConn, beaconApiUrl string, beaconApiHeaders map[string][]string, beaconApiTimeout time.Duration) NodeConnection {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe for stuff liek api headers and beacon api timeout we can turn those into functional parameters and add them in that way

Comment on lines +648 to +649
// Skip malformed pairs
continue
Copy link
Contributor

@Inspector-Butters Inspector-Butters Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add some tests for this function (parseBeaconApiHeaders())


headersTransport := api.NewCustomHeadersTransport(http.DefaultTransport, v.conn.GetBeaconApiHeaders())
restHandler := beaconApi.NewBeaconApiRestHandler(
http.Client{Timeout: v.conn.GetBeaconApiTimeout(), Transport: otelhttp.NewTransport(http.DefaultTransport)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the DefaultTransport do nothing? or does it add some default parameters to the request? because maybe we need to extend it instead of replacing it?

Comment on lines 192 to +193
restHandler := beaconApi.NewBeaconApiRestHandler(
http.Client{Timeout: v.conn.GetBeaconApiTimeout(), Transport: otelhttp.NewTransport(http.DefaultTransport)},
http.Client{Timeout: v.conn.GetBeaconApiTimeout(), Transport: otelhttp.NewTransport(headersTransport)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible, we should have tests to see if the headers get added after the Start()

Comment on lines +60 to 63
headersTransport := api.NewCustomHeadersTransport(http.DefaultTransport, conn.GetBeaconApiHeaders())
restHandler := beaconApi.NewBeaconApiRestHandler(
http.Client{Timeout: s.beaconApiTimeout, Transport: otelhttp.NewTransport(http.DefaultTransport)},
http.Client{Timeout: s.beaconApiTimeout, Transport: otelhttp.NewTransport(headersTransport)},
s.beaconApiEndpoint,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too, if possible, we should test if headers are being added after registerBeaconClient()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validator Client in REST mode should not drop URL query strings

3 participants