-
Notifications
You must be signed in to change notification settings - Fork 15
WIP refactor(ponder-sdk): define a package to consolidate Ponder-related ideas and functionality #1416
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
base: main
Are you sure you want to change the base?
WIP refactor(ponder-sdk): define a package to consolidate Ponder-related ideas and functionality #1416
Changes from all commits
5e336e4
7beb37e
07583d6
5fbf1a5
77d05ad
31a715b
efd1034
3cc7ea4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason we need {
'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 Also, it's wrong to assume the following:
To clarify, |
||
|
|
||
| /** | ||
| * 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. | ||
|
|
@@ -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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -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, | ||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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-sdkin the root readme file of the monorepo the way we reference other packages there?There was a problem hiding this comment.
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 👍