From 2b334c3570322fa5145e3a568e10d5f2acabf23e Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Thu, 22 Jun 2023 11:42:23 +0200 Subject: [PATCH 1/2] log slot-uid --- server/service.go | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/server/service.go b/server/service.go index f3689187..b70030cb 100644 --- a/server/service.go +++ b/server/service.go @@ -331,15 +331,6 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request) return } - // Log how late into the slot the request starts - slotStartTimestamp := config.GenesisTime + (int64(_slot) * config.SlotTimeSec) - msIntoSlot := time.Now().UTC().UnixMilli() - (slotStartTimestamp * 1000) - log.WithFields(logrus.Fields{ - "genesisTime": config.GenesisTime, - "slotTimeSec": config.SlotTimeSec, - "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 { @@ -348,6 +339,16 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request) } uid := m.slotUID.uid m.slotUIDLock.Unlock() + log = log.WithField("slotUid", uid) + + // Log how late into the slot the request starts + slotStartTimestamp := config.GenesisTime + (int64(_slot) * config.SlotTimeSec) + msIntoSlot := time.Now().UTC().UnixMilli() - (slotStartTimestamp * 1000) + log.WithFields(logrus.Fields{ + "genesisTime": config.GenesisTime, + "slotTimeSec": config.SlotTimeSec, + "msIntoSlot": msIntoSlot, + }).Infof("getHeader request start - %d milliseconds into slot %d", msIntoSlot, _slot) // Add request headers headers := map[string]string{ @@ -614,6 +615,16 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re return } + // 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() + // Prepare logger ua := UserAgent(req.Header.Get("User-Agent")) log = log.WithFields(logrus.Fields{ @@ -621,6 +632,7 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re "slot": payload.Message.Slot, "blockHash": payload.Message.Body.ExecutionPayloadHeader.BlockHash.String(), "parentHash": payload.Message.Body.ExecutionPayloadHeader.ParentHash.String(), + "slotUid": uid, }) // Log how late into the slot the request starts @@ -646,16 +658,6 @@ 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} From d90b92bbbf14dcab6a033a795e691b3620298164 Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Thu, 22 Jun 2023 14:10:09 +0200 Subject: [PATCH 2/2] pr feedback --- server/service.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/service.go b/server/service.go index b70030cb..084ebc41 100644 --- a/server/service.go +++ b/server/service.go @@ -337,9 +337,9 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request) m.slotUID.slot = _slot m.slotUID.uid = uuid.New() } - uid := m.slotUID.uid + slotUID := m.slotUID.uid m.slotUIDLock.Unlock() - log = log.WithField("slotUid", uid) + log = log.WithField("slotUID", slotUID) // Log how late into the slot the request starts slotStartTimestamp := config.GenesisTime + (int64(_slot) * config.SlotTimeSec) @@ -352,7 +352,7 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request) // Add request headers headers := map[string]string{ - HeaderKeySlotUID: uid.String(), + HeaderKeySlotUID: slotUID.String(), } // Prepare relay responses @@ -615,11 +615,11 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re return } - // Get the uid for this slot - uid := "" + // Get the slotUID for this slot + slotUID := "" m.slotUIDLock.Lock() if m.slotUID.slot == uint64(payload.Message.Slot) { - uid = m.slotUID.uid.String() + 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) } @@ -632,7 +632,7 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re "slot": payload.Message.Slot, "blockHash": payload.Message.Body.ExecutionPayloadHeader.BlockHash.String(), "parentHash": payload.Message.Body.ExecutionPayloadHeader.ParentHash.String(), - "slotUid": uid, + "slotUID": slotUID, }) // Log how late into the slot the request starts @@ -659,7 +659,7 @@ func (m *BoostService) processCapellaPayload(w http.ResponseWriter, req *http.Re // go m.sendAuctionTranscriptToRelayMonitors(&AuctionTranscript{Bid: originalBid.response.Data, Acceptance: payload}) // Add request headers - headers := map[string]string{HeaderKeySlotUID: uid} + headers := map[string]string{HeaderKeySlotUID: slotUID} // Prepare for requests var wg sync.WaitGroup