mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 23:08:15 -05:00
Merge branch 'main' into zkbesu
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package org.hyperledger.besu.evm.operation;
|
||||
|
||||
import static org.hyperledger.besu.evm.internal.Words.clampedToLong;
|
||||
import static org.hyperledger.besu.evm.operation.AbstractCallOperation.LEGACY_FAILURE_STACK_ITEM;
|
||||
|
||||
import org.hyperledger.besu.datatypes.Address;
|
||||
import org.hyperledger.besu.datatypes.Wei;
|
||||
@@ -158,12 +157,18 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
|
||||
*/
|
||||
protected abstract Code getInitCode(MessageFrame frame, EVM evm);
|
||||
|
||||
private void fail(final MessageFrame frame) {
|
||||
/**
|
||||
* Handles stack items when operation fails for validation reasons (noe enough ether, bad eof
|
||||
* code)
|
||||
*
|
||||
* @param frame the current execution frame
|
||||
*/
|
||||
protected void fail(final MessageFrame frame) {
|
||||
final long inputOffset = clampedToLong(frame.getStackItem(1));
|
||||
final long inputSize = clampedToLong(frame.getStackItem(2));
|
||||
frame.readMutableMemory(inputOffset, inputSize);
|
||||
frame.popStackItems(getStackItemsConsumed());
|
||||
frame.pushStackItem(LEGACY_FAILURE_STACK_ITEM);
|
||||
frame.pushStackItem(Bytes.EMPTY);
|
||||
}
|
||||
|
||||
private void spawnChildMessage(final MessageFrame parent, final Code code, final EVM evm) {
|
||||
@@ -227,12 +232,12 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
|
||||
} else {
|
||||
frame.getWorldUpdater().deleteAccount(childFrame.getRecipientAddress());
|
||||
frame.setReturnData(childFrame.getOutputData());
|
||||
frame.pushStackItem(LEGACY_FAILURE_STACK_ITEM);
|
||||
frame.pushStackItem(Bytes.EMPTY);
|
||||
onInvalid(frame, (CodeInvalid) outputCode);
|
||||
}
|
||||
} else {
|
||||
frame.setReturnData(childFrame.getOutputData());
|
||||
frame.pushStackItem(LEGACY_FAILURE_STACK_ITEM);
|
||||
frame.pushStackItem(Bytes.EMPTY);
|
||||
onFailure(frame, childFrame.getExceptionalHaltReason());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
package org.hyperledger.besu.evm.operation;
|
||||
|
||||
import static org.hyperledger.besu.evm.internal.Words.clampedAdd;
|
||||
import static org.hyperledger.besu.evm.worldstate.DelegatedCodeGasCostHelper.deductDelegatedCodeGasCost;
|
||||
|
||||
import org.hyperledger.besu.datatypes.Address;
|
||||
@@ -116,9 +117,11 @@ public abstract class AbstractExtCallOperation extends AbstractCallOperation {
|
||||
}
|
||||
if (toBytes.size() > Address.SIZE) {
|
||||
return new OperationResult(
|
||||
gasCalculator.memoryExpansionGasCost(frame, inputOffset, inputLength)
|
||||
+ (zeroValue ? 0 : gasCalculator.callValueTransferGasCost())
|
||||
+ gasCalculator.getColdAccountAccessCost(),
|
||||
clampedAdd(
|
||||
clampedAdd(
|
||||
gasCalculator.memoryExpansionGasCost(frame, inputOffset, inputLength),
|
||||
(zeroValue ? 0 : gasCalculator.callValueTransferGasCost())),
|
||||
gasCalculator.getColdAccountAccessCost()),
|
||||
ExceptionalHaltReason.ADDRESS_OUT_OF_RANGE);
|
||||
}
|
||||
Address to = Words.toAddress(toBytes);
|
||||
@@ -135,16 +138,21 @@ public abstract class AbstractExtCallOperation extends AbstractCallOperation {
|
||||
|
||||
boolean accountCreation = contract == null && !zeroValue;
|
||||
long cost =
|
||||
gasCalculator.memoryExpansionGasCost(frame, inputOffset, inputLength)
|
||||
+ (zeroValue ? 0 : gasCalculator.callValueTransferGasCost())
|
||||
+ (frame.warmUpAddress(to) || gasCalculator.isPrecompile(to)
|
||||
? gasCalculator.getWarmStorageReadCost()
|
||||
: gasCalculator.getColdAccountAccessCost())
|
||||
+ (accountCreation ? gasCalculator.newAccountGasCost() : 0);
|
||||
long currentGas = frame.getRemainingGas() - cost;
|
||||
if (currentGas < 0) {
|
||||
clampedAdd(
|
||||
clampedAdd(
|
||||
clampedAdd(
|
||||
gasCalculator.memoryExpansionGasCost(frame, inputOffset, inputLength),
|
||||
(zeroValue ? 0 : gasCalculator.callValueTransferGasCost())),
|
||||
(frame.warmUpAddress(to) || gasCalculator.isPrecompile(to)
|
||||
? gasCalculator.getWarmStorageReadCost()
|
||||
: gasCalculator.getColdAccountAccessCost())),
|
||||
(accountCreation ? gasCalculator.newAccountGasCost() : 0));
|
||||
long currentGas = frame.getRemainingGas();
|
||||
if (currentGas < cost) {
|
||||
return new OperationResult(cost, ExceptionalHaltReason.INSUFFICIENT_GAS);
|
||||
}
|
||||
currentGas -= cost;
|
||||
frame.expandMemory(inputOffset, inputLength);
|
||||
|
||||
final Code code =
|
||||
contract == null
|
||||
@@ -202,7 +210,7 @@ public abstract class AbstractExtCallOperation extends AbstractCallOperation {
|
||||
.build();
|
||||
|
||||
frame.setState(MessageFrame.State.CODE_SUSPENDED);
|
||||
return new OperationResult(cost + childGas, null, 0);
|
||||
return new OperationResult(clampedAdd(cost, childGas), null, 0);
|
||||
}
|
||||
|
||||
private @Nonnull OperationResult softFailure(final MessageFrame frame, final long cost) {
|
||||
|
||||
@@ -16,7 +16,6 @@ package org.hyperledger.besu.evm.operation;
|
||||
|
||||
import static org.hyperledger.besu.crypto.Hash.keccak256;
|
||||
import static org.hyperledger.besu.evm.internal.Words.clampedAdd;
|
||||
import static org.hyperledger.besu.evm.internal.Words.clampedToInt;
|
||||
import static org.hyperledger.besu.evm.internal.Words.clampedToLong;
|
||||
|
||||
import org.hyperledger.besu.datatypes.Address;
|
||||
@@ -49,8 +48,8 @@ public class EOFCreateOperation extends AbstractCreateOperation {
|
||||
|
||||
@Override
|
||||
public long cost(final MessageFrame frame, final Supplier<Code> codeSupplier) {
|
||||
final int inputOffset = clampedToInt(frame.getStackItem(2));
|
||||
final int inputSize = clampedToInt(frame.getStackItem(3));
|
||||
final long inputOffset = clampedToLong(frame.getStackItem(2));
|
||||
final long inputSize = clampedToLong(frame.getStackItem(3));
|
||||
return clampedAdd(
|
||||
gasCalculator().memoryExpansionGasCost(frame, inputOffset, inputSize),
|
||||
clampedAdd(
|
||||
@@ -86,4 +85,13 @@ public class EOFCreateOperation extends AbstractCreateOperation {
|
||||
protected int getPcIncrement() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fail(final MessageFrame frame) {
|
||||
final long inputOffset = clampedToLong(frame.getStackItem(2));
|
||||
final long inputSize = clampedToLong(frame.getStackItem(3));
|
||||
frame.readMutableMemory(inputOffset, inputSize);
|
||||
frame.popStackItems(getStackItemsConsumed());
|
||||
frame.pushStackItem(Bytes.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user