debug: add logging for participant information in gRPC handlers

Added debug logging to track participant details including party_index in:
- account service MPC keygen handler
- session coordinator gRPC client
- session coordinator gRPC handler

This helps debug the party index assignment issue where all parties
were receiving index 0 instead of unique indices (0, 1, 2).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-05 03:11:18 -08:00
parent ac76fd80bc
commit c9cb5676d0
3 changed files with 561 additions and 526 deletions

View File

@ -8,10 +8,12 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/rwadurian/mpc-system/pkg/logger"
"github.com/rwadurian/mpc-system/services/account/adapters/output/grpc" "github.com/rwadurian/mpc-system/services/account/adapters/output/grpc"
"github.com/rwadurian/mpc-system/services/account/application/ports" "github.com/rwadurian/mpc-system/services/account/application/ports"
"github.com/rwadurian/mpc-system/services/account/application/use_cases" "github.com/rwadurian/mpc-system/services/account/application/use_cases"
"github.com/rwadurian/mpc-system/services/account/domain/value_objects" "github.com/rwadurian/mpc-system/services/account/domain/value_objects"
"go.uber.org/zap"
) )
// AccountHTTPHandler handles HTTP requests for accounts // AccountHTTPHandler handles HTTP requests for accounts
@ -579,6 +581,11 @@ func (h *AccountHTTPHandler) CreateKeygenSession(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
logger.Info("Calling CreateKeygenSession via gRPC",
zap.Int("threshold_n", req.ThresholdN),
zap.Int("threshold_t", req.ThresholdT),
zap.Int("num_participants", len(participants)))
resp, err := h.sessionCoordinatorClient.CreateKeygenSession( resp, err := h.sessionCoordinatorClient.CreateKeygenSession(
ctx, ctx,
int32(req.ThresholdN), int32(req.ThresholdN),
@ -588,10 +595,15 @@ func (h *AccountHTTPHandler) CreateKeygenSession(c *gin.Context) {
) )
if err != nil { if err != nil {
logger.Error("gRPC CreateKeygenSession failed", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return return
} }
logger.Info("gRPC CreateKeygenSession succeeded",
zap.String("session_id", resp.SessionID),
zap.Int("num_join_tokens", len(resp.JoinTokens)))
c.JSON(http.StatusCreated, gin.H{ c.JSON(http.StatusCreated, gin.H{
"session_id": resp.SessionID, "session_id": resp.SessionID,
"session_type": "keygen", "session_type": "keygen",

View File

@ -91,11 +91,21 @@ func (c *SessionCoordinatorClient) CreateKeygenSession(
ExpiresInSeconds: expiresInSeconds, ExpiresInSeconds: expiresInSeconds,
} }
logger.Info("Sending CreateSession gRPC request",
zap.String("session_type", "keygen"),
zap.Int32("threshold_n", thresholdN),
zap.Int32("threshold_t", thresholdT))
resp, err := c.client.CreateSession(ctx, req) resp, err := c.client.CreateSession(ctx, req)
if err != nil { if err != nil {
logger.Error("CreateSession gRPC call failed", zap.Error(err))
return nil, fmt.Errorf("failed to create keygen session: %w", err) return nil, fmt.Errorf("failed to create keygen session: %w", err)
} }
logger.Info("CreateSession gRPC call succeeded",
zap.String("session_id", resp.SessionId),
zap.Int("num_join_tokens", len(resp.JoinTokens)))
return &CreateSessionResponse{ return &CreateSessionResponse{
SessionID: resp.SessionId, SessionID: resp.SessionId,
JoinTokens: resp.JoinTokens, JoinTokens: resp.JoinTokens,

View File

@ -6,11 +6,13 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
pb "github.com/rwadurian/mpc-system/api/grpc/coordinator/v1" pb "github.com/rwadurian/mpc-system/api/grpc/coordinator/v1"
"github.com/rwadurian/mpc-system/pkg/logger"
"github.com/rwadurian/mpc-system/services/session-coordinator/application/ports/input" "github.com/rwadurian/mpc-system/services/session-coordinator/application/ports/input"
"github.com/rwadurian/mpc-system/services/session-coordinator/application/use_cases" "github.com/rwadurian/mpc-system/services/session-coordinator/application/use_cases"
"github.com/rwadurian/mpc-system/services/session-coordinator/domain/entities" "github.com/rwadurian/mpc-system/services/session-coordinator/domain/entities"
"github.com/rwadurian/mpc-system/services/session-coordinator/domain/repositories" "github.com/rwadurian/mpc-system/services/session-coordinator/domain/repositories"
"github.com/rwadurian/mpc-system/services/session-coordinator/domain/value_objects" "github.com/rwadurian/mpc-system/services/session-coordinator/domain/value_objects"
"go.uber.org/zap"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
@ -50,6 +52,12 @@ func (s *SessionCoordinatorServer) CreateSession(
ctx context.Context, ctx context.Context,
req *pb.CreateSessionRequest, req *pb.CreateSessionRequest,
) (*pb.CreateSessionResponse, error) { ) (*pb.CreateSessionResponse, error) {
logger.Info("gRPC CreateSession received",
zap.String("session_type", req.SessionType),
zap.Int32("threshold_n", req.ThresholdN),
zap.Int32("threshold_t", req.ThresholdT),
zap.Int("num_participants", len(req.Participants)))
// Convert request to input // Convert request to input
participants := make([]input.ParticipantInfo, len(req.Participants)) participants := make([]input.ParticipantInfo, len(req.Participants))
for i, p := range req.Participants { for i, p := range req.Participants {
@ -81,9 +89,14 @@ func (s *SessionCoordinatorServer) CreateSession(
// Execute use case // Execute use case
output, err := s.createSessionUC.Execute(ctx, inputData) output, err := s.createSessionUC.Execute(ctx, inputData)
if err != nil { if err != nil {
logger.Error("gRPC CreateSession use case failed", zap.Error(err))
return nil, toGRPCError(err) return nil, toGRPCError(err)
} }
logger.Info("gRPC CreateSession completed successfully",
zap.String("session_id", output.SessionID.String()),
zap.Int("num_join_tokens", len(output.JoinTokens)))
// Convert output to response // Convert output to response
return &pb.CreateSessionResponse{ return &pb.CreateSessionResponse{
SessionId: output.SessionID.String(), SessionId: output.SessionID.String(),