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

Ensure concurrency safety across when downloading compilers for multiple hardhat projects #3818

Conversation

HenryNguyen5
Copy link

@HenryNguyen5 HenryNguyen5 commented Apr 6, 2023

Introduces a new wrapper around the compiler downloader that ensures multiple downloader calls within a transaction are guaranteed to execute sequentially.

This fixes a concurrency issue that arises from the separation of the isCompilerDownloaded and downloadCompiler calls, where the previous call to downloadCompiler was safe, but isCompilerDownloaded was not.

By allowing the composition of calls via transaction, and only exposing the underlying downloader via the transaction method, we can expose a much safer API surface for managing the downloads of multiple compilers.

This also has the nice side effect of downloading the same compiler once and only once. Before this bug fix, we'd be seeing multiple re-downloads of the same compiler within our project, https://github.com/smartcontractkit/chainlink

I ended up creating a wrapper class rather than adding this functionality to the existing compiler class to preserve the current interface that it adheres to, so we can keep using the same interfaces for future compiler implementations without having to think about concurrency handling at the same time.

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

Introduce a new wrapper around the compiler
downloader that ensures multiple downloader calls within
a transaction are guarenteed to execute sequentially.

This fixes a concurrency issue that arises from the separation of the
`isCompilerDownloaded` and `downloadCompiler` calls, where the
previous call to `downloadCompiler` was safe, but `isCompilerDownloaded`
was not.

By allowing the composition of calls via `transaction`, and only
exposing the underlying downloader via the `transaction` method,
we can expose a much safer api surface for manging the downloads
of multiple compilers.
@changeset-bot
Copy link

changeset-bot bot commented Apr 6, 2023

🦋 Changeset detected

Latest commit: 63f5bd2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
hardhat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Apr 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2023 0:38am
hardhat-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2023 0:38am

@HenryNguyen5 HenryNguyen5 changed the title ] Ensure concurrency safety across when downloading compilers for multiple hardhat projects Ensure concurrency safety across when downloading compilers for multiple hardhat projects Apr 6, 2023
@HenryNguyen5
Copy link
Author

@fvictorio Friendly ping on this as our CI pipelines are pretty flaky when we cache bust the compilers. LMK if you need anything else from me to expedite this!

@ChristopherDedominici
Copy link
Contributor

The issue has been resolved in this PR

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants