fix(session-coordinator): pass PartyComposition from gRPC request to use case
Fixed critical bug where PartyComposition (persistent/delegate party counts) was being sent by account-service in gRPC request but was not being extracted and passed to the CreateSession use case, causing delegate party selection to fail. Changes: - Extract PartyComposition from protobuf request and pass to CreateSessionInput - Add logging for party composition values in gRPC handler - Return delegate_party_id and selected_parties in CreateSessionResponse - Load session after creation to get delegate party ID This fixes the issue where require_delegate=true had no effect and all parties selected were persistent parties instead of 2 persistent + 1 delegate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c5d3840835
commit
36e1359f43
|
|
@ -160,6 +160,19 @@ func (s *SessionCoordinatorServer) CreateSession(
|
|||
ExpiresIn: time.Duration(req.ExpiresInSeconds) * time.Second,
|
||||
}
|
||||
|
||||
// Add party composition if provided (for automatic party selection)
|
||||
if req.PartyComposition != nil {
|
||||
inputData.PartyComposition = &input.PartyComposition{
|
||||
PersistentCount: int(req.PartyComposition.PersistentCount),
|
||||
DelegateCount: int(req.PartyComposition.DelegateCount),
|
||||
TemporaryCount: int(req.PartyComposition.TemporaryCount),
|
||||
}
|
||||
logger.Info("Party composition specified in gRPC request",
|
||||
zap.Int("persistent_count", inputData.PartyComposition.PersistentCount),
|
||||
zap.Int("delegate_count", inputData.PartyComposition.DelegateCount),
|
||||
zap.Int("temporary_count", inputData.PartyComposition.TemporaryCount))
|
||||
}
|
||||
|
||||
// Add delegate user share if provided (for sign sessions with delegate party)
|
||||
if req.DelegateUserShare != nil {
|
||||
inputData.DelegateUserShare = &input.DelegateUserShare{
|
||||
|
|
@ -180,11 +193,28 @@ func (s *SessionCoordinatorServer) CreateSession(
|
|||
zap.String("session_id", output.SessionID.String()),
|
||||
zap.Int("num_join_tokens", len(output.JoinTokens)))
|
||||
|
||||
// Load session to get delegate party ID
|
||||
session, err := s.sessionRepo.FindByUUID(ctx, output.SessionID)
|
||||
if err != nil {
|
||||
logger.Error("Failed to load session after creation", zap.Error(err))
|
||||
return nil, toGRPCError(err)
|
||||
}
|
||||
|
||||
// Extract selected party IDs from join tokens
|
||||
selectedParties := make([]string, 0, len(output.JoinTokens))
|
||||
for partyID := range output.JoinTokens {
|
||||
if partyID != "*" { // Exclude universal token
|
||||
selectedParties = append(selectedParties, partyID)
|
||||
}
|
||||
}
|
||||
|
||||
// Convert output to response
|
||||
return &pb.CreateSessionResponse{
|
||||
SessionId: output.SessionID.String(),
|
||||
JoinTokens: output.JoinTokens,
|
||||
ExpiresAt: output.ExpiresAt.UnixMilli(),
|
||||
SessionId: output.SessionID.String(),
|
||||
JoinTokens: output.JoinTokens,
|
||||
ExpiresAt: output.ExpiresAt.UnixMilli(),
|
||||
SelectedParties: selectedParties,
|
||||
DelegatePartyId: session.DelegatePartyID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ func main() {
|
|||
|
||||
// Create keygen session via account-service
|
||||
sessionData := map[string]interface{}{
|
||||
"threshold_n": 3,
|
||||
"threshold_t": 2,
|
||||
"username": "admin",
|
||||
"threshold_n": 3,
|
||||
"threshold_t": 2,
|
||||
"username": "admin",
|
||||
"require_delegate": true,
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(sessionData)
|
||||
|
|
|
|||
Loading…
Reference in New Issue