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

Implement robustness improvements in the compiler downloader #6056

Merged
merged 15 commits into from
Jan 3, 2025

Conversation

galargh
Copy link
Member

@galargh galargh commented Dec 16, 2024

  • 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.

Resolves #5990

This PR implements changes outlined in #5990. Please note, that trimming down the solc dependency has been extracted to a separate issue #6071 as it will be easier to review that way.

Copy link

changeset-bot bot commented Dec 16, 2024

⚠️ No Changeset found

Latest commit: 6745a2a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Dec 16, 2024

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 Jan 3, 2025 10:48am

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have copied the multi-process mutex from the v2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have copied the compiler downloader tests from v2 and updated them to work with the v3 implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have copied the compiler tests from v2 and updated them to work with the v3 implementation. One significant update is the installation of tsx for the solcjs compiler tests.

Comment on lines 418 to 424
assertRejectsWithHardhatError(
() => mockDownloader.downloadCompiler("0.4.12"),
HardhatError.ERRORS.SOLIDITY.INVALID_DOWNLOAD,
{
remoteVersion: "0.4.12+commit.194ff033",
},
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this check being flaky already as we sometimes get HardhatError.ERRORS.SOLIDITY.DOWNLOAD_FAILED instead. What do you think about adding a retry mechanism to the downloader?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but let's discuss it with @alcuadrado. Either way, this should be addressed in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had another look at that and I don't quite understand why this is being flaky. We're using a mock downloader in this test case, which just writes to the disk. I assumed it was flaky because of the network use, but we're not even touching it here.

I'm trying to capture the full error we get when this flakes on another branch. I'll report back here when I find something.

I still think a retry mechanism might be an idea worth exploring, but I would definitely like to understand the source of flakiness in this test case better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found it! It was throwing the dir doesn't exist error because we weren't awaiting the assert 🤦 We should be able to catch it with a linting rule.

Suggested change
assertRejectsWithHardhatError(
() => mockDownloader.downloadCompiler("0.4.12"),
HardhatError.ERRORS.SOLIDITY.INVALID_DOWNLOAD,
{
remoteVersion: "0.4.12+commit.194ff033",
},
);
await assertRejectsWithHardhatError(
() => mockDownloader.downloadCompiler("0.4.12"),
HardhatError.ERRORS.SOLIDITY.INVALID_DOWNLOAD,
{
remoteVersion: "0.4.12+commit.194ff033",
},
);

@galargh galargh changed the title [WIP - not ready for review] Implement robustness improvements in the compiler downloader Implement robustness improvements in the compiler downloader Dec 22, 2024
@galargh galargh marked this pull request as ready for review December 22, 2024 11:29
@schaable schaable added the v-next A Hardhat v3 development task label Dec 30, 2024
Copy link
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Piotr! Sorry for the delay in reviewing this. It looks good. I just left a few comments.

v-next/hardhat-utils/src/synchronization.ts Outdated Show resolved Hide resolved
v-next/hardhat-utils/src/synchronization.ts Outdated Show resolved Hide resolved
v-next/hardhat-utils/src/synchronization.ts Outdated Show resolved Hide resolved
v-next/hardhat-utils/src/synchronization.ts Outdated Show resolved Hide resolved
v-next/hardhat-utils/src/synchronization.ts Outdated Show resolved Hide resolved
Comment on lines 418 to 424
assertRejectsWithHardhatError(
() => mockDownloader.downloadCompiler("0.4.12"),
HardhatError.ERRORS.SOLIDITY.INVALID_DOWNLOAD,
{
remoteVersion: "0.4.12+commit.194ff033",
},
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but let's discuss it with @alcuadrado. Either way, this should be addressed in a separate PR.

Copy link
Contributor

hardhat

Total size of the bundle: 219M
Total number of dependencies (including transitive): 53

List of dependencies (sorted by size)
214M	total
30M	@ignored/edr-optimism-linux-x64-musl
30M	@ignored/edr-optimism-linux-x64-gnu
27M	@ignored/edr-optimism-linux-arm64-musl
27M	@ignored/edr-optimism-linux-arm64-gnu
22M	@ignored/edr-optimism-win32-x64-msvc
21M	@ignored/edr-optimism-darwin-x64
20M	esbuild
20M	@ignored/edr-optimism-darwin-arm64
2.8M	@sentry/tracing
2.5M	micro-eth-signer
1.9M	@noble/curves
1.7M	undici
1.2M	@sentry/types
1.2M	@noble/hashes
932K	@sentry/node
920K	@sentry/utils
856K	zod
844K	@ignored/hardhat-vnext-utils
616K	micro-packed
576K	tsx
548K	@sentry/core
504K	fast-equals
492K	@scure/bip39
460K	@ignored/edr
384K	@ignored/edr-optimism
368K	ethereum-cryptography
344K	@sentry/hub
320K	enquirer
320K	@ignored/hardhat-vnext-errors
284K	semver
192K	ws
168K	@scure/base
136K	adm-zip
128K	get-tsconfig
96K	@scure/bip32
92K	chalk
88K	tslib
88K	@sentry/minimal
76K	agent-base
72K	@nomicfoundation/solidity-analyzer
68K	debug
64K	lru_map
64K	https-proxy-agent
60K	@ignored/hardhat-vnext-zod-utils
56K	rfdc
48K	ansi-colors
40K	resolve-pkg-maps
36K	p-map
32K	cookie
24K	strip-ansi
24K	env-paths
24K	ansi-regex
20K	ms

@galargh galargh requested a review from schaable December 30, 2024 19:53
@galargh galargh added this pull request to the merge queue Jan 3, 2025
Merged via the queue into v-next with commit a8c02e1 Jan 3, 2025
142 checks passed
@galargh galargh deleted the robust-compiler-downloader branch January 3, 2025 10:57
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 v-next A Hardhat v3 development task
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants