From d4a393c1269caf7aecaf210049d1bd1cff9d5869 Mon Sep 17 00:00:00 2001 From: Borja Castellano Date: Fri, 22 May 2026 11:01:17 -0700 Subject: [PATCH] bump rust-dashcore to rev f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc --- .codecov.yml | 2 +- .serena/project.yml | 2 +- Cargo.lock | 50 ++++++----- Cargo.toml | 16 ++-- .../rs-platform-wallet/src/spv/runtime.rs | 86 ++++--------------- packages/rs-platform-wallet/tests/spv_sync.rs | 9 +- 6 files changed, 58 insertions(+), 107 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 532e4905251..120f9c5626d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -138,7 +138,7 @@ ignore: - "packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs" # Versioned dispatch methods — pure version routing with no logic - "packages/rs-dpp/src/data_contract/document_type/methods/versioned_methods.rs" - + coverage: status: project: diff --git a/.serena/project.yml b/.serena/project.yml index 3fc6fe59ef9..48df7c44058 100644 --- a/.serena/project.yml +++ b/.serena/project.yml @@ -61,7 +61,7 @@ read_only: false # This extends the existing exclusions (e.g. from the global configuration) # # Below is the complete list of tools for convenience. -# To make sure you have the latest list of tools, and to view their descriptions, +# To make sure you have the latest list of tools, and to view their descriptions, # execute `uv run scripts/print_tool_overview.py`. # # * `activate_project`: Activates a project by name. diff --git a/Cargo.lock b/Cargo.lock index 2119a766129..14a81bc501d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1549,8 +1549,8 @@ dependencies = [ [[package]] name = "dash-network" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "bincode", "bincode_derive", @@ -1560,8 +1560,8 @@ dependencies = [ [[package]] name = "dash-network-seeds" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "dash-network", ] @@ -1637,8 +1637,8 @@ dependencies = [ [[package]] name = "dash-spv" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "async-trait", "chrono", @@ -1647,6 +1647,7 @@ dependencies = [ "dashcore", "dashcore_hashes", "futures", + "git-state", "hex", "key-wallet", "key-wallet-manager", @@ -1665,8 +1666,8 @@ dependencies = [ [[package]] name = "dashcore" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "anyhow", "base64-compat", @@ -1691,13 +1692,13 @@ dependencies = [ [[package]] name = "dashcore-private" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" [[package]] name = "dashcore-rpc" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "dashcore-rpc-json", "hex", @@ -1709,8 +1710,8 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "bincode", "dashcore", @@ -1724,8 +1725,8 @@ dependencies = [ [[package]] name = "dashcore_hashes" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "bincode", "dashcore-private", @@ -2632,6 +2633,11 @@ dependencies = [ "weezl", ] +[[package]] +name = "git-state" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" + [[package]] name = "glob" version = "0.3.3" @@ -3773,8 +3779,8 @@ dependencies = [ [[package]] name = "key-wallet" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "aes", "async-trait", @@ -3801,8 +3807,8 @@ dependencies = [ [[package]] name = "key-wallet-ffi" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "cbindgen 0.29.2", "dash-network", @@ -3817,8 +3823,8 @@ dependencies = [ [[package]] name = "key-wallet-manager" -version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=cfb01fa751951b628a7272558e93278348b2cd1f#cfb01fa751951b628a7272558e93278348b2cd1f" +version = "0.43.0" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc#f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" dependencies = [ "async-trait", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 4896eef20bb..58fbcf368b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,14 +49,14 @@ members = [ ] [workspace.dependencies] -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "cfb01fa751951b628a7272558e93278348b2cd1f" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "f569e7b7b99dfe589c41f9ba7d36fbbe6805acdc" } # Optimize heavy crypto crates even in dev/test builds so that # Halo 2 proof generation and verification run at near-release speed. diff --git a/packages/rs-platform-wallet/src/spv/runtime.rs b/packages/rs-platform-wallet/src/spv/runtime.rs index d0c56e48b7a..a68eb683677 100644 --- a/packages/rs-platform-wallet/src/spv/runtime.rs +++ b/packages/rs-platform-wallet/src/spv/runtime.rs @@ -1,12 +1,11 @@ //! SPV client runtime — manages the DashSpvClient lifecycle. -use std::sync::{Arc, Mutex as StdMutex}; +use std::sync::Arc; use tokio::sync::RwLock; use dashcore::sml::llmq_type::LLMQType; use dashcore::{QuorumHash, Transaction}; -use tokio_util::sync::CancellationToken; use dash_spv::network::PeerNetworkManager; use dash_spv::storage::DiskStorageManager; @@ -30,10 +29,6 @@ pub struct SpvRuntime { event_manager: Arc, wallet_manager: Arc>>, client: RwLock>, - /// Cancel token for the `run()` task when it was spawned via - /// [`spawn_in_background`]. [`stop`] fires this token and joins - /// on the client shutdown. - background_cancel: StdMutex>, } // TODO: We want it better impl SpvRuntime { @@ -46,7 +41,6 @@ impl SpvRuntime { event_manager, wallet_manager, client: RwLock::new(None), - background_cancel: StdMutex::new(None), } } @@ -109,6 +103,9 @@ impl SpvRuntime { .await .map_err(|e| PlatformWalletError::SpvError(e.to_string()))?; + let mut client = self.client.write().await; + let _ = client.take(); + Ok(()) } @@ -135,63 +132,25 @@ impl SpvRuntime { Ok(*quorum.quorum_entry.quorum_public_key.as_ref()) } - /// Run the SPV sync loop until the cancellation token fires. - pub async fn run( - &self, - config: ClientConfig, - cancel_token: CancellationToken, - ) -> Result<(), PlatformWalletError> { + /// Run the SPV sync loop until calling [`stop`]. This blocks the current thread. + pub async fn run(&self, config: ClientConfig) -> Result<(), PlatformWalletError> { tracing::info!("SpvRuntime::run() starting client..."); self.start(config).await?; tracing::info!("SpvRuntime::run() client started, entering sync loop"); - let result = { - let client_guard = self.client.read().await; - let client = client_guard - .as_ref() - .ok_or(PlatformWalletError::SpvNotRunning)?; - - let run_cancel = CancellationToken::new(); - let run_future = client.run(run_cancel.clone()); - tokio::pin!(run_future); - - tokio::select! { - res = &mut run_future => { - tracing::info!("SpvRuntime::run() client.run() completed: {:?}", res.is_ok()); - res.map_err(|e| PlatformWalletError::SpvError(e.to_string())) - } - _ = cancel_token.cancelled() => { - tracing::info!("SpvRuntime::run() cancel_token fired, cancelling client"); - run_cancel.cancel(); - Ok(()) - } - } - }; - - tracing::info!( - "SpvRuntime::run() exiting sync loop, result ok={}", - result.is_ok() - ); - if let Err(e) = self.stop().await { - tracing::warn!("SPV stop error during cleanup: {}", e); - } - tracing::info!("SpvRuntime::run() done"); - result + let client_guard = self.client.read().await; + let client = client_guard + .as_ref() + .ok_or(PlatformWalletError::SpvNotRunning)?; + + client + .run() + .await + .map_err(|e| PlatformWalletError::SpvError(e.to_string())) } /// Stop SPV sync gracefully. - /// - /// If a `run()` task was spawned via [`spawn_in_background`], its - /// cancel token is fired here too so the background task exits. pub async fn stop(&self) -> Result<(), PlatformWalletError> { - if let Some(token) = self - .background_cancel - .lock() - .expect("background_cancel poisoned") - .take() - { - token.cancel(); - } let mut client = self.client.write().await; if let Some(c) = client.take() { c.stop() @@ -203,22 +162,11 @@ impl SpvRuntime { /// Spawn `run()` on the current tokio runtime and return immediately. /// - /// The returned cancel token is stashed internally; calling [`stop`] - /// fires it and awaits client shutdown. Replacing an already-running - /// background task cancels the previous one first. + /// Call [`stop`] to stop it pub fn spawn_in_background(self: &Arc, config: ClientConfig) { - // Cancel any previous run. - let mut guard = self.background_cancel.lock().expect("bg_cancel poisoned"); - if let Some(prev) = guard.take() { - prev.cancel(); - } - let cancel = CancellationToken::new(); - *guard = Some(cancel.clone()); - drop(guard); - let this = Arc::clone(self); tokio::spawn(async move { - if let Err(e) = this.run(config, cancel).await { + if let Err(e) = this.run(config).await { tracing::warn!("SpvRuntime background run exited with error: {}", e); } }); diff --git a/packages/rs-platform-wallet/tests/spv_sync.rs b/packages/rs-platform-wallet/tests/spv_sync.rs index fb621bafcd0..b91206de056 100644 --- a/packages/rs-platform-wallet/tests/spv_sync.rs +++ b/packages/rs-platform-wallet/tests/spv_sync.rs @@ -28,7 +28,6 @@ use platform_wallet::changeset::{ use platform_wallet::events::{EventHandler, PlatformEventHandler}; use platform_wallet::wallet::platform_wallet::WalletId; use platform_wallet::PlatformWalletManager; -use tokio_util::sync::CancellationToken; /// Recording persister that captures all store calls for test verification. struct RecordingPersister { @@ -220,11 +219,9 @@ async fn test_spv_sync_and_balance() { } // --- Start SPV in background --- - let cancel = CancellationToken::new(); let manager_for_spv = Arc::clone(&manager); - let cancel_for_spv = cancel.clone(); let spv_handle = tokio::spawn(async move { - if let Err(e) = manager_for_spv.spv().run(config, cancel_for_spv).await { + if let Err(e) = manager_for_spv.spv().run(config).await { eprintln!("SPV runtime error: {}", e); } }); @@ -243,7 +240,7 @@ async fn test_spv_sync_and_balance() { loop { if start.elapsed() > timeout { - cancel.cancel(); + let _ = manager.spv().stop().await; let _ = spv_handle.await; panic!("Timeout waiting for wallet balance after {:?}", timeout); } @@ -268,7 +265,7 @@ async fn test_spv_sync_and_balance() { if confirmed > 0 { println!("SUCCESS: Wallet has confirmed balance: {} duffs", confirmed); - cancel.cancel(); + let _ = manager.spv().stop().await; let _ = spv_handle.await; // --- Verify persistence ---