Skip to content

Commit

Permalink
fix(ucs01-relay): don't emit success attribute for ucs01-relay on ack
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo committed Oct 12, 2023
1 parent 05be964 commit 3dd76fd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 48 deletions.
23 changes: 12 additions & 11 deletions cosmwasm/ucs01-relay-api/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,22 @@ pub trait TransferProtocol {
// https://github.com/cosmos/ibc-go/blob/5ca37ef6e56a98683cf2b3b1570619dc9b322977/modules/apps/transfer/ibc_module.go#L261
let ack = Into::<GenericAck>::into(Self::Ack::try_from(raw_ack.clone().into())?);
let (ack_msgs, ack_attr) = match ack {
Ok(value) => (
self.send_tokens_success(packet.sender(), packet.receiver(), packet.tokens())?,
attr("success", value.to_string()),
),
Ok(value) => {
let value_string = value.to_string();
(
self.send_tokens_success(packet.sender(), packet.receiver(), packet.tokens())?,
(!value_string.is_empty()).then_some(("success", value_string)),
)
}
Err(error) => (
self.send_tokens_failure(packet.sender(), packet.receiver(), packet.tokens())?,
attr("error", error.to_string()),
Some(("error", error.to_string())),
),
};

let memo = Into::<String>::into(packet.extension().clone());
let packet_event = if memo.is_empty() {
Event::new(PACKET_EVENT)
} else {
Event::new(PACKET_EVENT).add_attribute("memo", &memo)
let packet_event = {
let memo = Into::<String>::into(packet.extension().clone());
Event::new(PACKET_EVENT).add_attributes((!memo.is_empty()).then_some(("memo", &memo)))
};

Ok(IbcBasicResponse::new()
Expand All @@ -182,7 +183,7 @@ pub trait TransferProtocol {
|TransferToken { denom, amount }| (format!("denom:{}", denom), amount),
)),
)
.add_event(Event::new(PACKET_EVENT).add_attributes([ack_attr]))
.add_event(Event::new(PACKET_EVENT).add_attributes(ack_attr))
.add_messages(ack_msgs))
}

Expand Down
79 changes: 42 additions & 37 deletions voyager/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,16 @@ impl<Q: Queue> Voyager<Q> {
}),
})
}
IbcEvent::AcknowledgePacket(_) => todo!(),
IbcEvent::AcknowledgePacket(ack_packet) => {
LcMsg::<EthereumMinimal>::Event(Identified {
chain_id: event.chain_id,
data: Event::Ibc(crate::msg::event::IbcEvent {
block_hash: event.block_hash,
height: event.height,
event: IbcEvent::AcknowledgePacket(ack_packet),
}),
})
}
IbcEvent::TimeoutPacket(_) => todo!(),
IbcEvent::WriteAcknowledgement(write_ack) => {
LcMsg::<EthereumMinimal>::Event(Identified {
Expand Down Expand Up @@ -1368,42 +1377,38 @@ where
vec![]
}

IbcEvent::RecvPacket(_packet) => {
//
// [RelayerMsg::Sequence(
// [
// RelayerMsg::Lc(AnyLcMsg::from(LcMsg::<L>::Wait(Identified {
// chain_id: l.chain().chain_id(),
// data: Wait::Block(WaitForBlock(ibc_event.height.increment())),
// }))),
// RelayerMsg::Aggregate {
// data: [].into(),
// queue: [RelayerMsg::Lc(AnyLcMsg::from(LcMsg::Fetch(
// Identified::new(
// l.chain().chain_id(),
// Fetch::ConnectionEnd(FetchConnectionEnd {
// at: ibc_event.height,
// connection_id: packet.connection_id.clone(),
// }),
// ),
// )))]
// .into(),
// receiver: AggregateReceiver::from(Identified::new(
// l.chain().chain_id(),
// Aggregate::PacketUpdateClient(AggregatePacketUpdateClient {
// update_to: ibc_event.height.increment(),
// event_height: ibc_event.height,
// block_hash: ibc_event.block_hash,
// packet_event: PacketEvent::Recv(packet),
// }),
// )),
// },
// ]
// .into(),
// )]
// .into()
[].into()
}
IbcEvent::RecvPacket(packet) => [RelayerMsg::Sequence(
[
RelayerMsg::Lc(AnyLcMsg::from(LcMsg::<L>::Wait(Identified {
chain_id: l.chain().chain_id(),
data: Wait::Block(WaitForBlock(ibc_event.height.increment())),
}))),
RelayerMsg::Aggregate {
data: [].into(),
queue: [RelayerMsg::Lc(AnyLcMsg::from(LcMsg::Fetch(
Identified::new(
l.chain().chain_id(),
Fetch::ConnectionEnd(FetchConnectionEnd {
at: ibc_event.height,
connection_id: packet.connection_id.clone(),
}),
),
)))]
.into(),
receiver: AggregateReceiver::from(Identified::new(
l.chain().chain_id(),
Aggregate::PacketUpdateClient(AggregatePacketUpdateClient {
update_to: ibc_event.height.increment(),
event_height: ibc_event.height,
block_hash: ibc_event.block_hash,
packet_event: PacketEvent::Recv(packet),
}),
)),
},
]
.into(),
)]
.into(),
IbcEvent::SendPacket(packet) => [RelayerMsg::Sequence(
[
RelayerMsg::Lc(AnyLcMsg::from(LcMsg::<L>::Wait(Identified {
Expand Down

0 comments on commit 3dd76fd

Please sign in to comment.