Skip to content

Commit

Permalink
remove docstring on binaries, rename new
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Oct 30, 2023
1 parent fd398b6 commit a2305e4
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 91 deletions.
71 changes: 18 additions & 53 deletions bin/state_bridge_service.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
//! # State Bridge Service
//!
//! ### Description
//!
//! The state bridge service for the World ID protocol takes care of periodically relaying the latest roots from the World ID Identity Manager onto L2 networks or sidechains that implement native bridge on Ethereum or have an integration with third party messaging protocol. The state bridge service requires a deployment of the [`world-id-state-bridge`](github.com/worldcoin/world-id-state-bridge/) contracts which in turn also have to be connected to a valid [`world-id-contracts`](https://github.com/worldcoin/world-id-contracts/) deployment.
//!
//! ### Usage
//!
//! #### CLI
//!
//! Create a state_bridge_service.toml file which will hold the configuration parameters for the state bridge
//! service. You can use the example in the test as a template:
//!
//! ```toml
//! rpc_url = "127.0.0.1:8545"
//! private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
//! world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9"
//! bridge_configs = [
//! [
//! "Optimism",
//! # StateBridge Address
//! "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9",
//! # BridgedWorldID Address
//! "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9",
//! "127.0.0.1:8545",
//! ]
//! ]
//! relaying_period_seconds = 5
//! ```
//!
//! ```bash
//! cargo build --bin state-bridge-service --release
//! ./target/release/state-bridge-service --config <CONFIG>
//! ```
use std::fs;
use std::path::PathBuf;
use std::sync::Arc;
Expand All @@ -51,8 +16,8 @@ use state_bridge::root::IWorldIDIdentityManager;
use state_bridge::StateBridgeService;
use tracing::info;

/// The state bridge service propagates roots from the world tree. Frequency of root propagation is specified
/// by the relaying_period. This service will not propagate roots that have already been propagated before.
// The state bridge service propagates roots from the world tree. Frequency of root propagation is specified
// by the relaying_period. This service will not propagate roots that have already been propagated before.
#[derive(Parser, Debug)]
#[clap(
name = "State Bridge Service",
Expand All @@ -63,7 +28,7 @@ struct Options {
config: PathBuf,
}

/// Converts a u64 into a Duration using Duration::from_secs
// Converts a u64 into a Duration using Duration::from_secs
mod duration_seconds {
use std::time::Duration;

Expand Down Expand Up @@ -93,29 +58,29 @@ struct BridgeConfig {
bridged_rpc_url: String,
}

/// The config TOML file defines all the necessary parameters to spawn a state bridge service.
/// rpc_url - HTTP rpc url for an Ethereum node (string)
/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string)
/// world_id_address - WorldIDIdentityManager contract address (string)
/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings)
/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings)
/// relaying_period: propagateRoot() call period time in seconds (u64)
/// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number)
// The config TOML file defines all the necessary parameters to spawn a state bridge service.
// rpc_url - HTTP rpc url for an Ethereum node (string)
// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string)
// world_id_address - WorldIDIdentityManager contract address (string)
// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings)
// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings)
// relaying_period: propagateRoot() call period time in seconds (u64)
// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number)
#[derive(Deserialize, Serialize, Debug, Clone)]
struct Config {
/// RPC URL for the HTTP provider (World ID IdentityManager)
// RPC URL for the HTTP provider (World ID IdentityManager)
rpc_url: String,
/// Private key to use for the middleware signer
// Private key to use for the middleware signer
private_key: String,
/// `WorldIDIdentityManager` contract address
// `WorldIDIdentityManager` contract address
world_id_address: H160,
/// List of `StateBridge` and `BridgedWorldID` pair addresses
// List of `StateBridge` and `BridgedWorldID` pair addresses
bridge_configs: Vec<BridgeConfig>,
/// `propagateRoot()` call period time in seconds
// `propagateRoot()` call period time in seconds
#[serde(with = "duration_seconds")]
relaying_period_seconds: Duration,
/// Number of block confirmations required for the `propagateRoot` call on the `StateBridge`
/// contract
// Number of block confirmations required for the `propagateRoot` call on the `StateBridge`
// contract
#[serde(default = "default_block_confirmations")]
block_confirmations: usize,
}
Expand Down
29 changes: 1 addition & 28 deletions bin/tree_availability_service.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
//! # Tree Availability Service
//!
//! The tree availability service is able to create an in-memory representation of the World ID
//! merkle tree by syncing the state of the World ID contract `registerIdentities` and `deleteIdentities`
//! function calldata and `TreeChanged` events. Once it syncs the latest state of the state of the tree, it
//! is able to serve inclusion proofs on the `/inclusionProof` endpoint. It also keeps a historical roots list
//! of `tree_history_size` size in order to serve proofs against older tree roots (including the roots of
//! World IDs bridged to other networks).
//!
//! ### Usage
//!
//! #### CLI
//!
//! In order to run the tree availability service you can run the following commands
//!
//! ```bash
//! # Build the binary
//! cargo build --bin tree-availability-service --release
//! # Run the command
//! ./target/release/tree-availability-service
//! --tree-depth <TREE_DEPTH>
//! --tree-history-size <TREE_HISTORY_SIZE>
//! --dense-prefix-depth <DENSE_PREFIX_DEPTH>
//! --address <ADDRESS>
//! --creation-block <CREATION_BLOCK>
//! --rpc-endpoint <RPC_ENDPOINT>
use std::sync::Arc;

