[V2-199] feat: verify OutputFilled via routemesh RPC before Polymer proof request (V2-199)#53
Conversation
…est (V2-199) Gates `/polymer` proof requests with a pre-flight `eth_getLogs` lookup against routemesh, ensuring the targeted (block, logIndex) actually emitted an OutputFilled event. Mismatches return 400 without calling Polymer; RPC failures log a warning and fall through so infra blips never block the happy path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces log verification for OutputFilled events. A new utility queries Routemesh RPC endpoints to validate that logs at specific block/log indices match expected OutputFilled event signatures, integrating a mismatch rejection into the polymer POST handler, with supporting environment variable configuration. ChangesOutputFilled Log Verification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/routes/polymer/`+server.ts:
- Around line 31-35: The code directly calls BigInt(srcBlockNumber) (and
Number(srcChainId)/Number(globalLogIndex)) on untrusted JSON before calling
verifyOutputFilledLog, which can throw and return a 500; validate and sanitize
these numeric inputs first (e.g., check typeof/value, ensure srcBlockNumber
matches /^\d+$/ before BigInt conversion, and that srcChainId/globalLogIndex are
finite numbers), or move the coercion inside a try/catch around the parsing and
return a 400/validation error on failure; update the call site that invokes
verifyOutputFilledLog to pass only validated/converted values (references:
srcBlockNumber, srcChainId, globalLogIndex, verifyOutputFilledLog).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 095eb4b0-877c-4e90-8963-e288c47e42df
📒 Files selected for processing (3)
.env.examplesrc/lib/libraries/outputFilledVerify.tssrc/routes/polymer/+server.ts
SvelteKit inlines `$env/static/private` at build time, so the new var must be set in the build step env to land in the bundle. Mirrored to the deploy step to match the existing pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed! Worker: |
Summary
POST /polymerwith a pre-flight RPC lookup against routemesh (https://lb.routeme.sh/rpc/<chainId>/<key>) that confirms the targeted(block, logIndex)actually emitted anOutputFilledevent before any Polymer proof request goes out.{"error": "log is not an OutputFilled event"}and zero outbound calls toapi.polymer.zone.polymerIndex).Linear: V2-199
Implementation notes
src/lib/libraries/outputFilledVerify.tswraps viem'screatePublicClient+getLogswithfromBlock === toBlockand the typedOutputFilledevent fromCOIN_FILLER_ABI. Topic0 filter happens RPC-side; helper just checkslogs.some(l => Number(l.logIndex) === globalLogIndex).chainobject passed to the client — keeps us from maintaining a chain map for every chain Polymer supports.COIN_FILLER_ABIfromsrc/lib/abi/outputsettler.ts; no event redeclaration.PRIVATE_ROUTEMESH_API_KEYadded to.env.example. Needs to be set on Cloudflare Workers viawrangler secret put PRIVATE_ROUTEMESH_API_KEYbefore deploy.Test plan
PRIVATE_ROUTEMESH_API_KEYlocally andbun run dev.getLogsround-trip visible.curlPOST /polymerwith(chainId, blockNumber, logIndex)pointing to a non-OutputFilled log (e.g. an ERC20Transfer). Expect 400 + no request toapi.polymer.zone.PRIVATE_ROUTEMESH_API_KEY=invalid, re-trigger a fill. Expect a console warning and the Polymer flow to still complete.polymerIndex+ arbitraryglobalLogIndex. Expect zero outbound requests tolb.routeme.sh.wrangler secret put PRIVATE_ROUTEMESH_API_KEYon prod before merging.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores