Skip to content

Backport bug fixes from upstream. Wrong seq encoding #72

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

Open
wants to merge 1 commit into
base: v0.48.1-octopus-nearibc
Choose a base branch
from
Open
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
13 changes: 1 addition & 12 deletions ibc-core/ics04-channel/src/handler/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,12 @@ where
let seq_recv_path_on_b =
SeqRecvPath::new(&msg.packet.port_id_on_b, &msg.packet.chan_id_on_b);

// let mut value = Vec::new();
// u64::from(msg.packet.seq_on_a)
// .encode(&mut value)
// .map_err(|_| PacketError::CannotEncodeSequence {
// sequence: msg.packet.seq_on_a,
// })?;

// Note: We expect the return to be a u64 encoded in big-endian. Refer to ibc-go:
// https://github.com/cosmos/ibc-go/blob/25767f6bdb5bab2c2a116b41d92d753c93e18121/modules/core/04-channel/client/utils/utils.go#L191
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(
Expand Down
10 changes: 1 addition & 9 deletions ibc-core/ics04-channel/src/handler/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use ibc_core_host::types::path::{
use ibc_core_host::ValidationContext;
use ibc_primitives::prelude::*;
use ibc_primitives::proto::Protobuf;
use prost::Message;

pub fn validate<Ctx>(ctx_a: &Ctx, msg: &MsgTimeoutOnClose) -> Result<(), ContextError>
where
Expand Down Expand Up @@ -135,19 +134,12 @@ where
}
let seq_recv_path_on_b = SeqRecvPath::new(&packet.port_id_on_b, &packet.chan_id_on_b);

let mut value = Vec::new();
u64::from(packet.seq_on_a).encode(&mut value).map_err(|_| {
PacketError::CannotEncodeSequence {
sequence: packet.seq_on_a,
}
})?;

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,
packet.seq_on_a.to_vec(),
)
} else {
let receipt_path_on_b = ReceiptPath::new(
Expand Down
5 changes: 5 additions & 0 deletions ibc-core/ics24-host/types/src/identifiers/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ impl Sequence {
pub fn increment(&self) -> Sequence {
Sequence(self.0 + 1)
}

/// Encodes the sequence number into a byte array in big endian.
pub fn to_vec(&self) -> Vec<u8> {
self.0.to_be_bytes().to_vec()
}
}

impl From<u64> for Sequence {
Expand Down