Feat/relayer envio#457
Conversation
❌ Deploy Preview for veascan failed. Why did it fail? →
|
❌ Deploy Preview for veashi-scan failed. Why did it fail? →
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis pull request introduces ChangesEnvio Indexer Implementation
Sequence DiagramsequenceDiagram
participant VeaInboxArbToEth as VeaInboxArbToEth Contract
participant MessageSentHandler as MessageSent Handler
participant SnapshotSavedHandler as SnapshotSaved Handler
participant MerkleUtils as Merkle Utils
participant IndexStore as Envio Store
VeaInboxArbToEth->>MessageSentHandler: emit MessageSent event
MessageSentHandler->>MerkleUtils: decodeNodeData(nodeData)
MerkleUtils->>MessageSentHandler: nonce, addresses, data
MessageSentHandler->>MerkleUtils: leafHash(nodeData)
MerkleUtils->>MessageSentHandler: leaf hash (32 bytes)
MessageSentHandler->>MessageSentHandler: compute XOR bitmap for changed Merkle nodes
MessageSentHandler->>MerkleUtils: hashPair(siblingHash, nodeHash) for each level
MerkleUtils->>MessageSentHandler: updated internal node hash
MessageSentHandler->>IndexStore: upsert Inbox, Sender, Receiver, MessageSent, MerkleNode
VeaInboxArbToEth->>SnapshotSavedHandler: emit SnapshotSaved event
SnapshotSavedHandler->>MerkleUtils: iterate snapshot count bit positions
MerkleUtils->>SnapshotSavedHandler: subtree root hashes
SnapshotSavedHandler->>MerkleUtils: hashPair for accumulated Merkle reconstruction
MerkleUtils->>SnapshotSavedHandler: reconstructed upper node hash
SnapshotSavedHandler->>IndexStore: write SnapshotSaved, persist reconstructed MerkleNode
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
relayer-envio-inbox/test/Test.ts (1)
12-85: ⚡ Quick winConsider adding error case tests.
The test suite provides good coverage of expected behavior but doesn't test error conditions such as:
- Malformed hex input (invalid characters, missing
0xprefix)- Wrong input lengths (too short or too long)
- Invalid address formats
- Boundary values (e.g., max nonce value)
If the utility functions are expected to handle these cases gracefully, adding negative tests would improve robustness.
🧪 Example error case tests
describe("decodeNodeData - error cases", () => { it("handles invalid hex input", () => { expect(() => decodeNodeData("not-hex")).toThrow(); }); it("handles input that is too short", () => { expect(() => decodeNodeData("0x1234")).toThrow(); }); }); describe("leafHash - edge cases", () => { it("handles empty input", () => { expect(() => leafHash("0x")).not.toThrow(); }); });Note: Adjust expectations based on whether functions should throw or handle gracefully.
🤖 Prompt for 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. In `@relayer-envio-inbox/test/Test.ts` around lines 12 - 85, Add negative and edge-case tests to cover malformed and boundary inputs: add a new "decodeNodeData - error cases" suite that asserts decodeNodeData throws or handles invalid hex (e.g., missing "0x" or non-hex chars) and inputs that are too short/too long or have invalid address lengths; add tests for extreme nonce values (max uint64) and for when trailing data is absent; also add tests for leafHash, concatAndSort, and hashPair that check behavior on empty input, invalid hex, and unexpected lengths (assert throw or notThrow based on intended behavior) so the functions decodeNodeData, leafHash, concatAndSort, and hashPair are covered for error and boundary conditions.
🤖 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 `@relayer-envio-inbox/.env.example`:
- Line 2: The ENVIO_API_TOKEN placeholder in .env.example is quoted; remove the
surrounding double quotes so the line reads ENVIO_API_TOKEN=<YOUR-API-TOKEN> to
match typical .env formatting and avoid accidental quoted secrets; update any
related documentation or README references that show the example so they also
use the unquoted placeholder string.
In `@relayer-envio-inbox/README.md`:
- Line 22: Update the README entry that currently references "Yarn (use v1 or
newer)" to require the repo's pinned version by changing the text to "Yarn (use
v4.6.0)" and, if desired, update the link target to the modern Yarn installation
guidance (or a short note about enabling Corepack) so contributors install Yarn
4.6.0 instead of Yarn 1; locate and modify the exact line containing the current
"[Yarn (use v1 or newer)]" text in README.md.
In `@relayer-envio-inbox/src/EventHandlers.ts`:
- Around line 103-143: The Merkle reconstruction loop corrupts large uint64
`count` by coercing it to JS Number and using 32-bit bitwise ops; change `size`,
`oldCount`, `height`, and `index` to bigint (initialize e.g. size =
BigInt(count)), and replace all numeric bit ops with bigint ops: use `& 1n`
instead of `& 1`, `>>= 1n` instead of `>>= 1`, and `2n ** height` instead of `2
** height`; update uses in the loop (variables `size`, `oldCount`, `height`,
`index`, and the `if ((size & 1) === 1)` branch and index calculations) so
template ids like `${inbox}-${index}` still stringify correctly and ensure
comparisons use bigint where needed.
In `@relayer-envio-inbox/src/utils/decoder.ts`:
- Around line 9-13: decodeNodeData currently calls hexToBuffer(...) and performs
fixed-offset reads (bytes.readBigUInt64BE(0), subarray(8,28), subarray(28,48))
without validating length; add a minimum-length guard that validates
bytes.length >= 48 before any fixed reads and handle insufficient length by
returning a safe value (e.g., null/undefined) or throwing a descriptive error so
callers (like EventHandlers.ts using event.params._nodeData) don't break; update
decodeNodeData to perform the length check right after hexToBuffer and ensure
downstream callers handle the null/error case appropriately.
---
Nitpick comments:
In `@relayer-envio-inbox/test/Test.ts`:
- Around line 12-85: Add negative and edge-case tests to cover malformed and
boundary inputs: add a new "decodeNodeData - error cases" suite that asserts
decodeNodeData throws or handles invalid hex (e.g., missing "0x" or non-hex
chars) and inputs that are too short/too long or have invalid address lengths;
add tests for extreme nonce values (max uint64) and for when trailing data is
absent; also add tests for leafHash, concatAndSort, and hashPair that check
behavior on empty input, invalid hex, and unexpected lengths (assert throw or
notThrow based on intended behavior) so the functions decodeNodeData, leafHash,
concatAndSort, and hashPair are covered for error and boundary conditions.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 958bba1f-d5a6-4269-bafc-6ab1c27cf89f
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (15)
.gitignorepackage.jsonrelayer-envio-inbox/.env.examplerelayer-envio-inbox/.gitignorerelayer-envio-inbox/README.mdrelayer-envio-inbox/config.yamlrelayer-envio-inbox/envio-env.d.tsrelayer-envio-inbox/jest.config.tsrelayer-envio-inbox/package.jsonrelayer-envio-inbox/schema.graphqlrelayer-envio-inbox/src/EventHandlers.tsrelayer-envio-inbox/src/utils/decoder.tsrelayer-envio-inbox/src/utils/merkle.tsrelayer-envio-inbox/test/Test.tsrelayer-envio-inbox/tsconfig.json
|


PR-Codex overview
This PR introduces the
relayer-envio-inbox, a new indexer for the Envio platform. It includes configuration files, a decoding utility, event handlers for blockchain events, and a GraphQL schema for message handling.Detailed summary
.envfile withENVIO_API_TOKEN.relayer-envio-inboxfolder structure.decodeNodeDatafunction indecoder.ts.EventHandlers.tsforMessageSent,SnapshotSaved, andSnapshotSentevents.schema.graphql.jest.config.ts.tsconfig.json..gitignorefor build artifacts and environment files.Summary by CodeRabbit
New Features
Chores
Documentation
Tests