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

Simplifications and clean ups to the runtime_service #2180

Merged
merged 8 commits into from
Mar 29, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Mar 28, 2022

See individual commits.

This attempts at cleaning up the code of the service and making it easier to read and understand.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      -12101 ┊ smoldot::network::service::ChainNetwork<TNow>::next_event::{{closure}}::hbd102ed669b6ae15
      +12101 ┊ smoldot::network::service::ChainNetwork<TNow>::next_event::{{closure}}::hffe05df3b4dba7cb
      -11853 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h0e91ac0548663e0b
      +11853 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hcfa24ecbc5cda2fb
      +11342 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hab58f018371ee2ca
      -11342 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hb330ba3a988c4797
      -10121 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h716ea87a926542db
      +10121 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha61c0f1bf19ee8cf
       +9935 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::hd58b0e56085829c8
       -9935 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::heefa7401a5ca14b2
       -8937 ┊ smoldot_light_base::Client<TChain,TPlat>::add_chain::h9182a7df5a1f8064
       +8937 ┊ smoldot_light_base::Client<TChain,TPlat>::add_chain::hb6f8871050d47773
       -7811 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1b5f251e2271db9a
       +7769 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h20c3fdbb4438cefe
       +6739 ┊ <&mut serde_json::de::Deserializer<R> as serde::de::Deserializer>::deserialize_map::h47215ba8aa4d15bb
       -6739 ┊ <&mut serde_json::de::Deserializer<R> as serde::de::Deserializer>::deserialize_map::hd3fbff4492efddb0
       +6150 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h66217759a1c827a2
       -6150 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc08c77ba2819f277
       +5852 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h44c1fc6e0e4c14af
       -5852 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hf8a0d83e3b74eb3e
       -2658 ┊ ... and 16507 more.
       -4221 ┊ Σ [16527 Total Rows]

bin/light-base/src/runtime_service.rs Outdated Show resolved Hide resolved
bin/light-base/src/runtime_service.rs Outdated Show resolved Hide resolved
bin/light-base/src/runtime_service.rs Show resolved Hide resolved
bin/light-base/src/runtime_service.rs Show resolved Hide resolved
stream::BoxStream<'static, Result<executor::CoreVersion, RuntimeError>>,
) {
let mut master_stream = stream::unfold(self.guarded.clone(), |guarded| async move {
let subscribe_all = Self::subscribe_all_inner(&guarded, 16, 32).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree it's not great. These functions are only used in order to respond to some JSON-RPC methods, and so we have no choice but to use magic numbers anyway. The question is just where to put these magic numbers.

I think these functions should be moved to the json_rpc_service. I'll do that in a follow-up PR if you don't mind.

@tomaka tomaka requested a review from melekes March 29, 2022 10:07
@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Mar 29, 2022
@mergify mergify bot merged commit 1b229e9 into paritytech:main Mar 29, 2022
@tomaka tomaka deleted the simplify-rt-service branch March 29, 2022 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants