Skip to content

Commit

Permalink
feat: rln
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Mar 21, 2024
1 parent a63b560 commit 03d0138
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion waku-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
44 changes: 44 additions & 0 deletions waku-bindings/src/node/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SecretKey>,
/// Cluster id that the node is running in
#[default(Some(0))]
pub cluster_id: Option<usize>,
/// Enable relay protocol. Default `true`
#[default(Some(true))]
pub relay: Option<bool>,
pub relay_topics: Vec<String>,
/// RLN configuration
#[serde(skip_serializing_if = "Option::is_none")]
pub rln_relay: Option<RLNConfig>,
}

/// RLN Relay configuration
#[derive(Clone, SmartDefault, Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
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")]
pub membership_index: Option<usize>,
/// On-chain dynamic group management
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic: Option<bool>,
/// Path to the RLN merkle tree sled db (https://github.com/spacejam/sled)
#[serde(skip_serializing_if = "Option::is_none")]
pub tree_path: Option<String>,
/// Message rate in bytes/sec after which verification of proofs should happen
#[serde(skip_serializing_if = "Option::is_none")]
pub bandwidth_threshold: Option<usize>,
/// Path for persisting rln-relay credential
#[serde(skip_serializing_if = "Option::is_none")]
pub credential_path: Option<String>,
/// HTTP address of an Ethereum testnet client e.g., http://localhost:8540/
#[serde(skip_serializing_if = "Option::is_none")]
pub eth_client_address: Option<String>,
/// Address of membership contract on an Ethereum testnet
#[serde(skip_serializing_if = "Option::is_none")]
pub contract_address: Option<String>,
/// Password for encrypting RLN credentials
#[serde(skip_serializing_if = "Option::is_none")]
pub credential_password: Option<String>,
/// Set a user message limit for the rln membership registration
#[serde(skip_serializing_if = "Option::is_none")]
pub user_message_limit: Option<u64>,
/// Epoch size in seconds used to rate limit RLN memberships
#[serde(skip_serializing_if = "Option::is_none")]
pub epoch_size_sec: Option<u64>,
}

mod secret_key_serde {
Expand Down
1 change: 1 addition & 0 deletions waku-bindings/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion waku-sys/vendor
Submodule vendor updated 378 files

0 comments on commit 03d0138

Please sign in to comment.