private static ValidationResult<TransactionInvalidReason> validateCodeDelegation(
      final Transaction transaction) {
    if (isDelegateCodeEmpty(transaction)) {
      return ValidationResult.invalid(
          TransactionInvalidReason.EMPTY_CODE_DELEGATION,
          "transaction code delegation transactions must have a non-empty code delegation list");
    }

    if (transaction.getTo().isEmpty()) {
      return ValidationResult.invalid(
          TransactionInvalidReason.INVALID_TRANSACTION_FORMAT,
          "transaction code delegation transactions must have a to address");
    }

    final Optional<ValidationResult<TransactionInvalidReason>> validationResult =
        transaction
            .getCodeDelegationList()
            .map(
                codeDelegations -> {
                  for (CodeDelegation codeDelegation : codeDelegations) {
                    if (codeDelegation.chainId().compareTo(TWO_POW_256) >= 0) {
                      throw new IllegalArgumentException(
                          "Invalid 'chainId' value, should be < 2^256 but got "
                              + codeDelegation.chainId());
                    }

                    if (codeDelegation.r().compareTo(TWO_POW_256) >= 0) {
                      throw new IllegalArgumentException(
                          "Invalid 'r' value, should be < 2^256 but got " + codeDelegation.r());
                    }

                    if (codeDelegation.s().compareTo(TWO_POW_256) >= 0) {
                      throw new IllegalArgumentException(
                          "Invalid 's' value, should be < 2^256 but got " + codeDelegation.s());
                    }
                  }

                  return ValidationResult.valid();
                });

    if (validationResult.isPresent() && !validationResult.get().isValid()) {
      return validationResult.get();
    }

    return ValidationResult.valid();
  }
Validates a transaction based on Frontier protocol runtime requirements.

<p>The {@link MainnetTransactionValidator} performs the intrinsic gas cost check on the given
{@link Transaction}.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java