debug(keygen): add detailed logging for message flow tracking

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 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-06 06:45:23 -08:00
parent 5344af465b
commit e786219f37
1 changed files with 27 additions and 0 deletions

View File

@ -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
}