Skip to content

hardhat-slang: add initial support for the new slang compiler on a similar pattern as hardhat-slang-solx - #8658

Merged
marianfe merged 11 commits into
mainfrom
feat/hardhat-slang
Oct 15, 2026
Merged

marianfe merged 11 commits into
mainfrom
feat/hardhat-slang

Conversation

@marianfe

@marianfe marianfe commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds initial support for the new slang compiler by following the previous hardhat-slang-solx plugin added in #8034.
The PR reuses the core hardhat swappable compiler type support added in #8008 and #8009.

hardhat-slang adds slang as a compiler type, and follows the same pattern of requiring adding a slang build profile to hardhat.config.ts.
Note that the compiler version is now decoupled from the Solidity language version, so the plugin configuration pins the slang version to download in slang.version , whereas the build profile specifies which solidity versions to be compiled with slang (currently, we aren't passing the Solidity version to slang, and compiler 0.8.x version support is not ready, see limitations). Same EVM versions supported as the previous hardhat-slang-solx.

Current limitations (will be addressed in follow-up PRs):

  • tested by successfully building real repositories (such as OpenZeppelin) however, current pre-release slang version used here does not output ABI or DWARF, so the end-to-end compiler tests in the EDR repo are not yet passing (support will be added in a next PR).
    running hardhat test --build-profile slang will fail because EDR rejects build info without ABI.
  • Releases mirror is not yet set up, so the current setup uses the github releases page directly, will be updated in a future PR.
  • the compiler pre-release binary used in this PR currently builds everything as 0.8.37.
  • The solidity version will need to be passed to the slang binary when compiling (future PR).
  • EDR will require updates to support slang compiler type
  • EDR will need to parse DWARF traces / slang traces instead of solc AST to reconstruct stack traces etc.
  • compiler pre-release version used here also doesn't output metadata, which is also required by hardhat.
  • only verified on linux x64 for now, no MacOS, Arm, or Windows tests yet.

No changeset included as this plugin is not release-ready yet.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:52
@marianfe marianfe added no changeset needed This PR doesn't require a changeset no peer bump needed no docs needed This PR doesn't require links to documentation labels Oct 1, 2026
@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: af1b1fb

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

hardhat

Total size of the bundle: 41M
Total number of dependencies (including transitive): 38

List of dependencies (sorted by size)
33M	total
7.3M	@sentry/core
5.2M	zod
3.8M	micro-eth-signer
2.2M	undici
2.2M	@noble/curves
1.8M	@noble/hashes
1.4M	@nomicfoundation/hardhat-utils
1.1M	@noble/ciphers
884K	@nomicfoundation/hardhat-vendored
792K	@streamparser/json
692K	@nomicfoundation/hardhat-errors
536K	@scure/bip39
508K	ethereum-cryptography
504K	tsx
468K	micro-packed
408K	json-stream-stringify
320K	enquirer
320K	@nomicfoundation/hardhat-zod-utils
292K	semver
216K	adm-zip
208K	@scure/base
204K	ws
188K	@streamparser/json-node
168K	esbuild
156K	@nomicfoundation/edr
152K	fast-equals
108K	@scure/bip32
100K	chokidar
72K	@nomicfoundation/solidity-analyzer
56K	rfdc
48K	ansi-colors
44K	resolve.exports
44K	readdirp
40K	p-map
24K	strip-ansi
24K	is-safe-filename
24K	env-paths
24K	ansi-regex

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Custom binary build identity can cause stale cache hits, and the documented test command cannot work with the pinned prerelease.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds the experimental @nomicfoundation/hardhat-slang plugin, modeled after hardhat-slang-solx, to integrate the new Slang compiler pipeline with Hardhat 3.

Changes:

  • Adds Slang configuration, compiler hooks, release validation, and output augmentation.
  • Implements verified compiler downloads and platform-specific asset selection.
  • Adds plugin documentation, errors, fixtures, and comprehensive tests.
File Description
pnpm-lock.yaml Registers the new workspace package.
packages/​hardhat-slang/​tsconfig.json Configures TypeScript references.
packages/​hardhat-slang/​test/​slang-compiler.ts Tests compiler invocation and selectors.
packages/​hardhat-slang/​test/​platform.ts Tests platform asset naming.
packages/​hardhat-slang/​test/​output-augmentation.ts Tests DWARF output integration.
packages/​hardhat-slang/​test/​optimizer-mode.ts Tests optimizer defaults.
packages/​hardhat-slang/​test/​mirror-availability.ts Checks release assets and checksums.
packages/​hardhat-slang/​test/​integration.ts Tests plugin integration and coexistence.
packages/​hardhat-slang/​test/​hook-handlers/​solidity.ts Tests compiler hooks and custom paths.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​package.json Defines debug-info fixture package.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​hardhat.config.ts Configures the debug-info fixture.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​contracts/​InlineAsm.sol Adds inline-assembly coverage.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​contracts/​Counter.sol Adds runtime-bytecode coverage.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​contracts/​ConstructorRevert.sol Adds creation-bytecode coverage.
packages/​hardhat-slang/​test/​fixture-projects/​with-debug-info/​.gitignore Ignores fixture outputs.
packages/​hardhat-slang/​test/​fixture-projects/​simple/​package.json Defines the simple fixture package.
packages/​hardhat-slang/​test/​fixture-projects/​simple/​hardhat.config.ts Configures the simple fixture.
packages/​hardhat-slang/​test/​fixture-projects/​simple/​contracts/​Greeter.sol Provides a basic fixture contract.
packages/​hardhat-slang/​test/​downloader.ts Tests downloading, retries, and verification.
packages/​hardhat-slang/​test/​config.ts Tests configuration resolution and validation.
packages/​hardhat-slang/​src/​type-extensions.ts Adds Slang configuration and output types.
packages/​hardhat-slang/​src/​internal/​slang-compiler.ts Implements the compiler adapter.
packages/​hardhat-slang/​src/​internal/​platform.ts Resolves platform asset names.
packages/​hardhat-slang/​src/​internal/​hook-handlers/​solidity.ts Implements compiler lifecycle hooks.
packages/​hardhat-slang/​src/​internal/​hook-handlers/​config.ts Implements plugin configuration hooks.
packages/​hardhat-slang/​src/​internal/​downloader.ts Downloads and verifies compiler binaries.
packages/​hardhat-slang/​src/​internal/​constants.ts Defines releases and supported settings.
packages/​hardhat-slang/​src/​index.ts Registers the plugin.
packages/​hardhat-slang/​README.md Documents installation and usage.
packages/​hardhat-slang/​package.json Defines package metadata and dependencies.
packages/​hardhat-slang/​LICENSE Adds the package license.
packages/​hardhat-slang/​eslint.config.js Configures linting.
packages/​hardhat-slang/​.prettierignore Excludes generated files from formatting.
packages/​hardhat-slang/​.gitignore Excludes generated package files.
packages/​hardhat-errors/​src/​descriptors.ts Adds Slang-specific errors.
cspell.dictionary.txt Adds MLIR to the dictionary.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

`Could not parse slang version from --version output: ${versionOutput}`,
);

