From 378970048bd56e8bbc0b1f6336c731e13ef674d2 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 6 Dec 2025 09:41:31 -0800 Subject: [PATCH] debug: add TSS signing debug logs to diagnose stuck issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/mpc-system/pkg/tss/signing.go | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/mpc-system/pkg/tss/signing.go b/backend/mpc-system/pkg/tss/signing.go index 4db22a62..4d37ed2f 100644 --- a/backend/mpc-system/pkg/tss/signing.go +++ b/backend/mpc-system/pkg/tss/signing.go @@ -182,16 +182,20 @@ func (s *SigningSession) Start(ctx context.Context) (*SigningResult, error) { } func (s *SigningSession) handleOutgoingMessages(ctx context.Context) { + fmt.Printf("[TSS-SIGN] handleOutgoingMessages started party_id=%s\n", s.selfParty.PartyID) for { select { case <-ctx.Done(): + fmt.Printf("[TSS-SIGN] handleOutgoingMessages context cancelled party_id=%s\n", s.selfParty.PartyID) return case msg := <-s.outCh: if msg == nil { + fmt.Printf("[TSS-SIGN] handleOutgoingMessages received nil message, stopping party_id=%s\n", s.selfParty.PartyID) return } msgBytes, _, err := msg.WireBytes() if err != nil { + fmt.Printf("[TSS-SIGN] Failed to get wire bytes party_id=%s error=%v\n", s.selfParty.PartyID, err) continue } @@ -203,7 +207,11 @@ func (s *SigningSession) handleOutgoingMessages(ctx context.Context) { } } + fmt.Printf("[TSS-SIGN] sending outgoing message party_id=%s is_broadcast=%v to_parties=%v msg_type=%s\n", + s.selfParty.PartyID, isBroadcast, toParties, msg.Type()) + if err := s.msgHandler.SendMessage(ctx, isBroadcast, toParties, msgBytes); err != nil { + fmt.Printf("[TSS-SIGN] Failed to send message party_id=%s error=%v\n", s.selfParty.PartyID, err) continue } } @@ -211,29 +219,49 @@ func (s *SigningSession) handleOutgoingMessages(ctx context.Context) { } func (s *SigningSession) handleIncomingMessages(ctx context.Context) { + fmt.Printf("[TSS-SIGN] handleIncomingMessages started party_id=%s\n", s.selfParty.PartyID) msgCh := s.msgHandler.ReceiveMessages() for { select { case <-ctx.Done(): + fmt.Printf("[TSS-SIGN] handleIncomingMessages context cancelled party_id=%s\n", s.selfParty.PartyID) return case msg, ok := <-msgCh: if !ok { + fmt.Printf("[TSS-SIGN] handleIncomingMessages channel closed party_id=%s\n", s.selfParty.PartyID) return } + fmt.Printf("[TSS-SIGN] received incoming message party_id=%s from_index=%d is_broadcast=%v msg_len=%d\n", + s.selfParty.PartyID, msg.FromPartyIndex, msg.IsBroadcast, len(msg.MsgBytes)) + + // Check if FromPartyIndex is valid + if msg.FromPartyIndex < 0 || msg.FromPartyIndex >= len(s.tssPartyIDs) { + fmt.Printf("[TSS-SIGN] ERROR: invalid FromPartyIndex=%d, len(tssPartyIDs)=%d party_id=%s\n", + msg.FromPartyIndex, len(s.tssPartyIDs), s.selfParty.PartyID) + continue + } + // Parse the message parsedMsg, err := tss.ParseWireMessage(msg.MsgBytes, s.tssPartyIDs[msg.FromPartyIndex], msg.IsBroadcast) if err != nil { + fmt.Printf("[TSS-SIGN] ERROR: failed to parse wire message party_id=%s from_index=%d error=%v\n", + s.selfParty.PartyID, msg.FromPartyIndex, err) continue } + fmt.Printf("[TSS-SIGN] parsed message successfully party_id=%s msg_type=%s\n", + s.selfParty.PartyID, parsedMsg.Type()) + // Update the party go func() { ok, err := s.localParty.Update(parsedMsg) if err != nil { + fmt.Printf("[TSS-SIGN] ERROR: party update failed party_id=%s error=%v\n", s.selfParty.PartyID, err) s.errCh <- err + } else { + fmt.Printf("[TSS-SIGN] party update succeeded party_id=%s ok=%v\n", s.selfParty.PartyID, ok) } - _ = ok }() } }