-
Notifications
You must be signed in to change notification settings - Fork 795
feat(solc): emit build info files if configured #1338
Conversation
Do we see this as impacting performance? |
it's definitely an overhead because a buildinfo object is in the MB and can be 50-100MB or even higher for large projects, so perhaps we should make this opt in via config val in foundry.toml? |
Yeah I'd disable it by default given we only really want it for hardhat-like integrations and only enable via foundry toml / CLI. Are there other use cases beyond Hardhat that we'd want it for? I think @tynes is the main feedback source here? |
If we do it based on timestamp, this could use a lot of space really quickly. The main consideration is we need to be able to go from qualified name -> build info file. If we use the timestamp methodology, the hh plugin can sort by timestamp and take the most recent buildinfo file. A way around using a lot of disk would be to have foundry delete the buildinfo file if one exists before writing the next one. hh maps a bulidinfo + solc version to a hash and uses that as the filename, see: https://github.com/NomicFoundation/hardhat/blob/783650c5711f457ad63cc7eee9ac190d0ff264fc/packages/hardhat-core/src/internal/artifacts.ts#L244 It looks like hh solves being able to look up qualified name -> buildinfo file by keeping a json debug file for each artifact that looks like this: const debugFile: DebugFile = {
_format: DEBUG_FILE_FORMAT_VERSION,
buildInfo: relativePathToBuildInfo,
}; https://github.com/NomicFoundation/hardhat/blob/783650c5711f457ad63cc7eee9ac190d0ff264fc/packages/hardhat-core/src/internal/artifacts.ts#L295 It seems like the options are:
I'm ok with either of these solutions, the first seems like the "better" solution as it would save a bunch of i/o but also more complex. Note that hh does prune old buildinfo files: https://github.com/NomicFoundation/hardhat/blob/783650c5711f457ad63cc7eee9ac190d0ff264fc/packages/hardhat-core/src/internal/artifacts.ts#L221
There are other people that have asked for access to the compiler input/output directly according to the tg group, it should def be gated by a flag in the |
I used the timestamp due to lack of understanding how the
right, I deemed that to be too much overhead, but makes sense now.
ah now, this makes sense :)
agreed, let's do option 1. I think what's missing is to get the build info file at least is just
The additional dbg.json would also be doable but would require some followup work |
It looks like its literally just the md5 of a json file:
|
oh good to know, we already use that for the content hash I believe, trying to get this over the line today |
file name is now the content hash of still needs a followup for:
|
An additional note: when slither is configured to work with hardhat, it uses the buildinfo files |
hardhat-deploy also relies on buildinfo files for etherscan verification |
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.
mhm seems fine to use, glad it's off by default :)
I can handle the hh plugin implementation of this once forge is updated with the latest ethers + a way to pass through config to trigger the buildinfo being written to disk |
Motivation
Emit build-info files that include the whole compiler(input, output) and version.
Solution
BuildInfo
BuildInfo
instance for each solc invocation.<root>/build-info/<solc>-<timestamp>.json
, this differs from hardhat which uses the content hash as file name, like0.8.14+commit.80d49f37.Darwin.appleclang-2022-06-02T12:17:16.944469+00:00.json
wdyt @tynes ?
PR Checklist