From 1befeacf3c1b1f7e06e5c7aa21152b70b251220d Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Wed, 18 Oct 2023 18:54:39 -0400 Subject: [PATCH] Unsigned timestamps and blob gas used (#6046) * lots of places an unsigned timestamp is a problem * adds unchecked annotations to OptionalUnsignedLong rpc parameter type --------- Signed-off-by: Justin Florentine (cherry picked from commit a90ea056f19915a4eca787fc066c080e1789c14c) Signed-off-by: Justin Florentine --- .../mainnet/ParentBeaconBlockRootHelper.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 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 5f257c3dd32..2c863add026 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,7 +15,6 @@ 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; @@ -28,8 +27,8 @@ public interface ParentBeaconBlockRootHelper { // Modulus to use for the timestamp to store the root - long HISTORY_BUFFER_LENGTH = 8191; - Address BEACON_ROOTS_ADDRESS = + public static final long HISTORY_BUFFER_LENGTH = 8191; + public static final Address BEACON_ROOTS_ADDRESS = Address.fromHexString("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"); static void storeParentBeaconBlockRoot( @@ -37,18 +36,13 @@ 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));