Skip to content

Commit

Permalink
Changes for the tendermint dep rebase (#437)
Browse files Browse the repository at this point in the history
* Changes for the tendermint dep rebase

* error format

* Changes for integration with tm pr#706

* remove event_monitor.rs file
  • Loading branch information
ancazamfir authored Dec 2, 2020
1 parent a473bec commit be001eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 189 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ exclude = [
tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "romac/skip-verif" }
2 changes: 1 addition & 1 deletion modules/src/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub mod test_util {
281_815_u64.try_into().unwrap(),
);

let vs = ValidatorSet::new(vec![v1], Some(v1), 281_815_u64.try_into().unwrap());
let vs = ValidatorSet::new(vec![v1], Some(v1), None);

Header {
signed_header: shdr,
Expand Down
30 changes: 4 additions & 26 deletions relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::convert::{TryFrom, TryInto};
use std::convert::TryFrom;
use std::future::Future;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
Expand All @@ -19,7 +19,7 @@ use tendermint::account::Id as AccountId;
use tendermint::block::Height;
use tendermint::consensus::Params;

use tendermint_light_client::types::{LightBlock as TMLightBlock, ValidatorSet};
use tendermint_light_client::types::LightBlock as TMLightBlock;
use tendermint_rpc::Client;
use tendermint_rpc::HttpClient;

Expand Down Expand Up @@ -376,8 +376,8 @@ impl Chain for CosmosSDKChain {
Ok(TMHeader {
trusted_height,
signed_header: target_light_block.signed_header.clone(),
validator_set: fix_validator_set(&target_light_block)?,
trusted_validator_set: fix_validator_set(&trusted_light_block)?,
validator_set: target_light_block.validators,
trusted_validator_set: trusted_light_block.validators,
})
}

Expand Down Expand Up @@ -411,28 +411,6 @@ impl Chain for CosmosSDKChain {
}
}

fn fix_validator_set(light_block: &TMLightBlock) -> Result<ValidatorSet, Error> {
let validators = light_block.validators.validators();
// Get the proposer.
let proposer = validators
.iter()
.find(|v| v.address == light_block.signed_header.header.proposer_address)
.ok_or(Kind::EmptyResponseValue)?;

let voting_power: u64 = validators.iter().map(|v| v.voting_power.value()).sum();

// Create the validator set with the proposer from the header.
// This is required by IBC on-chain validation.
let validator_set = ValidatorSet::new(
validators.clone(),
Some(*proposer),
voting_power
.try_into()
.map_err(|e| Kind::EmptyResponseValue.context(e))?,
);
Ok(validator_set)
}

/// Perform a generic `abci_query`, and return the corresponding deserialized response data.
async fn abci_query(
chain: &CosmosSDKChain,
Expand Down
8 changes: 3 additions & 5 deletions relayer/src/event/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ impl EventMonitor {
// Shut down previous client
debug!("Gracefully shutting down previous client");

self.rt
.lock()
.map_err(|_| Kind::PoisonedMutex)?
.block_on(websocket_client.close())
.map_err(|e| format!("Failed to close previous WebSocket client: {}", e))?;
if let Err(e) = websocket_client.close() {
error!("Previous websocket client closing failure {}", e);
}

self.rt
.lock()
Expand Down
156 changes: 0 additions & 156 deletions relayer/src/event_monitor.rs

This file was deleted.

0 comments on commit be001eb

Please sign in to comment.