Skip to content

feat(mytask-index): A-8 indexer 首个消费方 — 索引 MyTask 挑战事件(codex 闭环)#20

Merged
jhfnetboy merged 2 commits into
masterfrom
feat/mytask-indexer-consumer
Jul 15, 2026
Merged

feat(mytask-index): A-8 indexer 首个消费方 — 索引 MyTask 挑战事件(codex 闭环)#20
jhfnetboy merged 2 commits into
masterfrom
feat/mytask-indexer-consumer

Conversation

@jhfnetboy

Copy link
Copy Markdown
Member

/dev/stdin

@jhfnetboy jhfnetboy requested a review from fanhousanbu as a code owner July 14, 2026 11:54

@clestons clestons left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE — A-8 indexer 的干净消费方。27/27 测试通过。

onModuleInit 把 TaskEscrowV2 注册为 indexer source:读 MYTASK_ESCROW_ADDRESS(默认已部署地址),/^0x[0-9a-fA-F]{40}$/ 校验,空/非法地址时记日志并跳过、绝不阻塞 boot(fail-safe)。读端点只答「谁挑战了/是否有裁决」,只读。复用的正是 #14 那套已审的 indexer(参数化 SQL、原子 reorg 回滚、dedup),本 PR 没有引入新的攻击面。scanned < total 时如实告知「更旧的未扫窗口里可能还有」,不假装全量。无阻塞。

— clestons (Opus review, tool-verified: 27 测试跑通)

将 TaskEscrowV2 (Sepolia, MT-8 重部署) 注册为 IndexerService 首个 source,
索引 TaskChallenged / ChallengeResolved 事件,并暴露按 taskId 查挑战者的读接口
(合约无 _challengers public getter,只能从事件索引取——落地 MT-11 遗留项)。

- 新模块 aastar/src/mytask-index/:onModuleInit 注册 source,仅在配了
  MYTASK_ESCROW_ADDRESS(envOr 默认部署地址)且 RPC 可用时注册,否则 skip+log
  不阻塞启动(对齐 A-8「无 source 不打 RPC」)。
- 读接口:GET /mytask/challenges?taskId=<bytes32>、GET /mytask/challenges/recent
  ?limit=,控制器 bytes32/limit 校验对齐 indexer.controller。
- event ABI 片段 1:1 复刻自 TaskEscrowV2.sol;不改 A-8 本体,只调其公开 API,
  taskId 过滤在本模块内(A-8 getEvents 无 arg 级过滤)。
- env:MYTASK_ESCROW_ADDRESS(默认 0x171234…1178)、MYTASK_INDEX_FROM_BLOCK
  (默认部署块 11269271)。
- 单测 mytask-index.service.spec.ts:注册/skip/taskId 过滤/recent limit 夹取。

Claude-Session: https://claude.ai/code/session_01MCxVCnKkpzi5sCGf1FZ4CH
回应 Codex REQUEST_CHANGES:未注册/截断被静默返空,调用方误判无挑战。

- H1 未注册静默返空:新增 registered 标志 + ensureRegistered() 守卫;
  source 因空/非法地址、无 RPC、注册失败被 skip 时,读接口抛
  ServiceUnavailableException(503)而非返静默空数组。
- H2/H3 扫描截断静默:drainEvents / getRecentChallenges 返回并透出
  scanned + total + truncated;命中 MAX_SCAN_EVENTS 上限且源未扫完时
  truncated=true,taskId 查询「查不到 + truncated」= 可能在更旧窗口,
  非「确实没有」;recent 未凑够 limit 同理。
- L 注册幂等:registerSource 前先 hasSource(),已注册直接 registered=true
  返回,避免重复注册噪音日志。
- 测试补强:未注册 503、>5000 事件截断(truncated + scanned 到上限)、
  幂等注册、controller spec(bytes32/limit 400 校验 + 夹取)、event ABI
  精确字段+indexed 断言防漂移。27 passed。

Claude-Session: https://claude.ai/code/session_01MCxVCnKkpzi5sCGf1FZ4CH
@jhfnetboy jhfnetboy force-pushed the feat/mytask-indexer-consumer branch from 650ee78 to 060a9eb Compare July 15, 2026 03:56
@jhfnetboy jhfnetboy merged commit 2e86d98 into master Jul 15, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants