From 956d1ab8786b413590dd305a276f55fd55916487 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 20 Oct 2023 11:43:26 +1000 Subject: [PATCH] Dencun corner cases (#6060) * cherry pick changes from https://github.com/hyperledger/besu/pull/6054/files\#diff-22b78733e37a697fa8d1d8a02d2a87fe5ccea9cf67c34ce5e6311f024c14abd6L643-R738 Signed-off-by: Sally MacFarlane * cherry pick changes from https://github.com/hyperledger/besu/pull/6054/files\#diff-61db834b59eae5ce5c438462505de1add8fa244deda830742060d15f668a9806R39-R44 Signed-off-by: Sally MacFarlane * formatting Signed-off-by: Sally MacFarlane * update the EIP-6110 acceptance tests Signed-off-by: Danno Ferrin --------- Signed-off-by: Sally MacFarlane Signed-off-by: Danno Ferrin Co-authored-by: Danno Ferrin (cherry picked from commit 9d9fe8c201daf4a386457794a57d0776e6a91437) Signed-off-by: Justin Florentine --- .../mainnet/ParentBeaconBlockRootHelper.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ParentBeaconBlockRootHelper.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ParentBeaconBlockRootHelper.java index 2c863add026..5f257c3dd32 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ParentBeaconBlockRootHelper.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ParentBeaconBlockRootHelper.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.evm.account.MutableAccount; import org.hyperledger.besu.evm.worldstate.WorldUpdater; @@ -27,8 +28,8 @@ public interface ParentBeaconBlockRootHelper { // Modulus to use for the timestamp to store the root - public static final long HISTORY_BUFFER_LENGTH = 8191; - public static final Address BEACON_ROOTS_ADDRESS = + long HISTORY_BUFFER_LENGTH = 8191; + Address BEACON_ROOTS_ADDRESS = Address.fromHexString("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"); static void storeParentBeaconBlockRoot( @@ -36,13 +37,18 @@ static void storeParentBeaconBlockRoot( /* see EIP-4788: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4788.md */ + // If code is not deployed don't do anything + final MutableAccount account = worldUpdater.getOrCreate(BEACON_ROOTS_ADDRESS); + if (Hash.EMPTY.equals(account.getCodeHash())) { + return; + } + final long timestampReduced = Long.remainderUnsigned(timestamp, HISTORY_BUFFER_LENGTH); final long timestampExtended = timestampReduced + HISTORY_BUFFER_LENGTH; final UInt256 timestampIndex = UInt256.valueOf(timestampReduced); final UInt256 rootIndex = UInt256.valueOf(timestampExtended); - final MutableAccount account = worldUpdater.getOrCreate(BEACON_ROOTS_ADDRESS); account.setStorageValue( timestampIndex, UInt256.fromBytes(Bytes.of(Longs.toByteArray(timestamp)))); account.setStorageValue(rootIndex, UInt256.fromBytes(root));