-
Notifications
You must be signed in to change notification settings - Fork 3
Waku API Spec: Node initialization #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 35 commits
93bd790
e013c15
adaba54
d5c688a
95ebcd9
25984c0
73354fd
2096211
b20f5fd
4ca0e08
6289f91
e92d2f8
1e312bc
6a37950
bebbe8b
872115a
1ec7527
f1225e1
b2b81b4
f68707e
cf84d3d
a3c37c1
0004fff
6c01164
4045000
f834dc4
5bb37c2
a0700f0
6de55db
036fe61
4ab8821
fa5bf8c
9d5191f
616306e
388c257
ad4fb96
0c64eaa
82181bf
09e3ade
34b9443
214ee73
7748d6a
b9454e3
6a421f5
5cd0080
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,327 @@ | ||||||||||||||
| --- | ||||||||||||||
| title: WAKU-API | ||||||||||||||
| name: Waku API definition | ||||||||||||||
| category: Standards Track | ||||||||||||||
| tags: [reliability, application, api, protocol composition] | ||||||||||||||
| editor: Oleksandr Kozlov <oleksandr@status.im> | ||||||||||||||
| contributors: | ||||||||||||||
| - Oleksandr Kozlov <oleksandr@status.im> | ||||||||||||||
| - Prem Chaitanya Prathi <prem@status.im> | ||||||||||||||
| - Franck Royer <franck@status.im> | ||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Table of contents | ||||||||||||||
|
|
||||||||||||||
| <!-- TOC --> | ||||||||||||||
| * [Table of contents](#table-of-contents) | ||||||||||||||
| * [Abstract](#abstract) | ||||||||||||||
| * [Motivation](#motivation) | ||||||||||||||
| * [Syntax](#syntax) | ||||||||||||||
| * [API design](#api-design) | ||||||||||||||
| * [IDL](#idl) | ||||||||||||||
| * [Primitive types and general guidelines](#primitive-types-and-general-guidelines) | ||||||||||||||
| * [Language mappings](#language-mappings) | ||||||||||||||
| * [Application](#application) | ||||||||||||||
| * [The Waku API](#the-waku-api) | ||||||||||||||
| * [Initialise Waku node](#initialise-waku-node) | ||||||||||||||
| * [Type definitions](#type-definitions) | ||||||||||||||
| * [Function definitions](#function-definitions) | ||||||||||||||
| * [Predefined values](#predefined-values) | ||||||||||||||
| * [Extended definitions](#extended-definitions) | ||||||||||||||
| * [The Validation API](#the-validation-api) | ||||||||||||||
| * [Security/Privacy Considerations](#securityprivacy-considerations) | ||||||||||||||
| * [Copyright](#copyright) | ||||||||||||||
| <!-- TOC --> | ||||||||||||||
|
|
||||||||||||||
| ## Abstract | ||||||||||||||
|
|
||||||||||||||
| This document specifies an Application Programming Interface (API) that is RECOMMENDED for developers of the [WAKU2](https://github.com/vacp2p/rfc-index/blob/7b443c1aab627894e3f22f5adfbb93f4c4eac4f6/waku/standards/core/10/waku2.md) clients to implement, | ||||||||||||||
| and for consumers to use as a single entry point to its functionalities. | ||||||||||||||
|
|
||||||||||||||
| This API defines the RECOMMENDED interface for leveraging Waku protocols to send and receive messages. | ||||||||||||||
| Application developers SHOULD use it to access capabilities for peer discovery, message routing, and peer-to-peer reliability. | ||||||||||||||
|
|
||||||||||||||
| ## Motivation | ||||||||||||||
|
|
||||||||||||||
| The accessibility of Waku protocols is capped by the accessibility of their implementations, and hence API. | ||||||||||||||
| This RFC enables a concerted effort to draft an API that is simple and accessible, and provides an opinion on sane defaults. | ||||||||||||||
|
|
||||||||||||||
| The API defined in this document is an opinionated-by-purpose method to use the more agnostic [WAKU2]() protocols. | ||||||||||||||
|
|
||||||||||||||
| ## Syntax | ||||||||||||||
|
|
||||||||||||||
| The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, | ||||||||||||||
| “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC2119](https://www.ietf.org/rfc/rfc2119.txt). | ||||||||||||||
|
|
||||||||||||||
| ## API design | ||||||||||||||
|
|
||||||||||||||
| ### IDL | ||||||||||||||
|
|
||||||||||||||
| A custom Interface Definition Language (IDL) in YAML is used to define the Waku API. | ||||||||||||||
| Existing IDL Such as OpenAPI, AsyncAPI or WIT do not exactly fit the requirements for this API. | ||||||||||||||
| Hence, instead of having the reader learn a new IDL, we propose to use a simple IDL with self-describing syntax. | ||||||||||||||
|
|
||||||||||||||
| An alternative would be to choose a programming language. However, such choice may express unintended opinions on the API. | ||||||||||||||
|
|
||||||||||||||
| ### Primitive types and general guidelines | ||||||||||||||
|
|
||||||||||||||
| - No `default` means that the value is mandatory, meaning a `default` value implies an optional parameter. | ||||||||||||||
| - Primitive types are `string`, `int`, `bool`, `enum` and `uint` | ||||||||||||||
| - Complex pre-defined types are: | ||||||||||||||
| - `struct`: object and other nested types. | ||||||||||||||
|
||||||||||||||
| - `array`: iterable object containing values of all the same type. | ||||||||||||||
| - `result`: an enum type that either contains a value or void (success), or an error (failure); The error is left to the implementor. | ||||||||||||||
| - `error`: Left to the implementor on whether `error` types are `string` or `object` in the given language. | ||||||||||||||
| - Usage of `result` is RECOMMENDED, usage of exceptions is NOT RECOMMENDED, no matter the language. | ||||||||||||||
|
|
||||||||||||||
| ### Language mappings | ||||||||||||||
|
|
||||||||||||||
| How the API definition should be translated to specific languages. | ||||||||||||||
weboko marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| ```yaml | ||||||||||||||
| language_mappings: | ||||||||||||||
| typescript: | ||||||||||||||
| naming_convention: | ||||||||||||||
| - functions: "camelCase" | ||||||||||||||
| - variables: "camelCase" | ||||||||||||||
| - types: "PascalCase" | ||||||||||||||
| nim: | ||||||||||||||
| naming_convention: | ||||||||||||||
| - functions: "camelCase" | ||||||||||||||
| - variables: "camelCase" | ||||||||||||||
| - types: "PascalCase" | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ### Application | ||||||||||||||
|
|
||||||||||||||
| This API is designed for generic use and ease across all programming languages, for `edge` and `relay` type nodes. | ||||||||||||||
|
|
||||||||||||||
| ## The Waku API | ||||||||||||||
|
|
||||||||||||||
| ```yaml | ||||||||||||||
| api_version: "0.0.1" | ||||||||||||||
| library_name: "waku" | ||||||||||||||
| description: "Waku: a private and censorship-resistant message routing library." | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ### Initialise Waku node | ||||||||||||||
|
|
||||||||||||||
| #### Type definitions | ||||||||||||||
|
|
||||||||||||||
| ```yaml | ||||||||||||||
| types: | ||||||||||||||
| WakuNode: | ||||||||||||||
| type: struct | ||||||||||||||
| description: "A Waku node instance." | ||||||||||||||
|
|
||||||||||||||
| NodeConfig: | ||||||||||||||
| type: struct | ||||||||||||||
| fields: | ||||||||||||||
| mode: | ||||||||||||||
| type: string | ||||||||||||||
| constraints: [ "edge", "relay" ] | ||||||||||||||
| default: "_platform dependent_" | ||||||||||||||
| description: "The mode of operation of the Waku node. Core protocols used by the node are inferred from this mode." | ||||||||||||||
| waku_config: | ||||||||||||||
| type: WakuConfig | ||||||||||||||
| default: TheWakuNetworkPreset | ||||||||||||||
| message_confirmation: | ||||||||||||||
| type: array<string> | ||||||||||||||
| constraints: [ "store", "filter" ] | ||||||||||||||
| # Until further dogfooding, assuming default false, usage of SDS should be preferred | ||||||||||||||
|
||||||||||||||
| default: [ "none" ] | ||||||||||||||
|
||||||||||||||
| constraints: [ "store", "filter" ] | |
| # Until further dogfooding, assuming default false, usage of SDS should be preferred | |
| default: [ "none" ] | |
| constraints: [ "none", "store", "sds" ] | |
| # Until further dogfooding, assuming default none, usage of SDS should be preferred | |
| default: [ "none" ] |
Besides, I can't quite get why an array<string> is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, I can't quite get why an array is needed
@Ivansete-status as I understand it is because we can have multiple confirmation mechanisms working at the same time filter + store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What @weboko said: the p2p reliability strategies are not mutually exclusive.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: and we can remove the comment above
| description: "Nodes to connect to; used for discovery bootstrapping and quick connectivity. entree and multiaddr formats are accepted." | |
| description: "Nodes to connect to; used for discovery bootstrapping and quick connectivity. entree and multiaddr formats are accepted. If not provided, node does not bootstrap (e.g for local development)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we ever add mDNS the comment will be false. But will add in the mean time.
Ivansete-status marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry if you mentioned it somewhere and I didn't see
question: why discarded? previously we were discussing it in the way that discovered nodes will be de-prioritized and used only if static store nodes are not available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can re-adjust at implementation time. Will correct and add todo.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # If the default config for TWN is not used, then we still provide a message validation default | |
| description: If the default config for TWN is not used, then we still provide a message validation default |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we include comments into description? I think this gives needed context and doesn't over bloat them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes all done
Ivansete-status marked this conversation as resolved.
Show resolved
Hide resolved
chaitanyaprem marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it worth mentioning remote nodes and contract address as they can get outdated rather fast: unpredicted contract changes like we did recently etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. I think it's fine to have it and forces us to update it as the intent is to ensure that all implementations are interoperable by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata should be loaded too.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can refer to roughly estimated bandwidth and hardware specified somewhere in specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, but maybe best to do that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to think that we also need another type of node: boot
This mode makes the node to become a facilitator within the network (PX, discv5, etc.) and doesn't mount relay and doesn't mount store either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I agree there is a type boot, but it is out of scope for the Waku API.
If someone wants to run a boot node, they can use wakunode2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.