From a5e08c8b026a8142d93a3819a8cad2eeb4ff8b1d Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Mon, 13 May 2024 07:05:15 +0300 Subject: [PATCH] Fix eip 2935 reftests (#7093) * Fix reference tests for eip-2935 Signed-off-by: Gabriel-Trintinalia --- .../mainnet/blockhash/PragueBlockHashProcessor.java | 9 ++++++--- .../besu/evm/operation/BlockHashOperation.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/blockhash/PragueBlockHashProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/blockhash/PragueBlockHashProcessor.java index a5638e57288..98ea102dc26 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/blockhash/PragueBlockHashProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/blockhash/PragueBlockHashProcessor.java @@ -27,6 +27,8 @@ import com.google.common.annotations.VisibleForTesting; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Processes and stores historical block hashes in accordance with EIP-2935. This class is @@ -34,6 +36,7 @@ * historical block hash access in smart contracts. */ public class PragueBlockHashProcessor extends CancunBlockHashProcessor { + private static final Logger LOG = LoggerFactory.getLogger(PragueBlockHashProcessor.class); public static final Address HISTORY_STORAGE_ADDRESS = Address.fromHexString("0x25a219378dad9b3503c8268c9ca836a52427a4fb"); @@ -76,7 +79,7 @@ public BlockHashLookup getBlockHashLookup( return (frame, blockNumber) -> { long currentBlockNumber = frame.getBlockValues().getNumber(); if (currentBlockNumber <= blockNumber - || currentBlockNumber - blockNumber >= historySaveWindow + || currentBlockNumber - blockNumber > historySaveWindow || blockNumber < 0) { return Hash.ZERO; } @@ -143,8 +146,8 @@ private void storeBlockHeaderHash(final MutableAccount account, final BlockHeade * @param hash The hash to be stored. */ private void storeHash(final MutableAccount account, final long number, final Hash hash) { - System.out.printf( - "Writing to %s %s=%s%n", + LOG.trace( + "Writing to {} {}=%{}", account.getAddress(), UInt256.valueOf(number % historySaveWindow).toDecimalString(), UInt256.fromBytes(hash).toHexString()); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java index e42d04d75ba..4c7ff7bf9ef 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java @@ -28,7 +28,7 @@ public class BlockHashOperation extends AbstractFixedCostOperation { /** Frontier maximum relative block delta */ - public static final int MAX_RELATIVE_BLOCK = 255; + public static final int MAX_RELATIVE_BLOCK = 256; /** * Function that gets the block hash, passed in as part of TxValues.