Commit Graph

13 Commits

Author SHA1 Message Date
hailin 43016e9ee8 fix(prisma): remove redundant migrations and duplicate indexes
- mpc-service: remove duplicate index idx_ms_username on mpc_shares.username
  (keep only unique index uq_ms_username since username is unique)
- identity-service: remove redundant migration 20241206000000_add_device_hardware_info
  (fields already exist in initial migration 20241204000000_init)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 07:08:24 -08:00
hailin bad6ba2232 fix(mpc-service): use @unique on username field for Prisma upsert compatibility 2025-12-07 02:19:17 -08:00
hailin 289691dc3c fix: align mpc-service migration with schema and fix identity-service compile errors
- Update mpc-service migration to match new gateway mode schema (mpc_wallets, mpc_shares)
- Remove old MySQL migrations (party_shares, session_states, share_backups)
- Fix MpcSignature type to use string format (64 bytes hex: R + S)
- Add persistence layer conversion functions for DB compatibility
- Fix method names in domain services (checkDeviceNotRegistered, generateNextUserSequence)
- Update wallet generator interface to use delegateShare instead of clientShareData

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 18:42:48 -08:00
hailin 9c36e6772b refactor: simplify mpc-service to gateway mode
mpc-service 重新定位为网关服务,转发请求到 mpc-system:
- 简化 Prisma schema:只保留 MpcWallet 和 MpcShare
- 添加 delegate share 存储(keygen 后保存用户的 share)
- 保留六边形架构结构,清理不再需要的实现
- 删除旧的 command handlers、queries、repository 实现
- 简化 infrastructure module,只保留 PrismaService

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 17:16:14 -08:00
hailin 747e4ae8ef refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing
- Remove Address field from PartyEndpoint (parties connect to router themselves)
- Update K8s Discovery to only manage PartyID and Role labels
- Add Party registration and SessionEvent protobuf definitions
- Implement PartyRegistry and SessionEventBroadcaster domain logic
- Add RegisterParty and SubscribeSessionEvents gRPC handlers
- Prepare infrastructure for party-driven MPC coordination

This is the first phase of migrating from coordinator-driven to party-driven
architecture following international MPC system design patterns.
2025-12-05 08:11:28 -08:00
Developer 9dee0d36a5 feat(backup,mpc): 添加 prisma 迁移文件
backup-service 和 mpc-service 缺少 prisma/migrations 目录
导致 prisma migrate deploy 无法执行

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 04:01:47 -08:00
Developer 9363e4991f fix(mpc-service): 使用 prisma db push 自动同步数据库 schema
- 容器启动时执行 prisma db push 自动创建/同步表结构
- 删除 migrations 目录,不再使用 migrate 机制
- 这是标准做法:schema.prisma 定义表结构,db push 同步到数据库

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:56:30 -08:00
Developer 8850ea6ab0 fix(mpc-service): 重构数据库迁移机制,从根本解决表不存在问题
问题分析:
- 旧迁移文件只有 party_shares 表,缺少 session_states 和 share_backups 表
- Prisma 的 _prisma_migrations 表记录迁移已完成,导致新表无法创建
- 迁移状态与实际数据库不一致

解决方案:
1. 删除旧迁移目录,创建全新的 0001_init 迁移
2. 新迁移包含所有三个表: party_shares, session_states, share_backups
3. 添加 docker-entrypoint.sh 启动脚本,容器启动时自动运行迁移
4. 修改 Dockerfile 使用 entrypoint 脚本

deploy.sh 新增命令:
- migrate-reset: 重置数据库并重新运行迁移
- migrate-push: 强制同步 schema (创建缺失的表)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:47:42 -08:00
Developer 122bf84c24 fix(mpc-service): 修复数据库迁移,添加缺失的表
migration.sql 与 schema.prisma 不同步,缺失以下表:
- session_states: 会话状态跟踪表
- share_backups: 分片备份表

同时修复了索引名称以匹配 schema 定义。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:32:36 -08:00
Developer 451aa8fae8 feat(mpc-service): 添加初始数据库 migration
创建 party_shares 和 signing_sessions 表及索引
修复健康检查失败问题(缺少数据库表)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:03:03 -08:00
Developer b224e209a6 fix(mpc-service): 修复PostgreSQL兼容性问题
1. Dockerfile: 将DATABASE_URL协议从mysql改为postgresql
2. schema.prisma: 重命名索引以满足PostgreSQL全局唯一性要求
   - idx_party_id -> idx_ps_party_id (party_shares)
   - idx_session_id -> idx_ps_session_id (party_shares)
   - idx_status -> idx_ps_status (party_shares)
   - idx_session_id -> idx_ss_session_id (session_states)
   - idx_party_id -> idx_ss_party_id (session_states)
   - idx_status -> idx_ss_status (session_states)

已在WSL2中验证Docker构建成功。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 06:09:16 -08:00
Developer a9594ef15e fix(mpc-service): 修复数据库provider从mysql改为postgresql
mpc-service错误配置为mysql,与项目统一使用的postgresql不一致,
导致服务启动时Prisma验证DATABASE_URL失败。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 05:54:07 -08:00
hailin 6fa4d7ac1d feat: 添加MPC多方计算服务模块
新增 mpc-service 微服务,实现 MPC-TSS 门限签名功能:

架构设计:
- 采用六边形架构(Hexagonal Architecture)
- 实现 CQRS 命令查询职责分离模式
- 遵循 DDD 领域驱动设计原则

核心功能:
- Keygen: 分布式密钥生成协议参与
- Signing: 门限签名协议参与
- Share Rotation: 密钥份额轮换
- Share Management: 份额查询和管理

技术栈:
- NestJS + TypeScript
- Prisma ORM
- Redis (缓存和分布式锁)
- Kafka (事件发布)
- Jest (单元/集成/E2E测试)

测试覆盖:
- 单元测试: 81个
- 集成测试: 30个
- E2E测试: 15个
- 总计: 111个测试全部通过

文档:
- ARCHITECTURE.md: 架构设计文档
- API.md: REST API接口文档
- TESTING.md: 测试架构说明
- DEVELOPMENT.md: 开发指南
- DEPLOYMENT.md: 部署运维文档

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:31:43 -08:00