-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: implement the solidity compilation cache #6129
base: v-next
Are you sure you want to change the base?
Changes from all commits
94a0a3c
8635878
6e89b99
1a755bc
a622510
7a20c12
7c4f198
100579e
0787fcc
ed3328a
cd0adef
73ba8e0
b224e1a
41bddca
96096b2
0f4974a
9b71988
b48e0b9
f724079
0d6e346
7ebad19
ded19e2
6386662
9a32f70
ff5bfd6
b28e802
8660ad0
b13cae7
0593851
1179386
0a52ab7
27d6a2d
e55db65
0b59516
b8eff76
d14b385
8f8a033
416e4d0
135d975
c2de298
35b8e96
7647d54
5ce2a3d
c14cf21
222a6c8
b1377d3
b1d6cad
0dbc016
d8eeaa6
bb1d79f
927b8cc
28fe32e
1da1e5c
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 |
---|---|---|
|
@@ -407,6 +407,50 @@ export async function getChangeTime(absolutePath: string): Promise<Date> { | |
} | ||
} | ||
|
||
/** | ||
* Retrieves the last access time of a file or directory's properties. | ||
* | ||
* @param absolutePath The absolute path to the file or directory. | ||
* @returns The time of the last access as a Date object. | ||
* @throws FileNotFoundError if the path does not exist. | ||
* @throws FileSystemAccessError for any other error. | ||
*/ | ||
export async function getAccessTime(absolutePath: string): Promise<Date> { | ||
try { | ||
const stats = await fsPromises.stat(absolutePath); | ||
return stats.atime; | ||
} catch (e) { | ||
ensureError<NodeJS.ErrnoException>(e); | ||
if (e.code === "ENOENT") { | ||
throw new FileNotFoundError(absolutePath, e); | ||
} | ||
|
||
throw new FileSystemAccessError(e.message, e); | ||
} | ||
} | ||
Comment on lines
+418
to
+430
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. ContextHere, I add two new helper functions, They are needed to implement the |
||
|
||
/** | ||
* Retrieves the size of a file. | ||
* | ||
* @param absolutePath The absolute path to the file. | ||
* @returns The size of the file in bytes. | ||
* @throws FileNotFoundError if the path does not exist. | ||
* @throws FileSystemAccessError for any other error. | ||
*/ | ||
export async function getFileSize(absolutePath: string): Promise<number> { | ||
try { | ||
const stats = await fsPromises.stat(absolutePath); | ||
return stats.size; | ||
} catch (e) { | ||
ensureError<NodeJS.ErrnoException>(e); | ||
if (e.code === "ENOENT") { | ||
throw new FileNotFoundError(absolutePath, e); | ||
} | ||
|
||
throw new FileSystemAccessError(e.message, e); | ||
} | ||
} | ||
|
||
/** | ||
* Checks if a file or directory exists. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,9 +104,9 @@ declare module "@ignored/hardhat-vnext/types/artifacts" { | |
}`; | ||
} | ||
|
||
export function getBuildInfo( | ||
export async function getBuildInfo( | ||
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. ContextIt is necessary to change the signatures of 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. (these comments are really helpful) |
||
compilationJob: CompilationJob, | ||
): SolidityBuildInfo { | ||
): Promise<SolidityBuildInfo> { | ||
const publicSourceNameMap = Object.fromEntries( | ||
[...compilationJob.dependencyGraph.getRoots().entries()].map( | ||
([publicSourceName, root]) => [publicSourceName, root.sourceName], | ||
|
@@ -115,7 +115,7 @@ export function getBuildInfo( | |
|
||
const buildInfo: Required<BuildInfo> = { | ||
_format: "hh3-sol-build-info-1", | ||
id: compilationJob.getBuildId(), | ||
id: await compilationJob.getBuildId(), | ||
solcVersion: compilationJob.solcConfig.version, | ||
solcLongVersion: compilationJob.solcLongVersion, | ||
publicSourceNameMap, | ||
|
@@ -125,13 +125,13 @@ export function getBuildInfo( | |
return buildInfo; | ||
} | ||
|
||
export function getBuildInfoOutput( | ||
export async function getBuildInfoOutput( | ||
compilationJob: CompilationJob, | ||
compilerOutput: CompilerOutput, | ||
): SolidityBuildInfoOutput { | ||
): Promise<SolidityBuildInfoOutput> { | ||
const buildInfoOutput: Required<SolidityBuildInfoOutput> = { | ||
_format: "hh3-sol-build-info-output-1", | ||
id: compilationJob.getBuildId(), | ||
id: await compilationJob.getBuildId(), | ||
output: compilerOutput, | ||
}; | ||
|
||
|
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 LGTM