Skip to content
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

Cache solc compilers in CI #5169

Open
kanej opened this issue Apr 26, 2024 · 7 comments
Open

Cache solc compilers in CI #5169

kanej opened this issue Apr 26, 2024 · 7 comments
Labels
status:ready This issue is ready to be worked on

Comments

@kanej
Copy link
Member

kanej commented Apr 26, 2024

To reduce the number of CI fails due to a solc compiler download failure we should add OS specific cache for the solc cache folder.

We shouldn't need cache invalidation as the solc compiler is always the same for each version. Though we should consider if there is a nice way of including these caches in lots of workflows.

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Apr 26, 2024
@argctl
Copy link

argctl commented May 2, 2024

We need multiple cache dirs, one for each OS.

Example(s):

cache-v2 -> cache_macosx-amd64
... ->cache_wasm

or convention on ENUM pattern:

cache-v2 -> cache-MACOS
... -> cache-WASM

or lastly we have cache folders within named for OS.

We then update references to the cache-v2 folder to a subdir or new naming convention, with subdir we use path.join

@argctl
Copy link

argctl commented May 2, 2024

It already sort of does this:

https://www.npmjs.com/package/env-paths

running npx hardhat compile caches at ~/.cache/hardhat-nodejs/compilers-v2 like:

linux-amd64

But that's redundant because of path-env package, The concept isn't because of compiler version. My situation might be different and at first it looked like I needed to call getCompilersDir in the /hardhat/internal/util dir and I do have the solc version specified in hardhat.config.js under solidity.compilers[].version.

Conclusion:
The CI fails are due to the container not allowing access to the path-env defined location. The correct method to deal with this with security in mind is to avoid copying versions to different OS's and to instead allow for the cache dir to place in a custom directory, local directory (has issues), update path-env to deal with container constraints, or re-arch with the added benefit of avoiding potential directory traversal if we remove path-env to run locally. I don't think this is feasible.

We should probably just have documentation to set path-env if that was the issue.

I understand that the VM with the container might be what you're after, so I'll look through and see if the compiler object in the config can additionally support an OS type like:

[ { version: "0.8.24", os: "linux-amd64" } ]

@argctl
Copy link

argctl commented May 2, 2024

lastly...

We'll need to select the right version every time, but I think the current method does os.whatever to get that linux-amd64 POSIXish string.

@argctl
Copy link

argctl commented May 7, 2024

public static getConcurrencySafeDownloader(

@kanej
Copy link
Member Author

kanej commented May 7, 2024

This issue is targeted at the caching for Hardhat's own CI tests, rather than projects that use Hardhat.
Because we don't have caching setup for compilers in Hardhat's github actions, we can get nondeterministic fails if the solc compiler download fails. This issue is about making our CI on Hardhat itself more robust.

@kanej
Copy link
Member Author

kanej commented May 9, 2024

We are going to hold on this - our CI has been reworked and several issues fixed. We will let that bed in and reassess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Status: Blocked
Development

No branches or pull requests

2 participants