diff --git a/client/blockchain-service/src/capacity_manager.rs b/client/blockchain-service/src/capacity_manager.rs index 75086c124..dab114861 100644 --- a/client/blockchain-service/src/capacity_manager.rs +++ b/client/blockchain-service/src/capacity_manager.rs @@ -1,4 +1,4 @@ -use std::collections::VecDeque; +use std::{collections::VecDeque, time::Duration}; use anyhow::anyhow; use log::{debug, error}; @@ -11,7 +11,7 @@ use shc_forest_manager::traits::ForestStorageHandler; use sp_api::ProvideRuntimeApi; use sp_core::H256; -use crate::{transaction::SubmittedTransaction, BlockchainService}; +use crate::{transaction::SubmittedTransaction, types::SendExtrinsicOptions, BlockchainService}; const LOG_TARGET: &str = "blockchain-service-capacity-manager"; @@ -304,13 +304,23 @@ where pallet_storage_providers::Call::change_capacity { new_capacity }, ); + let extrinsic_retry_timeout = Duration::from_secs(self.config.extrinsic_retry_timeout); + // Send extrinsic to increase capacity - match self.send_extrinsic(call, Default::default()).await { + match self + .send_extrinsic(call, &SendExtrinsicOptions::new(extrinsic_retry_timeout)) + .await + { Ok(output) => { // Add all pending requests to the list of requests waiting for inclusion. if let Some(capacity_manager) = self.capacity_manager.as_mut() { capacity_manager.add_pending_requests_to_waiting_for_inclusion( - SubmittedTransaction::new(output.receiver, output.hash, output.nonce), + SubmittedTransaction::new( + output.receiver, + output.hash, + output.nonce, + extrinsic_retry_timeout, + ), ); } else { error!(target: LOG_TARGET, "Capacity manager not initialized"); diff --git a/client/blockchain-service/src/commands.rs b/client/blockchain-service/src/commands.rs index c190eb7a5..de4f63f34 100644 --- a/client/blockchain-service/src/commands.rs +++ b/client/blockchain-service/src/commands.rs @@ -401,6 +401,7 @@ pub trait BlockchainServiceInterface { async fn submit_extrinsic_with_retry( &self, call: impl Into + Send, + options: SendExtrinsicOptions, retry_strategy: RetryStrategy, with_events: bool, ) -> Result>; @@ -849,6 +850,7 @@ where async fn submit_extrinsic_with_retry( &self, call: impl Into + Send, + options: SendExtrinsicOptions, retry_strategy: RetryStrategy, with_events: bool, ) -> Result> { @@ -861,14 +863,11 @@ where for retry_count in 0..=retry_strategy.max_retries { debug!(target: LOG_TARGET, "Submitting transaction {:?} with tip {}", call, tip); - let extrinsic_options = SendExtrinsicOptions::new() + let extrinsic_options = SendExtrinsicOptions::new(options.timeout()) .with_tip(tip as u128) .with_nonce(nonce); - let mut transaction = self - .send_extrinsic(call.clone(), extrinsic_options) - .await? - .with_timeout(retry_strategy.timeout); + let mut transaction = self.send_extrinsic(call.clone(), extrinsic_options).await?; let result: Result, _> = if with_events { transaction diff --git a/client/blockchain-service/src/handler.rs b/client/blockchain-service/src/handler.rs index 5e3065d57..62eeeaa70 100644 --- a/client/blockchain-service/src/handler.rs +++ b/client/blockchain-service/src/handler.rs @@ -110,6 +110,8 @@ pub struct BlockchainService where FSH: ForestStorageHandler + Clone + Send + Sync + 'static, { + /// The configuration for the BlockchainService. + pub(crate) config: BlockchainServiceConfig, /// The event bus provider. pub(crate) event_bus_provider: BlockchainServiceEventBusProvider, /// The parachain client. Used to interact with the runtime. @@ -279,13 +281,14 @@ where call, options, callback, - } => match self.send_extrinsic(call, options).await { + } => match self.send_extrinsic(call, &options).await { Ok(output) => { debug!(target: LOG_TARGET, "Extrinsic sent successfully: {:?}", output); match callback.send(Ok(SubmittedTransaction::new( output.receiver, output.hash, output.nonce, + options.timeout(), ))) { Ok(_) => { trace!(target: LOG_TARGET, "Receiver sent successfully"); @@ -1100,6 +1103,7 @@ where { /// Create a new [`BlockchainService`]. pub fn new( + config: BlockchainServiceConfig, client: Arc, keystore: KeystorePtr, rpc_handlers: Arc, @@ -1109,6 +1113,7 @@ where capacity_request_queue: Option, ) -> Self { Self { + config, event_bus_provider: BlockchainServiceEventBusProvider::new(), client, keystore, diff --git a/client/blockchain-service/src/lib.rs b/client/blockchain-service/src/lib.rs index cb1f111d6..d18513457 100644 --- a/client/blockchain-service/src/lib.rs +++ b/client/blockchain-service/src/lib.rs @@ -11,6 +11,7 @@ pub mod utils; use std::{path::PathBuf, sync::Arc}; use capacity_manager::{CapacityConfig, CapacityRequestQueue}; +use handler::BlockchainServiceConfig; use sc_service::RpcHandlers; use sp_keystore::KeystorePtr; @@ -21,6 +22,7 @@ pub use self::handler::BlockchainService; pub async fn spawn_blockchain_service( task_spawner: &TaskSpawner, + config: BlockchainServiceConfig, client: Arc, keystore: KeystorePtr, rpc_handlers: Arc, @@ -37,6 +39,7 @@ where .with_group("network"); let blockchain_service = BlockchainService::::new( + config, client, keystore, rpc_handlers, diff --git a/client/blockchain-service/src/transaction.rs b/client/blockchain-service/src/transaction.rs index 4e6b6a686..8acb09cf0 100644 --- a/client/blockchain-service/src/transaction.rs +++ b/client/blockchain-service/src/transaction.rs @@ -3,7 +3,7 @@ use std::{ time::{Duration, Instant}, }; -use log::{debug, error, info, warn}; +use log::{debug, error, info}; use shc_actors_framework::actor::ActorHandle; use shc_common::types::StorageHubEventsVec; use shc_forest_manager::traits::ForestStorageHandler; @@ -30,21 +30,18 @@ pub struct SubmittedTransaction { watcher: Receiver, /// The hash of the transaction. hash: ExtrinsicHash, - /// The maximum amount of time to wait for the transaction to either be successful or fail. - timeout: Option, /// The nonce of the transaction. nonce: u32, + /// The maximum amount of time to wait for the transaction to either be successful or fail. + timeout: Duration, } -/// TODO: CONSTANTS -const DEFAULT_WATCH_TRANSACTION_TIMEOUT: Duration = Duration::from_secs(60); - impl SubmittedTransaction { - pub fn new(watcher: Receiver, hash: H256, nonce: u32) -> Self { + pub fn new(watcher: Receiver, hash: H256, nonce: u32, timeout: Duration) -> Self { Self { watcher, hash, - timeout: None, + timeout, nonce, } } @@ -59,15 +56,6 @@ impl SubmittedTransaction { self.nonce } - /// Sets the timeout for the transaction. - /// - /// If the transaction is not successful within the specified timeout, it will be considered - /// failed and an error will be returned. - pub fn with_timeout(mut self, timeout: Duration) -> Self { - self.timeout = Some(timeout); - self - } - /// Handles the lifecycle of a submitted transaction. /// /// Waits for the transaction to be included in a block AND the checks the transaction is successful. @@ -168,18 +156,14 @@ impl SubmittedTransaction { // Get the elapsed time since submit. let elapsed = start_time.elapsed(); // Calculate the remaining time to wait. - let remaining = match self.timeout { - Some(timeout) => { - // Check if the timeout has been reached. - if elapsed > timeout { - error!(target: LOG_TARGET, "Timeout waiting for transaction {} to be included in a block", self.hash); - return Err(WatchTransactionError::Timeout); - } - timeout - elapsed - } - None => DEFAULT_WATCH_TRANSACTION_TIMEOUT, - }; + // Check if the timeout has been reached. + if elapsed > self.timeout { + error!(target: LOG_TARGET, "Timeout waiting for transaction {} to be included in a block", self.hash); + return Err(WatchTransactionError::Timeout); + } + + let remaining = self.timeout - elapsed; // Wait for either a new message from the watcher, or the timeout to be reached. let result = match tokio::time::timeout(remaining, self.watcher.recv()).await { @@ -192,20 +176,11 @@ impl SubmittedTransaction { }, Err(_) => { // Timeout reached, exit the loop. - match self.timeout { - Some(_) => { - error!(target: LOG_TARGET, "Timeout waiting for transaction to be included in a block"); - return Err(WatchTransactionError::Timeout); - } - None => { - // No timeout set, continue waiting. - warn!(target: LOG_TARGET, "No timeout set and {:?} elapsed, continuing to wait for transaction to be included in a block.", DEFAULT_WATCH_TRANSACTION_TIMEOUT); - - continue; - } - } + error!(target: LOG_TARGET, "Timeout waiting for transaction to be included in a block"); + return Err(WatchTransactionError::Timeout); } }; + // Parse the JSONRPC string. The strings sent by the RPC wacher should be valid JSONRPC strings. let json: serde_json::Value = serde_json::from_str(&result).map_err(|_| { let err_msg = format!( diff --git a/client/blockchain-service/src/types.rs b/client/blockchain-service/src/types.rs index 429c4ed36..466ffd404 100644 --- a/client/blockchain-service/src/types.rs +++ b/client/blockchain-service/src/types.rs @@ -237,11 +237,17 @@ pub struct SendExtrinsicOptions { tip: Tip, /// Optionally override the nonce to use when sending the transaction. nonce: Option, + /// Maximum time to wait for a response before assuming the extrinsic submission has failed. + timeout: Duration, } impl SendExtrinsicOptions { - pub fn new() -> Self { - Self::default() + pub fn new(timeout: Duration) -> Self { + Self { + tip: Tip::from(0), + nonce: None, + timeout, + } } pub fn with_tip(mut self, tip: u128) -> Self { @@ -261,6 +267,10 @@ impl SendExtrinsicOptions { pub fn nonce(&self) -> Option { self.nonce } + + pub fn timeout(&self) -> Duration { + self.timeout + } } impl Default for SendExtrinsicOptions { @@ -268,6 +278,7 @@ impl Default for SendExtrinsicOptions { Self { tip: Tip::from(0), nonce: None, + timeout: Duration::from_secs(60), } } } @@ -287,8 +298,6 @@ impl Default for SendExtrinsicOptions { pub struct RetryStrategy { /// Maximum number of retries after which the extrinsic submission will be considered failed. pub max_retries: u32, - /// Maximum time to wait for a response before assuming the extrinsic submission has failed. - pub timeout: Duration, /// Maximum tip to be paid for the extrinsic submission. The progression follows an exponential /// backoff strategy. pub max_tip: f64, @@ -310,10 +319,9 @@ pub struct RetryStrategy { impl RetryStrategy { /// Creates a new `RetryStrategy` instance. - pub fn new(max_retries: u32, timeout: Duration, max_tip: f64, base_multiplier: f64) -> Self { + pub fn new(max_retries: u32, max_tip: f64, base_multiplier: f64) -> Self { Self { max_retries, - timeout, max_tip, base_multiplier, should_retry: None, @@ -326,14 +334,6 @@ impl RetryStrategy { self } - /// Set the timeout for the extrinsic. - /// - /// After this timeout, the extrinsic will be retried (if applicable) or fail. - pub fn with_timeout(mut self, timeout: Duration) -> Self { - self.timeout = timeout; - self - } - /// Set the maximum tip for the extrinsic. /// /// As the number of times the extrinsic is retried increases, the tip will increase @@ -413,7 +413,6 @@ impl Default for RetryStrategy { fn default() -> Self { Self { max_retries: 5, - timeout: Duration::from_secs(30), max_tip: 0.0, base_multiplier: 2.0, should_retry: None, diff --git a/client/blockchain-service/src/utils.rs b/client/blockchain-service/src/utils.rs index 6b8b18d17..17e286901 100644 --- a/client/blockchain-service/src/utils.rs +++ b/client/blockchain-service/src/utils.rs @@ -441,7 +441,7 @@ where pub(crate) async fn send_extrinsic( &mut self, call: impl Into, - options: SendExtrinsicOptions, + options: &SendExtrinsicOptions, ) -> Result { debug!(target: LOG_TARGET, "Sending extrinsic to the runtime"); diff --git a/node/src/services/builder.rs b/node/src/services/builder.rs index c7711760f..10e7ca481 100644 --- a/node/src/services/builder.rs +++ b/node/src/services/builder.rs @@ -159,10 +159,13 @@ where let capacity_config = self.capacity_config.clone(); + let blockchain_service_config = self.blockchain_service_config.clone().unwrap_or_default(); + let blockchain_service_handle = spawn_blockchain_service::<<(R, S) as ShNodeType>::FSH>( self.task_spawner .as_ref() .expect("Task spawner is not set."), + blockchain_service_config, client.clone(), keystore.clone(), rpc_handlers.clone(), diff --git a/node/src/tasks/bsp_charge_fees.rs b/node/src/tasks/bsp_charge_fees.rs index c6f94c2a3..282b91609 100644 --- a/node/src/tasks/bsp_charge_fees.rs +++ b/node/src/tasks/bsp_charge_fees.rs @@ -9,7 +9,7 @@ use shc_blockchain_service::{ LastChargeableInfoUpdated, ProcessStopStoringForInsolventUserRequest, SpStopStoringInsolventUser, UserWithoutFunds, }, - types::StopStoringForInsolventUserRequest, + types::{SendExtrinsicOptions, StopStoringForInsolventUserRequest}, }; use shc_common::{consts::CURRENT_FOREST_KEY, types::MaxUsersToCharge}; use shc_forest_manager::traits::{ForestStorage, ForestStorageHandler}; @@ -317,15 +317,15 @@ where // continue only if it is successful. self.storage_hub_handler .blockchain - .send_extrinsic(stop_storing_for_insolvent_user_call, Default::default()) - .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) - .watch_for_success(&self.storage_hub_handler.blockchain) + .send_extrinsic( + stop_storing_for_insolvent_user_call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await?; trace!(target: LOG_TARGET, "Stop storing submitted successfully"); diff --git a/node/src/tasks/bsp_submit_proof.rs b/node/src/tasks/bsp_submit_proof.rs index 5bb911817..89091b4b0 100644 --- a/node/src/tasks/bsp_submit_proof.rs +++ b/node/src/tasks/bsp_submit_proof.rs @@ -12,7 +12,7 @@ use shc_blockchain_service::{ events::{ FinalisedTrieRemoveMutationsApplied, MultipleNewChallengeSeeds, ProcessSubmitProofRequest, }, - types::{RetryStrategy, SubmitProofRequest, WatchTransactionError}, + types::{RetryStrategy, SendExtrinsicOptions, SubmitProofRequest, WatchTransactionError}, BlockchainService, }; use shc_common::{ @@ -313,15 +313,15 @@ where .blockchain .submit_extrinsic_with_retry( call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), RetryStrategy::default() .with_max_retries(MAX_PROOF_SUBMISSION_ATTEMPTS) .with_max_tip(max_tip as f64) - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .with_should_retry(Some(Box::new(should_retry))), false, ) diff --git a/node/src/tasks/bsp_upload_file.rs b/node/src/tasks/bsp_upload_file.rs index 7ae683a12..8d410bab6 100644 --- a/node/src/tasks/bsp_upload_file.rs +++ b/node/src/tasks/bsp_upload_file.rs @@ -16,7 +16,7 @@ use shc_blockchain_service::{ capacity_manager::CapacityRequestData, commands::BlockchainServiceInterface, events::{NewStorageRequest, ProcessConfirmStoringRequest}, - types::{ConfirmStoringRequest, RetryStrategy}, + types::{ConfirmStoringRequest, RetryStrategy, SendExtrinsicOptions}, }; use shc_common::{ consts::CURRENT_FOREST_KEY, @@ -368,15 +368,15 @@ where .blockchain .submit_extrinsic_with_retry( call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), RetryStrategy::default() .with_max_retries(self.config.max_try_count) .with_max_tip(self.config.max_tip) - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .retry_only_if_timeout(), true, ) @@ -643,14 +643,16 @@ where let result = self .storage_hub_handler .blockchain - .send_extrinsic(call.clone(), Default::default()) + .send_extrinsic( + call.clone(), + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await; @@ -673,14 +675,16 @@ where let result = self .storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await; diff --git a/node/src/tasks/mock_bsp_volunteer.rs b/node/src/tasks/mock_bsp_volunteer.rs index 44afe6b1e..c431e8b0a 100644 --- a/node/src/tasks/mock_bsp_volunteer.rs +++ b/node/src/tasks/mock_bsp_volunteer.rs @@ -4,7 +4,9 @@ use std::time::Duration; use log::*; use shc_actors_framework::event_bus::EventHandler; -use shc_blockchain_service::{commands::BlockchainServiceInterface, events::NewStorageRequest}; +use shc_blockchain_service::{ + commands::BlockchainServiceInterface, events::NewStorageRequest, types::SendExtrinsicOptions, +}; use sp_core::H256; use crate::services::{ @@ -66,14 +68,16 @@ where self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await?; diff --git a/node/src/tasks/mock_sp_react_to_event.rs b/node/src/tasks/mock_sp_react_to_event.rs index 489c00237..473645ef5 100644 --- a/node/src/tasks/mock_sp_react_to_event.rs +++ b/node/src/tasks/mock_sp_react_to_event.rs @@ -6,6 +6,7 @@ use log::*; use shc_actors_framework::event_bus::EventHandler; use shc_blockchain_service::{ commands::BlockchainServiceInterface, events::MultipleNewChallengeSeeds, + types::SendExtrinsicOptions, }; use crate::services::{handler::StorageHubHandler, types::ShNodeType}; @@ -69,14 +70,16 @@ where self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await?; diff --git a/node/src/tasks/msp_delete_file.rs b/node/src/tasks/msp_delete_file.rs index 5b478610b..384bf46ec 100644 --- a/node/src/tasks/msp_delete_file.rs +++ b/node/src/tasks/msp_delete_file.rs @@ -9,7 +9,7 @@ use shc_blockchain_service::{ FileDeletionRequest, FinalisedProofSubmittedForPendingFileDeletionRequest, ProcessFileDeletionRequest, }, - types::{self, RetryStrategy}, + types::{self, RetryStrategy, SendExtrinsicOptions}, }; use shc_file_manager::traits::FileStorage; use shc_forest_manager::traits::{ForestStorage, ForestStorageHandler}; @@ -211,15 +211,15 @@ where .blockchain .submit_extrinsic_with_retry( call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), RetryStrategy::default() .with_max_retries(max_try_count) .with_max_tip(max_tip) - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .retry_only_if_timeout(), false, ) diff --git a/node/src/tasks/msp_move_bucket.rs b/node/src/tasks/msp_move_bucket.rs index 0e145635d..82c1694e3 100644 --- a/node/src/tasks/msp_move_bucket.rs +++ b/node/src/tasks/msp_move_bucket.rs @@ -21,7 +21,7 @@ use shc_blockchain_service::{ capacity_manager::CapacityRequestData, commands::BlockchainServiceInterface, events::{MoveBucketRequestedForMsp, StartMovedBucketDownload}, - types::RetryStrategy, + types::{RetryStrategy, SendExtrinsicOptions}, }; use shc_common::types::{ BucketId, FileKeyProof, FileMetadata, HashT, ProviderId, StorageProofsMerkleTrieLayout, @@ -492,15 +492,15 @@ where .blockchain .submit_extrinsic_with_retry( call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), RetryStrategy::default() .with_max_retries(self.config.max_try_count) - .with_max_tip(self.config.max_tip) - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )), + .with_max_tip(self.config.max_tip), false, ) .await @@ -538,15 +538,15 @@ where .blockchain .submit_extrinsic_with_retry( call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), RetryStrategy::default() .with_max_retries(self.config.max_try_count) - .with_max_tip(self.config.max_tip) - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )), + .with_max_tip(self.config.max_tip), false, ) .await diff --git a/node/src/tasks/msp_stop_storing_insolvent_user.rs b/node/src/tasks/msp_stop_storing_insolvent_user.rs index f617779e9..ccf3846b0 100644 --- a/node/src/tasks/msp_stop_storing_insolvent_user.rs +++ b/node/src/tasks/msp_stop_storing_insolvent_user.rs @@ -279,15 +279,14 @@ where .blockchain .send_extrinsic( stop_storing_bucket_for_insolvent_user_call, - SendExtrinsicOptions::default(), + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await { diff --git a/node/src/tasks/msp_upload_file.rs b/node/src/tasks/msp_upload_file.rs index c8b16d7d1..deda59dd8 100644 --- a/node/src/tasks/msp_upload_file.rs +++ b/node/src/tasks/msp_upload_file.rs @@ -7,8 +7,8 @@ use std::{ use sc_network::PeerId; use sc_tracing::tracing::*; -use shc_blockchain_service::capacity_manager::CapacityRequestData; use shc_blockchain_service::types::{MspRespondStorageRequest, RespondStorageRequest}; +use shc_blockchain_service::{capacity_manager::CapacityRequestData, types::SendExtrinsicOptions}; use sp_core::H256; use sp_runtime::AccountId32; @@ -322,9 +322,16 @@ where self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs(60)) .watch_for_success(&self.storage_hub_handler.blockchain) .await?; @@ -530,9 +537,16 @@ where self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs(60)) .watch_for_success(&self.storage_hub_handler.blockchain) .await?; @@ -841,9 +855,16 @@ where self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs(60)) .watch_for_success(&self.storage_hub_handler.blockchain) .await?; diff --git a/node/src/tasks/sp_slash_provider.rs b/node/src/tasks/sp_slash_provider.rs index 6dcf3dbc6..535e96006 100644 --- a/node/src/tasks/sp_slash_provider.rs +++ b/node/src/tasks/sp_slash_provider.rs @@ -3,7 +3,9 @@ use std::time::Duration; use sc_tracing::tracing::*; use shc_actors_framework::event_bus::EventHandler; -use shc_blockchain_service::{commands::BlockchainServiceInterface, events::SlashableProvider}; +use shc_blockchain_service::{ + commands::BlockchainServiceInterface, events::SlashableProvider, types::SendExtrinsicOptions, +}; use crate::services::{handler::StorageHubHandler, types::ShNodeType}; @@ -77,14 +79,16 @@ where // Send extrinsic and wait for it to be included in the block. self.storage_hub_handler .blockchain - .send_extrinsic(call, Default::default()) + .send_extrinsic( + call, + SendExtrinsicOptions::new(Duration::from_secs( + self.storage_hub_handler + .provider_config + .blockchain_service + .extrinsic_retry_timeout, + )), + ) .await? - .with_timeout(Duration::from_secs( - self.storage_hub_handler - .provider_config - .blockchain_service - .extrinsic_retry_timeout, - )) .watch_for_success(&self.storage_hub_handler.blockchain) .await?;