Local testing hardhat fork ganache error

I have the following config in my hardhat config file

hardhat: {
      forking: {
        url: my-alchemy-url,
      },
    }

when i run hardhat test i get the following error

   Error: Invalid signature v value
      at Object.exports.ecrecover (node_modules/hardhat/node_modules/ethereumjs-util/src/signature.ts:46:11)
      at new ForkTransaction (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkTransaction.ts:32:26)
      at ForkBlockchain._processRemoteBlock (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:250:9)
      at ForkBlockchain._getBlockByNumber (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:226:17)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at ForkBlockchain.getLatestBlock (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:40:19)
      at HardhatNode.takeSnapshot (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:645:20)
      at HardhatNode._runInPendingBlockContext (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1421:24)
      at HardhatNode.estimateGas (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:459:20)
      at EthModule._estimateGasAction (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:396:9)
      at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:100:18)
      at EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
1 Like

Could you please share some code to reproduce it?

I am also experiencing this issue, but with the hardhat network(not ganache). I'm thinking they might be related. No matter what I try, it always seems to come back to:


 npx hardhat test



  Contract - Deployed
    1) "before each" hook for "Should provide sanity"


  0 passing (5s)
  1 failing

  1) Contract - Deployed
       "before each" hook for "Should provide sanity":
     Error: Invalid signature v value
      at Object.exports.ecrecover (node_modules/ethereumjs-util/src/signature.ts:46:11)
      at new ForkTransaction (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkTransaction.ts:32:26)
      at ForkBlockchain._processRemoteBlock (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:250:9)
      at ForkBlockchain._getBlockByNumber (node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:226:17)



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! eons@1.0.0 test: `npx hardhat test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the project@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2021-09-22T13_38_48_243Z-debug.log
My-MacBook-Pro:project me$ 

As far as code to reproduce, here is my hardhat config setting for the mainnet fork:

  defaultNetwork: 'hardhat',
  networks: {
    hardhat: {
      forking: {
        enabled: true,
        chainId: 1,
        url: "https://eth-mainnet.alchemyapi.io/v2/<-Alchemy-Key->",
        blockNumber: 13241496
      },
    },

I've tried multiple chainId values already.

I'll provide as much additional info as I can. This one has been taking up quite a bit of time for me.

Hi Skyge.

So when i attempt to deploy my contract is when it seems to be giving me an error.

here is my deploy code in my test suite

export async function initUtilityContracts({ manager }: InitOptions): Promise<UtilityContracts> {
  /** Locker */
  const locker = (await upgrades.deployProxy(await UtilityFactory.getLockerFactory(), [], {
    unsafeAllowCustomTypes: true,
    unsafeAllowLinkedLibraries: true,
  })) as Locker;
  /** offering */
  const offering = (await upgrades.deployProxy(
    await UtilityFactory.getOfferingFactory(),
    [],
    {
      unsafeAllowCustomTypes: true,
      unsafeAllowLinkedLibraries: true,
    }
  )) as Offering;
  /** team vault */
  const teamVault = (await upgrades.deployProxy(
    await UtilityFactory.getTeamVaultFactory(),
    [],
    {
      unsafeAllowCustomTypes: true,
      unsafeAllowLinkedLibraries: true,
    }
  )) as TeamVault;

  return {
    teamVault,
    offering,
    locker,
  };
}

Hi, welcome1 :wave:

How about update your hardhat to the latest version and then have a try?

1 Like

Emmmm, so did you get the same error as above? Error: Invalid signature v value

1 Like

Yes that is the error i am getting. I'm unsure why. I'm following the direction then running yarn test and i just get invalid signature V soon as i send a transaction

The error occurs inside of ForkTransaction

Maybe you can share your full code, so that I can test on my local environment.

It turns out I wasn't actually running the latest version of Hardhat. Updating to version 2.6.4 fixed it.