From be1a1ce4d4a7c90d65f272f6630fb6941c11ffad Mon Sep 17 00:00:00 2001 From: Chiara Seim Date: Fri, 18 Oct 2024 04:41:17 -0700 Subject: [PATCH] Rita client registration crate into exit trust root crate --- Cargo.lock | 31 ++++--------------- Cargo.toml | 1 - .../src/exits/server_list_signatures.rs | 6 ++-- exit_trust_root/Cargo.toml | 5 ++- .../src/client_db.rs | 5 +-- exit_trust_root/src/config.rs | 7 ++--- exit_trust_root/src/lib.rs | 30 +++++++++++++----- .../src/register_client_batch_loop.rs | 15 ++++++--- .../src/rita_client_registration.rs | 20 +++++------- integration_tests/Cargo.toml | 1 - integration_tests/src/contract_test.rs | 10 +++--- integration_tests/src/db_migration_test.rs | 6 ++-- integration_tests/src/registration_server.rs | 10 +++--- integration_tests/src/setup_utils/rita.rs | 4 +-- integration_tests/src/utils.rs | 2 +- rita_bin/Cargo.toml | 2 +- rita_bin/src/contract-util.rs | 12 +++---- rita_bin/src/exit.rs | 4 +-- rita_client_registration/Cargo.toml | 23 -------------- rita_db_migration/Cargo.toml | 2 +- rita_db_migration/src/lib.rs | 6 ++-- rita_exit/Cargo.toml | 1 - rita_exit/src/database/mod.rs | 4 +-- rita_exit/src/rita_loop/mod.rs | 4 +-- test_runner/Cargo.toml | 1 - 25 files changed, 93 insertions(+), 119 deletions(-) rename {rita_client_registration => exit_trust_root}/src/client_db.rs (98%) rename {rita_client_registration => exit_trust_root}/src/register_client_batch_loop.rs (94%) rename rita_client_registration/src/lib.rs => exit_trust_root/src/rita_client_registration.rs (96%) delete mode 100644 rita_client_registration/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 81b85fa31..07cba3442 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1356,8 +1356,10 @@ dependencies = [ name = "exit_trust_root" version = "0.21.5" dependencies = [ + "actix", "actix-web", "althea_types", + "awc", "clarity", "crypto_box", "env_logger", @@ -1365,12 +1367,13 @@ dependencies = [ "log", "openssl", "openssl-probe", - "rita_client_registration", + "phonenumber", "rustls 0.20.9", "rustls-pemfile 0.3.0", "serde", "serde_derive", "serde_json", + "tokio", "toml 0.5.11", "web30", ] @@ -1955,7 +1958,6 @@ dependencies = [ "petgraph", "phonenumber", "rita_client", - "rita_client_registration", "rita_common", "rita_db_migration", "rita_exit", @@ -3074,6 +3076,7 @@ dependencies = [ "diesel", "docopt", "env_logger", + "exit_trust_root", "flate2", "hex-literal", "ipnetwork", @@ -3084,7 +3087,6 @@ dependencies = [ "phonenumber", "r2d2", "rita_client", - "rita_client_registration", "rita_common", "rita_db_migration", "rita_exit", @@ -3134,25 +3136,6 @@ dependencies = [ "web30", ] -[[package]] -name = "rita_client_registration" -version = "0.1.0" -dependencies = [ - "actix", - "althea_types", - "awc", - "clarity", - "futures 0.3.31", - "lazy_static", - "log", - "num-traits", - "phonenumber", - "rand", - "serde", - "tokio", - "web30", -] - [[package]] name = "rita_common" version = "0.21.5" @@ -3208,9 +3191,9 @@ dependencies = [ "clarity", "diesel", "dotenv", + "exit_trust_root", "log", "r2d2", - "rita_client_registration", "serde", "serde_derive", "serde_json", @@ -3239,7 +3222,6 @@ dependencies = [ "num256", "phonenumber", "reqwest", - "rita_client_registration", "rita_common", "serde", "serde_derive", @@ -3933,7 +3915,6 @@ dependencies = [ "futures 0.3.31", "integration_tests", "log", - "rita_client_registration", "web30", ] diff --git a/Cargo.toml b/Cargo.toml index b3786e457..4591698b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ members = [ "rita_common", "rita_exit", "rita_client", - "rita_client_registration", "rita_db_migration", "rita_bin", "test_runner", diff --git a/althea_types/src/exits/server_list_signatures.rs b/althea_types/src/exits/server_list_signatures.rs index 9bb25c41f..2b71f7d6a 100644 --- a/althea_types/src/exits/server_list_signatures.rs +++ b/althea_types/src/exits/server_list_signatures.rs @@ -65,10 +65,12 @@ impl ExitServerList { match sig.recover(&hash) { Ok(addr) => { println!("Recovered address is {:?}", addr); - addr == key}, + addr == key + } Err(_) => { println!("Failed to recover address from signature"); - false}, + false + } } } else { println!("Signature is invalid"); diff --git a/exit_trust_root/Cargo.toml b/exit_trust_root/Cargo.toml index 5ffe86737..4b02068a5 100644 --- a/exit_trust_root/Cargo.toml +++ b/exit_trust_root/Cargo.toml @@ -25,11 +25,14 @@ clarity = "1.4" web30 = "1.4" crypto_box = "0.9" lazy_static = "1.5" +phonenumber = "0.3.6" +awc = "3.5" +actix = "0.13" +tokio = { version = "1.40", features = ["macros", "time"] } serde = "1.0" serde_derive = "1.0" serde_json = "1.0" toml = "0.5" -rita_client_registration = { path = "../rita_client_registration" } # we don't call or us OpenSSL directly in this codebase, but by adding # this dependency with this feature we can enforce that openssl is compiled # in 'vendored' mode all the way down the tree. What this means is that we use diff --git a/rita_client_registration/src/client_db.rs b/exit_trust_root/src/client_db.rs similarity index 98% rename from rita_client_registration/src/client_db.rs rename to exit_trust_root/src/client_db.rs index 73a81a812..00b54e484 100644 --- a/rita_client_registration/src/client_db.rs +++ b/exit_trust_root/src/client_db.rs @@ -3,7 +3,6 @@ //! exit and client routers can read it to coordinate user setup and two way key exchange with the blockchain //! as the trusted party -use crate::convert_althea_types_to_web3_error; use althea_types::{ExitIdentity, Identity, WgKey}; use clarity::{ abi::{encode_call, AbiToken}, @@ -17,10 +16,12 @@ use web30::{ types::{SendTxOption, TransactionRequest}, }; +use crate::rita_client_registration::convert_althea_types_to_web3_error; + /// The EVM integer size pub const WORD_SIZE: usize = 32; -pub async fn get_all_regsitered_clients( +pub async fn get_all_registered_clients( web30: &Web3, requester_address: Address, contract: Address, diff --git a/exit_trust_root/src/config.rs b/exit_trust_root/src/config.rs index dc558330d..736c37f1a 100644 --- a/exit_trust_root/src/config.rs +++ b/exit_trust_root/src/config.rs @@ -1,13 +1,12 @@ -use std::{fs::File, io::Read}; -use lazy_static::lazy_static; use althea_types::WgKey; use clarity::PrivateKey; +use lazy_static::lazy_static; use log::error; use serde::{Deserialize, Serialize}; +use std::{fs::File, io::Read}; use crate::DEVELOPMENT; - ///Struct containing settings for Exit root server #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ConfigStruct { @@ -43,7 +42,7 @@ pub fn load_config() -> ConfigStruct { return ConfigStruct { clarity_private_key: PrivateKey::from_bytes([1u8; 32]).unwrap(), wg_private_key: WgKey::from([2; 32]), - } + }; } else { "/etc/exit_root_server.toml" }; diff --git a/exit_trust_root/src/lib.rs b/exit_trust_root/src/lib.rs index 739c386d0..4d2f8b798 100644 --- a/exit_trust_root/src/lib.rs +++ b/exit_trust_root/src/lib.rs @@ -2,9 +2,9 @@ use actix_web::rt::System; use actix_web::{get, web, App, HttpResponse, HttpServer, Responder}; use althea_types::{ExitServerList, SignedExitServerList}; use clarity::Address; +use client_db::get_exits_list; use config::CONFIG; use log::info; -use rita_client_registration::client_db::get_exits_list; use rustls::ServerConfig; use std::collections::HashMap; use std::net::{IpAddr, Ipv4Addr}; @@ -15,7 +15,10 @@ use tls::{load_certs, load_rustls_private_key}; use web30::client::Web3; use web30::jsonrpc::error::Web3Error; +pub mod client_db; pub mod config; +pub mod register_client_batch_loop; +pub mod rita_client_registration; pub mod tls; const RPC_SERVER: &str = "https://dai.althea.net"; @@ -71,7 +74,10 @@ async fn retrieve_exit_server_list( true => { let node_ip = IpAddr::V4(Ipv4Addr::new(7, 7, 7, 1)); let web3_url = format!("http://{}:8545", node_ip); - info!("Our address is {:?}", CONFIG.clarity_private_key.to_address()); + info!( + "Our address is {:?}", + CONFIG.clarity_private_key.to_address() + ); get_exits_list( &Web3::new(&web3_url, WEB3_TIMEOUT), CONFIG.clarity_private_key.to_address(), @@ -97,7 +103,10 @@ async fn retrieve_exit_server_list( exit_list: exits, created: std::time::SystemTime::now(), }; - println!("Signing exit list with PUBKEY: {:?}", CONFIG.clarity_private_key.to_address()); + println!( + "Signing exit list with PUBKEY: {:?}", + CONFIG.clarity_private_key.to_address() + ); let cache_value = exit_list.sign(CONFIG.clarity_private_key); // add this new exit list to the cache @@ -129,8 +138,10 @@ pub fn start_exit_trust_root_server() { }); info!("Starting exit trust root server on {:?}", EXIT_ROOT_DOMAIN); let server = if SSL { - let cert_chain = - load_certs(&format!("/etc/letsencrypt/live/{}/fullchain.pem", EXIT_ROOT_DOMAIN)); + let cert_chain = load_certs(&format!( + "/etc/letsencrypt/live/{}/fullchain.pem", + EXIT_ROOT_DOMAIN + )); let keys = load_rustls_private_key(&format!( "/etc/letsencrypt/live/{}/privkey.pem", EXIT_ROOT_DOMAIN @@ -143,11 +154,16 @@ pub fn start_exit_trust_root_server() { info!("Binding to SSL"); server - .bind_rustls(format!("{}:{}", EXIT_ROOT_DOMAIN, SERVER_PORT), config.clone()) + .bind_rustls( + format!("{}:{}", EXIT_ROOT_DOMAIN, SERVER_PORT), + config.clone(), + ) .unwrap() } else { info!("Binding to {}:{}", EXIT_ROOT_DOMAIN, SERVER_PORT); - server.bind(format!("{}:{}", EXIT_ROOT_DOMAIN, SERVER_PORT)).unwrap() + server + .bind(format!("{}:{}", EXIT_ROOT_DOMAIN, SERVER_PORT)) + .unwrap() }; let _ = server.run().await; diff --git a/rita_client_registration/src/register_client_batch_loop.rs b/exit_trust_root/src/register_client_batch_loop.rs similarity index 94% rename from rita_client_registration/src/register_client_batch_loop.rs rename to exit_trust_root/src/register_client_batch_loop.rs index c527cb258..da8f56ecb 100644 --- a/rita_client_registration/src/register_client_batch_loop.rs +++ b/exit_trust_root/src/register_client_batch_loop.rs @@ -1,10 +1,7 @@ -use crate::{ - client_db::{add_users_to_registered_list, get_all_regsitered_clients}, - get_reg_queue, remove_client_from_reg_queue, REGISTRATION_LOOP_SPEED, TX_TIMEOUT, WEB3_TIMEOUT, -}; use actix::System; use althea_types::Identity; use clarity::{Address, PrivateKey}; +use log::{error, info}; use std::{ collections::HashSet, thread, @@ -12,6 +9,14 @@ use std::{ }; use web30::{client::Web3, types::SendTxOption}; +use crate::{ + client_db::{add_users_to_registered_list, get_all_registered_clients}, + rita_client_registration::{ + get_reg_queue, remove_client_from_reg_queue, REGISTRATION_LOOP_SPEED, TX_TIMEOUT, + WEB3_TIMEOUT, + }, +}; + pub const MAX_BATCH_SIZE: usize = 75; /// Utility function used to easily perform O(1) lookups against the identities list @@ -55,7 +60,7 @@ pub fn register_client_batch_loop( // get a copy of all existing clients, we do this in order to handle a potential future edgecase where more than one registration server // is operating at a time and the same user attempts to register to more than one before the transaction can be sent. Without this check // once a already registered user is in the queue all future transactions would fail and the server would no longer operate correctly - let all_clients = match get_all_regsitered_clients(&web3, our_private_key.to_address(), contract_addr).await { + let all_clients = match get_all_registered_clients(&web3, our_private_key.to_address(), contract_addr).await { Ok(all_clients) => all_clients, Err(e) => { error!("Failed to get list of already registered clients {:?}, retrying", e); diff --git a/rita_client_registration/src/lib.rs b/exit_trust_root/src/rita_client_registration.rs similarity index 96% rename from rita_client_registration/src/lib.rs rename to exit_trust_root/src/rita_client_registration.rs index f40dbb7ae..c182a102c 100644 --- a/rita_client_registration/src/lib.rs +++ b/exit_trust_root/src/rita_client_registration.rs @@ -1,6 +1,10 @@ use althea_types::{error::AltheaTypesError, ExitClientIdentity, Identity, WgKey}; use awc::error::JsonPayloadError; use awc::error::SendRequestError; +use lazy_static::lazy_static; +use log::error; +use log::info; +use log::trace; use phonenumber::PhoneNumber; use serde::{Deserialize, Serialize}; use std::{ @@ -12,22 +16,14 @@ use std::{ }; use web30::jsonrpc::error::Web3Error; -#[macro_use] -extern crate log; -#[macro_use] -extern crate lazy_static; - -pub mod client_db; -pub mod register_client_batch_loop; - lazy_static! { /// A map that stores number of texts sent to a client during registration static ref TEXTS_SENT: Arc>> = Arc::new(RwLock::new(HashMap::new())); static ref REGISTER_QUEUE: Arc>> = Arc::new(RwLock::new(HashSet::new())); } -const REGISTRATION_LOOP_SPEED: Duration = Duration::from_secs(10); -const WEB3_TIMEOUT: Duration = Duration::from_secs(15); +pub const REGISTRATION_LOOP_SPEED: Duration = Duration::from_secs(10); +pub const WEB3_TIMEOUT: Duration = Duration::from_secs(15); pub const TX_TIMEOUT: Duration = Duration::from_secs(60); /// Return struct from check_text and Send Text. Verified indicates status from api http req, @@ -97,11 +93,11 @@ pub fn add_client_to_reg_queue(id: Identity) { REGISTER_QUEUE.write().unwrap().insert(id); } -fn remove_client_from_reg_queue(id: Identity) { +pub fn remove_client_from_reg_queue(id: Identity) { REGISTER_QUEUE.write().unwrap().remove(&id); } -fn get_reg_queue() -> Vec { +pub fn get_reg_queue() -> Vec { REGISTER_QUEUE.read().unwrap().clone().into_iter().collect() } diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 4e0d3caac..949db9a20 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -22,7 +22,6 @@ rita_client = { path = "../rita_client", features = ["dev_env"] } rita_common = { path = "../rita_common", features = ["integration_test"] } rita_exit = { path = "../rita_exit", features = ["dev_env"] } exit_trust_root = { path = "../exit_trust_root", features = ["development"] } -rita_client_registration = { path = "../rita_client_registration" } rita_db_migration = { path = "../rita_db_migration" } ctrlc = { version = "3.4.5", features = ["termination"] } diesel = { version = "1.4", features = ["postgres", "r2d2"] } diff --git a/integration_tests/src/contract_test.rs b/integration_tests/src/contract_test.rs index 27c668515..bb6f4539a 100644 --- a/integration_tests/src/contract_test.rs +++ b/integration_tests/src/contract_test.rs @@ -1,9 +1,9 @@ use althea_types::random_identity; use althea_types::{regions::Regions, ExitIdentity, SystemChain}; use clarity::{Address, PrivateKey}; -use rita_client_registration::client_db::{ +use exit_trust_root::client_db::{ add_exit_admin, add_exits_to_registration_list, add_users_to_registered_list, - check_and_add_user_admin, get_all_regsitered_clients, get_exits_list, + check_and_add_user_admin, get_all_registered_clients, get_exits_list, get_registered_client_using_wgkey, }; use std::collections::HashSet; @@ -199,7 +199,7 @@ pub async fn validate_contract_user_functionality(db_addr: Address) { .unwrap(); // Try requests when there are no users present - let res = get_all_regsitered_clients(&contact, miner_pub_key, db_addr).await; + let res = get_all_registered_clients(&contact, miner_pub_key, db_addr).await; assert_eq!(res.unwrap(), vec![]); @@ -247,7 +247,7 @@ pub async fn validate_contract_user_functionality(db_addr: Address) { assert_eq!(user_1, res); // Request a list of all reg users (should be an array of one entry) - let res = get_all_regsitered_clients(&contact, miner_pub_key, db_addr) + let res = get_all_registered_clients(&contact, miner_pub_key, db_addr) .await .unwrap(); @@ -336,7 +336,7 @@ pub async fn validate_contract_user_functionality(db_addr: Address) { ) .await; - let res = get_all_regsitered_clients(&contact, miner_pub_key, db_addr) + let res = get_all_registered_clients(&contact, miner_pub_key, db_addr) .await .unwrap(); diff --git a/integration_tests/src/db_migration_test.rs b/integration_tests/src/db_migration_test.rs index b2b6cc633..463953d81 100644 --- a/integration_tests/src/db_migration_test.rs +++ b/integration_tests/src/db_migration_test.rs @@ -6,8 +6,8 @@ use std::{ use althea_types::random_identity; use clarity::{Address, PrivateKey}; use diesel::{PgConnection, RunQueryDsl}; -use rita_client_registration::{ - client_db::{check_and_add_user_admin, get_all_regsitered_clients}, +use exit_trust_root::{ + client_db::{check_and_add_user_admin, get_all_registered_clients}, register_client_batch_loop::register_client_batch_loop, }; use rita_db_migration::{ @@ -129,7 +129,7 @@ async fn validate_db_migration( let start = Instant::now(); loop { - let client_vec = get_all_regsitered_clients(&contact, miner_pub_key, althea_db_addr).await; + let client_vec = get_all_registered_clients(&contact, miner_pub_key, althea_db_addr).await; if client_vec.is_err() { if Instant::now() - start > Duration::from_secs(300) { panic!("Failed to migrate clients after waiting for 5 mins"); diff --git a/integration_tests/src/registration_server.rs b/integration_tests/src/registration_server.rs index f74158071..1ca0b4586 100644 --- a/integration_tests/src/registration_server.rs +++ b/integration_tests/src/registration_server.rs @@ -7,19 +7,17 @@ use actix_web::{ }; use althea_types::ExitClientIdentity; use clarity::{Address, PrivateKey}; -use rita_client_registration::{ - client_db::check_and_add_user_admin, handle_sms_registration, register_client_batch_loop, +use exit_trust_root::{ + client_db::check_and_add_user_admin, register_client_batch_loop::register_client_batch_loop, + rita_client_registration::handle_sms_registration, }; use web30::client::Web3; +use crate::utils::REGISTRATION_SERVER_KEY; use crate::{ payments_eth::WEB3_TIMEOUT, utils::{get_eth_node, get_test_runner_magic_phone, TX_TIMEOUT}, }; -use crate::{ - registration_server::register_client_batch_loop::register_client_batch_loop, - utils::REGISTRATION_SERVER_KEY, -}; pub const REGISTRATION_PORT_SERVER: u16 = 40400; diff --git a/integration_tests/src/setup_utils/rita.rs b/integration_tests/src/setup_utils/rita.rs index 7dfdbd0d4..2bb4491b2 100644 --- a/integration_tests/src/setup_utils/rita.rs +++ b/integration_tests/src/setup_utils/rita.rs @@ -306,9 +306,7 @@ pub fn spawn_exit_root() { .app_data(web_data.clone()) }); info!("Starting exit trust root server on 10.0.0.1:4050"); - let server = server - .bind("10.0.0.1:4050") - .unwrap(); + let server = server.bind("10.0.0.1:4050").unwrap(); successful_start.store(true, Relaxed); let _ = server.run().await; }); diff --git a/integration_tests/src/utils.rs b/integration_tests/src/utils.rs index 7e7f37686..8b97ee918 100644 --- a/integration_tests/src/utils.rs +++ b/integration_tests/src/utils.rs @@ -23,6 +23,7 @@ use awc::http::StatusCode; use babel_monitor::{open_babel_stream, parse_routes, structs::Route}; use clarity::{Address, PrivateKey as ClarityPrivkey, Transaction, Uint256}; use deep_space::{Address as AltheaAddress, Coin, Contact, CosmosPrivateKey, PrivateKey}; +use exit_trust_root::client_db::{add_exit_admin, add_exits_to_registration_list}; use futures::future::join_all; use ipnetwork::IpNetwork; use lazy_static; @@ -32,7 +33,6 @@ use nix::{ sys::stat::Mode, }; use phonenumber::PhoneNumber; -use rita_client_registration::client_db::{add_exit_admin, add_exits_to_registration_list}; use rita_common::{ debt_keeper::GetDebtsResult, payment_validator::{ALTHEA_CHAIN_PREFIX, ALTHEA_CONTACT_TIMEOUT}, diff --git a/rita_bin/Cargo.toml b/rita_bin/Cargo.toml index fbf8f5e17..6cc4b4124 100644 --- a/rita_bin/Cargo.toml +++ b/rita_bin/Cargo.toml @@ -45,10 +45,10 @@ r2d2 = "0.8" ctrlc = { version = "3.4.5", features = ["termination"] } rita_common = { path = "../rita_common", default-features = false } rita_client = { path = "../rita_client", default-features = false } -rita_client_registration = { path = "../rita_client_registration", default-features = false } rita_db_migration = { path = "../rita_db_migration", default-features = false } rita_exit = { path = "../rita_exit", default-features = false } rita_extender = { path = "../rita_extender", default-features = false } +exit_trust_root = { path = "../exit_trust_root" } flate2 = { version = "1.0", features = [ "rust_backend", ], default-features = false } diff --git a/rita_bin/src/contract-util.rs b/rita_bin/src/contract-util.rs index c6f86a5cc..18062849e 100644 --- a/rita_bin/src/contract-util.rs +++ b/rita_bin/src/contract-util.rs @@ -13,12 +13,12 @@ use althea_types::SystemChain; use clarity::PrivateKey; use diesel::RunQueryDsl; use docopt::Docopt; +use exit_trust_root::client_db::add_exits_to_registration_list; +use exit_trust_root::client_db::add_users_to_registered_list; +use exit_trust_root::client_db::get_all_registered_clients; +use exit_trust_root::register_client_batch_loop::get_clients_hashset; +use exit_trust_root::register_client_batch_loop::MAX_BATCH_SIZE; use log::{error, info}; -use rita_client_registration::client_db::add_exits_to_registration_list; -use rita_client_registration::{ - client_db::{add_users_to_registered_list, get_all_regsitered_clients}, - register_client_batch_loop::{get_clients_hashset, MAX_BATCH_SIZE}, -}; use rita_db_migration::{ get_database_connection, models::{self, Client}, @@ -72,7 +72,7 @@ async fn main() { // is operating at a time and the same user attempts to register to more than one before the transaction can be sent. Without this check // once a already registered user is in the queue all future transactions would fail and the server would no longer operate correctly let all_contract_clients = - match get_all_regsitered_clients(&web3, address, contract_addr).await { + match get_all_registered_clients(&web3, address, contract_addr).await { Ok(all_clients) => all_clients, Err(e) => { panic!("Failed to get list of already registered clients {:?}", e); diff --git a/rita_bin/src/exit.rs b/rita_bin/src/exit.rs index f1b2d5d53..d165e237d 100644 --- a/rita_bin/src/exit.rs +++ b/rita_bin/src/exit.rs @@ -15,6 +15,7 @@ use althea_types::Identity; use clarity::Address; +use exit_trust_root::client_db::get_all_registered_clients; #[cfg(feature = "jemalloc")] use jemallocator::Jemalloc; use rita_exit::rita_loop::start_rita_exit_list_endpoint; @@ -29,7 +30,6 @@ static GLOBAL: Jemalloc = Jemalloc; extern crate log; use docopt::Docopt; -use rita_client_registration::client_db::get_all_regsitered_clients; use rita_common::debt_keeper::save_debt_on_shutdown; use rita_common::logging::enable_remote_logging; use rita_common::rita_loop::get_web3_server; @@ -222,7 +222,7 @@ async fn get_registered_users() -> Result, Web3Error> { let contract_address = settings::get_rita_exit() .exit_network .registered_users_contract_addr; - get_all_regsitered_clients(&web3, our_address, contract_address).await + get_all_registered_clients(&web3, our_address, contract_address).await } async fn check_balance( diff --git a/rita_client_registration/Cargo.toml b/rita_client_registration/Cargo.toml deleted file mode 100644 index fe076253a..000000000 --- a/rita_client_registration/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "rita_client_registration" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -lazy_static = "1.5" -althea_types = { path = "../althea_types" } -log = { version = "0.4", features = ["release_max_level_info"] } -serde = "1.0" -clarity = "1.4" -phonenumber = "0.3.6" -awc = "3.5" -web30 = "1.4" -tokio = { version = "1.40", features = ["macros", "time"] } -actix = "0.13" -futures = { version = "0.3", features = ["compat"] } -num-traits = "0.2" - -[dev-dependencies] -rand = "0.8" diff --git a/rita_db_migration/Cargo.toml b/rita_db_migration/Cargo.toml index 588a44031..f7af054aa 100644 --- a/rita_db_migration/Cargo.toml +++ b/rita_db_migration/Cargo.toml @@ -14,6 +14,6 @@ althea_types = { path = "../althea_types" } serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -rita_client_registration = { path = "../rita_client_registration" } +exit_trust_root = { path = "../exit_trust_root" } clarity = "1.4" web30 = "1.4" diff --git a/rita_db_migration/src/lib.rs b/rita_db_migration/src/lib.rs index f57943d2a..25ce06e37 100644 --- a/rita_db_migration/src/lib.rs +++ b/rita_db_migration/src/lib.rs @@ -16,9 +16,11 @@ use althea_types::Identity; use clarity::Address; use diesel::{r2d2::ConnectionManager, PgConnection, RunQueryDsl}; use error::RitaDBMigrationError; +use exit_trust_root::{ + client_db::get_all_registered_clients, rita_client_registration::add_client_to_reg_queue, +}; use models::Client; use r2d2::PooledConnection; -use rita_client_registration::{add_client_to_reg_queue, client_db::get_all_regsitered_clients}; use web30::client::Web3; const WEB3_TIMEOUT: Duration = Duration::from_secs(60); @@ -63,7 +65,7 @@ async fn add_clients_to_reg_queue( contract: Address, ) { let existing_users: HashSet = - match get_all_regsitered_clients(contact, requester_address, contract).await { + match get_all_registered_clients(contact, requester_address, contract).await { Ok(a) => HashSet::from_iter(a.iter().cloned()), Err(e) => { error!( diff --git a/rita_exit/Cargo.toml b/rita_exit/Cargo.toml index a5093c393..9ec5bd212 100644 --- a/rita_exit/Cargo.toml +++ b/rita_exit/Cargo.toml @@ -9,7 +9,6 @@ license = "Apache-2.0" num256 = "0.5" exit_trust_root = { path = "../exit_trust_root" } rita_common = { path = "../rita_common" } -rita_client_registration = { path = "../rita_client_registration" } althea_kernel_interface = { path = "../althea_kernel_interface" } althea_types = { path = "../althea_types" } settings = { path = "../settings" } diff --git a/rita_exit/src/database/mod.rs b/rita_exit/src/database/mod.rs index d1c83cc29..0988aed22 100644 --- a/rita_exit/src/database/mod.rs +++ b/rita_exit/src/database/mod.rs @@ -30,8 +30,8 @@ use althea_types::Identity; use althea_types::WgKey; use althea_types::{ExitClientDetails, ExitClientIdentity, ExitDetails, ExitState, ExitVerifMode}; use clarity::Address; -use rita_client_registration::client_db::get_registered_client_using_wgkey; -use rita_client_registration::ExitSignupReturn; +use exit_trust_root::client_db::get_registered_client_using_wgkey; +use exit_trust_root::rita_client_registration::ExitSignupReturn; use rita_common::blockchain_oracle::calculate_close_thresh; use rita_common::debt_keeper::get_debts_list; use rita_common::debt_keeper::DebtAction; diff --git a/rita_exit/src/rita_loop/mod.rs b/rita_exit/src/rita_loop/mod.rs index 57b1b7f4f..83ef493a3 100644 --- a/rita_exit/src/rita_loop/mod.rs +++ b/rita_exit/src/rita_loop/mod.rs @@ -23,7 +23,7 @@ use althea_kernel_interface::wg_iface_counter::WgUsage; use althea_kernel_interface::ExitClient; use althea_types::{Identity, WgKey}; use babel_monitor::{open_babel_stream, parse_routes}; -use rita_client_registration::client_db::get_all_regsitered_clients; +use exit_trust_root::client_db::get_all_registered_clients; use rita_common::debt_keeper::DebtAction; use rita_common::rita_loop::get_web3_server; use settings::exit::{EXIT_LIST_IP, EXIT_LIST_PORT}; @@ -117,7 +117,7 @@ async fn update_client_list(reg_clients_list: Vec) -> Vec { let web3 = web30::client::Web3::new(&full_node, Duration::from_secs(5)); let get_clients_benchmark = Instant::now(); - match get_all_regsitered_clients(&web3, our_address, contract_address).await { + match get_all_registered_clients(&web3, our_address, contract_address).await { Ok(list) => { info!( "Finished Rita get clients, got {:?} clients in {}ms", diff --git a/test_runner/Cargo.toml b/test_runner/Cargo.toml index e4da6f4c3..ceab78030 100644 --- a/test_runner/Cargo.toml +++ b/test_runner/Cargo.toml @@ -18,7 +18,6 @@ integration_tests = { path = "../integration_tests" } althea_types = { path = "../althea_types" } althea_kernel_interface = { path = "../althea_kernel_interface" } deep_space = { version = "2", features = ["althea"] } -rita_client_registration = { path = "../rita_client_registration" } web30 = "1.4" clarity = "1.4"