@Override
  public OperationResult execute(final MessageFrame frame, final EVM evm) {
    final long memOffset = clampedToLong(frame.popStackItem());
    final long sourceOffset = clampedToLong(frame.popStackItem());
    final long numBytes = clampedToLong(frame.popStackItem());
    final Bytes returnData = frame.getReturnData();
    final int returnDataLength = returnData.size();

    if (frame.getCode().getEofVersion() < 1) {
      try {
        final long end = Math.addExact(sourceOffset, numBytes);
        if (end > returnDataLength) {
          return INVALID_RETURN_DATA_BUFFER_ACCESS;
        }
      } catch (final ArithmeticException ae) {
        return OUT_OF_BOUNDS;
      }
    }

    final long cost = gasCalculator().dataCopyOperationGasCost(frame, memOffset, numBytes);
    if (frame.getRemainingGas() < cost) {
      return new OperationResult(cost, ExceptionalHaltReason.INSUFFICIENT_GAS);
    }

    frame.writeMemory(memOffset, sourceOffset, numBytes, returnData, true);

    return new OperationResult(cost, null);
  }
Instantiates a new Return data copy operation.

@param gasCalculator the gas calculator
evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataCopyOperation.java