Skip to content

Parity runtime moved to parity common for publication in crates.io#271

Merged
grbIzl merged 19 commits into
masterfrom
ParityRuntime
Feb 11, 2020
Merged

Parity runtime moved to parity common for publication in crates.io#271
grbIzl merged 19 commits into
masterfrom
ParityRuntime

Conversation

@grbIzl
Copy link
Copy Markdown
Contributor

@grbIzl grbIzl commented Nov 25, 2019

Current runtime wrapper is used in different components in Parity, but it's placed in parity-ethereum repository. That doesn't allow to use it outside Parity repository. After this move this dependency will be softened.
The following changes were made:

  • Code was moved with git subtree command, so all history was preserved.
  • After the move additional documentation for the module was added (README and CHANGELOG).
  • Crate was renamed to parity-ethereum-runtime for publication on crates.io.
  • Version changed to 0.1.1

c0gent and others added 6 commits October 22, 2018 09:40
* Replace `tokio_core` with `tokio`.

* Remove `tokio-core` and replace with `tokio` in

    - `ethcore/stratum`

    - `secret_store`

    - `util/fetch`

    - `util/reactor`

* Bump hyper to 0.12 in

    - `miner`

    - `util/fake-fetch`

    - `util/fetch`

    - `secret_store`

* Bump `jsonrpc-***` to 0.9 in

    - `parity`

    - `ethcore/stratum`

    - `ipfs`

    - `rpc`

    - `rpc_client`

    - `whisper`

* Bump `ring` to 0.13

* Use a more graceful shutdown process in `secret_store` tests.

* Convert some mutexes to rwlocks in `secret_store`.

* Consolidate Tokio Runtime use, remove `CpuPool`.

* Rename and move the `tokio_reactor` crate (`util/reactor`) to
  `tokio_runtime` (`util/runtime`).

* Rename `EventLoop` to `Runtime`.

    - Rename `EventLoop::spawn` to `Runtime::with_default_thread_count`.

    - Add the `Runtime::with_thread_count` method.

    - Rename `Remote` to `Executor`.

* Remove uses of `CpuPool` and spawn all tasks via the `Runtime` executor
  instead.

* Other changes related to `CpuPool` removal:

    - Remove `Reservations::with_pool`. `::new` now takes an `Executor` as an argument.

    - Remove `SenderReservations::with_pool`. `::new` now takes an `Executor` as an argument.
* Remove the independent runtimes from `KeyServerHttpListener` and
  `KeyServerCore` and instead require a `parity_runtime::Executor`
  to be passed upon creation of each.

* Remove the `threads` parameter from both `ClusterConfiguration` structs.

* Implement the `future::Executor` trait for `parity_runtime::Executor`.

* Update tests.
  - Update the `loop_until` function to instead use a oneshot to signal
    completion.
  - Modify the `make_key_servers` function to create and return a runtime.
* misc: bump license header to 2019

* misc: remove_duplicate_empty_lines.sh

* misc: run license header script

* commit cargo lock
* Upgrade to jsonrpc v14

Contains paritytech/jsonrpc#495 with good bugfixes to resource usage.

* Bump tokio & futures.

* Bump even further.

* Upgrade tokio to 0.1.22

* Partially revert "Bump tokio & futures."

This reverts commit 100907eb91907aa124d856d52374637256118e86.
git-subtree-dir: runtime
git-subtree-mainline: a2987e8
git-subtree-split: 0121354
@parity-cla-bot
Copy link
Copy Markdown

It looks like @grbIzl hasn't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io

Once you've signed, please reply to this thread with [clabot:check] to prove it.

Many thanks,

Parity Technologies CLA Bot

Comment thread runtime/Cargo.toml Outdated
@ordian ordian requested a review from dvdplm November 25, 2019 11:30
Comment thread runtime/src/lib.rs Outdated
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs Outdated
/// Executor for existing runtime.
///
/// Deprecated: Exists only to connect with current JSONRPC implementation.
pub fn new(executor: TaskExecutor) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps add #[deprecated(note="some nice explaination"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it's used at all and I don't really understand what the comment (now deprecation descr) refers to. Would be good to get rid of this.

Comment thread runtime/Cargo.toml Outdated
Copy link
Copy Markdown
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

The code looks good (added a few nitpicks) but I think the interesting part comes after this. Can you elaborate a little on how a freestanding app can use this library? Things I'd like to be able to do:

  • move secret-store outside of the main tree: I guess one would need to provide a main() and import this runtime + ethcore?
  • e.g. POA Networks has a HBBFT Engine implemented as a crate: how would they use it with parity-ethereum without including it in-tree?
  • maybe there's a way to resurrect whisper in the same way as secret-store if there's interest?

