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

Validation is blocked on the entire project when there's an invalid import on a single file. #238

Closed
antico5 opened this issue Aug 19, 2022 · 9 comments

Comments

@antico5
Copy link
Collaborator

antico5 commented Aug 19, 2022

As the title says, if at least 1 file has an invalid import (either relative or library import), the validation gets blocked for all files in the project. The expected behavior is that the diagnostic is shown for the file with the error, and other files are validated normally.

@JacobRhiel
Copy link

I am running into this same issue, it started in version 0.4.5 and is still broken, I keep my projects using 0.4.4 and it's working, but i'd like the new features..

@kanej
Copy link
Member

kanej commented Aug 22, 2022

I am running into this same issue, it started in version 0.4.5 and is still broken, I keep my projects using 0.4.4 and it's working, but i'd like the new features..

@JacobRhiel hey we definitely want you to be getting the new features! Could we get some more details?

Are you getting a validation issue with a bad import in a dependent file? What happens if you resolve the import issue?

@JacobRhiel
Copy link

JacobRhiel commented Aug 22, 2022

@kanej

So, most features work, but the most important, syntax highlighting and compilation.

  • npx hardhat for TS produces the same error on the below setup, with no extra files and bare minimum configuration.

It only displays this error on 0.4.5 and newer, but gives no insight.

No syntax highlighting on any version (other features work, just not compilation):

Versions:

NPM: 8.16.0
Node: 18.7.0

"devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^1.0.2",
    "hardhat": "^2.10.1",
    "hardhat-abi-exporter": "^2.10.0",
    "hardhat-contract-sizer": "^2.6.1",
    "hardhat-dependency-compiler": "^1.1.3",
    "hardhat-storage-layout": "^0.1.6",
    "prettier-plugin-solidity": "^1.0.0-dev.23"
  },
  "dependencies": {
    "@openzeppelin/contracts": "^4.7.0",
    "@openzeppelin/contracts-upgradeable": "^4.7.3",
    "dotenv": "^16.0.1"
  }

hardhat.config.ts:

import { HardhatUserConfig, task } from "hardhat/config";

import "@nomicfoundation/hardhat-toolbox";  // https://www.npmjs.com/package/@nomicfoundation/hardhat-toolbox
import "hardhat-dependency-compiler";       // https://www.npmjs.com/package/hardhat-dependency-compiler
import "hardhat-storage-layout";            // https://www.npmjs.com/package/hardhat-storage-layout
import "hardhat-contract-sizer";            // https://www.npmjs.com/package/hardhat-contract-sizer
import "hardhat-abi-exporter";              // https://www.npmjs.com/package/hardhat-abi-exporter

/* task("accounts", "Prints the list of accounts", async (_, {ethers}) => {
  const accounts = await ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
}); */

dotenv.config();

const config: HardhatUserConfig = {
  solidity: {
    version: process.env.COMPILE_VERSION || "0.8.16",
    settings: {
      optimizer: {
        enabled: process.env.OPTIMIZER == "true",
        runs: process.env.OPTIMIZER_RUNS || 200,
      },
      outputSelection: {
        "*": {
          "*": ["storageLayout"],
        },
      }
    },
  },
  gasReporter: {
    enabled: process.env.REPORT_GAS == "true"
  },
  defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
  networks: {
    rinkeby: {
      url: process.env.RINKEBY_URI || "",
      accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
    },
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY
  },
  dependencyCompiler: { // add your dependencies here
    paths: [
    ],
  },
  abiExporter: {
    runOnCompile: process.env.ABI_EXPORTER == "true",
    only: [],
  }
};

export default config;

Also, just trying CLI compilation produces this error on all versions:

> npx hardhat compile

Generating typings for: 3 artifacts in dir: typechain-types for target: ethers-v5
An unexpected error occurred:

TypeError: Cannot read properties of undefined (reading 'filter')
    at lowestCommonPath (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\typechain\src\utils\files\lowestCommonPath.ts:3:36)
    at detectInputsRoot (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\typechain\src\utils\files\detectInputsRoot.ts:7:108)
    at runTypeChain (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\typechain\src\typechain\runTypeChain.ts:29:31)
    at SimpleTaskDefinition.action (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\@typechain\hardhat\src\index.ts:87:38)
    at Environment._runTaskDefinition (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:35)
    at Environment.run (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:25)
    at OverriddenTaskDefinition._action (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\@typechain\hardhat\src\index.ts:31:11)
    at async Environment._runTaskDefinition (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
    at async Environment.run (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
    at async SimpleTaskDefinition.action (E:\blockchain\polygon\seven-seas\asset-generation-contracts\node_modules\hardhat\src\builtin-tasks\compile.ts:1358:63)```

antico5 added a commit that referenced this issue Aug 23, 2022
Added a link on the status item linking to the file that is importing a non existent file.
antico5 added a commit that referenced this issue Aug 23, 2022
Added a link on the status item linking to the file that is importing a non existent file.
antico5 added a commit that referenced this issue Aug 23, 2022
Added a link on the status item linking to the file that is importing a non existent file.
antico5 added a commit that referenced this issue Aug 24, 2022
Added a link on the status item linking to the file that is importing a non existent file.
antico5 added a commit that referenced this issue Aug 29, 2022
Added a link on the status item linking to the file that is importing a non existent file.
@kanej
Copy link
Member

kanej commented Aug 31, 2022

The link to the error location improves the UX, but to fully resolve the issue we need whole project diagnostics.

@kanej kanej reopened this Aug 31, 2022
kanej pushed a commit that referenced this issue Sep 8, 2022
Added a link on the status item linking to the file that is importing a non existent file.
@JacobRhiel
Copy link

Just an update on my portion of this issue.

It just gets stuck on 'validator starting', hardhat.config.ts has a check mark.

image

@kanej
Copy link
Member

kanej commented Sep 20, 2022

Hey @JacobRhiel, if you make a further edit in the open editor does the validator starting message change?

@pemmenegger
Copy link

yes, on VSCode launch I got "Validation blocked - validator starting" and after editing a .sol file I got "Validation blocked - unable to load hardhat config" but the checkmark hardhat.config.js stayed

@kanej
Copy link
Member

kanej commented Sep 26, 2022

@pemmenegger validation depends on being able to compile with hardhat. If the extension cannot read the hardhat.config.js we cannot get any further in the process. If you try and run npx hardhat compile for the project with that hardhat.config.js, do you get more details?

@antico5
Copy link
Collaborator Author

antico5 commented Dec 27, 2022

Closing this since with 0.6.0 the compilation process was changed and now unrelated contracts don't prevent validation on current file.

@antico5 antico5 closed this as completed Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants