Skip to content

Instantly share code, notes, and snippets.

@fvictorio
Created August 30, 2021 13:06
Show Gist options
  • Save fvictorio/9c54b7228869ce605287f7c563802674 to your computer and use it in GitHub Desktop.
Save fvictorio/9c54b7228869ce605287f7c563802674 to your computer and use it in GitHub Desktop.
Hardhat mainnet fork and "Missing trie node" error

tl;dr You are not using an archive node. Explanation below.


When you fork a Network with Hardhat, you are forking it from a given block number. If you don't specify one, the latest block will be used (minus N, where N is chosen to prevent reorgs messing with the fork).

Hardhat will use the node to fetch the data it needs. When you ask for data in a node, you are asking about the data at some specific block. If you are forking from the latest block, then you'll be able to get this data even if the node you are using is not an archive node. But after some minutes, this block you forked will become old enough for the node to stop having historical information about it, and you'll start getting the "Missing trie node".

To fix this, use an archive node or a provider like Alchemy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment