NomicFoundation / edr

An Ethereum development runtime implementation that can be reused to build new developer tools.
MIT License
32 stars 3 forks source link

Better handling of unknown hardfork histories #522

Open fvictorio opened 1 week ago

fvictorio commented 1 week ago

PR https://github.com/NomicFoundation/hardhat/pull/5394 adds some naive hardfork histories for optimism/arbitrum chains, where the same (conservative) hardfork is used for all blocks.

The underlying problem here is this: if Hardhat/EDR doesn't have a hardfork history for a given chain id, then "historical" calls will fail. This was a compromise we decided to make when we added hardfork histories. What we didn't foresee is that making a call immediately after forking is executed as a historical call, because the call is run in the forked block, which is not considered local. This means that if you fork a chain whose history is not in the default config and you immediately make a call, then you'll get an error.

It's unclear what's the right fix here. Two ideas:

  1. Use the local hardfork for calls executed in the forked block. The forked block is already a weird block (e.g., it has an irregular state transition that changes the balances of the default accounts), so adding a little more weirdness seems like a fine compromise.
  2. Have a safe default hardfork for unknown chain ids (maybe printing a warning).

Notice that we can do both too.

fvictorio commented 1 week ago

I'm marking this as "Blocked" because we should either figure this out as part of the multichain effort, or re-visit it after that.