Improve BLOCKHASH Short Circuit (#8171)

* Improve BLOCKHASH Short Circuit
Signed-off-by: Danno Ferrin <danno@numisight.com>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
This commit is contained in:
Danno Ferrin
2025-01-29 19:03:39 -07:00
committed by GitHub
parent 98bed38814
commit 6af23ea024

View File

@@ -57,9 +57,9 @@ public class BlockHashOperation extends AbstractOperation {
final long currentBlockNumber = blockValues.getNumber();
final BlockHashLookup blockHashLookup = frame.getBlockHashLookup();
// If the current block is the genesis block or the sought block is
// not within the lookback window, zero is returned.
if (currentBlockNumber == 0
// If the sought block is negative, a future block, the current block, or not in the
// lookback window, zero is returned.
if (soughtBlock < 0
|| soughtBlock >= currentBlockNumber
|| soughtBlock < (currentBlockNumber - blockHashLookup.getLookback())) {
frame.pushStackItem(Bytes32.ZERO);