use clap::Parser;
Expand All @@ -34,7 +7,7 @@ use futures::stream::FuturesUnordered;
use futures::StreamExt;
use tree_availability::TreeAvailabilityService;

/// CLI interface for the Tree Availability Service
// CLI interface for the Tree Availability Service
#[derive(Parser, Debug)]
#[clap(
name = "Tree Availability Service",
Expand Down
4 changes: 2 additions & 2 deletions crates/state_bridge/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct StateBridge<M: Middleware + 'static> {
}

impl<M: Middleware> StateBridge<M> {
/// Constructor
/// Initializes a StateBridge
///
/// `state_bridge`: `StateBridge` contract interface
///
Expand All @@ -66,7 +66,7 @@ impl<M: Middleware> StateBridge<M> {
})
}

/// Constructor with address and middleware
/// Initializes a StateBridge with address and middleware
///
/// `bridge_address`: `StateBridge` contract address
///
Expand Down
4 changes: 2 additions & 2 deletions crates/state_bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<M> StateBridgeService<M>
where
M: Middleware,
{
/// ### Constructor for the `StateBridgeService`
/// Initializes the `StateBridgeService`
///
/// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager`
pub async fn new(
Expand All @@ -48,7 +48,7 @@ where
})
}

/// Constructor for the `StateBridgeService`
/// Initializes the `StateBridgeService`
///
/// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager`
///
Expand Down
4 changes: 2 additions & 2 deletions crates/state_bridge/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<M> WorldTreeRoot<M>
where
M: Middleware,
{
/// `WorldTreeRoot` constructor
/// Initializes `WorldTreeRoot`
///
/// `world_id_identity_manager`:`IWorldIDIdentityManager<M>` - `WorldIDIdentityManager` interface
pub async fn new(
Expand All @@ -51,7 +51,7 @@ where
})
}

/// `WorldTreeRoot` constructor from address and middleware
/// Initializes `WorldTreeRoot` from address and middleware
///
/// `world_id_identity_manager`:`IWorldIDIdentityManager<M>` - `WorldIDIdentityManager` interface
///
Expand Down
2 changes: 1 addition & 1 deletion crates/tree_availability/src/world_tree/block_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<M> BlockScanner<M>
where
M: Middleware,
{
/// Constructor
/// Initializes a BlockScanner
pub const fn new(
middleware: M,
window_size: u64,
Expand Down
2 changes: 1 addition & 1 deletion crates/tree_availability/src/world_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct WorldTree<M: Middleware> {
}

impl<M: Middleware> WorldTree<M> {
/// Constructor
/// Initializes WorldTree
pub fn new(
tree: PoseidonTree<Canonical>,
tree_history_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/tree_availability/src/world_tree/tree_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct TreeUpdate {
}

impl TreeData {
/// Constructor
/// Initializes TreeData
///
/// `tree`: Canonical in-memory tree
///
Expand Down
2 changes: 1 addition & 1 deletion crates/tree_availability/src/world_tree/tree_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct TreeUpdater<M: Middleware> {
}

impl<M: Middleware> TreeUpdater<M> {
/// Constructor
/// Initializes TreeUpdater
///
/// `address`: `WorldIDIdentityManager` contract address
///
Expand Down

0 comments on commit a2305e4

Please sign in to comment.