rfc/specs/waku/waku-v2.md

176 lines
5.3 KiB
Markdown
Raw Normal View History

2020-07-02 04:48:15 +00:00
---
title: Waku
2020-07-03 06:23:41 +00:00
version: 2.0.0-alpha1
2020-07-02 04:48:15 +00:00
status: Raw
authors: Oskar Thorén <oskar@status.im>
---
## Table of Contents
2020-07-07 05:07:16 +00:00
- [Abstract](#abstract)
- [Motivation](#motivation)
- [Definitions](#definitions)
- [Goals](#goals)
- [Underlying Transports and Prerequisites](#underlying-transports-and-prerequisites)
* [Peer Discovery](#peer-discovery)
* [PubSub interface](#pubsub-interface)
* [Protocol Identifier](#protocol-identifier)
* [FloodSub](#floodsub)
* [Bridge mode](#bridge-mode)
- [Wire Specification](#wire-specification)
* [Messages](#messages)
* [SubOpts](#subopts)
- [Changelog](#changelog)
- [Copyright](#copyright)
- [References](#references)
2020-07-02 04:48:15 +00:00
## Abstract
2020-07-08 04:09:30 +00:00
Waku is a privacy-preserving peer-to-peer messaging protocol for resource
restricted devices. It implements PubSub over libp2p and adds capabilities on
top of it. These capabilities are: (i) retrieving historical messages for
mostly-offline devices (ii) adaptive nodes, allowing for heterogeneous nodes to
contribute, and (iii) bandwidth preservation for light nodes. This makes it
ideal for running a p2p protocol on mobile.
Historically, it has its roots in [Waku v1](specs.vac.dev/waku/waku.html), which
stems from [Whisper](https://eips.ethereum.org/EIPS/eip-627), originally part of
the Ethereum stack. However, Waku v2 acts more as a thin wrapper for PubSub and
has a different API. It is implemented in an iterative manner where initial
focus is on porting essential functionality to libp2p. See [rough road
map](https://vac.dev/waku-v2-plan).
2020-07-02 04:48:15 +00:00
2020-07-07 05:50:07 +00:00
## Motivation and goals
2020-07-02 04:48:15 +00:00
2020-07-07 05:50:07 +00:00
1. **Generalized messaging.** Many applications requires some form of messaging
protocol to communicate between different subsystems or different nodes. This
messaging can be human-to-human or machine-to-machine or a mix.
2. **Peer-to-peer.**These applications sometimes have requirements that make
them suitable for peer-to-peer solutions.
3. **Resource restricted**.These applications often run in constrained
environments, where resources or the environment is restricted in some
fashion. E.g.:
- limited bandwidth, CPU, memory, disk, battery, etc
2020-07-07 05:50:07 +00:00
- not being publicly connectable
- only being intermittently connected; mostly-offline
4. **Privacy.** These applications have a desire for some privacy guarantees,
such as pseudonymity, metadata protection in transit, etc.
2020-07-02 04:48:15 +00:00
2020-07-07 05:50:07 +00:00
Waku provides a solution that satisfies these goals in a reasonable matter.
2020-07-02 04:48:15 +00:00
## Definitions
TODO
## Underlying Transports and Prerequisites
2020-07-03 06:21:24 +00:00
TODO Right now this is more like a set of components
2020-07-02 04:48:15 +00:00
2020-07-03 05:53:36 +00:00
### Peer Discovery
2020-07-08 04:09:30 +00:00
WakuSub and PubSub don't provide an peer discovery mechanism. This has to be
provided for by the environment.
2020-07-03 05:53:36 +00:00
2020-07-03 05:29:54 +00:00
### PubSub interface
2020-07-08 04:09:30 +00:00
Waku v2 is implementing the PubSub interface in Libp2p. See [PubSub interface
for libp2p (r2,
2019-02-01)](https://github.com/libp2p/specs/blob/master/pubsub/README.md) for
more details.
2020-07-03 05:29:54 +00:00
2020-07-03 05:25:30 +00:00
### Protocol Identifier
2020-07-08 04:09:30 +00:00
The current [protocol identifier](https://docs.libp2p.io/concepts/protocols/)
is: `/wakusub/2.0.0-alpha1`.
2020-07-03 05:25:30 +00:00
2020-07-03 05:53:36 +00:00
### FloodSub
2020-07-08 04:09:30 +00:00
WakuSub is currently a subprotocol of FloodSub. Future versions of WakuSub will
support [GossipSub
v1.0](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.0.md)
and [GossipSub
1.1](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md).
2020-07-03 05:53:36 +00:00
2020-07-03 06:21:24 +00:00
### Bridge mode
2020-07-08 04:09:30 +00:00
To maintain compatibility with Waku v1, a bridge mode can be achieved. See
separate spec.
2020-07-03 06:21:24 +00:00
TODO Detail this in a separate spec
2020-07-02 04:48:15 +00:00
## Wire Specification
2020-07-08 04:23:55 +00:00
We are using protobuf RPC messages between peers. Here's what the protobuf messages looks like, as defined in the PubSub interface. Please see [PubSub interface spec](https://github.com/libp2p/specs/blob/master/pubsub/README.md) for more details.
2020-07-03 06:21:24 +00:00
2020-07-08 04:23:55 +00:00
In this section we specify two things:
1) How WakuSub is using these messages.
2) Additional message types.
2020-07-02 04:48:15 +00:00
2020-07-08 04:23:55 +00:00
### Protobuf
2020-07-03 06:21:24 +00:00
```
2020-07-08 04:23:55 +00:00
message RPC {
repeated SubOpts subscriptions = 1;
repeated Message publish = 2;
message SubOpts {
optional bool subscribe = 1;
optional string topicid = 2;
}
}
2020-07-03 06:21:24 +00:00
message Message {
optional string from = 1;
optional bytes data = 2;
optional bytes seqno = 3;
repeated string topicIDs = 4;
optional bytes signature = 5;
optional bytes key = 6;
}
```
2020-07-08 04:23:55 +00:00
WakuSub does not currently use the `ControlMessage` defined in GossipSub. However, later versions will add likely add this capability.
2020-07-03 06:21:24 +00:00
2020-07-08 04:23:55 +00:00
`TopicDescriptor` as defined in the PubSub interface spec is not currently used.
2020-07-03 06:21:24 +00:00
2020-07-08 04:23:55 +00:00
### Historical message support
TODO(Dean): Fill out this section with historical message API.
### Options used
*NOTE: Should contain protobuf definitions that cover essentials of Waku v1. In cases where it doesn't cover, we can defer to siblings/child specs, e.g. such as the data field for encryption, etc.*
2020-07-03 06:21:24 +00:00
2020-07-02 04:48:15 +00:00
## Changelog
TODO
## Copyright
2020-07-08 04:09:30 +00:00
Copyright and related rights waived via
[CC0](https://creativecommons.org/publicdomain/zero/1.0/).
2020-07-02 04:48:15 +00:00
2020-07-03 06:21:24 +00:00
## References
2020-07-03 05:25:30 +00:00
2020-07-07 05:14:01 +00:00
1. [Protocol Identifiers](https://docs.libp2p.io/concepts/protocols/)
2020-07-03 05:29:54 +00:00
2020-07-08 04:09:30 +00:00
2. [PubSub interface for libp2p (r2,
2019-02-01)](https://github.com/libp2p/specs/blob/master/pubsub/README.md)
2020-07-03 05:53:36 +00:00
2020-07-08 04:09:30 +00:00
3. [GossipSub
v1.0](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.0.md)
2020-07-03 05:53:36 +00:00
2020-07-08 04:09:30 +00:00
4. [GossipSub
v1.1](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md)
2020-07-03 06:16:05 +00:00
2020-07-07 05:14:01 +00:00
5. [Waku v1 spec](specs.vac.dev/waku/waku.html)
2020-07-03 06:16:05 +00:00
2020-07-07 05:14:01 +00:00
6. [Whisper spec (EIP627)](https://eips.ethereum.org/EIPS/eip-627)
2020-07-03 06:16:05 +00:00
2020-07-07 05:14:01 +00:00
7. [Waku v2 plan](https://vac.dev/waku-v2-plan)