Feat/relayer envio - #457
Conversation
✅ Deploy Preview for veascan ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for veashi-scan canceled.
|
WalkthroughThis pull request adds ChangesEnvio Indexer Implementation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant VeaInboxArbToEth as VeaInboxArbToEth Contract
participant EventHandlers as EventHandlers
participant MerkleUtils as Merkle Utils
participant IndexStore as Envio Store
VeaInboxArbToEth->>EventHandlers: emit MessageSent, SnapshotSaved, or SnapshotSent
EventHandlers->>MerkleUtils: decode node data and compute hashes
MerkleUtils->>EventHandlers: return decoded fields and Merkle hashes
EventHandlers->>IndexStore: persist event entities and MerkleNode records
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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, adding a new indexer for managing events from theVeaInboxArbToEthcontract. It includes configurations, TypeScript support, and utility functions for decoding data and managing Merkle trees.Detailed summary
.envand example for API token configuration.relayer-envio-inboxpackage with TypeScript support.decoder.tsandmerkle.ts.EventHandlers.tsfor processingMessageSent,SnapshotSaved, andSnapshotSentevents.schema.graphql.README.mdwith instructions for running the indexer and generating files.Summary by CodeRabbit
New Features
Documentation
ENVIO_API_TOKENenvironment variable.Tests
Chores