From 78119bc6a46d4016f556856a8c04f6e6fabcd750 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 6 Dec 2025 00:08:47 -0800 Subject: [PATCH] fix(proto): add party_index to JoinSessionResponse for correct index assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The JoinSessionResponse from coordinator was missing party_index field, causing message router to try finding self's index in OtherParties (which only contains other parties). This resulted in incorrect party index assignment leading to "duplicate indexes" error in TSS keygen. Changes: - Add party_index field to coordinator's JoinSessionResponse proto - Coordinator now includes PartyIndex in gRPC response - Message router uses party_index from coordinator instead of searching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/mpc-system/api/proto/session_coordinator.proto | 1 + .../adapters/input/grpc/message_grpc_handler.go | 8 ++++---- .../adapters/input/grpc/session_grpc_handler.go | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/mpc-system/api/proto/session_coordinator.proto b/backend/mpc-system/api/proto/session_coordinator.proto index c1aceb1c..506c41df 100644 --- a/backend/mpc-system/api/proto/session_coordinator.proto +++ b/backend/mpc-system/api/proto/session_coordinator.proto @@ -82,6 +82,7 @@ message JoinSessionResponse { bool success = 1; SessionInfo session_info = 2; repeated PartyInfo other_parties = 3; + int32 party_index = 4; // This party's assigned index } // SessionInfo contains session information diff --git a/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go b/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go index 7d51fd19..042751d1 100644 --- a/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go +++ b/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go @@ -518,6 +518,9 @@ func (s *MessageRouterServer) JoinSession( } } + // Use party_index directly from coordinator response + resp.PartyIndex = coordResp.PartyIndex + if len(coordResp.OtherParties) > 0 { resp.OtherParties = make([]*pb.PartyInfo, len(coordResp.OtherParties)) for i, p := range coordResp.OtherParties { @@ -525,16 +528,13 @@ func (s *MessageRouterServer) JoinSession( PartyId: p.PartyId, PartyIndex: p.PartyIndex, } - // Find this party's index - if p.PartyId == req.PartyId { - resp.PartyIndex = p.PartyIndex - } } } logger.Info("Proxied JoinSession to coordinator", zap.String("session_id", req.SessionId), zap.String("party_id", req.PartyId), + zap.Int32("party_index", resp.PartyIndex), zap.Bool("success", resp.Success)) return resp, nil diff --git a/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go b/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go index 2f986ed9..8fa0762e 100644 --- a/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go +++ b/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go @@ -251,6 +251,7 @@ func (s *SessionCoordinatorServer) JoinSession( Status: output.SessionInfo.Status, }, OtherParties: otherParties, + PartyIndex: int32(output.PartyIndex), }, nil }