From 129474238db6e26e881ec915fbd468670bba0954 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 21 Mar 2024 11:44:43 -0400 Subject: [PATCH] feat: rln --- waku-bindings/src/lib.rs | 2 +- waku-bindings/src/node/config.rs | 44 ++++++++++++++++++++++++++++++++ waku-bindings/src/node/mod.rs | 1 + waku-sys/vendor | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/waku-bindings/src/lib.rs b/waku-bindings/src/lib.rs index 4f7bb38..eee8841 100644 --- a/waku-bindings/src/lib.rs +++ b/waku-bindings/src/lib.rs @@ -13,7 +13,7 @@ use rln; pub use node::{ waku_create_content_topic, waku_destroy, waku_new, Event, Initialized, Key, Multiaddr, - PublicKey, Running, SecretKey, WakuMessageEvent, WakuNodeConfig, WakuNodeHandle, + PublicKey, RLNConfig, Running, SecretKey, WakuMessageEvent, WakuNodeConfig, WakuNodeHandle, }; pub use general::{ diff --git a/waku-bindings/src/node/config.rs b/waku-bindings/src/node/config.rs index 0889642..eb9e5c0 100644 --- a/waku-bindings/src/node/config.rs +++ b/waku-bindings/src/node/config.rs @@ -20,10 +20,54 @@ pub struct WakuNodeConfig { /// Secp256k1 private key in Hex format (`0x123...abc`). Default random #[serde(with = "secret_key_serde", rename = "key")] pub node_key: Option, + /// Cluster id that the node is running in + #[default(Some(0))] + pub cluster_id: Option, /// Enable relay protocol. Default `true` #[default(Some(true))] pub relay: Option, pub relay_topics: Vec, + /// RLN configuration + #[serde(skip_serializing_if = "Option::is_none")] + pub rln_relay: Option, +} + +/// RLN Relay configuration +#[derive(Clone, SmartDefault, Serialize, Deserialize, Debug)] +#[serde(rename_all = "kebab-case")] +pub struct RLNConfig { + /// Indicates if RLN support will be enabled. + pub enabled: bool, + /// Index of the onchain commitment to use + #[serde(skip_serializing_if = "Option::is_none", rename = "membership-index")] + pub membership_index: Option, + /// On-chain dynamic group management + #[serde(skip_serializing_if = "Option::is_none")] + pub dynamic: Option, + /// Path to the RLN merkle tree sled db (https://github.com/spacejam/sled) + #[serde(skip_serializing_if = "Option::is_none")] + pub tree_path: Option, + /// Message rate in bytes/sec after which verification of proofs should happen + #[serde(skip_serializing_if = "Option::is_none")] + pub bandwidth_threshold: Option, + /// Path for persisting rln-relay credential + #[serde(skip_serializing_if = "Option::is_none")] + pub cred_path: Option, + /// HTTP address of an Ethereum testnet client e.g., http://localhost:8540/ + #[serde(skip_serializing_if = "Option::is_none")] + pub eth_client_address: Option, + /// Address of membership contract on an Ethereum testnet + #[serde(skip_serializing_if = "Option::is_none")] + pub eth_contract_address: Option, + /// Password for encrypting RLN credentials + #[serde(skip_serializing_if = "Option::is_none")] + pub cred_password: Option, + /// Set a user message limit for the rln membership registration + #[serde(skip_serializing_if = "Option::is_none")] + pub user_message_limit: Option, + /// Epoch size in seconds used to rate limit RLN memberships + #[serde(skip_serializing_if = "Option::is_none")] + pub epoch_sec: Option, } mod secret_key_serde { diff --git a/waku-bindings/src/node/mod.rs b/waku-bindings/src/node/mod.rs index 1419d88..817e34b 100644 --- a/waku-bindings/src/node/mod.rs +++ b/waku-bindings/src/node/mod.rs @@ -17,6 +17,7 @@ use std::time::Duration; use crate::general::{MessageHash, Result, WakuMessage}; use context::WakuNodeContext; +pub use config::RLNConfig; pub use config::WakuNodeConfig; pub use events::{Event, WakuMessageEvent}; pub use relay::waku_create_content_topic; diff --git a/waku-sys/vendor b/waku-sys/vendor index 7ef1293..964d7ab 160000 --- a/waku-sys/vendor +++ b/waku-sys/vendor @@ -1 +1 @@ -Subproject commit 7ef1293bc3f94660da0c80f2e2ea052ef6600742 +Subproject commit 964d7ab7dc3dc38c9a05087b998a0cc7a1475cc0