Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request start time metrics to request header field #647

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,19 @@ func (m *BoostService) handleRegisterValidator(w http.ResponseWriter, req *http.
"ua": ua,
})

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

relayRespCh := make(chan error, len(m.relays))

for _, relay := range m.relays {
go func(relay types.RelayEntry) {
url := relay.GetURI(params.PathRegisterValidator)
log := log.WithField("url", url)

_, err := SendHTTPRequest(context.Background(), m.httpClientRegVal, http.MethodPost, url, ua, nil, payload, nil)
_, err := SendHTTPRequest(context.Background(), m.httpClientRegVal, http.MethodPost, url, ua, headers, payload, nil)
relayRespCh <- err
if err != nil {
log.WithError(err).Warn("error calling registerValidator on relay")
Expand Down Expand Up @@ -337,16 +342,15 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
"slotTimeSec": config.SlotTimeSec,
"msIntoSlot": msIntoSlot,
}).Infof("getHeader request start - %d milliseconds into slot %d", msIntoSlot, _slot)

// Add request headers
headers := map[string]string{
HeaderKeySlotUID: slotUID.String(),
HeaderKeySlotUID: slotUID.String(),
HeaderStartTimeMsIntoSlot: fmt.Sprintf("%d", msIntoSlot),
bhakiyakalimuthu marked this conversation as resolved.
Show resolved Hide resolved
HeaderStartTimeMsUnix: fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),
}

// Prepare relay responses
result := bidResp{} // the final response, containing the highest bid (if any)
relays := make(map[BlockHashHex][]types.RelayEntry) // relays that sent the bid for a specific blockHash

// Call the relays
var mu sync.Mutex
var wg sync.WaitGroup
Expand Down Expand Up @@ -461,7 +465,6 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
result.t = time.Now()
}(relay)
}

// Wait for all requests to complete...
wg.Wait()

Expand Down Expand Up @@ -668,7 +671,11 @@ func (m *BoostService) processDenebPayload(w http.ResponseWriter, req *http.Requ
}

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

// Prepare for requests
var wg sync.WaitGroup
Expand Down
6 changes: 4 additions & 2 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import (
)

const (
HeaderKeySlotUID = "X-MEVBoost-SlotID"
HeaderKeyVersion = "X-MEVBoost-Version"
HeaderKeySlotUID = "X-MEVBoost-SlotID"
HeaderKeyVersion = "X-MEVBoost-Version"
HeaderStartTimeMsUnix = "X-MEVBoost-StartTimeMSUnix"
HeaderStartTimeMsIntoSlot = "X-MEVBoost-StartTimeMSIntoSlot"
)

var (
Expand Down
Loading