return match[1];
Comment on lines +42 to +46
Run tests or compile using the slang build profile:

```bash
hardhat test --build-profile slang
hardhat build --build-profile slang
@marianfe
marianfe force-pushed the feat/hardhat-slang branch from 8a1901d to 4b63ff5 Compare October 1, 2026 16:08
Copilot AI balanced review requested due to automatic review settings October 1, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Compiler defaults, custom-binary identity, release automation, and CI coverage contain unresolved correctness issues.

Review effort: Balanced
Findings: 2 High severity · 3 Medium severity · 2 Low severity

Open (7)
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

"files": [
"dist/src/",
"src/",
"CHANGELOG.md",
Comment on lines +382 to +389
settings: {
...settings,
// Defaults added here instead of in SlangCompiler.compile so this reaches
// the solcInput and hence the build-id hash.
optimizer: {
...optimizer,
mode: optimizer.mode ?? DEFAULT_SLANG_OPTIMIZER_MODE,
},
Comment on lines +92 to +100
const needsDownload = compilerConfigs.some((c) => {
if (c.type !== SLANG_COMPILER_TYPE) {
return false;
}
if (c.path !== undefined) {
log(
`Skipping download for Solidity ${c.version}: custom path provided`,
);
return false;
Comment on lines +29 to +31
// Opt-in: run by the path-filtered mirror-availability job in ci.yml,
// not on every PR that rebuilds this package.
{ skip: process.env.HARDHAT_RUN_MIRROR_TESTS !== "true" },
Comment on lines +277 to +280
function describeChecksumRequestFailure(error: Error): string {
if (error instanceof ResponseStatusCodeError) {
return `the mirror responded with status ${error.statusCode}`;
}
@nebasuke

nebasuke commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

As a heads up I'm adding --solidity-version <version> and settings.solidityVersion in NomicFoundation/solx#787.

Claude comment

NomicFoundation/solx#787 takes the Solidity version from settings.solidityVersion in standard JSON mode and rejects --solidity-version next to --standard-json, the same way it handles --evm-version. Could augmentIfSlang set solidityVersion: entry.version alongside the optimizer and debug-info defaults instead? Then it's in the solcInput, so the build info reproduces the compile on its own, and targetVersionFlag/targetSolidityVersion can go.

Claude example:

  return {
    ...entry,
    settings: {
      ...settings,
      solidityVersion: entry.version,
      optimizer: {

A solx without #787 ignores the unknown key and compiles at its latest version, as it does today.

We don't mark the package as private (this is to allow local testing via
verdaccio). However, we do exclude it from release in the publish
scripts.

The release builds its publish list from a pnpm publish dry run, so
excluding the package there keeps it out of every later step. The local
command for regenerating that list gets the same exclusion.

This crude filter will be reverted, likely when we merge `hardhat-slang`
into core as a built-in plugin.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Custom binaries can receive incompatible arguments, config hooks load compiler internals eagerly, and the mirror test is not enabled in CI.

Review effort: Balanced
Findings: 2 High severity · 3 Medium severity · 2 Low severity

Open (7)
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Previously missed (2)

In code that hasn't changed since last review

Medium severity Avoid importing compiler dependencies in config hooks

packages/​hardhat-slang/​src/​internal/​hook-handlers/​config.ts:36

This config hook statically imports slang-compiler.ts, which in turn imports hardhat/internal/solidity and its compiler-execution dependencies. Config hook factories run on every Hardhat invocation, so commands that never compile still pay this startup cost. Move the output-selection constants/helper into a lightweight module that does not import the compiler runner, and import that module here.

Medium severity Use custom compiler version for protocol metadata

packages/​hardhat-slang/​src/​internal/​hook-handlers/​solidity.ts:151

A custom-path compiler is driven with metadata selected from the global pin rather than from the custom binary whose version was just parsed. Once releases have different CLI protocols (for example, a newer release with targetVersionFlag), pinning an older downloadable release while using a newer custom binary sends the older release's arguments and can compile the wrong Solidity target or be rejected. Select protocol metadata using customSlangVersion when known, and define an explicit fallback for unknown/nightly versions instead of letting slang.version control the custom binary.

kanej added 2 commits October 6, 2026 14:47
…file

main moved prettier to 3.9.9, so merging it left the lockfile pointing
hardhat-slang at a 3.9.8 entry that no longer exists. The lockfile is
regenerated from main's, which also drops @typescript-eslint 8.70.0
entries nothing references.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

);

const slangVersionType = z.string().superRefine((version, ctx) => {
if (!(version in SLANG_RELEASES)) {
}

// Honor custom path — skip version lookup and download
if (compilerConfig.path !== undefined) {
Comment on lines +141 to +143
const customSlangVersion = await getSlangVersionFromBinary(
compilerConfig.path,
);

@kanej kanej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have added an exclusion to our release scripts to avoid hardhat-slang, it has no npm package currently even if this exclusion was to fail.
I think we merge the plugin now, and continue with follow on PRs.

@marianfe marianfe changed the title WIP: hardhat-slang: add support for the new slang compiler by following the hardhat-slang-solx template. hardhat-slang: add initial support for the new slang compiler by following the hardhat-slang-solx as a template. Oct 14, 2026
@marianfe marianfe changed the title hardhat-slang: add initial support for the new slang compiler by following the hardhat-slang-solx as a template. hardhat-slang: add initial support for the new slang compiler by following the hardhat-slang-solx as a template Oct 14, 2026
@marianfe
marianfe marked this pull request as ready for review October 14, 2026 18:31
@marianfe marianfe changed the title hardhat-slang: add initial support for the new slang compiler by following the hardhat-slang-solx as a template hardhat-slang: add initial support for the new slang compiler on a similar pattern as hardhat-slang-solx Oct 14, 2026
@marianfe
marianfe enabled auto-merge October 14, 2026 19:00
@marianfe
marianfe added this pull request to the merge queue Oct 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@marianfe
marianfe added this pull request to the merge queue Oct 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@marianfe
marianfe added this pull request to the merge queue Oct 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@marianfe
marianfe added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit b059d56 Oct 15, 2026
243 checks passed
@marianfe
marianfe deleted the feat/hardhat-slang branch October 15, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changeset needed This PR doesn't require a changeset no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants