Specification # A node which wants to provide mailserver functionality MUST store envelopes from incoming Messages packets (Waku packet-code 0x01). The envelopes can be stored in any format, however they MUST be serialized and deserialized to the Waku envelope format.
A mailserver SHOULD store envelopes for all topics to be generally useful for any peer, however for specific use cases it MAY store envelopes for a subset of topics.">
Specification # A node which wants to provide mailserver functionality MUST store envelopes from incoming Messages packets (Waku packet-code 0x01). The envelopes can be stored in any format, however they MUST be serialized and deserialized to the Waku envelope format.
A mailserver SHOULD store envelopes for all topics to be generally useful for any peer, however for specific use cases it MAY store envelopes for a subset of topics." />
<li>Editor: Andrea Maria Piana <ahref="mailto:andreap@status.im">andreap@status.im</a></li>
<li>Contributors:
Adam Babik <ahref="mailto:adam@status.im">adam@status.im</a>
,
Dean Eigenmann <ahref="mailto:dean@status.im">dean@status.im</a>
,
Oskar Thorén <ahref="mailto:oskar@status.im">oskar@status.im</a>
</li>
</ul><h2id="abstract">
Abstract
<aclass="anchor"href="#abstract">#</a>
</h2>
<p>In this specification, we describe Mailservers. These are nodes responsible for archiving envelopes and delivering them to peers on-demand.</p>
<h2id="specification">
Specification
<aclass="anchor"href="#specification">#</a>
</h2>
<p>A node which wants to provide mailserver functionality MUST store envelopes from incoming Messages packets (Waku packet-code <code>0x01</code>). The envelopes can be stored in any format, however they MUST be serialized and deserialized to the Waku envelope format.</p>
<p>A mailserver SHOULD store envelopes for all topics to be generally useful for any peer, however for specific use cases it MAY store envelopes for a subset of topics.</p>
<p>In order to request historic envelopes, a node MUST send a packet P2P Request (<code>0x7e</code>) to a peer providing mailserver functionality. This packet requires one argument which MUST be a Waku envelope.</p>
<p>In the Waku envelope’s payload section, there MUST be RLP-encoded information about the details of the request:</p>
<divclass="highlight"><pretabindex="0"style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><codeclass="language-abnf"data-lang="abnf"><spanstyle="display:flex;"><span><spanstyle="color:#75715e">; UNIX time in seconds; oldest requested envelope's creation time</span>
</span></span></code></pre></div><p>The <code>Cursor</code> field SHOULD be filled in if a number of envelopes between <code>Lower</code> and <code>Upper</code> is greater than <code>Limit</code> so that the requester can send another request using the obtained <code>Cursor</code> value. What exactly is in the <code>Cursor</code> is up to the implementation. The requester SHOULD NOT use a <code>Cursor</code> obtained from one mailserver in a request to another mailserver because the format or the result MAY be different.</p>
<p>The envelope MUST be encrypted with a symmetric key agreed between the requester and Mailserver.</p>
<p>If <code>Topics</code> is used the <code>Cursor</code> field MUST be specified for the argument order to be unambiguous. However, it MAY be set to <code>null</code>. <code>Topics</code> is used to specify which topics a node is interested in. If <code>Topics</code> is not empty, a mailserver MUST only send envelopes that belong to a topic from <code>Topics</code> list and <code>Bloom</code> value MUST be ignored.</p>
<p>Historic envelopes MUST be sent to a peer as a packet with a P2P Message code (<code>0x7f</code>) followed by an array of Waku envelopes. A Mailserver MUST limit the amount of messages sent, either by the <code>Limit</code> specified in the request or limited to the maximum <ahref="./waku#maximum-packet-size">RLPx packet size</a>, whichever limit comes first.</p>
<p>In order to receive historic envelopes from a mailserver, a node MUST trust the selected mailserver, that is allow to receive expired packets with the P2P Message code. By default, such packets are discarded.</p>
<p>Received envelopes MUST be passed through the Whisper envelope pipelines so that they are picked up by registered filters and passed to subscribers.</p>
<p>For a requester, to know that all envelopes have been sent by mailserver, it SHOULD handle P2P Request Complete code (<code>0x7d</code>). This code is followed by a list with:</p>
<divclass="highlight"><pretabindex="0"style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><codeclass="language-abnf"data-lang="abnf"><spanstyle="display:flex;"><span><spanstyle="color:#75715e">; array with a Keccak-256 hash of the envelope containing the original request.</span>
</span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e">; array with a Keccak-256 hash of the last sent envelope for the request. </span>
</span></span></code></pre></div><p>If <code>Cursor</code> is not empty, it means that not all envelopes were sent due to the set <code>Limit</code> in the request. One or more consecutive requests MAY be sent with <code>Cursor</code> field filled in in order to receive the rest of the envelopes.</p>
<p>There are several security considerations to take into account when running or interacting with Mailservers. Chief among them are: scalability, DDoS-resistance and privacy.</p>
<p><strong>Mailserver High Availability requirement:</strong></p>
<p>A mailserver has to be online to receive envelopes for other nodes, this puts a high availability requirement on it.</p>
The collection of such information allows the mailserver to link clients’ IP/IDs to their topic interests and build a profile for each client over time.
As such, the mailserver client has to trust the mailserver with this level of information.
A similar concern exists for the light nodes and their direct peers which is discussed in the security considerations of <ahref="/spec/7">6/WAKU1</a>.</p>
<p>A mailserver has a direct TCP connection, which means they are trusted to send traffic. This means a malicious or malfunctioning mailserver can overwhelm an individual node.</p>