Skip to content

Commit

Permalink
Voyager cleanup more (#3486)
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo authored Jan 11, 2025
2 parents 1f5b667 + b01e47d commit e2966f5
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 365 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions voyager/lens-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"client": [
{
"enabled": true,
"path": "./target/debug/voyager-client-module-state-lens-evm",
"path": "./target/debug/voyager-client-module-state-lens-ics23-mpt",
"info": {
"client_type": "state-lens/evm",
"consensus_type": "ethereum",
Expand Down Expand Up @@ -208,7 +208,7 @@
"client_bootstrap": [
{
"enabled": true,
"path": "./target/debug/voyager-client-bootstrap-module-state-lens-evm",
"path": "./target/debug/voyager-client-bootstrap-module-state-lens-ics23-mpt",
"info": {
"chain_id": "32382",
"client_type": "state-lens/evm"
Expand Down
2 changes: 1 addition & 1 deletion voyager/modules/client-bootstrap/state-lens/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
edition = "2021"
name = "voyager-client-bootstrap-module-state-lens-evm"
name = "voyager-client-bootstrap-module-state-lens-ics23-mpt"
version = "0.1.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion voyager/modules/client/state-lens/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
edition = "2021"
name = "voyager-client-module-state-lens-evm"
name = "voyager-client-module-state-lens-ics23-mpt"
version = "0.1.0"

[dependencies]
Expand Down
52 changes: 8 additions & 44 deletions voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,49 +406,13 @@ event! {
acknowledgement: Bytes,
},

// #[event(tag = "acknowledge_packet", deprecated("packet_connection"))]
// AcknowledgePacket {
// #[parse(u64::from_str)]
// packet_timeout_height: Height,
// #[parse(u64::from_str)]
// packet_timeout_timestamp: u64,
// #[parse(NonZeroU64::from_str)]
// packet_sequence: NonZeroU64,
// #[parse(String::from_str)]
// packet_src_port: String,
// #[parse(u32::from_str)]
// packet_src_channel: u32,
// #[parse(String::from_str)]
// packet_dst_port: String,
// #[parse(u32::from_str)]
// packet_dst_channel: u32,
// #[parse(Order::from_str)]
// packet_channel_ordering: Order,
// #[parse(u32::from_str)]
// connection_id: u32,
// },

// #[event(tag = "timeout_packet")]
// TimeoutPacket {
// #[parse(u64::from_str)]
// packet_timeout_height: Height,
// #[parse(u64::from_str)]
// packet_timeout_timestamp: u64,
// #[parse(NonZeroU64::from_str)]
// packet_sequence: NonZeroU64,
// #[parse(String::from_str)]
// packet_src_port: String,
// #[parse(u32::from_str)]
// packet_src_channel: u32,
// #[parse(String::from_str)]
// packet_dst_port: String,
// #[parse(u32::from_str)]
// packet_dst_channel: u32,
// #[parse(Order::from_str)]
// packet_channel_ordering: Order,
// #[parse(u32::from_str)]
// connection_id: u32,
// },
#[event(tag = "wasm-write_ack")]
UnionWriteAck {
#[parse(serde_json::from_str)]
packet: ibc_solidity::Packet,
#[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
acknowledgement: Bytes,
},
}
}

Expand Down Expand Up @@ -486,10 +450,10 @@ impl IbcEvent {
IbcEvent::UnionChannelOpenTry(_) => "channel_open_try",
IbcEvent::UnionChannelOpenAck(_) => "channel_open_ack",
IbcEvent::UnionChannelOpenConfirm(_) => "channel_open_confirm",
// IbcEvent::UnionWriteAcknowledgement(_) => "write_acknowledgement",
IbcEvent::UnionRecvPacket(_) => "recv_packet",
IbcEvent::UnionSendPacket(_) => "send_packet",
IbcEvent::UnionAcknowledgePacket(_) => "acknowledge_packet",
IbcEvent::UnionWriteAck(_) => "write_ack",
// IbcEvent::UnionTimeoutPacket(_) => "timeout_packet",
}
}
Expand Down
100 changes: 97 additions & 3 deletions voyager/plugins/event-source/cosmos-sdk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,10 +1600,49 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {
IbcEvent::UnionRecvPacket(recv_packet) => {
let packet = recv_packet.packet;

let source_channel = voyager_client
let destination_channel = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ChannelPath {
channel_id: packet.destination_channel,
},
)
.await?
.state
.unwrap();

let destination_connection = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ConnectionPath {
connection_id: destination_channel.connection_id,
},
)
.await?
.state
.unwrap();

let client_info = voyager_client
.client_info::<IbcUnion>(
self.chain_id.clone(),
destination_connection.client_id,
)
.await?;

let client_meta = voyager_client
.client_meta::<IbcUnion>(
self.chain_id.clone(),
height.into(),
destination_connection.client_id,
)
.await?;

let source_channel = voyager_client
.query_ibc_state(
client_meta.chain_id.clone(),
QueryHeight::Latest,
ibc_union_spec::ChannelPath {
channel_id: packet.source_channel,
},
Expand All @@ -1612,6 +1651,49 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {
.state
.unwrap();

let event = ibc_union_spec::PacketRecv {
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: destination_connection.counterparty_client_id,
connection_id: destination_connection
.counterparty_connection_id,
},
},
destination_channel: ibc_union_spec::ChannelMetadata {
channel_id: packet.destination_channel,
version: destination_channel.version.clone(),

connection: ibc_union_spec::ConnectionMetadata {
client_id: destination_connection.client_id,
connection_id: destination_channel.connection_id,
},
},
timeout_height: packet.timeout_height,
timeout_timestamp: packet.timeout_timestamp,
},
relayer_msg: recv_packet.relayer_msg,
}
.into();

ibc_union_spec::log_event(&event, &self.chain_id);

Ok(data(ChainEvent {
chain_id: self.chain_id.clone(),
client_info,
counterparty_chain_id: client_meta.chain_id,
tx_hash,
provable_height,
ibc_spec_id: IbcUnion::ID,
event: into_value::<ibc_union_spec::FullEvent>(event),
}))
}
IbcEvent::UnionWriteAck(write_ack) => {
let packet = write_ack.packet;

let destination_channel = voyager_client
.query_ibc_state(
self.chain_id.clone(),
Expand Down Expand Up @@ -1651,7 +1733,19 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {
)
.await?;

let event = ibc_union_spec::PacketRecv {
let source_channel = voyager_client
.query_ibc_state(
client_meta.chain_id.clone(),
QueryHeight::Latest,
ibc_union_spec::ChannelPath {
channel_id: packet.source_channel,
},
)
.await?
.state
.unwrap();

let event = ibc_union_spec::WriteAck {
packet_data: packet.data.into(),
packet: ibc_union_spec::PacketMetadata {
source_channel: ibc_union_spec::ChannelMetadata {
Expand All @@ -1675,7 +1769,7 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {
timeout_height: packet.timeout_height,
timeout_timestamp: packet.timeout_timestamp,
},
relayer_msg: recv_packet.relayer_msg,
acknowledgement: write_ack.acknowledgement,
}
.into();

Expand Down
Loading

0 comments on commit e2966f5

Please sign in to comment.