class RevertOperation extends AbstractOperation {

  @Override
  public OperationResult execute(final MessageFrame frame, final EVM evm) {
    final UInt256 from = UInt256.fromBytes(frame.popStackItem());
    final UInt256 length = UInt256.fromBytes(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));
    }

    final Bytes reason = frame.readMemory(from, length);
    frame.setOutputData(reason);
    frame.setRevertReason(reason);
    frame.setState(MessageFrame.State.REVERT);
    return new OperationResult(optionalCost, Optional.empty());
  }

  public  RevertOperation(final GasCalculator gasCalculator);

}