From d9bab0b02e2be0387a44d4341fcc5e559ade7b3a Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 23 Jun 2021 09:30:44 -0400 Subject: [PATCH 01/10] temp fix --- relayer/src/event/rpc.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/relayer/src/event/rpc.rs b/relayer/src/event/rpc.rs index 676caae9fa..bc9d666ddb 100644 --- a/relayer/src/event/rpc.rs +++ b/relayer/src/event/rpc.rs @@ -20,7 +20,8 @@ pub fn get_all_events( let mut vals: Vec<(Height, IbcEvent)> = vec![]; match &result.data { - RpcEventData::NewBlock { block, .. } => { + RpcEventData::NewBlock { block, result_begin_block, result_end_block } => { + tracing::trace!("Got begin block {:#?}, end block {:#?}", result_begin_block, result_end_block); let height = Height::new( ChainId::chain_version(chain_id.to_string().as_str()), u64::from(block.as_ref().ok_or("tx.height")?.header.height), @@ -29,7 +30,9 @@ pub fn get_all_events( vals.push((height, NewBlock::new(height).into())); } - RpcEventData::Tx { .. } => { + RpcEventData::Tx { tx_result } => { + tracing::trace!("Got Tx events {:#?}", tx_result); + let events = &result.events.ok_or("missing events")?; let height_raw = events.get("tx.height").ok_or("tx.height")?[0] .parse::() @@ -81,7 +84,7 @@ pub fn build_event(mut object: RawObject) -> Result { )?)), // Channel events - "channel_open_init" => Ok(IbcEvent::from(ChannelEvents::OpenInit::try_from(object)?)), + "channel_open_init" | "register" => Ok(IbcEvent::from(ChannelEvents::OpenInit::try_from(object)?)), "channel_open_try" => Ok(IbcEvent::from(ChannelEvents::OpenTry::try_from(object)?)), "channel_open_ack" => Ok(IbcEvent::from(ChannelEvents::OpenAck::try_from(object)?)), "channel_open_confirm" => Ok(IbcEvent::from(ChannelEvents::OpenConfirm::try_from( @@ -99,7 +102,7 @@ pub fn build_event(mut object: RawObject) -> Result { // - "register" and "send" for ICS27 // However the attributes are all prefixed with "send_packet" therefore the overwrite here // TODO: This need to be sorted out - "transfer" | "register" | "send" => { + "transfer" | "send" => { object.action = "send_packet".to_string(); Ok(IbcEvent::from(ChannelEvents::SendPacket::try_from(object)?)) } From 0f3eacfea5effa7562bfe0f713a2279aa7d76ac4 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 23 Jun 2021 11:33:03 -0400 Subject: [PATCH 02/10] Debugability, add check for chan try for counterparty ch --- relayer/src/channel.rs | 45 ++++++++++++++++++++++++++++++++++++++- relayer/src/event/rpc.rs | 15 +++++++------ relayer/src/supervisor.rs | 18 +++++++++------- 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index 54784028d7..eb18ca3cb5 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -32,6 +32,7 @@ use crate::object::Channel as WorkerChannelObject; use crate::supervisor::Error as WorkerChannelError; use crate::util::retry::RetryResult; use crate::util::retry::{retry_count, retry_with_index}; +use std::fmt; mod retry_strategy { use std::time::Duration; @@ -625,7 +626,7 @@ impl Channel { match self.handshake_step(state) { Err(e) => { - error!("Failed {:?} with error {}", state, e); + error!("[{}] failed {:?} with error {}", self, state, e); RetryResult::Retry(index) } Ok(ev) => { @@ -839,6 +840,30 @@ impl Channel { .query_connection(self.dst_connection_id(), Height::zero()) .map_err(|e| ChannelError::QueryError(self.dst_chain().id(), e))?; + // If a counterparty channel is specified check that the channel exists on destination + if let Some(counterparty_channel_id) = self.dst_channel_id() { + let channel = self + .dst_chain() + .query_channel(self.dst_port_id(), counterparty_channel_id, Height::zero()) + .map_err(|e| { + ChannelError::Failed(format!( + "error querying counterparty channel {}/{} on destination chain {}: {}", + self.dst_port_id(), + counterparty_channel_id, + self.dst_chain().id(), + e + )) + })?; + if channel.state_matches(&State::Uninitialized) { + return Err(ChannelError::Failed(format!( + "counterparty channel {}/{} specified in open-init but does not exist on destination chain {}", + self.dst_port_id(), + counterparty_channel_id, + self.dst_chain().id() + ))); + } + } + let query_height = self .src_chain() .query_latest_height() @@ -1238,6 +1263,24 @@ impl Channel { } } +impl fmt::Display for Channel { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let channel_id = self + .src_channel_id() + .map(ToString::to_string) + .unwrap_or_else(|| "None".to_string()); + + write!( + f, + "{}:{}/{} -> {}", + self.src_chain().id(), + self.src_port_id(), + channel_id, + self.dst_chain().id() + ) + } +} + pub fn extract_channel_id(event: &IbcEvent) -> Result<&ChannelId, ChannelError> { match event { IbcEvent::OpenInitChannel(ev) => ev.channel_id(), diff --git a/relayer/src/event/rpc.rs b/relayer/src/event/rpc.rs index bc9d666ddb..a7d534efc3 100644 --- a/relayer/src/event/rpc.rs +++ b/relayer/src/event/rpc.rs @@ -20,8 +20,7 @@ pub fn get_all_events( let mut vals: Vec<(Height, IbcEvent)> = vec![]; match &result.data { - RpcEventData::NewBlock { block, result_begin_block, result_end_block } => { - tracing::trace!("Got begin block {:#?}, end block {:#?}", result_begin_block, result_end_block); + RpcEventData::NewBlock { block, .. } => { let height = Height::new( ChainId::chain_version(chain_id.to_string().as_str()), u64::from(block.as_ref().ok_or("tx.height")?.header.height), @@ -30,8 +29,8 @@ pub fn get_all_events( vals.push((height, NewBlock::new(height).into())); } - RpcEventData::Tx { tx_result } => { - tracing::trace!("Got Tx events {:#?}", tx_result); + RpcEventData::Tx { .. } => { + tracing::trace!("Got Tx events {:#?}", result.events); let events = &result.events.ok_or("missing events")?; let height_raw = events.get("tx.height").ok_or("tx.height")?[0] @@ -61,6 +60,7 @@ pub fn get_all_events( } pub fn build_event(mut object: RawObject) -> Result { + tracing::trace!("building event from {:#?}", object); match object.action.as_str() { // Client events "create_client" => Ok(IbcEvent::from(ClientEvents::CreateClient::try_from( @@ -84,7 +84,10 @@ pub fn build_event(mut object: RawObject) -> Result { )?)), // Channel events - "channel_open_init" | "register" => Ok(IbcEvent::from(ChannelEvents::OpenInit::try_from(object)?)), + "channel_open_init" | "register" => { + object.action = "channel_open_init".to_string(); + Ok(IbcEvent::from(ChannelEvents::OpenInit::try_from(object)?)) + } "channel_open_try" => Ok(IbcEvent::from(ChannelEvents::OpenTry::try_from(object)?)), "channel_open_ack" => Ok(IbcEvent::from(ChannelEvents::OpenAck::try_from(object)?)), "channel_open_confirm" => Ok(IbcEvent::from(ChannelEvents::OpenConfirm::try_from( @@ -99,7 +102,7 @@ pub fn build_event(mut object: RawObject) -> Result { // Note: There is no message.action "send_packet", the only one we can hook into is the // module's action: // - "transfer" for ICS20 - // - "register" and "send" for ICS27 + // - "send" for ICS27 // However the attributes are all prefixed with "send_packet" therefore the overwrite here // TODO: This need to be sorted out "transfer" | "send" => { diff --git a/relayer/src/supervisor.rs b/relayer/src/supervisor.rs index eac7e13fab..21786a25b8 100644 --- a/relayer/src/supervisor.rs +++ b/relayer/src/supervisor.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; use anomaly::BoxError; use crossbeam_channel::Receiver; use itertools::Itertools; -use tracing::{debug, error, warn}; +use tracing::{debug, error, trace, warn}; use ibc::{ events::IbcEvent, @@ -111,9 +111,11 @@ impl Supervisor { continue; } + trace!("got event {:?}", event); let object = event .channel_attributes() .map(|attr| Object::channel_from_chan_open_events(attr, src_chain)); + trace!("built object {:?}", object); if let Some(Ok(object)) = object { collected.per_object.entry(object).or_default().push(event); @@ -545,6 +547,13 @@ impl Supervisor { let mut collected = self.collect_events(src_chain.clone().as_ref(), batch); + // If there is a NewBlock event, forward the event to any workers affected by it. + if let Some(IbcEvent::NewBlock(new_block)) = collected.new_block { + for worker in self.workers.to_notify(&src_chain.id()) { + worker.send_new_block(height, new_block)?; + } + } + for (object, events) in collected.per_object.drain() { if events.is_empty() { continue; @@ -557,13 +566,6 @@ impl Supervisor { worker.send_events(height, events, chain_id.clone())? } - // If there is a NewBlock event, forward the event to any workers affected by it. - if let Some(IbcEvent::NewBlock(new_block)) = collected.new_block { - for worker in self.workers.to_notify(&src_chain.id()) { - worker.send_new_block(height, new_block)?; - } - } - Ok(()) } From a2bf4eea026ad79b04929891ded3d43651a54b8d Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 23 Jun 2021 17:54:10 -0400 Subject: [PATCH 03/10] Get events from RPC event's data insead of events --- modules/src/events.rs | 62 ------- modules/src/ics02_client/events.rs | 55 +----- modules/src/ics03_connection/events.rs | 72 +------- modules/src/ics04_channel/events.rs | 208 +---------------------- relayer/src/channel.rs | 12 +- relayer/src/event/rpc.rs | 224 +++---------------------- 6 files changed, 40 insertions(+), 593 deletions(-) diff --git a/modules/src/events.rs b/modules/src/events.rs index 1b9542c264..6e5d63a4bc 100644 --- a/modules/src/events.rs +++ b/modules/src/events.rs @@ -210,30 +210,6 @@ impl IbcEvent { } } -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct RawObject { - pub height: Height, - pub action: String, - pub idx: usize, - pub events: HashMap>, -} - -impl RawObject { - pub fn new( - height: Height, - action: String, - idx: usize, - events: HashMap>, - ) -> RawObject { - RawObject { - height, - action, - idx, - events, - } - } -} - pub fn extract_events( events: &HashMap, S>, action_string: &str, @@ -246,41 +222,3 @@ pub fn extract_events( } Err("Incorrect Event Type".into()) } - -#[macro_export] -macro_rules! make_event { - ($a:ident, $b:literal) => { - #[derive(Debug, Deserialize, Serialize, Clone)] - pub struct $a { - pub data: ::std::collections::HashMap>, - } - impl ::std::convert::TryFrom<$crate::events::RawObject> for $a { - type Error = ::anomaly::BoxError; - - fn try_from(result: $crate::events::RawObject) -> Result { - match $crate::events::extract_events(&result.events, $b) { - Ok(()) => Ok($a { - data: result.events.clone(), - }), - Err(e) => Err(e), - } - } - } - }; -} - -#[macro_export] -macro_rules! attribute { - ($a:ident, $b:literal) => { - $a.events.get($b).ok_or($b)?[$a.idx].parse()? - }; -} - -#[macro_export] -macro_rules! some_attribute { - ($a:ident, $b:literal) => { - $a.events - .get($b) - .map_or_else(|| None, |tags| tags[$a.idx].parse().ok()) - }; -} diff --git a/modules/src/ics02_client/events.rs b/modules/src/ics02_client/events.rs index b3080d1682..71691308fc 100644 --- a/modules/src/ics02_client/events.rs +++ b/modules/src/ics02_client/events.rs @@ -1,17 +1,14 @@ //! Types for the IBC events emitted from Tendermint Websocket by the client module. -use std::convert::{TryFrom, TryInto}; -use anomaly::BoxError; use serde_derive::{Deserialize, Serialize}; use subtle_encoding::hex; use tendermint_proto::Protobuf; -use crate::events::{IbcEvent, RawObject}; +use crate::events::IbcEvent; use crate::ics02_client::client_type::ClientType; use crate::ics02_client::header::AnyHeader; use crate::ics02_client::height::Height; use crate::ics24_host::identifier::ClientId; -use crate::{attribute, some_attribute}; /// The content of the `type` field for the event that a chain produces upon executing the create client transaction. const CREATE_EVENT_TYPE: &str = "create_client"; @@ -157,19 +154,6 @@ impl From for CreateClient { } } -impl TryFrom for CreateClient { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let consensus_height_str: String = attribute!(obj, "create_client.consensus_height"); - Ok(CreateClient(Attributes { - height: obj.height, - client_id: attribute!(obj, "create_client.client_id"), - client_type: attribute!(obj, "create_client.client_type"), - consensus_height: consensus_height_str.as_str().try_into()?, - })) - } -} - impl From for IbcEvent { fn from(v: CreateClient) -> Self { IbcEvent::CreateClient(v) @@ -219,30 +203,6 @@ impl From for UpdateClient { } } -impl TryFrom for UpdateClient { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let header_str: Option = some_attribute!(obj, "update_client.header"); - let header: Option = match header_str { - Some(str) => { - let header_bytes = hex::decode(str)?; - Some(Protobuf::decode(header_bytes.as_ref())?) - } - None => None, - }; - let consensus_height_str: String = attribute!(obj, "update_client.consensus_height"); - Ok(UpdateClient { - common: Attributes { - height: obj.height, - client_id: attribute!(obj, "update_client.client_id"), - client_type: attribute!(obj, "update_client.client_type"), - consensus_height: consensus_height_str.as_str().try_into()?, - }, - header, - }) - } -} - impl From for IbcEvent { fn from(v: UpdateClient) -> Self { IbcEvent::UpdateClient(v) @@ -272,19 +232,6 @@ impl ClientMisbehaviour { } } -impl TryFrom for ClientMisbehaviour { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let consensus_height_str: String = attribute!(obj, "client_misbehaviour.consensus_height"); - Ok(ClientMisbehaviour(Attributes { - height: obj.height, - client_id: attribute!(obj, "client_misbehaviour.client_id"), - client_type: attribute!(obj, "client_misbehaviour.client_type"), - consensus_height: consensus_height_str.as_str().try_into()?, - })) - } -} - impl From for IbcEvent { fn from(v: ClientMisbehaviour) -> Self { IbcEvent::ClientMisbehaviour(v) diff --git a/modules/src/ics03_connection/events.rs b/modules/src/ics03_connection/events.rs index 13243d1f25..5908207d4c 100644 --- a/modules/src/ics03_connection/events.rs +++ b/modules/src/ics03_connection/events.rs @@ -1,11 +1,8 @@ //! Types for the IBC events emitted from Tendermint Websocket by the connection module. -use crate::events::{IbcEvent, RawObject}; +use crate::events::IbcEvent; use crate::ics02_client::height::Height; use crate::ics24_host::identifier::{ClientId, ConnectionId}; -use crate::{attribute, some_attribute}; -use anomaly::BoxError; use serde_derive::{Deserialize, Serialize}; -use std::convert::TryFrom; /// The content of the `type` field for the event that a chain produces upon executing a connection handshake transaction. const INIT_EVENT_TYPE: &str = "connection_open_init"; @@ -105,22 +102,6 @@ impl From for OpenInit { } } -impl TryFrom for OpenInit { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenInit(Attributes { - height: obj.height, - connection_id: some_attribute!(obj, "connection_open_init.connection_id"), - client_id: attribute!(obj, "connection_open_init.client_id"), - counterparty_connection_id: some_attribute!( - obj, - "connection_open_init.counterparty_connection_id" - ), - counterparty_client_id: attribute!(obj, "connection_open_init.counterparty_client_id"), - })) - } -} - impl From for IbcEvent { fn from(v: OpenInit) -> Self { IbcEvent::OpenInitConnection(v) @@ -151,22 +132,6 @@ impl From for OpenTry { } } -impl TryFrom for OpenTry { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenTry(Attributes { - height: obj.height, - connection_id: some_attribute!(obj, "connection_open_try.connection_id"), - client_id: attribute!(obj, "connection_open_try.client_id"), - counterparty_connection_id: some_attribute!( - obj, - "connection_open_try.counterparty_connection_id" - ), - counterparty_client_id: attribute!(obj, "connection_open_try.counterparty_client_id"), - })) - } -} - impl From for IbcEvent { fn from(v: OpenTry) -> Self { IbcEvent::OpenTryConnection(v) @@ -197,22 +162,6 @@ impl From for OpenAck { } } -impl TryFrom for OpenAck { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenAck(Attributes { - height: obj.height, - connection_id: some_attribute!(obj, "connection_open_ack.connection_id"), - client_id: attribute!(obj, "connection_open_ack.client_id"), - counterparty_connection_id: some_attribute!( - obj, - "connection_open_ack.counterparty_connection_id" - ), - counterparty_client_id: attribute!(obj, "connection_open_ack.counterparty_client_id"), - })) - } -} - impl From for IbcEvent { fn from(v: OpenAck) -> Self { IbcEvent::OpenAckConnection(v) @@ -243,25 +192,6 @@ impl From for OpenConfirm { } } -impl TryFrom for OpenConfirm { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenConfirm(Attributes { - height: obj.height, - connection_id: some_attribute!(obj, "connection_open_confirm.connection_id"), - client_id: attribute!(obj, "connection_open_confirm.client_id"), - counterparty_connection_id: some_attribute!( - obj, - "connection_open_confirm.counterparty_connection_id" - ), - counterparty_client_id: attribute!( - obj, - "connection_open_confirm.counterparty_client_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: OpenConfirm) -> Self { IbcEvent::OpenConfirmConnection(v) diff --git a/modules/src/ics04_channel/events.rs b/modules/src/ics04_channel/events.rs index 5debf0d2c3..daae896142 100644 --- a/modules/src/ics04_channel/events.rs +++ b/modules/src/ics04_channel/events.rs @@ -1,12 +1,9 @@ //! Types for the IBC events emitted from Tendermint Websocket by the channels module. -use crate::events::{IbcEvent, RawObject}; +use crate::events::IbcEvent; use crate::ics02_client::height::Height; use crate::ics04_channel::packet::Packet; use crate::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; -use crate::{attribute, some_attribute}; -use anomaly::BoxError; use serde_derive::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; /// Channel event types const OPEN_INIT_EVENT_TYPE: &str = "channel_open_init"; @@ -64,7 +61,7 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option { SEND_PACKET => { let (packet, write_ack) = extract_packet_and_write_ack_from_tx(event); // This event should not have a write ack. - assert!(write_ack.is_none()); + assert_eq!(write_ack.len(), 0); Some(IbcEvent::SendPacket(SendPacket { height: Default::default(), packet, @@ -72,8 +69,6 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option { } WRITE_ACK => { let (packet, write_ack) = extract_packet_and_write_ack_from_tx(event); - // This event should have a write ack. - let write_ack = write_ack.unwrap(); Some(IbcEvent::WriteAcknowledgement(WriteAcknowledgement { height: Default::default(), packet, @@ -83,7 +78,7 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option { ACK_PACKET => { let (packet, write_ack) = extract_packet_and_write_ack_from_tx(event); // This event should not have a write ack. - assert!(write_ack.is_none()); + assert_eq!(write_ack.len(), 0); Some(IbcEvent::AcknowledgePacket(AcknowledgePacket { height: Default::default(), packet, @@ -92,7 +87,7 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option { TIMEOUT => { let (packet, write_ack) = extract_packet_and_write_ack_from_tx(event); // This event should not have a write ack. - assert!(write_ack.is_none()); + assert_eq!(write_ack.len(), 0); Some(IbcEvent::TimeoutPacket(TimeoutPacket { height: Default::default(), packet, @@ -125,11 +120,9 @@ fn extract_attributes_from_tx(event: &tendermint::abci::Event) -> Attributes { attr } -fn extract_packet_and_write_ack_from_tx( - event: &tendermint::abci::Event, -) -> (Packet, Option>) { +fn extract_packet_and_write_ack_from_tx(event: &tendermint::abci::Event) -> (Packet, Vec) { let mut packet = Packet::default(); - let mut write_ack = None; + let mut write_ack: Vec = vec![]; for tag in &event.attributes { let key = tag.key.as_ref(); let value = tag.value.as_ref(); @@ -144,7 +137,7 @@ fn extract_packet_and_write_ack_from_tx( packet.timeout_timestamp = value.parse().unwrap() } PKT_DATA_ATTRIBUTE_KEY => packet.data = Vec::from(value.as_bytes()), - PKT_ACK_ATTRIBUTE_KEY => write_ack = Some(Vec::from(value.as_bytes())), + PKT_ACK_ATTRIBUTE_KEY => write_ack = Vec::from(value.as_bytes()), _ => {} }; } @@ -211,23 +204,6 @@ impl From for OpenInit { } } -impl TryFrom for OpenInit { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenInit(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_open_init.port_id"), - channel_id: some_attribute!(obj, "channel_open_init.channel_id"), - connection_id: attribute!(obj, "channel_open_init.connection_id"), - counterparty_port_id: attribute!(obj, "channel_open_init.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_open_init.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: OpenInit) -> Self { IbcEvent::OpenInitChannel(v) @@ -261,23 +237,6 @@ impl From for OpenTry { } } -impl TryFrom for OpenTry { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenTry(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_open_try.port_id"), - channel_id: some_attribute!(obj, "channel_open_try.channel_id"), - connection_id: attribute!(obj, "channel_open_try.connection_id"), - counterparty_port_id: attribute!(obj, "channel_open_try.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_open_try.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: OpenTry) -> Self { IbcEvent::OpenTryChannel(v) @@ -315,23 +274,6 @@ impl From for OpenAck { } } -impl TryFrom for OpenAck { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenAck(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_open_ack.port_id"), - channel_id: some_attribute!(obj, "channel_open_ack.channel_id"), - connection_id: attribute!(obj, "channel_open_ack.connection_id"), - counterparty_port_id: attribute!(obj, "channel_open_ack.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_open_ack.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: OpenAck) -> Self { IbcEvent::OpenAckChannel(v) @@ -365,23 +307,6 @@ impl From for OpenConfirm { } } -impl TryFrom for OpenConfirm { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(OpenConfirm(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_open_confirm.port_id"), - channel_id: some_attribute!(obj, "channel_open_confirm.channel_id"), - connection_id: attribute!(obj, "channel_open_confirm.connection_id"), - counterparty_port_id: attribute!(obj, "channel_open_confirm.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_open_confirm.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: OpenConfirm) -> Self { IbcEvent::OpenConfirmChannel(v) @@ -427,23 +352,6 @@ impl From for CloseInit { } } -impl TryFrom for CloseInit { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(CloseInit(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_close_init.port_id"), - channel_id: some_attribute!(obj, "channel_close_init.channel_id"), - connection_id: attribute!(obj, "channel_close_init.connection_id"), - counterparty_port_id: attribute!(obj, "channel_close_init.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_close_init.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: CloseInit) -> Self { IbcEvent::CloseInitChannel(v) @@ -483,23 +391,6 @@ impl From for CloseConfirm { } } -impl TryFrom for CloseConfirm { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(CloseConfirm(Attributes { - height: obj.height, - port_id: attribute!(obj, "channel_close_confirm.port_id"), - channel_id: some_attribute!(obj, "channel_close_confirm.channel_id"), - connection_id: attribute!(obj, "channel_close_confirm.connection_id"), - counterparty_port_id: attribute!(obj, "channel_close_confirm.counterparty_port_id"), - counterparty_channel_id: some_attribute!( - obj, - "channel_close_confirm.counterparty_channel_id" - ), - })) - } -} - impl From for IbcEvent { fn from(v: CloseConfirm) -> Self { IbcEvent::CloseConfirmChannel(v) @@ -514,24 +405,6 @@ macro_rules! p_attribute { }}; } -impl TryFrom for Packet { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let height_str: String = p_attribute!(obj, "packet_timeout_height"); - let sequence: u64 = p_attribute!(obj, "packet_sequence"); - Ok(Packet { - sequence: sequence.into(), - source_port: p_attribute!(obj, "packet_src_port"), - source_channel: p_attribute!(obj, "packet_src_channel"), - destination_port: p_attribute!(obj, "packet_dst_port"), - destination_channel: p_attribute!(obj, "packet_dst_channel"), - data: vec![], - timeout_height: height_str.as_str().try_into()?, - timeout_timestamp: p_attribute!(obj, "packet_timeout_timestamp"), - }) - } -} - #[derive(Debug, Deserialize, Serialize, Clone)] pub struct SendPacket { pub height: Height, @@ -559,17 +432,6 @@ impl SendPacket { } } -impl TryFrom for SendPacket { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let height = obj.height; - let data_str: String = p_attribute!(obj, "packet_data"); - let mut packet = Packet::try_from(obj)?; - packet.data = Vec::from(data_str.as_str().as_bytes()); - Ok(SendPacket { height, packet }) - } -} - impl From for IbcEvent { fn from(v: SendPacket) -> Self { IbcEvent::SendPacket(v) @@ -609,17 +471,6 @@ impl ReceivePacket { } } -impl TryFrom for ReceivePacket { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let height = obj.height; - let data_str: String = p_attribute!(obj, "packet_data"); - let mut packet = Packet::try_from(obj)?; - packet.data = Vec::from(data_str.as_str().as_bytes()); - Ok(ReceivePacket { height, packet }) - } -} - impl From for IbcEvent { fn from(v: ReceivePacket) -> Self { IbcEvent::ReceivePacket(v) @@ -661,22 +512,6 @@ impl WriteAcknowledgement { } } -impl TryFrom for WriteAcknowledgement { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let height = obj.height; - let data_str: String = p_attribute!(obj, "packet_data"); - let ack_str: String = p_attribute!(obj, "packet_ack"); - let mut packet = Packet::try_from(obj)?; - packet.data = Vec::from(data_str.as_str().as_bytes()); - Ok(WriteAcknowledgement { - height, - packet, - ack: Vec::from(ack_str.as_str().as_bytes()), - }) - } -} - impl From for IbcEvent { fn from(v: WriteAcknowledgement) -> Self { IbcEvent::WriteAcknowledgement(v) @@ -714,15 +549,6 @@ impl AcknowledgePacket { } } -impl TryFrom for AcknowledgePacket { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - let height = obj.height; - let packet = Packet::try_from(obj)?; - Ok(AcknowledgePacket { height, packet }) - } -} - impl From for IbcEvent { fn from(v: AcknowledgePacket) -> Self { IbcEvent::AcknowledgePacket(v) @@ -762,16 +588,6 @@ impl TimeoutPacket { } } -impl TryFrom for TimeoutPacket { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(TimeoutPacket { - height: obj.height, - packet: Packet::try_from(obj)?, - }) - } -} - impl From for IbcEvent { fn from(v: TimeoutPacket) -> Self { IbcEvent::TimeoutPacket(v) @@ -811,16 +627,6 @@ impl TimeoutOnClosePacket { } } -impl TryFrom for TimeoutOnClosePacket { - type Error = BoxError; - fn try_from(obj: RawObject) -> Result { - Ok(TimeoutOnClosePacket { - height: obj.height, - packet: Packet::try_from(obj)?, - }) - } -} - impl From for IbcEvent { fn from(v: TimeoutOnClosePacket) -> Self { IbcEvent::TimeoutOnClosePacket(v) diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index eb18ca3cb5..f8ea1e630d 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -885,7 +885,7 @@ impl Channel { *src_channel.ordering(), counterparty, vec![self.dst_connection_id().clone()], - self.dst_version()?, + src_channel.version(), ); // Get signer @@ -907,12 +907,14 @@ impl Channel { let new_msg = MsgChannelOpenTry { port_id: self.dst_port_id().clone(), previous_channel_id, - counterparty_version: self.src_version()?, + counterparty_version: src_channel.version(), channel, proofs, signer, }; + tracing::trace!("Built try message: {:#?}", new_msg); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -958,7 +960,7 @@ impl Channel { self.validated_expected_channel(ChannelMsgType::OpenAck)?; // Channel must exist on source - self.src_chain() + let src_channel = self.src_chain() .query_channel(self.src_port_id(), src_channel_id, Height::zero()) .map_err(|e| ChannelError::QueryError(self.src_chain().id(), e))?; @@ -999,11 +1001,13 @@ impl Channel { port_id: self.dst_port_id().clone(), channel_id: dst_channel_id.clone(), counterparty_channel_id: src_channel_id.clone(), - counterparty_version: self.src_version()?, + counterparty_version: src_channel.version, proofs, signer, }; + tracing::trace!("Built ack message: {:#?}", new_msg); + msgs.push(new_msg.to_any()); Ok(msgs) } diff --git a/relayer/src/event/rpc.rs b/relayer/src/event/rpc.rs index a7d534efc3..9bc2e2f671 100644 --- a/relayer/src/event/rpc.rs +++ b/relayer/src/event/rpc.rs @@ -1,17 +1,10 @@ -use std::{collections::HashMap, convert::TryFrom}; - -use anomaly::BoxError; -use tendermint_rpc::event::{Event as RpcEvent, EventData as RpcEventData}; +use tendermint::abci::tag::Tag as AbciTag; +use tendermint_rpc::event::{Event as RpcEvent, EventData as RpcEventData, EventData}; +use ibc::events::{from_tx_response_event, IbcEvent}; use ibc::ics02_client::events::NewBlock; use ibc::ics02_client::height::Height; use ibc::ics24_host::identifier::ChainId; -use ibc::{ - events::{IbcEvent, RawObject}, - ics02_client::events as ClientEvents, - ics03_connection::events as ConnectionEvents, - ics04_channel::events as ChannelEvents, -}; pub fn get_all_events( chain_id: &ChainId, @@ -28,28 +21,29 @@ pub fn get_all_events( vals.push((height, NewBlock::new(height).into())); } - - RpcEventData::Tx { .. } => { - tracing::trace!("Got Tx events {:#?}", result.events); - - let events = &result.events.ok_or("missing events")?; - let height_raw = events.get("tx.height").ok_or("tx.height")?[0] - .parse::() - .map_err(|e| e.to_string())?; + EventData::Tx { tx_result } => { let height = Height::new( ChainId::chain_version(chain_id.to_string().as_str()), - height_raw, + tx_result.height as u64, ); - - let actions_and_indices = extract_helper(events)?; - for action in actions_and_indices { - if let Ok(event) = build_event(RawObject::new( - height, - action.0, - action.1 as usize, - events.clone(), - )) { - vals.push((height, event)); + for event in tx_result.result.events.iter() { + let abci_event = tendermint::abci::Event { + type_str: event.event_type.to_string(), + attributes: event + .attributes + .iter() + .map(|rpc_tag| { + serde_json::from_str::( + serde_json::to_string(rpc_tag).unwrap().as_str(), + ) + .unwrap() + }) + .collect(), + }; + + if let Some(ibc_event) = from_tx_response_event(height, &abci_event) { + tracing::trace!("Extracted ibc_event {:?}", ibc_event); + vals.push((height, ibc_event)); } } } @@ -58,175 +52,3 @@ pub fn get_all_events( Ok(vals) } - -pub fn build_event(mut object: RawObject) -> Result { - tracing::trace!("building event from {:#?}", object); - match object.action.as_str() { - // Client events - "create_client" => Ok(IbcEvent::from(ClientEvents::CreateClient::try_from( - object, - )?)), - "update_client" => Ok(IbcEvent::from(ClientEvents::UpdateClient::try_from( - object, - )?)), - "submit_misbehaviour" => Ok(IbcEvent::from(ClientEvents::ClientMisbehaviour::try_from( - object, - )?)), - - // Connection events - "connection_open_init" => Ok(IbcEvent::from(ConnectionEvents::OpenInit::try_from( - object, - )?)), - "connection_open_try" => Ok(IbcEvent::from(ConnectionEvents::OpenTry::try_from(object)?)), - "connection_open_ack" => Ok(IbcEvent::from(ConnectionEvents::OpenAck::try_from(object)?)), - "connection_open_confirm" => Ok(IbcEvent::from(ConnectionEvents::OpenConfirm::try_from( - object, - )?)), - - // Channel events - "channel_open_init" | "register" => { - object.action = "channel_open_init".to_string(); - Ok(IbcEvent::from(ChannelEvents::OpenInit::try_from(object)?)) - } - "channel_open_try" => Ok(IbcEvent::from(ChannelEvents::OpenTry::try_from(object)?)), - "channel_open_ack" => Ok(IbcEvent::from(ChannelEvents::OpenAck::try_from(object)?)), - "channel_open_confirm" => Ok(IbcEvent::from(ChannelEvents::OpenConfirm::try_from( - object, - )?)), - "channel_close_init" => Ok(IbcEvent::from(ChannelEvents::CloseInit::try_from(object)?)), - "channel_close_confirm" => Ok(IbcEvent::from(ChannelEvents::CloseConfirm::try_from( - object, - )?)), - - // Packet events - // Note: There is no message.action "send_packet", the only one we can hook into is the - // module's action: - // - "transfer" for ICS20 - // - "send" for ICS27 - // However the attributes are all prefixed with "send_packet" therefore the overwrite here - // TODO: This need to be sorted out - "transfer" | "send" => { - object.action = "send_packet".to_string(); - Ok(IbcEvent::from(ChannelEvents::SendPacket::try_from(object)?)) - } - // Same here - // TODO: sort this out - "recv_packet" => { - object.action = "write_acknowledgement".to_string(); - Ok(IbcEvent::from( - ChannelEvents::WriteAcknowledgement::try_from(object)?, - )) - } - "write_acknowledgement" => Ok(IbcEvent::from( - ChannelEvents::WriteAcknowledgement::try_from(object)?, - )), - "acknowledge_packet" => Ok(IbcEvent::from(ChannelEvents::AcknowledgePacket::try_from( - object, - )?)), - "timeout_packet" => Ok(IbcEvent::from(ChannelEvents::TimeoutPacket::try_from( - object, - )?)), - - "timeout_on_close_packet" => { - object.action = "timeout_packet".to_string(); - Ok(IbcEvent::from( - ChannelEvents::TimeoutOnClosePacket::try_from(object)?, - )) - } - - event_type => Err(format!("Incorrect event type: '{}'", event_type).into()), - } -} - -/// Takes events in the form -/// -/// ```json -/// { -/// "events": { -/// "connection_open_init.client_id": [ -/// "testclient", -/// "testclientsec" -/// ], -/// "connection_open_init.connection_id": [ -/// "ancaconnonetest", -/// "ancaconnonetestsec" -/// ], -/// "connection_open_init.counterparty_client_id": [ -/// "testclientsec", -/// "testclientsecsec" -/// ], -/// "create_client.client_id": [ -/// "testclientthird" -/// ], -/// "create_client.client_type": [ -/// "tendermint" -/// ], -/// "message.action": [ -/// "connection_open_init", -/// "create_client", -/// "connection_open_init" -/// ], -/// "message.module": [ -/// "ibc_connection", -/// "ibc_client", -/// "ibc_connection" -/// ], -/// "message.sender": [ -/// "cosmos187xxg4yfkypl05cqylucezpjvycj24nurvm8p9", -/// "cosmos187xxg4yfkypl05cqylucezpjvycj24nurvm8p9", -/// "cosmos187xxg4yfkypl05cqylucezpjvycj24nurvm8p9", -/// "cosmos187xxg4yfkypl05cqylucezpjvycj24nurvm8p9" -/// ], -/// "tm.event": [ -/// "Tx" -/// ], -/// "transfer.amount": [ -/// "5000stake" -/// ], -/// "transfer.recipient": [ -/// "cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta" -/// ], -/// "tx.hash": [ -/// "A9E18AE3909F22232F8DBDB1C48F2FECB260A308A2D157E8832E901D45950605" -/// ], -/// "tx.height": [ -/// "35" -/// ] -/// } -/// } -/// ``` -/// -/// and returns: -/// -/// ```rust -/// vec![ -/// ("connection_open_init", 0), -/// ("create_client", 0), -/// ("connection_open_init", 1), -/// ]; -/// ``` -/// -/// where the number in each entry is the index in the matching events that should be used to build the event. -/// -/// e.g. for the last "connection_open_init" in the result -/// -/// ```text -/// "connection_open_init.client_id" -> "testclientsec" -/// "connection_open_init.connection_id" -> "ancaconnonetestsec", -/// "connection_open_init.counterparty_client_id" -> "testclientsec", "testclientsecsec", -/// ``` -fn extract_helper(events: &HashMap>) -> Result, String> { - let actions = events.get("message.action").ok_or("Incorrect Event Type")?; - - let mut val_indices = HashMap::new(); - let mut result = Vec::with_capacity(actions.len()); - - for action in actions { - let idx = val_indices.entry(action.clone()).or_insert_with(|| 0); - result.push((action.clone(), *idx)); - - *val_indices.get_mut(action.as_str()).unwrap() += 1; - } - - Ok(result) -} From 611a5547513880ce1b0aefd910670d24377d91db Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 30 Jun 2021 08:43:26 -0400 Subject: [PATCH 04/10] Fix error message --- relayer/src/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index f8ea1e630d..fbd04dc305 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -626,7 +626,7 @@ impl Channel { match self.handshake_step(state) { Err(e) => { - error!("[{}] failed {:?} with error {}", self, state, e); + error!("[{}] failed to build message from state {:?} with error {}", self, state, e); RetryResult::Retry(index) } Ok(ev) => { From f58b37ec838c6398a529f821294019b0588b6707 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 30 Jun 2021 08:58:52 -0400 Subject: [PATCH 05/10] Debug for proof bytes and getter of other_proof --- modules/src/ics04_channel/msgs/timeout_on_close.rs | 2 +- modules/src/ics23_commitment/commitment.rs | 8 +++++++- modules/src/proofs.rs | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/src/ics04_channel/msgs/timeout_on_close.rs b/modules/src/ics04_channel/msgs/timeout_on_close.rs index ace86cb977..f7a3d93f3b 100644 --- a/modules/src/ics04_channel/msgs/timeout_on_close.rs +++ b/modules/src/ics04_channel/msgs/timeout_on_close.rs @@ -93,7 +93,7 @@ impl From for RawMsgTimeoutOnClose { proof_unreceived: domain_msg.proofs.object_proof().clone().into(), proof_close: domain_msg .proofs - .other_proof + .other_proof() .clone() .map_or_else(Vec::new, |v| v.into()), proof_height: Some(domain_msg.proofs.height().into()), diff --git a/modules/src/ics23_commitment/commitment.rs b/modules/src/ics23_commitment/commitment.rs index 4b0faac1e0..0f783fcb4c 100644 --- a/modules/src/ics23_commitment/commitment.rs +++ b/modules/src/ics23_commitment/commitment.rs @@ -43,13 +43,19 @@ impl From> for CommitmentRoot { #[derive(Clone, Debug, PartialEq)] pub struct CommitmentPath; -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +#[derive(Clone, PartialEq, Eq, Serialize)] #[serde(transparent)] pub struct CommitmentProofBytes { #[serde(serialize_with = "crate::serializers::ser_hex_upper")] bytes: Vec, } +impl fmt::Debug for CommitmentProofBytes { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "[...]") + } +} + impl CommitmentProofBytes { pub fn is_empty(&self) -> bool { self.bytes.len() == 0 diff --git a/modules/src/proofs.rs b/modules/src/proofs.rs index d0fbfbbb28..d62cca6d2e 100644 --- a/modules/src/proofs.rs +++ b/modules/src/proofs.rs @@ -12,7 +12,7 @@ pub struct Proofs { client_proof: Option, consensus_proof: Option, /// Currently used for proof_close for MsgTimeoutOnCLose where object_proof is proof_unreceived - pub(crate) other_proof: Option, + other_proof: Option, /// Height for the commitment root for proving the proofs above. /// When creating these proofs, the chain is queried at `height-1`. height: Height, @@ -64,6 +64,11 @@ impl Proofs { pub fn client_proof(&self) -> &Option { &self.client_proof } + + /// Getter for the other_proof. + pub fn other_proof(&self) -> &Option { + &self.other_proof + } } #[derive(Clone, Debug, PartialEq, Eq, Serialize)] From f1bafab9e5a33bdc7c864fef05f96a72d643b2de Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Wed, 18 Aug 2021 09:24:02 -0400 Subject: [PATCH 06/10] fmt fix --- relayer/src/channel.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index 31b2f4a324..8faa45b0d4 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -960,7 +960,8 @@ impl Channel { self.validated_expected_channel(ChannelMsgType::OpenAck)?; // Channel must exist on source - let src_channel = self.src_chain() + let src_channel = self + .src_chain() .query_channel(self.src_port_id(), src_channel_id, Height::zero()) .map_err(|e| ChannelError::QueryError(self.src_chain().id(), e))?; From 45fae3e63b59278f934ecec23a9bf87effbab25f Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Mon, 23 Aug 2021 13:31:20 -0400 Subject: [PATCH 07/10] Remove event conversion, redundant with current tendermint-rs refpoint --- relayer/src/event/rpc.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/relayer/src/event/rpc.rs b/relayer/src/event/rpc.rs index cb4fceeef7..855f5b71a2 100644 --- a/relayer/src/event/rpc.rs +++ b/relayer/src/event/rpc.rs @@ -1,4 +1,3 @@ -use tendermint::abci::tag::Tag as AbciTag; use tendermint_rpc::event::{Event as RpcEvent, EventData as RpcEventData, EventData}; use ibc::events::{from_tx_response_event, IbcEvent}; @@ -26,21 +25,7 @@ pub fn get_all_events( ChainId::chain_version(chain_id.to_string().as_str()), tx_result.height as u64, ); - for event in tx_result.result.events.iter() { - let abci_event = tendermint::abci::Event { - type_str: event.type_str.clone(), - attributes: event - .attributes - .iter() - .map(|rpc_tag| { - serde_json::from_str::( - serde_json::to_string(rpc_tag).unwrap().as_str(), - ) - .unwrap() - }) - .collect(), - }; - + for abci_event in tx_result.result.events.iter() { if let Some(ibc_event) = from_tx_response_event(height, &abci_event) { tracing::trace!("Extracted ibc_event {:?}", ibc_event); vals.push((height, ibc_event)); From 1a38886ffe8c47a75f6efa8cdd3ed87600954884 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Mon, 23 Aug 2021 14:15:33 -0400 Subject: [PATCH 08/10] Review comments --- modules/src/ics23_commitment/commitment.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/src/ics23_commitment/commitment.rs b/modules/src/ics23_commitment/commitment.rs index 7eb7126a84..64badebadc 100644 --- a/modules/src/ics23_commitment/commitment.rs +++ b/modules/src/ics23_commitment/commitment.rs @@ -51,8 +51,9 @@ pub struct CommitmentProofBytes { } impl fmt::Debug for CommitmentProofBytes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "[...]") + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let hex = Hex::upper_case().encode_to_string(&self.bytes).unwrap(); + f.debug_tuple("CommitmentProof").field(&hex).finish() } } From 368d37bd9e771796ecaa928de53840100a762aa7 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 23 Aug 2021 20:51:44 +0200 Subject: [PATCH 09/10] Add .changelog entry for #1191 --- .changelog/unreleased/improvements/1191-ica-compat.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changelog/unreleased/improvements/1191-ica-compat.md diff --git a/.changelog/unreleased/improvements/1191-ica-compat.md b/.changelog/unreleased/improvements/1191-ica-compat.md new file mode 100644 index 0000000000..b189173405 --- /dev/null +++ b/.changelog/unreleased/improvements/1191-ica-compat.md @@ -0,0 +1,4 @@ +- Improve support for Interchain Accounts (ICS 027) ([#1191]) + +[#1191]: https://github.com/informalsystems/ibc-rs/issues/1191 + From 9753197082433418daaef4a026341a2697fb013c Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 23 Aug 2021 21:30:37 +0200 Subject: [PATCH 10/10] Fix clippy warning --- relayer/src/event/rpc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/relayer/src/event/rpc.rs b/relayer/src/event/rpc.rs index 855f5b71a2..043a9fddb0 100644 --- a/relayer/src/event/rpc.rs +++ b/relayer/src/event/rpc.rs @@ -25,8 +25,9 @@ pub fn get_all_events( ChainId::chain_version(chain_id.to_string().as_str()), tx_result.height as u64, ); - for abci_event in tx_result.result.events.iter() { - if let Some(ibc_event) = from_tx_response_event(height, &abci_event) { + + for abci_event in &tx_result.result.events { + if let Some(ibc_event) = from_tx_response_event(height, abci_event) { tracing::trace!("Extracted ibc_event {:?}", ibc_event); vals.push((height, ibc_event)); }