-
Notifications
You must be signed in to change notification settings - Fork 13
feat: devnet support for dash-spv
#784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
38d2656
4cf58b7
4c2dbc9
a8a537e
f59de5f
4d5e0f6
e3c8002
a5b5204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ use clap::ValueEnum; | |
| use std::net::SocketAddr; | ||
| use std::path::PathBuf; | ||
|
|
||
| use dashcore::sml::llmq_type::set_llmq_devnet_params; | ||
| use dashcore::Network; | ||
| // Serialization removed due to complex Address types | ||
|
|
||
|
|
@@ -70,6 +71,10 @@ pub struct ClientConfig { | |
| /// Start syncing from a specific block height. | ||
| /// The client will use the nearest checkpoint at or before this height. | ||
| pub start_from_height: Option<u32>, | ||
|
|
||
| /// Override for `LLMQ_DEVNET` quorum size and threshold, applied at startup. | ||
| /// Mirrors Dash Core's `-llmqdevnetparams=<size>:<threshold>`. Only meaningful on devnet. | ||
| pub llmq_devnet_params: Option<(u32, u32)>, | ||
| } | ||
|
|
||
| impl Default for ClientConfig { | ||
|
|
@@ -90,6 +95,7 @@ impl Default for ClientConfig { | |
| max_mempool_transactions: 1000, | ||
| fetch_mempool_transactions: true, | ||
| start_from_height: None, | ||
| llmq_devnet_params: None, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -181,6 +187,13 @@ impl ClientConfig { | |
| self | ||
| } | ||
|
|
||
| /// Override `LLMQ_DEVNET` quorum size and threshold for a devnet. | ||
| /// Mirrors Dash Core's `-llmqdevnetparams=<size>:<threshold>`. | ||
| pub fn with_llmq_devnet_params(mut self, size: u32, threshold: u32) -> Self { | ||
| self.llmq_devnet_params = Some((size, threshold)); | ||
| self | ||
| } | ||
|
|
||
| /// Validate the configuration. | ||
| pub fn validate(&self) -> Result<(), String> { | ||
| // Note: Empty peers list is now valid - DNS discovery will be used automatically | ||
|
|
@@ -196,6 +209,10 @@ impl ClientConfig { | |
| ); | ||
| } | ||
|
|
||
| if self.llmq_devnet_params.is_some() && self.network != Network::Devnet { | ||
| return Err("llmq_devnet_params is only valid on devnet".to_string()); | ||
| } | ||
|
|
||
| std::fs::create_dir_all(&self.storage_path).map_err(|e| { | ||
| format!( | ||
| "A valid storage path must be provided to the ClientConfig {:?}: {e}", | ||
|
|
@@ -205,4 +222,13 @@ impl ClientConfig { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Apply process-wide settings derived from this config. Idempotent for the | ||
| /// same values, returns an error if a conflicting setting was already applied. | ||
| pub(crate) fn apply_global_overrides(&self) -> Result<(), String> { | ||
| if let Some((size, threshold)) = self.llmq_devnet_params { | ||
| set_llmq_devnet_params(size, threshold).map_err(|e| e.to_string())?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
Comment on lines
+226
to
+233
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The method comment says same-value calls are idempotent, but 🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ pub mod rotation; | |
|
|
||
| use std::fmt::{Display, Formatter}; | ||
| use std::io; | ||
| use std::sync::OnceLock; | ||
|
|
||
| #[cfg(feature = "bincode")] | ||
| use bincode::{Decode, Encode}; | ||
|
|
@@ -207,6 +208,27 @@ pub const LLMQ_DEVNET: LLMQParams = LLMQParams { | |
| recovery_members: 6, | ||
| }; | ||
|
|
||
| /// Runtime override for `LLMQ_DEVNET` params, matching Dash Core's `-llmqdevnetparams`. | ||
| static LLMQ_DEVNET_OVERRIDE: OnceLock<(u32, u32)> = OnceLock::new(); | ||
|
|
||
| /// Override the `LLMQ_DEVNET` quorum size and threshold (matches Dash Core's | ||
| /// `-llmqdevnetparams=<size>:<threshold>`). May only be called once per process. | ||
| pub fn set_llmq_devnet_params(size: u32, threshold: u32) -> Result<(), &'static str> { | ||
| LLMQ_DEVNET_OVERRIDE.set((size, threshold)).map_err(|_| "LLMQ_DEVNET params already set") | ||
| } | ||
|
|
||
| /// Get the effective `LLMQ_DEVNET` params, applying any runtime override. | ||
| pub fn llmq_devnet_params() -> LLMQParams { | ||
| let mut params = LLMQ_DEVNET; | ||
| if let Some(&(size, threshold)) = LLMQ_DEVNET_OVERRIDE.get() { | ||
| params.size = size; | ||
| params.min_size = threshold; | ||
| params.threshold = threshold; | ||
| params.dkg_params.bad_votes_threshold = threshold; | ||
|
xdustinface marked this conversation as resolved.
Outdated
|
||
| } | ||
| params | ||
| } | ||
|
Comment on lines
+222
to
+252
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Add focused tests for the new process-wide devnet override path. Please add unit tests for: valid override application, invalid value rejection, and second-set behavior. As per coding guidelines, "Write unit tests for new functionality". 🤖 Prompt for AI Agents |
||
|
|
||
| pub const LLMQ_50_60: LLMQParams = LLMQParams { | ||
| quorum_type: LLMQType::Llmqtype50_60, | ||
| name: "llmq_50_60", | ||
|
|
@@ -358,14 +380,14 @@ impl LLMQType { | |
| LLMQType::Llmqtype60_75 => LLMQ_60_75, | ||
| LLMQType::Llmqtype25_67 => LLMQ_25_67, | ||
| LLMQType::LlmqtypeTest => LLMQ_TEST, | ||
| LLMQType::LlmqtypeDevnet => LLMQ_DEVNET, | ||
| LLMQType::LlmqtypeDevnet => llmq_devnet_params(), | ||
| LLMQType::LlmqtypeTestV17 => LLMQ_V017, | ||
| LLMQType::LlmqtypeTestDIP0024 => LLMQ_TEST_DIP00024, | ||
| LLMQType::LlmqtypeTestInstantSend => LLMQ_TEST_INSTANT_SEND, | ||
| LLMQType::LlmqtypeDevnetDIP0024 => LLMQ_0024, | ||
| LLMQType::LlmqtypeTestnetPlatform => LLMQ_TEST_PLATFORM, | ||
| LLMQType::LlmqtypeDevnetPlatform => LLMQ_DEV_PLATFORM, | ||
| LLMQType::LlmqtypeUnknown => LLMQ_DEVNET, | ||
| LLMQType::LlmqtypeUnknown => llmq_devnet_params(), | ||
| } | ||
| } | ||
| pub fn size(&self) -> u32 { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.