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

Upgrade jsonrpc to upgrade hyper #804

Merged
merged 5 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Unreleased

### BUG FIXES

* `[light-node]` Upgrade `jsonrpc` dependency to v17.0 to fix security
vulnerability in `hyper` v0.12.35 ([#803])

[#803]: https://github.com/informalsystems/tendermint-rs/issues/803

## v0.18.0

*Jan 29, 2021*
Expand Down
8 changes: 4 additions & 4 deletions light-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ path = "src/bin/tendermint-light-node/main.rs"
anomaly = { version = "0.2", features = ["serializer"] }
async-trait = "0.1"
gumdrop = "0.7"
jsonrpc-core = "14.2"
jsonrpc-core-client = "14.2"
jsonrpc-http-server = "14.2"
jsonrpc-derive = "14.2"
jsonrpc-core = "17.0"
jsonrpc-core-client = "17.0"
jsonrpc-http-server = "17.0"
jsonrpc-derive = "17.0"
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1.0"
thiserror = "1.0"
Expand Down
33 changes: 18 additions & 15 deletions light-node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ where
}

mod sealed {
use jsonrpc_core::futures::future::{self, FutureResult};
use jsonrpc_core::futures;
use jsonrpc_core::types::Error;
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;

use tendermint_light_client::supervisor::Handle;
Expand All @@ -46,11 +47,11 @@ mod sealed {
pub trait Rpc {
/// Returns the latest trusted block.
#[rpc(name = "state")]
fn state(&self) -> FutureResult<Option<LightBlock>, Error>;
fn state(&self) -> BoxFuture<Result<Option<LightBlock>>>;

/// Returns the latest status.
#[rpc(name = "status")]
fn status(&self) -> FutureResult<LatestStatus, Error>;
fn status(&self) -> BoxFuture<Result<LatestStatus>>;
}

pub use self::rpc_impl_Rpc::gen_client::Client;
Expand All @@ -75,34 +76,32 @@ mod sealed {
where
H: Handle + Send + Sync + 'static,
{
fn state(&self) -> FutureResult<Option<LightBlock>, Error> {
fn state(&self) -> BoxFuture<Result<Option<LightBlock>>> {
let res = self.handle.latest_trusted().map_err(|e| {
let mut err = Error::internal_error();
err.message = e.to_string();
err.data = serde_json::to_value(e.kind()).ok();
err
});

future::result(res)
Box::pin(futures::future::ready(res))
}

fn status(&self) -> FutureResult<LatestStatus, Error> {
fn status(&self) -> BoxFuture<Result<LatestStatus>> {
let res = self.handle.latest_status().map_err(|e| {
let mut err = Error::internal_error();
err.message = e.to_string();
err.data = serde_json::to_value(e.kind()).ok();
err
});

future::result(res)
Box::pin(futures::future::ready(res))
}
}
}

#[cfg(test)]
mod test {
use futures::compat::Future01CompatExt as _;
use jsonrpc_core::futures::future::Future;
use jsonrpc_core::IoHandler;
use jsonrpc_core_client::transports::local;
use pretty_assertions::assert_eq;
Expand All @@ -117,13 +116,15 @@ mod test {
#[tokio::test]
async fn state() {
let server = Server::new(MockHandle {});
let fut = {
let have = {
let mut io = IoHandler::new();
io.extend_with(server.to_delegate());
let (client, server) = local::connect::<Client, _, _>(io);
client.state().join(server)
tokio::select! {
result = client.state() => result.unwrap(),
_ = server => panic!("server terminated before client state request completed"),
}
};
let (have, _) = fut.compat().await.unwrap();
let want = serde_json::from_str(LIGHTBLOCK_JSON).unwrap();

assert_eq!(have, want);
Expand All @@ -132,13 +133,15 @@ mod test {
#[tokio::test]
async fn status() {
let server = Server::new(MockHandle {});
let fut = {
let have = {
let mut io = IoHandler::new();
io.extend_with(server.to_delegate());
let (client, server) = local::connect::<Client, _, _>(io);
client.status().join(server)
tokio::select! {
result = client.status() => result.unwrap(),
_ = server => panic!("server terminated before client status request completed"),
}
};
let (have, _) = fut.compat().await.unwrap();
let want = serde_json::from_str(STATUS_JSON).unwrap();

assert_eq!(have, want);
Expand Down
6 changes: 0 additions & 6 deletions tendermint/src/lite.rs

This file was deleted.