Search in sources :

Example 11 with Gas

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());
}
Also used : Gas(org.hyperledger.besu.evm.Gas)

Example 12 with Gas

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;
}
Also used : Gas(org.hyperledger.besu.evm.Gas)

Example 13 with Gas

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;
    }
}
Also used : Gas(org.hyperledger.besu.evm.Gas)

Example 14 with Gas

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;
}
Also used : Gas(org.hyperledger.besu.evm.Gas)

Example 15 with Gas

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());
}
Also used : Gas(org.hyperledger.besu.evm.Gas)

Aggregations

Gas (org.hyperledger.besu.evm.Gas)29 Address (org.hyperledger.besu.datatypes.Address)6 Bytes (org.apache.tuweni.bytes.Bytes)5 Wei (org.hyperledger.besu.datatypes.Wei)4 MutableAccount (org.hyperledger.besu.evm.account.MutableAccount)4 UInt256 (org.apache.tuweni.units.bigints.UInt256)3 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)3 HederaWorldState (com.hedera.services.store.contracts.HederaWorldState)2 HederaWorldUpdater (com.hedera.services.store.contracts.HederaWorldUpdater)2 ImmutableList (com.google.common.collect.ImmutableList)1 InvalidTransactionException (com.hedera.services.exceptions.InvalidTransactionException)1 HederaStackedWorldStateUpdater (com.hedera.services.store.contracts.HederaStackedWorldStateUpdater)1 ArrayDeque (java.util.ArrayDeque)1 Map (java.util.Map)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 BadBlockManager (org.hyperledger.besu.ethereum.chain.BadBlockManager)1 MutableWorldState (org.hyperledger.besu.ethereum.core.MutableWorldState)1 MutableProtocolSchedule (org.hyperledger.besu.ethereum.mainnet.MutableProtocolSchedule)1 ProtocolSpec (org.hyperledger.besu.ethereum.mainnet.ProtocolSpec)1 PrivateTransactionValidator (org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator)1