Skip to content

Waku API Spec: Node initialization#65

Merged
fryorcraken merged 45 commits intomasterfrom
f/waku-api-custom-idl
Oct 1, 2025
Merged

Waku API Spec: Node initialization#65
fryorcraken merged 45 commits intomasterfrom
f/waku-api-custom-idl

Conversation

@fryorcraken
Copy link
Contributor

@fryorcraken fryorcraken commented Jun 17, 2025

This PR intends to introduce the customer Interface Definition Language, by proposing an initialization function and accompanying config for the Waku API.

The "Waku API" is a proposed renamed of "Waku Messaging API" because the term "messaging" is very generic and is going to also be used by Status to qualify the Waku Chat SDK API.

Also best to start generic for us with "Waku API", as this is the API we want developers to use. And we can refine at a later stage if there is a more specialized API we want to offer (aka "RLN API").

This PR is a suggestion to replace #19. I have already made comment in #19, but in short:

  • More succinct document and definition, we are here to define an API, behaviour should be inferred by protocols already defined
  • Focus on iterative delivery, the spec should match the code. eg we do not intend to implement Waku API in REST API in 2025H2, so the spec can be done later
  • Trying to avoid duplicate block of text, and keeping definitions close to introduction
  • Making it language agnostic, so it can truly define the API across all languages.

#68

@fryorcraken fryorcraken force-pushed the f/waku-api-custom-idl branch from 6e40863 to 93bd790 Compare June 18, 2025 00:13
@fryorcraken fryorcraken changed the title F/waku api custom idl Waku API Spec Jun 18, 2025
Copy link
Contributor

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really superb so far! Congrats for it 🙌
I'm just suggesting minor tweaks

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some recomendation.

- No `default` means that the value is mandatory
- Primitive types are `string`, `int`, `bool` and `uint`
- Complex pre-define types are `struct`, `option` and `array`
- Primitive types are preferred to describe the API for simplicity, the implementator may prefer a native type (e.g. `string` vs `Multiaddr` object/struct)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue with it, as such API has reduntant use of complex types (structs like WakuMessage or even very specific named types like Multiaddr). I think IDL shall support references to such types to allow reuse them over native types.- much like OpenAPI syntax.
This is even beneficial if we think it is harder to read as it leads more comprehensive api definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced Waku Message needs to leak out of the API.

In terms of Multiaddr, I don't want to prescribe the API to have to only accept an object Multiaddr because in some language like JS, a string is often used and expected.

