Skip to content
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

Rename runtimeUpdates to withRuntime #624

Merged
merged 2 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/json_rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ define_methods! {
#[rename = "networkConfig"] network_config: Option<NetworkConfig>
) -> 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(
Expand Down Expand Up @@ -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<MaybeRuntimeSpec<'a>>,
},
#[serde(rename = "bestBlockChanged")]
Expand Down
4 changes: 2 additions & 2 deletions light-base/src/json_rpc_service/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,8 @@ impl<TPlat: PlatformRef> Background<TPlat> {
)
.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 {} => {
Expand Down
22 changes: 11 additions & 11 deletions light-base/src/json_rpc_service/background/chain_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<TPlat: PlatformRef> Background<TPlat> {
pub(super) async fn chain_head_follow(
self: &Arc<Self>,
request_id: (&str, &requests_subscriptions::RequestId),
runtime_updates: bool,
with_runtime: bool,
) {
let (subscription_id, messages_rx, subscription_start) = match self
.requests_subscriptions
Expand All @@ -126,7 +126,7 @@ impl<TPlat: PlatformRef> Background<TPlat> {
}
};

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())
Expand Down Expand Up @@ -312,11 +312,11 @@ impl<TPlat: PlatformRef> Background<TPlat> {
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,
Expand Down Expand Up @@ -707,12 +707,12 @@ struct ChainHeadFollowTask<TPlat: PlatformRef> {
}

enum Subscription<TPlat: PlatformRef> {
RuntimeUpdates {
WithRuntime {
notifications: runtime_service::Subscription<TPlat>,
subscription_id: runtime_service::SubscriptionId,
},
// TODO: better typing?
NoRuntimeUpdates(mpsc::Receiver<sync_service::Notification>),
WithoutRuntime(mpsc::Receiver<sync_service::Notification>),
}

impl<TPlat: PlatformRef> ChainHeadFollowTask<TPlat> {
Expand Down Expand Up @@ -750,10 +750,10 @@ impl<TPlat: PlatformRef> ChainHeadFollowTask<TPlat> {
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))
}
});
Expand Down Expand Up @@ -1086,7 +1086,7 @@ impl<TPlat: PlatformRef> ChainHeadFollowTask<TPlat> {
} => {
// 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) {
Expand All @@ -1109,7 +1109,7 @@ impl<TPlat: PlatformRef> ChainHeadFollowTask<TPlat> {
.await
.ok()
}
Subscription::NoRuntimeUpdates(_) => {
Subscription::WithoutRuntime(_) => {
requests_subscriptions
.respond(
&get_request_id.1,
Expand Down Expand Up @@ -1162,7 +1162,7 @@ impl<TPlat: PlatformRef> ChainHeadFollowTask<TPlat> {
} => {
let valid = {
if self.pinned_blocks_headers.remove(&hash.0).is_some() {
if let Subscription::RuntimeUpdates {
if let Subscription::WithRuntime {
subscription_id, ..
} = self.subscription
{
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down