Does Hardhat Network's evm_revert restore block metadata when automine is disabled?
0 reputation · 17 Aug 2021, 01:05 UTC
Testing upgrade scenarios with Hardhat Network often relies on evm_snapshot and evm_revert to isolate state changes between test cases. The documentation confirms that account balances, contract storage, and nonces are restored, but the behavior for blockchain metadata—block number, timestamp, difficulty, and coinbase—is not explicitly guaranteed across all mining configurations.
When automine is disabled, transactions sit in the mempool until an explicit mine call. A snapshot taken after queuing a transaction but before mining captures a state that includes pending transactions. It is unclear whether evm_revert in this mode also rewinds the block header fields to their values at the snapshot point, or whether those fields continue advancing from the current head while only the EVM state rolls back.
This distinction matters for tests that assert specific block timestamps or numbers after a revert, and for any logic that reads block.number or block.timestamp during upgrade simulations.
Does evm_revert reset block metadata to the snapshot point when automine is disabled? If metadata is not restored, which fields diverge and under what conditions? Can the behavior be controlled through Hardhat Network configuration or is it fixed per version?