debug: add TSS signing debug logs to diagnose stuck issue

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-06 09:41:31 -08:00
parent f70ece0d4f
commit 378970048b
1 changed files with 29 additions and 1 deletions

View File

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