From a847821857dec979c0169719a578b451201cad33 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 19:02:03 +0100 Subject: [PATCH 01/10] ibc-proto v0.42.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e3efe6af3..cd22b6d8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,7 +93,7 @@ ibc-client-wasm-types = { version = "0.50.0", path = "./ibc-clients/ics08- ibc-app-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics20-transfer/types", default-features = false } ibc-app-nft-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics721-nft-transfer/types", default-features = false } -ibc-proto = { version = "0.41.0", default-features = false } +ibc-proto = { version = "0.42.1", default-features = false } # cosmos dependencies tendermint = { version = "0.34.0", default-features = false } From b787a0f859068eb80a7119c13373bb3580eaac2b Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:12:27 +0100 Subject: [PATCH 02/10] handle new data fields --- ibc-core/ics04-channel/types/src/channel.rs | 7 +++++++ ibc-core/ics04-channel/types/src/error.rs | 2 ++ .../ics04-channel/types/src/msgs/chan_close_confirm.rs | 5 +++++ ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/ibc-core/ics04-channel/types/src/channel.rs b/ibc-core/ics04-channel/types/src/channel.rs index 20c3957ff..81d4fee84 100644 --- a/ibc-core/ics04-channel/types/src/channel.rs +++ b/ibc-core/ics04-channel/types/src/channel.rs @@ -52,12 +52,17 @@ impl TryFrom for IdentifiedChannelEnd { type Error = ChannelError; fn try_from(value: RawIdentifiedChannel) -> Result { + if value.upgrade_sequence != 0 { + return Err(ChannelError::UnsupportedChannelUpgradeSequence); + } + let raw_channel_end = RawChannel { state: value.state, ordering: value.ordering, counterparty: value.counterparty, connection_hops: value.connection_hops, version: value.version, + upgrade_sequence: value.upgrade_sequence, }; Ok(IdentifiedChannelEnd { @@ -83,6 +88,7 @@ impl From for RawIdentifiedChannel { version: value.channel_end.version.to_string(), port_id: value.port_id.to_string(), channel_id: value.channel_id.to_string(), + upgrade_sequence: 0, } } } @@ -161,6 +167,7 @@ impl From for RawChannel { .map(|v| v.as_str().to_string()) .collect(), version: value.version.to_string(), + upgrade_sequence: 0, } } } diff --git a/ibc-core/ics04-channel/types/src/error.rs b/ibc-core/ics04-channel/types/src/error.rs index 652ad0878..9fb77c7c0 100644 --- a/ibc-core/ics04-channel/types/src/error.rs +++ b/ibc-core/ics04-channel/types/src/error.rs @@ -33,6 +33,8 @@ pub enum ChannelError { NonUtf8PacketData, /// missing counterparty MissingCounterparty, + /// unsupported channel upgrade sequence + UnsupportedChannelUpgradeSequence, /// version not supported: expected `{expected}`, actual `{actual}` VersionNotSupported { expected: Version, actual: Version }, /// missing channel end diff --git a/ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs b/ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs index c60d3bf5e..c533fc59c 100644 --- a/ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs +++ b/ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs @@ -35,6 +35,10 @@ impl TryFrom for MsgChannelCloseConfirm { type Error = ChannelError; fn try_from(raw_msg: RawMsgChannelCloseConfirm) -> Result { + if raw_msg.counterparty_upgrade_sequence != 0 { + return Err(ChannelError::UnsupportedChannelUpgradeSequence); + } + Ok(MsgChannelCloseConfirm { port_id_on_b: raw_msg.port_id.parse()?, chan_id_on_b: raw_msg.channel_id.parse()?, @@ -59,6 +63,7 @@ impl From for RawMsgChannelCloseConfirm { proof_init: domain_msg.proof_chan_end_on_a.clone().into(), proof_height: Some(domain_msg.proof_height_on_a.into()), signer: domain_msg.signer.to_string(), + counterparty_upgrade_sequence: 0, } } } diff --git a/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs b/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs index 95cdb826d..8d2608b79 100644 --- a/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs +++ b/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs @@ -6,6 +6,7 @@ use ibc_primitives::Signer; use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose; use ibc_proto::Protobuf; +use crate::error::ChannelError; use crate::error::PacketError; use crate::packet::Packet; @@ -39,6 +40,12 @@ impl TryFrom for MsgTimeoutOnClose { return Err(PacketError::ZeroPacketSequence); } + if raw_msg.counterparty_upgrade_sequence != 0 { + return Err(PacketError::Channel( + ChannelError::UnsupportedChannelUpgradeSequence, + )); + } + Ok(MsgTimeoutOnClose { packet: raw_msg .packet @@ -71,6 +78,7 @@ impl From for RawMsgTimeoutOnClose { proof_height: Some(domain_msg.proof_height_on_b.into()), next_sequence_recv: domain_msg.next_seq_recv_on_b.into(), signer: domain_msg.signer.to_string(), + counterparty_upgrade_sequence: 0, } } } From 87cd3a63fc8dff6912a678d947ccb48a6fa28fb1 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:13:04 +0100 Subject: [PATCH 03/10] impl new service methods --- ibc-query/src/core/channel/service.rs | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ibc-query/src/core/channel/service.rs b/ibc-query/src/core/channel/service.rs index 7367caa48..05d64428b 100644 --- a/ibc-query/src/core/channel/service.rs +++ b/ibc-query/src/core/channel/service.rs @@ -8,7 +8,8 @@ use ibc_proto::google::protobuf::Any; use ibc_proto::ibc::core::channel::v1::query_server::Query as ChannelQuery; use ibc_proto::ibc::core::channel::v1::{ QueryChannelClientStateRequest, QueryChannelClientStateResponse, - QueryChannelConsensusStateRequest, QueryChannelConsensusStateResponse, QueryChannelRequest, + QueryChannelConsensusStateRequest, QueryChannelConsensusStateResponse, + QueryChannelParamsRequest, QueryChannelParamsResponse, QueryChannelRequest, QueryChannelResponse, QueryChannelsRequest, QueryChannelsResponse, QueryConnectionChannelsRequest, QueryConnectionChannelsResponse, QueryNextSequenceReceiveRequest, QueryNextSequenceReceiveResponse, @@ -18,6 +19,7 @@ use ibc_proto::ibc::core::channel::v1::{ QueryPacketCommitmentResponse, QueryPacketCommitmentsRequest, QueryPacketCommitmentsResponse, QueryPacketReceiptRequest, QueryPacketReceiptResponse, QueryUnreceivedAcksRequest, QueryUnreceivedAcksResponse, QueryUnreceivedPacketsRequest, QueryUnreceivedPacketsResponse, + QueryUpgradeErrorRequest, QueryUpgradeErrorResponse, QueryUpgradeRequest, QueryUpgradeResponse, }; use tonic::{Request, Response, Status}; @@ -188,4 +190,31 @@ where Ok(Response::new(response)) } + + async fn upgrade_error( + &self, + _request: Request, + ) -> Result, Status> { + Err(Status::unimplemented( + "Querying UpgradeError is not supported yet", + )) + } + + async fn upgrade( + &self, + _request: Request, + ) -> Result, Status> { + Err(Status::unimplemented( + "Querying Upgrade is not supported yet", + )) + } + + async fn channel_params( + &self, + _request: Request, + ) -> Result, Status> { + Err(Status::unimplemented( + "Querying ChannelParams is not supported yet", + )) + } } From 4ec2b4e62891433d8da6f4a4b6d6bfb3ae09229a Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:14:09 +0100 Subject: [PATCH 04/10] new mock client header in testkit --- .../testapp/ibc/clients/mock/client_state.rs | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs index 89645d1b5..830c657f0 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs @@ -18,9 +18,7 @@ use crate::testapp::ibc::clients::mock::client_state::client_type as mock_client use crate::testapp::ibc::clients::mock::consensus_state::MockConsensusState; use crate::testapp::ibc::clients::mock::header::{MockHeader, MOCK_HEADER_TYPE_URL}; use crate::testapp::ibc::clients::mock::misbehaviour::{Misbehaviour, MOCK_MISBEHAVIOUR_TYPE_URL}; -use crate::testapp::ibc::clients::mock::proto::{ - ClientState as RawMockClientState, Header as RawMockHeader, -}; +use crate::testapp::ibc::clients::mock::proto::ClientState as RawMockClientState; pub const MOCK_CLIENT_STATE_TYPE_URL: &str = "/ibc.mock.ClientState"; pub const MOCK_CLIENT_TYPE: &str = "9999-mock"; @@ -35,14 +33,16 @@ pub fn client_type() -> ClientType { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct MockClientState { pub header: MockHeader, - pub frozen_height: Option, + pub trusting_period: Duration, + pub frozen: bool, } impl MockClientState { pub fn new(header: MockHeader) -> Self { Self { header, - frozen_height: None, + trusting_period: Duration::from_nanos(0), + frozen: false, } } @@ -54,15 +54,22 @@ impl MockClientState { None } - pub fn with_frozen_height(self, frozen_height: Height) -> Self { + pub fn with_trusting_period(self, trusting_period: Duration) -> Self { Self { - frozen_height: Some(frozen_height), + trusting_period, + ..self + } + } + + pub fn with_frozen_height(self, _frozen_height: Height) -> Self { + Self { + frozen: true, ..self } } pub fn is_frozen(&self) -> bool { - self.frozen_height.is_some() + self.frozen } fn expired(&self, _elapsed: Duration) -> bool { @@ -76,17 +83,29 @@ impl TryFrom for MockClientState { type Error = ClientError; fn try_from(raw: RawMockClientState) -> Result { - Ok(Self::new(raw.header.expect("Never fails").try_into()?)) + Ok(Self { + header: raw + .header + .ok_or(ClientError::Other { + description: "header is not present".into(), + })? + .try_into()?, + trusting_period: Duration::from_nanos(raw.trusting_period), + frozen: raw.frozen, + }) } } impl From for RawMockClientState { fn from(value: MockClientState) -> Self { RawMockClientState { - header: Some(RawMockHeader { - height: Some(value.header.height().into()), - timestamp: value.header.timestamp.nanoseconds(), - }), + header: Some(value.header.into()), + trusting_period: value + .trusting_period + .as_nanos() + .try_into() + .expect("no error"), + frozen: value.frozen, } } } From 83f61c72430b770723618dd57d85d389a5c9d979 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:14:25 +0100 Subject: [PATCH 05/10] update fixtures with new fields --- ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs | 1 + ibc-testkit/src/fixtures/core/channel/mod.rs | 1 + ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs b/ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs index df833f545..57694974f 100644 --- a/ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs +++ b/ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs @@ -17,6 +17,7 @@ pub fn dummy_raw_msg_chan_close_confirm(proof_height: u64) -> RawMsgChannelClose revision_height: proof_height, }), signer: dummy_bech32_account(), + counterparty_upgrade_sequence: 0, } } diff --git a/ibc-testkit/src/fixtures/core/channel/mod.rs b/ibc-testkit/src/fixtures/core/channel/mod.rs index a1375cd72..96834609e 100644 --- a/ibc-testkit/src/fixtures/core/channel/mod.rs +++ b/ibc-testkit/src/fixtures/core/channel/mod.rs @@ -48,6 +48,7 @@ pub fn dummy_raw_channel_end(state: i32, channel_id: Option) -> RawChannel counterparty: Some(dummy_raw_counterparty_chan(channel_id)), connection_hops: vec![ConnectionId::zero().to_string()], version: "".to_string(), // The version is not validated. + upgrade_sequence: 0, } } diff --git a/ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs b/ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs index 42db0e35f..2fc633160 100644 --- a/ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs +++ b/ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs @@ -17,6 +17,7 @@ pub fn dummy_raw_msg_timeout_on_close(height: u64, timeout_timestamp: u64) -> Ra }), next_sequence_recv: 1, signer: dummy_bech32_account(), + counterparty_upgrade_sequence: 0, } } From d69b41a7fca8347e3a0c113ff9e37c5458a19060 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:15:10 +0100 Subject: [PATCH 06/10] patch crates-io release --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index cd22b6d8b..2d7aba575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,3 +106,6 @@ tendermint-testgen = { version = "0.34.0", default-features = fals # parity dependencies parity-scale-codec = { version = "3.6.5", default-features = false, features = ["full"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } + +[patch.crates-io] +ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs", rev="618ebea" } From 4a40e0b0c275cadd222813e4a7001c7efcd15780 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 14 Mar 2024 20:18:53 +0100 Subject: [PATCH 07/10] refactor MockClientState methods --- .../src/testapp/ibc/clients/mock/client_state.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs index 830c657f0..2b597b1e1 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs @@ -61,13 +61,20 @@ impl MockClientState { } } - pub fn with_frozen_height(self, _frozen_height: Height) -> Self { + pub fn frozen(self) -> Self { Self { frozen: true, ..self } } + pub fn unfrozen(self) -> Self { + Self { + frozen: false, + ..self + } + } + pub fn is_frozen(&self) -> bool { self.frozen } @@ -373,7 +380,7 @@ where client_id: &ClientId, _client_message: Any, ) -> Result<(), ClientError> { - let frozen_client_state = self.with_frozen_height(Height::min(0)); + let frozen_client_state = self.frozen(); ctx.store_client_state( ClientStatePath::new(client_id.clone()), From 4fa981c2e2d786b326e881ed9b4736953a0459df Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 14 Mar 2024 16:38:44 -0700 Subject: [PATCH 08/10] chore: set ibc-proto-rs to v0.42.2 --- Cargo.toml | 5 +---- ci/cw-check/Cargo.lock | 4 ++-- ci/no-std-check/Cargo.lock | 4 ++-- ci/no-std-check/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2d7aba575..946a3efdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,7 +93,7 @@ ibc-client-wasm-types = { version = "0.50.0", path = "./ibc-clients/ics08- ibc-app-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics20-transfer/types", default-features = false } ibc-app-nft-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics721-nft-transfer/types", default-features = false } -ibc-proto = { version = "0.42.1", default-features = false } +ibc-proto = { version = "0.42.2", default-features = false } # cosmos dependencies tendermint = { version = "0.34.0", default-features = false } @@ -106,6 +106,3 @@ tendermint-testgen = { version = "0.34.0", default-features = fals # parity dependencies parity-scale-codec = { version = "3.6.5", default-features = false, features = ["full"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } - -[patch.crates-io] -ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs", rev="618ebea" } diff --git a/ci/cw-check/Cargo.lock b/ci/cw-check/Cargo.lock index 98a8201e7..d191ea07d 100644 --- a/ci/cw-check/Cargo.lock +++ b/ci/cw-check/Cargo.lock @@ -862,9 +862,9 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4ee32b22d3b06f31529b956f4928e5c9a068d71e46cf6abfa19c31ca550553" +checksum = "c1a6f2bbf7e1d12f98d8d54d9114231b865418d0f8b619c0873180eafdee07fd" dependencies = [ "base64 0.21.6", "bytes", diff --git a/ci/no-std-check/Cargo.lock b/ci/no-std-check/Cargo.lock index fb12ae90c..e430db282 100644 --- a/ci/no-std-check/Cargo.lock +++ b/ci/no-std-check/Cargo.lock @@ -1617,9 +1617,9 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4ee32b22d3b06f31529b956f4928e5c9a068d71e46cf6abfa19c31ca550553" +checksum = "c1a6f2bbf7e1d12f98d8d54d9114231b865418d0f8b619c0873180eafdee07fd" dependencies = [ "base64 0.21.7", "borsh", diff --git a/ci/no-std-check/Cargo.toml b/ci/no-std-check/Cargo.toml index 815a42f96..d7f6f8965 100644 --- a/ci/no-std-check/Cargo.toml +++ b/ci/no-std-check/Cargo.toml @@ -6,7 +6,7 @@ resolver = "2" [dependencies] ibc = { path = "../../ibc", default-features = false, features = ["serde"] } -ibc-proto = { version = "0.41.0", default-features = false, features = [ +ibc-proto = { version = "0.42.2", default-features = false, features = [ "parity-scale-codec", "borsh", "serde", From faf113bbdd98e2a1834892ca731e701676840798 Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 14 Mar 2024 16:43:04 -0700 Subject: [PATCH 09/10] chore: add changelog --- .../breaking-changes/1125-upgrade-ibc-proto-to-v042.md | 2 ++ .changelog/unreleased/breaking-changes/973-update-meta.md | 6 +++--- .../improvements/1074-refactor-default-implemetation.md | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .changelog/unreleased/breaking-changes/1125-upgrade-ibc-proto-to-v042.md diff --git a/.changelog/unreleased/breaking-changes/1125-upgrade-ibc-proto-to-v042.md b/.changelog/unreleased/breaking-changes/1125-upgrade-ibc-proto-to-v042.md new file mode 100644 index 000000000..8df9dec51 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/1125-upgrade-ibc-proto-to-v042.md @@ -0,0 +1,2 @@ +- [ibc] Upgrade `ibc-proto-rs` to `v0.42.2` + ([\#1125](https://github.com/cosmos/ibc-rs/pull/1125)) diff --git a/.changelog/unreleased/breaking-changes/973-update-meta.md b/.changelog/unreleased/breaking-changes/973-update-meta.md index 2aabe1231..97702e220 100644 --- a/.changelog/unreleased/breaking-changes/973-update-meta.md +++ b/.changelog/unreleased/breaking-changes/973-update-meta.md @@ -1,6 +1,6 @@ -- Merge client update time and height modification method pairs into - one, that is replace +- [ibc-core-client] Merge client update time and height modification method + pairs into one, that is replace a) client_update_{time,height} by update_meta, b) store_update_{time,height} by store_update_meta and c) delete_update_{time,height} by delete_update_meta. - ([\#972](https://github.com/cosmos/ibc-rs/pull/972)) + ([\#973](https://github.com/cosmos/ibc-rs/issues/973)) diff --git a/.changelog/unreleased/improvements/1074-refactor-default-implemetation.md b/.changelog/unreleased/improvements/1074-refactor-default-implemetation.md index fcf1cafe6..908463b41 100644 --- a/.changelog/unreleased/improvements/1074-refactor-default-implemetation.md +++ b/.changelog/unreleased/improvements/1074-refactor-default-implemetation.md @@ -1,2 +1,2 @@ -- [types] Refactor `Default` implementations with concrete names +- [ibc-data-types] Refactor `Default` implementations with concrete names ([\#1074](https://github.com/cosmos/ibc-rs/issues/1074)) From f6474c6f3555c15c1a9a49281f9136c372cf84c5 Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 14 Mar 2024 16:45:36 -0700 Subject: [PATCH 10/10] fix: make fmt happy --- ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs b/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs index 8d2608b79..7673d5f33 100644 --- a/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs +++ b/ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs @@ -6,8 +6,7 @@ use ibc_primitives::Signer; use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose; use ibc_proto::Protobuf; -use crate::error::ChannelError; -use crate::error::PacketError; +use crate::error::{ChannelError, PacketError}; use crate::packet::Packet; pub const TIMEOUT_ON_CLOSE_TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeoutOnClose";