Skip to content

Commit

Permalink
Fix eip 2935 reftests (hyperledger#7093)
Browse files Browse the repository at this point in the history
* Fix reference tests for eip-2935

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
  • Loading branch information
Gabriel-Trintinalia committed May 13, 2024
1 parent 5fa1750 commit a5e08c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@

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
* responsible for managing the storage of block hashes to support EIP-2935, which introduces
* 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");
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a5e08c8

Please sign in to comment.