Skip to content

Conversation

galargh
Copy link
Contributor

@galargh galargh commented Jun 25, 2025

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

This replaces #6524

It is a simplified approach to watch for build completion events from hardhat node processes. Unlike the original approach, it relies on the fact that the build info output file and the build info file are created sequentially. This is achieved by first creating those files in parallel in the cache directory and moving them one by one to the artifacts directory only after both have been fully written to disk.

Copy link

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: b50287a

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

Copy link
Contributor

github-actions bot commented Jun 25, 2025

hardhat

Total size of the bundle: 55M
Total number of dependencies (including transitive): 40

List of dependencies (sorted by size)
48M	total
20M	esbuild
7.3M	@sentry/core
5.2M	zod
2.7M	micro-eth-signer
1.9M	@noble/curves
1.7M	undici
1.2M	@noble/hashes
904K	@nomicfoundation/hardhat-utils
864K	@streamparser/json
624K	micro-packed
592K	tsx
544K	fast-equals
532K	@nomicfoundation/hardhat-errors
492K	@scure/bip39
456K	@nomicfoundation/edr
408K	json-stream-stringify
368K	ethereum-cryptography
332K	@streamparser/json-node
320K	enquirer
320K	@nomicfoundation/hardhat-zod-utils
288K	semver
200K	ws
180K	chokidar
168K	@scure/base
136K	get-tsconfig
136K	adm-zip
96K	@scure/bip32
92K	chalk
72K	@nomicfoundation/solidity-analyzer
68K	debug
60K	readdirp
56K	rfdc
48K	ansi-colors
44K	resolve.exports
40K	resolve-pkg-maps
36K	p-map
24K	strip-ansi
24K	env-paths
24K	ansi-regex
20K	ms

@galargh galargh marked this pull request as ready for review June 25, 2025 14:50
@kanej kanej requested a review from alcuadrado June 25, 2025 15:11
@kanej kanej linked an issue Jul 8, 2025 that may be closed by this pull request
@kanej
Copy link
Member

kanej commented Jul 18, 2025

We think we can land this after partial recompilation - we need to check that the changed locations for outputs are reviewed.

@kanej kanej changed the base branch from v-next to main August 11, 2025 21:12
@antico5 antico5 force-pushed the build-info-watcher-v2 branch from c1c5897 to ccde1db Compare August 27, 2025 11:01
@antico5 antico5 force-pushed the build-info-watcher-v2 branch from ccde1db to 81cca78 Compare September 11, 2025 15:18
@antico5 antico5 self-assigned this Sep 11, 2025
@antico5 antico5 requested a review from kanej September 11, 2025 15:23
@antico5
Copy link
Contributor

antico5 commented Sep 11, 2025

@kanej this is ready for review. I changed it to use a new internal method vs an rpc method for the edr provider, and adjusted a couple lines related to recent build system changes.

@kanej kanej removed the request for review from alcuadrado September 17, 2025 11:02
return;
}

const buildId = path.basename(absolutePath).replace(".json", "");
Copy link
Member

Choose a reason for hiding this comment

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

Is there any implication from the change to include the solc version in the file name?
Do we consider the version to be part of the build id now?

Copy link
Contributor

Choose a reason for hiding this comment

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

No implications. The build id in this case is used to get the build info filename. But even if it was used for something else, the whole concept of build id now includes the solc version on the id itself, besides the hash


// NOTE: We listen only to the "add" event because the contents of the build info
// files identified by a build id should be considered immutable under usual circumstances.
watcher.on("add", listener.bind(null, handler));
Copy link
Member

Choose a reason for hiding this comment

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

Can I double check, we expect the update to happen when:

  1. A new contract is added and then a compile done (leading to a completely new build info file)
  2. An update on an existing contract happens, but this triggers a new build info file?
    Or is it the case that we don't expect 2?

Copy link
Contributor

Choose a reason for hiding this comment

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

When a contract is modified and recompiled, a new build info file is always created. Since build info filenames are a hash of their own content, their content never changes, so no need to listen to update events

@antico5 antico5 force-pushed the build-info-watcher-v2 branch from a05cfa7 to b50287a Compare September 17, 2025 17:28
@antico5 antico5 requested a review from kanej September 17, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Add build info watcher to the hardhat node task
4 participants