Fix eip 2935 reftests (#7093)

* Fix reference tests for eip-2935

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7095/head
Gabriel-Trintinalia 6 months ago committed by GitHub
parent 5fa1750606
commit a5e08c8b02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/blockhash/PragueBlockHashProcessor.java
  2. 2
      evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java

@ -27,6 +27,8 @@ import org.hyperledger.besu.plugin.data.ProcessableBlockHeader;
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 @@ import org.apache.tuweni.units.bigints.UInt256;
* 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 class PragueBlockHashProcessor extends CancunBlockHashProcessor {
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 @@ public class PragueBlockHashProcessor extends CancunBlockHashProcessor {
* @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());

@ -28,7 +28,7 @@ import org.apache.tuweni.units.bigints.UInt256;
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.

Loading…
Cancel
Save