Skip to content

Commit 32e8719

Browse files
deps: upgrade ibc-proto-rs to 0.42.2 (#1125)
* ibc-proto v0.42.1 * handle new data fields * impl new service methods * new mock client header in testkit * update fixtures with new fields * patch crates-io release * refactor MockClientState methods * chore: set ibc-proto-rs to v0.42.2 * chore: add changelog * fix: make fmt happy --------- Co-authored-by: Farhad Shabani <farhad.shabani@gmail.com>
1 parent ffb4f55 commit 32e8719

File tree

16 files changed

+107
-26
lines changed

16 files changed

+107
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc] Upgrade `ibc-proto-rs` to `v0.42.2`
2+
([\#1125](https://github.com/cosmos/ibc-rs/pull/1125))
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
- Merge client update time and height modification method pairs into
2-
one, that is replace
1+
- [ibc-core-client] Merge client update time and height modification method
2+
pairs into one, that is replace
33
a) client_update_{time,height} by update_meta,
44
b) store_update_{time,height} by store_update_meta and
55
c) delete_update_{time,height} by delete_update_meta.
6-
([\#972](https://github.com/cosmos/ibc-rs/pull/972))
6+
([\#973](https://github.com/cosmos/ibc-rs/issues/973))
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- [types] Refactor `Default` implementations with concrete names
1+
- [ibc-data-types] Refactor `Default` implementations with concrete names
22
([\#1074](https://github.com/cosmos/ibc-rs/issues/1074))

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ibc-client-wasm-types = { version = "0.50.0", path = "./ibc-clients/ics08-
9393
ibc-app-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics20-transfer/types", default-features = false }
9494
ibc-app-nft-transfer-types = { version = "0.50.0", path = "./ibc-apps/ics721-nft-transfer/types", default-features = false }
9595

96-
ibc-proto = { version = "0.41.0", default-features = false }
96+
ibc-proto = { version = "0.42.2", default-features = false }
9797

9898
# cosmos dependencies
9999
tendermint = { version = "0.34.0", default-features = false }

ci/cw-check/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/no-std-check/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/no-std-check/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resolver = "2"
66

77
[dependencies]
88
ibc = { path = "../../ibc", default-features = false, features = ["serde"] }
9-
ibc-proto = { version = "0.41.0", default-features = false, features = [
9+
ibc-proto = { version = "0.42.2", default-features = false, features = [
1010
"parity-scale-codec",
1111
"borsh",
1212
"serde",

ibc-core/ics04-channel/types/src/channel.rs

+7
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ impl TryFrom<RawIdentifiedChannel> for IdentifiedChannelEnd {
5252
type Error = ChannelError;
5353

5454
fn try_from(value: RawIdentifiedChannel) -> Result<Self, Self::Error> {
55+
if value.upgrade_sequence != 0 {
56+
return Err(ChannelError::UnsupportedChannelUpgradeSequence);
57+
}
58+
5559
let raw_channel_end = RawChannel {
5660
state: value.state,
5761
ordering: value.ordering,
5862
counterparty: value.counterparty,
5963
connection_hops: value.connection_hops,
6064
version: value.version,
65+
upgrade_sequence: value.upgrade_sequence,
6166
};
6267

6368
Ok(IdentifiedChannelEnd {
@@ -83,6 +88,7 @@ impl From<IdentifiedChannelEnd> for RawIdentifiedChannel {
8388
version: value.channel_end.version.to_string(),
8489
port_id: value.port_id.to_string(),
8590
channel_id: value.channel_id.to_string(),
91+
upgrade_sequence: 0,
8692
}
8793
}
8894
}
@@ -161,6 +167,7 @@ impl From<ChannelEnd> for RawChannel {
161167
.map(|v| v.as_str().to_string())
162168
.collect(),
163169
version: value.version.to_string(),
170+
upgrade_sequence: 0,
164171
}
165172
}
166173
}

ibc-core/ics04-channel/types/src/error.rs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ pub enum ChannelError {
3333
NonUtf8PacketData,
3434
/// missing counterparty
3535
MissingCounterparty,
36+
/// unsupported channel upgrade sequence
37+
UnsupportedChannelUpgradeSequence,
3638
/// version not supported: expected `{expected}`, actual `{actual}`
3739
VersionNotSupported { expected: Version, actual: Version },
3840
/// missing channel end

ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ impl TryFrom<RawMsgChannelCloseConfirm> for MsgChannelCloseConfirm {
3535
type Error = ChannelError;
3636

3737
fn try_from(raw_msg: RawMsgChannelCloseConfirm) -> Result<Self, Self::Error> {
38+
if raw_msg.counterparty_upgrade_sequence != 0 {
39+
return Err(ChannelError::UnsupportedChannelUpgradeSequence);
40+
}
41+
3842
Ok(MsgChannelCloseConfirm {
3943
port_id_on_b: raw_msg.port_id.parse()?,
4044
chan_id_on_b: raw_msg.channel_id.parse()?,
@@ -59,6 +63,7 @@ impl From<MsgChannelCloseConfirm> for RawMsgChannelCloseConfirm {
5963
proof_init: domain_msg.proof_chan_end_on_a.clone().into(),
6064
proof_height: Some(domain_msg.proof_height_on_a.into()),
6165
signer: domain_msg.signer.to_string(),
66+
counterparty_upgrade_sequence: 0,
6267
}
6368
}
6469
}

ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ibc_primitives::Signer;
66
use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose;
77
use ibc_proto::Protobuf;
88

9-
use crate::error::PacketError;
9+
use crate::error::{ChannelError, PacketError};
1010
use crate::packet::Packet;
1111

1212
pub const TIMEOUT_ON_CLOSE_TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeoutOnClose";
@@ -39,6 +39,12 @@ impl TryFrom<RawMsgTimeoutOnClose> for MsgTimeoutOnClose {
3939
return Err(PacketError::ZeroPacketSequence);
4040
}
4141

42+
if raw_msg.counterparty_upgrade_sequence != 0 {
43+
return Err(PacketError::Channel(
44+
ChannelError::UnsupportedChannelUpgradeSequence,
45+
));
46+
}
47+
4248
Ok(MsgTimeoutOnClose {
4349
packet: raw_msg
4450
.packet
@@ -71,6 +77,7 @@ impl From<MsgTimeoutOnClose> for RawMsgTimeoutOnClose {
7177
proof_height: Some(domain_msg.proof_height_on_b.into()),
7278
next_sequence_recv: domain_msg.next_seq_recv_on_b.into(),
7379
signer: domain_msg.signer.to_string(),
80+
counterparty_upgrade_sequence: 0,
7481
}
7582
}
7683
}

ibc-query/src/core/channel/service.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use ibc_proto::google::protobuf::Any;
88
use ibc_proto::ibc::core::channel::v1::query_server::Query as ChannelQuery;
99
use ibc_proto::ibc::core::channel::v1::{
1010
QueryChannelClientStateRequest, QueryChannelClientStateResponse,
11-
QueryChannelConsensusStateRequest, QueryChannelConsensusStateResponse, QueryChannelRequest,
11+
QueryChannelConsensusStateRequest, QueryChannelConsensusStateResponse,
12+
QueryChannelParamsRequest, QueryChannelParamsResponse, QueryChannelRequest,
1213
QueryChannelResponse, QueryChannelsRequest, QueryChannelsResponse,
1314
QueryConnectionChannelsRequest, QueryConnectionChannelsResponse,
1415
QueryNextSequenceReceiveRequest, QueryNextSequenceReceiveResponse,
@@ -18,6 +19,7 @@ use ibc_proto::ibc::core::channel::v1::{
1819
QueryPacketCommitmentResponse, QueryPacketCommitmentsRequest, QueryPacketCommitmentsResponse,
1920
QueryPacketReceiptRequest, QueryPacketReceiptResponse, QueryUnreceivedAcksRequest,
2021
QueryUnreceivedAcksResponse, QueryUnreceivedPacketsRequest, QueryUnreceivedPacketsResponse,
22+
QueryUpgradeErrorRequest, QueryUpgradeErrorResponse, QueryUpgradeRequest, QueryUpgradeResponse,
2123
};
2224
use tonic::{Request, Response, Status};
2325

@@ -188,4 +190,31 @@ where
188190

189191
Ok(Response::new(response))
190192
}
193+
194+
async fn upgrade_error(
195+
&self,
196+
_request: Request<QueryUpgradeErrorRequest>,
197+
) -> Result<Response<QueryUpgradeErrorResponse>, Status> {
198+
Err(Status::unimplemented(
199+
"Querying UpgradeError is not supported yet",
200+
))
201+
}
202+
203+
async fn upgrade(
204+
&self,
205+
_request: Request<QueryUpgradeRequest>,
206+
) -> Result<Response<QueryUpgradeResponse>, Status> {
207+
Err(Status::unimplemented(
208+
"Querying Upgrade is not supported yet",
209+
))
210+
}
211+
212+
async fn channel_params(
213+
&self,
214+
_request: Request<QueryChannelParamsRequest>,
215+
) -> Result<Response<QueryChannelParamsResponse>, Status> {
216+
Err(Status::unimplemented(
217+
"Querying ChannelParams is not supported yet",
218+
))
219+
}
191220
}

ibc-testkit/src/fixtures/core/channel/chan_close_confirm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn dummy_raw_msg_chan_close_confirm(proof_height: u64) -> RawMsgChannelClose
1717
revision_height: proof_height,
1818
}),
1919
signer: dummy_bech32_account(),
20+
counterparty_upgrade_sequence: 0,
2021
}
2122
}
2223

ibc-testkit/src/fixtures/core/channel/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub fn dummy_raw_channel_end(state: i32, channel_id: Option<u64>) -> RawChannel
4848
counterparty: Some(dummy_raw_counterparty_chan(channel_id)),
4949
connection_hops: vec![ConnectionId::zero().to_string()],
5050
version: "".to_string(), // The version is not validated.
51+
upgrade_sequence: 0,
5152
}
5253
}
5354

ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn dummy_raw_msg_timeout_on_close(height: u64, timeout_timestamp: u64) -> Ra
1717
}),
1818
next_sequence_recv: 1,
1919
signer: dummy_bech32_account(),
20+
counterparty_upgrade_sequence: 0,
2021
}
2122
}
2223

ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs

+40-14
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ use crate::testapp::ibc::clients::mock::client_state::client_type as mock_client
1818
use crate::testapp::ibc::clients::mock::consensus_state::MockConsensusState;
1919
use crate::testapp::ibc::clients::mock::header::{MockHeader, MOCK_HEADER_TYPE_URL};
2020
use crate::testapp::ibc::clients::mock::misbehaviour::{Misbehaviour, MOCK_MISBEHAVIOUR_TYPE_URL};
21-
use crate::testapp::ibc::clients::mock::proto::{
22-
ClientState as RawMockClientState, Header as RawMockHeader,
23-
};
21+
use crate::testapp::ibc::clients::mock::proto::ClientState as RawMockClientState;
2422

2523
pub const MOCK_CLIENT_STATE_TYPE_URL: &str = "/ibc.mock.ClientState";
2624
pub const MOCK_CLIENT_TYPE: &str = "9999-mock";
@@ -35,14 +33,16 @@ pub fn client_type() -> ClientType {
3533
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
3634
pub struct MockClientState {
3735
pub header: MockHeader,
38-
pub frozen_height: Option<Height>,
36+
pub trusting_period: Duration,
37+
pub frozen: bool,
3938
}
4039

4140
impl MockClientState {
4241
pub fn new(header: MockHeader) -> Self {
4342
Self {
4443
header,
45-
frozen_height: None,
44+
trusting_period: Duration::from_nanos(0),
45+
frozen: false,
4646
}
4747
}
4848

@@ -54,15 +54,29 @@ impl MockClientState {
5454
None
5555
}
5656

57-
pub fn with_frozen_height(self, frozen_height: Height) -> Self {
57+
pub fn with_trusting_period(self, trusting_period: Duration) -> Self {
58+
Self {
59+
trusting_period,
60+
..self
61+
}
62+
}
63+
64+
pub fn frozen(self) -> Self {
5865
Self {
59-
frozen_height: Some(frozen_height),
66+
frozen: true,
67+
..self
68+
}
69+
}
70+
71+
pub fn unfrozen(self) -> Self {
72+
Self {
73+
frozen: false,
6074
..self
6175
}
6276
}
6377

6478
pub fn is_frozen(&self) -> bool {
65-
self.frozen_height.is_some()
79+
self.frozen
6680
}
6781

6882
fn expired(&self, _elapsed: Duration) -> bool {
@@ -76,17 +90,29 @@ impl TryFrom<RawMockClientState> for MockClientState {
7690
type Error = ClientError;
7791

7892
fn try_from(raw: RawMockClientState) -> Result<Self, Self::Error> {
79-
Ok(Self::new(raw.header.expect("Never fails").try_into()?))
93+
Ok(Self {
94+
header: raw
95+
.header
96+
.ok_or(ClientError::Other {
97+
description: "header is not present".into(),
98+
})?
99+
.try_into()?,
100+
trusting_period: Duration::from_nanos(raw.trusting_period),
101+
frozen: raw.frozen,
102+
})
80103
}
81104
}
82105

83106
impl From<MockClientState> for RawMockClientState {
84107
fn from(value: MockClientState) -> Self {
85108
RawMockClientState {
86-
header: Some(RawMockHeader {
87-
height: Some(value.header.height().into()),
88-
timestamp: value.header.timestamp.nanoseconds(),
89-
}),
109+
header: Some(value.header.into()),
110+
trusting_period: value
111+
.trusting_period
112+
.as_nanos()
113+
.try_into()
114+
.expect("no error"),
115+
frozen: value.frozen,
90116
}
91117
}
92118
}
@@ -354,7 +380,7 @@ where
354380
client_id: &ClientId,
355381
_client_message: Any,
356382
) -> Result<(), ClientError> {
357-
let frozen_client_state = self.with_frozen_height(Height::min(0));
383+
let frozen_client_state = self.frozen();
358384

359385
ctx.store_client_state(
360386
ClientStatePath::new(client_id.clone()),

0 commit comments

Comments
 (0)