feat(mytask-index): A-8 indexer 首个消费方 — 索引 MyTask 挑战事件(codex 闭环)#20
Merged
Conversation
clestons
approved these changes
Jul 15, 2026
clestons
left a comment
There was a problem hiding this comment.
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
650ee78 to
060a9eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/dev/stdin