diff --git a/lib/src/json_rpc/methods.rs b/lib/src/json_rpc/methods.rs index d788a9b5d7..31d1a8b7d5 100644 --- a/lib/src/json_rpc/methods.rs +++ b/lib/src/json_rpc/methods.rs @@ -440,7 +440,7 @@ define_methods! { #[rename = "networkConfig"] network_config: Option ) -> Cow<'a, str>, chainHead_unstable_follow( - #[rename = "runtimeUpdates"] runtime_updates: bool + #[rename = "withRuntime"] with_runtime: bool ) -> Cow<'a, str>, chainHead_unstable_genesisHash() -> HashHexString, chainHead_unstable_header( @@ -679,7 +679,7 @@ pub enum FollowEvent<'a> { #[serde(rename = "parentBlockHash")] parent_block_hash: HashHexString, #[serde(rename = "newRuntime")] - // TODO: must not be present if runtime_updates: false + // TODO: must not be present if with_runtime: false new_runtime: Option>, }, #[serde(rename = "bestBlockChanged")] diff --git a/light-base/src/json_rpc_service/background.rs b/light-base/src/json_rpc_service/background.rs index ed85ac73d5..fb88787539 100644 --- a/light-base/src/json_rpc_service/background.rs +++ b/light-base/src/json_rpc_service/background.rs @@ -811,8 +811,8 @@ impl Background { ) .await; } - methods::MethodCall::chainHead_unstable_follow { runtime_updates } => { - self.chain_head_follow((request_id, &state_machine_request_id), runtime_updates) + methods::MethodCall::chainHead_unstable_follow { with_runtime } => { + self.chain_head_follow((request_id, &state_machine_request_id), with_runtime) .await; } methods::MethodCall::chainHead_unstable_genesisHash {} => { 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 9af86c2a46..e8ddef91b9 100644 --- a/light-base/src/json_rpc_service/background/chain_head.rs +++ b/light-base/src/json_rpc_service/background/chain_head.rs @@ -100,7 +100,7 @@ impl Background { pub(super) async fn chain_head_follow( self: &Arc, request_id: (&str, &requests_subscriptions::RequestId), - runtime_updates: bool, + with_runtime: bool, ) { let (subscription_id, messages_rx, subscription_start) = match self .requests_subscriptions @@ -126,7 +126,7 @@ impl Background { } }; - let subscription = if runtime_updates { + let subscription = if with_runtime { let subscribe_all = self .runtime_service .subscribe_all("chainHead_follow", 32, NonZeroUsize::new(32).unwrap()) @@ -312,11 +312,11 @@ impl Background { non_finalized_blocks, pinned_blocks_headers, subscription: match subscription { - either::Left((sub, id)) => Subscription::RuntimeUpdates { + either::Left((sub, id)) => Subscription::WithRuntime { notifications: sub.new_blocks, subscription_id: id, }, - either::Right(sub) => Subscription::NoRuntimeUpdates(sub.new_blocks), + either::Right(sub) => Subscription::WithoutRuntime(sub.new_blocks), }, log_target, runtime_service, @@ -707,12 +707,12 @@ struct ChainHeadFollowTask { } enum Subscription { - RuntimeUpdates { + WithRuntime { notifications: runtime_service::Subscription, subscription_id: runtime_service::SubscriptionId, }, // TODO: better typing? - NoRuntimeUpdates(mpsc::Receiver), + WithoutRuntime(mpsc::Receiver), } impl ChainHeadFollowTask { @@ -750,10 +750,10 @@ impl ChainHeadFollowTask { loop { let outcome = { let next_block = pin::pin!(match &mut self.subscription { - Subscription::RuntimeUpdates { notifications, .. } => { + Subscription::WithRuntime { notifications, .. } => { future::Either::Left(notifications.next().map(either::Left)) } - Subscription::NoRuntimeUpdates(notifications) => { + Subscription::WithoutRuntime(notifications) => { future::Either::Right(notifications.next().map(either::Right)) } }); @@ -1086,7 +1086,7 @@ impl ChainHeadFollowTask { } => { // Determine whether the requested block hash is valid and start the call. let pre_runtime_call = match self.subscription { - Subscription::RuntimeUpdates { + Subscription::WithRuntime { subscription_id, .. } => { if !self.pinned_blocks_headers.contains_key(&hash.0) { @@ -1109,7 +1109,7 @@ impl ChainHeadFollowTask { .await .ok() } - Subscription::NoRuntimeUpdates(_) => { + Subscription::WithoutRuntime(_) => { requests_subscriptions .respond( &get_request_id.1, @@ -1162,7 +1162,7 @@ impl ChainHeadFollowTask { } => { let valid = { if self.pinned_blocks_headers.remove(&hash.0).is_some() { - if let Subscription::RuntimeUpdates { + if let Subscription::WithRuntime { subscription_id, .. } = self.subscription { diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index 486d79b727..ea3b2990dc 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Changed + +- The parameter of `chainHead_unstable_follow` has been renamed from `runtimeUpdates` to `withRuntime` in accordance with the latest JSON-RPC specification changes. ([#624](https://github.com/smol-dot/smoldot/pull/624)) + ## 1.0.7 - 2023-05-25 ### Fixed