-
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?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
1807993
to
a1d4dca
Compare
hardhatTotal size of the bundle: List of dependencies (sorted by size)
|
a1d4dca
to
ae3401d
Compare
ae3401d
to
db3ac09
Compare
db3ac09
to
73ba8e0
Compare
|
||
import { ResolvedFileType } from "../../../../types/solidity.js"; | ||
|
||
export class ProjectResolvedFileImplementation implements ProjectResolvedFile { |
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.
Context
I add implementations of ProjectResolvedFile
and NpmPackageResolvedFile
interfaces here. These are necessary in order to lazily store content hashes on them, as proposed as part of the getBuildId
optimisations.
@@ -35,14 +35,15 @@ export interface ResolvedNpmPackage { | |||
*/ | |||
export enum ResolvedFileType { | |||
PROJECT_FILE = "PROJECT_FILE", | |||
NPM_PACKGE_FILE = "NPM_PACKAGE_FILE", | |||
NPM_PACKAGE_FILE = "NPM_PACKAGE_FILE", | |||
} | |||
|
|||
/** | |||
* A file that's part of the Hardhat project (i.e. not installed through npm). | |||
*/ | |||
export interface ProjectResolvedFile { |
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.
Context
I add getContentHash()
methods on the ProjectResolvedFile
and NpmPackageResolvedFile
interfaces here. These functions are needed to implement the getBuildId
optimisations.
@@ -17,17 +15,22 @@ export async function keccak256(bytes: Uint8Array): Promise<Uint8Array> { | |||
* | |||
* This function is primarily intended for generating unique identifiers from | |||
* a given input string. | |||
* It uses the MD5 hash algorithm, which is not cryptographically secure, but | |||
* It uses the SHA-1 hash algorithm, which is not cryptographically secure, but |
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
v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/cache.ts
Outdated
Show resolved
Hide resolved
v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/cache.ts
Outdated
Show resolved
Hide resolved
v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts
Show resolved
Hide resolved
v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts
Outdated
Show resolved
Hide resolved
buildId, | ||
contractArtifactsGenerated: | ||
contractArtifactsGenerated.get(publicSourceName) ?? [], | ||
warnings: errors, |
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.
self-answer: yes, these warnings have been remapped
* If we notice that the amount of write failures is too high, or that the | ||
* cache is not getting cleaned up often enough, we should reconsider this | ||
* approach. |
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.
FYI, I included some of the reasons why we might have to end up awaiting the cache update after all. I think we can start with this version and reconsider if/when needed.
In this PR, I implement the solidity compilation cache as outlined in the associated design doc.
The implementation diverges from the design doc in 1 areas: