diff --git a/.changelog/unreleased/bug-fixes/1004-fix-packet-sequence-encoding.md b/.changelog/unreleased/bug-fixes/1004-fix-packet-sequence-encoding.md new file mode 100644 index 000000000..e6e8f84a4 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/1004-fix-packet-sequence-encoding.md @@ -0,0 +1,2 @@ +- Encode packet sequence into a big endian bytes. + ([\#1004](https://github.com/cosmos/ibc-rs/pull/1004)) \ No newline at end of file diff --git a/ibc-core/ics04-channel/src/handler/timeout.rs b/ibc-core/ics04-channel/src/handler/timeout.rs index 23c7da13d..0cfed7c03 100644 --- a/ibc-core/ics04-channel/src/handler/timeout.rs +++ b/ibc-core/ics04-channel/src/handler/timeout.rs @@ -229,14 +229,13 @@ where } let seq_recv_path_on_b = SeqRecvPath::new(&msg.packet.port_id_on_b, &msg.packet.chan_id_on_b); - let value = u64::from(msg.packet.seq_on_a).to_be_bytes().to_vec(); client_state_of_b_on_a.verify_membership( conn_end_on_a.counterparty().prefix(), &msg.proof_unreceived_on_b, consensus_state_of_b_on_a.root(), Path::SeqRecv(seq_recv_path_on_b), - value, + msg.packet.seq_on_a.to_vec(), ) } else { let receipt_path_on_b = ReceiptPath::new( diff --git a/ibc-core/ics24-host/types/src/identifiers/sequence.rs b/ibc-core/ics24-host/types/src/identifiers/sequence.rs index ece48903b..7919ba56e 100644 --- a/ibc-core/ics24-host/types/src/identifiers/sequence.rs +++ b/ibc-core/ics24-host/types/src/identifiers/sequence.rs @@ -1,5 +1,4 @@ use ibc_primitives::prelude::*; -use ibc_primitives::ToVec; use crate::error::IdentifierError; @@ -50,10 +49,9 @@ impl Sequence { Sequence(self.0 + 1) } - /// Encodes the sequence number into a `Vec` using - /// `prost::Message::encode_to_vec`. + /// Encodes the sequence number into a byte array in big endian. pub fn to_vec(&self) -> Vec { - self.0.to_vec() + self.0.to_be_bytes().to_vec() } }