diff --git a/bin/darkfid/darkfid_config.toml b/bin/darkfid/darkfid_config.toml index 85bdbd2e9..574741a6d 100644 --- a/bin/darkfid/darkfid_config.toml +++ b/bin/darkfid/darkfid_config.toml @@ -9,6 +9,9 @@ # Blockchain network to use network = "testnet" +## ===================== +## TESTNET CONFIGURATION +## ===================== # Testnet blockchain network configuration [network_config."testnet"] # Path to the blockchain database directory @@ -38,15 +41,23 @@ txs_batch_size = 50 ## Testnet JSON-RPC settings [network_config."testnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:8340" +rpc_listen = "tcp://127.0.0.1:18345" # Disabled RPC methods -rpc_disabled_methods = ["p2p.get_info"] +#rpc_disabled_methods = [] + +## Testnet management JSON-RPC settings +[network_config."testnet".management_rpc] +# JSON-RPC listen URL +rpc_listen = "tcp://127.0.0.1:18346" + +# Disabled RPC methods +#rpc_disabled_methods = [] ## Testnet JSON-RPC settings for stratum mining requests (optional) #[network_config."testnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -#rpc_listen = "tcp://127.0.0.1:8341" +#rpc_listen = "tcp://127.0.0.1:18347" # Disabled RPC methods (stratum mining) #rpc_disabled_methods = [] @@ -54,7 +65,7 @@ rpc_disabled_methods = ["p2p.get_info"] ## Testnet JSON-RPC settings for p2pool merge mining requests (optional) #[network_config."testnet".mm_rpc] # JSON-RPC listen URL (merge mining) -#rpc_listen = "http+tcp://127.0.0.1:8341" +#rpc_listen = "http+tcp://127.0.0.1:18348" # Disabled RPC methods (merge mining) #rpc_disabled_methods = [] @@ -109,41 +120,41 @@ active_profiles = ["tor"] [network_config."testnet".net.profiles."tcp+tls"] # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses -seeds = ["tcp+tls://lilith0.dark.fi:8342", "tcp+tls://lilith1.dark.fi:8342"] +seeds = ["tcp+tls://lilith0.dark.fi:18340", "tcp+tls://lilith1.dark.fi:18340"] # Peer nodes to manually connect to #peers = [] # P2P accept addresses the instance listens on for inbound connections # You can also use an IPv6 address -#inbound = ["tcp+tls://0.0.0.0:8342"] +#inbound = ["tcp+tls://0.0.0.0:18340"] # IPv6 version: -#inbound = ["tcp+tls://[::]:8342"] +#inbound = ["tcp+tls://[::]:18340"] # Combined: -#inbound = ["tcp+tls://0.0.0.0:8342", "tcp+tls://[::]:8342"] +#inbound = ["tcp+tls://0.0.0.0:18340", "tcp+tls://[::]:18340"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. # You can also use an IPv6 address -#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8342"] +#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:18340"] # IPv6 version: -#external_addrs = ["tcp+tls://[ipv6 address here]:8342"] +#external_addrs = ["tcp+tls://[ipv6 address here]:18340"] # Combined: -#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8342", "tcp+tls://[ipv6 address here]:8342"] +#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:18340", "tcp+tls://[ipv6 address here]:18340"] [network_config."testnet".net.profiles."tor"] # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses seeds = [ - "tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:8343", - "tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:8343", + "tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:18341", + "tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:18341", ] # Peer nodes to manually connect to #peers = [] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tor://127.0.0.1:8342"] +#inbound = ["tor://127.0.0.1:18341"] [network_config."testnet".net.profiles."i2p"] # Seed nodes to connect to for peer discovery and/or adversising our @@ -154,18 +165,18 @@ seeds = [ #peers = [] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tcp://127.0.0.1:25551"] +#inbound = ["tcp://127.0.0.1:18342"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. -#external_addrs = ["i2p://youraddress.b32.i2p:25551"] +#external_addrs = ["i2p://youraddress.b32.i2p:18342"] [network_config."testnet".net.profiles."socks5"] # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses seeds = [ - "socks5://127.0.0.1:9050/g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:8343", - "socks5://127.0.0.1:9050/yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:8343", + "socks5://127.0.0.1:9050/g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:18341", + "socks5://127.0.0.1:9050/yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:18341", ] # Peer nodes to manually connect to @@ -175,8 +186,8 @@ seeds = [ # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses seeds = [ - #"socks5+tls://127.0.0.1:9050/lilith0.dark.fi:8342", - #"socks5+tls://127.0.0.1:1080/lilith1.dark.fi:8342" + #"socks5+tls://127.0.0.1:9050/lilith0.dark.fi:18340", + #"socks5+tls://127.0.0.1:1080/lilith1.dark.fi:18340" ] # Peer nodes to manually connect to @@ -186,13 +197,16 @@ seeds = [ # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses seeds = [ - "tor+tls://lilith0.dark.fi:8342", - "tor+tls://lilith1.dark.fi:8342" + "tor+tls://lilith0.dark.fi:18340", + "tor+tls://lilith1.dark.fi:18340" ] # Peer nodes to manually connect to #peers = [] +## ===================== +## MAINNET CONFIGURATION +## ===================== # Mainnet blockchain network configuration [network_config."mainnet"] # Path to the blockchain database directory @@ -222,15 +236,23 @@ txs_batch_size = 50 ## Mainnet JSON-RPC settings [network_config."mainnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:8440" +rpc_listen = "tcp://127.0.0.1:8345" # Disabled RPC methods -rpc_disabled_methods = ["p2p.get_info"] +#rpc_disabled_methods = [] + +## Mainnet management JSON-RPC settings +[network_config."mainnet".management_rpc] +# JSON-RPC listen URL +rpc_listen = "tcp://127.0.0.1:8346" + +# Disabled RPC methods +#rpc_disabled_methods = [] ## Mainnet JSON-RPC settings for stratum mining requests (optional) #[network_config."mainnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -#rpc_listen = "tcp://127.0.0.1:8441" +#rpc_listen = "tcp://127.0.0.1:8347" # Disabled RPC methods (stratum mining) #rpc_disabled_methods = [] @@ -238,7 +260,7 @@ rpc_disabled_methods = ["p2p.get_info"] ## Mainnet JSON-RPC settings for p2pool merge mining requests (optional) #[network_config."mainnet".mm_rpc] # JSON-RPC listen URL (merge mining) -#rpc_listen = "http+tcp://127.0.0.1:8441" +#rpc_listen = "http+tcp://127.0.0.1:8348" # Disabled RPC methods (merge mining) #rpc_disabled_methods = [] @@ -299,27 +321,27 @@ active_profiles = ["tor"] [network_config."mainnet".net.profiles."tcp+tls"] # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses -seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"] +seeds = ["tcp+tls://lilith0.dark.fi:8340", "tcp+tls://lilith1.dark.fi:8340"] # Peer nodes to manually connect to #peers = [] # P2P accept addresses the instance listens on for inbound connections # You can also use an IPv6 address -#inbound = ["tcp+tls://0.0.0.0:8442"] +#inbound = ["tcp+tls://0.0.0.0:8340"] # IPv6 version: -#inbound = ["tcp+tls://[::]:8442"] +#inbound = ["tcp+tls://[::]:8340"] # Combined: -#inbound = ["tcp+tls://0.0.0.0:8442", "tcp+tls://[::]:8442"] +#inbound = ["tcp+tls://0.0.0.0:8340", "tcp+tls://[::]:8340"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. # You can also use an IPv6 address -#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8442"] +#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8340"] # IPv6 version: -#external_addrs = ["tcp+tls://[ipv6 address here]:8442"] +#external_addrs = ["tcp+tls://[ipv6 address here]:8340"] # Combined: -#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8442", "tcp+tls://[ipv6 address here]:8442"] +#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8340", "tcp+tls://[ipv6 address here]:8340"] [network_config."mainnet".net.profiles."tor"] # Seed nodes to connect to for peer discovery and/or adversising our @@ -330,7 +352,7 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"] #peers = [] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tor://127.0.0.1:8442"] +#inbound = ["tor://127.0.0.1:8341"] [network_config."mainnet".net.profiles."i2p"] # Seed nodes to connect to for peer discovery and/or adversising our @@ -341,11 +363,11 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"] #peers = [] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tcp://127.0.0.1:8442"] +#inbound = ["tcp://127.0.0.1:8342"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. -#external_addrs = ["i2p://youraddress.b32.i2p:8442"] +#external_addrs = ["i2p://youraddress.b32.i2p:8342"] [network_config."mainnet".net.profiles."socks5"] # Seed nodes to connect to for peer discovery and/or adversising our @@ -371,8 +393,9 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"] # Peer nodes to manually connect to #peers = [] - - +## ====================== +## LOCALNET CONFIGURATION +## ====================== # Localnet blockchain network configuration [network_config."localnet"] # Path to the blockchain database directory @@ -405,15 +428,23 @@ txs_batch_size = 50 ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:8240" +rpc_listen = "tcp://127.0.0.1:28345" # Disabled RPC methods -rpc_disabled_methods = ["p2p.get_info"] +#rpc_disabled_methods = [] + +## Localnet management JSON-RPC settings +[network_config."localnet".management_rpc] +# JSON-RPC listen URL +rpc_listen = "tcp://127.0.0.1:28346" + +# Disabled RPC methods +#rpc_disabled_methods = [] ## Localnet JSON-RPC settings for stratum mining requests (optional) #[network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -#rpc_listen = "tcp://127.0.0.1:8241" +#rpc_listen = "tcp://127.0.0.1:28347" # Disabled RPC methods (stratum mining) #rpc_disabled_methods = [] @@ -421,7 +452,7 @@ rpc_disabled_methods = ["p2p.get_info"] ## Localnet JSON-RPC settings for p2pool merge mining requests (optional) #[network_config."localnet".mm_rpc] # JSON-RPC listen URL (merge mining) -#rpc_listen = "http+tcp://127.0.0.1:8241" +#rpc_listen = "http+tcp://127.0.0.1:28348" # Disabled RPC methods (merge mining) #rpc_disabled_methods = [] @@ -481,7 +512,7 @@ localnet = true [net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tcp+tls://0.0.0.0:8242"] +#inbound = ["tcp+tls://0.0.0.0:28340"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. @@ -496,7 +527,7 @@ localnet = true [net.profiles."tcp"] # P2P accept addresses the instance listens on for inbound connections -#inbound = ["tcp://0.0.0.0:8242"] +#inbound = ["tcp://0.0.0.0:28340"] # P2P external addresses the instance advertises so other peers can # reach us and connect to us, as long as inbound addrs are configured. @@ -507,4 +538,4 @@ localnet = true # Seed nodes to connect to for peer discovery and/or adversising our # own external addresses -#seeds = [] \ No newline at end of file +#seeds = [] diff --git a/bin/darkfid/src/lib.rs b/bin/darkfid/src/lib.rs index ed7412fa4..bc2461728 100644 --- a/bin/darkfid/src/lib.rs +++ b/bin/darkfid/src/lib.rs @@ -45,7 +45,7 @@ use error::{server_error, RpcError}; /// JSON-RPC requests handler and methods mod rpc; -use rpc::DefaultRpcHandler; +use rpc::{management::ManagementRpcHandler, DefaultRpcHandler}; /// Validator async tasks pub mod task; @@ -76,6 +76,8 @@ pub struct DarkfiNode { subscribers: HashMap<&'static str, JsonSubscriber>, /// Main JSON-RPC connection tracker rpc_connections: Mutex>, + /// Management JSON-RPC connection tracker + management_rpc_connections: Mutex>, } impl DarkfiNode { @@ -93,6 +95,7 @@ impl DarkfiNode { txs_batch_size, subscribers, rpc_connections: Mutex::new(HashSet::new()), + management_rpc_connections: Mutex::new(HashSet::new()), })) } } @@ -108,6 +111,8 @@ pub struct Darkfid { dnet_task: StoppableTaskPtr, /// Main JSON-RPC background task rpc_task: StoppableTaskPtr, + /// Management JSON-RPC background task + management_rpc_task: StoppableTaskPtr, /// Consensus protocol background task consensus_task: StoppableTaskPtr, } @@ -161,19 +166,22 @@ impl Darkfid { // Generate the background tasks let dnet_task = StoppableTask::new(); let rpc_task = StoppableTask::new(); + let management_rpc_task = StoppableTask::new(); let consensus_task = StoppableTask::new(); info!(target: "darkfid::Darkfid::init", "Darkfi daemon initialized successfully!"); - Ok(Arc::new(Self { node, dnet_task, rpc_task, consensus_task })) + Ok(Arc::new(Self { node, dnet_task, rpc_task, management_rpc_task, consensus_task })) } - /// Start the DarkFi daemon in the given executor, using the provided JSON-RPC listen url - /// and consensus initialization configuration. + /// Start the DarkFi daemon in the given executor, using the + /// provided JSON-RPC settings and consensus initialization + /// configuration. pub async fn start( &self, executor: &ExecutorPtr, rpc_settings: &RpcSettings, + management_rpc_settings: &RpcSettings, stratum_rpc_settings: &Option, mm_rpc_settings: &Option, config: &ConsensusInitTaskConfig, @@ -218,6 +226,21 @@ impl Darkfid { executor.clone(), ); + // Start the management JSON-RPC task + info!(target: "darkfid::Darkfid::start", "Starting management JSON-RPC server"); + let node_ = self.node.clone(); + self.management_rpc_task.clone().start( + listen_and_serve::(management_rpc_settings.clone(), self.node.clone(), None, executor.clone()), + |res| async move { + match res { + Ok(()) | Err(Error::RpcServerStopped) => >::stop_connections(&node_).await, + Err(e) => error!(target: "darkfid::Darkfid::start", "Failed starting management JSON-RPC server: {e}"), + } + }, + Error::RpcServerStopped, + executor.clone(), + ); + // Start the miners registry info!(target: "darkfid::Darkfid::start", "Starting miners registry"); self.node.registry.start(executor, &self.node, stratum_rpc_settings, mm_rpc_settings)?; @@ -260,6 +283,10 @@ impl Darkfid { info!(target: "darkfid::Darkfid::stop", "Stopping main JSON-RPC server..."); self.rpc_task.stop().await; + // Stop the management JSON-RPC task + info!(target: "darkfid::Darkfid::stop", "Stopping management JSON-RPC server..."); + self.management_rpc_task.stop().await; + // Stop the miners registry info!(target: "darkfid::Darkfid::stop", "Stopping miners registry..."); self.node.registry.stop().await; diff --git a/bin/darkfid/src/main.rs b/bin/darkfid/src/main.rs index 77022ba6f..491c96ebb 100644 --- a/bin/darkfid/src/main.rs +++ b/bin/darkfid/src/main.rs @@ -135,6 +135,10 @@ pub struct BlockchainNetwork { /// Main server JSON-RPC settings rpc: RpcSettingsOpt, + #[structopt(flatten)] + /// Management server JSON-RPC settings + management_rpc: RpcSettingsOpt, + #[structopt(skip)] /// Stratum server JSON-RPC settings (optional) stratum_rpc: Option, @@ -251,6 +255,7 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { .start( &ex, &blockchain_config.rpc.into(), + &blockchain_config.management_rpc.into(), &blockchain_config.stratum_rpc.map(|stratum_rpc_opts| stratum_rpc_opts.into()), &blockchain_config.mm_rpc.map(|mm_rpc_opts| mm_rpc_opts.into()), &config, diff --git a/bin/darkfid/src/rpc/management.rs b/bin/darkfid/src/rpc/management.rs new file mode 100644 index 000000000..e800ec115 --- /dev/null +++ b/bin/darkfid/src/rpc/management.rs @@ -0,0 +1,131 @@ +/* This file is part of DarkFi (https://dark.fi) + * + * Copyright (C) 2020-2026 Dyne.org foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +use std::collections::HashSet; + +use async_trait::async_trait; +use smol::lock::MutexGuard; +use tinyjson::JsonValue; +use tracing::debug; + +use darkfi::{ + net::P2pPtr, + rpc::{ + jsonrpc::{ErrorCode, JsonError, JsonRequest, JsonResponse, JsonResult}, + p2p_method::HandlerP2p, + server::RequestHandler, + }, + system::StoppableTaskPtr, +}; + +use crate::DarkfiNode; + +/// JSON-RPC `RequestHandler` for node management +pub struct ManagementRpcHandler; + +#[async_trait] +#[rustfmt::skip] +impl RequestHandler for DarkfiNode { + async fn handle_request(&self, req: JsonRequest) -> JsonResult { + debug!(target: "darkfid::rpc::management_rpc", "--> {}", req.stringify().unwrap()); + + match req.method.as_str() { + // ======================= + // Node management methods + // ======================= + "ping" => >::pong(self, req.id, req.params).await, + "dnet.switch" => self.dnet_switch(req.id, req.params).await, + "dnet.subscribe_events" => self.dnet_subscribe_events(req.id, req.params).await, + "p2p.get_info" => self.p2p_get_info(req.id, req.params).await, + _ => JsonError::new(ErrorCode::MethodNotFound, None, req.id).into(), + } + } + + async fn connections_mut(&self) -> MutexGuard<'life0, HashSet> { + self.management_rpc_connections.lock().await + } +} + +impl HandlerP2p for DarkfiNode { + fn p2p(&self) -> P2pPtr { + self.p2p_handler.p2p.clone() + } +} + +impl DarkfiNode { + // RPCAPI: + // Activate or deactivate dnet in the P2P stack. + // By sending `true`, dnet will be activated, and by sending `false` dnet + // will be deactivated. + // + // Returns `true` on success. + // + // --> {"jsonrpc": "2.0", "method": "dnet.switch", "params": [true], "id": 1} + // <-- {"jsonrpc": "2.0", "result": true, "id": 1} + pub async fn dnet_switch(&self, id: u16, params: JsonValue) -> JsonResult { + let Some(params) = params.get::>() else { + return JsonError::new(ErrorCode::InvalidParams, None, id).into() + }; + if params.len() != 1 || !params[0].is_bool() { + return JsonError::new(ErrorCode::InvalidParams, None, id).into() + } + + let switch = params[0].get::().unwrap(); + + if *switch { + self.p2p_handler.p2p.dnet_enable(); + } else { + self.p2p_handler.p2p.dnet_disable(); + } + + JsonResponse::new(JsonValue::Boolean(true), id).into() + } + + // RPCAPI: + // Initializes a subscription to P2P dnet events. + // Once a subscription is established, `darkfid` will send JSON-RPC + // notifications of new network events to the subscriber. + // + // --> { + // "jsonrpc": "2.0", + // "method": "dnet.subscribe_events", + // "params": [], + // "id": 1 + // } + // <-- { + // "jsonrpc": "2.0", + // "method": "dnet.subscribe_events", + // "params": [ + // { + // "chan": {"Channel": "Info"}, + // "cmd": "command", + // "time": 1767016282 + // } + // ] + // } + pub async fn dnet_subscribe_events(&self, id: u16, params: JsonValue) -> JsonResult { + let Some(params) = params.get::>() else { + return JsonError::new(ErrorCode::InvalidParams, None, id).into() + }; + if !params.is_empty() { + return JsonError::new(ErrorCode::InvalidParams, None, id).into() + } + + self.subscribers.get("dnet").unwrap().clone().into() + } +} diff --git a/bin/darkfid/src/rpc/misc.rs b/bin/darkfid/src/rpc/misc.rs index 9034adf7b..1b20569d3 100644 --- a/bin/darkfid/src/rpc/misc.rs +++ b/bin/darkfid/src/rpc/misc.rs @@ -19,7 +19,7 @@ use tinyjson::JsonValue; use darkfi::{ - rpc::jsonrpc::{ErrorCode, JsonError, JsonResponse, JsonResult}, + rpc::jsonrpc::{JsonResponse, JsonResult}, util::time::Timestamp, }; @@ -34,65 +34,4 @@ impl DarkfiNode { pub async fn clock(&self, id: u16, _params: JsonValue) -> JsonResult { JsonResponse::new((Timestamp::current_time().inner() as f64).into(), id).into() } - - // RPCAPI: - // Activate or deactivate dnet in the P2P stack. - // By sending `true`, dnet will be activated, and by sending `false` dnet - // will be deactivated. - // - // Returns `true` on success. - // - // --> {"jsonrpc": "2.0", "method": "dnet.switch", "params": [true], "id": 1} - // <-- {"jsonrpc": "2.0", "result": true, "id": 1} - pub async fn dnet_switch(&self, id: u16, params: JsonValue) -> JsonResult { - let Some(params) = params.get::>() else { - return JsonError::new(ErrorCode::InvalidParams, None, id).into() - }; - if params.len() != 1 || !params[0].is_bool() { - return JsonError::new(ErrorCode::InvalidParams, None, id).into() - } - - let switch = params[0].get::().unwrap(); - - if *switch { - self.p2p_handler.p2p.dnet_enable(); - } else { - self.p2p_handler.p2p.dnet_disable(); - } - - JsonResponse::new(JsonValue::Boolean(true), id).into() - } - - // RPCAPI: - // Initializes a subscription to P2P dnet events. - // Once a subscription is established, `darkfid` will send JSON-RPC - // notifications of new network events to the subscriber. - // - // --> { - // "jsonrpc": "2.0", - // "method": "dnet.subscribe_events", - // "params": [], - // "id": 1 - // } - // <-- { - // "jsonrpc": "2.0", - // "method": "dnet.subscribe_events", - // "params": [ - // { - // "chan": {"Channel": "Info"}, - // "cmd": "command", - // "time": 1767016282 - // } - // ] - // } - pub async fn dnet_subscribe_events(&self, id: u16, params: JsonValue) -> JsonResult { - let Some(params) = params.get::>() else { - return JsonError::new(ErrorCode::InvalidParams, None, id).into() - }; - if !params.is_empty() { - return JsonError::new(ErrorCode::InvalidParams, None, id).into() - } - - self.subscribers.get("dnet").unwrap().clone().into() - } } diff --git a/bin/darkfid/src/rpc/mod.rs b/bin/darkfid/src/rpc/mod.rs index 298c3041d..adf1074ba 100644 --- a/bin/darkfid/src/rpc/mod.rs +++ b/bin/darkfid/src/rpc/mod.rs @@ -23,10 +23,8 @@ use smol::lock::MutexGuard; use tracing::debug; use darkfi::{ - net::P2pPtr, rpc::{ jsonrpc::{ErrorCode, JsonError, JsonRequest, JsonResult}, - p2p_method::HandlerP2p, server::RequestHandler, }, system::StoppableTaskPtr, @@ -49,6 +47,9 @@ pub mod xmr; /// Misc JSON-RPC methods pub mod misc; +/// Node management JSON-RPC methods +pub mod management; + /// Default JSON-RPC `RequestHandler` pub struct DefaultRpcHandler; @@ -64,9 +65,6 @@ impl RequestHandler for DarkfiNode { // ===================== "ping" => >::pong(self, req.id, req.params).await, "clock" => self.clock(req.id, req.params).await, - "dnet.switch" => self.dnet_switch(req.id, req.params).await, - "dnet.subscribe_events" => self.dnet_subscribe_events(req.id, req.params).await, - "p2p.get_info" => self.p2p_get_info(req.id, req.params).await, // ================== // Blockchain methods @@ -104,9 +102,3 @@ impl RequestHandler for DarkfiNode { self.rpc_connections.lock().await } } - -impl HandlerP2p for DarkfiNode { - fn p2p(&self) -> P2pPtr { - self.p2p_handler.p2p.clone() - } -} diff --git a/bin/darkfid/src/rpc/stratum.rs b/bin/darkfid/src/rpc/stratum.rs index e4a63e55f..f433364f0 100644 --- a/bin/darkfid/src/rpc/stratum.rs +++ b/bin/darkfid/src/rpc/stratum.rs @@ -49,7 +49,7 @@ pub struct StratumRpcHandler; #[rustfmt::skip] impl RequestHandler for DarkfiNode { async fn handle_request(&self, req: JsonRequest) -> JsonResult { - debug!(target: "darkfid::stratum_rpc", "--> {}", req.stringify().unwrap()); + debug!(target: "darkfid::rpc::stratum_rpc", "--> {}", req.stringify().unwrap()); match req.method.as_str() { // ====================== diff --git a/bin/darkfid/src/rpc/xmr.rs b/bin/darkfid/src/rpc/xmr.rs index f43281835..36822529a 100644 --- a/bin/darkfid/src/rpc/xmr.rs +++ b/bin/darkfid/src/rpc/xmr.rs @@ -61,7 +61,7 @@ pub struct MmRpcHandler; #[rustfmt::skip] impl RequestHandler for DarkfiNode { async fn handle_request(&self, req: JsonRequest) -> JsonResult { - debug!(target: "darkfid::mm_rpc", "--> {}", req.stringify().unwrap()); + debug!(target: "darkfid::rpc::rpc_xmr", "--> {}", req.stringify().unwrap()); match req.method.as_str() { // ================================================ diff --git a/bin/darkfid/src/tests/mod.rs b/bin/darkfid/src/tests/mod.rs index 28608393a..ecb4af106 100644 --- a/bin/darkfid/src/tests/mod.rs +++ b/bin/darkfid/src/tests/mod.rs @@ -281,7 +281,11 @@ fn darkfid_programmatic_control() -> Result<()> { checkpoint: None, }; let rpc_settings = RpcSettings { - listen: Url::parse("tcp://127.0.0.1:8240").unwrap(), + listen: Url::parse("tcp://127.0.0.1:18245").unwrap(), + ..RpcSettings::default() + }; + let management_rpc_settings = RpcSettings { + listen: Url::parse("tcp://127.0.0.1:18246").unwrap(), ..RpcSettings::default() }; @@ -298,13 +302,33 @@ fn darkfid_programmatic_control() -> Result<()> { .unwrap(); // Start it - daemon.start(&ex, &rpc_settings, &None, &None, &consensus_config).await.unwrap(); + daemon + .start( + &ex, + &rpc_settings, + &management_rpc_settings, + &None, + &None, + &consensus_config, + ) + .await + .unwrap(); // Stop it daemon.stop().await.unwrap(); // Start it again - daemon.start(&ex, &rpc_settings, &None, &None, &consensus_config).await.unwrap(); + daemon + .start( + &ex, + &rpc_settings, + &management_rpc_settings, + &None, + &None, + &consensus_config, + ) + .await + .unwrap(); // Stop it daemon.stop().await.unwrap(); diff --git a/bin/dnet/dnet_config.toml b/bin/dnet/dnet_config.toml index ad6761046..244c16d49 100644 --- a/bin/dnet/dnet_config.toml +++ b/bin/dnet/dnet_config.toml @@ -19,19 +19,19 @@ #[[nodes]] #name = "darkfid-testnet" #host = "localhost" -#port = 8340 +#port = 18346 #type = "NORMAL" #[[nodes]] #name = "darkfid-mainnet" #host = "localhost" -#port = 8440 +#port = 8346 #type = "NORMAL" #[[nodes]] #name = "darkfid-localnet" #host = "localhost" -#port = 8240 +#port = 28346 #type = "NORMAL" #[[nodes]] diff --git a/bin/drk/drk_config.toml b/bin/drk/drk_config.toml index 130acb2fa..0e9c15d9a 100644 --- a/bin/drk/drk_config.toml +++ b/bin/drk/drk_config.toml @@ -24,7 +24,7 @@ wallet_path = "~/.local/share/darkfi/drk/localnet/wallet.db" wallet_pass = "changeme" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8240" +endpoint = "tcp://127.0.0.1:28345" # Path to interactive shell history file history_path = "~/.local/share/darkfi/drk/localnet/history.txt" @@ -41,7 +41,7 @@ wallet_path = "~/.local/share/darkfi/drk/testnet/wallet.db" wallet_pass = "changeme" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8340" +endpoint = "tcp://127.0.0.1:18345" # Path to interactive shell history file history_path = "~/.local/share/darkfi/drk/testnet/history.txt" @@ -58,7 +58,7 @@ wallet_path = "~/.local/share/darkfi/drk/mainnet/wallet.db" wallet_pass = "changeme" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8440" +endpoint = "tcp://127.0.0.1:8345" # Path to interactive shell history file history_path = "~/.local/share/darkfi/drk/mainnet/history.txt" diff --git a/bin/drk/src/main.rs b/bin/drk/src/main.rs index 3283048fe..2723fcaf1 100644 --- a/bin/drk/src/main.rs +++ b/bin/drk/src/main.rs @@ -596,7 +596,7 @@ struct BlockchainNetwork { /// Password for the wallet database wallet_pass: String, - #[structopt(short, long, default_value = "tcp://127.0.0.1:8240")] + #[structopt(short, long, default_value = "tcp://127.0.0.1:28345")] /// darkfid JSON-RPC endpoint endpoint: Url, diff --git a/bin/explorer/README.md b/bin/explorer/README.md index 545115891..0d7707612 100644 --- a/bin/explorer/README.md +++ b/bin/explorer/README.md @@ -98,7 +98,7 @@ Upon successful initialization of the Explorer environment, confirmation message [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] - Synced Blocks: 9 [INFO] - Synced Transactions: 9 -[INFO] - Connected Darkfi Node: tcp://127.0.0.1:8240 +[INFO] - Connected Darkfi Node: tcp://127.0.0.1:28345 [INFO] ======================================================================================== [INFO] All is good. Waiting for block notifications... Started explorer site on localnet network (PID=31911) diff --git a/bin/explorer/explorerd/README.md b/bin/explorer/explorerd/README.md index bc79124e3..d5fe8a702 100644 --- a/bin/explorer/explorerd/README.md +++ b/bin/explorer/explorerd/README.md @@ -72,19 +72,19 @@ make stop When a DarkFi Explorer Node successfully starts, users should a startup banner displaying the node's configuration details and current sync status. Here is a successful localnet node startup example: ``` -03:31:37 [INFO] ======================================================================================== -03:31:37 [INFO] Started DarkFi Explorer Node -03:31:37 [INFO] ======================================================================================== -03:31:37 [INFO] - Network: localnet -03:31:37 [INFO] - JSON-RPC Endpoint: tcp://127.0.0.1:14567 -03:31:37 [INFO] - Database: ~/.local/share/darkfi/explorerd/localnet -03:31:37 [INFO] - Configuration: ./explorerd_config.toml -03:31:37 [INFO] - Reset Blocks: No -03:31:37 [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -03:31:37 [INFO] - Synced Blocks: 8 -03:31:37 [INFO] - Synced Transactions: 8 -03:31:37 [INFO] - Connected Darkfi Node: tcp://127.0.0.1:8240 -03:31:37 [INFO] ======================================================================================== +[INFO] ======================================================================================== +[INFO] Started DarkFi Explorer Node +[INFO] ======================================================================================== +[INFO] - Network: localnet +[INFO] - JSON-RPC Endpoint: tcp://127.0.0.1:14567 +[INFO] - Database: ~/.local/share/darkfi/explorerd/localnet +[INFO] - Configuration: ./explorerd_config.toml +[INFO] - Reset Blocks: No +[INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[INFO] - Synced Blocks: 8 +[INFO] - Synced Transactions: 8 +[INFO] - Connected Darkfi Node: tcp://127.0.0.1:28345 +[INFO] ======================================================================================== ``` > **Note** In no-sync mode, you will see “Started DarkFi Explorer Node (No-Sync Mode)” in the banner header, and the “Connected Darkfi Node:” line will show “Not connected”. @@ -113,7 +113,7 @@ Below is an example of a localnet configuration for `explorerd` (`~/.config/dark database = "~/.local/share/darkfi/explorerd/localnet" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8240" +endpoint = "tcp://127.0.0.1:28345" ## Localnet JSON-RPC settings [network_config."localnet".rpc] @@ -147,14 +147,14 @@ To create a custom explorerd configuration, use [Explorerd Configuration](../exp ```toml [network_config."localnet".rpc] - rpc_listen = "tcp://127.0.0.1:8240" + rpc_listen = "tcp://127.0.0.1:28345" ``` - `explorerd_config.toml`: ```toml [network_config."localnet"] - endpoint = "tcp://127.0.0.1:8240" + endpoint = "tcp://127.0.0.1:28345" ``` ### Installation diff --git a/bin/explorer/explorerd/explorerd_config.toml b/bin/explorer/explorerd/explorerd_config.toml index f9d6e429e..4afe22286 100644 --- a/bin/explorer/explorerd/explorerd_config.toml +++ b/bin/explorer/explorerd/explorerd_config.toml @@ -18,7 +18,7 @@ network = "testnet" database = "~/.local/share/darkfi/explorerd/localnet" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8240" +endpoint = "tcp://127.0.0.1:28345" ## Localnet JSON-RPC settings [network_config."localnet".rpc] @@ -37,7 +37,7 @@ rpc_listen = "tcp://127.0.0.1:14567" database = "~/.local/share/darkfi/explorerd/testnet" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8340" +endpoint = "tcp://127.0.0.1:18345" ## Localnet JSON-RPC settings [network_config."testnet".rpc] @@ -55,7 +55,7 @@ rpc_listen = "tcp://127.0.0.1:14667" database = "~/.local/share/darkfi/explorerd/mainnet" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8440" +endpoint = "tcp://127.0.0.1:8345" ## Localnet JSON-RPC settings [network_config."mainnet".rpc] diff --git a/bin/explorer/explorerd/src/config.rs b/bin/explorer/explorerd/src/config.rs index cdef889c9..8b0cff3e6 100644 --- a/bin/explorer/explorerd/src/config.rs +++ b/bin/explorer/explorerd/src/config.rs @@ -162,7 +162,7 @@ pub struct ExplorerNetworkConfig { /// Path to the explorer's database. pub database: String, - #[structopt(short, long, default_value = "tcp://127.0.0.1:8340")] + #[structopt(short, long, default_value = "tcp://127.0.0.1:28345")] /// Endpoint of the DarkFi node JSON-RPC server to sync with. pub endpoint: Url, } @@ -238,19 +238,19 @@ mod tests { ( "localnet", "~/.local/share/darkfi/explorerd/localnet", - "tcp://127.0.0.1:8240/", + "tcp://127.0.0.1:28345/", "tcp://127.0.0.1:14567/", ), ( "testnet", "~/.local/share/darkfi/explorerd/testnet", - "tcp://127.0.0.1:8340/", + "tcp://127.0.0.1:18345/", "tcp://127.0.0.1:14667/", ), ( "mainnet", "~/.local/share/darkfi/explorerd/mainnet", - "tcp://127.0.0.1:8440/", + "tcp://127.0.0.1:8345/", "tcp://127.0.0.1:14767/", ), ]; diff --git a/bin/explorer/explorerd/src/test_utils/mod.rs b/bin/explorer/explorerd/src/test_utils/mod.rs index ef1f79f15..90bbfa464 100644 --- a/bin/explorer/explorerd/src/test_utils/mod.rs +++ b/bin/explorer/explorerd/src/test_utils/mod.rs @@ -66,7 +66,7 @@ pub fn setup() -> Arc { let db_path_buf = temp_dir.path().join("explorerd_0"); let db_path = db_path_buf.to_str().expect("Failed to convert db_path to string").to_string(); - let darkfid_endpoint = Url::parse("http://127.0.0.1:8240").expect("Invalid URL"); + let darkfid_endpoint = Url::parse("http://127.0.0.1:28345").expect("Invalid URL"); let executor = Arc::new(Executor::new()); // Block on the async function to resolve Explorerd::new diff --git a/bin/lilith/lilith_config.toml b/bin/lilith/lilith_config.toml index 7ac1ccc54..cc83918b3 100644 --- a/bin/lilith/lilith_config.toml +++ b/bin/lilith/lilith_config.toml @@ -16,7 +16,7 @@ rpc_listen = "tcp://127.0.0.1:18927" ## Per-network settings #[network."darkfid_testnet_v5"] -#accept_addrs = ["tcp+tls://0.0.0.0:8342"] +#accept_addrs = ["tcp+tls://0.0.0.0:18345"] #seeds = [] #peers = [] #version = "0.5.0" diff --git a/contrib/localnet/darkfid-five-nodes/darkfid0.toml b/contrib/localnet/darkfid-five-nodes/darkfid0.toml index 8d4148db6..5a13e3d61 100644 --- a/contrib/localnet/darkfid-five-nodes/darkfid0.toml +++ b/contrib/localnet/darkfid-five-nodes/darkfid0.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48240" +rpc_listen = "tcp://127.0.0.1:48345" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48241" +rpc_listen = "tcp://127.0.0.1:48346" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,4 +58,4 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48242"] +inbound = ["tcp+tls://0.0.0.0:48340"] diff --git a/contrib/localnet/darkfid-five-nodes/darkfid1.toml b/contrib/localnet/darkfid-five-nodes/darkfid1.toml index f0e977dad..c222c80ba 100644 --- a/contrib/localnet/darkfid-five-nodes/darkfid1.toml +++ b/contrib/localnet/darkfid-five-nodes/darkfid1.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48340" +rpc_listen = "tcp://127.0.0.1:48445" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48340" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48341" +rpc_listen = "tcp://127.0.0.1:48446" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48342"] +inbound = ["tcp+tls://0.0.0.0:48440"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242"] +peers = ["tcp+tls://0.0.0.0:48340"] diff --git a/contrib/localnet/darkfid-five-nodes/darkfid2.toml b/contrib/localnet/darkfid-five-nodes/darkfid2.toml index 2876241b2..e9084a66e 100644 --- a/contrib/localnet/darkfid-five-nodes/darkfid2.toml +++ b/contrib/localnet/darkfid-five-nodes/darkfid2.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48440" +rpc_listen = "tcp://127.0.0.1:48545" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48440" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48441" +rpc_listen = "tcp://127.0.0.1:48546" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48442"] +inbound = ["tcp+tls://0.0.0.0:48540"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342"] +peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440"] diff --git a/contrib/localnet/darkfid-five-nodes/darkfid3.toml b/contrib/localnet/darkfid-five-nodes/darkfid3.toml index 05a90ff41..37b1d68b4 100644 --- a/contrib/localnet/darkfid-five-nodes/darkfid3.toml +++ b/contrib/localnet/darkfid-five-nodes/darkfid3.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48540" +rpc_listen = "tcp://127.0.0.1:48645" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48540" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48541" +rpc_listen = "tcp://127.0.0.1:48646" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48542"] +inbound = ["tcp+tls://0.0.0.0:48640"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342", "tcp+tls://0.0.0.0:48442"] +peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440", "tcp+tls://0.0.0.0:48540"] diff --git a/contrib/localnet/darkfid-five-nodes/darkfid4.toml b/contrib/localnet/darkfid-five-nodes/darkfid4.toml index f0ad8bca7..df8cc0b3e 100644 --- a/contrib/localnet/darkfid-five-nodes/darkfid4.toml +++ b/contrib/localnet/darkfid-five-nodes/darkfid4.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48640" +rpc_listen = "tcp://127.0.0.1:48745" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48640" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48641" +rpc_listen = "tcp://127.0.0.1:48746" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48642"] +inbound = ["tcp+tls://0.0.0.0:48740"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342", "tcp+tls://0.0.0.0:48442", "tcp+tls://0.0.0.0:48542"] +peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440", "tcp+tls://0.0.0.0:48540", "tcp+tls://0.0.0.0:48640"] diff --git a/contrib/localnet/darkfid-five-nodes/tmux_sessions.sh b/contrib/localnet/darkfid-five-nodes/tmux_sessions.sh index 8b7009a41..098cb92a6 100755 --- a/contrib/localnet/darkfid-five-nodes/tmux_sessions.sh +++ b/contrib/localnet/darkfid-five-nodes/tmux_sessions.sh @@ -20,23 +20,23 @@ else fi tmux new-session -d -s $session -n "node0" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48241 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48346 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid0.toml $verbose" Enter tmux new-window -t $session -n "node1" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48341 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48446 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid1.toml $verbose" Enter tmux new-window -t $session -n "node2" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48441 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48546 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid2.toml $verbose" Enter tmux new-window -t $session -n "node3" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48541 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48646 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid3.toml $verbose" Enter tmux new-window -t $session -n "node4" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48641 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48746 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid4.toml $verbose" Enter tmux attach -t $session diff --git a/contrib/localnet/darkfid-single-node/darkfid.toml b/contrib/localnet/darkfid-single-node/darkfid.toml index ee638319e..baeba4513 100644 --- a/contrib/localnet/darkfid-single-node/darkfid.toml +++ b/contrib/localnet/darkfid-single-node/darkfid.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48240" +rpc_listen = "tcp://127.0.0.1:48345" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48241" +rpc_listen = "tcp://127.0.0.1:48346" # Disabled RPC methods (stratum mining) #rpc_disabled_methods = [] @@ -69,4 +69,4 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48242"] +inbound = ["tcp+tls://0.0.0.0:48340"] diff --git a/contrib/localnet/darkfid-single-node/drk.toml b/contrib/localnet/darkfid-single-node/drk.toml index 8215c801b..afe9d5d76 100644 --- a/contrib/localnet/darkfid-single-node/drk.toml +++ b/contrib/localnet/darkfid-single-node/drk.toml @@ -21,7 +21,7 @@ wallet_path = "drk/wallet.db" wallet_pass = "testing" # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:48240" +endpoint = "tcp://127.0.0.1:48345" # Path to interactive shell history file history_path = "drk/history.txt" diff --git a/contrib/localnet/darkfid-single-node/tmux_sessions.sh b/contrib/localnet/darkfid-single-node/tmux_sessions.sh index d15e087b0..7794cd325 100755 --- a/contrib/localnet/darkfid-single-node/tmux_sessions.sh +++ b/contrib/localnet/darkfid-single-node/tmux_sessions.sh @@ -5,7 +5,7 @@ set -e # xmrig configuration XMRIG_BINARY_PATH="xmrig" -XMRIG_STRATUM_ENDPOINT="127.0.0.1:48241" +XMRIG_STRATUM_ENDPOINT="127.0.0.1:48346" XMRIG_THREADS="4" XMRIG_USER="DZnsGMCvZU5CEzvpuExnxbvz6SEhE2rn89sMcuHsppFE6TjL4SBTrKkf" XMRIG_PARAMS="-u x+1 -r 1000 -R 20 -o $XMRIG_STRATUM_ENDPOINT -t $XMRIG_THREADS -u $XMRIG_USER" diff --git a/contrib/localnet/darkfid-small/darkfid0.toml b/contrib/localnet/darkfid-small/darkfid0.toml index 848f59dfc..74fa5a337 100644 --- a/contrib/localnet/darkfid-small/darkfid0.toml +++ b/contrib/localnet/darkfid-small/darkfid0.toml @@ -38,7 +38,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48240" +rpc_listen = "tcp://127.0.0.1:48345" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48241" +rpc_listen = "tcp://127.0.0.1:48346" ## Localnet P2P network settings [network_config."localnet".net] @@ -58,4 +58,4 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48242"] +inbound = ["tcp+tls://0.0.0.0:48340"] diff --git a/contrib/localnet/darkfid-small/darkfid1.toml b/contrib/localnet/darkfid-small/darkfid1.toml index 481dadacc..58b1a381c 100644 --- a/contrib/localnet/darkfid-small/darkfid1.toml +++ b/contrib/localnet/darkfid-small/darkfid1.toml @@ -46,7 +46,7 @@ skip_fees = false ## Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48340" +rpc_listen = "tcp://127.0.0.1:48445" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -54,7 +54,7 @@ rpc_listen = "tcp://127.0.0.1:48340" ## Localnet JSON-RPC settings for stratum mining requests (optional) [network_config."localnet".stratum_rpc] # JSON-RPC listen URL (stratum mining) -rpc_listen = "tcp://127.0.0.1:48341" +rpc_listen = "tcp://127.0.0.1:48446" ## Localnet P2P network settings [network_config."localnet".net] @@ -66,7 +66,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48342"] +inbound = ["tcp+tls://0.0.0.0:48440"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242"] +peers = ["tcp+tls://0.0.0.0:48340"] diff --git a/contrib/localnet/darkfid-small/darkfid2.toml b/contrib/localnet/darkfid-small/darkfid2.toml index 5530345ea..9af9da77f 100644 --- a/contrib/localnet/darkfid-small/darkfid2.toml +++ b/contrib/localnet/darkfid-small/darkfid2.toml @@ -38,7 +38,7 @@ skip_fees = false # Localnet JSON-RPC settings [network_config."localnet".rpc] # JSON-RPC listen URL -rpc_listen = "tcp://127.0.0.1:48440" +rpc_listen = "tcp://127.0.0.1:48545" # Disabled RPC methods #rpc_disabled_methods = ["p2p.get_info"] @@ -53,7 +53,7 @@ active_profiles = ["tcp+tls"] [network_config."localnet".net.profiles."tcp+tls"] # P2P accept addresses the instance listens on for inbound connections -inbound = ["tcp+tls://0.0.0.0:48442"] +inbound = ["tcp+tls://0.0.0.0:48540"] # Peer nodes to manually connect to -peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342"] +peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440"] diff --git a/contrib/localnet/darkfid-small/tmux_sessions.sh b/contrib/localnet/darkfid-small/tmux_sessions.sh index b0e7f4d8d..8836752d3 100755 --- a/contrib/localnet/darkfid-small/tmux_sessions.sh +++ b/contrib/localnet/darkfid-small/tmux_sessions.sh @@ -21,11 +21,11 @@ else fi tmux new-session -d -s $session -n "node0" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48241 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48346 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid0.toml $verbose" Enter tmux new-window -t $session -n "node1" -tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48341 -t 2 -u $XMRIG_USER" Enter +tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48446 -t 2 -u $XMRIG_USER" Enter tmux split-window -t $session -v -l 80% tmux send-keys -t $session "$DARKFID -c darkfid1.toml $verbose" Enter tmux new-window -t $session -n "node2" diff --git a/doc/Makefile b/doc/Makefile index 2db28dcf1..eb9f6b41b 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -21,7 +21,7 @@ $(DARKFID_JSONRPC): @echo "# darkfid JSON-RPC API" > $@ @echo "## Methods" >> $@ @echo "" >> $@ - for i in blockchain tx stratum xmr misc; do \ + for i in blockchain tx stratum xmr misc management; do \ echo "## $$i methods" >> $@ ;\ ./build_jsonrpc.py ../bin/darkfid/src/rpc/$$i.rs >> $@ ;\ done diff --git a/doc/src/testnet/dao.md b/doc/src/testnet/dao.md index ab85c10b7..e499b9942 100644 --- a/doc/src/testnet/dao.md +++ b/doc/src/testnet/dao.md @@ -731,7 +731,7 @@ DarkFi DAO mining configuration address: Then start an `xmrig` instance to mine for the DAO: ```shell -$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:8341 -t {XMRIG_THREADS} -u {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION} +$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:18347 -t {XMRIG_THREADS} -u {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION} ``` After your miners have successfully mined confirmed blocks, you will diff --git a/doc/src/testnet/merge-mining.md b/doc/src/testnet/merge-mining.md index 5a5ae16d3..a58a6bfaf 100644 --- a/doc/src/testnet/merge-mining.md +++ b/doc/src/testnet/merge-mining.md @@ -187,21 +187,16 @@ endpoint that will be used by `p2pool` in `darkfid` config: ```toml [network_config."testnet".mm_rpc] -rpc_listen = "http+tcp://127.0.0.1:8341" +rpc_listen = "http+tcp://127.0.0.1:18348" ``` -> Note: -> -> If you are also using a `Stratum` RPC endpoint make sure the two -> ports are different. - Then start `darkfid` as usual. Stop `p2pool` if it's running, and re-run it with the merge-mining parameters appended: ```shell -$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:8341 {YOUR_DARKFI_WALLET_ADDRESS} +$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:18348 {YOUR_DARKFI_WALLET_ADDRESS} ``` Now `p2pool` should communicate with both `monerod` and `darkfid` in @@ -229,7 +224,7 @@ Stop `p2pool` if it's running, and re-run it with the merge-mining parameters appended: ```shell -$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_DAO_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:8341 {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION} +$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_DAO_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:18348 {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION} ``` After your miners have successfully mined confirmed blocks, you will diff --git a/doc/src/testnet/node.md b/doc/src/testnet/node.md index 7734aa4ba..69425b468 100644 --- a/doc/src/testnet/node.md +++ b/doc/src/testnet/node.md @@ -256,7 +256,7 @@ config: ```toml [network_config."testnet".stratum_rpc] -rpc_listen = "tcp://127.0.0.1:8341" +rpc_listen = "tcp://127.0.0.1:18347" ``` > Note: @@ -285,7 +285,7 @@ for maximum mining performance. Start `darkfid` as usual and then start which wallet: ```shell -$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:8341 -t {XMRIG_THREADS} -u {YOUR_DARKFI_WALLET_ADDRESS} +$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:18347 -t {XMRIG_THREADS} -u {YOUR_DARKFI_WALLET_ADDRESS} ``` In `darkfid`, you should see a notification like this: diff --git a/script/research/blockchain-storage-metrics/blockchain_storage_metrics_config.toml b/script/research/blockchain-storage-metrics/blockchain_storage_metrics_config.toml index 2d4a85235..d9df2cf09 100644 --- a/script/research/blockchain-storage-metrics/blockchain_storage_metrics_config.toml +++ b/script/research/blockchain-storage-metrics/blockchain_storage_metrics_config.toml @@ -7,7 +7,7 @@ ## uncommenting, or by using the command-line. # darkfid JSON-RPC endpoint -endpoint = "tcp://127.0.0.1:8340" +endpoint = "tcp://127.0.0.1:28345" # Block height to measure until height = 0 diff --git a/script/research/blockchain-storage-metrics/src/main.rs b/script/research/blockchain-storage-metrics/src/main.rs index 3c460bb6a..a4e238312 100644 --- a/script/research/blockchain-storage-metrics/src/main.rs +++ b/script/research/blockchain-storage-metrics/src/main.rs @@ -44,7 +44,7 @@ struct Args { /// Configuration file to use config: Option, - #[structopt(short, long, default_value = "tcp://127.0.0.1:8340")] + #[structopt(short, long, default_value = "tcp://127.0.0.1:28345")] /// darkfid JSON-RPC endpoint endpoint: Url,