From 06288a648dad6490c48eb27d35050f8da66dc160 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 14:07:01 -0600 Subject: [PATCH 1/8] Decorate MsgSubmitMisbehaviour with `deprecated` attribute --- ibc-core/ics02-client/types/src/msgs/misbehaviour.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs index b47be6166..c6097ee5d 100644 --- a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs +++ b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs @@ -12,6 +12,13 @@ use crate::error::ClientError; pub const SUBMIT_MISBEHAVIOUR_TYPE_URL: &str = "/ibc.core.client.v1.MsgSubmitMisbehaviour"; /// A type of message that submits client misbehaviour proof. +/// +/// Deprecated since v0.50.0. Misbehaviour reports should be submitted via the `MsgUpdateClient` +/// type through its `client_message` field. +#[deprecated( + since = "0.50.0", + note = "Misbehaviour reports should be submitted via `MsgUpdateClient` through its `client_message` field" +)] #[cfg_attr( feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) From f797bb9d99f7ce6cb35baeba2b98fd15ad6f9135 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 14:16:09 -0600 Subject: [PATCH 2/8] Add #[allow(deprecated)] attributes in ibc-testkit --- ibc-core/ics02-client/types/src/msgs/mod.rs | 2 ++ ibc-core/ics25-handler/types/src/msgs.rs | 2 ++ ibc-testkit/tests/core/ics02_client/update_client.rs | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/ibc-core/ics02-client/types/src/msgs/mod.rs b/ibc-core/ics02-client/types/src/msgs/mod.rs index 33330a77d..a7ba138fc 100644 --- a/ibc-core/ics02-client/types/src/msgs/mod.rs +++ b/ibc-core/ics02-client/types/src/msgs/mod.rs @@ -1,4 +1,6 @@ //! Defines the client message types that are sent to the chain by the relayer. +#![allow(deprecated)] + use ibc_core_host_types::identifiers::ClientId; use ibc_primitives::prelude::*; use ibc_primitives::Signer; diff --git a/ibc-core/ics25-handler/types/src/msgs.rs b/ibc-core/ics25-handler/types/src/msgs.rs index 849bcaaf6..1272c0aff 100644 --- a/ibc-core/ics25-handler/types/src/msgs.rs +++ b/ibc-core/ics25-handler/types/src/msgs.rs @@ -6,6 +6,7 @@ use ibc_core_channel_types::msgs::{ CHAN_OPEN_INIT_TYPE_URL, CHAN_OPEN_TRY_TYPE_URL, RECV_PACKET_TYPE_URL, TIMEOUT_ON_CLOSE_TYPE_URL, TIMEOUT_TYPE_URL, }; +#[allow(deprecated)] use ibc_core_client_types::msgs::{ ClientMsg, MsgCreateClient, MsgSubmitMisbehaviour, MsgUpdateClient, MsgUpgradeClient, CREATE_CLIENT_TYPE_URL, SUBMIT_MISBEHAVIOUR_TYPE_URL, UPDATE_CLIENT_TYPE_URL, @@ -35,6 +36,7 @@ pub enum MsgEnvelope { Packet(PacketMsg), } +#[allow(deprecated)] impl TryFrom for MsgEnvelope { type Error = RouterError; diff --git a/ibc-testkit/tests/core/ics02_client/update_client.rs b/ibc-testkit/tests/core/ics02_client/update_client.rs index 2d4e7bbf3..85d555805 100644 --- a/ibc-testkit/tests/core/ics02_client/update_client.rs +++ b/ibc-testkit/tests/core/ics02_client/update_client.rs @@ -9,6 +9,7 @@ use ibc::clients::tendermint::types::{ }; use ibc::core::client::context::client_state::{ClientStateCommon, ClientStateValidation}; use ibc::core::client::context::ClientValidationContext; +#[allow(deprecated)] use ibc::core::client::types::msgs::{ClientMsg, MsgSubmitMisbehaviour, MsgUpdateClient}; use ibc::core::client::types::proto::v1::Height as RawHeight; use ibc::core::client::types::Height; @@ -80,6 +81,7 @@ fn msg_update_client() -> MsgEnvelope { /// rstest fixture that returns a `MsgEnvelope` with the `misbehaviour` /// field set to a `MockMisbehaviour` report. +#[allow(deprecated)] #[fixture] fn msg_submit_misbehaviour() -> MsgEnvelope { let client_id = ClientId::default(); @@ -801,6 +803,7 @@ fn test_misbehaviour_client_ok(fixture: Fixture, #[case] msg_envelope: MsgEnvelo ensure_misbehaviour(&ctx, &client_id, &mock_client_type()); } +#[allow(deprecated)] #[rstest] fn test_submit_misbehaviour_nonexisting_client(fixture: Fixture) { let Fixture { router, .. } = fixture; @@ -859,6 +862,7 @@ fn test_client_update_misbehaviour_nonexisting_client(fixture: Fixture) { /// Tests misbehaviour handling for the synthetic Tendermint client. /// Misbehaviour evidence consists of equivocal headers. +#[allow(deprecated)] #[rstest] fn test_misbehaviour_synthetic_tendermint_equivocation() { let client_id = tm_client_type().build_client_id(0); @@ -921,6 +925,7 @@ fn test_misbehaviour_synthetic_tendermint_equivocation() { ensure_misbehaviour(&ctx_a, &client_id, &tm_client_type()); } +#[allow(deprecated)] #[rstest] fn test_misbehaviour_synthetic_tendermint_bft_time() { let client_id = tm_client_type().build_client_id(0); From 7990ee89897041e16e819078fbbc4ea0109dce67 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 14:44:42 -0600 Subject: [PATCH 3/8] Add #![allow(deprecated)] attribute to ics02/types/msgs/mod.rs --- ibc-core/ics02-client/types/src/msgs/misbehaviour.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs index c6097ee5d..8d8efea94 100644 --- a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs +++ b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs @@ -39,7 +39,6 @@ impl Protobuf for MsgSubmitMisbehaviour {} impl TryFrom for MsgSubmitMisbehaviour { type Error = ClientError; - #[allow(deprecated)] fn try_from(raw: RawMsgSubmitMisbehaviour) -> Result { let raw_misbehaviour = raw .misbehaviour @@ -58,7 +57,6 @@ impl TryFrom for MsgSubmitMisbehaviour { impl From for RawMsgSubmitMisbehaviour { fn from(ics_msg: MsgSubmitMisbehaviour) -> Self { - #[allow(deprecated)] RawMsgSubmitMisbehaviour { client_id: ics_msg.client_id.to_string(), misbehaviour: Some(ics_msg.misbehaviour), From f2d20567af1324b1537aea6d704882597fa85e5b Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 16:02:36 -0600 Subject: [PATCH 4/8] Remove usages of MsgSubmitMisbehaviour from ibc-testkit/update_client.rs --- .../types/src/msgs/misbehaviour.rs | 2 +- ibc-core/ics02-client/types/src/msgs/mod.rs | 3 +- .../tests/core/ics02_client/update_client.rs | 52 +++++-------------- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs index 8d8efea94..c5f1e90e5 100644 --- a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs +++ b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs @@ -16,7 +16,7 @@ pub const SUBMIT_MISBEHAVIOUR_TYPE_URL: &str = "/ibc.core.client.v1.MsgSubmitMis /// Deprecated since v0.50.0. Misbehaviour reports should be submitted via the `MsgUpdateClient` /// type through its `client_message` field. #[deprecated( - since = "0.50.0", + since = "0.51.0", note = "Misbehaviour reports should be submitted via `MsgUpdateClient` through its `client_message` field" )] #[cfg_attr( diff --git a/ibc-core/ics02-client/types/src/msgs/mod.rs b/ibc-core/ics02-client/types/src/msgs/mod.rs index a7ba138fc..ab9a145ed 100644 --- a/ibc-core/ics02-client/types/src/msgs/mod.rs +++ b/ibc-core/ics02-client/types/src/msgs/mod.rs @@ -1,6 +1,7 @@ -//! Defines the client message types that are sent to the chain by the relayer. #![allow(deprecated)] +//! Defines the client message types that are sent to the chain by the relayer. + use ibc_core_host_types::identifiers::ClientId; use ibc_primitives::prelude::*; use ibc_primitives::Signer; diff --git a/ibc-testkit/tests/core/ics02_client/update_client.rs b/ibc-testkit/tests/core/ics02_client/update_client.rs index 85d555805..967359e73 100644 --- a/ibc-testkit/tests/core/ics02_client/update_client.rs +++ b/ibc-testkit/tests/core/ics02_client/update_client.rs @@ -58,11 +58,8 @@ fn fixture() -> Fixture { Fixture { ctx, router } } -/// rstest fixture that returns a `MsgEnvelope` with the `client_message` -/// field set to a `MockMisbehaviour` report. -#[fixture] -fn msg_update_client() -> MsgEnvelope { - let client_id = ClientId::default(); +/// Returns a `MsgEnvelope` with the `client_message` field set to a `MockMisbehaviour` report. +fn msg_update_client(client_id: &ClientId) -> MsgEnvelope { let timestamp = Timestamp::now(); let height = Height::new(0, 46).unwrap(); let msg = MsgUpdateClient { @@ -784,15 +781,14 @@ fn ensure_misbehaviour(ctx: &MockContext, client_id: &ClientId, client_type: &Cl /// Misbehaviour evidence consists of identical headers - mock misbehaviour handler /// considers it a valid proof of misbehaviour. #[rstest] -#[case::msg_submit_misbehaviour(msg_submit_misbehaviour())] -#[case::msg_update_client(msg_update_client())] -fn test_misbehaviour_client_ok(fixture: Fixture, #[case] msg_envelope: MsgEnvelope) { +fn test_misbehaviour_client_ok(fixture: Fixture) { let Fixture { mut ctx, mut router, } = fixture; let client_id = ClientId::default(); + let msg_envelope = msg_update_client(&client_id); let res = validate(&ctx, &router, msg_envelope.clone()); assert!(res.is_ok()); @@ -803,24 +799,13 @@ fn test_misbehaviour_client_ok(fixture: Fixture, #[case] msg_envelope: MsgEnvelo ensure_misbehaviour(&ctx, &client_id, &mock_client_type()); } -#[allow(deprecated)] #[rstest] fn test_submit_misbehaviour_nonexisting_client(fixture: Fixture) { let Fixture { router, .. } = fixture; let client_id = ClientId::from_str("mockclient1").unwrap(); - let height = Height::new(0, 46).unwrap(); - let msg = MsgSubmitMisbehaviour { - client_id: ClientId::from_str("nonexistingclient").unwrap(), - misbehaviour: MockMisbehaviour { - client_id: client_id.clone(), - header1: MockHeader::new(height), - header2: MockHeader::new(height), - } - .into(), - signer: dummy_account_id(), - }; - let msg_envelope = MsgEnvelope::from(ClientMsg::from(msg)); + + let msg_envelope = msg_update_client(&ClientId::from_str("nonexistingclient").unwrap()); let ctx = MockContext::default().with_client_config( MockClientConfig::builder() @@ -837,18 +822,8 @@ fn test_client_update_misbehaviour_nonexisting_client(fixture: Fixture) { let Fixture { router, .. } = fixture; let client_id = ClientId::from_str("mockclient1").unwrap(); - let height = Height::new(0, 46).unwrap(); - let msg = MsgUpdateClient { - client_id: ClientId::from_str("nonexistingclient").unwrap(), - client_message: MockMisbehaviour { - client_id: client_id.clone(), - header1: MockHeader::new(height), - header2: MockHeader::new(height), - } - .into(), - signer: dummy_account_id(), - }; - let msg_envelope = MsgEnvelope::from(ClientMsg::from(msg)); + + let msg_envelope = msg_update_client(&ClientId::from_str("nonexistingclient").unwrap()); let ctx = MockContext::default().with_client_config( MockClientConfig::builder() @@ -862,7 +837,6 @@ fn test_client_update_misbehaviour_nonexisting_client(fixture: Fixture) { /// Tests misbehaviour handling for the synthetic Tendermint client. /// Misbehaviour evidence consists of equivocal headers. -#[allow(deprecated)] #[rstest] fn test_misbehaviour_synthetic_tendermint_equivocation() { let client_id = tm_client_type().build_client_id(0); @@ -911,9 +885,9 @@ fn test_misbehaviour_synthetic_tendermint_equivocation() { tm_block.into() }; - let msg = MsgSubmitMisbehaviour { + let msg = MsgUpdateClient { client_id: client_id.clone(), - misbehaviour: TmMisbehaviour::new(client_id.clone(), header1, header2).into(), + client_message: TmMisbehaviour::new(client_id.clone(), header1, header2).into(), signer: dummy_account_id(), }; let msg_envelope = MsgEnvelope::from(ClientMsg::from(msg)); @@ -925,7 +899,6 @@ fn test_misbehaviour_synthetic_tendermint_equivocation() { ensure_misbehaviour(&ctx_a, &client_id, &tm_client_type()); } -#[allow(deprecated)] #[rstest] fn test_misbehaviour_synthetic_tendermint_bft_time() { let client_id = tm_client_type().build_client_id(0); @@ -974,9 +947,10 @@ fn test_misbehaviour_synthetic_tendermint_bft_time() { tm_block }; - let msg = MsgSubmitMisbehaviour { + let msg = MsgUpdateClient { client_id: client_id.clone(), - misbehaviour: TmMisbehaviour::new(client_id.clone(), header1.into(), header2.into()).into(), + client_message: TmMisbehaviour::new(client_id.clone(), header1.into(), header2.into()) + .into(), signer: dummy_account_id(), }; From 2faf71bcbdcd32ccf5a5acc4298e1edf38ee0cff Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 16:03:30 -0600 Subject: [PATCH 5/8] Remove unused rstest fixture --- .../tests/core/ics02_client/update_client.rs | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/ibc-testkit/tests/core/ics02_client/update_client.rs b/ibc-testkit/tests/core/ics02_client/update_client.rs index 967359e73..fc60fcbab 100644 --- a/ibc-testkit/tests/core/ics02_client/update_client.rs +++ b/ibc-testkit/tests/core/ics02_client/update_client.rs @@ -9,8 +9,7 @@ use ibc::clients::tendermint::types::{ }; use ibc::core::client::context::client_state::{ClientStateCommon, ClientStateValidation}; use ibc::core::client::context::ClientValidationContext; -#[allow(deprecated)] -use ibc::core::client::types::msgs::{ClientMsg, MsgSubmitMisbehaviour, MsgUpdateClient}; +use ibc::core::client::types::msgs::{ClientMsg, MsgUpdateClient}; use ibc::core::client::types::proto::v1::Height as RawHeight; use ibc::core::client::types::Height; use ibc::core::commitment_types::specs::ProofSpecs; @@ -76,28 +75,6 @@ fn msg_update_client(client_id: &ClientId) -> MsgEnvelope { MsgEnvelope::from(ClientMsg::from(msg)) } -/// rstest fixture that returns a `MsgEnvelope` with the `misbehaviour` -/// field set to a `MockMisbehaviour` report. -#[allow(deprecated)] -#[fixture] -fn msg_submit_misbehaviour() -> MsgEnvelope { - let client_id = ClientId::default(); - let timestamp = Timestamp::now(); - let height = Height::new(0, 46).unwrap(); - let msg = MsgSubmitMisbehaviour { - client_id: client_id.clone(), - misbehaviour: MockMisbehaviour { - client_id: client_id.clone(), - header1: MockHeader::new(height).with_timestamp(timestamp), - header2: MockHeader::new(height).with_timestamp(timestamp), - } - .into(), - signer: dummy_account_id(), - }; - - MsgEnvelope::from(ClientMsg::from(msg)) -} - #[rstest] fn test_update_client_ok(fixture: Fixture) { let Fixture { From 8c52c81b71b0191a38fcf0b97614f503f803734f Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 16:04:12 -0600 Subject: [PATCH 6/8] Fix incorrect doc comment --- ibc-core/ics02-client/types/src/msgs/misbehaviour.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs index c5f1e90e5..fc13aa91f 100644 --- a/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs +++ b/ibc-core/ics02-client/types/src/msgs/misbehaviour.rs @@ -13,7 +13,7 @@ pub const SUBMIT_MISBEHAVIOUR_TYPE_URL: &str = "/ibc.core.client.v1.MsgSubmitMis /// A type of message that submits client misbehaviour proof. /// -/// Deprecated since v0.50.0. Misbehaviour reports should be submitted via the `MsgUpdateClient` +/// Deprecated since v0.51.0. Misbehaviour reports should be submitted via the `MsgUpdateClient` /// type through its `client_message` field. #[deprecated( since = "0.51.0", From 40d6e3b669e47e5a88867c970bd4d0839360f1f5 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 6 Feb 2024 20:15:44 -0600 Subject: [PATCH 7/8] Add changelog entry --- .../improvements/1077-deprecate-msgsubmitmisbehaviour.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md diff --git a/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md b/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md new file mode 100644 index 000000000..9d7bab727 --- /dev/null +++ b/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md @@ -0,0 +1 @@ +- [ibc-core] Deprecate `MsgSubmitMisbehaviour` in favor of `MsgUpdateClient` for submitting misbehaviour reports ([\#1077](https://github.com/cosmos/ibc-rs/pull/1077)) From 15372c89ab6f7e084430ef6315491535a086c3cd Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Tue, 6 Feb 2024 19:51:58 -0800 Subject: [PATCH 8/8] chore: add missing unclog for PR835 --- .../improvements/1077-deprecate-msgsubmitmisbehaviour.md | 4 +++- .../835-msg-update-client-handler-accept-misbehaviour.md | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changelog/unreleased/improvements/835-msg-update-client-handler-accept-misbehaviour.md diff --git a/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md b/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md index 9d7bab727..e92dc29d2 100644 --- a/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md +++ b/.changelog/unreleased/improvements/1077-deprecate-msgsubmitmisbehaviour.md @@ -1 +1,3 @@ -- [ibc-core] Deprecate `MsgSubmitMisbehaviour` in favor of `MsgUpdateClient` for submitting misbehaviour reports ([\#1077](https://github.com/cosmos/ibc-rs/pull/1077)) +- [ibc-core] Deprecate `MsgSubmitMisbehaviour` in favor of `MsgUpdateClient` for + submitting misbehaviour reports + ([\#1077](https://github.com/cosmos/ibc-rs/issues/1077)) diff --git a/.changelog/unreleased/improvements/835-msg-update-client-handler-accept-misbehaviour.md b/.changelog/unreleased/improvements/835-msg-update-client-handler-accept-misbehaviour.md new file mode 100644 index 000000000..6e6b8488e --- /dev/null +++ b/.changelog/unreleased/improvements/835-msg-update-client-handler-accept-misbehaviour.md @@ -0,0 +1,3 @@ +- [ibc-core] Update `MsgUpdateClient` handler to accept misbehaviour reports via + its `client_message` field + ([\#835](https://github.com/cosmos/ibc-rs/issues/835))