Open fp-crypto opened 1 year ago
The reason Hardhat's time is constant is that when more than N blocks are mined (I don't remember the value of N) they are not actually mined. Instead, a fake range of blocks is created and then the last ones are actually mined. This means that the hash of the latest block is kind of fake, but that's an acceptable trade-off.
There are some non-obvious things to keep in mind to implement this approach though. Happy to share them here if someone is interested in implementing this in Anvil.
What would be the way to go about implementing this @fvictorio?
Hi @fvictorio,
Following up on this issue since there hasn't been any activity for a while. Would it be possible to discuss implementing this functionality, either here or via email? We're currently using anvil extensively for testing and this functionality would save us a lot of CI time. I'm more than willing to tackle this issue if pointed in the right direction.
Cheers :tada:
I attempted to move my testing from
hardhat node
toanvil
. Some of my testing requires mining a large number of blocks.anvil_mine
execution time seems to scale linearly relative to block count, whereashardhat_mine
withhardhat node
is nearly constant. See the following benchmarks:Anvil
Hardhat
I'm using:
anvil 0.1.0 (0e33b3e 2023-07-26T00:26:08.161934000Z)
hardhat 9.6.7
ape 0.6.14
(for testing)https://github.com/foundry-rs/foundry/blob/41bae8e6265e905f73c3f4eac14a5ba9275417a4/anvil/src/eth/api.rs#L1421-L1440