Skip to content

Commit

Permalink
Use tendermint-rs master
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Sep 15, 2021
1 parent 5d38857 commit 5e2a7cf
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 126 deletions.
186 changes: 94 additions & 92 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ exclude = [
]

[patch.crates-io]
# tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::ics24_host::identifier::{ChannelId, PortId};
use flex_error::define_error;

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
UnknowMessageTypeUrl
{ url: String }
Expand Down
21 changes: 10 additions & 11 deletions modules/src/ics02_client/error.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use std::num::TryFromIntError;

use flex_error::{define_error, TraceError};

use crate::ics02_client::client_type::ClientType;
use crate::ics07_tendermint::error::Error as Ics07Error;
use crate::ics23_commitment::error::Error as Ics23Error;
use crate::ics24_host::error::ValidationError;
use crate::ics24_host::identifier::ClientId;
use crate::Height;

use std::num::TryFromIntError;

use flex_error::{define_error, DisplayOnly, TraceError};
use tendermint_proto::Error as TendermintError;

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
UnknownClientType
{ client_type: String }
Expand Down Expand Up @@ -57,7 +56,7 @@ define_error! {

FailedTrustThresholdConversion
{ numerator: u64, denominator: u64 }
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
[ tendermint::Error ]
| e | { format_args!("failed to build Tendermint domain type trust threshold from fraction: {}/{}", e.numerator, e.denominator) },

UnknownClientStateType
Expand Down Expand Up @@ -104,14 +103,14 @@ define_error! {
},

DecodeRawClientState
[ TraceError<TendermintError> ]
[ TraceError<tendermint_proto::Error> ]
| _ | { "error decoding raw client state" },

MissingRawClientState
| _ | { "missing raw client state" },

InvalidRawConsensusState
[ TraceError<TendermintError> ]
[ TraceError<tendermint_proto::Error> ]
| _ | { "invalid raw client consensus state" },

MissingRawConsensusState
Expand All @@ -133,14 +132,14 @@ define_error! {
| _ | { "invalid client identifier" },

InvalidRawHeader
[ TraceError<TendermintError> ]
[ TraceError<tendermint_proto::Error> ]
| _ | { "invalid raw header" },

MissingRawHeader
| _ | { "missing raw header" },

DecodeRawMisbehaviour
[ TraceError<TendermintError> ]
[ TraceError<tendermint_proto::Error> ]
| _ | { "invalid raw misbehaviour" },

InvalidRawMisbehaviour
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::Height;
use flex_error::define_error;

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
Ics02Client
[ client_error::Error ]
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics04_channel/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use flex_error::{define_error, TraceError};
use tendermint_proto::Error as TendermintError;

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
Ics03Connection
[ connection_error::Error ]
Expand Down
8 changes: 4 additions & 4 deletions modules/src/ics07_tendermint/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::ics24_host::error::ValidationError;
use flex_error::{define_error, DisplayOnly, TraceError};
use flex_error::{define_error, TraceError};

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
InvalidTrustingPeriod
{ reason: String }
Expand All @@ -17,7 +17,7 @@ define_error! {

InvalidHeader
{ reason: String }
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
[ tendermint::Error ]
| _ | { "invalid header, failed basic validation" },

InvalidTrustThreshold
Expand Down Expand Up @@ -88,7 +88,7 @@ define_error! {
| _ | { "invalid raw client consensus state" },

InvalidRawHeader
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
[ tendermint::Error ]
| _ | { "invalid raw header" },

InvalidRawMisbehaviour
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics26_routing/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ics04_channel;
use flex_error::{define_error, TraceError};

define_error! {
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
Error {
Ics02Client
[ ics02_client::error::Error ]
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use flex_error::{define_error, DisplayOnly};
use flex_error::define_error;
use ibc::ics04_channel::channel::IdentifiedChannelEnd;
use ibc::ics24_host::identifier::ChainId;
use ibc_relayer::channel::ChannelError;
Expand Down Expand Up @@ -30,7 +30,7 @@ define_error! {

InvalidHash
{ hash: String }
[ DisplayOnly<Box<dyn std::error::Error>> ]
[ tendermint::Error ]
| e | {
format_args!("CLI argument error: could not parse '{}' into a valid hash",
e.hash)
Expand Down
4 changes: 2 additions & 2 deletions relayer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ define_error! {
|_| { "Malformed proof" },

InvalidHeight
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
[ tendermint::Error ]
|_| { "Invalid height" },

InvalidMetadata
Expand Down Expand Up @@ -305,7 +305,7 @@ define_error! {

InvalidKeyAddress
{ address: String }
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
[ tendermint::Error ]
|e| { format!("invalid key address: {0}", e.address) },

Bech32Encoding
Expand Down
12 changes: 6 additions & 6 deletions relayer/src/event/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ use tokio::{runtime::Runtime as TokioRuntime, sync::mpsc};
use tracing::{debug, error, info, trace};

use tendermint_rpc::{
error::Code,
event::Event as RpcEvent,
query::{EventType, Query},
Error as RpcError, Result as RpcResult, SubscriptionClient, Url, WebSocketClient,
WebSocketClientDriver,
Error as RpcError, SubscriptionClient, Url, WebSocketClient, WebSocketClientDriver,
};

use ibc::{events::IbcEvent, ics02_client::height::Height, ics24_host::identifier::ChainId};
Expand Down Expand Up @@ -87,8 +85,10 @@ define_error! {

impl Error {
fn canceled_or_generic(e: RpcError) -> Self {
match (e.code(), e.data()) {
(Code::ServerError, Some(msg)) if msg.contains("subscription was cancelled") => {
use tendermint_rpc::error::ErrorDetail;

match e.detail() {
ErrorDetail::Server(detail) if detail.reason.contains("subscription was cancelled") => {
Self::subscription_cancelled(e)
}
_ => Self::rpc(e),
Expand All @@ -106,7 +106,7 @@ pub struct EventBatch {
pub events: Vec<IbcEvent>,
}

type SubscriptionResult = RpcResult<RpcEvent>;
type SubscriptionResult = std::result::Result<RpcEvent, RpcError>;
type SubscriptionStream = dyn Stream<Item = SubscriptionResult> + Send + Sync + Unpin;

pub type EventSender = channel::Sender<Result<EventBatch>>;
Expand Down

0 comments on commit 5e2a7cf

Please sign in to comment.