From 1b48c05aa773c22b84516474ab9afa0705658b6a Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 29 Dec 2025 11:59:53 -0800 Subject: [PATCH] =?UTF-8?q?fix(mpc-system):=20GetSessionStatus=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=AE=9E=E9=99=85=E7=9A=84=20threshold=5Fn=20?= =?UTF-8?q?=E5=92=8C=20threshold=5Ft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - Message Router 的 GetSessionStatus 把 TotalParties 当作 ThresholdN 返回 - 导致 server-party 收到错误的 threshold_n=2 而不是 3 - TSS 协议无法正确启动(参与者数量验证失败) 修复: - 在 session_coordinator.proto 添加 threshold_n 和 threshold_t 字段 - Session Coordinator 返回实际的 threshold 值 - Message Router 透传 threshold 值而不是参与者数量 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 --- .../coordinator/v1/session_coordinator.pb.go | 29 +++++++++++++++++-- .../api/proto/session_coordinator.proto | 4 +++ .../input/grpc/message_grpc_handler.go | 6 ++-- .../input/grpc/session_grpc_handler.go | 2 ++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backend/mpc-system/api/grpc/coordinator/v1/session_coordinator.pb.go b/backend/mpc-system/api/grpc/coordinator/v1/session_coordinator.pb.go index 3dd3eeec..a28e699a 100644 --- a/backend/mpc-system/api/grpc/coordinator/v1/session_coordinator.pb.go +++ b/backend/mpc-system/api/grpc/coordinator/v1/session_coordinator.pb.go @@ -850,7 +850,11 @@ type GetSessionStatusResponse struct { DelegateShare *DelegateShareInfo `protobuf:"bytes,8,opt,name=delegate_share,json=delegateShare,proto3" json:"delegate_share,omitempty"` // participants contains detailed participant information including party_index // Used by service-party-app for co_managed_keygen sessions - Participants []*ParticipantStatus `protobuf:"bytes,9,rep,name=participants,proto3" json:"participants,omitempty"` + Participants []*ParticipantStatus `protobuf:"bytes,9,rep,name=participants,proto3" json:"participants,omitempty"` + // threshold_n and threshold_t - actual threshold values from session config + // Used for co_managed_keygen sessions where total_parties may differ from threshold_n during joining + ThresholdN int32 `protobuf:"varint,10,opt,name=threshold_n,json=thresholdN,proto3" json:"threshold_n,omitempty"` // Total number of parties required (e.g., 3 in 2-of-3) + ThresholdT int32 `protobuf:"varint,11,opt,name=threshold_t,json=thresholdT,proto3" json:"threshold_t,omitempty"` // Minimum parties needed to sign (e.g., 2 in 2-of-3) unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -948,6 +952,20 @@ func (x *GetSessionStatusResponse) GetParticipants() []*ParticipantStatus { return nil } +func (x *GetSessionStatusResponse) GetThresholdN() int32 { + if x != nil { + return x.ThresholdN + } + return 0 +} + +func (x *GetSessionStatusResponse) GetThresholdT() int32 { + if x != nil { + return x.ThresholdT + } + return 0 +} + // ParticipantStatus contains participant status information type ParticipantStatus struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1718,7 +1736,7 @@ const file_session_coordinator_proto_rawDesc = "" + "deviceInfo\"8\n" + "\x17GetSessionStatusRequest\x12\x1d\n" + "\n" + - "session_id\x18\x01 \x01(\tR\tsessionId\"\xa0\x03\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\"\xe2\x03\n" + "\x18GetSessionStatusResponse\x12\x16\n" + "\x06status\x18\x01 \x01(\tR\x06status\x12+\n" + "\x11completed_parties\x18\x02 \x01(\x05R\x10completedParties\x12#\n" + @@ -1729,7 +1747,12 @@ const file_session_coordinator_proto_rawDesc = "" + "\tsignature\x18\x06 \x01(\fR\tsignature\x12!\n" + "\fhas_delegate\x18\a \x01(\bR\vhasDelegate\x12L\n" + "\x0edelegate_share\x18\b \x01(\v2%.mpc.coordinator.v1.DelegateShareInfoR\rdelegateShare\x12I\n" + - "\fparticipants\x18\t \x03(\v2%.mpc.coordinator.v1.ParticipantStatusR\fparticipants\"g\n" + + "\fparticipants\x18\t \x03(\v2%.mpc.coordinator.v1.ParticipantStatusR\fparticipants\x12\x1f\n" + + "\vthreshold_n\x18\n" + + " \x01(\x05R\n" + + "thresholdN\x12\x1f\n" + + "\vthreshold_t\x18\v \x01(\x05R\n" + + "thresholdT\"g\n" + "\x11ParticipantStatus\x12\x19\n" + "\bparty_id\x18\x01 \x01(\tR\apartyId\x12\x1f\n" + "\vparty_index\x18\x02 \x01(\x05R\n" + diff --git a/backend/mpc-system/api/proto/session_coordinator.proto b/backend/mpc-system/api/proto/session_coordinator.proto index f0ab1cac..d70eedbb 100644 --- a/backend/mpc-system/api/proto/session_coordinator.proto +++ b/backend/mpc-system/api/proto/session_coordinator.proto @@ -135,6 +135,10 @@ message GetSessionStatusResponse { // participants contains detailed participant information including party_index // Used by service-party-app for co_managed_keygen sessions repeated ParticipantStatus participants = 9; + // threshold_n and threshold_t - actual threshold values from session config + // Used for co_managed_keygen sessions where total_parties may differ from threshold_n during joining + int32 threshold_n = 10; // Total number of parties required (e.g., 3 in 2-of-3) + int32 threshold_t = 11; // Minimum parties needed to sign (e.g., 2 in 2-of-3) } // ParticipantStatus contains participant status 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 a0f926f4..2fe78ade 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 @@ -694,9 +694,9 @@ func (s *MessageRouterServer) GetSessionStatus( return &pb.GetSessionStatusResponse{ SessionId: req.SessionId, Status: coordResp.Status, - ThresholdN: coordResp.TotalParties, // Use TotalParties as N - ThresholdT: coordResp.CompletedParties, // Return completed count in ThresholdT for info - Participants: participants, // Include participants for co_managed_keygen + ThresholdN: coordResp.ThresholdN, // Actual threshold N from session config + ThresholdT: coordResp.ThresholdT, // Actual threshold T from session config + Participants: participants, // Include participants for co_managed_keygen }, 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 0e1df4d4..16d1c2cb 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 @@ -360,6 +360,8 @@ func (s *SessionCoordinatorServer) GetSessionStatus( Signature: output.Signature, HasDelegate: output.HasDelegate, // Only meaningful for keygen sessions Participants: protoParticipants, // Include participant details with party_index + ThresholdN: int32(output.ThresholdN), + ThresholdT: int32(output.ThresholdT), } // Try to get delegate share from cache