From a7c930d7e33573612267b0766e9cf8f0e3220888 Mon Sep 17 00:00:00 2001 From: Luis Pinto Date: Wed, 8 Jan 2025 18:13:33 +0000 Subject: [PATCH 1/2] Fix javadoc issues Signed-off-by: Luis Pinto --- .../merge/blockcreation/MergeCoordinator.java | 2 +- .../besu/evm/account/MutableAccount.java | 5 + .../gascalculator/BerlinGasCalculator.java | 3 +- .../gascalculator/Eip4762GasCalculator.java | 11 +- .../besu/evm/gascalculator/GasCalculator.java | 30 ++++ .../gascalculator/stateless/AccessEvents.java | 155 ++++++++++++++++-- .../gascalculator/stateless/AccessMode.java | 49 ------ .../stateless/Eip4762AccessWitness.java | 79 +++++---- .../stateless/NoopAccessWitness.java | 6 + .../evm/operation/ExtCodeSizeOperation.java | 6 +- .../besu/evm/operation/SLoadOperation.java | 8 + .../services/storage/DataStorageFormat.java | 1 + 12 files changed, 254 insertions(+), 101 deletions(-) delete mode 100644 evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessMode.java diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java index 729fafa1561..b458e82319e 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java @@ -641,7 +641,7 @@ && isDescendantOf(newHead, blockchain.getChainHeadHeader())) { return ForkchoiceResult.withResult(newFinalized, Optional.of(newHead)); } - public boolean setNewHead(final MutableBlockchain blockchain, final BlockHeader newHead) { + private boolean setNewHead(final MutableBlockchain blockchain, final BlockHeader newHead) { if (newHead.getHash().equals(blockchain.getChainHeadHash())) { LOG.atDebug() diff --git a/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java b/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java index 9c00060f3d3..1c2054ceec1 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java @@ -80,6 +80,11 @@ default Wei decrementBalance(final Wei value) { */ void setBalance(Wei value); + /** + * Gets the code size of this account. + * + * @return the code size of this account. + */ Optional getCodeSize(); /** diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java index daf82e356bd..4b06502c0f3 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java @@ -48,6 +48,7 @@ public class BerlinGasCalculator extends IstanbulGasCalculator { protected static final long ACCESS_LIST_STORAGE_COST = 1900L; // redefinitions for EIP-2929 + /** The constant SLOAD_GAS. */ protected static final long SLOAD_GAS = WARM_STORAGE_READ_COST; /** The constant SSTORE_RESET_GAS. */ @@ -66,7 +67,7 @@ public class BerlinGasCalculator extends IstanbulGasCalculator { private static final long NEGATIVE_SSTORE_CLEARS_SCHEDULE = -SSTORE_CLEARS_SCHEDULE; // unchanged from Frontier - protected static final long COPY_WORD_GAS_COST = 3L; + private static final long COPY_WORD_GAS_COST = 3L; private final int maxPrecompile; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/Eip4762GasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/Eip4762GasCalculator.java index 2ae64e2c556..d09ee5877ba 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/Eip4762GasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/Eip4762GasCalculator.java @@ -30,12 +30,19 @@ import org.apache.tuweni.units.bigints.UInt256; +/** + * Gas Calculator as per EIP-4762 + * + *
    + *
  • Gas costs for EIP-4762 (Stateless trie) + *
+ */ public class Eip4762GasCalculator extends PragueGasCalculator { - public static final Address HISTORY_STORAGE_ADDRESS = + private static final Address HISTORY_STORAGE_ADDRESS = Address.fromHexString("0xfffffffffffffffffffffffffffffffffffffffe"); private static final long CREATE_OPERATION_GAS_COST = 1_000L; - /** Instantiates a new Prague Gas Calculator. */ + /** Instantiates a new EIP-4762 Gas Calculator. */ public Eip4762GasCalculator() { super(KZG_POINT_EVAL.toArrayUnsafe()[19]); } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java index 8ae4132d043..2f23f13367b 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java @@ -270,6 +270,12 @@ long callOperationGasCost( */ long gasAvailableForChildCall(MessageFrame frame, long stipend, boolean transfersValue); + /** + * The cost of creating a contract account to the trie. + * + * @param frame The current frame + * @return the gas cost + */ long completedCreateContractGasCost(final MessageFrame frame); /** @@ -333,6 +339,13 @@ long callOperationGasCost( */ long initcodeCost(final int initCodeLength); + /** + * The cost of checking if a contract already exists in the trie. + * + * @param frame The current frame + * @param address The contract address + * @return the gas cost for the proof of absence check + */ default long proofOfAbsenceCost(final MessageFrame frame, final Address address) { return 0; } @@ -370,6 +383,15 @@ default long proofOfAbsenceCost(final MessageFrame frame, final Address address) long codeCopyOperationGasCost( MessageFrame frame, long memOffset, long codeOffset, long readSize, final long codeSize); + /** + * Returns the amount of gas consumed by a PUSH operation. + * + * @param frame The current frame + * @param codeOffset offset of the code in bytes where the EVM is currently executing + * @param readSize size, in bytes, of the code that is being read by the PUSH operation + * @param codeSize full size of the code + * @return the amount of gas consumed by a PUSH operation + */ long pushOperationGasCost(MessageFrame frame, long codeOffset, long readSize, long codeSize); /** @@ -538,6 +560,9 @@ long selfDestructOperationGasCost( /** * Returns the cost for executing a {@link SLoadOperation}. * + * @param frame The current frame + * @param key The slot key + * @param slotIsWarm The storage slot is warm * @return the cost for executing the storage load operation */ long sloadOperationGasCost(MessageFrame frame, UInt256 key, final boolean slotIsWarm); @@ -763,6 +788,11 @@ default long calculateDelegateCodeGasRefund(final long alreadyExistingAccountSiz return 0L; } + /** + * Creates a new access witness instance. + * + * @return an access witness instance that by default is an access witness that does nothing + */ default AccessWitness newAccessWitness() { return NoopAccessWitness.get(); } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessEvents.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessEvents.java index ec2a4e0255f..e03d7b81044 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessEvents.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessEvents.java @@ -14,6 +14,13 @@ */ package org.hyperledger.besu.evm.gascalculator.stateless; +/** + * Manages access events that are done to the AccessWitness. An access mode is passed to the witness + * representing the type of access being done on the verkle trie leaf node: read, write to an + * existing leaf (reset) or write to a non-existent leaf (set). The access mode is then evaluated + * against structures that tracks previous access events, to avoid double charging. What results is + * the **new** access event schedule that is then used for gas charging. + */ public final class AccessEvents { private static final long WITNESS_BRANCH_COST = 1900; @@ -22,51 +29,177 @@ public final class AccessEvents { private static final long CHUNK_EDIT_COST = 500; private static final long CHUNK_FILL_COST = 6200; - public static final short NONE = 0; - public static final short BRANCH_READ = 1; - public static final short BRANCH_WRITE = 2; - public static final short LEAF_READ = 4; - public static final short LEAF_RESET = 8; - public static final short LEAF_SET = 16; + /** Bit mask for NONE */ + public static final int NONE = 0; + + /** Bit mask for BRANCH READ */ + public static final int BRANCH_READ = 1; + + /** Bit mask for BRANCH WRITE */ + public static final int BRANCH_WRITE = 2; + + /** Bit mask for LEAF READ */ + public static final int LEAF_READ = 4; + + /** Bit mask for LEAF RESET */ + public static final int LEAF_RESET = 8; + + /** Bit mask for LEAF SET */ + public static final int LEAF_SET = 16; private AccessEvents() {} - public static boolean isBranchRead(final short accessEvents) { + /** + * Checks if a branch read event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains a branch read event, false otherwise + */ + public static boolean isBranchRead(final int accessEvents) { return (accessEvents & BRANCH_READ) != 0; } - public static boolean isBranchWrite(final short accessEvents) { + /** + * Adds a branch read event to the bit mask of access events. + * + * @param accessEvents bit mask of all access events so far + * @return bit mask with all access events plus a branch read + */ + public static int branchRead(final int accessEvents) { + return accessEvents | BRANCH_READ; + } + + /** + * Checks if a branch write event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains a branch write event, false otherwise + */ + public static boolean isBranchWrite(final int accessEvents) { return (accessEvents & BRANCH_WRITE) != 0; } - public static boolean isLeafRead(final short accessEvents) { + /** + * Adds a branch write event to the bit mask of access events. + * + * @param accessEvents bit mask of all access events so far + * @return bit mask with all access events plus a branch write + */ + public static int branchWrite(final int accessEvents) { + return accessEvents | BRANCH_WRITE; + } + + /** + * Checks if a leaf read event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains a leaf read event, false otherwise + */ + public static boolean isLeafRead(final int accessEvents) { return (accessEvents & LEAF_READ) != 0; } - public static boolean isLeafReset(final short accessEvents) { + /** + * Adds a leaf read event to the bit mask of access events. + * + * @param accessEvents bit mask of all access events so far + * @return bit mask with all access events plus a leaf read + */ + public static int leafRead(final int accessEvents) { + return accessEvents | LEAF_READ; + } + + /** + * Checks if a leaf reset event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains a leaf reset event, false otherwise + */ + public static boolean isLeafReset(final int accessEvents) { return (accessEvents & LEAF_RESET) != 0; } - public static boolean isLeafSet(final short accessEvents) { + /** + * Adds a leaf reset event to the bit mask of access events. + * + * @param accessEvents bit mask of all access events so far + * @return bit mask with all access events plus a leaf reset + */ + public static int leafReset(final int accessEvents) { + return accessEvents | LEAF_RESET; + } + + /** + * Checks if a leaf set event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains a leaf set event, false otherwise + */ + public static boolean isLeafSet(final int accessEvents) { return (accessEvents & LEAF_SET) != 0; } + /** + * Adds a leaf set event to the bit mask of access events. + * + * @param accessEvents bit mask of all access events so far + * @return bit mask with all access events plus a leaf set + */ + public static int leafSet(final int accessEvents) { + return accessEvents | LEAF_SET; + } + + /** + * Checks if a write event has occurred. + * + * @param accessEvents bit mask of all access events so far + * @return true if bit mask contains any of the write events, false otherwise + */ + public static boolean isWrite(final int accessEvents) { + return isBranchWrite(accessEvents) || isLeafSet(accessEvents) || isLeafReset(accessEvents); + } + + /** + * The branch read event cost. + * + * @return cost of a branch read event. + */ public static long getBranchReadCost() { return WITNESS_BRANCH_COST; } + /** + * The leaf read event cost. + * + * @return cost of a leaf read event. + */ public static long getLeafReadCost() { return WITNESS_CHUNK_COST; } + /** + * The branch write event cost. + * + * @return cost of a branch write event. + */ public static long getBranchWriteCost() { return SUBTREE_EDIT_COST; } + /** + * The leaf reset event cost. + * + * @return cost of a leaf reset event. + */ public static long getLeafResetCost() { return CHUNK_EDIT_COST; } + /** + * The leaf set event cost. + * + * @return cost of a leaf set event. + */ public static long getLeafSetCost() { return CHUNK_FILL_COST; } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessMode.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessMode.java deleted file mode 100644 index 91477ba3cea..00000000000 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/AccessMode.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.evm.gascalculator.stateless; - -public final class AccessMode { - public static int NONE = 0; - public static int READ = 1; - public static int WRITE_SET = 2; - public static int WRITE_RESET = 4; - - private static boolean isRead(final int accessMode) { - return (accessMode & READ) != 0; - } - - public static boolean isWrite(final int accessMode) { - return isWriteSet(accessMode) || isWriteReset(accessMode); - } - - public static boolean isWriteSet(final int accessMode) { - return (accessMode & WRITE_SET) != 0; - } - - private static boolean isWriteReset(final int accessMode) { - return (accessMode & WRITE_RESET) != 0; - } - - public static String toString(final int accessMode) { - if (isRead(accessMode)) { - return "READ"; - } else if (isWriteSet(accessMode)) { - return "WRITE_SET"; - } else if (isWriteReset(accessMode)) { - return "WRITE_RESET"; - } - return "UNKNOWN_ACCESS_MODE"; - } -} diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/Eip4762AccessWitness.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/Eip4762AccessWitness.java index 4fce60e3981..5af08a480d7 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/Eip4762AccessWitness.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/Eip4762AccessWitness.java @@ -36,6 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** Implementation of the AccessWitness as per EIP-4762. */ public class Eip4762AccessWitness implements AccessWitness { private static final Logger LOG = LoggerFactory.getLogger(Eip4762AccessWitness.class); @@ -45,10 +46,17 @@ public class Eip4762AccessWitness implements AccessWitness { private final Map leaves; private final Map branches; + /** Instantiates a new EIP-4762 access witness. */ public Eip4762AccessWitness() { this(new HashMap<>(), new HashMap<>()); } + /** + * Instantiates a new EIP-4762 access witness. + * + * @param leaves Collection the controls access to leaves in the trie. + * @param branches Collection the controls access to branches in the trie. + */ public Eip4762AccessWitness( final Map leaves, final Map branches) { this.branches = branches; @@ -240,18 +248,18 @@ public long touchCodeChunks( private long touchAddressOnWriteResetAndComputeGas( final Address address, final UInt256 treeIndex, final UInt256 subIndex) { - return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessMode.WRITE_RESET); + return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessEvents.LEAF_RESET); } private long touchAddressOnWriteSetAndComputeGas( final Address address, final UInt256 treeIndex, final UInt256 subIndex) { - // TODO: change to WRITE_SET when CHUNK_FILL is implemented. Still not implemented in devnet-7 - return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessMode.WRITE_RESET); + // TODO: change to LEAF_SET when CHUNK_FILL is implemented. Still not implemented in devnet-7 + return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessEvents.LEAF_RESET); } private long touchAddressOnReadAndComputeGas( final Address address, final UInt256 treeIndex, final UInt256 subIndex) { - return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessMode.READ); + return touchAddressAndChargeGas(address, treeIndex, subIndex, AccessEvents.LEAF_READ); } private List getStorageSlotTreeIndexes(final UInt256 storageKey) { @@ -276,12 +284,12 @@ public long touchAndChargeStorageStore( return touchAddressOnWriteResetAndComputeGas(address, treeIndexes.get(0), treeIndexes.get(1)); } - public long touchAddressAndChargeGas( + private long touchAddressAndChargeGas( final Address address, final UInt256 treeIndex, final UInt256 subIndex, final int accessMode) { - final short accessEvents = touchAddress(address, treeIndex, subIndex, accessMode); + final int accessEvents = touchAddress(address, treeIndex, subIndex, accessMode); long gas = 0; if (AccessEvents.isBranchRead(accessEvents)) { gas = clampedAdd(gas, AccessEvents.getBranchReadCost()); @@ -315,7 +323,7 @@ public long touchAddressAndChargeGas( return gas; } - private static String costSchedulePrettyPrint(final short accessEvents) { + private static String costSchedulePrettyPrint(final int accessEvents) { String message = ""; if (AccessEvents.isBranchRead(accessEvents)) { message += "\n\tWITNESS_BRANCH_COST " + AccessEvents.getBranchReadCost(); @@ -335,33 +343,32 @@ private static String costSchedulePrettyPrint(final short accessEvents) { return message; } - public short touchAddress( + private int touchAddress( final Address addr, final UInt256 treeIndex, final UInt256 leafIndex, final int accessMode) { - short accessEvents = AccessEvents.NONE; BranchAccessKey branchKey = new BranchAccessKey(addr, treeIndex); - accessEvents |= touchAddressForBranch(branchKey, accessMode); + int accessEvents = AccessEvents.NONE; + accessEvents = touchAddressForBranch(accessMode, branchKey, accessEvents); if (leafIndex != null) { - accessEvents |= touchAddressForLeaf(branchKey, leafIndex, accessMode); + accessEvents = touchAddressForLeaf(accessMode, branchKey, leafIndex, accessEvents); } return accessEvents; } - private short touchAddressForBranch(final BranchAccessKey branchKey, final int accessMode) { - short accessEvents = AccessEvents.NONE; - + private int touchAddressForBranch( + final int accessMode, final BranchAccessKey branchKey, final int accEvents) { + int accessEvents = accEvents; if (!this.branches.containsKey(branchKey)) { - accessEvents |= AccessEvents.BRANCH_READ; - this.branches.put(branchKey, AccessMode.READ); + accessEvents = AccessEvents.branchRead(accessEvents); + this.branches.put(branchKey, AccessEvents.BRANCH_READ); } // A write is always a read - if (AccessMode.isWrite(accessMode)) { - int previousAccessMode = - !this.branches.containsKey(branchKey) ? AccessMode.NONE : this.branches.get(branchKey); - if (!AccessMode.isWrite(previousAccessMode)) { - accessEvents |= AccessEvents.BRANCH_WRITE; + if (AccessEvents.isWrite(accessMode)) { + int previousAccessMode = this.branches.getOrDefault(branchKey, AccessEvents.NONE); + if (!AccessEvents.isWrite(previousAccessMode)) { + accessEvents = AccessEvents.branchWrite(accessEvents); this.branches.put(branchKey, (previousAccessMode | accessMode)); } } @@ -369,24 +376,26 @@ private short touchAddressForBranch(final BranchAccessKey branchKey, final int a return accessEvents; } - private short touchAddressForLeaf( - final BranchAccessKey branchKey, final UInt256 subIndex, final int accessMode) { + private int touchAddressForLeaf( + final int accessMode, + final BranchAccessKey branchKey, + final UInt256 subIndex, + final int accEvents) { LeafAccessKey leafKey = new LeafAccessKey(branchKey, subIndex); - short accessEvents = AccessEvents.NONE; + int accessEvents = accEvents; if (!this.leaves.containsKey(leafKey)) { - accessEvents |= AccessEvents.LEAF_READ; - this.leaves.put(leafKey, AccessMode.READ); + accessEvents = AccessEvents.leafRead(accessEvents); + this.leaves.put(leafKey, AccessEvents.LEAF_READ); } // A write is always a read - if (AccessMode.isWrite(accessMode)) { - int previousAccessMode = - !this.leaves.containsKey(leafKey) ? AccessMode.NONE : this.leaves.get(leafKey); - if (!AccessMode.isWrite(previousAccessMode)) { - accessEvents |= AccessEvents.LEAF_RESET; - if (AccessMode.isWriteSet(accessMode)) { - accessEvents |= AccessEvents.LEAF_SET; + if (AccessEvents.isWrite(accessMode)) { + int previousAccessMode = this.leaves.getOrDefault(leafKey, AccessEvents.NONE); + if (!AccessEvents.isWrite(previousAccessMode)) { + accessEvents = AccessEvents.leafReset(accessEvents); + if (AccessEvents.isLeafSet(accessMode)) { + accessEvents = AccessEvents.leafSet(accessEvents); } this.leaves.put(leafKey, (previousAccessMode | accessMode)); } @@ -412,7 +421,7 @@ public String toString() { return "AccessWitness{" + "leaves=" + leaves + ", branches=" + branches + '}'; } - public record BranchAccessKey(Address address, UInt256 treeIndex) {} + record BranchAccessKey(Address address, UInt256 treeIndex) {} - public record LeafAccessKey(BranchAccessKey branchAccessKey, UInt256 leafIndex) {} + record LeafAccessKey(BranchAccessKey branchAccessKey, UInt256 leafIndex) {} } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/NoopAccessWitness.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/NoopAccessWitness.java index c88bc7d40ad..01077e47fd7 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/NoopAccessWitness.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/stateless/NoopAccessWitness.java @@ -22,12 +22,18 @@ import org.apache.tuweni.units.bigints.UInt256; +/** An access witness that does nothing. */ public class NoopAccessWitness implements AccessWitness { private static NoopAccessWitness instance; private NoopAccessWitness() {} + /** + * Gets a singleton to an access witness that does nothing. + * + * @return the singleton + */ public static NoopAccessWitness get() { if (instance == null) { instance = new NoopAccessWitness(); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java index 36edbcc486b..6c5e415d4d8 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java @@ -58,11 +58,13 @@ public ExtCodeSizeOperation(final GasCalculator gasCalculator, final boolean ena /** * Cost of Ext code size operation. * + * @param frame The current frame + * @param address The address of the account's code * @param accountIsWarm the account is warm * @return the long */ protected long cost( - final boolean accountIsWarm, final MessageFrame frame, final Address address) { + final MessageFrame frame, final Address address, final boolean accountIsWarm) { return gasCalculator().extCodeSizeOperationGasCost(frame, accountIsWarm, address); } @@ -71,7 +73,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { final Address address = Words.toAddress(frame.popStackItem()); final boolean accountIsWarm = frame.warmUpAddress(address) || gasCalculator().isPrecompile(address); - final long cost = cost(accountIsWarm, frame, address); + final long cost = cost(frame, address, accountIsWarm); if (frame.getRemainingGas() < cost) { return new OperationResult(cost, ExceptionalHaltReason.INSUFFICIENT_GAS); } else { diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java index b55d07e432b..fc4f4199d37 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java @@ -38,6 +38,14 @@ public SLoadOperation(final GasCalculator gasCalculator) { super(0x54, "SLOAD", 1, 1, gasCalculator); } + /** + * Returns the cost for executing an {@link SLoadOperation}. + * + * @param frame The current frame + * @param key The slot key + * @param slotIsWarm The storage slot is warm + * @return the cost for executing SLOAD + */ protected long cost(final MessageFrame frame, final Bytes32 key, final boolean slotIsWarm) { return gasCalculator().sloadOperationGasCost(frame, UInt256.fromBytes(key), slotIsWarm); } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/storage/DataStorageFormat.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/storage/DataStorageFormat.java index 15d01bf5d0b..d73b07060bd 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/storage/DataStorageFormat.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/storage/DataStorageFormat.java @@ -20,5 +20,6 @@ public enum DataStorageFormat { FOREST, /** New format. Store one trie, and trie logs to roll forward and backward */ BONSAI, + /** Storage format for stateless clients */ VERKLE; } From d87540199a4f5bcb86d09b6ce524fdd9b06b5b45 Mon Sep 17 00:00:00 2001 From: Luis Pinto Date: Wed, 8 Jan 2025 18:14:50 +0000 Subject: [PATCH 2/2] Fix plugin-api checksum check Signed-off-by: Luis Pinto --- plugin-api/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 8ed11696c4c..0b6bf08c701 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -71,7 +71,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'iXB9eWeTq1e/uWXSb2dNTa7yL1BCunZ2doLC26y6VrA=' + knownHash = 'B8W17nUrnYudyncBvQEz8z8tXOCGXHm91eEF6gQh4jk=' } check.dependsOn('checkAPIChanges')