-
Notifications
You must be signed in to change notification settings - Fork 16
2003 add new app with endpoint for submitting labels #2015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
djstrong
wants to merge
26
commits into
main
Choose a base branch
from
2003-add-new-app-with-endpoint-for-submitting-labels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
19b42ed
feat: add ens-labels-collector app for label submission and classific…
djstrong c57108e
feat: increase label submission limits and update related tests
djstrong c0c013e
chore: update pnpm-lock.yaml with new dependency hashes and version a…
djstrong 3537486
feat(yoga): add masked error handling for production environment
djstrong 440023c
feat(ens-labels-collector): enhance error handling and add timeout fo…
djstrong 4b49138
chore(pnpm-lock): add ensnode-sdk dependency for ens-labels-collector
djstrong 912c16c
Merge branch 'main' into 2003-add-new-app-with-endpoint-for-submittin…
djstrong 3021d5c
feat(ens-labels-collector): enhance timeout handling in label lookups
djstrong 8c41088
refactor: improve configuration parsing and logging
djstrong 4634cc4
refactor(ens-labels-collector): streamline configuration handling and…
djstrong 0b5365b
docs(ens-labels-collector): clarify submission limits and normalizati…
djstrong ff194f9
feat(ens-labels-collector): improve error handling for omnigraph lookups
djstrong 2adbc92
Merge branch 'main' into 2003-add-new-app-with-endpoint-for-submittin…
djstrong 74ff599
Merge branch 'main' into 2003-add-new-app-with-endpoint-for-submittin…
djstrong 053913b
update zod
djstrong 2005200
Merge branch 'main' into 2003-add-new-app-with-endpoint-for-submittin…
djstrong caf277d
rename app to ensrainbowbeam
djstrong a723be4
Add `EnsRainbowBeam` app with `/api/discover` endpoint for label subm…
djstrong d643370
Refactor label handling in submissions: update `SubmissionsRequestSch…
djstrong 7597168
Enhance `Query.labels` functionality: Introduce stricter validation f…
djstrong 6e1f410
Enhance `LabelHash` parsing: Update `parseValue` to include error han…
djstrong 07c9d1f
lint
djstrong 33e3ed1
Add `EnsRainbowBeamClient` for HTTP interactions: Implement `health()…
djstrong 23b4eaa
Add tests for `EnsRainbowBeamClient` and `validateDiscoverParams`: Im…
djstrong b79863c
Add `EnsRainbowBeam` support: Integrate CORS handling, update deploym…
djstrong d01acae
lint
djstrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| "ensrainbow", | ||
| "ensapi", | ||
| "fallback-ensapi", | ||
| "ensrainbowbeam", | ||
| "enssdk", | ||
| "enscli", | ||
| "enskit", | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensapi": minor | ||
| --- | ||
|
|
||
| Omnigraph **`Query.labels`** improvements: add a **`LabelHash`** GraphQL scalar (`0x` + 64 lowercase hex, parsed via `parseLabelHash`), rename the input to **`LabelsByLabelHashesInput`** with field **`labelHashes`**, enforce stricter parsing/validation through the scalar layer, normalize mixed-case hex at parse time, cap batch size to **`100`** distinct LabelHashes per request (after deduplication) for a round-number limit aligned with the `inArray` workload, and keep development error masking aligned with Yoga defaults while ensuring intentional `GraphQLError`s still surface useful client messages where applicable. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensrainbow-sdk": minor | ||
| --- | ||
|
|
||
| Add a light **EnsRainbowBeam** HTTP client (`EnsRainbowBeamClient`): `health()` and `discover()` against EnsRainbowBeam, client-side validation aligned with the server, `EnsRainbowBeamHttpError` for non-2xx responses with optional `{ message, details }` parsing, and subpath export `@ensnode/ensrainbow-sdk/ensrainbowbeam-client`. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensrainbowbeam": minor | ||
| --- | ||
|
|
||
| Add **`EnsRainbowBeam`** (`apps/ensrainbowbeam`) exposing **`POST /api/discover`**, classifies each submitted label literal against ENSNode via **`labels(by: { labelHashes })`** (with client-side chunking aligned to ENSApi batch limits), emits structured JSON Lines to stdout for future sinks, mirrors other apps’ Dockerfile + Compose service patterns (`docker/services/ensrainbowbeam.yml`), and includes MIT **`LICENSE`** in the app directory ([issue \#2003](https://github.com/namehash/ensnode/issues/2003)). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "enssdk": minor | ||
| --- | ||
|
|
||
| Regenerate `enssdk/omnigraph` artifacts for the Omnigraph **`LabelHash`** scalar, mapped in `OmnigraphScalars` for typed **`graphql`** documents. |
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
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
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
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
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
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
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
142 changes: 142 additions & 0 deletions
142
apps/ensapi/src/omnigraph-api/schema/label.integration.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| import { | ||
| asInterpretedLabel, | ||
| encodeLabelHash, | ||
| type InterpretedLabel, | ||
| type LabelHash, | ||
| labelhashInterpretedLabel, | ||
| parseLabelHash, | ||
| } from "enssdk"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { LABELS_BY_LABELHASH_MAX } from "@/omnigraph-api/schema/label"; | ||
| import { request } from "@/test/integration/graphql-utils"; | ||
| import { gql } from "@/test/integration/omnigraph-api-client"; | ||
|
|
||
| type LabelsByLabelHashResult = { | ||
| labels: Array<{ hash: LabelHash; interpreted: InterpretedLabel }>; | ||
| }; | ||
|
|
||
| const LabelsByLabelHash = gql` | ||
| query LabelsByLabelHash($labelHashes: [LabelHash!]!) { | ||
| labels(by: { labelHashes: $labelHashes }) { | ||
| hash | ||
| interpreted | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| // 'eth' is always seeded in the devnet fixture as a healed label | ||
| const ETH_LABEL_HASH: LabelHash = labelhashInterpretedLabel(asInterpretedLabel("eth")); | ||
|
|
||
| // a LabelHash that should not exist in the index (deterministic dummy bytes) | ||
| const ABSENT_LABEL_HASH = parseLabelHash(`0x${"ff".repeat(32)}`); | ||
|
|
||
| describe("Query.labels", () => { | ||
| it("returns a healed label entry for a known LabelHash", async () => { | ||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { labelHashes: [ETH_LABEL_HASH] }), | ||
| ).resolves.toMatchObject({ | ||
| labels: [{ hash: ETH_LABEL_HASH, interpreted: "eth" }], | ||
| }); | ||
| }); | ||
|
|
||
| it("accepts non-normalized (mixed-case hex digits) LabelHash variables and resolves matches", async () => { | ||
| // Lowercase `0x` prefix only; uppercase `0X` is rejected (see enssdk `parseLabelHash`). | ||
| const mixedCaseVariable = `0x${ETH_LABEL_HASH.slice(2) | ||
| .split("") | ||
| .map((c, i) => (i % 2 === 0 ? c.toUpperCase() : c)) | ||
| .join("")}` as LabelHash; | ||
| expect(parseLabelHash(mixedCaseVariable)).toBe(ETH_LABEL_HASH); | ||
|
|
||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { | ||
| labelHashes: [mixedCaseVariable], | ||
| }), | ||
| ).resolves.toMatchObject({ | ||
| labels: [{ hash: ETH_LABEL_HASH, interpreted: "eth" }], | ||
| }); | ||
| }); | ||
|
|
||
| it("rejects uppercase 0X hex prefix", async () => { | ||
| const badPrefix = `0X${ETH_LABEL_HASH.slice(2)}`; | ||
| await expect(request(LabelsByLabelHash, { labelHashes: [badPrefix] })).rejects.toThrow( | ||
| /Invalid labelHash/i, | ||
| ); | ||
| }); | ||
|
|
||
| it("omits LabelHashes that are not present in the index", async () => { | ||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { labelHashes: [ABSENT_LABEL_HASH] }), | ||
| ).resolves.toEqual({ labels: [] }); | ||
| }); | ||
|
|
||
| it("returns only the present labels when input mixes present and absent LabelHashes", async () => { | ||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { | ||
| labelHashes: [ETH_LABEL_HASH, ABSENT_LABEL_HASH], | ||
| }), | ||
| ).resolves.toMatchObject({ | ||
| labels: [{ hash: ETH_LABEL_HASH }], | ||
| }); | ||
| }); | ||
|
|
||
| it("dedupes repeated input LabelHashes", async () => { | ||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { | ||
| labelHashes: [ETH_LABEL_HASH, ETH_LABEL_HASH, ETH_LABEL_HASH], | ||
| }), | ||
| ).resolves.toMatchObject({ | ||
| labels: [{ hash: ETH_LABEL_HASH }], | ||
| }); | ||
| }); | ||
|
|
||
| it("returns an empty list when input is empty", async () => { | ||
| await expect(request(LabelsByLabelHash, { labelHashes: [] })).resolves.toEqual({ labels: [] }); | ||
| }); | ||
|
|
||
| it("classifies returned labels: 'eth' is healed (interpreted !== encodeLabelHash(hash))", async () => { | ||
| const { labels } = await request<LabelsByLabelHashResult>(LabelsByLabelHash, { | ||
| labelHashes: [ETH_LABEL_HASH], | ||
| }); | ||
|
|
||
| expect(labels).toHaveLength(1); | ||
| expect(labels[0].interpreted).not.toEqual(encodeLabelHash(ETH_LABEL_HASH)); | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| it("rejects junk strings that cannot be parsed as LabelHashes", async () => { | ||
| await expect( | ||
| request(LabelsByLabelHash, { | ||
| labelHashes: ["not-even-hex"], | ||
| }), | ||
| ).rejects.toThrow(/Invalid labelHash/i); | ||
| }); | ||
|
|
||
| it("rejects hex values that are not exactly 32 bytes", async () => { | ||
| await expect( | ||
| request(LabelsByLabelHash, { | ||
| labelHashes: ["0x00"], | ||
| }), | ||
| ).rejects.toThrow(/Invalid labelHash/i); | ||
| }); | ||
|
|
||
| it("rejects requests over the maximum allowed distinct LabelHash count", async () => { | ||
| const labelHashes: LabelHash[] = []; | ||
| for (let i = 0; i <= LABELS_BY_LABELHASH_MAX; i++) { | ||
| labelHashes.push(parseLabelHash(`0x${i.toString(16).padStart(64, "0")}`)); | ||
| } | ||
|
|
||
| await expect(request(LabelsByLabelHash, { labelHashes })).rejects.toThrow( | ||
| /Too many distinct LabelHashes/i, | ||
| ); | ||
| }); | ||
|
|
||
| it("allows input with duplicate LabelHashes when the distinct count is within the max", async () => { | ||
| await expect( | ||
| request<LabelsByLabelHashResult>(LabelsByLabelHash, { | ||
| labelHashes: [ETH_LABEL_HASH, ETH_LABEL_HASH, ETH_LABEL_HASH], | ||
| }), | ||
| ).resolves.toMatchObject({ | ||
| labels: [{ hash: ETH_LABEL_HASH, interpreted: "eth" }], | ||
| }); | ||
| }); | ||
| }); | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.