Open wchargin opened 1 year ago
This issue is also being tracked on Linear.
We use Linear to manage our development process, but we keep the conversations on Github.
LINEAR-ID: 54194f1e-982c-497c-8bfa-3925d5a114ea
We're giving this a lower priority because it doesn't seem to have a real world application/impact. If you disagree, please explain your use case and it may convince us to increase the priority. Thank you.
I have a contract that behaves differently when the block number exceeds 2^64. Obviously, this height isn't expected to be reached any time soon under current mainnet parameters, but it could plausibly happen on some side chain (or later version of mainnet), and it should definitely be possible to test.
At first glance, the
hardhat_mine
RPC from #1112 and #2032 seem like the perfect tools. But I'm running into two issues:Though the docs claim that this method is constant-time with "the same performance no matter how many blocks are mined", it seems to markedly slow down as
n
exceeds around 2^32.Mining more than 2^53 blocks at once doesn't seem to be supported at all: "Error: Number can only safely store up to 53 bits".
This script demonstrates (
npx hardhat run script.js
in a fresh repo):Sample outputs:
Also, executing trivial transactions after mining order-of 2^38 blocks seems to take a long time, too (order-of 100 seconds).
This is a little surprising to me since the
mineBlocks
implementation seems to take its arguments asBigNumber
s, so it sounds like it expects to work in those ranges: https://github.com/NomicFoundation/hardhat/blob/bcd32259a1439a57a60ca67d2682014d051f5f8a/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts#L508-L509What's the best way for me to test contract behavior when
block.number
exceedstype(uint64).max
?