Skip to content

Commit

Permalink
Update Tokio to 1.0, Prost to 0.7 and Tonic to 0.4 (#534)
Browse files Browse the repository at this point in the history
* Update Tokio to 1.0, Prost to 0.7 and Tonic to 0.4

* Point to tendermint-rs `ibc` branch

* Update changelog
  • Loading branch information
romac authored Jan 19, 2021
1 parent bc6b445 commit 1a77c0a
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 130 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

### IMPROVEMENTS

- Update to `tendermint-rs` v0.17.1 ([#517])
- Update to `tokio` 1.0, `prost` 0.7 and `tonic` 0.4 ([#527])

- [relayer-cli]
- Replace `ChannelConfig` in `Channel::new` ([#511])
- Add `packet-send` CLI ([#470])
Expand All @@ -24,8 +27,6 @@
- Clean the validate_basic method ([#94])
- MsgConnectionOpenAck testing improvements ([#306])

- Update to `tendermint-rs` v0.17.1 ([#517])

### BUG FIXES:

- [modules]
Expand All @@ -42,6 +43,7 @@
[#514]: https://github.com/informalsystems/ibc-rs/issues/514
[#517]: https://github.com/informalsystems/ibc-rs/issues/517
[#525]: https://github.com/informalsystems/ibc-rs/issues/525
[#527]: https://github.com/informalsystems/ibc-rs/issues/527


## v0.0.6
Expand Down
6 changes: 3 additions & 3 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ serde_derive = "1.0.104"
serde = "1.0.104"
serde_json = "1"
tracing = "0.1.13"
prost = "0.6.1"
prost-types = "0.6.1"
prost = "0.7"
prost-types = "0.7"
bytes = "1.0.0"
dyn-clonable = "0.9.0"
regex = "1"
Expand All @@ -55,6 +55,6 @@ version = "=0.17.1"
optional = true

[dev-dependencies]
tokio = { version = "0.2", features = ["macros"] }
tokio = { version = "1.0", features = ["macros"] }
subtle-encoding = { version = "0.5" }
tendermint-testgen = { version = "=0.17.1" } # Needed for generating (synthetic) light blocks.
3 changes: 2 additions & 1 deletion modules/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ pub fn string_to_account(raw: String) -> Result<AccountId, BoxError> {
let addr_bytes =
Vec::<u8>::from_base32(&data).map_err(|e| Context::new("bad signer", Some(e.into())))?;

Ok(AccountId::try_from(addr_bytes).map_err(|e| Context::new("bad signer", Some(e.into())))?)
Ok(AccountId::try_from(addr_bytes)
.map_err(|e| Context::new("bad signer", Some(Box::new(e))))?)
}
8 changes: 3 additions & 5 deletions proto-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ publish = false

[dependencies]
git2 = "0.13"
prost-build = "0.6"
prost-build = "0.7"
tempdir = "0.3.7"
walkdir = "2.3"
argh = "0.1.3"
tonic = "0.3.1"

#[build-dependencies]
tonic-build = "0.3.1"
tonic = "0.4"
tonic-build = "0.4"
6 changes: 3 additions & 3 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ description = """
all-features = true

[dependencies]
prost = { version = "0.6" }
prost-types = { version = "0.6" }
prost = "0.7"
prost-types = "0.7"
anomaly = "0.2"
bytes = "1.0"
thiserror = "1.0"
tonic = "0.3.1"
tonic = "0.4"

[dependencies.tendermint-proto]
version = "=0.17.1"
6 changes: 3 additions & 3 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ anomaly = "0.2.0"
gumdrop = "0.7"
serde = { version = "1", features = ["serde_derive"] }
thiserror = "1"
tokio = { version = "0.2", features = ["full"] }
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.13"
tracing-subscriber = "0.2.3"
futures = "0.3.5"
toml = "0.5.6"
serde_derive = "1.0.116"
serde_json = "1"
sled = "0.34.4"
prost = "0.6.1"
prost-types = { version = "0.6.1" }
prost = "0.7"
prost-types = { version = "0.7" }
hex = "0.4"
crossbeam-channel = "0.5.0"

Expand Down
12 changes: 4 additions & 8 deletions relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::{
ops::Deref,
sync::{Arc, Mutex},
thread,
};
use std::{ops::Deref, sync::Arc, thread};

use abscissa_core::{application::fatal_error, error::BoxError, Command, Options, Runnable};
use crossbeam_channel as channel;
Expand All @@ -21,7 +17,7 @@ pub struct ListenCmd {

impl ListenCmd {
fn cmd(&self) -> Result<(), BoxError> {
let rt = Arc::new(Mutex::new(TokioRuntime::new()?));
let rt = Arc::new(TokioRuntime::new()?);
let config = app_config();

let chain_id = self.chain_id.clone().unwrap();
Expand All @@ -39,7 +35,7 @@ impl Runnable for ListenCmd {
}

/// Listen to events
pub fn listen(rt: Arc<Mutex<TokioRuntime>>, config: ChainConfig) -> Result<(), BoxError> {
pub fn listen(rt: Arc<TokioRuntime>, config: ChainConfig) -> Result<(), BoxError> {
info!(chain.id = %config.id, "spawning event monitor for");

let (event_monitor, rx) = subscribe(config, rt)?;
Expand All @@ -54,7 +50,7 @@ pub fn listen(rt: Arc<Mutex<TokioRuntime>>, config: ChainConfig) -> Result<(), B

fn subscribe(
chain_config: ChainConfig,
rt: Arc<Mutex<TokioRuntime>>,
rt: Arc<TokioRuntime>,
) -> Result<(EventMonitor, channel::Receiver<EventBatch>), BoxError> {
let (mut event_monitor, rx) = EventMonitor::new(chain_config.id, chain_config.rpc_addr, rt)
.map_err(|e| format!("couldn't initialize event monitor: {}", e))?;
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/commands/query/channel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use abscissa_core::{Command, Options, Runnable};
use serde_json::json;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl Runnable for QueryChannelEndCmd {
// run without proof:
// cargo run --bin relayer -- -c relayer/tests/config/fixtures/simple_config.toml query channel end ibc-test firstport firstchannel --height 3 -p false

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());

let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();
let height = ibc::Height::new(chain.id().version(), opts.height);
Expand Down
8 changes: 4 additions & 4 deletions relayer-cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use abscissa_core::{Command, Options, Runnable};
use serde_json::json;
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Runnable for QueryClientStateCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();
let height = ibc::Height::new(chain.id().version(), opts.height);

Expand Down Expand Up @@ -171,7 +171,7 @@ impl Runnable for QueryClientConsensusCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();
let height = ibc::Height::new(chain.id().version(), opts.height);

Expand Down Expand Up @@ -282,7 +282,7 @@ impl Runnable for QueryClientConnectionsCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();
let height = ibc::Height::new(chain.id().version(), opts.height);

Expand Down
6 changes: 3 additions & 3 deletions relayer-cli/src/commands/query/connection.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use abscissa_core::{Command, Options, Runnable};
use serde_json::json;
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Runnable for QueryConnectionEndCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();
let height = ibc::Height::new(chain.id().version(), opts.height);

Expand Down Expand Up @@ -154,7 +154,7 @@ impl Runnable for QueryConnectionChannelsCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();

let req = QueryConnectionChannelsRequest {
Expand Down
14 changes: 7 additions & 7 deletions relayer-cli/src/commands/query/packet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use abscissa_core::{Command, Options, Runnable};
use serde_json::json;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Runnable for QueryPacketCommitmentsCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();

let grpc_request = QueryPacketCommitmentsRequest {
Expand Down Expand Up @@ -146,7 +146,7 @@ impl Runnable for QueryPacketCommitmentCmd {

// run without proof:
// cargo run --bin relayer -- -c relayer/tests/config/fixtures/simple_config.toml query packet commitment ibc-0 transfer ibconexfer 3 --height 3
let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();

let res = chain.build_packet_proofs(
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Runnable for QueryUnreceivedPacketsCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let src_chain = CosmosSDKChain::bootstrap(src_chain_config, rt.clone()).unwrap();
let dst_chain = CosmosSDKChain::bootstrap(dst_chain_config, rt).unwrap();

Expand Down Expand Up @@ -315,7 +315,7 @@ impl Runnable for QueryPacketAcknowledgementsCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();

let grpc_request = QueryPacketAcknowledgementsRequest {
Expand Down Expand Up @@ -396,7 +396,7 @@ impl Runnable for QueryPacketAcknowledgmentCmd {

// run without proof:
// cargo run --bin relayer -- -c relayer/tests/config/fixtures/simple_config.toml query packet acknowledgment ibc-0 transfer ibconexfer --height 3
let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap();

let res = chain.build_packet_proofs(
Expand Down Expand Up @@ -473,7 +473,7 @@ impl Runnable for QueryUnreceivedAcknowledgementCmd {
};
status_info!("Options", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let src_chain = CosmosSDKChain::bootstrap(src_chain_config, rt.clone()).unwrap();
let dst_chain = CosmosSDKChain::bootstrap(dst_chain_config, rt).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl StartCmd {

impl Runnable for StartCmd {
fn run(&self) {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();

rt.block_on(async move {
self.cmd()
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/commands/tx/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use abscissa_core::{Command, Options, Runnable};
use serde_json::json;
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Runnable for TxRawSendPacketCmd {
};
status_info!("Message", "{:?}", opts);

let rt = Arc::new(Mutex::new(TokioRuntime::new().unwrap()));
let rt = Arc::new(TokioRuntime::new().unwrap());
let src_chain =
CosmosSDKChain::bootstrap(opts.packet_src_chain_config.clone(), rt.clone()).unwrap();
let dst_chain =
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
unused_qualifications
)]

use std::str::FromStr;
use std::sync::Arc;
use std::{str::FromStr, sync::Mutex};

use ibc::ics02_client::raw::ConnectionIds as DomainTypeClientConnections;
use ibc::ics04_channel::channel::{ChannelEnd, Order, State as ChannelState};
Expand Down Expand Up @@ -48,7 +48,7 @@ fn simd_config() -> Config {

/// Chain created for the informaldev/simd DockerHub image running on localhost.
fn simd_chain() -> CosmosSDKChain {
let rt = Arc::new(Mutex::new(tokio::runtime::Runtime::new().unwrap()));
let rt = Arc::new(tokio::runtime::Runtime::new().unwrap());
CosmosSDKChain::bootstrap(simd_config().chains[0].clone(), rt).unwrap()
}

Expand Down
8 changes: 4 additions & 4 deletions relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ sled = { version = "0.34.4", features = ["no_metrics", "no_logs"] }
thiserror = "1.0.11"
toml = "0.5"
tracing = "0.1.13"
tokio = { version = "0.2", features = ["rt-core", "time", "stream", "sync"] }
tokio = { version = "1.0", features = ["rt-multi-thread", "time", "sync"] }
serde_json = { version = "1" }
bytes = "1.0.0"
prost = "0.6.1"
prost-types = { version = "0.6.1" }
prost = "0.7"
prost-types = "0.7"
futures = "0.3.5"
retry = "1.1.0"
crossbeam-channel = "0.5.0"
Expand All @@ -37,7 +37,7 @@ rust-crypto = "0.2.36"
bech32 = "0.7.2"
itertools = "0.10.0"
dyn-clonable = "0.9.0"
tonic = "0.3.1"
tonic = "0.4"
dirs-next = "2.0.0"
dyn-clone = "1.0.3"

Expand Down
9 changes: 3 additions & 6 deletions relayer/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pub mod runtime;
pub mod mock;

use crossbeam_channel as channel;
use std::{
sync::{Arc, Mutex},
thread,
};
use std::{sync::Arc, thread};
use tokio::runtime::Runtime as TokioRuntime;

use prost_types::Any;
Expand Down Expand Up @@ -80,7 +77,7 @@ pub trait Chain: Sized {
type ClientState: ClientState;

/// Constructs the chain
fn bootstrap(config: ChainConfig, rt: Arc<Mutex<TokioRuntime>>) -> Result<Self, Error>;
fn bootstrap(config: ChainConfig, rt: Arc<TokioRuntime>) -> Result<Self, Error>;

#[allow(clippy::type_complexity)]
/// Initializes and returns the light client (if any) associated with this chain.
Expand All @@ -91,7 +88,7 @@ pub trait Chain: Sized {
/// Initializes and returns the event monitor (if any) associated with this chain.
fn init_event_monitor(
&self,
rt: Arc<Mutex<TokioRuntime>>,
rt: Arc<TokioRuntime>,
) -> Result<
(
channel::Receiver<EventBatch>,
Expand Down
Loading

0 comments on commit 1a77c0a

Please sign in to comment.