-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Prep for ENSIndexer Build ID #1929
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?
Changes from all commits
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,91 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| // src/lib/checksum.ts | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| import { createHash } from "node:crypto"; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { resolve } from "node:path"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| import ts from "typescript"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| import { logger } from "@/lib/logger"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+8
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Get a checksum representing a given entry point file. | ||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||
| * @param entryPoint The entry point file for which to compute the checksum. | ||||||||||||||||||||||||||||||||||||||||||||||
| * This is a path relative to the ENSIndexer app directory (`apps/ensindexer`). | ||||||||||||||||||||||||||||||||||||||||||||||
| * @param tsConfigPath The path to the TypeScript configuration file. | ||||||||||||||||||||||||||||||||||||||||||||||
| * @returns The computed checksum as a string. | ||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||
| * @example | ||||||||||||||||||||||||||||||||||||||||||||||
| * ```ts | ||||||||||||||||||||||||||||||||||||||||||||||
| * // Compute checksums for the `apps/ensindexer/ponder/ponder.config.ts` file | ||||||||||||||||||||||||||||||||||||||||||||||
| * const ponderConfigChecksum = fileChecksum("ponder/ponder.config.ts"); | ||||||||||||||||||||||||||||||||||||||||||||||
| * // Compute checksums for the `apps/ensindexer/ponder/ponder.schema.ts` file | ||||||||||||||||||||||||||||||||||||||||||||||
| * const ponderSchemaChecksum = fileChecksum("ponder/ponder.schema.ts"); | ||||||||||||||||||||||||||||||||||||||||||||||
| * // Compute checksums for the `apps/ensindexer/ponder/src/register-handlers.ts` file | ||||||||||||||||||||||||||||||||||||||||||||||
| * const ponderLogicChecksum = fileChecksum("ponder/src/register-handlers.ts"); | ||||||||||||||||||||||||||||||||||||||||||||||
| * ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| export function fileChecksum(entryPoint: string, tsConfigPath: string = "tsconfig.json"): string { | ||||||||||||||||||||||||||||||||||||||||||||||
| const root = process.cwd(); | ||||||||||||||||||||||||||||||||||||||||||||||
| const resolvedEntry = resolve(root, entryPoint); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| logger.info({ | ||||||||||||||||||||||||||||||||||||||||||||||
| msg: "Computing entrypoint checksum", | ||||||||||||||||||||||||||||||||||||||||||||||
| entryPoint, | ||||||||||||||||||||||||||||||||||||||||||||||
| resolvedEntry, | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Read tsconfig | ||||||||||||||||||||||||||||||||||||||||||||||
| const tsConfigFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (tsConfigFile.error) { | ||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error(`Failed to read tsconfig: ${tsConfigPath}`); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const parsedTsConfig = ts.parseJsonConfigFileContent( | ||||||||||||||||||||||||||||||||||||||||||||||
| tsConfigFile.config, | ||||||||||||||||||||||||||||||||||||||||||||||
| ts.sys, | ||||||||||||||||||||||||||||||||||||||||||||||
| root, | ||||||||||||||||||||||||||||||||||||||||||||||
| undefined, | ||||||||||||||||||||||||||||||||||||||||||||||
| tsConfigPath, | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const tsProgram = ts.createProgram([resolvedEntry], parsedTsConfig.options); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+52
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const allTsFiles = tsProgram | ||||||||||||||||||||||||||||||||||||||||||||||
| .getSourceFiles() | ||||||||||||||||||||||||||||||||||||||||||||||
| .filter( | ||||||||||||||||||||||||||||||||||||||||||||||
| (sourceFile) => | ||||||||||||||||||||||||||||||||||||||||||||||
| !sourceFile.isDeclarationFile && | ||||||||||||||||||||||||||||||||||||||||||||||
| !sourceFile.fileName.includes("node_modules") && | ||||||||||||||||||||||||||||||||||||||||||||||
| !sourceFile.fileName.startsWith("\0"), | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| .map((sourceFile) => sourceFile.fileName); | ||||||||||||||||||||||||||||||||||||||||||||||
| const tsSourceFiles = new Set<string>(allTsFiles); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (tsSourceFiles.size === 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error(`No source files found for entry point: ${entryPoint}`); | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| logger.info({ | ||||||||||||||||||||||||||||||||||||||||||||||
| msg: "Files included in logic checksum", | ||||||||||||||||||||||||||||||||||||||||||||||
| entryPoint, | ||||||||||||||||||||||||||||||||||||||||||||||
| filesCount: tsSourceFiles.size, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+71
|
||||||||||||||||||||||||||||||||||||||||||||||
| const tsSourceFiles = new Set<string>(allTsFiles); | |
| if (tsSourceFiles.size === 0) { | |
| throw new Error(`No source files found for entry point: ${entryPoint}`); | |
| } else { | |
| logger.info({ | |
| msg: "Files included in logic checksum", | |
| entryPoint, | |
| filesCount: tsSourceFiles.size, | |
| const tsSourceFiles = Array.from( | |
| new Map(allTsFiles.map((file) => [file.replace(/\\/g, "/"), file])).entries(), | |
| ) | |
| .sort(([normalizedFileA], [normalizedFileB]) => normalizedFileA.localeCompare(normalizedFileB)) | |
| .map(([, file]) => file); | |
| if (tsSourceFiles.length === 0) { | |
| throw new Error(`No source files found for entry point: ${entryPoint}`); | |
| } else { | |
| logger.info({ | |
| msg: "Files included in logic checksum", | |
| entryPoint, | |
| filesCount: tsSourceFiles.length, |
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.
| for (const file of tsSourceFiles) { | |
| // Sort files to ensure deterministic hash output across different runs and machines | |
| const sortedFiles = Array.from(tsSourceFiles).sort(); | |
| for (const file of sortedFiles) { |
File checksum for Build ID is non-deterministic due to unsorted iteration over TypeScript source files returned by compiler
Copilot
AI
Apr 14, 2026
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.
If ts.sys.readFile(file) returns undefined (permissions/race/missing file), the current code silently skips that file, producing a checksum that no longer represents the full dependency set. It’s safer to throw (or at least log+fail) when any expected source file can’t be read.
| if (content) hash.update(content); | |
| if (content === undefined) { | |
| throw new Error(`Failed to read source file for checksum: ${file}`); | |
| } | |
| hash.update(content); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||||||||||||||||||||
| } from "ponder:registry"; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import { waitForEnsRainbowToBeReady } from "@/lib/ensrainbow/singleton"; | ||||||||||||||||||||||||||
| import { fileChecksum } from "@/ponder/logical-checksum"; | ||||||||||||||||||||||||||
|
Check failure on line 19 in apps/ensindexer/src/lib/indexing-engines/ponder.ts
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| import { fileChecksum } from "@/ponder/logical-checksum"; | |
| import { fileChecksum } from "@/lib/file-checksum"; |
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.
Copilot
AI
Apr 14, 2026
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.
This console.log will run on every startup (once per process) and will bypass the app’s structured logger. Please switch to logger (and/or gate behind a debug flag) to avoid noisy stdout in production.
| console.log(`Logical checksum`, { | |
| ponderConfig: ponderConfigChecksum, | |
| ponderSchema: ponderSchemaChecksum, | |
| ponderLogic: ponderLogicChecksum, | |
| }); | |
| if (process.env.DEBUG) { | |
| console.log(`Logical checksum`, { | |
| ponderConfig: ponderConfigChecksum, | |
| ponderSchema: ponderSchemaChecksum, | |
| ponderLogic: ponderLogicChecksum, | |
| }); | |
| } |
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.
File header comment is misleading (
// src/lib/checksum.ts) and doesn’t match the actual filename (file-checksum.ts). Please update or remove it to avoid confusion when navigating/searching.