use of org.hyperledger.besu.evm.Gas in project besu by hyperledger.
the class BerlinGasCalculator method callOperationGasCost.
// Redefined costs from EIP-2929
@Override
public Gas callOperationGasCost(final MessageFrame frame, final Gas stipend, final long inputDataOffset, final long inputDataLength, final long outputDataOffset, final long outputDataLength, final Wei transferValue, final Account recipient, final Address to) {
final Gas baseCost = super.callOperationGasCost(frame, stipend, inputDataOffset, inputDataLength, outputDataOffset, outputDataLength, transferValue, recipient, to);
final boolean accountIsWarm = frame.warmUpAddress(to) || isPrecompile(to);
return baseCost.plus(accountIsWarm ? getWarmStorageReadCost() : getColdAccountAccessCost());
}
use of org.hyperledger.besu.evm.Gas in project besu by hyperledger.
the class SpuriousDragonGasCalculator method callOperationGasCost.
@Override
public Gas callOperationGasCost(final MessageFrame frame, final Gas stipend, final long inputDataOffset, final long inputDataLength, final long outputDataOffset, final long outputDataLength, final Wei transferValue, final Account recipient, final Address to) {
final Gas inputDataMemoryExpansionCost = memoryExpansionGasCost(frame, inputDataOffset, inputDataLength);
final Gas outputDataMemoryExpansionCost = memoryExpansionGasCost(frame, outputDataOffset, outputDataLength);
final Gas memoryExpansionCost = inputDataMemoryExpansionCost.max(outputDataMemoryExpansionCost);
Gas cost = callOperationBaseGasCost().plus(memoryExpansionCost);
if (!transferValue.isZero()) {
cost = cost.plus(callValueTransferGasCost());
}
if ((recipient == null || recipient.isEmpty()) && !transferValue.isZero()) {
cost = cost.plus(newAccountGasCost());
}
return cost;
}
use of org.hyperledger.besu.evm.Gas in project besu by hyperledger.
the class TangerineWhistleGasCalculator method gasAvailableForChildCall.
@Override
public Gas gasAvailableForChildCall(final MessageFrame frame, final Gas stipend, final boolean transfersValue) {
final Gas gasCap = gasCap(frame.getRemainingGas(), stipend);
// TODO: Integrate this into AbstractCallOperation since it's
// a little out of place to mutate the frame here.
frame.decrementRemainingGas(gasCap);
if (transfersValue) {
return gasCap.plus(getAdditionalCallStipend());
} else {
return gasCap;
}
}
use of org.hyperledger.besu.evm.Gas in project besu by hyperledger.
the class TangerineWhistleGasCalculator method callOperationGasCost.
@Override
public Gas callOperationGasCost(final MessageFrame frame, final Gas stipend, final long inputDataOffset, final long inputDataLength, final long outputDataOffset, final long outputDataLength, final Wei transferValue, final Account recipient, final Address to) {
final Gas inputDataMemoryExpansionCost = memoryExpansionGasCost(frame, inputDataOffset, inputDataLength);
final Gas outputDataMemoryExpansionCost = memoryExpansionGasCost(frame, outputDataOffset, outputDataLength);
final Gas memoryExpansionCost = inputDataMemoryExpansionCost.max(outputDataMemoryExpansionCost);
Gas cost = callOperationBaseGasCost().plus(memoryExpansionCost);
if (!transferValue.isZero()) {
cost = cost.plus(callValueTransferGasCost());
}
if (recipient == null) {
cost = cost.plus(newAccountGasCost());
}
return cost;
}
use of org.hyperledger.besu.evm.Gas in project besu by hyperledger.
the class ReturnOperation method execute.
@Override
public OperationResult execute(final MessageFrame frame, final EVM evm) {
final long from = clampedToLong(frame.popStackItem());
final long length = clampedToLong(frame.popStackItem());
final Gas cost = gasCalculator().memoryExpansionGasCost(frame, from, length);
final Optional<Gas> optionalCost = Optional.of(cost);
if (frame.getRemainingGas().compareTo(cost) < 0) {
return new OperationResult(optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
}
frame.setOutputData(frame.readMemory(from, length));
frame.setState(MessageFrame.State.CODE_SUCCESS);
return new OperationResult(optionalCost, Optional.empty());
}
Aggregations