Chore/migrate to hardhat#131
Open
schaable wants to merge 14 commits into
Open
Conversation
schaable
commented
Jun 8, 2026
|
|
||
| - name: Install node modules | ||
| run: npm install | ||
| run: yarn install --frozen-lockfile |
Author
There was a problem hiding this comment.
CI now installs deps with yarn instead of npm because the repo already uses yarn and relies on resolutions in package.json to pin transitive dependencies.
schaable
commented
Jun 8, 2026
| "@nomicfoundation/hardhat-ignition": "^3.1.6", | ||
| "@nomicfoundation/hardhat-keystore": "^3.0.11", | ||
| "@nomicfoundation/hardhat-verify": "^3.0.0", | ||
| "hardhat": "^3.8.0", |
Author
There was a problem hiding this comment.
We're using a range, but this can also be pinned to a specific version depending on the repo needs.
schaable
commented
Jun 8, 2026
Comment on lines
+36
to
+37
| default: { compilers: [swapVmCompiler] }, | ||
| production: { compilers: [swapVmCompiler] }, |
Author
There was a problem hiding this comment.
default is used as the default profile for most tasks, except for deployment and verification which use production by default.
schaable
commented
Jun 8, 2026
| @@ -1 +1 @@ | |||
| # SPDX-License-Identifier: LicenseRef-Degensoft-SwapVM-1.1 | |||
Author
There was a problem hiding this comment.
I wasn't sure how get / get-outputs are used on your side (same for .env.automation / the OPS_* env vars), so I didn't migrate them for now. We can migrate them as Hardhat scripts if needed.
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.
Makes Hardhat 3 the primary toolchain for
swap-vm: compilation, Solidity tests, gas snapshots, CI, and deployment now run on Hardhat. The build configuration fromfoundry.tomlwas migrated into a newhardhat.config.ts.Parity: all 706 Solidity tests pass under Hardhat 3, matching Forge exactly (706/706). No tests were disabled and no behavioral differences were found. When the gas snapshots were first regenerated under Hardhat, all non-fuzz values matched Forge exactly (705/705). A later bump to
@1inch/solidity-utils@6.9.9increased all entries by a small, uniform amount (≤0.032%).Building
The
via_irand custom YuloptimizerStepssettings were translated directly into the solc configuration and applied to both thedefaultandproductionprofiles. This is required because Ignition builds useproduction, and the router contracts hit "stack too deep" errors without viaIR.yarn build # or npx hardhat compileAdded
hardhat-ignore-warningsto suppress solc warnings from dependencies and test contracts.Testing
The full Solidity test suite (706 tests) passes under Hardhat.
Coverage
Generate a coverage report (including HTML output) with:
npx hardhat test solidity --coverageProduces
coverage/lcov.infoand an HTML report. Unlike Forge, no--ir-minimumflag is required for this via-IR project.Gas Report
Gas snapshots were regenerated under Hardhat and integrated into
yarn snapshot:check. Both.gas-snapshotand thesnapshots/*.jsonfiles are covered.To update the snapshot:
yarn snapshot # or npx hardhat test solidity --snapshotTo check against the snapshot:
yarn snapshot:check # or npx hardhat test solidity --snapshot-checkCompared to the original Forge baseline, the differences are:
Contract#func()vsContract:func())@1inch/solidity-utils@6.9.9upgrade, which slightly increased the bytecode size of a hot-path libraryThe baselines (
.gas-snapshotandsnapshots/*.json) were regenerated after the dependency upgrade. All 706 tests continue to pass.Deployment
Added Hardhat Ignition and
hardhat-verifyalongside the existing Foundry deployment flow. The modules inignition/modules/are generated from a shared_router.tsfactory, and per-chainignition/parameters/chain-<chainId>.jsonfiles replace the previousConfig.solJSON-loading mechanism. Verification uses Etherscan API v2, with constructor arguments provided automatically by Ignition.Add
--verifyto verify during deployment. The full workflow is documented inDEPLOY.md.CI
Tests and gas snapshot checks now run through Hardhat. Dependency installation was also switched from
npm installtoyarn install --frozen-lockfileso thatresolutionsare respected (see below).Key decisions
@1inch/solidity-utils@6.9.9and@openzeppelin/contracts@5.4.0. Without these pins, transitive dependencies can install multiple copies of the same Solidity packages, causing type mismatches between interfaces such asIERC20andSafeERC20. The resolutions reproduce the flat dependency layout that Forge gets through remappings. Since npm ignoresresolutions, CI was moved to Yarn as well.splitTestsCompilation: true: without it, a coldignition deploycompiles the entire via-IR project (~245s) and exceeds Node's default heap limit. Enabling it restricts deployment builds to the required contracts, reducing compilation time to ~11s. Tests and gas snapshots are unaffected.Follow-ups
forge fmt->prettier-plugin-solidity): is handled in a follow-up PR in the fork: Replace forge fmt with prettier-plugin-solidity NomicFoundation/swap-vm#2I kept it separate to make this PR easier to review. Once this PR is merged, I'll open the formatting PR against 1inch.
foundry.toml,remappings.txt, Forge-relatedMakefiletargets, andscript/*.s.sol).Review
Note
Reviewing this PR one commit at a time is likely the easiest approach.