debug(service-party-app): 添加 keygen 触发流程详细日志
添加 [KEYGEN] 前缀的 console.log 来追踪: - checkAndTriggerKeygen 是否被调用 - activeKeygenSession 的状态 - 轮询条件是否满足 - handleSessionStart 的执行 - participateKeygen 的参数 帮助诊断 external party 为何不启动 TSS 进程 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
576679ae30
commit
75a2470233
|
|
@ -128,14 +128,23 @@ function cleanExpiredEventCache() {
|
|||
// 检查并触发 keygen(100% 可靠方案:轮询等待所有参与者加入)
|
||||
// 与 server-party 的 waitForAllParticipants 逻辑保持一致
|
||||
async function checkAndTriggerKeygen(sessionId: string) {
|
||||
console.log('[KEYGEN] checkAndTriggerKeygen called with sessionId:', sessionId);
|
||||
|
||||
if (!activeKeygenSession || activeKeygenSession.sessionId !== sessionId) {
|
||||
console.log('No matching active keygen session for', sessionId);
|
||||
console.log('[KEYGEN] No matching active keygen session for', sessionId);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[KEYGEN] Active session found:', {
|
||||
sessionId: activeKeygenSession.sessionId,
|
||||
partyIndex: activeKeygenSession.partyIndex,
|
||||
threshold: activeKeygenSession.threshold,
|
||||
participantCount: activeKeygenSession.participants.length,
|
||||
});
|
||||
|
||||
// 如果 TSS 已经在运行,不重复触发
|
||||
if (tssHandler?.getIsRunning()) {
|
||||
console.log('TSS already running, skip check');
|
||||
console.log('[KEYGEN] TSS already running, skip check');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +152,7 @@ async function checkAndTriggerKeygen(sessionId: string) {
|
|||
const maxWaitMs = 5 * 60 * 1000; // 5分钟超时
|
||||
const startTime = Date.now();
|
||||
|
||||
console.log('[KEYGEN] Starting to poll session status...');
|
||||
debugLog.info('main', `Starting to poll session status for ${sessionId}`);
|
||||
|
||||
while (Date.now() - startTime < maxWaitMs) {
|
||||
|
|
@ -180,7 +190,16 @@ async function checkAndTriggerKeygen(sessionId: string) {
|
|||
status.status === 'all_joined' ||
|
||||
status.status === 'waiting_for_keygen';
|
||||
|
||||
console.log('[KEYGEN] Check conditions:', {
|
||||
hasAllParticipants,
|
||||
statusReady,
|
||||
currentParticipants,
|
||||
expectedN,
|
||||
status: status.status,
|
||||
});
|
||||
|
||||
if (hasAllParticipants && statusReady) {
|
||||
console.log('[KEYGEN] Conditions met! Triggering keygen...');
|
||||
debugLog.info('main', `All ${expectedN} participants joined (status: ${status.status}), triggering keygen...`);
|
||||
|
||||
// 使用后端返回的 participants 信息(包含正确的 party_index)
|
||||
|
|
@ -393,7 +412,16 @@ async function handleSessionStart(event: {
|
|||
thresholdT: number;
|
||||
selectedParties: string[];
|
||||
}) {
|
||||
console.log('[KEYGEN] handleSessionStart called:', {
|
||||
eventType: event.eventType,
|
||||
sessionId: event.sessionId,
|
||||
thresholdN: event.thresholdN,
|
||||
thresholdT: event.thresholdT,
|
||||
selectedParties: event.selectedParties?.length,
|
||||
});
|
||||
|
||||
if (!activeKeygenSession) {
|
||||
console.log('[KEYGEN] No active keygen session, ignoring');
|
||||
debugLog.debug('main', 'No active keygen session, ignoring session start event');
|
||||
return;
|
||||
}
|
||||
|
|
@ -472,6 +500,13 @@ async function handleSessionStart(event: {
|
|||
})))}`);
|
||||
}
|
||||
|
||||
console.log('[KEYGEN] Calling tssHandler.participateKeygen with:', {
|
||||
sessionId: activeKeygenSession.sessionId,
|
||||
partyId: grpcClient?.getPartyId(),
|
||||
partyIndex: activeKeygenSession.partyIndex,
|
||||
participants: activeKeygenSession.participants.map(p => ({ partyId: p.partyId.substring(0, 8), partyIndex: p.partyIndex })),
|
||||
threshold: activeKeygenSession.threshold,
|
||||
});
|
||||
debugLog.info('tss', `Starting keygen for session ${event.sessionId}...`);
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue