Skip to content

Conversation

@odysseus0
Copy link
Contributor

Summary

Add utilities for extracting and transforming HTTP headers in the JSON-RPC request chain.

New: headers.go

  • ExtractHeaders(req, names) - extract specified headers from request
  • TransformToFlashbots(headers) - transform User-Agent→X-Flashbots-User-Agent, Origin→X-Flashbots-Http-Origin
  • Header constants: HeaderFlashbotsUserAgent, HeaderFlashbotsHttpOrigin, HeaderFlashbotsOrigin, etc.
  • Default lists: EdgeHeaders, FlashbotsHeaders

Modified: jsonrpc_server.go

  • Added Header(ctx, name) - nil-safe helper to get header value from request in context

Usage

// Edge service (protect-rpc): extract and transform
edge := rpcserver.ExtractHeaders(req, rpcserver.EdgeHeaders)
transformed := rpcserver.TransformToFlashbots(edge)

// Passthrough service (protect-of-api): forward existing
existing := rpcserver.ExtractHeaders(req, rpcserver.FlashbotsHeaders)

// Storage service (mev-share-node): read from context
userAgent := rpcserver.Header(ctx, rpcserver.HeaderFlashbotsUserAgent)
httpOrigin := rpcserver.Header(ctx, rpcserver.HeaderFlashbotsHttpOrigin)

Test plan

  • Unit tests for ExtractHeaders, TransformToFlashbots
  • Tests for nil request handling
  • Tests for header constants

🤖 Generated with Claude Code

odysseus0 and others added 2 commits January 25, 2026 11:58
Add utilities for extracting and transforming HTTP headers in the
JSON-RPC request chain:

- headers.go: ExtractHeaders, TransformToFlashbots, header constants
- Header(ctx, name): nil-safe helper to get header from request context

Used by protect-rpc (edge transformation), protect-of-api (passthrough),
and mev-share-node (storage) for User-Agent and Origin header logging.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@odysseus0 odysseus0 force-pushed the feature/header-helpers branch from 8fecfd6 to ac89d8a Compare January 25, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant