Skip to content

Commit

Permalink
Add HeaderDateMilliseconds for improved request timing tracking (#748)
Browse files Browse the repository at this point in the history
- Introduce new HeaderDateMilliseconds constant in constants.go
- Add HeaderDateMilliseconds to getHeader and processPayload methods
- Mark HeaderStartTimeUnixMS as deprecated with a comment
  • Loading branch information
alextes authored Feb 27, 2025
1 parent 1b71802 commit ed7d69e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions server/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ const (
HeaderEthConsensusVersion = "Eth-Consensus-Version"
HeaderKeySlotUID = "X-MEVBoost-SlotID"
HeaderKeyVersion = "X-MEVBoost-Version"
HeaderStartTimeUnixMS = "X-MEVBoost-StartTimeUnixMS"
HeaderUserAgent = "User-Agent"
// Deprecated: replaced by HeaderDateMilliseconds below.
HeaderStartTimeUnixMS = "X-MEVBoost-StartTimeUnixMS"
HeaderUserAgent = "User-Agent"
// Header which communicates when a request was sent. Used to measure latency.
// Replaces HeaderStartTimeUnixMS above which may be dropped in a future release.
HeaderDateMilliseconds = "Date-Milliseconds"

MediaTypeJSON = "application/json"
MediaTypeOctetStream = "application/octet-stream"
Expand Down
1 change: 1 addition & 0 deletions server/get_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (m *BoostService) getHeader(log *logrus.Entry, slot phase0.Slot, pubkey, pa
req.Header.Set(HeaderKeySlotUID, slotUID.String())
req.Header.Set(HeaderStartTimeUnixMS, startTime)
req.Header.Set(HeaderUserAgent, userAgent)
req.Header.Set(HeaderDateMilliseconds, startTime)

// Send the request
log.Debug("requesting header")
Expand Down
5 changes: 3 additions & 2 deletions server/get_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ func processPayload[P Payload](m *BoostService, log *logrus.Entry, ua UserAgent,

// Add request headers
headers := map[string]string{
HeaderKeySlotUID: currentSlotUID,
HeaderStartTimeUnixMS: fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),
HeaderKeySlotUID: currentSlotUID,
HeaderStartTimeUnixMS: fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),
HeaderDateMilliseconds: fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),
}

// Prepare for requests
Expand Down

0 comments on commit ed7d69e

Please sign in to comment.