Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: axon ack #344

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/relayer/src/chain/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,19 +755,22 @@ impl ChainEndpoint for AxonChain {
) -> Result<Vec<Sequence>, Error> {
let mut sequences: Vec<Sequence> = vec![];
for seq in request.packet_ack_sequences {
// The packet hasn't been acknowledged if packet commitment is
// found. (Packet commitment is deleted after the packet is
// acknowledged.)
let (_, found) = self
.rt
.block_on(
self.contract()?
.get_hashed_packet_acknowledgement_commitment(
.get_hashed_packet_commitment(
request.port_id.to_string(),
request.channel_id.to_string(),
seq.into(),
)
.call(),
)
.map_err(convert_err)?;
if !found {
if found {
sequences.push(seq);
}
}
Expand Down
7 changes: 5 additions & 2 deletions crates/relayer/src/chain/ckb4ibc/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Ckb4IbcEventMonitor {
true
})
.map(
|(((packet, content), tx), block_number)| match packet.status {
|(((packet, _content), tx), block_number)| match packet.status {
PacketStatus::Send => {
info!(
"🫡 {} received SendPacket({}) event, from {}/{} to {}/{}",
Expand Down Expand Up @@ -392,8 +392,11 @@ impl Ckb4IbcEventMonitor {
);
IbcEventWithHeight {
event: IbcEvent::WriteAcknowledgement(WriteAcknowledgement {
ack: packet
.ack
.clone()
.expect("write ack packet should have ack"),
packet: convert_packet(packet),
ack: content,
}),
height: Height::from_noncosmos_height(block_number),
tx_hash: tx.into(),
Expand Down
19 changes: 17 additions & 2 deletions tools/ibc-test/src/tests/ibc/sudt_erc20_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,26 @@ impl BinaryConnectionTest for SudtErc20TransferTest {
ckb_sender_key,
)
.unwrap();
let axon_events = chains.handle_b.subscribe().unwrap();
send_transaction(&ckb_url, tx).unwrap();
log::info!("Received SUDT");

// Sleep some time so the ack can be written to axon.
std::thread::sleep(Duration::from_secs(60));
log::info!("check ack on axon");
loop {
let batch = axon_events.recv().unwrap();
if (*batch)
.as_ref()
.unwrap()
.events
.iter()
// Use string comparison instead of enum matching because
// relayer_types is not a direct dep.
.any(|e| e.event.event_type().as_str() == "acknowledge_packet")
{
break;
}
}
log::info!("checked ack on axon");

Ok(())
}
Expand Down
Loading