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

log slot-uid #536

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Changes from all 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
44 changes: 23 additions & 21 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
return
}

// Make sure we have a uid for this slot
m.slotUIDLock.Lock()
if m.slotUID.slot < _slot {
m.slotUID.slot = _slot
m.slotUID.uid = uuid.New()
}
slotUID := m.slotUID.uid
m.slotUIDLock.Unlock()
log = log.WithField("slotUID", slotUID)

// Log how late into the slot the request starts
slotStartTimestamp := config.GenesisTime + (int64(_slot) * config.SlotTimeSec)
msIntoSlot := time.Now().UTC().UnixMilli() - (slotStartTimestamp * 1000)
Expand All @@ -340,18 +350,9 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
"msIntoSlot": msIntoSlot,
}).Infof("getHeader request start - %d milliseconds into slot %d", msIntoSlot, _slot)

// Make sure we have a uid for this slot
m.slotUIDLock.Lock()
if m.slotUID.slot < _slot {
m.slotUID.slot = _slot
m.slotUID.uid = uuid.New()
}
uid := m.slotUID.uid
m.slotUIDLock.Unlock()

// Add request headers
headers := map[string]string{
HeaderKeySlotUID: uid.String(),
HeaderKeySlotUID: slotUID.String(),
}

// Prepare relay responses
Expand Down Expand Up @@ -614,13 +615,24 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re
return
}

// Get the slotUID for this slot
slotUID := ""
m.slotUIDLock.Lock()
if m.slotUID.slot == uint64(payload.Message.Slot) {
slotUID = m.slotUID.uid.String()
} else {
log.Warnf("latest slotUID is for slot %d rather than payload slot %d", m.slotUID.slot, payload.Message.Slot)
}
m.slotUIDLock.Unlock()

// Prepare logger
ua := UserAgent(req.Header.Get("User-Agent"))
log = log.WithFields(logrus.Fields{
"ua": ua,
"slot": payload.Message.Slot,
"blockHash": payload.Message.Body.ExecutionPayloadHeader.BlockHash.String(),
"parentHash": payload.Message.Body.ExecutionPayloadHeader.ParentHash.String(),
"slotUID": slotUID,
})

// Log how late into the slot the request starts
Expand All @@ -646,18 +658,8 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re
// send bid and signed block to relay monitor with capella payload
// go m.sendAuctionTranscriptToRelayMonitors(&AuctionTranscript{Bid: originalBid.response.Data, Acceptance: payload})

// Get the uid for this slot
uid := ""
m.slotUIDLock.Lock()
if m.slotUID.slot == uint64(payload.Message.Slot) {
uid = m.slotUID.uid.String()
} else {
log.Warnf("latest slotUID is for slot %d rather than payload slot %d", m.slotUID.slot, payload.Message.Slot)
}
m.slotUIDLock.Unlock()

// Add request headers
headers := map[string]string{HeaderKeySlotUID: uid}
headers := map[string]string{HeaderKeySlotUID: slotUID}

// Prepare for requests
var wg sync.WaitGroup
Expand Down