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)) diff --git a/Cargo.toml b/Cargo.toml index e3efe6af3..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.41.0", default-features = false } +ibc-proto = { version = "0.42.2", default-features = false } # cosmos dependencies tendermint = { version = "0.34.0", default-features = false } 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", 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..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,7 +6,7 @@ use ibc_primitives::Signer; use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose; use ibc_proto::Protobuf; -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"; @@ -39,6 +39,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 +77,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, } } } 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", + )) + } } 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, } } 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..2b597b1e1 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,29 @@ impl MockClientState { None } - pub fn with_frozen_height(self, frozen_height: Height) -> Self { + pub fn with_trusting_period(self, trusting_period: Duration) -> Self { + Self { + trusting_period, + ..self + } + } + + pub fn frozen(self) -> Self { Self { - frozen_height: Some(frozen_height), + frozen: true, + ..self + } + } + + pub fn unfrozen(self) -> Self { + Self { + frozen: false, ..self } } pub fn is_frozen(&self) -> bool { - self.frozen_height.is_some() + self.frozen } fn expired(&self, _elapsed: Duration) -> bool { @@ -76,17 +90,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, } } } @@ -354,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()),