Skip to content

Conversation

@tk-o
Copy link
Contributor

@tk-o tk-o commented May 26, 2025

It's best to review this PR with Hide whitespace turned on.

This change prevents premature execution of plugin-specific config factories.

Before this change, running ENSIndexer service with ENS_DEPLOYMENT_CHAIN env var set to other valid value than mainnet would cause application runtime error. The problem was caused due to all plugin config files being unconditionally executed from ponder.config.ts file. For example, the basenames plugin would not find a required datasource loaded when ENS_DEPLOYMENT_CHAIN was set to either sepolia, holesky, or ens-test-env.

ensindexer  | 9:08:53 AM ERROR build      Error while executing 'ponder.config.ts':
ensindexer  | TypeError: Cannot destructure property 'chain' of 'deployment[__vite_ssr_import_3__.DatasourceName.Basenames]' as it is undefined.
ensindexer  |     at /app/apps/ensindexer/src/plugins/basenames/basenames.plugin.ts:24:9
ensindexer  |   22 | // extract the chain and contract configs for Basenames Datasource in order to build ponder config
ensindexer  |   23 | const deployment = getENSDeployment(appConfig.ensDeploymentChain);
ensindexer  | > 24 | const { chain, contracts } = deployment[DatasourceName.Basenames];
ensindexer  |      |         ^
ensindexer  |   25 |
ensindexer  |   26 | export const config = createConfig({
ensindexer  |   27 |   networks: networksConfigForChain(chain.id),
ensindexer  | 9:08:53 AM WARN  process    Failed intial build, starting shutdown sequence
Cleaning up...
 ELIFECYCLE  Command failed with exit code 1.

The fix was to make the plugin config object construction logic lazy-evaluated and only called during plugin activation phase (by when all required datasources must be available).

This change prevents premature exectuion of plugin-specific config factories. Before this change, we could not run ENSIndexer for any `ENS_DEPLOYMENT_CHAIN` except for `mainnet`. With this change, the ENSIndexer will attempt loading plugin-specific configuration for active plugins only. It means all required datasources configuration will be also available during config validation phase so no validation errors should occur anymore.
@tk-o tk-o requested a review from a team as a code owner May 26, 2025 15:51
@changeset-bot
Copy link

changeset-bot bot commented May 26, 2025

🦋 Changeset detected

Latest commit: 1f9d3e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
ensindexer Patch
ensadmin Patch
ensrainbow Patch
@ensnode/ens-deployments Patch
@ensnode/utils Patch
@ensnode/ensrainbow-sdk Patch
@ensnode/ponder-metadata Patch
@ensnode/ensnode-schema Patch
@ensnode/ponder-subgraph Patch
@ensnode/shared-configs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
admin.ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 5:20pm
ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 5:20pm
ensrainbow.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 5:20pm

@shrugs
Copy link
Collaborator

shrugs commented May 26, 2025

perhaps we can restructure to something more like this:

export default {
  get config () {
    // ...
    return createConfig()
  }
  activate: activateHandlers({ ... });
}

so we're exporting a single plugin-shaped object from each plugin file


the solution i had in my l2 primary name branch was similar to the previous behavior where we merged the configs

export const getENSDeployment = (ensDeploymentChain: keyof typeof ENSDeployments) =>
  ({
    ...ENSDeployments.mainnet,
    ...ENSDeployments[ensDeploymentChain],
  }) as ENSDeploymentGlobalType;

but i think i prefer your deferred execution approach rather than the hacky merged deployment thing

tk-o added 2 commits May 26, 2025 18:53
Consolidate all plugin members into a default export to make importing plugins more straightforward.
Comment on lines +6 to +9
import basenamesPlugin from "@/plugins/basenames/basenames.plugin";
import lineaNamesPlugin from "@/plugins/lineanames/lineanames.plugin";
import subgraphPlugin from "@/plugins/subgraph/subgraph.plugin";
import threednsPlugin from "@/plugins/threedns/threedns.plugin";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single object describes the public API of a plugin now. Importing default into named const.

@tk-o tk-o merged commit 7f68c87 into main May 26, 2025
7 checks passed
@tk-o tk-o deleted the fix/plugin-config-execution branch May 26, 2025 18:20
@github-actions github-actions bot mentioned this pull request May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants