Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

deps: upgrade ibc-proto-rs to 0.42.2 #1125

Merged
merged 10 commits into from
Mar 14, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ibc] Upgrade `ibc-proto-rs` to `v0.42.2`
([\#1125](https://github.com/cosmos/ibc-rs/pull/1125))
6 changes: 3 additions & 3 deletions .changelog/unreleased/breaking-changes/973-update-meta.md
Original file line number Diff line number Diff line change
@@ -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))
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions ci/cw-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ci/no-std-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ci/no-std-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions ibc-core/ics04-channel/types/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@
type Error = ChannelError;

fn try_from(value: RawIdentifiedChannel) -> Result<Self, Self::Error> {
if value.upgrade_sequence != 0 {
return Err(ChannelError::UnsupportedChannelUpgradeSequence);
}

Check warning on line 58 in ibc-core/ics04-channel/types/src/channel.rs

View check run for this annotation

Codecov / codecov/patch

ibc-core/ics04-channel/types/src/channel.rs#L55-L58

Added lines #L55 - L58 were not covered by tests
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,

Check warning on line 65 in ibc-core/ics04-channel/types/src/channel.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L65 was not covered by tests
};

Ok(IdentifiedChannelEnd {
Expand All @@ -83,6 +88,7 @@
version: value.channel_end.version.to_string(),
port_id: value.port_id.to_string(),
channel_id: value.channel_id.to_string(),
upgrade_sequence: 0,

Check warning on line 91 in ibc-core/ics04-channel/types/src/channel.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L91 was not covered by tests
}
}
}
Expand Down Expand Up @@ -161,6 +167,7 @@
.map(|v| v.as_str().to_string())
.collect(),
version: value.version.to_string(),
upgrade_sequence: 0,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions ibc-core/ics04-channel/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
type Error = ChannelError;

fn try_from(raw_msg: RawMsgChannelCloseConfirm) -> Result<Self, Self::Error> {
if raw_msg.counterparty_upgrade_sequence != 0 {
return Err(ChannelError::UnsupportedChannelUpgradeSequence);

Check warning on line 39 in ibc-core/ics04-channel/types/src/msgs/chan_close_confirm.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L39 was not covered by tests
}

Ok(MsgChannelCloseConfirm {
port_id_on_b: raw_msg.port_id.parse()?,
chan_id_on_b: raw_msg.channel_id.parse()?,
Expand All @@ -59,6 +63,7 @@
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,
}
}
}
9 changes: 8 additions & 1 deletion ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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";
Expand Down Expand Up @@ -39,6 +39,12 @@
return Err(PacketError::ZeroPacketSequence);
}

if raw_msg.counterparty_upgrade_sequence != 0 {
return Err(PacketError::Channel(
ChannelError::UnsupportedChannelUpgradeSequence,
));

Check warning on line 45 in ibc-core/ics04-channel/types/src/msgs/timeout_on_close.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L43 - L45 were not covered by tests
}

Ok(MsgTimeoutOnClose {
packet: raw_msg
.packet
Expand Down Expand Up @@ -71,6 +77,7 @@
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,
}
}
}
31 changes: 30 additions & 1 deletion ibc-query/src/core/channel/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
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,
Expand All @@ -18,6 +19,7 @@
QueryPacketCommitmentResponse, QueryPacketCommitmentsRequest, QueryPacketCommitmentsResponse,
QueryPacketReceiptRequest, QueryPacketReceiptResponse, QueryUnreceivedAcksRequest,
QueryUnreceivedAcksResponse, QueryUnreceivedPacketsRequest, QueryUnreceivedPacketsResponse,
QueryUpgradeErrorRequest, QueryUpgradeErrorResponse, QueryUpgradeRequest, QueryUpgradeResponse,
};
use tonic::{Request, Response, Status};

Expand Down Expand Up @@ -188,4 +190,31 @@

Ok(Response::new(response))
}

async fn upgrade_error(
&self,
_request: Request<QueryUpgradeErrorRequest>,
) -> Result<Response<QueryUpgradeErrorResponse>, Status> {
Err(Status::unimplemented(
"Querying UpgradeError is not supported yet",
))
}

Check warning on line 201 in ibc-query/src/core/channel/service.rs

View check run for this annotation

Codecov / codecov/patch

ibc-query/src/core/channel/service.rs#L194-L201

Added lines #L194 - L201 were not covered by tests

async fn upgrade(
&self,
_request: Request<QueryUpgradeRequest>,
) -> Result<Response<QueryUpgradeResponse>, Status> {
Err(Status::unimplemented(
"Querying Upgrade is not supported yet",
))
}

Check warning on line 210 in ibc-query/src/core/channel/service.rs

View check run for this annotation

Codecov / codecov/patch

ibc-query/src/core/channel/service.rs#L203-L210

Added lines #L203 - L210 were not covered by tests

async fn channel_params(
&self,
_request: Request<QueryChannelParamsRequest>,
) -> Result<Response<QueryChannelParamsResponse>, Status> {
Err(Status::unimplemented(
"Querying ChannelParams is not supported yet",
))
}

Check warning on line 219 in ibc-query/src/core/channel/service.rs

View check run for this annotation

Codecov / codecov/patch

ibc-query/src/core/channel/service.rs#L212-L219

Added lines #L212 - L219 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions ibc-testkit/src/fixtures/core/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub fn dummy_raw_channel_end(state: i32, channel_id: Option<u64>) -> 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,
}
}

Expand Down
1 change: 1 addition & 0 deletions ibc-testkit/src/fixtures/core/channel/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
54 changes: 40 additions & 14 deletions ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
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";
Expand All @@ -35,14 +33,16 @@
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct MockClientState {
pub header: MockHeader,
pub frozen_height: Option<Height>,
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,
}
}

Expand All @@ -54,15 +54,29 @@
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
}
}

Check warning on line 62 in ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs

View check run for this annotation

Codecov / codecov/patch

ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs#L57-L62

Added lines #L57 - L62 were not covered by tests

pub fn frozen(self) -> Self {
Self {
frozen_height: Some(frozen_height),
frozen: true,
..self
}
}

pub fn unfrozen(self) -> Self {
Self {
frozen: false,

Check warning on line 73 in ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs

View check run for this annotation

Codecov / codecov/patch

ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs#L71-L73

Added lines #L71 - L73 were not covered by tests
..self
}
}

pub fn is_frozen(&self) -> bool {
self.frozen_height.is_some()
self.frozen
}

fn expired(&self, _elapsed: Duration) -> bool {
Expand All @@ -76,17 +90,29 @@
type Error = ClientError;

fn try_from(raw: RawMockClientState) -> Result<Self, Self::Error> {
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<MockClientState> 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,
}
}
}
Expand Down Expand Up @@ -354,7 +380,7 @@
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()),
Expand Down
Loading