From a2305e4e92f7972ee2a7c5d66275081e92c66d98 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Mon, 30 Oct 2023 15:03:02 +0000 Subject: [PATCH] remove docstring on binaries, rename new --- bin/state_bridge_service.rs | 71 +++++-------------- bin/tree_availability_service.rs | 29 +------- crates/state_bridge/src/bridge.rs | 4 +- crates/state_bridge/src/lib.rs | 4 +- crates/state_bridge/src/root.rs | 4 +- .../src/world_tree/block_scanner.rs | 2 +- .../tree_availability/src/world_tree/mod.rs | 2 +- .../src/world_tree/tree_data.rs | 2 +- .../src/world_tree/tree_updater.rs | 2 +- 9 files changed, 29 insertions(+), 91 deletions(-) diff --git a/bin/state_bridge_service.rs b/bin/state_bridge_service.rs index ae9289ac..60b108cc 100644 --- a/bin/state_bridge_service.rs +++ b/bin/state_bridge_service.rs @@ -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 -//! ``` - use std::fs; use std::path::PathBuf; use std::sync::Arc; @@ -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", @@ -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; @@ -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, - /// `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, } diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 919b144c..4c1657e4 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -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-history-size -//! --dense-prefix-depth -//! --address
-//! --creation-block -//! --rpc-endpoint - use std::sync::Arc; use clap::Parser; @@ -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", diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 929482f4..91432ca3 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -43,7 +43,7 @@ pub struct StateBridge { } impl StateBridge { - /// Constructor + /// Initializes a StateBridge /// /// `state_bridge`: `StateBridge` contract interface /// @@ -66,7 +66,7 @@ impl StateBridge { }) } - /// Constructor with address and middleware + /// Initializes a StateBridge with address and middleware /// /// `bridge_address`: `StateBridge` contract address /// diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index 01b1df49..a724d937 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -35,7 +35,7 @@ impl StateBridgeService where M: Middleware, { - /// ### Constructor for the `StateBridgeService` + /// Initializes the `StateBridgeService` /// /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` pub async fn new( @@ -48,7 +48,7 @@ where }) } - /// Constructor for the `StateBridgeService` + /// Initializes the `StateBridgeService` /// /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` /// diff --git a/crates/state_bridge/src/root.rs b/crates/state_bridge/src/root.rs index 82b904c7..5c16e8d2 100644 --- a/crates/state_bridge/src/root.rs +++ b/crates/state_bridge/src/root.rs @@ -37,7 +37,7 @@ impl WorldTreeRoot where M: Middleware, { - /// `WorldTreeRoot` constructor + /// Initializes `WorldTreeRoot` /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface pub async fn new( @@ -51,7 +51,7 @@ where }) } - /// `WorldTreeRoot` constructor from address and middleware + /// Initializes `WorldTreeRoot` from address and middleware /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface /// diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 4b001818..4181e55e 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -19,7 +19,7 @@ impl BlockScanner where M: Middleware, { - /// Constructor + /// Initializes a BlockScanner pub const fn new( middleware: M, window_size: u64, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index 7ff23dd0..7a2e9c5d 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -33,7 +33,7 @@ pub struct WorldTree { } impl WorldTree { - /// Constructor + /// Initializes WorldTree pub fn new( tree: PoseidonTree, tree_history_size: usize, diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 925aff78..f939f88c 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -25,7 +25,7 @@ pub struct TreeUpdate { } impl TreeData { - /// Constructor + /// Initializes TreeData /// /// `tree`: Canonical in-memory tree /// diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 4d17c90d..5a3e9f1e 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -34,7 +34,7 @@ pub struct TreeUpdater { } impl TreeUpdater { - /// Constructor + /// Initializes TreeUpdater /// /// `address`: `WorldIDIdentityManager` contract address ///