Repository navigation
Conversation
jar-ben
force-pushed
the
jaroslav/hardhat-build-info-config
branch
from
November 18, 2026 19:10
f254dd4 to
9b2411a
Compare
shellygr
approved these changes
Nov 18, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Autosetup resolves a Hardhat project's compiler settings by loading
hardhat.config.{js,ts}througha Node.js extraction script. When that fails (no Node.js, or the extraction errors), it falls back to
the default configuration: no solc version, so solc is resolved from the source pragmas and the newest
version they admit is used.
For a project pinned to an older solc, the newest admitted version can fail where the pinned one
compiles. Seen on a
^0.8.19project configured for0.8.19withviaIR: autosetup picked0.8.34, the main contract hit stack-too-deep (YulException: Cannot swap Variable ... too deep in the stack) under every setting the compilation workarounds tried, and compilation analysis failed.Compiled directly with solc from the project's own build-info input, the same contract compiles on
0.8.19and fails on0.8.34with or without the optimizer andviaIR.Fix
HardhatManager.parse_configfalls back toartifacts/build-info/*.jsonwhen the config cannot beresolved through Node.js. Each build-info file is the solc standard-json input of one job of the
project's own
hardhat compile, with the exactsolcVersionand settings it ran with.solidity.compilersentry, the job compilingthe most sources first, in the same shape the Node.js extractor produces. It goes through the
existing
_extract_config_from_json, so single vs. multiple solc versions (compiler_map),evmVersion, and not inheriting the optimizer /viaIRbehave exactly as for an extracted config.solcVersionand aninputare skipped; unreadable ones are skipped with awarning.
Node.js is still tried first, so environments where it is available behave as before.
Limitations
solidity.overridesare not recovered: an override job is just another compilers entry,so the first entry's settings (e.g.
evmVersion) apply to every file. The Node.js path stillhandles overrides.
paths.artifactsis only known through Node.js.Testing
tests/test_hardhat_config.py: build-info used when Node.js resolution fails (version, optimizer,viaIR,evmVersion); multiple versions leavesolcunset; the largest job sets the settings;files without solc input and malformed JSON are skipped; defaults when neither source is available.
parse_configwith Node.js offPATHon the affected project's sources: resolves to{'solc': 'solc8.19'}(previously nosolc, resolved to0.8.34).pytest tests/ -m "not expensive": no new failures (the only errors are tests needing a localpostgres/docker).
pyrightclean on the changed module.