hailin
8cfd107a92
refactor(pool-accounts): 移除硬编码钱包名,改为从后端 API 动态获取
...
- 后端: 新增 GET /admin/pool-accounts 接口,返回从 .env 配置的池账户列表
- 前端: 新增 usePoolAccounts hook,动态渲染池账户卡片
- 前端: 提取 PoolAccountCard 子组件,消除重复代码
- 移除前端硬编码的 BURN_POOL_WALLET_NAME / MINING_POOL_WALLET_NAME 常量
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:57:40 -08:00
hailin
7972163af6
fix(docker): 移除池账户钱包硬编码默认值,改为从 .env 读取
...
所有池账户钱包配置(USERNAME/ADDRESS)不再有硬编码默认值,
必须在 .env 中配置才会生效。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:54:00 -08:00
hailin
c89c8769d9
fix(docker): 设置池账户钱包地址默认值
...
从 .env.example 获取池账户 MPC 钱包地址作为 docker-compose 默认值:
- BURN_POOL_WALLET_ADDRESS: 0xdE2932D2A25e1698c1354A41e2e46B414C46F5a1
- MINING_POOL_WALLET_ADDRESS: 0x8BC9091375ae8ef43ae011F0f9bAf10e51bC9D59
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:48:58 -08:00
hailin
a8098d801b
fix(docker): 添加池账户 MPC 钱包环境变量到 mining-blockchain-service
...
为100亿销毁池和200万挖矿池添加 BURN_POOL_WALLET_USERNAME/ADDRESS
和 MINING_POOL_WALLET_USERNAME/ADDRESS 环境变量配置。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:42:55 -08:00
hailin
a5f6b23a95
feat(pool-account): 池账户充值弹窗新增中心化充值 tab
...
与做市商管理一致,充值弹窗包含"中心化充值"和"区块链充值"两个 tab。
中心化充值直接调整池账户余额(ADJUSTMENT 类型分类账),无需区块链交易。
变更:
- wallet-service: pool-account.service 新增 centralizedDeposit 方法
- wallet-service: pool-account.controller 新增 POST /centralized-deposit
- admin-service: pool-account.controller 新增 POST /:walletName/centralized-deposit 代理
- frontend: configs.api + use-configs hook + configs page 充值弹窗 Tabs UI
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:26:31 -08:00
hailin
c51539e494
fix(docker): 补充 mining-admin-service 池账户相关环境变量
...
添加 MINING_WALLET_SERVICE_URL、MINING_BLOCKCHAIN_SERVICE_URL、
BURN_POOL_WALLET_USERNAME、MINING_POOL_WALLET_USERNAME 到
docker-compose.2.0.yml 的 mining-admin-service 配置中。
缺少这些变量导致池账户 API 的 walletName→poolType 映射为空,
返回 400 Bad Request。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:18:35 -08:00
hailin
46f85b13b0
fix(pool-account): 修复 seed.ts 覆盖池余额 + 激活挖矿前校验池余额
...
1. seed.ts upsert 的 update 子句移除 balance/targetBurn/remainingBurn,
避免重新部署时将已有池余额清零(导致 BurnConsumer 和
MiningDistributionConsumer 因余额不足崩溃)
2. activateMining 激活前检查 SHARE_POOL_A/B 余额,任一为0则阻止激活
并返回 400 错误提示先通过区块链充值
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:00:59 -08:00
hailin
4f5b18be48
feat(pool-account): 实现池账户区块链充值检测和提现功能
...
为100亿销毁池和200万挖矿池实现完整的区块链充值/提现流程:
- 充值:独立扫描器检测 fUSDT 转入 → Kafka 事件 → wallet-service 入账
- 提现:前端 → admin-service 代理 → blockchain-service MPC签名转账 → wallet-service 记账
mining-blockchain-service:
- 新增 PoolAccountDeposit/PoolAccountBlockCheckpoint Prisma 模型
- 新增 PoolAccountDepositDetectionService(每5秒扫描 fUSDT 充值,每30秒更新确认数)
- 扩展 MPC 签名客户端支持 burnPool/miningPool 2-of-3 门限钱包
- 扩展 ERC20TransferService 支持池账户 fUSDT 转账
- 新增 API: POST /transfer/pool-account, GET /pool-accounts/:poolType/wallet-info
- 新增 Kafka topic 映射: pool_account.deposit.confirmed → pool_account.deposits
mining-wallet-service:
- TransactionType 枚举新增 BLOCKCHAIN_DEPOSIT/BLOCKCHAIN_WITHDRAW
- Seed: SHARE_POOL_A/B 初始余额改为0(完全靠链上充值)
- PoolAccountService 新增 blockchainDeposit()/blockchainWithdraw() 方法
- 新增 PoolAccountDepositConsumer 监听 Kafka 充值确认事件(Redis+DB 双重幂等)
- 新增 POST /pool-accounts/blockchain-withdraw 内部 API
mining-admin-service:
- 新增 PoolAccountController 代理到 wallet-service + blockchain-service
- GET /admin/pool-accounts/:walletName/balance(并行查询链下余额+链上钱包信息)
- POST /admin/pool-accounts/:walletName/blockchain-withdraw(先链上转账再记账)
- 新增配置: MINING_WALLET_SERVICE_URL, MINING_BLOCKCHAIN_SERVICE_URL, 池钱包用户名
frontend (mining-admin-web):
- 池账户 API 从 tradingClient (→trading-service) 改为 apiClient (→admin-service)
- 移除未使用的 tradingClient 和 axios 依赖
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 01:34:06 -08:00
hailin
4d2bcc7568
fix(mining-admin): 池账户钱包配置移到后端 .env,前端从 API 读取
...
做市商的 kavaWalletAddress 是后端 API 返回的,池账户应该一样。
- 后端 mining-blockchain-service/.env.example: 新增
BURN_POOL_WALLET_USERNAME/ADDRESS 和
MINING_POOL_WALLET_USERNAME/ADDRESS(同做市商钱包配置模式)
- 前端 .env.production: 移除 NEXT_PUBLIC_BURN/MINING_POOL 变量
- 前端 configs/page.tsx: 钱包地址改从 API 响应
(poolAccountBalance.walletAddress) 读取,未配置时显示提示
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 00:14:38 -08:00
hailin
6dbb620e82
feat(mining-admin): 配置管理新增100亿销毁池和200万挖矿池账户
...
在配置管理页面新增两个池账户卡片,UI 风格对齐做市商管理中的
"现金余额(积分值)",仅支持区块链方式充值与提现:
- 100亿销毁池 (wallet-22fd661f, 2-of-3 门限)
地址: 0xdE2932D2A25e1698c1354A41e2e46B414C46F5a1
- 200万挖矿池 (wallet-974e78f5, 2-of-3 门限)
地址: 0x8BC9091375ae8ef43ae011F0f9bAf10e51bC9D59
具体改动:
- .env.production: 新增 BURN_POOL / MINING_POOL 钱包名和地址环境变量
- configs.api.ts: 新增 tradingClient、PoolAccountBalance 接口、
getPoolAccountBalance 和 poolAccountBlockchainWithdraw API
- use-configs.ts: 新增 usePoolAccountBalance (30s 刷新) 和
usePoolAccountBlockchainWithdraw hooks
- configs/page.tsx: 新增两个并排池账户 Card,包含余额展示、
QR 码充值弹窗、区块链提现弹窗(含 0x 地址校验)
后端需实现:
- GET /admin/pool-accounts/:walletName/balance
- POST /admin/pool-accounts/:walletName/blockchain-withdraw
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 00:02:32 -08:00
hailin
999d0389b3
refactor(trading): 价格数据源从 SharePool 切换到做市商 cashBalance
...
积分股价格公式中的"绿积分"(分子)本质上就是做市商的积分值余额,
SharePool 是多余的抽象层。此次改动将价格计算的数据源从独立的
SharePool 表切换到做市商的 TradingAccount.cashBalance。
主要变更:
- price.service.ts: 通过 PrismaService 直接读取做市商 cashBalance
作为价格公式的分子(绿积分),移除 SharePoolRepository 依赖
- asset.service.ts: getMarketOverview() 同步切换数据源
- order.service.ts: 10%交易手续费从 sharePoolRepository.feeIn()
改为 increment 回做市商的 TradingAccount,手续费自然留存在池中
- burn.service.ts: 移除 SharePool 初始化逻辑和依赖
- infrastructure.module.ts: 移除 SharePoolRepository 注册和导出
- seed.ts: 移除 SharePool 57.6亿初始化
价格公式、10%手续费扣除、销毁机制均保持不变,仅切换数据源。
SharePool 表和 repository 文件保留在磁盘上供历史数据参考。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 23:13:59 -08:00
hailin
14e70b56bb
fix(c2c-bot): 水单完成时间转换为北京时间 (UTC+8)
...
问题:水单上的完成时间显示 UTC 时间(如 03:38:40),实际北京时间为 11:38:40。
原因:toISOString() 始终返回 UTC 时间。
修复:手动加 8 小时偏移量,将 UTC 转换为北京时间后再格式化。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:42:13 -08:00
hailin
bf11a269a4
fix(c2c-bot): 水单移除交易哈希,仅保留在分类账中
...
水单图片不再显示交易哈希(txHash),减少对终端用户暴露的链上细节。
txHash 仍保留在 ProofData 接口和数据库中,供分类账和审计使用。
同时缩小 SVG 高度(480→420)并重新排列剩余字段。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:35:48 -08:00
hailin
0fe0f3b72a
fix(c2c-bot): 水单显示优化:dUSDT→绿积分,收款地址→对方ID
...
水单图片调整:
- "支付金额 (dUSDT)" → "支付金额 (绿积分)"
- "收款地址"(显示 Kava 地址)→ "对方ID"(显示卖家账户 ID)
- ProofData 接口新增 sellerId 字段(来自 order.makerAccountSequence)
- sellerAddress 仍保留在数据结构中,供明细分类账使用
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:24:02 -08:00
hailin
7ee6d633c6
fix(kafka): 修复 MPC Kafka consumer 启动订阅失败后不重试的问题
...
问题现象:
- blockchain-service 启动时 Kafka consumer subscribe() 抛出
"This server does not host this topic-partition" 错误
- 原实现只 try-catch 一次就放弃,consumer 永久失效
- 后续所有 MPC 签名结果都收不到,表现为 signing timeout 300s
- 需要手动 docker restart 才能恢复
根因分析:
- 服务启动时 Kafka broker 可能尚未完成 topic-partition 分配
(特别是容器编排环境中服务启动顺序不确定)
- onModuleInit() 中的 connect/subscribe/run 是一次性调用
- KafkaJS 的 retry 配置只作用于内部操作,不覆盖初始连接流程
修复方案:
- 新增 connectWithRetry() 方法:指数退避重试(2s→4s→8s→...→60s)
最多 10 次,总等待约 5 分钟
- 每次重试前断开连接清理状态,避免 KafkaJS 内部状态残留
- 监听 consumer CRASH 事件:当 KafkaJS 不自动重启时(restart=false)
手动触发 connectWithRetry() 重连
- 新增 isShuttingDown 标志:防止 onModuleDestroy 时触发无意义的重连
- 同时修复 blockchain-service 和 identity-service 两个 consumer
影响范围:
- blockchain-service: 影响 MPC 签名结果接收(热钱包转账)
- identity-service: 影响 MPC 密钥生成结果接收(用户钱包创建)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:18:10 -08:00
hailin
2de4baf0af
fix(c2c-bot): 安装中文字体解决水单图片乱码问题
...
Alpine Linux 容器没有中文字体,sharp 渲染 SVG 时中文显示为方块。
- Dockerfile: 安装 fontconfig + font-noto-cjk 并刷新字体缓存
- SVG 模板: font-family 改为 Noto Sans CJK SC
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:56:55 -08:00
hailin
21f51c5d84
fix(c2c-bot): 修复 sharp 导入方式,解决水单生成 is not a function 错误
...
NestJS 使用 CommonJS 模块系统,`import sharp from 'sharp'` 编译后
生成 `sharp_1.default` 调用,但 sharp 没有 default export。
改为 `import * as sharp from 'sharp'` 修复。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:47:38 -08:00
hailin
eab61abace
feat(c2c-bot): 顺序处理订单 + 自动生成付款水单图片
...
1. 顺序处理订单:
- Scheduler 每个10s周期只处理1个卖单(原先最多10个)
- 移除 for 循环,确保完成一个订单后再处理下一个
- 分布式锁 TTL 从 8s 增加到 30s,留足链上转账时间
2. 付款水单自动生成:
- 新增 PaymentProofService,使用 SVG 模板 + sharp 转 PNG
- 水单包含:订单号、支付金额、交易哈希、收款地址、完成时间
- Bot 完成转账后自动生成水单并调用 updatePaymentProof 更新订单
- 水单生成失败不影响订单本身(try-catch 保护)
文件变更:
- package.json: 添加 sharp ^0.33.2 依赖
- c2c-bot.scheduler.ts: 限制每周期1单,增加锁时间
- payment-proof.service.ts: 新文件,SVG→PNG 水单生成服务
- application.module.ts: 注册 PaymentProofService
- c2c-bot.service.ts: 注入 PaymentProofService,步骤5生成水单
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:32:52 -08:00
hailin
7a1d438f84
fix(mpc): 去除 message_hash 的 0x 前缀,修复 MPC 签名 400 错误
...
MPC account-service 期望纯 hex 格式的 message_hash,不接受 0x 前缀。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:15:40 -08:00
hailin
cb8c69788b
fix(deploy): curl -s 改为 curl -sf,修复 HTTP 404 不被检测的问题
...
curl -s 只是静默输出,HTTP 404 仍然返回 exit code 0,导致就绪
检查在 Kafka Connect REST API 未初始化完时就通过了。
-f 标志让 curl 在 HTTP 4xx/5xx 时返回非零 exit code。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:30:37 -08:00
hailin
d8ef156b5e
fix(debezium): 修复 authorization connector 凭据和注册重试逻辑
...
- authorization-connector.json: 将硬编码的 debezium/debezium_password
改为 ${POSTGRES_USER}/${POSTGRES_PASSWORD} 占位符,与其他 connector 一致
- register-connectors.sh: 添加 3 次重试逻辑,应对 Kafka Connect REST API
初始化期间的间歇性 404
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:28:52 -08:00
hailin
5b3c391340
fix(infra): 添加 Zookeeper 数据持久化卷,修复 Kafka Cluster ID 冲突
...
Kafka 有持久化卷但 Zookeeper 没有,导致 down/up 后 ZK 生成新的
Cluster ID,与 Kafka meta.properties 中的旧 ID 冲突。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:25:14 -08:00
hailin
d575287713
fix(deploy): 修复 deploy.sh Debezium connector 注册失败的问题
...
根因:就绪检查只检测 Jetty 根路径 /,但 Kafka Connect REST API
(/connectors) 需要更长时间初始化,导致注册时返回 404。
- deploy.sh: 就绪检查改为 /connectors,等待时间从 60s 增加到 120s
- deploy.sh: 删除 250 行硬编码的 connector 配置,改为调用
register-connectors.sh(单一数据源,JSON 文件)
- register-connectors.sh: 同步修复就绪检查
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:22:04 -08:00
hailin
6f668d69bd
fix(infra): 添加 Kafka 数据持久化卷,防止容器重建后 Debezium connector 丢失
...
根因:Kafka 没有配置数据卷,容器重建后 debezium_configs/offsets 等内部
topic 丢失,导致 connector 注册信息消失。新 snapshot 的 offset 与旧
processed_events 碰撞,CDC 数据被跳过。
- docker-compose.yml: 添加 kafka_data 命名卷挂载到 /var/lib/kafka/data
- register-connectors.sh: 添加环境变量替换、幂等注册、--force/--1.0/--2.0 参数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:16:07 -08:00
hailin
0f3d03d832
fix(wallet-service): 修复提现失败时不写 UNFREEZE ledger 流水的 bug
...
问题描述:
withdrawal-status.handler.ts 的 executeWithdrawalFailed() 方法在处理
提现失败事件时,虽然正确地将冻结余额退回到可用余额(usdt_frozen → usdt_available),
但没有在 wallet_ledger_entries 表中写入 UNFREEZE 类型的流水记录,导致审计缺口。
对比 system-withdrawal-application.service.ts 中的同名方法 handleWithdrawalFailed(),
后者在退回余额时正确地写入了 UNFREEZE ledger entry。两者逻辑应保持一致。
影响范围:
所有通过 blockchain-service Kafka 事件触发的提现失败场景(包括链上提现和内部转账),
余额变动不会被记录到流水表中,无法审计追踪。
修复内容:
在 wallet_accounts 余额更新成功后,新增 tx.ledgerEntry.create() 调用,
写入 UNFREEZE 类型的流水记录,包含:
- amount: 实际退回金额(newAvailable - currentAvailable,兼容冻结不足的边缘情况)
- memo: "提现失败退款: {error}"
- payloadJson: toAddress, chainType, error 便于排查
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 09:13:40 -08:00
hailin
758babfdf8
fix(blockchain+trading): 修复做市商区块链充值无法入账的三个 bug
...
1. OutboxPublisherService 未注册到 NestJS 模块,导致充值确认事件永远
停留在 outbox_events 表 PENDING 状态,无法发布到 Kafka
2. trading-service 消费者监听的 Kafka topic 和 event type 与发布端不匹配
(blockchain.market_maker.deposits → mining_blockchain.market_maker.deposits)
3. 消费者只更新 market_maker_config 余额,但 API 从 trading_accounts 读取
余额,导致入账后前端仍显示 0
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:30:30 -08:00
hailin
1f434f32fb
fix(service-party-android): 修复导入钱包签名时 'party not registered' 错误
...
导入的钱包份额携带原始 keygen partyId,与设备自身 partyId 不同。
签名时用原始 partyId 订阅 session events,但该 ID 未在 message-router
注册,导致服务端返回 FAILED_PRECONDITION。
修复:签名前将导入份额的 partyId 也注册到 message-router(带 3 次重试),
注册失败则中断签名流程并提示用户;断线重连时自动恢复双 partyId 注册;
签名结束后清理额外注册。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:24:14 -08:00
hailin
fe6c1b3fce
fix(mining-admin-service): 修复 manual-mining 分页参数 NaN 问题
...
NestJS transform 会将缺失的 query 参数转为 NaN,
而 NaN ?? 1 仍然是 NaN。改用 Number(page) || 1 确保默认值生效。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:37:55 -08:00
hailin
3bce996dd3
fix(mining-admin-service): 修复 manual-mining 和 pending-contributions 内部调用 URL
...
这两个 service 调用 mining-service 时缺少 /api/v2/mining 前缀,
导致请求到达 mining-service 后 404。
修复前: ${miningServiceUrl}/admin/manual-mining/records
修复后: ${miningServiceUrl}/api/v2/mining/admin/manual-mining/records
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:24:00 -08:00
hailin
6f43408da5
fix(mining-admin-web): docker-compose 自动连接 rwa-2-network
...
mining-admin-web 需要同时连接 rwa-network 和 rwa-2-network,
以便通过 Next.js rewrite 直连 rwa-2-network 上的后端服务。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 01:43:06 -08:00
hailin
e99dc122ad
fix(nginx): API 请求改为代理到 Next.js 而非直连 mining-admin-service
...
nginx /api/ 直连 mining-admin-service:3023 会绕过 Next.js rewrite,
导致 /api/trading 和 /api/mining 无法路由到对应服务 (404)。
改为代理到 Next.js (3100), 由 rewrite 规则分发到各后端服务。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 01:36:55 -08:00
hailin
0b8c76f8b5
fix(mining-admin-web): Dockerfile 添加 build ARG 传入后端服务地址
...
next.config.js 的 rewrite 在 next build 时计算, Docker build 阶段
环境变量不可用导致 rewrite 使用 localhost 默认值 (容器内不可达)。
添加 ARG 将服务地址传入 build 阶段:
- NEXT_PUBLIC_API_URL -> mining-admin-service:3023
- TRADING_SERVICE_URL -> trading-service:3022
- MINING_SERVICE_URL -> mining-service:3021
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 01:32:29 -08:00
hailin
59efdb1f78
fix(mining-admin-web): 修复 API 请求超时和路由问题
...
问题:
- mining-admin-web 容器与后端服务在不同 Docker 网络, 无法通过公网 IP 回连 (hairpin NAT 失败)
- next.config.js 生产模式强制走 mapi.szaiai.com Kong 网关, 容器内无法访问
- client.ts 使用 NEXT_PUBLIC_API_URL 导致外部 URL 被 build 时内联到客户端包
- mining-service controller 有 mining/ 前缀, 直连模式 rewrite 丢失该前缀
修复:
- next.config.js: 改用 API_GATEWAY_URL 判断路由模式, 未设置则直连后端服务
- next.config.js: mining rewrite 保留 mining/ 前缀匹配 controller 路由
- client.ts: baseURL 固定为 /api, 所有请求统一走 Next.js rewrite 代理
- docker-compose.2.0.yml: 添加 TRADING_SERVICE_URL 和 MINING_SERVICE_URL 环境变量
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 01:14:19 -08:00
hailin
d9d8f69562
feat(nginx): 添加 madmin.szaiai.com nginx 配置
...
mining-admin-web 前端代理,Next.js :3100。
API 由 Next.js SSR rewrite 转发到 mapi.szaiai.com (Kong)。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:01:37 -08:00
hailin
6443acf34a
fix(deploy-mining): cdc-resnapshot 支持 standalone 模式远程操作 1.0 Debezium
...
standalone 模式下 source CDC connectors 在 1.0 服务器 (192.168.1.111:8084),
cdc-resnapshot 需要指向 1.0 Debezium 才能删除并重建 connector 触发全量快照。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:42:53 -08:00
hailin
0204f748e6
fix(debezium): outbox connector 配置支持 standalone 模式 (postgres-2)
...
- database.hostname 从硬编码 "postgres" 改为 ${DEBEZIUM_DB_HOST:-postgres}
- database.user/password 改为环境变量替换 ${POSTGRES_USER}/${POSTGRES_PASSWORD}
- standalone 模式设置 DEBEZIUM_DB_HOST=postgres-2
- shared 模式不设置,默认值 postgres 保持不变
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:01:45 -08:00
hailin
2a5b51aa8d
fix(deploy-mining): ensure_kafka_image 输出到 stderr 避免被 $() 捕获
...
docker pull 在 group_info=$(run_kafka_cmd ...) 内执行时,stdout 被命令替换
捕获到变量中,屏幕无任何输出导致脚本看起来卡住。
- ensure_kafka_image 输出重定向到 stderr
- full_reset 开头显式预拉取镜像
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:42:42 -08:00
hailin
0156be8d25
fix(deploy-mining): 预拉取 Kafka CLI 镜像避免 timeout 期间拉取失败
...
standalone 模式下 run_kafka_cmd 使用 docker run confluentinc/cp-kafka:7.5.0,
首次运行时镜像未缓存导致 docker pull 被 timeout 30 截断,循环重试卡住。
添加 ensure_kafka_image() 在执行命令前先确保镜像已拉取。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:36:38 -08:00
hailin
d53c2212a6
fix(deploy-mining): 修复 standalone 模式跨服务器 full-reset 卡住问题
...
- run_kafka_cmd 添加 timeout 30 防止跨服务器 Kafka 命令无限挂起
- CDC consumer offset 重置前先检查 group 是否存在,不存在则跳过
- 等待时间从 15s/20s 增加到 30s(匹配 KafkaJS 默认 sessionTimeout)
- max_retries 从 3 增加到 5,并输出实际 Kafka 错误信息
- 重试失败后 fallback 删除 consumer group(服务重启时自动重建)
- 同步修复 sync_reset() 和 full_reset() Step 3/Step 8 三处逻辑
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:33:28 -08:00
hailin
394f2529cd
fix(mining-admin-web): ensure public dir exists in Docker build
...
mkdir -p public before build so COPY --from=builder /app/public works
even without static assets.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:03:44 -08:00
hailin
ad51aa521f
fix(mining-admin-web): add public/.gitkeep to fix Docker build
...
Dockerfile COPY --from=builder /app/public fails when public dir is missing.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:03:01 -08:00
hailin
88ad3ab53d
feat: 2.0 API 域名从 rwaapi.szaiai.com 迁移到 mapi.szaiai.com
...
- mining-admin-web: .env.production, next.config.js fallback URL
- mining-app: environment.dart baseUrl, update_config.dart checkUpdateUrl
- docker-compose.2.0.yml: mining-admin-service UPLOAD_BASE_URL
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:58:03 -08:00
hailin
981b11f746
feat(api-gateway): 添加 standalone 模式 (up2) 支持 2.0 服务与 Kong 同机部署
...
- 新增 kong-standalone.yml: 2.0 服务通过 host.docker.internal 访问本机端口
1.0 服务仍走 192.168.1.111, CORS 已添加 mapi.szaiai.com
- 新增 docker-compose.standalone.yml: compose override 添加 extra_hosts
- deploy.sh 新增 up2/sync2 命令
用法:
./deploy.sh up2 # 启动 Kong (standalone)
./deploy.sh sync2 # 重新同步 standalone 配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:44:20 -08:00
hailin
42cf189749
feat(api-gateway): 添加 mapi.szaiai.com nginx+SSL 配置和 deploy.sh nginx 子命令
...
- 新增 nginx/mapi.szaiai.com.conf: 与 rwaapi.szaiai.com 同构的 SSL 反代配置
- deploy.sh 新增 nginx install/ssl 子命令,支持一键安装 nginx+证书
- 用法: sudo ./deploy.sh nginx install mapi.szaiai.com
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:35:00 -08:00
hailin
ec73541fe1
refactor(mining-blockchain): 移除 mpc-service 依赖,改为 HTTP 直调 mpc-system
...
将 mining-blockchain-service 的 MPC 签名通信从 Kafka 事件驱动(经由 mpc-service 中转)
改为 HTTP 直接调用 mpc-system 的 account-service (port 4000)。
## 核心变更
### mpc-signing.client.ts (重写)
- 移除 EventPublisherService、MpcEventConsumerService 依赖和 pendingRequests Map
- 移除 OnModuleInit 中的 Kafka 事件注册
- 新增 HttpService (@nestjs/axios) + JwtService (@nestjs/jwt) 依赖注入
- 签名流程改为:
1. POST /api/v1/mpc/sign → 创建签名会话 (snake_case: username, message_hash)
2. GET /api/v1/mpc/sessions/{session_id} → 轮询结果 (每 2s, 最多 5 分钟)
- JWT 认证: 使用 MPC_JWT_SECRET (HS256) 生成 Bearer token,匹配 mpc-system 格式
- 所有公共接口不变 (signMessage, signMessageAsXxxMarketMaker, isConfigured, getXxxAddress 等)
### 删除的文件
- mpc-event-consumer.service.ts: Kafka MPC 事件消费者 (SigningCompleted/SessionFailed/KeygenCompleted)
- mpc-keygen-completed.handler.ts: Keygen 地址派生处理器 (不再由此服务处理)
### 模块更新
- infrastructure.module.ts: 移除 MpcEventConsumerService,新增 JwtModule.register({})
- kafka/index.ts: 移除 mpc-event-consumer.service 导出
- event-handlers/index.ts: 移除 mpc-keygen-completed.handler 导出
### 部署配置
- docker-compose.2.0.yml: 新增 MPC_ACCOUNT_SERVICE_URL 和 MPC_JWT_SECRET 环境变量
- deploy-mining.sh: standalone 模式新增 export MPC_ACCOUNT_SERVICE_URL (默认 http://192.168.1.111:4000 )
## 不受影响的部分
- Erc20TransferService / MpcTransferInitializerService 调用方式不变
- EventPublisherService (用于其他事件) 不变
- WithdrawalEventConsumerService 不变
- mpc-system 本身零修改
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:53:35 -08:00
hailin
c657bf6e2b
revert: 撤回 mpc-service HTTP 调用方案,改为直接调用 mpc-system
...
Revert "fix(deploy): export MPC_SERVICE_URL in standalone mode"
Revert "refactor(mining-blockchain): replace Kafka MPC signing with HTTP direct calls"
将改为直接调用 mpc-system (Go TSS 后端) 的 API,跳过 mpc-service 中间层。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:33:39 -08:00
hailin
3102f3e7fb
fix(deploy): export MPC_SERVICE_URL in standalone mode
...
In standalone mode, mpc-service runs on the 1.0 server (192.168.1.111),
not in the local Docker network. The default docker-compose value
http://mpc-service:3006 won't resolve. Export MPC_SERVICE_URL pointing
to the 1.0 server's IP so mining-blockchain-service can reach it.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:30:44 -08:00
hailin
1106a40ff1
refactor(mining-blockchain): replace Kafka MPC signing with HTTP direct calls
...
Remove Kafka event-driven MPC signing (publish/consume pattern) and replace
with HTTP POST + polling to mpc-service, matching identity-service approach.
- Rewrite mpc-signing.client.ts: POST /api/v1/mpc/sign + poll status
- Delete mpc-event-consumer.service.ts (no longer needed)
- Delete mpc-keygen-completed.handler.ts (keygen handled elsewhere)
- Add MPC_SERVICE_URL env var to docker-compose.2.0.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:28:26 -08:00
hailin
0d47fadf59
feat(kafka): add EXTERNAL listener on port 9093 for LAN access
...
Add a third Kafka listener (EXTERNAL://0.0.0.0:9093) so that
2.0 standalone services on other servers (e.g. 192.168.1.10) can
connect to 1.0's Kafka at 192.168.1.111:9093.
Listeners now:
- PLAINTEXT (kafka:29092) - internal Docker network
- PLAINTEXT_HOST (localhost:9092) - host-local access
- EXTERNAL (192.168.1.111:9093) - LAN access for remote services
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 19:49:34 -08:00
hailin
ee07b52af9
feat(mining-2.0): 支持 standalone 独立部署模式,2.0 服务可脱离 1.0 单独运行
...
## 背景
2.0 挖矿生态需要从 1.0 服务器(192.168.1.111)迁移到独立服务器(192.168.1.10),
实现物理隔离部署。2.0 拥有独立的 PostgreSQL/Redis,通过远程 Kafka 接收 1.0 CDC 数据。
## docker-compose.2.0.yml 变更
### 网络参数化
- 网络改为 external: true + name 参数化:
`name: ${RWA_NETWORK_NAME:-services_rwa-network}`
- shared 模式复用 1.0 网络, standalone 模式使用独立 rwa-2-network
### 基础设施地址参数化 (所有 7 个 backend service)
- DATABASE_URL: @${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}
- REDIS_HOST: ${REDIS_HOST:-redis}
- KAFKA_BROKERS: ${KAFKA_BROKERS:-kafka:29092}
### 新增 3 个 standalone profile 基础设施服务
- postgres-2: PostgreSQL 16, WAL logical, init-multiple-dbs.sh 自动建库
- redis-2: Redis 7, appendonly 持久化
- debezium-2: Debezium Connect 2.4, 连接远程 Kafka(192.168.1.111:9093)
用于 2.0 内部 outbox 模式 (服务事件 → Kafka → mining-admin-service)
### 可选依赖
- 应用 service 添加 depends_on postgres-2/redis-2 with required: false
(Docker Compose v2.20+, shared 模式下自动跳过)
## deploy-mining.sh 变更
### 部署模式切换
- DEPLOY_MODE 环境变量: shared(默认) / standalone
- load_env() 按模式设置基础设施地址和 COMPOSE_ARGS
- shared 模式不 export 变量,避免覆盖容器侧 Docker Compose 默认值
### Kafka 远程操作支持
- run_kafka_cmd() / run_kafka_cmd_stdin(): standalone 模式用临时容器执行 Kafka CLI
- 所有 Kafka 操作函数 (sync_reset, sync_status, cdc_resnapshot, full_reset) 已适配
### 基础设施生命周期管理
- infra_up / infra_down: 独立管理 standalone 基础设施
- services_up(): standalone 模式自动先启动基础设施
- services_down(): standalone 模式同时停止基础设施
- services_clean(): fallback 列表包含 standalone 容器名
### full_reset() standalone 适配
- standalone 模式跳过 1.0 source CDC 操作 (远程 Debezium 管理)
- standalone 使用 debezium_2_offsets offset topic
- 自动启动 debezium-2 后注册 outbox connectors
### 其他
- health_check(): standalone 模式检查本地 PG/Redis 容器 + 远程 Kafka
- show_help(): 新增 DEPLOY_MODE 说明和 infra-up/infra-down 命令
- print_header(): 显示当前 DEPLOY_MODE
- 所有 ~15 处 docker compose 调用统一使用 $COMPOSE_ARGS
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 19:32:03 -08:00