I guess what I'm asking about is an outline of what the path to re-usability looks like; I think this PR here is the first step of several? It would be nice to see a PoC of how it'd work though.

Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
enum Mode {
Tokio(TaskExecutor),
Sync,
ThreadPerFuture,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if these two are actually used outside tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't find any usages of this in production code (aka not tests).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add comments to clarify this.

Comment thread runtime/src/lib.rs Outdated
impl Executor {
/// Executor for existing runtime.
///
/// Deprecated: Exists only to connect with current JSONRPC implementation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm. So this one is deprecated and new_sync and new_thread_per_future() is mostly used in tests? Doesn't add up!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Everywhere in the code the executor is retrieved from runtime (it has executor() method for accessing it)

Comment thread runtime/src/lib.rs Outdated
Comment thread runtime/src/lib.rs Outdated
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs Outdated
Comment thread runtime/README.MD Outdated
@grbIzl
Copy link
Copy Markdown
Contributor Author

grbIzl commented Nov 26, 2019

I put this PR onice for now, in order to sync it with SecretStore separation and prevent redundant changes after its publishing.

Copy link
Copy Markdown
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm, only minor nits

Comment thread runtime/src/lib.rs
enum Mode {
Tokio(TaskExecutor),
Sync,
ThreadPerFuture,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add comments to clarify this.

Comment thread runtime/src/lib.rs Outdated
}
}

/// Synchronous executor, used mostly for tests.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"mostly" or "only"? If it's tests-only, let's mark it #[cfg(test)].

Comment thread runtime/src/lib.rs
@niklasad1
Copy link
Copy Markdown
Contributor

@grbIzl status on this PR?

You need to run cargo fmt in order to make the CI happy BTW

@grbIzl
Copy link
Copy Markdown
Contributor Author

grbIzl commented Jan 14, 2020

@grbIzl status on this PR?

You need to run cargo fmt in order to make the CI happy BTW

As we agreed, I'm trying to separate SecretStore code first. And if it's feasible, proceed with this PR. PS I'm a little bit slow these days.

@NikVolf
Copy link
Copy Markdown
Contributor

NikVolf commented Jan 14, 2020

I think adding at least one example to make sure api is exposed ok-ish is a must

Copy link
Copy Markdown
Contributor

@NikVolf NikVolf left a comment

Choose a reason for hiding this comment

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

Example missing for new crate

Copy link
Copy Markdown
Contributor

@ordian ordian left a comment

Choose a reason for hiding this comment

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

I hope we can burn parity-runtime with fire someday.

Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
Comment thread runtime/src/lib.rs
@ordian
Copy link
Copy Markdown
Contributor

ordian commented Jan 15, 2020

looks good modulo @NikVolf's request

@ordian ordian requested a review from NikVolf February 11, 2020 13:40
@grbIzl
Copy link
Copy Markdown
Contributor Author

grbIzl commented Feb 11, 2020

As an example I've added test with simple read of the current dir, using runtime executor: https://github.com/paritytech/parity-common/pull/271/files#diff-11f21b7f145f98241270cf825e0aaab5R272


/// Read current directory in future, which is executed in the created runtime
fn main() {
let fut = read_dir(".")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not include this in doctest instead in the crate root to be part of the documentation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AFAIU the idea was to run this sample as standard cargo example in order to make sure, that public API is declared properly

let runtime = Runtime::with_default_thread_count();
runtime.executor().spawn(fut);
let timeout = Duration::from_secs(3);
park_timeout(timeout);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this would help with openethereum/parity-ethereum#9636

Comment thread runtime/examples/simple.rs Outdated
Comment thread runtime/src/lib.rs Outdated
/// Executor for existing runtime.
///
/// Deprecated: Exists only to connect with current JSONRPC implementation.
pub fn new(executor: TaskExecutor) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it's used at all and I don't really understand what the comment (now deprecation descr) refers to. Would be good to get rid of this.

Comment thread runtime/src/lib.rs Outdated
Comment thread runtime/src/lib.rs Outdated
@grbIzl grbIzl merged commit fc93b7e into master Feb 11, 2020
@grbIzl grbIzl deleted the ParityRuntime branch February 11, 2020 16:04
ordian added a commit that referenced this pull request Feb 12, 2020
* master:
  Update/change licenses: MIT/Apache2.0 (#342)
  rlp-derive extracted (#343)
  Format for readme and changelog corrected (#341)
  Parity runtime moved to parity common for publication in crates.io (#271)
  Disable cache if explicit memory budget=0 passed (#339)
ordian added a commit that referenced this pull request Feb 13, 2020
* master:
  prepare rlp-derive release (#344)
  Update/change licenses: MIT/Apache2.0 (#342)
  rlp-derive extracted (#343)
  Format for readme and changelog corrected (#341)
  Parity runtime moved to parity common for publication in crates.io (#271)
  Disable cache if explicit memory budget=0 passed (#339)
  [parity-crypto] prepare 0.5.0 (#336)
  [parity crypto]: remove unused depend `rustc_hex` (#337)
  Update doc comment (#335)
ordian added a commit that referenced this pull request Mar 6, 2020
* master:
  kvdb-rocksdb: bump version (#348)
  kvdb-rocksdb: expose RocksDB stats (#347)
  Implement Error for FromDecStrErr (#346)
  Fix clippy lints for rlp-derive (#345)
  prepare rlp-derive release (#344)
  Update/change licenses: MIT/Apache2.0 (#342)
  rlp-derive extracted (#343)
  Format for readme and changelog corrected (#341)
  Parity runtime moved to parity common for publication in crates.io (#271)
  Disable cache if explicit memory budget=0 passed (#339)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants