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

Unable to fork sepolia testnet #5554

Closed
Abhishekkochar opened this issue Jul 26, 2024 · 3 comments
Closed

Unable to fork sepolia testnet #5554

Abhishekkochar opened this issue Jul 26, 2024 · 3 comments
Assignees
Labels
status:needs-more-info There's not enough information to start working on this issue

Comments

@Abhishekkochar
Copy link

Abhishekkochar commented Jul 26, 2024

I'm trying to fork the sepolia testnet using alchemy.

Following is the hardhat.config.ts file:

require("dotenv").config();
require("hardhat-contract-sizer");

import chalk from "chalk";
import { HardhatUserConfig } from "hardhat/config";
import { privateKeys } from "./utils/wallets";

import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "solidity-coverage";
import "./tasks";

const forkingConfig = {
  url: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_TOKEN}`,
  blockNumber: 6378120,
};

checkForkedProviderEnvironment();

const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.6.10",
        settings: { optimizer: { enabled: true, runs: 200 } },
      },
      {
        version: "0.8.11",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200,
          },
        },
      },
    ],
  },
  networks: {
    hardhat: {
      allowUnlimitedContractSize: false,
      forking: (process.env.FORK) ? forkingConfig : undefined,
      accounts: getHardhatPrivateKeys(),
      gas: 12000000,
      blockGasLimit: 12000000
    },
    localhost: {
      url: "http://127.0.0.1:8545/",
      forking: (process.env.FORK) ? forkingConfig : undefined,
      timeout: 200000,
      gas: 12000000,
      blockGasLimit: 12000000
    },
    // sepolia: {
    //   url: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_TOKEN}`,
    //   // @ts-ignore
    //   accounts: [`0x${process.env.DEPLOY_PRIVATE_KEY}`],
    // },
  },
  // @ts-ignore
  typechain: {
    outDir: "typechain",
    target: "ethers-v5",
    externalArtifacts: ["external/**/*.json"],
  },
  // @ts-ignore
  contractSizer: {
    runOnCompile: false,
  },

  // These are external artifacts we don't compile but would like to improve
  // test performance for by hardcoding the gas into the abi at runtime
  // @ts-ignore
  externalGasMods: [
    "external/abi/perp",
  ],
};

function getHardhatPrivateKeys() {
  return privateKeys.map(key => {
    const ONE_MILLION_ETH = "1000000000000000000000000";
    return {
      privateKey: key,
      balance: ONE_MILLION_ETH,
    };
  });
}

function checkForkedProviderEnvironment() {
  if (process.env.FORK &&
      (!process.env.ALCHEMY_TOKEN || process.env.ALCHEMY_TOKEN === "fake_alchemy_token")
     ) {
    console.log(chalk.red(
      "You are running forked provider tests with invalid Alchemy credentials.\n" +
      "Update your ALCHEMY_TOKEN settings in the `.env` file."
    ));
    process.exit(1);
  }
}

export default config;

All the .env variables are valid and FORK has been set to true.
Below is the error:
Screenshot 2024-07-27 at 1 18 19 AM

@Abhishekkochar
Copy link
Author

Issue happens when try to fork the chain.

@schaable
Copy link
Member

schaable commented Aug 8, 2024

Hey @Abhishekkochar, I tested a simplified version of your Hardhat config and it seems to work as expected. Here’s the configuration I used:

const forkingConfig = {
  url: `your-alchemy-url`,
  blockNumber: 6378120,
};

const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.6.10",
        settings: { optimizer: { enabled: true, runs: 200 } },
      },
      {
        version: "0.8.11",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200,
          },
        },
      },
    ],
  },
  networks: {
    hardhat: {
      allowUnlimitedContractSize: false,
      forking: forkingConfig,
      gas: 12000000,
      blockGasLimit: 12000000,
    },
  },
};

Could you try again with this configuration and let me know if it works for you? If not, could you provide any extra information or share a link to the repo (if public)? Also, which version of Hardhat are you using?

@schaable schaable added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Aug 8, 2024
@schaable
Copy link
Member

I'm closing this for bookkeeping purposes, but if you can provide the requested details, please let us know, and we’ll reopen it. Thanks!

@schaable schaable closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Sep 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:needs-more-info There's not enough information to start working on this issue
Projects
Archived in project
Development

No branches or pull requests

2 participants