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

Unable to override compiler options for contracts in node_modules #6090

Open
theonekeyg opened this issue Dec 27, 2024 · 0 comments
Open

Unable to override compiler options for contracts in node_modules #6090

theonekeyg opened this issue Dec 27, 2024 · 0 comments
Assignees

Comments

@theonekeyg
Copy link

theonekeyg commented Dec 27, 2024

Version of Hardhat

1.22.17

What happened?

I have a set of smart contracts that use npm package for some contract dependencies. One of the smart contracts in the npm package is failing the optimizer, therefore if I want to have optimizer enabled for my contracts, I have to somehow disable optimizer for failing contracts (because fails on optimizer revert the whole compilation).

I created a very simplistic repo showcasing the error, there I put exact setup that I face, I import the contract that does not suffer from optimization failures from the package that contains a contract that does fail. The result is that the whole optimization (and therefore compilation) step is failing, even thought I don't import the failing contract directly.

I try to use solidity.overrides to disable optimizer for the problematic contract, but it does not seem to produce any effect, the compilation still fails.

Here's my hardhat.config.ts

 const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.8.28",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200,
          },
          viaIR: true,
        },
      }
    ],
    overrides: {
      "node_modules/@entangle_protocol/oracle-sdk/contracts/EndPoint.sol": {
        version: "0.8.27",
        settings: {
          optimizer: {
            enabled: false,
          },
        },
      },
    },
  },
};

Like I said this does not produce any effect, even in logs with --verbose it shows that it does not use compiler from overrides.

hardhat:core:compilation-job File '/home/keyg/tmp/hardhat-overrides-bug/node_modules/@entangle_protocol/oracle-sdk/contracts/EndPoint.sol' will be compiled with version '0.8.28'

Minimal reproduction steps

Clone the repo https://github.com/theonekeyg/hardhat-overrides-bug and run:

  1. yarn install
  2. yarn hardhat compile
  3. Observe error of failing Yul optimizer
YulException: Cannot swap Variable expr_1156_offset with Variable _3: too deep in the stack by 1 slots in [ value_5 var_transmitterSigs_length RET var_transmitterSigs_offset expr_1156_offset var_opData_offset value_3 value_2 value _2 _1 value_2 value_1 value var_opData_offset value_3 value_5 value_4 expr_1158_length expr_1158_offset expr_length _3 ]
No memoryguard was present. Consider using memory-safe assembly only and annotating it via 'assembly ("memory-safe") { ... }'.
   --> @entangle_protocol/oracle-sdk/contracts/EndPoint.sol:404:17:
    |
404 |                 opData.params,
    |                 ^^^^^^^^^^^^^


Error HH600: Compilation failed

For more info go to https://hardhat.org/HH600 or run Hardhat with --show-stack-traces
error Command failed with exit code 1.

Search terms

No response

@github-project-automation github-project-automation bot moved this to Backlog in Hardhat Dec 27, 2024
@theonekeyg theonekeyg changed the title Unable to specify compiler options for contracts in node_modules Unable to override compiler options for contracts in node_modules Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants