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 a7b919ef53c..2ae64e2c556 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 @@ -55,6 +55,32 @@ public long proofOfAbsenceCost(final MessageFrame frame, final Address address) return frame.getAccessWitness().touchAndChargeProofOfAbsence(address); } + @Override + public long callCodeOperationGasCost( + final MessageFrame frame, + final long stipend, + final long inputDataOffset, + final long inputDataLength, + final long outputDataOffset, + final long outputDataLength, + final Wei transferValue, + final Account recipient, + final Address contract, + final boolean accountIsWarm) { + return callOperationGasCost( + frame, + stipend, + inputDataOffset, + inputDataLength, + outputDataOffset, + outputDataLength, + // CALLCODE transfers value to itself so hardcode it to zero + Wei.ZERO, + recipient, + contract, + accountIsWarm); + } + @Override public long callOperationGasCost( final MessageFrame frame, diff --git a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java index 0047b924a5a..b91a81e2cd5 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java @@ -258,6 +258,31 @@ public long callOperationGasCost( true); } + @Override + public long callCodeOperationGasCost( + final MessageFrame frame, + final long stipend, + final long inputDataOffset, + final long inputDataLength, + final long outputDataOffset, + final long outputDataLength, + final Wei transferValue, + final Account recipient, + final Address contract, + final boolean accountIsWarm) { + return callOperationGasCost( + frame, + stipend, + inputDataOffset, + inputDataLength, + outputDataOffset, + outputDataLength, + transferValue, + recipient, + contract, + accountIsWarm); + } + @Override public long callOperationGasCost( final MessageFrame frame, 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 93c527a4329..91306d978d8 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 @@ -199,6 +199,33 @@ default long callOperationGasCost( true); } + /** + * Returns the gas cost that the CALLCODE operation will consume. + * + * @param frame The current frame + * @param stipend The gas stipend being provided by the CALL caller + * @param inputDataOffset The offset in memory to retrieve the CALL input data + * @param inputDataLength The CALL input data length + * @param outputDataOffset The offset in memory to place the CALL output data + * @param outputDataLength The CALL output data length + * @param transferValue The wei being transferred + * @param recipient The CALL recipient (may be null if self destructed or new) + * @param contract The address of the recipient (never null) + * @param accountIsWarm The address of the contract is "warm" as per EIP-2929 + * @return The gas cost for the CALL operation + */ + long callCodeOperationGasCost( + final MessageFrame frame, + final long stipend, + final long inputDataOffset, + final long inputDataLength, + final long outputDataOffset, + final long outputDataLength, + final Wei transferValue, + final Account recipient, + final Address contract, + final boolean accountIsWarm); + /** * Returns the gas cost for one of the various CALL operations. * diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java index e9bfe77d123..bd845cff82c 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java @@ -86,15 +86,14 @@ public long cost(final MessageFrame frame, final boolean accountIsWarm) { final Address to = to(frame); GasCalculator gasCalculator = gasCalculator(); - return gasCalculator.callOperationGasCost( + return gasCalculator.callCodeOperationGasCost( frame, stipend, inputDataOffset, inputDataLength, outputDataOffset, outputDataLength, - // As far as CALLCODE is concerned, there isn't a value transfer - Wei.ZERO, + value(frame), recipient, to, accountIsWarm);