zemse / hardhat-tracer

🕵️ allows you to see internal calls, events and storage operations in the console
MIT License
355 stars 36 forks source link

Error HH310: Invalid param --traceError. Command line params must be lowercase. #69

Closed MetaMmodern closed 7 months ago

MetaMmodern commented 7 months ago

I followed the instructions, imported hardhat-tracer into config file, ran loca node like this:

hh node

and then ran test like this

npx hardhat test --traceError --network localhost ./test/MyTestFile.test.ts

And it gave the error from title.

Here's my package.json

{
  "name": "doesnt_matter",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@nomicfoundation/hardhat-ethers": "^3.0.5",
    "@nomicfoundation/hardhat-toolbox": "^4.0.0",
    "ethers": "^6.11.1",
    "hardhat": "2.20.1"
  },
  "dependencies": {
    "@balancer-labs/v2-interfaces": "^0.4.0",
    "@balancer-labs/v2-solidity-utils": "^4.0.0",
    "@uniswap/sdk-core": "^4.1.3",
    "@uniswap/v2-core": "^1.0.1",
    "@uniswap/v2-periphery": "^1.1.0-beta.0",
    "@uniswap/v3-sdk": "^3.10.2",
    "dotenv": "^16.4.5",
    "hardhat-tracer": "^2.8.1"
  }
}

here's my hardhat.config.ts

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-ethers";
import "hardhat-tracer";
import { config as dotEnvConfig } from "dotenv";

dotEnvConfig();

const config: HardhatUserConfig = {
  networks: {
    localhost: {
      url: "http://127.0.0.1:8545/",
      accounts: [
        "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // local test account
      ],
    },
    hardhat: {
      forking: {
        url: process.env.INFURA_MAINNET_ENDPOINT ?? "",
        enabled: true,
        blockNumber: 19464443,
      },
    },
    mainnet: {
      url: process.env.INFURA_MAINNET_ENDPOINT,
      accounts: [process.env.PRIVATE_KEY!],
    },
    sepolia: {
      url: process.env.INFURA_SEPOLIA_ENDPOINT,
      accounts: [process.env.PRIVATE_KEY!],
    },
  },

  solidity: {
    compilers: [
      { version: "0.7.0" },
      { version: "0.7.6" },
      { version: "0.6.6" },
    ],
  },
};

export default config;

Note: I also tried --vv flag and it gave no results, no error Tx tracing.

zemse commented 7 months ago

Thanks for the report, just released a patch, please use hardhat-tracer@2.8.2.

To run hardhat node with trace printing enabled:

npx hardhat node --traceerror

and

npx hardhat test --network localhost

otherwise you could also do this:

npx hardhat test --traceerror
MetaMmodern commented 7 months ago

@zemse nice, thanks. It works. One thing I noticed:

in your documentation you mention only the latter command, "npx hardhat test --traceError", which I mistakenly assumed is related to the test command. But from your comment I now understand that tracing is related to the running node and not to the test. I was expecting logs to appear in test console, instead I accidentally saw them in network console. (I'm running node and tests separately as you've written in first codeblock). Maybe it's worth noting somewhere.

I'll close the issue since the core issue is resolved now. Thanks for the library, it helped me identify a bug reason in my project.

zemse commented 7 months ago

If you do "npx hardhat test --trace", that should print the traces in the console while tests are running. However it is required that the network should be hardhat (it is by default). This is what I do.

If you use localhost network then traces cannot be printed in the tests console, but they could be printed in the node terminal if tracing was enabled there. This feature honestly I never use. It seems this feature is causing a confusion, I'll update the docs.