diff --git a/lib/src/json_rpc/methods.rs b/lib/src/json_rpc/methods.rs index 92c6aaeabe..c8ffefc04c 100644 --- a/lib/src/json_rpc/methods.rs +++ b/lib/src/json_rpc/methods.rs @@ -448,15 +448,13 @@ define_methods! { // The functions below are experimental and are defined in the document https://github.com/paritytech/json-rpc-interface-spec/ chainHead_unstable_body( #[rename = "followSubscription"] follow_subscription: Cow<'a, str>, - hash: HashHexString, - #[rename = "networkConfig"] network_config: Option + hash: HashHexString ) -> Cow<'a, str>, chainHead_unstable_call( #[rename = "followSubscription"] follow_subscription: Cow<'a, str>, hash: HashHexString, function: Cow<'a, str>, - #[rename = "callParameters"] call_parameters: HexString, - #[rename = "networkConfig"] network_config: Option + #[rename = "callParameters"] call_parameters: HexString ) -> Cow<'a, str>, chainHead_unstable_follow( #[rename = "withRuntime"] with_runtime: bool @@ -479,8 +477,7 @@ define_methods! { #[rename = "followSubscription"] follow_subscription: Cow<'a, str>, hash: HashHexString, items: Vec, - #[rename = "childTrie"] child_trie: Option, - #[rename = "networkConfig"] network_config: Option + #[rename = "childTrie"] child_trie: Option ) -> Cow<'a, str>, chainHead_unstable_storageContinue( #[rename = "subscription"] subscription: Cow<'a, str> @@ -998,16 +995,6 @@ pub struct HeaderDigest { pub logs: Vec, } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct NetworkConfig { - #[serde(rename = "totalAttempts")] - pub total_attempts: u32, - #[serde(rename = "maxParallel")] - pub max_parallel: u32, // TODO: NonZeroU32? - #[serde(rename = "timeoutMs")] - pub timeout_ms: u32, -} - #[derive(Debug, Clone)] pub struct RpcMethods { pub methods: Vec, diff --git a/light-base/src/json_rpc_service/background/chain_head.rs b/light-base/src/json_rpc_service/background/chain_head.rs index 3d7b673fb5..b6b1f16d62 100644 --- a/light-base/src/json_rpc_service/background/chain_head.rs +++ b/light-base/src/json_rpc_service/background/chain_head.rs @@ -29,7 +29,7 @@ use alloc::{ vec::Vec, }; use core::{ - cmp, iter, + iter, num::{NonZeroU32, NonZeroUsize}, time::Duration, }; @@ -800,7 +800,6 @@ impl ChainHeadFollowTask { async fn start_chain_head_body(&mut self, request: service::SubscriptionStartProcess) { let methods::MethodCall::chainHead_unstable_body { hash, - network_config, .. } = request.request() else { @@ -820,12 +819,6 @@ impl ChainHeadFollowTask { } }; - let network_config = network_config.unwrap_or(methods::NetworkConfig { - max_parallel: 1, - timeout_ms: 4000, - total_attempts: 3, - }); - let mut subscription = request.accept(); let subscription_id = subscription.subscription_id().to_owned(); @@ -843,12 +836,9 @@ impl ChainHeadFollowTask { body: true, justifications: false, }, - cmp::min(10, network_config.total_attempts), - Duration::from_millis(u64::from(cmp::min( - 20000, - network_config.timeout_ms, - ))), - NonZeroU32::new(network_config.max_parallel.clamp(1, 5)).unwrap(), + 3, + Duration::from_secs(20), + NonZeroU32::new(2).unwrap(), ); // Drive the future, but cancel execution if the JSON-RPC client @@ -900,7 +890,6 @@ impl ChainHeadFollowTask { hash, items, child_trie, - network_config, .. } = request.request() else { @@ -918,12 +907,6 @@ impl ChainHeadFollowTask { } }; - let network_config = network_config.unwrap_or(methods::NetworkConfig { - max_parallel: 1, - timeout_ms: 8000, - total_attempts: 3, - }); - if child_trie.is_some() { // TODO: implement this request.fail(json_rpc::parse::ErrorResponse::ServerError( @@ -998,12 +981,9 @@ impl ChainHeadFollowTask { &hash.0, decoded_header.state_root, queries.into_iter(), - cmp::min(10, network_config.total_attempts), - Duration::from_millis(u64::from(cmp::min( - 20000, - network_config.timeout_ms, - ))), - NonZeroU32::new(network_config.max_parallel.clamp(1, 5)).unwrap(), + 3, + Duration::from_secs(20), + NonZeroU32::new(2).unwrap(), ); // Drive the future, but cancel execution if the JSON-RPC client @@ -1102,30 +1082,18 @@ impl ChainHeadFollowTask { } async fn start_chain_head_call(&mut self, request: service::SubscriptionStartProcess) { - let (hash, function_to_call, call_parameters, network_config) = { + let (hash, function_to_call, call_parameters) = { let methods::MethodCall::chainHead_unstable_call { hash, function, call_parameters, - network_config, .. } = request.request() else { unreachable!() }; - let network_config = network_config.unwrap_or(methods::NetworkConfig { - max_parallel: 1, - timeout_ms: 8000, - total_attempts: 3, - }); - - ( - hash, - function.into_owned(), - call_parameters.0, - network_config, - ) + (hash, function.into_owned(), call_parameters.0) }; // Determine whether the requested block hash is valid and start the call. @@ -1180,12 +1148,9 @@ impl ChainHeadFollowTask { let call_future = pre_runtime_call.start( &function_to_call, iter::once(&call_parameters), - cmp::min(10, network_config.total_attempts), - Duration::from_millis(u64::from(cmp::min( - 20000, - network_config.timeout_ms, - ))), - NonZeroU32::new(network_config.max_parallel.clamp(1, 5)).unwrap(), + 3, + Duration::from_secs(20), + NonZeroU32::new(2).unwrap(), ); // Drive the future, but cancel execution if the JSON-RPC client unsubscribes. diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index 469cc27e6f..ae1123831d 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changed +- Remove `networkConfig` parameter from all `chainHead` JSON-RPC functions, in accordance with the latest changes to the JSON-RPC API specification. ([#963](https://github.com/smol-dot/smoldot/pull/963)) - A JSON-RPC error is now returned if the JSON-RPC client tries to open more than two simultaneous `chainHead_unstable_follow` subscriptions, in accordance with the latest changes in the JSON-RPC API specification. ([#962](https://github.com/smol-dot/smoldot/pull/962)) ## 1.0.13 - 2023-07-16