rfc/spec/57/index.html

826 lines
44 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="generator" content="Hugo 0.106.0">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Abstract # This document describes how to scale 56/STATUS-COMMUNITIES as well as 55/STATUS-1TO1-CHAT using existing Waku v2 protocols and components. It also adds a few new aspects, where more sophisticated components are not yet researched and evaluated.
Note: (Parts of) this RFC will be deprecated in the future as we continue research to scale specific components in a way that aligns better with our principles of decentralization and protecting anonymity.">
<meta name="theme-color" content="#FFFFFF"><meta property="og:title" content="57/STATUS-Simple-Scaling" />
<meta property="og:description" content="Abstract # This document describes how to scale 56/STATUS-COMMUNITIES as well as 55/STATUS-1TO1-CHAT using existing Waku v2 protocols and components. It also adds a few new aspects, where more sophisticated components are not yet researched and evaluated.
Note: (Parts of) this RFC will be deprecated in the future as we continue research to scale specific components in a way that aligns better with our principles of decentralization and protecting anonymity." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://rfc.vac.dev/spec/57/" /><meta property="article:section" content="docs" />
<title>57/STATUS-Simple-Scaling | Vac RFC</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="/book.min.e935e20bd0d469378cb482f0958edf258c731a4f895dccd55799c6fbc8043f23.css" integrity="sha256-6TXiC9DUaTeMtILwlY7fJYxzGk&#43;JXczVV5nG&#43;8gEPyM=">
<script defer src="/en.search.min.6c850667c4402a32dafd5e17531337dad3c49720ac8c3a8c62f49e96c5b524bd.js" integrity="sha256-bIUGZ8RAKjLa/V4XUxM32tPElyCsjDqMYvSelsW1JL0="></script>
<!--
Made with Book Theme
https://github.com/alex-shpak/hugo-book
-->
</head>
<body dir="ltr">
<input type="checkbox" class="hidden toggle" id="menu-control" />
<input type="checkbox" class="hidden toggle" id="toc-control" />
<main class="container flex">
<aside class="book-menu">
<div class="book-menu-content">
<nav>
<h2 class="book-brand">
<a href="/"><span>Vac RFC</span>
</a>
</h2>
<div class="book-search">
<input type="text" id="book-search-input" placeholder="Search" aria-label="Search" maxlength="64" data-hotkeys="s/" />
<div class="book-search-spinner hidden"></div>
<ul id="book-search-results"></ul>
</div>
<ul>
<li>Raw
<ul>
<li><a href="/spec/20/">20/TOY-ETH-PM</a></li>
<li><a href="/spec/24/">24/STATUS-CURATION</a></li>
<li><a href="/spec/28/">28/STATUS-FEATURING</a></li>
<li><a href="/spec/31/">31/WAKU2-ENR</a></li>
<li><a href="/spec/32/">32/RLN-V1</a></li>
<li><a href="/spec/34/">34/WAKU2-PEER-EXCHANGE</a></li>
<li><a href="/spec/35/">35/WAKU2-NOISE</a></li>
<li><a href="/spec/37/">37/WAKU2-NOISE-SESSIONS</a></li>
<li><a href="/spec/38/">38/CONSENSUS-CLARO</a></li>
<li><a href="/spec/43/">43/WAKU2-NOISE-PAIRING</a></li>
<li><a href="/spec/44/">44/WAKU2-DANDELION</a></li>
<li><a href="/spec/45/">45/WAKU2-ADVERSARIAL-MODELS</a></li>
<li><a href="/spec/46/">46/GOSSIPSUB-TOR-PUSH</a></li>
<li><a href="/spec/47/">47/WAKU2-TOR-PUSH</a></li>
<li><a href="/spec/48/">48/RLN-INTEREP-SPEC</a></li>
<li><a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a></li>
<li><a href="/spec/52/">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a></li>
<li><a href="/spec/57/"class=active>57/STATUS-Simple-Scaling</a></li>
<li><a href="/spec/58/">58/RLN-V2</a></li>
</ul>
</li>
<li>Draft
<ul>
<li><a href="/spec/1/">1/COSS</a></li>
<li><a href="/spec/3/">3/REMOTE-LOG</a></li>
<li><a href="/spec/4/">4/MVDS-META</a></li>
<li><a href="/spec/10/">10/WAKU2</a></li>
<li><a href="/spec/12/">12/WAKU2-FILTER</a></li>
<li><a href="/spec/13/">13/WAKU2-STORE</a></li>
<li><a href="/spec/14/">14/WAKU2-MESSAGE</a></li>
<li><a href="/spec/15/">15/WAKU2-BRIDGE</a></li>
<li><a href="/spec/16/">16/WAKU2-RPC</a></li>
<li><a href="/spec/17/">17/WAKU2-RLN-RELAY</a></li>
<li><a href="/spec/18/">18/WAKU2-SWAP</a></li>
<li><a href="/spec/19/">19/WAKU2-LIGHTPUSH</a></li>
<li><a href="/spec/21/">21/WAKU2-FTSTORE</a></li>
<li><a href="/spec/22/">22/TOY-CHAT</a></li>
<li><a href="/spec/23/">23/WAKU2-TOPICS</a></li>
<li><a href="/spec/26/">26/WAKU2-PAYLOAD</a></li>
<li><a href="/spec/27/">27/WAKU2-PEERS</a></li>
<li><a href="/spec/29/">29/WAKU2-CONFIG</a></li>
<li><a href="/spec/30/">30/ADAPTIVE-NODES</a></li>
<li><a href="/spec/33/">33/WAKU2-DISCV5</a></li>
<li><a href="/spec/36/">36/WAKU2-BINDINGS-API</a></li>
<li><a href="/spec/53/">53/WAKU2-X3DH</a></li>
<li><a href="/spec/54/">54/WAKU2-X3DH-SESSIONS</a></li>
<li><a href="/spec/55/">55/STATUS-1TO1-CHAT</a></li>
<li><a href="/spec/56/">56/STATUS-COMMUNITIES</a></li>
</ul>
</li>
<li>Stable
<ul>
<li><a href="/spec/2/">2/MVDS</a></li>
<li><a href="/spec/6/">6/WAKU1</a></li>
<li><a href="/spec/7/">7/WAKU-DATA</a></li>
<li><a href="/spec/8/">8/WAKU-MAIL</a></li>
<li><a href="/spec/9/">9/WAKU-RPC</a></li>
<li><a href="/spec/11/">11/WAKU2-RELAY</a></li>
</ul>
</li>
<li>Deprecated
<ul>
<li><a href="/spec/5/">5/WAKU0</a></li>
</ul>
</li>
<li>Retired</li>
</ul>
</nav>
<script>(function(){var e=document.querySelector("aside.book-menu nav");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script>
</div>
</aside>
<div class="book-page">
<header class="book-header">
<div class="flex align-center justify-between">
<label for="menu-control">
<img src="/svg/menu.svg" class="book-icon" alt="Menu" />
</label>
<strong>57/STATUS-Simple-Scaling</strong>
<label for="toc-control">
<img src="/svg/toc.svg" class="book-icon" alt="Table of Contents" />
</label>
</div>
<aside class="hidden clearfix">
<nav id="TableOfContents">
<ul>
<li><a href="#shard-allocation">Shard Allocation</a>
<ul>
<li><a href="#implementation-suggestion">Implementation Suggestion</a></li>
</ul>
</li>
<li><a href="#status-communities">Status Communities</a>
<ul>
<li><a href="#static-mapping">Static Mapping</a></li>
<li><a href="#owner-mapping">Owner Mapping</a></li>
</ul>
</li>
<li><a href="#11-chat">1:1 Chat</a></li>
</ul>
<ul>
<li><a href="#statically-mapped-communities">Statically-Mapped Communities</a></li>
<li><a href="#owner-mapped-communities">Owner-Mapped Communities</a></li>
<li><a href="#11-chat-1">1:1 chat</a></li>
</ul>
<ul>
<li><a href="#control-message-shards">Control Message Shards</a></li>
<li><a href="#media-shards">Media Shards</a></li>
<li><a href="#infrastructure-focused-community">Infrastructure-focused Community</a></li>
</ul>
<ul>
<li><a href="#libp2p-rendezvous-and-circuit-relay">Libp2p Rendezvous and Circuit-Relay</a>
<ul>
<li><a href="#announcing-shard-participation">Announcing Shard Participation</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="#design-requirements-publisher">Design requirements (publisher)</a></li>
<li><a href="#required-changes">Required changes</a></li>
<li><a href="#test-vectors">Test vectors</a></li>
<li><a href="#owner-mapped-communities-1">Owner-Mapped Communities</a></li>
<li><a href="#11-chat-2">1:1 Chat</a></li>
</ul>
</nav>
</aside>
</header>
<article class="markdown">
<h1 id="57status-simple-scaling">
57/STATUS-Simple-Scaling
<a class="anchor" href="#57status-simple-scaling">#</a>
</h1>
<h1 id="status-simple-scaling">
Status Simple Scaling
<a class="anchor" href="#status-simple-scaling">#</a>
</h1>
<img src="https://img.shields.io/badge/status-raw-lightgrey?style=flat-square" />
<ul>
<li>Status: raw</li>
<li>Editor: Daniel Kaiser <a href="mailto:danielkaiser@status.im">danielkaiser@status.im</a></li>
<li>Contributors:
Alvaro Revuelta <a href="mailto:alrevuelta@status.im">alrevuelta@status.im</a>
</li>
</ul><h1 id="abstract">
Abstract
<a class="anchor" href="#abstract">#</a>
</h1>
<p>This document describes how to scale <a href="/spec/56/">56/STATUS-COMMUNITIES</a> as well as <a href="/spec/55/">55/STATUS-1TO1-CHAT</a>
using existing Waku v2 protocols and components.
It also adds a few new aspects, where more sophisticated components are not yet researched and evaluated.</p>
<blockquote>
<p><em>Note:</em> (Parts of) this RFC will be deprecated in the future as we continue research to scale specific components
in a way that aligns better with our principles of decentralization and protecting anonymity.
This document informs about scaling at the current stage of research and shows it is practically possible.
Practical feasibility is also a core goal for us.
We believe in incremental improvement, i.e. having a working decentralized scaling solution with trade-offs is better than a fully centralized solution.</p>
</blockquote>
<h1 id="background-and-motivation">
Background and Motivation
<a class="anchor" href="#background-and-motivation">#</a>
</h1>
<p><a href="/spec/56/">56/STATUS-COMMUNITIES</a> as well as <a href="/spec/55/">55/STATUS-1TO1-CHAT</a> use Waku v2 protocols.
Both use Waku content topics (see <a href="/spec/23/">23/WAKU2-TOPICS</a>) for content based filtering.</p>
<p>Waku v2 currently has scaling limitations in two dimensions:</p>
<ol>
<li>
<p>Messages that are part of a specific content topic have to be disseminated in a single mesh network (i.e. pubsub topic).
This limits scaling the number of messages disseminated in a specific content topic,
and by extension, the number of active nodes that are part of this content topic.</p>
</li>
<li>
<p>Scaling a large set of content topics requires distributing these over several mesh networks (which this document refers to as pubsub topic shards).</p>
</li>
</ol>
<p>This document focuses on the second scaling dimension.
With the scaling solutions discussed in this document,
each content topics can have a large set of active users, but still has to fit in a single pubsub mesh.</p>
<blockquote>
<p><em>Note:</em> While it is possible to use the same content topic name on several shards,
each node that is interested in this content topic has to be subscribed to all respective shards, which does not scale.
Splitting content topics in a more sophisticated and efficient way will be part of a future document.</p>
</blockquote>
<h1 id="relay-shards">
Relay Shards
<a class="anchor" href="#relay-shards">#</a>
</h1>
<p>Sharding the <a href="/spec/11/">Waku Relay</a> network is an integral part of scaling the Status app.</p>
<p><a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a> specifies shards clusters, which are sets of <code>1024</code> shards (separate pubsub mesh networks).
Content topics specified by application protocols can be distributed over these shards.
The Status app protocols are assigned to shard cluster <code>16</code>,
as defined in <a href="/spec/52/">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a>.</p>
<p><a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a> specifies three sharding methods.
This document uses <em>static sharding</em>, which leaves the distribution of content topics to application protocols,
but takes care of shard discovery.</p>
<p>The 1024 shards within the main Status shard cluster are allocated as follows.</p>
<h2 id="shard-allocation">
Shard Allocation
<a class="anchor" href="#shard-allocation">#</a>
</h2>
<table>
<thead>
<tr>
<th>shard index</th>
<th>usage</th>
</tr>
</thead>
<tbody>
<tr>
<td>0 - 15</td>
<td>reserved</td>
</tr>
<tr>
<td>16 - 127</td>
<td>specific (large) communities</td>
</tr>
<tr>
<td>128 - 767</td>
<td>communities</td>
</tr>
<tr>
<td>768 - 895</td>
<td>1:1 chat</td>
</tr>
<tr>
<td>896 - 1023</td>
<td>media and control msgs</td>
</tr>
</tbody>
</table>
<p>Shard indices are mapped to pubsub topic names as follows (specified in <a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a>).</p>
<p><code>/waku/2/rs/&lt;shard_cluster_index&gt;/&lt;shard_number&gt;</code></p>
<p>an example for the shard with index <code>18</code> in the Status shard cluster:</p>
<p><code>/waku/2/rs/16/18</code></p>
<p>In other words, the mesh network with the pubsub topic name <code>/waku/2/rs/16/18</code> carries messages associated with shard <code>18</code> in the Status shard cluster.</p>
<h3 id="implementation-suggestion">
Implementation Suggestion
<a class="anchor" href="#implementation-suggestion">#</a>
</h3>
<p>The Waku implementation should offer an interface that allows Status nodes to subscribe to Status specific content topics like</p>
<pre tabindex="0"><code>subscribe(&#34;/status/xyz&#34;, 16, 18)
</code></pre><p>The shard cluster index <code>16</code> can be kept in the Status app configuration,
so that Status nodes can simply use</p>
<pre tabindex="0"><code>subscribe(&#34;/status/xyz&#34;, 18)
</code></pre><p>which means: connect to the <code>&quot;status/xyz&quot;</code> content topic on shard <code>18</code> within the Status shard cluster.</p>
<h2 id="status-communities">
Status Communities
<a class="anchor" href="#status-communities">#</a>
</h2>
<p>In order to associate a community with a shard,
the community description protobuf is extended by the field
<code>uint16 relay_shard_index = 15</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-protobuf" data-lang="protobuf"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>syntax <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;proto3&#34;</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">message</span> <span style="color:#a6e22e">CommunityDescription</span> {<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The Lamport timestamp of the message
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">uint64</span> clock <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// A mapping of members in the community to their roles
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> map&lt;<span style="color:#66d9ef">string</span>,CommunityMember&gt; members <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The permissions of the Community
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> CommunityPermissions permissions <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The metadata of the Community
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> ChatIdentity identity <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// A mapping of chats to their details
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> map&lt;<span style="color:#66d9ef">string</span>,CommunityChat&gt; chats <span style="color:#f92672">=</span> <span style="color:#ae81ff">6</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// A list of banned members
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">repeated</span> <span style="color:#66d9ef">string</span> ban_list <span style="color:#f92672">=</span> <span style="color:#ae81ff">7</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// A mapping of categories to their details
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> map&lt;<span style="color:#66d9ef">string</span>,CommunityCategory&gt; categories <span style="color:#f92672">=</span> <span style="color:#ae81ff">8</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The admin settings of the Community
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> CommunityAdminSettings admin_settings <span style="color:#f92672">=</span> <span style="color:#ae81ff">10</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// If the community is encrypted
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">bool</span> encrypted <span style="color:#f92672">=</span> <span style="color:#ae81ff">13</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The list of tags
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">repeated</span> <span style="color:#66d9ef">string</span> tags <span style="color:#f92672">=</span> <span style="color:#ae81ff">14</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// index of the community&#39;s shard within the Status shard cluster
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> uint16 relay_shard_index <span style="color:#f92672">=</span> <span style="color:#ae81ff">15</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>}<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><blockquote>
<p><em>Note</em>: Currently, Status app has allocated shared cluster <code>16</code> in <a href="/spec/52/">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a>.
Status app could allocate more shard clusters, for instance to establish a test net.
We could add the shard cluster index to the community description as well.
The recommendation for now is to keep it as a configuration option of the Status app.</p>
</blockquote>
<blockquote>
<p><em>Note</em>: Once this RFC moves forward, the new community description protobuf fields should be mentioned in <a href="https://rfc.vac.dev/spec/56/">56/STATUS-COMMUNITIES</a>.</p>
</blockquote>
<p>Status communities can be mapped to shards in two ways: static, and owner-based.</p>
<h3 id="static-mapping">
Static Mapping
<a class="anchor" href="#static-mapping">#</a>
</h3>
<p>With static mapping, communities are assigned a specific shard index within the Status shard cluster.
This mapping is similar in nature to the shard cluster allocation in <a href="/spec/52/">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a>.
Shard indices allocated in that way are in the range <code>16 - 127</code>.
The Status CC community uses index <code>16</code> (not to confuse with shard cluster index <code>16</code>, which is the Status shard cluster).</p>
<h3 id="owner-mapping">
Owner Mapping
<a class="anchor" href="#owner-mapping">#</a>
</h3>
<blockquote>
<p><em>Note</em>: This way of mapping will be specified post-MVP.</p>
</blockquote>
<p>Community owners can choose to map their communities to any shard within the index range <code>128 - 767</code>.</p>
<h2 id="11-chat">
1:1 Chat
<a class="anchor" href="#11-chat">#</a>
</h2>
<p><a href="/spec/55">55/STATUS-1TO1-CHAT</a> uses partitioned topics to map 1:1 chats to a set of 5000 content topics.
This document extends this mapping to 8192 content topics that are, in turn, mapped to 128 shards in the index range of <code>768 - 895</code>.</p>
<pre tabindex="0"><code>contentPartitionsNum = 8192
contentPartition = mod(publicKey, contentPartitionsNum)
partitionContentTopic = &#34;contact-discovery-&#34; + contentPartition
partitionContentTopic = keccak256(partitionContentTopic)
shardNum = 128
shardIndex = 768 + mod(publicKey, shardNum)
</code></pre><h1 id="infrastructure-nodes">
Infrastructure Nodes
<a class="anchor" href="#infrastructure-nodes">#</a>
</h1>
<p>As described in <a href="/spec/30/">30/ADAPTIVE-NODES</a>,
Waku supports a continuum of node types with respect to available resources.
Infrastructure nodes are powerful nodes that have a high bandwidth connection and a high up-time.</p>
<p>This document, which informs about simple ways of scaling Status over Waku,
assumes the presence of a set of such infrastructure nodes in each shard.
Infrastructure nodes are especially important for providing connectivity in the roll-out phase.</p>
<p>Infrastructure nodes are not limited to Status fleets, or nodes run by community owners.
Anybody can run infrastructure nodes.</p>
<h2 id="statically-mapped-communities">
Statically-Mapped Communities
<a class="anchor" href="#statically-mapped-communities">#</a>
</h2>
<p>Infrastructure nodes are provided by the community owner, or by members of the respective community.</p>
<h2 id="owner-mapped-communities">
Owner-Mapped Communities
<a class="anchor" href="#owner-mapped-communities">#</a>
</h2>
<p>Infrastructure nodes are part of a subset of the shards in the range <code>128 - 767</code>.
Recommendations on choosing this subset will be added in a future version of this document.</p>
<p>Status fleet nodes make up a part of these infrastructure nodes.</p>
<h2 id="11-chat-1">
1:1 chat
<a class="anchor" href="#11-chat-1">#</a>
</h2>
<p>Infrastructure nodes are part of a subset of the shards in the range <code>768 - 985</code> (similar to owner-mapped communities).
Recommendations on choosing this subset will be added in a future version of this document.</p>
<p>Desktop clients can choose to only use filter and lightpush.</p>
<blockquote>
<p><em>Note</em>: Discussion: I&rsquo;d suggest to set this as the default for the MVP.
The load on infrastructure nodes would not be higher, because they have to receive and relay each message anyways.
This comes as a trade-off to anonymity and decentralization,
but can significantly improve scaling.
We still have k-anonymity because several chat pairs are mapped into one content topic.
We could improve on this in the future, and research the applicability of PIR (private information retrieval) techniques in the future.</p>
</blockquote>
<h1 id="infrastructure-shards">
Infrastructure Shards
<a class="anchor" href="#infrastructure-shards">#</a>
</h1>
<p>Waku messages are typically relayed in larger mesh networks comprised of nodes with varying resource profiles (see <a href="/spec/30/">30/ADAPTIVE-NODES</a>).
To maximise scaling, relaying of specific message types can be dedicated to shards where only infrastructure nodes with very strong resource profiles relay messages.
This comes as a trade-off to decentralization.</p>
<h2 id="control-message-shards">
Control Message Shards
<a class="anchor" href="#control-message-shards">#</a>
</h2>
<p>To get the maximum scaling for select large communities for the Status scaling MVP,
specific control messages that cause significant load (at a high user number) SHOULD be moved to a separate control message shard.
These control messages comprise:</p>
<ul>
<li>community description</li>
<li>membership update</li>
<li>backup</li>
<li>community request to join response</li>
<li>sync profile picture</li>
</ul>
<p>The relay functionality of control messages shards SHOULD be provided by infrastructure nodes.
Desktop clients should use light protocols as the default for control message shards.
Strong Desktop clients MAY opt in to support the relay network.</p>
<p>Each large community (in the index range of <code>16 - 127</code>) can get its dedicated control message shard (in the index range <code>896 - 1023</code>) if deemed necessary.
The Status CC community uses shard <code>896</code> as its control message shard.
This comes with trade-offs to decentralization and anonymity (see <em>Security Considerations</em> section).</p>
<h2 id="media-shards">
Media Shards
<a class="anchor" href="#media-shards">#</a>
</h2>
<p>Similar to control messages, media-heavy communities should use separate media shards (in the index range <code>896 - 1023</code>) for disseminating messages with large media data.
The Status CC community uses shard <code>897</code> as its media shard.</p>
<h2 id="infrastructure-focused-community">
Infrastructure-focused Community
<a class="anchor" href="#infrastructure-focused-community">#</a>
</h2>
<p>Large communities MAY choose to mainly rely on infrastructure nodes for <em>all</em> message transfers (not limited to control, and media messages).
Desktop clients of such communities should use light protocols as the default.
Strong Desktop clients MAY opt in to support the relay network.</p>
<blockquote>
<p><em>Note</em>: This is not planned for the MVP.</p>
</blockquote>
<h1 id="light-protocols">
Light Protocols
<a class="anchor" href="#light-protocols">#</a>
</h1>
<p>Light protocols may be used to save bandwidth,
at the (global) cost of not contributing to the network.
Using light protocols is RECOMMENDED for resource restricted nodes,
e.g. browsers,
and devices that (temporarily) have a low bandwidth connection or a connection with usage-based billing.</p>
<p>Light protocols comprise</p>
<ul>
<li><a href="/spec/19/">19/WAKU2-LIGHTPUSH</a> for sending messages</li>
<li><a href="/spec/12/">12/WAKU2-FILTER</a> for requesting messages with specific attributes</li>
<li><a href="/spec/34">34/WAKU2-PEER-EXCHANGE</a> for discovering peers</li>
</ul>
<h1 id="waku-archive">
Waku Archive
<a class="anchor" href="#waku-archive">#</a>
</h1>
<p>Archive nodes are Waku nodes that offer the Waku archive service via the Waku store protocol (<a href="/spec/13/">13/WAKU2-STORE</a>).
They are part of a set of shards and store all messages disseminated in these shards.
Nodes can request history messages via the <a href="/spec/13/">13/WAKU2-STORE</a>.</p>
<p>The store service is not limited to a Status fleet.
Anybody can run a Waku Archive node in the Status shards.</p>
<blockquote>
<p><em>Note</em>: There is no specification for discovering archive nodes associated with specific shards yet.
Nodes expect archive nodes to store all messages, regardless of shard association.</p>
</blockquote>
<p>The recommendation for the allocation of archive nodes to shards is similar to the
allocation of infrastructure nodes to shards described above.
In fact, the archive service can be offered by infrastructure nodes.</p>
<h1 id="discovery">
Discovery
<a class="anchor" href="#discovery">#</a>
</h1>
<p>Shard discovery is covered by <a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a>.
This allows the Status app to abstract from the discovery process and simply address shards by their index.</p>
<h2 id="libp2p-rendezvous-and-circuit-relay">
Libp2p Rendezvous and Circuit-Relay
<a class="anchor" href="#libp2p-rendezvous-and-circuit-relay">#</a>
</h2>
<p>To make nodes behind restrictive NATs discoverable,
this document suggests using <a href="https://github.com/libp2p/specs/blob/master/rendezvous/README.md">libp2p rendezvous</a>.
Nodes can check whether they are behind a restrictive NAT using the <a href="https://github.com/libp2p/specs/blob/master/autonat/README.md">libp2p AutoNAT protocol</a>.</p>
<blockquote>
<p><em>Note:</em> The following will move into <a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a>, or <a href="/spec/33/">33/WAKU2-DISCV5</a>:
Nodes behind restrictive NATs SHOULD not announce their publicly unreachable address via <a href="/spec/33/">33/WAKU2-DISCV5</a> discovery.</p>
</blockquote>
<p>It is RECOMMENDED that nodes that are part of the relay network also act as rendezvous points.
This includes accepting register queries from peers, as well as answering rendezvous discover queries.
Nodes MAY opt-out of the rendezvous functionality.</p>
<p>To allow nodes to initiate connections to peers behind restrictive NATs (after discovery via rendezvous),
it is RECOMMENDED that nodes that are part of the Waku relay network also offer
<a href="https://github.com/libp2p/specs/blob/6634ca7abb2f955645243d48d1cd2fd02a8e8880/relay/circuit-v2.md">libp2p circuit relay</a> functionality.</p>
<p>To minimize the load on circuit-relay nodes, nodes SHOULD</p>
<ol>
<li>make use of the <a href="https://github.com/libp2p/specs/blob/6634ca7abb2f955645243d48d1cd2fd02a8e8880/relay/circuit-v2.md#reservation">limiting</a>
functionality offered by the libp2p circuit relay protocols, and</li>
<li>use <a href="https://github.com/libp2p/specs/blob/master/relay/DCUtR.md">DCUtR</a> to upgrade to a direct connection.</li>
</ol>
<p>Nodes that do not announce themselves at all and only plan to use light protocols,
MAY use rendezvous discovery instead of or along-side <a href="/specs/34">34/WAKU2-PEER-EXCHANGE</a>.
For these nodes, rendezvous and <a href="/specs/34">34/WAKU2-PEER-EXCHANGE</a> offer the same functionality,
but return node sets sampled in different ways.
Using both can help increasing connectivity.</p>
<p>Nodes that are not behind restrictive NATs MAY register at rendezvous points, too;
this helps increasing discoverability, and by extension connectivity.
Such nodes SHOULD, however, not register at circuit relays.</p>
<h3 id="announcing-shard-participation">
Announcing Shard Participation
<a class="anchor" href="#announcing-shard-participation">#</a>
</h3>
<p>Registering a namespace via <a href="https://github.com/libp2p/specs/blob/master/rendezvous/README.md#interaction">lib-p2p rendezvous</a>
is done via a register query:</p>
<pre tabindex="0"><code>REGISTER{my-app, {QmA, AddrA}}
</code></pre><p>The app name, <code>my-app</code> is used to encode a single shard in the form:</p>
<pre tabindex="0"><code>&lt;rs (utf8 encoded)&gt; | &lt;2-byte shard cluster index&gt; | &lt;2-byte shard index&gt;
</code></pre><p>Registering shard 2 in the Status shard cluster (with shard cluster index 16, see <a href="/spec/52/h">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a>),
the register query would look like</p>
<pre tabindex="0"><code>REGISTER{0x727300100002, {QmA, AddrA}}
</code></pre><p>Participation in further shards is registered with further queries; one register query per shard.
(0x7273 is the encoding of <code>rs</code>.)</p>
<p>A discovery query for nodes that are part of this shard would look like</p>
<pre tabindex="0"><code>DISCOVER{ns: 0x727300100002}
</code></pre><h1 id="dos-protection">
DoS Protection
<a class="anchor" href="#dos-protection">#</a>
</h1>
<p>Hereunder we describe the &ldquo;opt-in message signing for DoS prevention&rdquo; solution, designed <em>ad hoc</em> for Status MVP.</p>
<p>Since publishing messages to pubsub topics has no limits, anyone can publish messages at a very high rate and DoS the network.
This would elevate the bandwidth consumption of all nodes subscribed to said pubsub topic, making it prohibitive (in terms of bandwidth) to be subscribed to it.
In order to scale, we need some mechanism to prevent this from happening, otherwise all scaling efforts will be in vain.
Since RLN is not ready yet, hereunder we describe a simpler approach designed <em>ad hoc</em> for Status use case, feasible to implement for the MVP and that validates some of the ideas that will evolve to solutions such as RLN.</p>
<p>With this approach, certain pubsub topics can be optionally configured to only accept messages signed with a given key, that only trusted entities know.
This key can be pre-shared among a set of participants, that are trusted to make fair usage of the network, publishing messages at a reasonable rate/size.
Note that this key can be shared/reused among multiple participants, and only one key is whitelisted per pubsub topic.
This is an opt-in solution that operators can choose to deploy in their shards (i.e. pubsub topics), but it&rsquo;s not enforced in the default one.
Operators can freely choose how they want to generate, and distribute the public keys. It&rsquo;s also their responsibility to handle the private key, sharing it with only trusted parties and keeping proper custody of it.</p>
<p>The following concepts are introduced:</p>
<ul>
<li><code>private-key-topic</code>: A private key of 32 bytes, that allows the holder to sign messages and it&rsquo;s mapped to a <code>protected-pubsub-topic</code>.</li>
<li><code>app-message-hash</code>: Application <code>WakuMessage</code> hash, calculated as <code>sha256(concat(pubsubTopic, payload, contentTopic))</code> with all elements in bytes.</li>
<li><code>message-signature</code>: ECDSA signature of <code>application-message-hash</code> using a given <code>private-key-topic</code>, 64 bytes.</li>
<li><code>public-key-topic</code>: The equivalent public key of <code>private-key-topic</code>.</li>
<li><code>protected-pubsub-topic</code>: Pubsub topic that only accepts messages that were signed with <code>private-key-topic</code>, where <code>verify(message-signature, app-message-hash, public-key-topic)</code> is only correct if the <code>message-signature</code> was produced by <code>private-key-topic</code>. See ECDSA signature verification algorithm.</li>
</ul>
<p>This solution introduces two roles:</p>
<ul>
<li>Publisher: A node that knows the <code>private-key-topic</code> associated to <code>public-key-topic</code>, that can publish messages with a valid <code>message-signature</code> that are accepted and relayed by the nodes implementing this feature.</li>
<li>Relayer: A node that knows the <code>public-key-topic</code>, which can be used to verify if the messages were signed with the equivalent <code>private-key-topic</code>. It allows distinguishing valid from invalid messages which protect the node against DoS attacks, assuming that the users of the key send messages of a reasonable size and rate. Note that a node can validate messages and relay them or not without knowing the private key.</li>
</ul>
<h2 id="design-requirements-publisher">
Design requirements (publisher)
<a class="anchor" href="#design-requirements-publisher">#</a>
</h2>
<p>A publisher that wants to send messages that are relayed in the network for a given <code>protected-pubsub-topic</code> shall:</p>
<ul>
<li>be able to sign messages with the <code>private-key-topic</code> configured for that topic, producing a ECDSA signature of 64 bytes.</li>
<li>include the signature of the <code>app-message-hash</code> (<code>message-signature</code>) that wishes to send in the <code>WakuMessage</code> <code>meta</code> field.</li>
</ul>
<p>## Design requirements (relay)</p>
<p>Requirements for the relay are listed below:</p>
<ul>
<li>A valid <code>protected-pubsub-topic</code> shall be configured with a <code>public-key-topic</code>, (derived from a <code>private-key-topic</code>). Note that the relay does not need to know the private key.
For simplicity, there is just one key per topic. Since this approach has clear privacy implications, this configuration is not part of the waku protocol, but of the application.</li>
<li>Relay nodes should leverage the existing gossipsub validators that allow to <code>Accept</code> or <code>Reject</code> messages.</li>
<li>Upon receiving a message, the node shall check the <code>meta</code> <code>WakuMessage</code> field. If empty, <code>Reject</code> the message.</li>
<li>If <code>meta</code> exists but its size is different than 64 bytes, <code>Reject</code> the message.</li>
<li>If <code>meta</code> exists and has a size of 64 bytes, assert that <code>message-signature</code> is verified according to the ECDSA signature verification algorithm using <code>public-key-topic</code> and <code>app-message-hash</code>.</li>
<li>If the signature does not verify correctly, <code>Reject</code> the message.</li>
<li>If and only if the signature is verified, <code>Accept</code> the message.</li>
<li>The node shall keep metrics on the messages validation output, <code>Accept</code> or <code>Reject</code>.</li>
<li>(Optional). To further strengthen DoS protection, gossipsub <a href="https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#extended-validators">scoring</a> can be used to trigger disconnections from peers sending multiple invalid messages. See <code>P4</code> penalty.
This protects each peer from DoS, since this score is used to trigger disconnections from nodes attempting to DoS them.</li>
</ul>
<h2 id="required-changes">
Required changes
<a class="anchor" href="#required-changes">#</a>
</h2>
<p>This solution is designed to be backward compatible so that nodes validating messages can coexist in the same topic with other nodes that don&rsquo;t perform validation. But note that only nodes that perform message validation will be protected against DoS. Nodes wishing to opt-in this DoS protection feature shall:</p>
<ul>
<li>Generate a <code>private-key-topic</code> and distribute it to a curated list of users, that are trusted to send messages at a reasonable rate.</li>
<li>Redeploy the nodes, adding a new configuration where a <code>protected-pubsub-topic</code> is configured with a <code>public-key-topic</code>, used to verify the messages being relayed.</li>
</ul>
<h2 id="test-vectors">
Test vectors
<a class="anchor" href="#test-vectors">#</a>
</h2>
<p>Relay nodes complying with this specification shall accept the following message in the configured pubsub topic.</p>
<p>Given the following key pair:</p>
<pre tabindex="0"><code>private-key-topic = 0x049c5fac802da41e07e6cdf51c3b9a6351ad5e65921527f2df5b7d59fd9b56ab02bab736cdcfc37f25095e78127500da371947217a8cd5186ab890ea
public-key-topic = 0x5526a8990317c9b7b58d07843d270f9cd1d9aaee129294c1c478abf7261dd9e6866211c3f6
</code></pre><p>And the following message to send:</p>
<pre tabindex="0"><code>protected-pubsub-topic = &#34;some-spam-protected-topic&#34;
contentTopic = &#34;my-content-topic&#34;
payload = 0x3af5c7a8d71498e82e1991089d8429448f3b78277fac141af9052e77fc003dfb
</code></pre><p>The message hash and signature are calculated as follows.</p>
<pre tabindex="0"><code>app-message-hash = 0xd0e3231ec48f9c0cf9306b7100c30b4e85c78854b67b41e4ee388fb4610f543d
message.meta = 0x4d79cb46a26912bfb3914d9c4cf3c76165d968b9f83c08e0c2ecf86071f2fc0e560d6b9e33923b63d62e46cc709e0ae48a956d3b5e8145e15b8fb558d3bded9c
</code></pre><p>Using <code>message.meta</code>, the relay node shall calculate the <code>app-message-hash</code> of the received message using <code>public-key-topic</code>, and with the values above, the signature should be verified, making the node <code>Accept</code> the message and relaying it to other nodes in the network.</p>
<h2 id="owner-mapped-communities-1">
Owner-Mapped Communities
<a class="anchor" href="#owner-mapped-communities-1">#</a>
</h2>
<p>Basic idea:
Tokenized load.</p>
<h2 id="11-chat-2">
1:1 Chat
<a class="anchor" href="#11-chat-2">#</a>
</h2>
<p>An idea we plan to explore in the future:
Map 1:1 chats to community shards, if both A and B are part of the respective community.
This increases k-anonymity and benefits from community DoS protection.
It could be rate-limited with RLN.</p>
<h1 id="securityprivacy-considerations">
Security/Privacy Considerations
<a class="anchor" href="#securityprivacy-considerations">#</a>
</h1>
<p>This document makes several trade-offs to privacy and anonymity.
Todo: elaborate.
See <a href="/spec/45">45/WAKU2-ADVERSARIAL-MODELS</a> for information on Waku Anonymity.</p>
<h1 id="copyright">
Copyright
<a class="anchor" href="#copyright">#</a>
</h1>
<p>Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>
<h1 id="references">
References
<a class="anchor" href="#references">#</a>
</h1>
<ul>
<li><a href="/spec/11/">11/WAKU2-RELAY</a></li>
<li><a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a></li>
<li><a href="/spec/33/">33/WAKU2-DISCV5</a></li>
<li><a href="/spec/13/">13/WAKU2-STORE</a></li>
<li><a href="/spec/19/">19/WAKU2-LIGHTPUSH</a></li>
<li><a href="/spec/12/">12/WAKU2-FILTER</a></li>
<li><a href="/spec/34/">34/WAKU2-PEER-EXCHANGE</a></li>
<li><a href="/spec/33/">33/WAKU2-DISCV5</a></li>
<li><a href="https://docs.libp2p.io/concepts/nat/circuit-relay/">Circuit Relay</a></li>
<li><a href="https://github.com/libp2p/specs/blob/6634ca7abb2f955645243d48d1cd2fd02a8e8880/relay/circuit-v2.md">libp2p circuit relay</a></li>
<li><a href="https://github.com/libp2p/specs/blob/master/relay/DCUtR.md">DCUtR</a></li>
<li><a href="/spec/31/">31/WAKU2-ENR</a></li>
<li><a href="/spec/45">45/WAKU2-ADVERSARIAL-MODELS</a></li>
</ul>
</article>
<footer class="book-footer">
<div class="flex flex-wrap justify-between">
</div>
</footer>
<div class="book-comments">
</div>
<label for="menu-control" class="hidden book-menu-overlay"></label>
</div>
<aside class="book-toc">
<div class="book-toc-content">
<nav id="TableOfContents">
<ul>
<li><a href="#shard-allocation">Shard Allocation</a>
<ul>
<li><a href="#implementation-suggestion">Implementation Suggestion</a></li>
</ul>
</li>
<li><a href="#status-communities">Status Communities</a>
<ul>
<li><a href="#static-mapping">Static Mapping</a></li>
<li><a href="#owner-mapping">Owner Mapping</a></li>
</ul>
</li>
<li><a href="#11-chat">1:1 Chat</a></li>
</ul>
<ul>
<li><a href="#statically-mapped-communities">Statically-Mapped Communities</a></li>
<li><a href="#owner-mapped-communities">Owner-Mapped Communities</a></li>
<li><a href="#11-chat-1">1:1 chat</a></li>
</ul>
<ul>
<li><a href="#control-message-shards">Control Message Shards</a></li>
<li><a href="#media-shards">Media Shards</a></li>
<li><a href="#infrastructure-focused-community">Infrastructure-focused Community</a></li>
</ul>
<ul>
<li><a href="#libp2p-rendezvous-and-circuit-relay">Libp2p Rendezvous and Circuit-Relay</a>
<ul>
<li><a href="#announcing-shard-participation">Announcing Shard Participation</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="#design-requirements-publisher">Design requirements (publisher)</a></li>
<li><a href="#required-changes">Required changes</a></li>
<li><a href="#test-vectors">Test vectors</a></li>
<li><a href="#owner-mapped-communities-1">Owner-Mapped Communities</a></li>
<li><a href="#11-chat-2">1:1 Chat</a></li>
</ul>
</nav>
</div>
</aside>
</main>
</body>
</html>