-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
No known hardfork for execution on historical block #5511
Comments
I also encountered it, it should be a problem with v2.22.3, I downgraded the version to v2.22.2 and it ran normally. |
I still get it with v2.22.2, forking the same network as above. |
Sorry I saw it wrong, I reverted to v2.19.4 |
Can confirm this error goes away with v2.19.4, but I am relying on features introduced later (and get other errors), so can't really use that version. Thanks for the input though! |
As additional input: my script works with anvil running the local fork, so error should be on the node task side |
You can try to roll back to the previous version from v2.22.3 |
Hi, I can't reproduce this. I'm forking sepolia and running a call with some random ERC-20: const blockNumber = await ethers.provider.getBlockNumber()
const mockDai = await ethers.getContractAt(["function totalSupply() public view returns(uint256)"], "0xd6a17186e7bde277ad70e5d5c99d042acf30990c")
console.log(await mockDai.totalSupply())
console.log(await mockDai.totalSupply({blockTag: blockNumber - 10})) Could someone give us a minimal reproducible example? |
I downgraded the version to v2.20.1 and it worked on optimistic network "devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"hardhat": "^2.20.1"
} Testcase code : import hre from "hardhat";
//USDC 合约地址
const USDC_ADDRESS = "0x0b2c639c533813f4aa9d7837caf62653d097ff85";
//USDC ABI
const USDC_ABI = ["function totalSupply() public view returns (uint)"];
describe("Optimistic USDC", function () {
describe("Balance", function () {
it("Get usdc balance by address", async function () {
const usdcToken = await hre.ethers.getContractAt(USDC_ABI, USDC_ADDRESS);
const block = await hre.ethers.provider.getBlockNumber();
console.log("Optimistic Block Number", block);
//获取 USDT 总发行量
const totalSupply = await usdcToken.totalSupply();
console.log("Optimistic USDC totalSupply", hre.ethers.formatUnits(totalSupply, 6));
});
});
}); Run command: fork:
npx hardhat node --fork https://opt-mainnet.g.alchemy.com/v2/...
run:
npx hardhat test --network localhost Result: Optimistic USDC
Balance
Optimistic Block Number 120288014
Optimistic USDC totalSupply 169377140.604314
✔ Get usdc balance by address (3721ms)
1 passing (4s) |
@noodlespan I can confirm this fixes the error as well with |
@fvictorio Is that enough or do you need more info? |
Confirmed and important, thanks! |
I hope we can fix this soon, but in the meantime: a workaround seems to be to immediately mine a block after starting the node. For example, adding this at the beginning of the script: import * as helpers from "@nomicfoundation/hardhat-network-helpers";
await helpers.mine()
// rest of the script |
@fvictorio Thanks for the workaround, can confirm this does fix the problem, at least temporally 👍 |
I am using 2.22.5. Didnt downgrade. used the code shared above. It resolved my issue. |
I am still getting this error on the latest version. Is it supposed to be solved? Hardhat version: "^2.22.8" |
@bytes0xcr6 we fixed it for some chains (Optimism and Arbitrum mainnets and testnets). This will continue to be an issue for "unknown" chains. The workarounds are:
We are going to fix the underlying issue so that these workarounds are not necessary, but I don't have an estimation of when that will happen. |
I had the same problem. When I reverted hardhat to v2.19.4, everything worked. Thank you! |
Still getting this issue on "^2.22.5" |
@Quazia which chain are you using? Zora? |
I got the same issue with Blast chain. I added the hardForkHistory in my hardhat.config.js file :
|
Version of Hardhat
2.22.3
What happened?
Forked arbitrum sepolia with
npx hardhat node
, when trying to run a typescript script that calls any function on-chain (even simple view function), I get the errorProviderError: No known hardfork for execution on historical block 42324641 (relative to fork block number 42324641). The node was not configured with a hardfork activation history.
The block number is the block at which the chain has been forked I believe (didn't specify so should be
latest
).Minimal reproduction steps
Fork arbitrum sepolia with
npx hardhat node
with an alchemy endpoint.Search terms
No response
The text was updated successfully, but these errors were encountered: