1

Whenever I do a fork on mainnet at latest with hardhat, it's never at the latest block. Why is that? For example in the below:

    console.log("BLOCK FRO ALCHEMY: ", (await alchemyEthProvider.getBlock("latest")).number); //block N
    console.log("BLOCK FROM HARDHAT", (await hardhatProvider.getBlock("latest")).number); //block N-5

The hardhat settings for mainnet forking just uses the same provider as alchemyEthProvider above, so it's sourced from the same provider, ultimately. But for some reason, forking is a bit slower.

1 Answer 1

0

There are a couple key factors here:

  • you're forking "from" mainnet, not on it
  • a data/code "fork" is just like a fork in the road; one continues to the left and another to the right

This is why the fork cannot match mainnet, because it's now a completely different road and is effectively its own network.

1
  • this is not exactly true. if he forks latest block, then the hardhat's and mainnet's heads are equal, until either the local network or mainnet is altered
    – Risinek
    Feb 28 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.