default <T> List<T> readList(final Function<RLPInput, T> valueReader) {
    final int size = enterList();
    final List<T> res = size == 0 ? List.of() : new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
      try {
        res.add(valueReader.apply(this));
      } catch (final RLPException e) {
        throw e;
      } catch (final Exception e) {
        throw new RLPException(
            String.format("Error applying element decoding function on element %d of the list", i),
            e);
      }
    }
    leaveList();
    return res;
  }
Reads a full list from the input given a method that knows how to read its elements.

@param valueReader A method that can decode a single list element.
@param <T> The type of the elements of the decoded list.
@return The next list of this input, where elements are decoded using {@code valueReader}.
@throws RLPException is the next item to read is not a list, of if any error happens when
    applying {@code valueReader} to read elements of the list.
ethereum/rlp/src/main/java/org/hyperledger/besu/ethereum/rlp/RLPInput.java