From e786219f373e2ffbbb8573095880cd6eb8d53ebe Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 6 Dec 2025 06:45:23 -0800 Subject: [PATCH] debug(keygen): add detailed logging for message flow tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added comprehensive debug logging to track message conversion and party index mapping in keygen protocol: 1. Log party index map construction with all participants 2. Log received MPC messages before conversion 3. Log when messages are dropped due to unknown sender 4. Log successful message conversion and TSS forwarding 5. Show known_parties map when dropping messages This will help identify why delegate party receives messages but doesn't process them during keygen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../use_cases/participate_keygen.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/mpc-system/services/server-party/application/use_cases/participate_keygen.go b/backend/mpc-system/services/server-party/application/use_cases/participate_keygen.go index 70db6862..82b4f763 100644 --- a/backend/mpc-system/services/server-party/application/use_cases/participate_keygen.go +++ b/backend/mpc-system/services/server-party/application/use_cases/participate_keygen.go @@ -121,7 +121,15 @@ func (uc *ParticipateKeygenUseCase) Execute( if p.PartyID == input.PartyID { selfIndex = p.PartyIndex } + logger.Debug("Added participant to index map", + zap.String("party_id", p.PartyID), + zap.Int("party_index", p.PartyIndex)) } + logger.Info("Built party index map", + zap.String("session_id", input.SessionID.String()), + zap.String("self_party_id", input.PartyID), + zap.Int("self_index", selfIndex), + zap.Int("total_participants", len(sessionInfo.Participants))) // 3. Subscribe to messages msgChan, err := uc.messageRouter.SubscribeMessages(ctx, input.SessionID, input.PartyID) @@ -303,16 +311,28 @@ func (h *keygenMessageHandler) convertMessages(ctx context.Context, inChan <-cha for { select { case <-ctx.Done(): + logger.Debug("convertMessages context cancelled", zap.String("session_id", h.sessionID.String())) close(h.msgChan) return case msg, ok := <-inChan: if !ok { + logger.Debug("convertMessages inChan closed", zap.String("session_id", h.sessionID.String())) close(h.msgChan) return } + logger.Debug("Received MPC message for conversion", + zap.String("session_id", h.sessionID.String()), + zap.String("from_party", msg.FromParty), + zap.Bool("is_broadcast", msg.IsBroadcast), + zap.Int("payload_size", len(msg.Payload))) + fromIndex, exists := h.partyIndexMap[msg.FromParty] if !exists { + logger.Warn("Message from unknown party - dropping", + zap.String("session_id", h.sessionID.String()), + zap.String("from_party", msg.FromParty), + zap.Any("known_parties", h.partyIndexMap)) continue } @@ -322,8 +342,15 @@ func (h *keygenMessageHandler) convertMessages(ctx context.Context, inChan <-cha MsgBytes: msg.Payload, } + logger.Debug("Converted message, sending to TSS", + zap.String("session_id", h.sessionID.String()), + zap.String("from_party", msg.FromParty), + zap.Int("from_index", fromIndex)) + select { case h.msgChan <- tssMsg: + logger.Debug("Message sent to TSS successfully", + zap.String("session_id", h.sessionID.String())) case <-ctx.Done(): return }