private void memoizeHashAndSize() {
    final Bytes bytes = TransactionEncoder.encodeOpaqueBytes(this, EncodingContext.BLOCK_BODY);
    hash = Hash.hash(bytes);
    if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) {
      final Bytes pooledBytes =
          TransactionEncoder.encodeOpaqueBytes(this, EncodingContext.POOLED_TRANSACTION);
      size = pooledBytes.size();
      return;
    }
    size = bytes.size();
  }
Returns the size in bytes of the encoded transaction.

@return the size in bytes of the encoded transaction.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java