@Override
  public Optional<ExceptionalHaltReason> validate(
      final Bytes contractCode, final MessageFrame frame, final EVM evm) {
    Code code = evm.getCode(Hash.hash(contractCode), contractCode);
    if (!code.isValid()) {
      LOG.trace("EOF Validation Error: {}", ((CodeInvalid) code).getInvalidReason());
      return Optional.of(ExceptionalHaltReason.INVALID_CODE);
    }

    if (frame.getCode().getEofVersion() != code.getEofVersion()) {
      LOG.trace(
          "Cannot deploy older eof versions: initcode version - {} runtime code version - {}",
          frame.getCode().getEofVersion(),
          code.getEofVersion());
      return Optional.of(ExceptionalHaltReason.EOF_CREATE_VERSION_INCOMPATIBLE);
    }

    return Optional.empty();
  }
Runs eof validation rules as per the various EIPs covering it.

@param contractCode the contract code to validate
@param frame the message frame to use for context
@param evm The EVM against which the validation should be considered against
@return Either an empty optional on success, or an optional containing one of the invalid
    reasons.
evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/EOFValidationCodeRule.java