diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 91d1a29b..65d553a5 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -9,7 +9,11 @@ "Bash(cat:*)", "Bash(git add:*)", "Bash(git commit:*)", - "Bash(git push)" + "Bash(git push)", + "Bash(find:*)", + "Bash(npm run build:*)", + "Bash(npx prisma generate:*)", + "Bash(npx tsc:*)" ], "deny": [], "ask": [] diff --git a/backend/services/backup-service/src/api/controllers/backup-share.controller.ts b/backend/services/backup-service/src/api/controllers/backup-share.controller.ts index 6cbd7694..380f3f4e 100644 --- a/backend/services/backup-service/src/api/controllers/backup-share.controller.ts +++ b/backend/services/backup-service/src/api/controllers/backup-share.controller.ts @@ -6,6 +6,7 @@ import { HttpCode, HttpStatus, Req, + Logger, } from '@nestjs/common'; import { BackupShareApplicationService } from '../../application/services/backup-share-application.service'; import { StoreBackupShareCommand } from '../../application/commands/store-backup-share/store-backup-share.command'; @@ -24,6 +25,8 @@ import { @Controller('backup-share') @UseGuards(ServiceAuthGuard) export class BackupShareController { + private readonly logger = new Logger(BackupShareController.name); + constructor( private readonly backupShareService: BackupShareApplicationService, ) {} @@ -34,24 +37,33 @@ export class BackupShareController { @Body() dto: StoreShareDto, @Req() request: any, ): Promise { - const command = new StoreBackupShareCommand( - dto.userId, - dto.accountSequence, - dto.publicKey, - dto.encryptedShareData, - request.sourceService, - request.sourceIp, - dto.threshold, - dto.totalParties, - ); + this.logger.log(`[STORE] Received store request: userId=${dto.userId}, accountSequence=${dto.accountSequence}, publicKey=${dto.publicKey?.substring(0, 20)}...`); - const result = await this.backupShareService.storeBackupShare(command); + try { + const command = new StoreBackupShareCommand( + dto.userId, + dto.accountSequence, + dto.publicKey, + dto.encryptedShareData, + request.sourceService, + request.sourceIp, + dto.threshold, + dto.totalParties, + ); - return { - success: true, - shareId: result.shareId, - message: 'Backup share stored successfully', - }; + const result = await this.backupShareService.storeBackupShare(command); + + this.logger.log(`[STORE] SUCCESS: shareId=${result.shareId}, userId=${dto.userId}, accountSequence=${dto.accountSequence}`); + + return { + success: true, + shareId: result.shareId, + message: 'Backup share stored successfully', + }; + } catch (error) { + this.logger.error(`[STORE] FAILED: userId=${dto.userId}, accountSequence=${dto.accountSequence}, error=${error.message}`); + throw error; + } } @Post('retrieve') diff --git a/backend/services/mpc-service/src/application/event-handlers/keygen-requested.handler.ts b/backend/services/mpc-service/src/application/event-handlers/keygen-requested.handler.ts index 20dfaf0a..c0a68b60 100644 --- a/backend/services/mpc-service/src/application/event-handlers/keygen-requested.handler.ts +++ b/backend/services/mpc-service/src/application/event-handlers/keygen-requested.handler.ts @@ -105,13 +105,14 @@ export class KeygenRequestedHandler implements OnModuleInit { try { await this.backupClient.storeBackupShare({ userId, + accountSequence, username, publicKey: result.publicKey, partyId: result.delegateShare.partyId, partyIndex: result.delegateShare.partyIndex, encryptedShare: result.delegateShare.encryptedShare, }); - this.logger.log(`Delegate share stored to backup-service: userId=${userId}`); + this.logger.log(`Delegate share stored to backup-service: userId=${userId}, accountSequence=${accountSequence}`); } catch (backupError) { // 备份失败不阻塞主流程,但记录错误 this.logger.error(`Failed to store delegate share to backup-service: userId=${userId}`, backupError); diff --git a/backend/services/mpc-service/src/infrastructure/external/backup/backup-client.service.ts b/backend/services/mpc-service/src/infrastructure/external/backup/backup-client.service.ts index e6387115..b9d563ea 100644 --- a/backend/services/mpc-service/src/infrastructure/external/backup/backup-client.service.ts +++ b/backend/services/mpc-service/src/infrastructure/external/backup/backup-client.service.ts @@ -13,6 +13,7 @@ import * as jwt from 'jsonwebtoken'; export interface StoreBackupShareParams { userId: string; + accountSequence: number; username: string; publicKey: string; partyId: string; @@ -77,10 +78,8 @@ export class BackupClientService { `${this.backupServiceUrl}/backup-share/store`, { userId: params.userId, - username: params.username, + accountSequence: params.accountSequence, publicKey: params.publicKey, - partyId: params.partyId, - partyIndex: params.partyIndex, encryptedShareData: params.encryptedShare, }, {