@Override
  public long modExpGasCost(final Bytes input) {
    final long baseLength = BigIntegerModularExponentiationPrecompiledContract.baseLength(input);
    final long exponentLength =
        BigIntegerModularExponentiationPrecompiledContract.exponentLength(input);
    final long modulusLength =
        BigIntegerModularExponentiationPrecompiledContract.modulusLength(input);
    final long exponentOffset =
        clampedAdd(BigIntegerModularExponentiationPrecompiledContract.BASE_OFFSET, baseLength);

    final long maxLength = Math.max(modulusLength, baseLength);
    if (maxLength <= 0) {
      return 500L;
    }
    long multiplicationComplexity = 16;
    long words = (maxLength + 7L) / 8L;
    words = Words.clampedMultiply(words, words);
    if (maxLength > 32) {
      multiplicationComplexity = words * 2;
    }

    long maxExponentLength = Long.MAX_VALUE / words * 3 / 8;
    if (exponentLength > maxExponentLength) {
      return Long.MAX_VALUE;
    }

    final long firstExponentBytesCap =
        Math.min(exponentLength, ByzantiumGasCalculator.MAX_FIRST_EXPONENT_BYTES);
    final BigInteger firstExpBytes =
        BigIntegerModularExponentiationPrecompiledContract.extractParameter(
            input, clampedToInt(exponentOffset), clampedToInt(firstExponentBytesCap));
    final long adjustedExponentLength = adjustedExponentLength(exponentLength, firstExpBytes);

    long gasRequirement =
        clampedMultiply(multiplicationComplexity, Math.max(adjustedExponentLength, 1L));
    if (gasRequirement != Long.MAX_VALUE) {
      gasRequirement /= 3;
    }

    return Math.max(gasRequirement, 500L);
  }
Instantiates a new Osaka Gas Calculator

@param maxPrecompile the max precompile
evm/src/main/java/org/hyperledger/besu/evm/gascalculator/OsakaGasCalculator.java