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

Internal libraries in contracts does not internal into code if viaIR-mode is enabled and solidity-coverage is running #14055

Closed
SevenSwen opened this issue Mar 17, 2023 · 3 comments
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. stale The issue/PR was marked as stale because it has been open for too long.

Comments

@SevenSwen
Copy link

Solidity-coverage has broken inliner optimization.
When I run coverage with optimizerSteps:

"dhfoDgvlfnTUtnIf" +
"[" +
    "xa[r]EscLM" +
    "cCTUtTOntnfDIl" +
    "Lcl" +
    "Vcl [j]" +
    "Tpel" +
    "xa[rl]" +
    "xa[r]cL" +
    "gvif" +
    "CTUca[r]LSsTFOtfDnca[r]Ilc"
"]" +
  "jml[jl] VcTOcl jml",

(default settings without u instrumentation in all steps) than all tests will be finished success. But If I remove "gvif" step then I will have error:
NomicLabsHardhatPluginError: The contract <contract_name> is missing links for the following libraries: @openzeppelin/contracts/utils/math/Math.sol:Math
Repo/branch:
https://github.com/1inch/farming/tree/feature/enable_viaIR

Maybe problem into solidity-coverage code, but probably they do not make any injections into the optimization steps, and any of their actions should not affect the success of the code compilation.

I also added a comment to the solidity-coverage repo issue

@github-actions github-actions bot added this to Triage in Solidity Mar 17, 2023
@r0qs
Copy link
Member

r0qs commented Mar 17, 2023

Hi @SevenSwen thanks for the issue, but I suspect this is because Hardhat currently does not fully support via-ir. See: https://hardhat.org/hardhat-runner/docs/reference/solidity-support#support-for-ir-based-codegen

For reference:

At the moment, this option only works well when the optimizer is enabled.
Since Hardhat works much better when the optimizer is disabled, we don't completely support the viaIR option yet.
You can still enable it to compile your contracts and run your tests, but things like stack traces might not work correctly.

If you use the viaIR option, we recommend you set the optimization step sequence to "u", to make Hardhat work as well as possible

Could you please try using the following compiler setting:

settings: {
    viaIR: true,
    optimizer: {
      enabled: true,
      details: {
        yulDetails: {
          optimizerSteps: "u",
        },
      },
    },
}

@SevenSwen SevenSwen changed the title Internal libraries in contracts does not inlined into code if viaIR-mode is enabled and solidity-coverage is running Internal libraries in contracts does not internal into code if viaIR-mode is enabled and solidity-coverage is running Apr 11, 2023
@cameel cameel removed this from Triage in Solidity Apr 27, 2023
@github-actions
Copy link

This issue has been marked as stale due to inactivity for the last 90 days.
It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Jul 11, 2023
@github-actions
Copy link

Hi everyone! This issue has been automatically closed due to inactivity.
If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen.
However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.

@github-actions github-actions bot added the closed due inactivity The issue/PR was automatically closed due to inactivity. label Jul 19, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. stale The issue/PR was marked as stale because it has been open for too long.
Projects
None yet
Development

No branches or pull requests

2 participants