Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Apr 5, 2024
2 parents 6e59b35 + 97804c8 commit 1839810
Show file tree
Hide file tree
Showing 32 changed files with 107 additions and 135 deletions.
1 change: 0 additions & 1 deletion crates/chain-registry/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! Contains struct to build a `tendermint_rpc::Url` representing a
//! WebSocket URL from a RPC URL and to parse or build a valid `http::Uri`
//! from an (in)complete GRPC URL.
use std::str::FromStr;

use http::{uri::Scheme, Uri};
Expand Down
3 changes: 1 addition & 2 deletions crates/chain-registry/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use std::{fmt::Debug, str::FromStr};
use async_trait::async_trait;
use futures::{stream::FuturesUnordered, StreamExt};
use http::Uri;

use ibc_proto::cosmos::bank::v1beta1::query_client::QueryClient;
use tendermint_rpc::{Client as _, HttpClient, HttpClientUrl, Url};
use tendermint_rpc::{Client, HttpClient, HttpClientUrl, Url};
use tracing::{debug, info};

use crate::error::RegistryError;
Expand Down
16 changes: 10 additions & 6 deletions crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Contains functions to generate a relayer config for a given chain
use std::{
collections::{BTreeMap, HashMap},
fmt::Display,
marker::Send,
};

use futures::future::join_all;
use http::Uri;
use tendermint_rpc::Url;
use tokio::task::{JoinError, JoinHandle};
use tracing::{error, trace};

use std::{collections::BTreeMap, collections::HashMap, fmt::Display, marker::Send};

use ibc_chain_registry::{
asset_list::AssetList,
chain::ChainData,
Expand All @@ -30,6 +30,10 @@ use ibc_relayer::{
keyring::Store,
};

use tendermint_rpc::Url;
use tokio::task::{JoinError, JoinHandle};
use tracing::{error, trace};

const MAX_HEALTHY_QUERY_RETRIES: u8 = 5;

/// Generate packet filters from Vec<IBCPath> and load them in a Map(chain_name -> filter).
Expand Down
11 changes: 5 additions & 6 deletions crates/relayer-cli/src/commands/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::ops::RangeInclusive;

use abscissa_core::{clap::Parser, config::Override, Command, FrameworkErrorKind, Runnable};
use ibc_relayer::{
chain::handle::{BaseChainHandle, ChainHandle},
chain::{
handle::{BaseChainHandle, ChainHandle},
requests::{IncludeProof, QueryChannelRequest, QueryHeight},
},
config::Config,
link::{error::LinkError, Link, LinkParameters},
util::seq_range::parse_seq_range,
Expand All @@ -16,11 +19,7 @@ use ibc_relayer_types::{
events::IbcEvent,
};

use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};

use crate::application::app_config;
use crate::cli_utils::spawn_chain_counterparty;
use crate::conclude::Output;
use crate::{application::app_config, cli_utils::spawn_chain_counterparty, conclude::Output};

/// `clear` subcommands
#[derive(Command, Debug, Parser, Runnable)]
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{collections::HashSet, path::PathBuf};

use abscissa_core::{clap::Parser, Command, Runnable};
use ibc_relayer::config::{store, ChainConfig, Config};

use itertools::Itertools;
use tracing::{error, info, warn};

Expand Down
21 changes: 7 additions & 14 deletions crates/relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use eyre::eyre;
use ibc_relayer::{
chain::handle::Subscription,
config::{ChainConfig, EventSourceMode},
error::Error,
event::source::EventSource,
util::compat_mode::compat_mode_from_version,
};
Expand Down Expand Up @@ -158,19 +157,13 @@ fn subscribe(
EventSourceMode::Pull {
interval,
max_retries,
} => {
let mut rpc_client = HttpClient::new(config.rpc_addr.clone())
.map_err(|e| Error::rpc(config.rpc_addr.clone(), e))?;
rpc_client.set_compat_mode(compat_mode);

EventSource::rpc(
chain_config.id().clone(),
rpc_client,
*interval,
*max_retries,
rt,
)
}
} => EventSource::rpc(
chain_config.id().clone(),
HttpClient::new(config.rpc_addr.clone())?,
*interval,
*max_retries,
rt,
),
}?;

