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

Error when I try to run test forked from Arbitrum network #3194

Closed
AbigailTCameron opened this issue Sep 17, 2022 · 8 comments · Fixed by #3302
Closed

Error when I try to run test forked from Arbitrum network #3194

AbigailTCameron opened this issue Sep 17, 2022 · 8 comments · Fixed by #3302
Assignees

Comments

@AbigailTCameron
Copy link

I've been trying to run tests, npx hardhat test on the arbitrum network with the basic testing framework that hardhat establishes upon creating a new project and I am continuously met with this error:

OnlyHardhatNetworkError: This helper can only be used with Hardhat Network. You are connected to 'hardhat'.
at checkIfHardhatNetwork (/Users/abigailcameron/testing-arb/node_modules/@nomicfoundation/hardhat-network-helpers/src/utils.ts:28:11)
      at getHardhatProvider (/Users/abigailcameron/testing-arb/node_modules/@nomicfoundation/hardhat-network-helpers/src/utils.ts:39:9)
      at async Object.latest (/Users/abigailcameron/testing-arb/node_modules/@nomicfoundation/hardhat-network-helpers/src/helpers/time/latest.ts:7:20)
      at async Context.<anonymous> (/Users/abigailcameron/testing-arb/test/Lock.ts:51:26)
An unexpected error occurred:

InternalError: Unknown transaction type 106
at ForkBlockchain._processRemoteBlock (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:300:15)
    at ForkBlockchain._getBlockByNumber (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:242:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ForkBlockchain.getBlock (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts:66:13)
    at async ForkBlockchain.getLatestBlock (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/BlockchainBase.ts:87:19)
    at async Function.create (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:205:31)
    at async HardhatNetworkProvider._init (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:251:28)
    at async HardhatNetworkProvider._send (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:192:5)
    at async HardhatNetworkProvider.request (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:118:18)
    at async SimpleTaskDefinition.action (/Users/abigailcameron/testing-arb/node_modules/hardhat/src/builtin-tasks/test.ts:171:37)
abigailcameron@MacBook-Pro testing-arb % 

The only changes I have made were done to the hardhat.config.ts file so that we're forking from the arbitrum network

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const config: HardhatUserConfig = {
  solidity: "0.8.17",
  networks:{
    hardhat:{
      chainId: 42161,
      forking:{
        url: "https://arb1.arbitrum.io/rpc"
      }
    }
  }
};

export default config;

I've already tried running hardhat patch but that doesn't seem to work for me, and I ONLY get this error when I try forking from the arbitrum network.

N.B. I am running the latest hardhat version to date (^2.11.2).

@github-actions
Copy link
Contributor

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: 11941d78-8527-444a-8c6c-a16a13590a0d

@voytenko-d
Copy link

The problem with new blocks, in my case, using old blocks helped me. When forking a branch, try not to start from the latest blocks.

networks: {
    hardhat: {
      forking: {
        url: `https://***/${process.env.***}`,
        blockNumber: 20005467
      },
    },
  },

@AbigailTCameron
Copy link
Author

That doesn't work for me, I still get the same OnlyHardhatNetworkError: This helper can only be used with Hardhat Network. You are connected to 'hardhat'. error

@fvictorio
Copy link
Member

I think the underlying cause here is the same as in #2995

The reason is that when forking starts, the latest block is fetched and processed. If that block has txs with "unknown" types, then the fork initialization fails. In this case, since the initialization is triggered by a network helper, then we are (incorrectly) assuming that it failed because of a non-hardhat network.

In short:

@fvictorio
Copy link
Member

Hi, we just published a beta version of Hardhat that should fix the forking issue. I would appreciate it if you can give it a try:

npm install hardhat@unknown-txs

(If you are using npm 7 or later, you might get some warnings about unsatisfied peer dependencies, but you can ignore those.)

If this seems to be working fine, we'll publish a stable version with this change as soon as possible.

Please try it out and let us know if it works (or doesn't!)

@branzinho
Copy link

I am also getting this issue when connecting to goerli.
OnlyHardhatNetworkError: This helper can only be used with Hardhat Network. You are connected to 'goerli', whose identifier is 'Geth/v1.10.23-stable-d901d853/linux-amd64/go1.18.5'

@Skyge
Copy link

Skyge commented Oct 28, 2022

@branzinho-nt I think you use something from @nomicfoundation/hardhat-network-helpers, such as loadFixture.

@fvictorio
Copy link
Member

This fix is now included in the latest release.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants