Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"ensapi",
"@ensnode/datasources",
"@ensnode/ensrainbow-sdk",
"@ensnode/ponder-metadata",
"@ensnode/ensnode-schema",
"@ensnode/ensnode-react",
"@ensnode/ponder-sdk",
"@ensnode/ponder-subgraph",
"@ensnode/ensnode-sdk",
"@ensnode/shared-configs",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/green-deer-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ensnode/ponder-sdk": minor
---

Renames `@ensnode/ponder-metadata` package to `@ensnode/ponder-sdk`.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make any changes to any of our devops scripts related to publishing packages to NPM or generating release notes?

Additionally, I imagine that we should include a reference to ponder-sdk in the root readme file of the monorepo the way we reference other packages there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no need to change any of our devops scripts.

On the second question, yes, that's a good point 👍

1 change: 0 additions & 1 deletion apps/ensadmin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@ensnode/ensnode-react": "workspace:*",
"@ensnode/ensnode-schema": "workspace:*",
"@ensnode/ensnode-sdk": "workspace:*",
"@ensnode/ponder-metadata": "workspace:*",
"@formkit/auto-animate": "^0.9.0",
"@graphiql/plugin-explorer": "5.1.1",
"@graphiql/react": "0.37.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/ensapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"drizzle-orm": "catalog:",
"hono": "catalog:",
"p-memoize": "^8.0.0",
"p-retry": "^7.1.0",
"p-retry": "catalog:",
"pg-connection-string": "catalog:",
"pino": "catalog:",
"ponder-enrich-gql-docs-middleware": "^0.1.3",
Expand Down
3 changes: 2 additions & 1 deletion apps/ensindexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"@ensnode/ensnode-schema": "workspace:*",
"@ensnode/ensnode-sdk": "workspace:*",
"@ensnode/ensrainbow-sdk": "workspace:*",
"@ensnode/ponder-metadata": "workspace:*",
"@ensnode/ponder-sdk": "workspace:*",
"caip": "catalog:",
"date-fns": "catalog:",
"deepmerge-ts": "^7.1.5",
"dns-packet": "^5.6.1",
"p-retry": "catalog:",
"pg-connection-string": "catalog:",
"hono": "catalog:",
"ponder": "catalog:",
Expand Down
34 changes: 17 additions & 17 deletions apps/ensindexer/src/lib/indexing-status/build-index-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@ import {
type OmnichainIndexingStatusSnapshot,
type UnixTimestamp,
} from "@ensnode/ensnode-sdk";

import ponderConfig from "@/ponder/config";

import {
type ChainBlockRefs,
type ChainName,
createSerializedChainSnapshots,
createSerializedOmnichainIndexingStatusSnapshot,
fetchPonderMetrics,
fetchPonderStatus,
getChainsBlockRefs,
getChainsBlockrange,
type PonderStatus,
type PrometheusMetrics,
type PonderMetricsResponse,
type PonderStatusResponse,
type PublicClient,
} from "./ponder-metadata";
} from "@ensnode/ponder-sdk";

import { ponderClient, waitForPonderApplicationToBecomeHealthy } from "@/lib/ponder-local-client";
import ponderConfig from "@/ponder/config";
Copy link
Member

Choose a reason for hiding this comment

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

Is there a special reason why we are making use of the full ponderConfig here rather than the ENSIndexer config?

Is it because the ENSIndexer config contains RPC URLs but not the actual RPC clients, which have already been created for us inside the ponderConfig?

If this is the only reason, then suggest to build a more pure / clean / reusable abstraction for this goal that isn't smashed together with the goal of building an indexing status snapshot. What do you think?

Copy link
Contributor Author

@tk-o tk-o Dec 22, 2025

Choose a reason for hiding this comment

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

The reason we need ponderConfig is that getChainsBlockrange function needs to know details about configured accounts, blocks, contracts, chains. Example output of the getChainsBlockrange function looks like this:

{
  '1': { startBlock: 3327417, endBlock: undefined },
  '10': { startBlock: 110393959, endBlock: undefined },
  '8453': { startBlock: 17522624, endBlock: undefined },
  '42161': { startBlock: 349263357, endBlock: undefined },
  '59144': { startBlock: 6682888, endBlock: undefined },
  '534352': { startBlock: 16604272, endBlock: undefined }
}

