From 7158fbb2d8c5a17fe832b6483602c52744677795 Mon Sep 17 00:00:00 2001 From: benluelo Date: Fri, 13 Dec 2024 18:25:08 +0000 Subject: [PATCH] feat(voyager): fixes and improvements --- Cargo.lock | 1 + cosmwasm/union-ibc/README.md | 2 +- cosmwasm/union-ibc/core/src/contract.rs | 13 +- lib/ibc-union-spec/Cargo.toml | 4 + lib/ibc-union-spec/src/lib.rs | 294 ++++++++++++++- .../event-source/cosmos-sdk/src/ibc_events.rs | 8 +- .../event-source/cosmos-sdk/src/main.rs | 291 ++++++-------- .../plugins/event-source/ethereum/Cargo.toml | 2 +- .../plugins/event-source/ethereum/src/main.rs | 356 ++++++++++-------- .../transaction/cosmos-sdk/src/main.rs | 72 ++-- .../plugins/transaction/ethereum/src/main.rs | 20 +- voyager/voyager.nix | 12 - 12 files changed, 673 insertions(+), 402 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1b71d700c..178e75246b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6377,6 +6377,7 @@ dependencies = [ "schemars", "serde", "sha3 0.10.8", + "tracing", "unionlabs", "voyager-core", ] diff --git a/cosmwasm/union-ibc/README.md b/cosmwasm/union-ibc/README.md index 61d988f1d3..722db772a3 100644 --- a/cosmwasm/union-ibc/README.md +++ b/cosmwasm/union-ibc/README.md @@ -1,3 +1,3 @@ - `union-ibc`: [union17e93ukhcyesrvu72cgfvamdhyracghrx4f7ww89rqjg944ntdegscxepme](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union17e93ukhcyesrvu72cgfvamdhyracghrx4f7ww89rqjg944ntdegscxepme) - `etheruem-light-client`: [union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk) -- `union-ibc-ucs00-pingpong`: [union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he) +- `union-ibc-ucs00-pingpong`: [union1aj2z8mf6ppg4pjsj787t69phxy3mx8p7ce8ncem05lls5j29haxsumypzd](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he) diff --git a/cosmwasm/union-ibc/core/src/contract.rs b/cosmwasm/union-ibc/core/src/contract.rs index 88e04bb912..b5cd7f08f7 100644 --- a/cosmwasm/union-ibc/core/src/contract.rs +++ b/cosmwasm/union-ibc/core/src/contract.rs @@ -44,9 +44,9 @@ type ContractResult = Result; pub mod events { pub mod client { - pub const REGISTER: &str = "client_register"; - pub const CREATE: &str = "client_create"; - pub const UPDATE: &str = "client_update"; + pub const REGISTER: &str = "register_client"; + pub const CREATE: &str = "create_client"; + pub const UPDATE: &str = "update_client"; } pub mod connection { pub const OPEN_INIT: &str = "connection_open_init"; @@ -76,7 +76,7 @@ pub mod events { pub const CONNECTION_ID: &str = "connection_id"; pub const CHANNEL_ID: &str = "channel_id"; pub const COUNTERPARTY_CHANNEL_ID: &str = "counterparty_channel_id"; - pub const HEIGHT: &str = "height"; + pub const COUNTERPARTY_HEIGHT: &str = "counterparty_height"; pub const PACKET: &str = "packet"; pub const PACKETS: &str = "packets"; pub const ACKS: &str = "acks"; @@ -771,7 +771,10 @@ fn update_client( Ok( Response::new().add_event(Event::new(events::client::UPDATE).add_attributes([ (events::attribute::CLIENT_ID, client_id.to_string()), - (events::attribute::HEIGHT, update.height.to_string()), + ( + events::attribute::COUNTERPARTY_HEIGHT, + update.height.to_string(), + ), ])), ) } diff --git a/lib/ibc-union-spec/Cargo.toml b/lib/ibc-union-spec/Cargo.toml index 1df8e123a2..406a0c7921 100644 --- a/lib/ibc-union-spec/Cargo.toml +++ b/lib/ibc-union-spec/Cargo.toml @@ -12,8 +12,12 @@ macros = { workspace = true } schemars = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] } sha3 = { workspace = true } +tracing = { workspace = true, optional = true } unionlabs = { workspace = true } voyager-core = { workspace = true } [lints] workspace = true + +[features] +tracing = ["dep:tracing"] diff --git a/lib/ibc-union-spec/src/lib.rs b/lib/ibc-union-spec/src/lib.rs index 0184f5499c..dae2f851f8 100644 --- a/lib/ibc-union-spec/src/lib.rs +++ b/lib/ibc-union-spec/src/lib.rs @@ -254,14 +254,14 @@ impl Datagram { Self::ConnectionOpenTry(msg) => Some(Height::new(msg.proof_height)), Self::ConnectionOpenAck(msg) => Some(Height::new(msg.proof_height)), Self::ConnectionOpenConfirm(msg) => Some(Height::new(msg.proof_height)), - Self::ChannelOpenInit(_msg) => todo!(), - Self::ChannelOpenTry(_msg) => todo!(), - Self::ChannelOpenAck(_msg) => todo!(), - Self::ChannelOpenConfirm(_msg) => todo!(), + Self::ChannelOpenInit(msg) => None, + Self::ChannelOpenTry(msg) => Some(Height::new(msg.proof_height)), + Self::ChannelOpenAck(msg) => Some(Height::new(msg.proof_height)), + Self::ChannelOpenConfirm(msg) => Some(Height::new(msg.proof_height)), Self::ChannelCloseInit(_msg) => todo!(), Self::ChannelCloseConfirm(_msg) => todo!(), - Self::PacketRecv(_msg) => todo!(), - Self::PacketAcknowledgement(_msg) => todo!(), + Self::PacketRecv(msg) => Some(Height::new(msg.proof_height)), + Self::PacketAcknowledgement(msg) => Some(Height::new(msg.proof_height)), Self::PacketTimeout(_msg) => todo!(), Self::IntentPacketRecv(_msg) => todo!(), Self::BatchSend(_msg) => todo!(), @@ -434,18 +434,18 @@ pub enum FullEvent { impl FullEvent { pub fn counterparty_client_id(&self) -> Option { match self { - FullEvent::CreateClient(_) => None, - FullEvent::UpdateClient(_) => None, - FullEvent::ConnectionOpenInit(event) => Some(event.counterparty_client_id), - FullEvent::ConnectionOpenTry(event) => Some(event.counterparty_client_id), - FullEvent::ConnectionOpenAck(event) => Some(event.counterparty_client_id), - FullEvent::ConnectionOpenConfirm(event) => Some(event.counterparty_client_id), - FullEvent::ChannelOpenInit(event) => Some(event.connection.counterparty_client_id), - FullEvent::ChannelOpenTry(event) => Some(event.connection.counterparty_client_id), - FullEvent::ChannelOpenAck(event) => Some(event.connection.counterparty_client_id), - FullEvent::ChannelOpenConfirm(event) => Some(event.connection.counterparty_client_id), - FullEvent::ChannelCloseInit(_) => todo!(), - FullEvent::ChannelCloseConfirm(_) => todo!(), + Self::CreateClient(_) => None, + Self::UpdateClient(_) => None, + Self::ConnectionOpenInit(event) => Some(event.counterparty_client_id), + Self::ConnectionOpenTry(event) => Some(event.counterparty_client_id), + Self::ConnectionOpenAck(event) => Some(event.counterparty_client_id), + Self::ConnectionOpenConfirm(event) => Some(event.counterparty_client_id), + Self::ChannelOpenInit(event) => Some(event.connection.counterparty_client_id), + Self::ChannelOpenTry(event) => Some(event.connection.counterparty_client_id), + Self::ChannelOpenAck(event) => Some(event.connection.counterparty_client_id), + Self::ChannelOpenConfirm(event) => Some(event.connection.counterparty_client_id), + Self::ChannelCloseInit(_) => todo!(), + Self::ChannelCloseConfirm(_) => todo!(), Self::PacketSend(event) => Some(event.packet.destination_channel.connection.client_id), Self::PacketRecv(event) => Some(event.packet.source_channel.connection.client_id), Self::IntentPacketRecv(event) => Some(event.packet.source_channel.connection.client_id), @@ -456,6 +456,29 @@ impl FullEvent { } } } + + pub fn name(&self) -> &'static str { + match self { + Self::CreateClient(_) => "create_client", + Self::UpdateClient(_) => "update_client", + Self::ConnectionOpenInit(_) => "connection_open_init", + Self::ConnectionOpenTry(_) => "connection_open_try", + Self::ConnectionOpenAck(_) => "connection_open_ack", + Self::ConnectionOpenConfirm(_) => "connection_open_confirm", + Self::ChannelOpenInit(_) => "channel_open_init", + Self::ChannelOpenTry(_) => "channel_open_try", + Self::ChannelOpenAck(_) => "channel_open_ack", + Self::ChannelOpenConfirm(_) => "channel_open_confirm", + Self::ChannelCloseInit(_) => "channel_close_init", + Self::ChannelCloseConfirm(_) => "channel_close_confirm", + Self::PacketSend(_) => "packet_send", + Self::PacketRecv(_) => "packet_recv", + Self::IntentPacketRecv(_) => "intent_packet_recv", + Self::WriteAck(_) => "write_ack", + Self::PacketAck(_) => "packet_ack", + Self::PacketTimeout(_) => "packet_timeout", + } + } } type ClientId = u32; @@ -634,3 +657,238 @@ pub struct ConnectionMetadata { pub client_id: ClientId, pub connection_id: ConnectionId, } + +#[cfg(feature = "tracing")] +pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { + use tracing::info; + + let event = e.name(); + + match e { + FullEvent::CreateClient(e) => info!( + event, + %chain_id, + data.client_id = %e.client_id, + data.client_type = %e.client_type, + "event" + ), + FullEvent::UpdateClient(e) => info!( + event, + %chain_id, + data.client_id = %e.client_id, + data.client_type = %e.client_type, + data.height = e.height, + "event" + ), + FullEvent::ConnectionOpenInit(e) => info!( + event, + %chain_id, + data.connection_id = %e.connection_id, + data.client_id = %e.client_id, + data.counterparty_client_id = %e.counterparty_client_id, + "event" + ), + FullEvent::ConnectionOpenTry(e) => info!( + event, + %chain_id, + data.connection_id = %e.connection_id, + data.client_id = %e.client_id, + data.counterparty_client_id = %e.counterparty_client_id, + data.counterparty_connection_id = %e.counterparty_connection_id, + "event" + ), + FullEvent::ConnectionOpenAck(e) => info!( + event, + %chain_id, + data.connection_id = %e.connection_id, + data.client_id = %e.client_id, + data.counterparty_client_id = %e.counterparty_client_id, + data.counterparty_connection_id = %e.counterparty_connection_id, + "event" + ), + FullEvent::ConnectionOpenConfirm(e) => info!( + event, + %chain_id, + data.connection_id = %e.connection_id, + data.client_id = %e.client_id, + data.counterparty_client_id = %e.counterparty_client_id, + data.counterparty_connection_id = %e.counterparty_connection_id, + "event" + ), + FullEvent::ChannelOpenInit(e) => info!( + event, + %chain_id, + data.port_id = %e.port_id, + data.channel_id = %e.channel_id, + data.counterparty_port_id = %e.counterparty_port_id, + data.connection.state = ?e.connection.state, + data.connection.client_id = %e.connection.client_id, + data.connection.counterparty_client_id = %e.connection.counterparty_client_id, + data.connection.counterparty_connection_id = %e.connection.counterparty_connection_id, + data.version = %e.version, + "event" + ), + FullEvent::ChannelOpenTry(e) => info!( + event, + %chain_id, + data.port_id = %e.port_id, + data.channel_id = %e.channel_id, + data.counterparty_port_id = %e.counterparty_port_id, + data.counterparty_channel_id = %e.counterparty_channel_id, + data.connection.state = ?e.connection.state, + data.connection.client_id = %e.connection.client_id, + data.connection.counterparty_client_id = %e.connection.counterparty_client_id, + data.connection.counterparty_connection_id = %e.connection.counterparty_connection_id, + data.version = %e.version, + "event" + ), + FullEvent::ChannelOpenAck(e) => info!( + event, + %chain_id, + data.port_id = %e.port_id, + data.channel_id = %e.channel_id, + data.counterparty_port_id = %e.counterparty_port_id, + data.counterparty_channel_id = %e.counterparty_channel_id, + data.connection.state = ?e.connection.state, + data.connection.client_id = %e.connection.client_id, + data.connection.counterparty_client_id = %e.connection.counterparty_client_id, + data.connection.counterparty_connection_id = %e.connection.counterparty_connection_id, + data.version = %e.version, + "event" + ), + FullEvent::ChannelOpenConfirm(e) => info!( + event, + %chain_id, + data.port_id = %e.port_id, + data.channel_id = %e.channel_id, + data.counterparty_port_id = %e.counterparty_port_id, + data.counterparty_channel_id = %e.counterparty_channel_id, + data.connection.state = ?e.connection.state, + data.connection.client_id = %e.connection.client_id, + data.connection.counterparty_client_id = %e.connection.counterparty_client_id, + data.connection.counterparty_connection_id = %e.connection.counterparty_connection_id, + data.version = %e.version, + "event" + ), + FullEvent::ChannelCloseInit(e) => info!(event, "event"), + FullEvent::ChannelCloseConfirm(e) => info!(event, "event"), + FullEvent::PacketSend(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + FullEvent::PacketRecv(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + data.relayer_msg = %e.relayer_msg, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + FullEvent::IntentPacketRecv(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + data.market_maker_msg = %e.market_maker_msg, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + FullEvent::WriteAck(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + data.acknowledgement = %e.acknowledgement, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + FullEvent::PacketAck(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + data.acknowledgement = %e.acknowledgement, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + FullEvent::PacketTimeout(e) => info!( + event, + %chain_id, + data.packet_data = %e.packet_data, + + data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, + data.packet.source_channel.version = %e.packet.source_channel.version, + data.packet.source_channel = %e.packet.source_channel.connection.client_id, + data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + + data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, + data.packet.destination_channel.version = %e.packet.destination_channel.version, + data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + + data.packet.timeout_height = %e.packet.timeout_height, + data.packet.timeout_timestamp = %e.packet.timeout_timestamp, + "event" + ), + } +} diff --git a/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs b/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs index d663e9940f..600b66c44e 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs @@ -266,7 +266,7 @@ event! { // events for the union IBC specification, emitted by the cosmwasm contract implementation. - #[event(tag = "wasm-client_create")] + #[event(tag = "wasm-create_client")] UnionCreateClient { #[parse(u32::from_str)] client_id: u32, @@ -276,12 +276,12 @@ event! { // height: u64, }, - #[event(tag = "wasm-client_update")] + #[event(tag = "wasm-update_client")] UnionUpdateClient { #[parse(u32::from_str)] client_id: u32, #[parse(u64::from_str)] - height: u64, + counterparty_height: u64, }, #[event(tag = "wasm-connection_open_init")] @@ -385,7 +385,7 @@ event! { connection_id: u32, }, - #[event(tag = "wasm-send_packet")] + #[event(tag = "wasm-packet_send")] UnionSendPacket { #[parse(serde_json::from_str)] packet: ibc_solidity::Packet, diff --git a/voyager/plugins/event-source/cosmos-sdk/src/main.rs b/voyager/plugins/event-source/cosmos-sdk/src/main.rs index 987f18925e..9f0ea51380 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/main.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/main.rs @@ -273,44 +273,6 @@ impl Module { )) } - // async fn fetch_connection(&self, connection_id: ConnectionId) -> (ConnectionEnd, Height) { - // let inner = protos::ibc::core::connection::v1::query_client::QueryClient::connect( - // self.grpc_url.clone(), - // ) - // .await - // .unwrap() - // .connection(protos::ibc::core::connection::v1::QueryConnectionRequest { - // connection_id: connection_id.to_string(), - // }) - // .await - // .unwrap() - // .into_inner(); - - // ( - // inner.connection.unwrap().try_into().unwrap(), - // inner.proof_height.unwrap().into(), - // ) - // } - - // async fn fetch_client(&self, client_id: ClientId) -> (Vec, Height) { - // let inner = protos::ibc::core::client::v1::query_client::QueryClient::connect( - // self.grpc_url.clone(), - // ) - // .await - // .unwrap() - // .client_state(protos::ibc::core::client::v1::QueryClientStateRequest { - // client_id: client_id.to_string(), - // }) - // .await - // .unwrap() - // .into_inner(); - - // ( - // inner.client_state.unwrap().try_into().unwrap(), - // inner.proof_height.unwrap().into(), - // ) - // } - async fn latest_height(&self) -> Result { let commit_response = self.tm_client.commit(None).await?; @@ -1035,8 +997,6 @@ impl PluginServer for Module { })) } IbcEvent::UnionCreateClient(create_client) => { - dbg!(&create_client); - let client_info = voyager_client .client_info::(self.chain_id.clone(), create_client.client_id) .await?; @@ -1049,6 +1009,14 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::CreateClient { + client_id: create_client.client_id, + client_type: ClientType::new(create_client.client_type), + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1056,18 +1024,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::CreateClient { - client_id: create_client.client_id, - client_type: ClientType::new(create_client.client_type), - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionUpdateClient(update_client) => { - dbg!(&update_client); - let client_info = voyager_client .client_info::(self.chain_id.clone(), update_client.client_id) .await?; @@ -1080,6 +1040,15 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::UpdateClient { + client_id: update_client.client_id, + client_type: client_info.client_type.clone(), + height: update_client.counterparty_height, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info: client_info.clone(), @@ -1087,19 +1056,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::UpdateClient { - client_id: update_client.client_id, - client_type: client_info.client_type, - height: update_client.height, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionConnectionOpenInit(connection_open_init) => { - dbg!(&connection_open_init); - let client_info = voyager_client .client_info::( self.chain_id.clone(), @@ -1115,6 +1075,15 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ConnectionOpenInit { + client_id: connection_open_init.client_id, + connection_id: connection_open_init.connection_id, + counterparty_client_id: connection_open_init.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1122,20 +1091,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ConnectionOpenInit { - client_id: connection_open_init.client_id, - connection_id: connection_open_init.connection_id, - counterparty_client_id: connection_open_init - .counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionConnectionOpenTry(connection_open_try) => { - dbg!(&connection_open_try); - let client_info = voyager_client .client_info::( self.chain_id.clone(), @@ -1151,6 +1110,17 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ConnectionOpenTry { + connection_id: connection_open_try.connection_id, + counterparty_connection_id: connection_open_try + .counterparty_connection_id, + client_id: connection_open_try.client_id, + counterparty_client_id: connection_open_try.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1158,22 +1128,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ConnectionOpenTry { - connection_id: connection_open_try.connection_id, - counterparty_connection_id: connection_open_try - .counterparty_connection_id, - client_id: connection_open_try.client_id, - counterparty_client_id: connection_open_try - .counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionConnectionOpenAck(connection_open_ack) => { - dbg!(&connection_open_ack); - let client_info = voyager_client .client_info::( self.chain_id.clone(), @@ -1189,6 +1147,17 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ConnectionOpenAck { + connection_id: connection_open_ack.connection_id, + counterparty_connection_id: connection_open_ack + .counterparty_connection_id, + client_id: connection_open_ack.client_id, + counterparty_client_id: connection_open_ack.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1196,22 +1165,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ConnectionOpenAck { - connection_id: connection_open_ack.connection_id, - counterparty_connection_id: connection_open_ack - .counterparty_connection_id, - client_id: connection_open_ack.client_id, - counterparty_client_id: connection_open_ack - .counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionConnectionOpenConfirm(connection_open_confirm) => { - dbg!(&connection_open_confirm); - let client_info = voyager_client .client_info::( self.chain_id.clone(), @@ -1227,6 +1184,17 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ConnectionOpenConfirm { + connection_id: connection_open_confirm.connection_id, + counterparty_connection_id: connection_open_confirm + .counterparty_connection_id, + client_id: connection_open_confirm.client_id, + counterparty_client_id: connection_open_confirm.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1234,22 +1202,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ConnectionOpenConfirm { - connection_id: connection_open_confirm.connection_id, - counterparty_connection_id: connection_open_confirm - .counterparty_connection_id, - client_id: connection_open_confirm.client_id, - counterparty_client_id: connection_open_confirm - .counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionChannelOpenTry(channel_open_try) => { - dbg!(&channel_open_try); - let connection = voyager_client .query_ibc_state( self.chain_id.clone(), @@ -1274,6 +1230,20 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ChannelOpenTry { + port_id: channel_open_try.port_id.into_bytes().into(), + channel_id: channel_open_try.channel_id, + counterparty_port_id: channel_open_try + .counterparty_port_id + .into_encoding(), + counterparty_channel_id: channel_open_try.counterparty_channel_id, + connection, + version: channel_open_try.counterparty_version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1281,25 +1251,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ChannelOpenTry { - port_id: channel_open_try.port_id.into_bytes().into(), - channel_id: channel_open_try.channel_id, - counterparty_port_id: channel_open_try - .counterparty_port_id - .into_encoding(), - counterparty_channel_id: channel_open_try - .counterparty_channel_id, - connection, - version: channel_open_try.counterparty_version, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionChannelOpenConfirm(channel_open_confirm) => { - dbg!(&channel_open_confirm); - let channel = voyager_client .query_ibc_state( self.chain_id.clone(), @@ -1336,6 +1291,20 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::ChannelOpenConfirm { + port_id: channel_open_confirm.port_id.into_bytes().into(), + channel_id: channel_open_confirm.channel_id, + counterparty_port_id: channel_open_confirm + .counterparty_port_id + .into_encoding(), + counterparty_channel_id: channel_open_confirm.counterparty_channel_id, + connection, + version: channel.version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1343,25 +1312,10 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::ChannelOpenConfirm { - port_id: channel_open_confirm.port_id.into_bytes().into(), - channel_id: channel_open_confirm.channel_id, - counterparty_port_id: channel_open_confirm - .counterparty_port_id - .into_encoding(), - counterparty_channel_id: channel_open_confirm - .counterparty_channel_id, - connection, - version: channel.version, - } - .into(), - ), + event: into_value::(event), })) } IbcEvent::UnionSendPacket(send_packet) => { - dbg!(&send_packet); - let packet = send_packet.packet; let source_channel = voyager_client @@ -1403,6 +1357,33 @@ impl PluginServer for Module { ) .await?; + let event = ibc_union_spec::PacketSend { + packet_data: packet.data.into(), + packet: ibc_union_spec::PacketMetadata { + source_channel: ibc_union_spec::ChannelMetadata { + channel_id: packet.source_channel, + version: source_channel.version.clone(), + connection: ibc_union_spec::ConnectionMetadata { + client_id: source_connection.client_id, + connection_id: source_channel.connection_id, + }, + }, + destination_channel: ibc_union_spec::ChannelMetadata { + channel_id: packet.destination_channel, + version: source_channel.version, + connection: ibc_union_spec::ConnectionMetadata { + client_id: source_connection.counterparty_client_id, + connection_id: source_connection.counterparty_connection_id, + }, + }, + timeout_height: packet.timeout_height, + timeout_timestamp: packet.timeout_timestamp, + }, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -1410,33 +1391,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ibc_union_spec::PacketSend { - packet_data: packet.data.into(), - packet: ibc_union_spec::PacketMetadata { - source_channel: ibc_union_spec::ChannelMetadata { - channel_id: packet.source_channel, - version: source_channel.version.clone(), - connection: ibc_union_spec::ConnectionMetadata { - client_id: source_connection.client_id, - connection_id: source_channel.connection_id, - }, - }, - destination_channel: ibc_union_spec::ChannelMetadata { - channel_id: packet.destination_channel, - version: source_channel.version, - connection: ibc_union_spec::ConnectionMetadata { - client_id: source_connection.counterparty_client_id, - connection_id: source_connection - .counterparty_connection_id, - }, - }, - timeout_height: packet.timeout_height, - timeout_timestamp: packet.timeout_timestamp, - }, - } - .into(), - ), + event: into_value::(event), })) } } diff --git a/voyager/plugins/event-source/ethereum/Cargo.toml b/voyager/plugins/event-source/ethereum/Cargo.toml index 0dd082ea82..b833419ae3 100644 --- a/voyager/plugins/event-source/ethereum/Cargo.toml +++ b/voyager/plugins/event-source/ethereum/Cargo.toml @@ -10,7 +10,7 @@ chain-utils = { workspace = true } enumorph = { workspace = true } futures = { workspace = true } ibc-solidity = { workspace = true, features = ["serde", "rpc"] } -ibc-union-spec = { workspace = true } +ibc-union-spec = { workspace = true, features = ["tracing"] } jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } macros = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/voyager/plugins/event-source/ethereum/src/main.rs b/voyager/plugins/event-source/ethereum/src/main.rs index 2514230d49..dd3647a98e 100644 --- a/voyager/plugins/event-source/ethereum/src/main.rs +++ b/voyager/plugins/event-source/ethereum/src/main.rs @@ -280,6 +280,14 @@ impl PluginServer for Module { ) .await?; + let event = CreateClient { + client_id: raw_event.client_id, + client_type: client_info.client_type.clone(), + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info: client_info.clone(), @@ -287,13 +295,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - CreateClient { - client_id: raw_event.client_id, - client_type: client_info.client_type, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::RegisterClient(raw_event) => { @@ -314,6 +316,15 @@ impl PluginServer for Module { ) .await?; + let event = UpdateClient { + client_type: client_info.client_type.clone(), + client_id: raw_event.client_id, + height: raw_event.height, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info: client_info.clone(), @@ -321,14 +332,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - UpdateClient { - client_type: client_info.client_type, - client_id: raw_event.client_id, - height: raw_event.height, - } - .into(), - ), + event: into_value::(event), })) } @@ -345,6 +349,15 @@ impl PluginServer for Module { ) .await?; + let event = ConnectionOpenInit { + client_id: raw_event.client_id, + connection_id: raw_event.connection_id, + counterparty_client_id: raw_event.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -352,14 +365,7 @@ impl PluginServer for Module { tx_hash, ibc_spec_id: IbcUnion::ID, provable_height, - event: into_value::( - ConnectionOpenInit { - client_id: raw_event.client_id, - connection_id: raw_event.connection_id, - counterparty_client_id: raw_event.counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ConnectionOpenTry(raw_event) => { @@ -375,6 +381,16 @@ impl PluginServer for Module { ) .await?; + let event = ConnectionOpenTry { + client_id: raw_event.client_id, + connection_id: raw_event.connection_id, + counterparty_client_id: raw_event.counterparty_client_id, + counterparty_connection_id: raw_event.counterparty_connection_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -382,16 +398,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ConnectionOpenTry { - client_id: raw_event.client_id, - connection_id: raw_event.connection_id, - counterparty_client_id: raw_event.counterparty_client_id, - counterparty_connection_id: raw_event - .counterparty_connection_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ConnectionOpenAck(raw_event) => { @@ -407,6 +414,16 @@ impl PluginServer for Module { ) .await?; + let event = ConnectionOpenAck { + client_id: raw_event.client_id, + connection_id: raw_event.connection_id, + counterparty_client_id: raw_event.counterparty_client_id, + counterparty_connection_id: raw_event.counterparty_connection_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -414,16 +431,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ConnectionOpenAck { - client_id: raw_event.client_id, - connection_id: raw_event.connection_id, - counterparty_client_id: raw_event.counterparty_client_id, - counterparty_connection_id: raw_event - .counterparty_connection_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ConnectionOpenConfirm(raw_event) => { @@ -439,6 +447,16 @@ impl PluginServer for Module { ) .await?; + let event = ConnectionOpenConfirm { + client_id: raw_event.client_id, + connection_id: raw_event.connection_id, + counterparty_client_id: raw_event.counterparty_client_id, + counterparty_connection_id: raw_event.counterparty_client_id, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -446,15 +464,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ConnectionOpenConfirm { - client_id: raw_event.client_id, - connection_id: raw_event.connection_id, - counterparty_client_id: raw_event.counterparty_client_id, - counterparty_connection_id: raw_event.counterparty_client_id, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ChannelOpenInit(raw_event) => { @@ -494,6 +504,17 @@ impl PluginServer for Module { .state .ok_or_else(missing_state("connection must exist", None))?; + let event = ChannelOpenInit { + port_id: raw_event.port_id.into(), + channel_id, + counterparty_port_id: raw_event.counterparty_port_id.into(), + connection, + version: channel.version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -501,16 +522,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ChannelOpenInit { - port_id: raw_event.port_id.into(), - channel_id, - counterparty_port_id: raw_event.counterparty_port_id.into(), - connection, - version: channel.version, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ChannelOpenTry(raw_event) => { @@ -550,6 +562,18 @@ impl PluginServer for Module { .state .ok_or_else(missing_state("channel must exist", None))?; + let event = ChannelOpenTry { + port_id: raw_event.port_id.into(), + channel_id, + counterparty_port_id: raw_event.counterparty_port_id.into(), + counterparty_channel_id: raw_event.counterparty_channel_id, + connection, + version: channel.version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -557,17 +581,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ChannelOpenTry { - port_id: raw_event.port_id.into(), - channel_id, - counterparty_port_id: raw_event.counterparty_port_id.into(), - counterparty_channel_id: raw_event.counterparty_channel_id, - connection, - version: channel.version, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ChannelOpenAck(raw_event) => { @@ -607,6 +621,18 @@ impl PluginServer for Module { .state .ok_or_else(missing_state("channel must exist", None))?; + let event = ChannelOpenAck { + port_id: raw_event.port_id.into(), + channel_id, + counterparty_port_id: raw_event.counterparty_port_id.into(), + counterparty_channel_id: raw_event.counterparty_channel_id, + connection, + version: channel.version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -614,17 +640,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ChannelOpenAck { - port_id: raw_event.port_id.into(), - channel_id, - counterparty_port_id: raw_event.counterparty_port_id.into(), - counterparty_channel_id: raw_event.counterparty_channel_id, - connection, - version: channel.version, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::ChannelOpenConfirm(raw_event) => { @@ -664,6 +680,18 @@ impl PluginServer for Module { .state .ok_or_else(missing_state("channel must exist", None))?; + let event = ChannelOpenConfirm { + port_id: raw_event.port_id.into(), + channel_id, + counterparty_port_id: channel.counterparty_port_id.into(), + counterparty_channel_id: channel.counterparty_channel_id, + connection, + version: channel.version, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -671,17 +699,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - ChannelOpenConfirm { - port_id: raw_event.port_id.into(), - channel_id, - counterparty_port_id: channel.counterparty_port_id.into(), - counterparty_channel_id: channel.counterparty_channel_id, - connection, - version: channel.version, - } - .into(), - ), + event: into_value::(event), })) } @@ -706,6 +724,19 @@ impl PluginServer for Module { ) .await?; + let event = PacketSend { + packet_data: event.packet.data.to_vec().into(), + packet: PacketMetadata { + source_channel, + destination_channel, + timeout_height: event.packet.timeout_height, + timeout_timestamp: event.packet.timeout_timestamp, + }, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -713,18 +744,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - PacketSend { - packet_data: event.packet.data.to_vec().into(), - packet: PacketMetadata { - source_channel, - destination_channel, - timeout_height: event.packet.timeout_height, - timeout_timestamp: event.packet.timeout_timestamp, - }, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::PacketTimeout(event) => { @@ -741,6 +761,19 @@ impl PluginServer for Module { ) .await?; + let event = PacketTimeout { + packet: PacketMetadata { + source_channel, + destination_channel, + timeout_height: event.packet.timeout_height, + timeout_timestamp: event.packet.timeout_timestamp, + }, + packet_data: event.packet.data.into(), + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -748,18 +781,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - PacketTimeout { - packet: PacketMetadata { - source_channel, - destination_channel, - timeout_height: event.packet.timeout_height, - timeout_timestamp: event.packet.timeout_timestamp, - }, - packet_data: event.packet.data.into(), - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::PacketAck(event) => { @@ -776,6 +798,20 @@ impl PluginServer for Module { ) .await?; + let event = PacketAck { + packet: PacketMetadata { + source_channel, + destination_channel, + timeout_height: event.packet.timeout_height, + timeout_timestamp: event.packet.timeout_timestamp, + }, + packet_data: event.packet.data.into(), + acknowledgement: event.acknowledgement.into(), + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -783,19 +819,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - PacketAck { - packet: PacketMetadata { - source_channel, - destination_channel, - timeout_height: event.packet.timeout_height, - timeout_timestamp: event.packet.timeout_timestamp, - }, - packet_data: event.packet.data.into(), - acknowledgement: event.acknowledgement.into(), - } - .into(), - ), + event: into_value::(event), })) } // packet origin is the counterparty chain @@ -813,6 +837,20 @@ impl PluginServer for Module { ) .await?; + let event = WriteAck { + packet_data: event.packet.data.to_vec().into(), + acknowledgement: event.acknowledgement.to_vec().into(), + packet: PacketMetadata { + source_channel, + destination_channel, + timeout_height: event.packet.timeout_height, + timeout_timestamp: event.packet.timeout_timestamp, + }, + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -820,19 +858,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - WriteAck { - packet_data: event.packet.data.to_vec().into(), - acknowledgement: event.acknowledgement.to_vec().into(), - packet: PacketMetadata { - source_channel, - destination_channel, - timeout_height: event.packet.timeout_height, - timeout_timestamp: event.packet.timeout_timestamp, - }, - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::PacketRecv(event) => { @@ -849,6 +875,20 @@ impl PluginServer for Module { ) .await?; + let event = PacketRecv { + packet_data: event.packet.data.to_vec().into(), + packet: PacketMetadata { + source_channel, + destination_channel, + timeout_height: event.packet.timeout_height, + timeout_timestamp: event.packet.timeout_timestamp, + }, + relayer_msg: event.relayer_msg.into(), + } + .into(); + + ibc_union_spec::log_event(&event, &self.chain_id); + Ok(data(ChainEvent { chain_id: self.chain_id.clone(), client_info, @@ -856,19 +896,7 @@ impl PluginServer for Module { tx_hash, provable_height, ibc_spec_id: IbcUnion::ID, - event: into_value::( - PacketRecv { - packet_data: event.packet.data.to_vec().into(), - packet: PacketMetadata { - source_channel, - destination_channel, - timeout_height: event.packet.timeout_height, - timeout_timestamp: event.packet.timeout_timestamp, - }, - relayer_msg: event.relayer_msg.into(), - } - .into(), - ), + event: into_value::(event), })) } IbcEvents::IntentPacketRecv(_event) => { @@ -991,14 +1019,14 @@ impl PluginServer for Module { Ibc::IbcEvents::ChannelCloseConfirm( channel_close_confirm, ) => IbcEvents::ChannelCloseConfirm(channel_close_confirm), - Ibc::IbcEvents::PacketSend(send_packet) => { - IbcEvents::PacketSend(send_packet) + Ibc::IbcEvents::PacketSend(packet_send) => { + IbcEvents::PacketSend(packet_send) } - Ibc::IbcEvents::PacketRecv(recv_packet) => { - IbcEvents::PacketRecv(recv_packet) + Ibc::IbcEvents::PacketRecv(packet_recv) => { + IbcEvents::PacketRecv(packet_recv) } - Ibc::IbcEvents::IntentPacketRecv(recv_intent_packet) => { - IbcEvents::IntentPacketRecv(recv_intent_packet) + Ibc::IbcEvents::IntentPacketRecv(intent_packet_recv) => { + IbcEvents::IntentPacketRecv(intent_packet_recv) } Ibc::IbcEvents::WriteAck(write_acknowledgement) => { IbcEvents::WriteAck(write_acknowledgement) diff --git a/voyager/plugins/transaction/cosmos-sdk/src/main.rs b/voyager/plugins/transaction/cosmos-sdk/src/main.rs index d56ff5fbeb..f3081c3267 100644 --- a/voyager/plugins/transaction/cosmos-sdk/src/main.rs +++ b/voyager/plugins/transaction/cosmos-sdk/src/main.rs @@ -16,7 +16,7 @@ use jsonrpsee::{ use prost::Message; use serde::{Deserialize, Serialize}; use sha2::Digest; -use tracing::{debug, error, info, instrument, warn}; +use tracing::{debug, error, info, instrument, trace, warn}; use unionlabs::{ self, bech32::Bech32, @@ -175,7 +175,7 @@ impl Module { .with(|signer| { let msgs = msgs.clone(); - dbg!(&msgs); + trace!(?msgs); async move { // TODO: Figure out a way to thread this value through @@ -355,8 +355,6 @@ impl Module { auth_info.fee = self.gas_config.mk_fee(simulation_gas_info.gas_used); - // dbg!(&auth_info.fee); - info!( fee = %auth_info.fee.amount[0].amount, gas_multiplier = %self.gas_config.gas_multiplier, @@ -474,10 +472,11 @@ impl Module { "cosmos transaction failed" ); - if let Some(union_ibc_error) = tx.tx_result.log.split(": ").find_map(|x| { - // dbg!(x); - union_ibc::ContractErrorKind::parse_from_error_message(x) - }) { + if let Some(union_ibc_error) = + tx.tx_result.log.split(": ").find_map(|x| { + union_ibc::ContractErrorKind::parse_from_error_message(x) + }) + { break Err(BroadcastTxCommitError::UnionIbcError(union_ibc_error)); } else { break Err(BroadcastTxCommitError::Tx(error)); @@ -1004,10 +1003,26 @@ fn process_msgs( .unwrap(), funds: vec![], }), - ibc_union_spec::Datagram::ChannelOpenInit(_msg_channel_open_init) => todo!(), - ibc_union_spec::Datagram::ChannelOpenTry(msg_channel_open_try) => { - dbg!(&msg_channel_open_try); + ibc_union_spec::Datagram::ChannelOpenInit(msg_channel_open_init) => { + let channel_open_init = union_ibc_msg::msg::ExecuteMsg::ChannelOpenInit( + union_ibc_msg::msg::MsgChannelOpenInit { + port_id: String::from_utf8(msg_channel_open_init.port_id.to_vec()) + .unwrap(), + relayer: signer.to_string(), + counterparty_port_id: msg_channel_open_init.counterparty_port_id, + connection_id: msg_channel_open_init.connection_id, + version: msg_channel_open_init.version, + }, + ); + mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { + sender: signer.to_string(), + contract: ibc_host_contract_address.to_string(), + msg: serde_json::to_vec(&channel_open_init).unwrap(), + funds: vec![], + }) + } + ibc_union_spec::Datagram::ChannelOpenTry(msg_channel_open_try) => { let channel_open_try = union_ibc_msg::msg::ExecuteMsg::ChannelOpenTry( union_ibc_msg::msg::MsgChannelOpenTry { port_id: String::from_utf8(msg_channel_open_try.port_id.to_vec()) @@ -1020,8 +1035,6 @@ fn process_msgs( }, ); - dbg!(&channel_open_try); - mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { sender: signer.to_string(), contract: ibc_host_contract_address.to_string(), @@ -1029,10 +1042,27 @@ fn process_msgs( funds: vec![], }) } - ibc_union_spec::Datagram::ChannelOpenAck(_msg_channel_open_ack) => todo!(), - ibc_union_spec::Datagram::ChannelOpenConfirm(msg_channel_open_confirm) => { - dbg!(&msg_channel_open_confirm); + ibc_union_spec::Datagram::ChannelOpenAck(msg_channel_open_ack) => { + let channel_open_ack = union_ibc_msg::msg::ExecuteMsg::ChannelOpenAck( + union_ibc_msg::msg::MsgChannelOpenAck { + channel_id: msg_channel_open_ack.channel_id, + counterparty_version: msg_channel_open_ack.counterparty_version, + counterparty_channel_id: msg_channel_open_ack + .counterparty_channel_id, + proof_try: msg_channel_open_ack.proof_try, + proof_height: msg_channel_open_ack.proof_height, + relayer: signer.to_string(), + }, + ); + mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { + sender: signer.to_string(), + contract: ibc_host_contract_address.to_string(), + msg: serde_json::to_vec(&channel_open_ack).unwrap(), + funds: vec![], + }) + } + ibc_union_spec::Datagram::ChannelOpenConfirm(msg_channel_open_confirm) => { let channel_open_confirm = union_ibc_msg::msg::ExecuteMsg::ChannelOpenConfirm( union_ibc_msg::msg::MsgChannelOpenConfirm { @@ -1043,8 +1073,6 @@ fn process_msgs( }, ); - dbg!(&channel_open_confirm); - mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { sender: signer.to_string(), contract: ibc_host_contract_address.to_string(), @@ -1057,8 +1085,6 @@ fn process_msgs( todo!() } ibc_union_spec::Datagram::PacketRecv(msg_packet_recv) => { - dbg!(&msg_packet_recv); - let packet_recv = union_ibc_msg::msg::ExecuteMsg::PacketRecv( union_ibc_msg::msg::MsgPacketRecv { packets: msg_packet_recv.packets, @@ -1069,8 +1095,6 @@ fn process_msgs( }, ); - dbg!(&packet_recv); - mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { sender: signer.to_string(), contract: ibc_host_contract_address.to_string(), @@ -1079,8 +1103,6 @@ fn process_msgs( }) } ibc_union_spec::Datagram::PacketAcknowledgement(msg_packet_acknowledgement) => { - dbg!(&msg_packet_acknowledgement); - let packet_recv = union_ibc_msg::msg::ExecuteMsg::PacketAck( union_ibc_msg::msg::MsgPacketAcknowledgement { packets: msg_packet_acknowledgement.packets, @@ -1091,8 +1113,6 @@ fn process_msgs( }, ); - dbg!(&packet_recv); - mk_any(&protos::cosmwasm::wasm::v1::MsgExecuteContract { sender: signer.to_string(), contract: ibc_host_contract_address.to_string(), diff --git a/voyager/plugins/transaction/ethereum/src/main.rs b/voyager/plugins/transaction/ethereum/src/main.rs index 19f677d236..1aab54fb0f 100644 --- a/voyager/plugins/transaction/ethereum/src/main.rs +++ b/voyager/plugins/transaction/ethereum/src/main.rs @@ -21,7 +21,7 @@ use jsonrpsee::{ Extensions, }; use serde::{Deserialize, Serialize}; -use tracing::{error, info, info_span, instrument, warn, Instrument}; +use tracing::{error, info, info_span, instrument, trace, warn, Instrument}; use unionlabs::{ hash::{H160, H256}, ErrorReporter, @@ -182,6 +182,8 @@ impl Module { pub enum TxSubmitError { #[error(transparent)] Error(#[from] Error), + #[error("error estimating gas")] + Estimate(#[source] Error), #[error("error waiting for transaction")] PendingTransactionError(#[from] PendingTransactionError), #[error("out of gas")] @@ -382,7 +384,19 @@ impl Module { info!("submitting evm tx"); - match call.send().await { + let gas_estimate = call.estimate_gas().await.map_err(TxSubmitError::Estimate)?; + // .map_err(|e| { + // ErrorObject::owned( + // -1, + // format!("error estimating gas: {}", ErrorReporter(e), None::<()>), + // ) + // })?; + + let gas_to_use = gas_estimate + (gas_estimate / 2); + + info!(gas_estimate, gas_to_use, "gas estimatation successful"); + + match call.gas(gas_to_use).send().await { Ok(ok) => { let tx_hash = ::from(*ok.tx_hash()); async move { @@ -496,7 +510,7 @@ fn process_msgs>( msgs: Vec, relayer: H160, ) -> RpcResult)>> { - dbg!(&msgs); + trace!(?msgs); msgs.clone() .into_iter() diff --git a/voyager/voyager.nix b/voyager/voyager.nix index 44ed4dc73f..901783b0a0 100644 --- a/voyager/voyager.nix +++ b/voyager/voyager.nix @@ -90,18 +90,6 @@ default = self.packages.${pkgs.system}.voyager; }; modules = mkOption { - # The configuration design is breaking quite often, would be a waste - # of effort to fix the type for now. - # type = types.submodule { - # options = { - # enabled = mkOption { - # type = types.bool; - # default = true; - # }; - # path = mkOption { type = types.path; }; - # config = mkOption { type = types.attrs; }; - # }; - # }; type = types.attrs; }; plugins = mkOption {