thread::spawn(move || event_source.run());
Expand Down
7 changes: 7 additions & 0 deletions crates/relayer-cli/src/commands/query/packet/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ibc_relayer_types::{
},
Height,
};
use serde::Serialize;
use subtle_encoding::{Encoding, Hex};

use crate::{
Expand All @@ -19,6 +20,12 @@ use crate::{
prelude::*,
};

#[derive(Serialize, Debug)]
struct PacketSeqs {
height: Height,
seqs: Vec<u64>,
}

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryPacketCommitmentCmd {
#[clap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use ibc_proto::{
};
use serde::{Deserialize, Serialize};

use crate::core::ics04_channel::channel::Ordering;
use crate::{
applications::ics27_ica::error::Error,
core::{
ics04_channel::version::Version,
ics04_channel::{channel::Ordering, version::Version},
ics24_host::{error::ValidationError, identifier::ConnectionId},
},
signer::Signer,
Expand Down
3 changes: 2 additions & 1 deletion crates/relayer-types/src/mock/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ impl From<MockHeader> for Any {

#[cfg(test)]
mod tests {
use super::*;
use ibc_proto::Protobuf;

use super::*;

#[test]
fn encode_any() {
let header = MockHeader::new(Height::new(1, 10).unwrap()).with_timestamp(Timestamp::none());
Expand Down
11 changes: 6 additions & 5 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
[package]
name = "ibc-relayer"

version = "0.27.2"
edition = "2021"
rust-version = "1.71.1"
description = """
Implementation of an IBC Relayer in Rust, as a library
"""
name = "ibc-relayer"
license = "Apache-2.0"
readme = "README.md"
keywords = ["blockchain", "consensus", "cosmos", "ibc", "tendermint"]
repository = "https://github.com/informalsystems/hermes"
authors = ["Informal Systems <[email protected]>"]
rust-version = "1.71.1"
description = """
Implementation of an IBC Relayer in Rust, as a library
"""

[package.metadata.docs.rs]
all-features = true
Expand Down
21 changes: 13 additions & 8 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ use bytes::{Buf, Bytes};
use futures::future::join_all;
use ibc_proto::{
cosmos::{
base::node::v1beta1::ConfigResponse,
base::tendermint::v1beta1::service_client::ServiceClient,
base::tendermint::v1beta1::{GetSyncingRequest, GetSyncingResponse},
base::{
node::v1beta1::ConfigResponse,
tendermint::v1beta1::{
service_client::ServiceClient, GetSyncingRequest, GetSyncingResponse,
},
},
staking::v1beta1::Params as StakingParams,
},
ibc::apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse},
Expand Down Expand Up @@ -70,10 +73,6 @@ use self::{
types::{app_state::GenesisAppState, gas::GasConfig},
version::Specs,
};
use crate::util::pretty::PrettySlice;
use crate::util::pretty::{
PrettyIdentifiedChannel, PrettyIdentifiedClientState, PrettyIdentifiedConnection,
};
use crate::{
account::Balance,
chain::{
Expand Down Expand Up @@ -125,7 +124,13 @@ use crate::{
keyring::{KeyRing, Secp256k1KeyPair, SigningKeyPair},
light_client::{tendermint::LightClient as TmLightClient, LightClient, Verified},
misbehaviour::MisbehaviourEvidence,
util::compat_mode::compat_mode_from_version,
util::{
compat_mode::compat_mode_from_version,
pretty::{
PrettyIdentifiedChannel, PrettyIdentifiedClientState, PrettyIdentifiedConnection,
PrettySlice,
},
},
};

pub mod batch;
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer/src/chain/cosmos/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use std::collections::BTreeMap;
use std::path::PathBuf;

use byte_unit::Byte;
use ibc_relayer_types::core::ics04_channel::packet::Sequence;

use ibc_relayer_types::core::{
ics04_channel::packet::Sequence,
ics23_commitment::specs::ProofSpecs,
ics24_host::identifier::{ChainId, ChannelId},
};
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer/src/chain/cosmos/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use ibc_proto::{cosmos::tx::v1beta1::Fee, google::protobuf::Any};
use ibc_relayer_types::events::IbcEvent;
use tendermint_rpc::{endpoint::broadcast::tx_sync::Response, Client, HttpClient, Url};

use super::batch::send_batched_messages_and_wait_commit;
use super::estimate::EstimatedGas;
use super::{batch::send_batched_messages_and_wait_commit, estimate::EstimatedGas};
use crate::{
chain::cosmos::{
encode::sign_and_encode_tx,
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/chain/cosmos/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use core::fmt::{Display, Error as FmtError, Formatter};

use flex_error::define_error;

use ibc_proto::cosmos::base::tendermint::v1beta1::{Module, VersionInfo};
use tracing::trace;

Expand Down
1 change: 1 addition & 0 deletions crates/relayer/src/chain/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::sync::Arc;
use core::convert::TryFrom;

use ibc_proto::ibc::apps::fee::v1::{
QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse,
Expand Down
13 changes: 9 additions & 4 deletions crates/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@ pub mod proof_specs;
pub mod refresh_rate;
pub mod types;

use alloc::collections::BTreeMap;
use core::{
cmp::Ordering,
fmt::{Display, Error as FmtError, Formatter},
str::FromStr,
time::Duration,
};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use std::{borrow::Cow, collections::BTreeMap};
use std::{fs, fs::File, io::Write, ops::Range, path::Path};
use std::{
borrow::Cow,
fs::{self, File},
io::Write,
ops::Range,
path::Path,
};

use byte_unit::Byte;
pub use error::Error;
pub use filter::PacketFilter;
use ibc_proto::google::protobuf::Any;
use ibc_relayer_types::{
core::{
ics23_commitment::specs::ProofSpecs,
ics04_channel::packet::Sequence,
ics24_host::identifier::{ChainId, ChannelId, PortId},
},
timestamp::ZERO_DURATION,
Expand Down
6 changes: 4 additions & 2 deletions crates/relayer/src/config/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,10 @@ impl<'de> Deserialize<'de> for ChannelFilterMatch {
}

pub(crate) mod port {
use super::*;
use ibc_relayer_types::core::ics24_host::identifier::PortId;

use super::*;

pub struct PortFilterMatchVisitor;

impl<'de> de::Visitor<'de> for PortFilterMatchVisitor {
Expand All @@ -400,9 +401,10 @@ pub(crate) mod port {
}

pub(crate) mod channel {
use super::*;
use ibc_relayer_types::core::ics24_host::identifier::ChannelId;

use super::*;

pub struct ChannelFilterMatchVisitor;

impl<'de> de::Visitor<'de> for ChannelFilterMatchVisitor {
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use serde::Serialize;
use subtle_encoding::hex;
use tendermint::abci::Event as AbciEvent;

use ibc_relayer_types::{
applications::{
Expand Down Expand Up @@ -29,6 +26,8 @@ use ibc_relayer_types::{
events::{Error as IbcEventError, IbcEvent, IbcEventType},
Height,
};
use serde::Serialize;
use tendermint::abci::Event as AbciEvent;

pub mod bus;
pub mod error;
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer/src/link/relay_path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use alloc::collections::{BTreeMap as HashMap, VecDeque};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use std::{
ops::Sub,
time::{Duration, Instant},
Expand All @@ -20,7 +19,7 @@ use ibc_relayer_types::{
recv_packet::MsgRecvPacket, timeout::MsgTimeout,
timeout_on_close::MsgTimeoutOnClose,
},
packet::{Packet, PacketMsgType},
packet::{Packet, PacketMsgType, Sequence},
},
ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId},
},
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/upgrade_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use ibc_relayer_types::{
downcast, Height,
};
use tendermint::Hash as TxHash;

use tracing::warn;

use crate::{
Expand Down
Loading

0 comments on commit 1839810

Please sign in to comment.