and we need it to calculate backfillEndBlock value.

Also, it's wrong to assume the following:

the actual RPC clients, which have already been created for us inside the ponderConfig

To clarify, ponderConfig has no references to RPC clients. It's just configuration data.


/**
* Names for each indexed chain
* Stringified chain IDs for each indexed chain
*/
const chainNames = Object.keys(ponderConfig.chains) as string[];
const chainIds = Object.keys(ponderConfig.chains) as string[];

/**
* A {@link Blockrange} for each indexed chain.
Expand Down Expand Up @@ -69,30 +67,32 @@ let chainsBlockRefs = new Map<ChainName, ChainBlockRefs>();
* re-use it for further `getChainsBlockRefs` calls.
*/
async function getChainsBlockRefsCached(
metrics: PrometheusMetrics,
metrics: PonderMetricsResponse,
publicClients: Record<ChainName, PublicClient>,
): Promise<Map<ChainName, ChainBlockRefs>> {
// early-return the cached chain block refs
if (chainsBlockRefs.size > 0) {
return chainsBlockRefs;
}

chainsBlockRefs = await getChainsBlockRefs(chainNames, chainsBlockrange, metrics, publicClients);
chainsBlockRefs = await getChainsBlockRefs(chainIds, chainsBlockrange, metrics, publicClients);

return chainsBlockRefs;
}

export async function buildOmnichainIndexingStatusSnapshot(
publicClients: Record<ChainName, PublicClient>,
): Promise<OmnichainIndexingStatusSnapshot> {
let metrics: PrometheusMetrics;
let status: PonderStatus;
await waitForPonderApplicationToBecomeHealthy;
Copy link
Member

Choose a reason for hiding this comment

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

Can you please document why this action is suggested to be taken here? Why is it important? What would happen if we didn't do this here?


let metrics: PonderMetricsResponse;
let status: PonderStatusResponse;

try {
// Get current Ponder metadata (metrics, status)
const [ponderMetrics, ponderStatus] = await Promise.all([
fetchPonderMetrics(config.ensIndexerUrl),
fetchPonderStatus(config.ensIndexerUrl),
ponderClient.metrics(),
ponderClient.status(),
]);

metrics = ponderMetrics;
Expand All @@ -109,7 +109,7 @@ export async function buildOmnichainIndexingStatusSnapshot(

// create serialized chain indexing snapshot for each indexed chain
const serializedChainSnapshots = createSerializedChainSnapshots(
chainNames,
chainIds,
chainsBlockRefs,
metrics,
status,
Expand Down

This file was deleted.

This file was deleted.

36 changes: 1 addition & 35 deletions apps/ensindexer/src/lib/ponder-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";

import type { Blockrange } from "@ensnode/ensnode-sdk";

import { constrainBlockrange, createStartBlockByChainIdMap } from "./ponder-helpers";
import { constrainBlockrange } from "./ponder-helpers";

const UNDEFINED_BLOCKRANGE = { startBlock: undefined, endBlock: undefined } satisfies Blockrange;
const BLOCKRANGE_WITH_END = { startBlock: undefined, endBlock: 1234 } satisfies Blockrange;
Expand Down Expand Up @@ -90,38 +90,4 @@ describe("ponder helpers", () => {
});
});
});

describe("createStartBlockByChainIdMap", () => {
it("should return a map of start blocks by chain ID", async () => {
const partialPonderConfig = {
contracts: {
"subgraph/Registrar": {
chain: {
"1": { id: 1, startBlock: 444_444_444 },
},
},
"subgraph/Registry": {
chain: {
"1": { id: 1, startBlock: 444_444_333 },
},
},
"basenames/Registrar": {
chain: {
"8453": { id: 8453, startBlock: 1_799_433 },
},
},
"basenames/Registry": {
chain: {
"8453": { id: 8453, startBlock: 1_799_430 },
},
},
},
};

expect(await createStartBlockByChainIdMap(Promise.resolve(partialPonderConfig))).toEqual({
1: 444_444_333,
8453: 1_799_430,
});
});
});
});
Loading