Hence not entirely sure the best way to express that. I gave it a go in adaba54 (#65)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO , Multiaddr type doesn't seem as generic as option, array, struct. I wouldn't add it adaba54

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cna expect it to be a string in most languages. so will do that.

Comment on lines 129 to 133
active_relay_shards:
type: array<uint>
constraints: mode == "relay"
default: []
description: "The shards for relay to subscribe to and participate in."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually not convinced this should be available when initializing a node.

The action here is that "subscribe" will be called on those shards. "subscribe" is a live action to be done on a running node.

While it is fine for wakunode2 to have a way to specify shards to subscribe to on the CLI, it should be seen separately for node instantiation.

Hence I think I would recommend removing it.

@@ -0,0 +1,224 @@
---
title: MESSAGING-API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we aligned on new naming.

Suggested change
title: MESSAGING-API
title: WAKU-API

- `option`: a value that can be set or left null
- `array`: iterable object containing values of all the same type
- `multiaddr`: a libp2p multiaddress; may be an object or a string, most idiomatic approach depending on the language
- `result`: an enum type that either contain a return value (success), or an error (failure). The error is left to the implementor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can specify somewhere that result is recommended way of communicating errors rather than throw but it can be left to implementations

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.

This effort is best done in an RFC, allowing all current implementors to review and agree on it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can omit this line, seems it doesn't bring much value

- `multiaddr`: a libp2p multiaddress; may be an object or a string, most idiomatic approach depending on the language
- `result`: an enum type that either contain a return value (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.
- The first parameter of a function MAY be considered as the object on which a method is called. It is left to the implementor on whether an objective programming approach is idiomatic to the language.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line seems to be too specific even though it is true for nim and rust

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can re-introduce it when we define function that needs a reference to some exiting Waku node instance.

## The Waku API

```yaml
api_version: "0.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just general question: why not start with 1.0.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As usual, let's mature things before we decide to crystallize and make it a 1.0.0

Being able to set what shard to subscribe too when initialising a Waku node is a biased towards service nodes.

Indeed, subscribing to shard should be done with the `subscribe` API (yet to be defined). Which can be used with a content topic, and pubsub topic (only if static sharding).

A service node such as the `wakunode2` binary can still accept "shards to subscribe to" via CLI, but this is unrelated to the Waku node conf, and the `wakunode2` software should simply call `subscribe` when ready.
@fryorcraken
Copy link
Contributor Author

Only comment node configuration and initialization part of this PR.

The work here is highly controversial, so let's focus on one bit at a time. Discussions related to other functions such as subscribe, etc, should wait for their own PR.

@fryorcraken fryorcraken linked an issue Jul 1, 2025 that may be closed by this pull request
fields:
mode:
type: string
constraints: ["edge", "relay"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core or standard are good alternatives to relay.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't change relay. It sounds correct to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fryorcraken fryorcraken changed the title Waku API Spec Waku API Spec: Node initialization Jul 4, 2025

If the `mode` set is `edge`, the initialised `WakuNode` MUST mount:

- [LIGHTPUSH](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/19/lightpush.md) as client
Copy link
Contributor Author

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.

@fryorcraken
Copy link
Contributor Author

@jimstir I think it's going to be hard to maintain a spell check dictionary.

Copy link
Contributor

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks so much for it! 🥳
Just added another nitpick one ;P

Comment on lines 130 to 132
constraints: [ "store", "filter" ]
# Until further dogfooding, assuming default false, usage of SDS should be preferred
default: [ "none" ]
Copy link
Contributor

@Ivansete-status Ivansete-status Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDITED:

I think we don't need that message_confirmation parameter. That can be considered internally as per the given operation mode (edge, relay.)


EDITED: disregard the following comment. I was confused.

Maybe :)?

Suggested change
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

Copy link
Contributor

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

Copy link
Contributor Author

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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The API defined in this document is an opinionated-by-purpose method to use the more agnostic [WAKU2]() protocols.
The API defined in this document is an opinionated-by-purpose method to use the more agnostic [WAKU2](https://github.com/vacp2p/rfc-index/blob/7b443c1aab627894e3f22f5adfbb93f4c4eac4f6/waku/standards/core/10/waku2.md) protocols.

- 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: by being biased by high level languages I would prefer object instead of struct

message_confirmation:
type: array<string>
constraints: [ "store", "filter" ]
# Until further dogfooding, assuming default false, usage of SDS should be preferred
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we mention SDS here as it is in dogfooding / experimental stage too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed, what I mean is that I expect we change the default in the future.

type: array<string>
# Default means the node does not bootstrap, e.g. for local development
default: []
description: "Nodes to connect to; used for discovery bootstrapping and quick connectivity. entree and multiaddr formats are accepted."
Copy link
Contributor

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

Suggested change
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)"

Copy link
Contributor Author

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.

static_store_nodes:
type: array<string>
default: []
description: "Only the passed nodes are used for store queries, discovered store nodes are discarded."
Copy link
Contributor

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

Copy link
Contributor Author

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.

description: "The auto-sharding config, if sharding mode is `auto`"
message_validation:
type: MessageValidation
# If the default config for TWN is not used, then we still provide a message validation default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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

type: string
fields:
listen_ipv4:
# Is not applicable in some environments such as browser.
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes all done

TheWakuNetworkPreset:
type: WakuConfig
fields:
remote_nodes: [ "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im" ]
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@weboko weboko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, lgtm otherwise

amazing to see progress on Waku API init

@fryorcraken fryorcraken marked this pull request as ready for review September 26, 2025 13:44
@jimstir
Copy link
Contributor

jimstir commented Sep 26, 2025

@jimstir I think it's going to be hard to maintain a spell check dictionary.

Yea, the nature of specifications, new terms will always be introduced which will require constant updates to the dictionary.

@fryorcraken fryorcraken merged commit 71ad70a into master Oct 1, 2025
1 check failed
@fryorcraken fryorcraken deleted the f/waku-api-custom-idl branch October 1, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define Waku API

7 participants