Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fluffy-hairs-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ensindexer": minor
"ensapi": minor
---

The `subgraph` and `ensv2` plugins can now be activated in parallel.
16 changes: 14 additions & 2 deletions apps/ensapi/src/handlers/ensnode-graphql-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import config from "@/config";

import { hasGraphqlApiConfigSupport } from "@ensnode/ensnode-sdk";

import { factory } from "@/lib/hono-factory";
import { requireCorePluginMiddleware } from "@/middleware/require-core-plugin.middleware";

const app = factory.createApp();

app.use(requireCorePluginMiddleware("ensv2"));
// 503 if ensv2 plugin not available
app.use(async (c, next) => {
const prerequisite = hasGraphqlApiConfigSupport(config.ensIndexerPublicConfig);
if (!prerequisite.supported) {
return c.text(`Service Unavailable: ${prerequisite.reason}`, 503);
}

await next();
});

app.use(async (c) => {
// defer the loading of the GraphQL Server until runtime, which allows these modules to require
// the Namechain datasource
Expand Down
14 changes: 10 additions & 4 deletions apps/ensapi/src/handlers/subgraph-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import config from "@/config";
import { createDocumentationMiddleware } from "ponder-enrich-gql-docs-middleware";

import * as schema from "@ensnode/ensnode-schema";
import type { Duration } from "@ensnode/ensnode-sdk";
import { type Duration, hasSubgraphApiConfigSupport } from "@ensnode/ensnode-sdk";
import { subgraphGraphQLMiddleware } from "@ensnode/ponder-subgraph";

import { factory } from "@/lib/hono-factory";
import { makeSubgraphApiDocumentation } from "@/lib/subgraph/api-documentation";
import { filterSchemaByPrefix } from "@/lib/subgraph/filter-schema-by-prefix";
import { fixContentLengthMiddleware } from "@/middleware/fix-content-length.middleware";
import { makeIsRealtimeMiddleware } from "@/middleware/is-realtime.middleware";
import { requireCorePluginMiddleware } from "@/middleware/require-core-plugin.middleware";
import { subgraphMetaMiddleware } from "@/middleware/subgraph-meta.middleware";
import { thegraphFallbackMiddleware } from "@/middleware/thegraph-fallback.middleware";

Expand All @@ -22,8 +21,15 @@ const subgraphSchema = filterSchemaByPrefix("subgraph_", schema);

const app = factory.createApp();

// 404 if subgraph core plugin not enabled
app.use(requireCorePluginMiddleware("subgraph"));
// 503 if subgraph plugin not available
app.use(async (c, next) => {
const prerequisite = hasSubgraphApiConfigSupport(config.ensIndexerPublicConfig);
if (!prerequisite.supported) {
return c.text(`Service Unavailable: ${prerequisite.reason}`, 503);
}

await next();
});

// inject c.var.isRealtime derived from MAX_REALTIME_DISTANCE_TO_RESOLVE
app.use(makeIsRealtimeMiddleware("subgraph-api", MAX_REALTIME_DISTANCE_TO_RESOLVE));
Expand Down
28 changes: 0 additions & 28 deletions apps/ensapi/src/middleware/require-core-plugin.middleware.ts

This file was deleted.

8 changes: 8 additions & 0 deletions apps/ensindexer/ponder/ponder.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import config from "@/config";

import { PluginName } from "@ensnode/ensnode-sdk";
import { prettyPrintJson } from "@ensnode/ensnode-sdk/internal";

import { redactENSIndexerConfig } from "@/config/redact";
Expand All @@ -12,6 +13,13 @@ import ponderConfig from "@/ponder/config";
console.log("ENSIndexer running with config:");
console.log(prettyPrintJson(redactENSIndexerConfig(config)));

// log warning about dual activation of subgraph and ensv2 plugins
if (config.plugins.includes(PluginName.Subgraph) && config.plugins.includes(PluginName.ENSv2)) {
console.warn(
`Both the '${PluginName.Subgraph}' and '${PluginName.ENSv2}' plugins are enabled. This results in the availability of both the legacy Subgraph-Compatible GraphQL API (/subgraph) _and_ ENSNode's GraphQL API (/api/graphql), and comes with an associated increase in indexing time. If your intent is to have both APIs available in parallel, excellent, otherwise you may benefit from only enabling the plugin for the API you plan to use.`,
);
}
Comment thread
shrugs marked this conversation as resolved.

////////
// Export the ponderConfig for Ponder to use for type inference and runtime behavior.
////////
Expand Down
5 changes: 2 additions & 3 deletions apps/ensindexer/src/config/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,18 @@ export function invariant_validContractConfigs(
}
}

// Invariant: ensv2 core plugin requires protocol acceleration
// Invariant: ensv2 plugin requires protocol acceleration
export function invariant_ensv2RequiresProtocolAcceleration(
ctx: ZodCheckFnInput<Pick<ENSIndexerConfig, "plugins">>,
) {
const { value: config } = ctx;

// TODO: getCorePlugin(config.plugins)
if (
config.plugins.includes(PluginName.ENSv2) &&
!config.plugins.includes(PluginName.ProtocolAcceleration)
) {
throw new Error(
`Core Plugin '${PluginName.ENSv2}' requires inclusion of '${PluginName.ProtocolAcceleration}' plugin.`,
`The '${PluginName.ENSv2}' plugin depends on the inclusion of '${PluginName.ProtocolAcceleration}' plugin.`,
);
}
}
3 changes: 0 additions & 3 deletions apps/ensindexer/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import type { PluginName } from "@ensnode/ensnode-sdk";

import type { MergedTypes } from "@/lib/lib-helpers";

// ENSV2 Core Plugin
import ensv2Plugin from "./ensv2/plugin";
// Core-Schema-Indepdendent Plugins
import protocolAccelerationPlugin from "./protocol-acceleration/plugin";
import registrarsPlugin from "./registrars/plugin";
// Subgraph-Schema Core Plugins
import basenamesPlugin from "./subgraph/plugins/basenames/plugin";
import lineaNamesPlugin from "./subgraph/plugins/lineanames/plugin";
import subgraphPlugin from "./subgraph/plugins/subgraph/plugin";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ export const resolverTextRecordRelations = relations(resolverTextRecord, ({ one
* Registry on their respective chains, for example.
*
* Note also that this Registry migration tracking is isolated to the Protocol Acceleration schema/plugin.
* That is, the subgraph core plugin implements its own Registry migration logic, and the future
* ensv2 core plugin will likely do the same. By isolating this logic to the Protocol Acceleration
* plugin, we allow the Protocol acceleration plugin to be run independently of a core plugin
* (and could be run _without_ a core plugin, for example).
* That is, the subgraph plugin implements its own Registry migration logic. By isolating this logic
* to the Protocol Acceleration plugin, we allow the Protocol Acceleration plugin to be run
* independently of other plugins.
*
* The ensv2 plugin depends on the Protocol Acceleration plugin in order to piggyback on this
* Registry migration logic.
*/
export const migratedNode = onchainTable("migrated_nodes", (t) => ({
node: t.hex().primaryKey(),
Expand Down