Skip to content

add user-agent header to all http clients#8786

Open
dapplion wants to merge 17 commits into
sigp:unstablefrom
dapplion:user-agent-param
Open

add user-agent header to all http clients#8786
dapplion wants to merge 17 commits into
sigp:unstablefrom
dapplion:user-agent-param

Conversation

@dapplion

Copy link
Copy Markdown
Collaborator

Issue Addressed

Closes #7963

Proposed Changes

Adds a User-Agent HTTP header to all outgoing HTTP requests. The header format is Lighthouse/v<version>-<commit> (e.g., Lighthouse/v8.0.0-67da032).

This helps distributed validator middleware operators identify what their peers are running.

Clients updated:

  • BeaconNodeHttpClient (BN API client)
  • ValidatorClientHttpClient (VC API client)
  • HttpJsonRpc (execution layer engine API)
  • BuilderHttpClient (already had user-agent)
  • MonitoringHttpClient (metrics endpoint)
  • Web3Signer client
  • ProductionValidatorClient beacon node builder

Key design decision: the user_agent is passed as a &str constructor parameter rather than having library crates depend on lighthouse_version directly. This avoids cargo cache invalidation cascading through the dependency tree on every git change, since lighthouse_version uses git_version!().

Only top-level/binary crates reference lighthouse_version::VERSION. Library crates (eth2, initialized_validators, beacon_node_fallback) receive it as a parameter.

Related PRs

Test plan

  • cargo check passes
  • cargo fmt --all clean
  • make lint-fix passes

pass user_agent as a parameter to http client constructors instead of
depending on lighthouse_version from library crates. this avoids
cargo cache invalidation cascading through the dependency tree on
every git change since lighthouse_version uses git_version!().
@dapplion dapplion force-pushed the user-agent-param branch 3 times, most recently from f13b4f9 to 328c0e0 Compare February 10, 2026 07:39
@chong-he

Copy link
Copy Markdown
Member

If I understand correctly, after this change, when the VC calls the HTTP requests to the BN, it should include its version.

I tested a running BN and VC and run: sudo tcpdump -A -i lo port 5052, I see the request sent by VC does not contain the user-agent, only has accept and host:

22:04:47.429301 IP localhost.54174 > localhost.5052: Flags [.], ack 32, win 510, options [nop,nop,TS val 3648558767 ecr 3648558767], length 0
E..4..@.@.D>..............A.!..c.....(.....
.x...x..
22:04:51.803986 IP localhost.54184 > localhost.5052: Flags [P.], seq 3425:3497, ack 105371, win 881, options [nop,nop,TS val 3648563141 ecr 3648558342], length 72
E..|..@.@.^..............v4..R.....q.p.....
.x...x..GET /eth/v1/node/version HTTP/1.1
accept: */*
host: localhost:5052


22:04:51.804203 IP localhost.5052 > localhost.54184: Flags [P.], seq 105371:105588, ack 3497, win 512, options [nop,nop,TS val 3648563142 ecr 3648563141], length 217
E.... @.@................R...v4H...........
.x...x..HTTP/1.1 200 OK
content-type: application/json
server: Lighthouse/v8.1.0-39edcf2/x86_64-linux
content-length: 61
date: Fri, 13 Feb 2026 14:04:51 GMT

{"data":{"version":"Lighthouse/v8.1.0-39edcf2/x86_64-linux"}}

@jimmygchen jimmygchen added the waiting-on-author The reviewer has suggested changes and awaits thier implementation. label Feb 18, 2026
@mergify mergify Bot added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Feb 18, 2026

@macladson macladson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe the reason it isn't working is because we never actually set the user agent when constructing the BeaconNodeHttpClient instance that is used by the VC on startup. We need to add a

.user_agent(&config.user_agent)

here:

let beacon_node_http_client = beacon_node_http_client_builder
// Set default timeout to be the full slot duration.
.timeout(slot_duration)
.build()
.map_err(|e| format!("Unable to build HTTP client: {:?}", e))?;

Also, I noticed that while the PR mentions updating HttpJsonRpc and MonitoringHttpClient (and web3signer) but I don't see any diffs for those. Are those still required?

Comment thread common/eth2/src/lib.rs Outdated
Comment thread common/eth2/src/lighthouse_vc/http_client.rs Outdated
@macladson macladson added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Feb 19, 2026
@cla-assistant

cla-assistant Bot commented Mar 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ chong-he
✅ dapplion
❌ Clawdia


Clawdia seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cla-assistant

cla-assistant Bot commented Mar 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ dapplion
❌ Clawdia


Clawdia seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@KaloyanTanev

Copy link
Copy Markdown

Hey @dapplion, is there an update on this one?

@mergify mergify Bot closed this Apr 16, 2026
@mergify

mergify Bot commented Apr 16, 2026

Copy link
Copy Markdown

Hi @dapplion, this pull request has been closed automatically due to 30 days of inactivity. If you’d like to continue working on it, feel free to reopen at any time.

@mergify mergify Bot added the stale Stale PRs that have been inactive and is now outdated label Apr 16, 2026
@chong-he chong-he reopened this Apr 21, 2026
@chong-he chong-he added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. stale Stale PRs that have been inactive and is now outdated labels May 12, 2026
@chong-he

Copy link
Copy Markdown
Member

Just did some minor fix. I believe @dapplion has addressed the comments. I tested with BN + VC and ca see that the user-agent requests now has Lighthouse version:

accept: */*
user-agent: Lighthouse/v8.1.3-c6bfbc9
host: localhost:5052

This PR is ready for another review.

pub initialized_validators: InitializedValidatorsConfig,
pub disable_attesting: bool,
/// User-Agent string for HTTP clients (set by the top-level binary).
#[serde(skip)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For testing we might need to take off serde(skip).

pub allow_insecure_genesis_sync: bool,
/// User-Agent string for HTTP clients (set by the top-level binary).
#[serde(skip)]
pub user_agent: String,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For testing:

  • One BN test
  • One VC test

Check that all "downstream" configs with user_agent are initialised when the top-level config is initialised.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added some tests in add test

@mergify

mergify Bot commented May 25, 2026

Copy link
Copy Markdown

Some required checks have failed. Could you please take a look @dapplion? 🙏

@mergify mergify Bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels May 25, 2026
@chong-he chong-he added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels May 25, 2026
@KaloyanTanev

Copy link
Copy Markdown

Hey guys, is there any chance we can get this merged and tagged before gloas? We'd love to keep get data of node operators which are on pre-gloas versions of their VCs and raise warnings to update.

@macladson

Copy link
Copy Markdown
Member

Hi @KaloyanTanev, most of the team is pretty flat out with Gloas at the moment but I'll try to review this by the end of the week and try to get this over the line

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

Labels

HTTP-API ready-for-review The code is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants