From 115223f64e2f89881df7ff7cbd76a6d9ccc3006c Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 20 Apr 2023 10:06:18 -0700 Subject: [PATCH] Remove store_client_type interface --- .../592-remove-store-client-type.md | 2 ++ crates/ibc/src/core/context.rs | 11 +------ .../ics02_client/handler/create_client.rs | 3 -- crates/ibc/src/core/ics24_host/path.rs | 32 ------------------- crates/ibc/src/mock/client_state.rs | 3 -- crates/ibc/src/mock/context.rs | 29 +---------------- 6 files changed, 4 insertions(+), 76 deletions(-) create mode 100644 .changelog/unreleased/breaking-changes/592-remove-store-client-type.md diff --git a/.changelog/unreleased/breaking-changes/592-remove-store-client-type.md b/.changelog/unreleased/breaking-changes/592-remove-store-client-type.md new file mode 100644 index 000000000..9827b0bd9 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/592-remove-store-client-type.md @@ -0,0 +1,2 @@ +- Remove `store_client_type` interface as it is not included in the IBC spec anymore. + ([#592](https://github.com/cosmos/ibc-rs/issues/592)) diff --git a/crates/ibc/src/core/context.rs b/crates/ibc/src/core/context.rs index a9d4f1fe9..b35605811 100644 --- a/crates/ibc/src/core/context.rs +++ b/crates/ibc/src/core/context.rs @@ -32,7 +32,6 @@ use core::time::Duration; use ibc_proto::google::protobuf::Any; use crate::core::ics02_client::client_state::ClientState; -use crate::core::ics02_client::client_type::ClientType; use crate::core::ics02_client::consensus_state::ConsensusState; use crate::core::ics03_connection::connection::ConnectionEnd; use crate::core::ics03_connection::version::{ @@ -48,8 +47,7 @@ use crate::core::ics23_commitment::commitment::CommitmentPrefix; use crate::core::ics24_host::identifier::{ConnectionId, PortId}; use crate::core::ics24_host::path::{ AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, ClientStatePath, - ClientTypePath, CommitmentPath, ConnectionPath, ReceiptPath, SeqAckPath, SeqRecvPath, - SeqSendPath, + CommitmentPath, ConnectionPath, ReceiptPath, SeqAckPath, SeqRecvPath, SeqSendPath, }; use crate::core::ics26_routing::context::{Module, ModuleId}; use crate::core::{ @@ -439,13 +437,6 @@ pub trait ExecutionContext: ValidationContext { } } - /// Called upon successful client creation - fn store_client_type( - &mut self, - client_type_path: ClientTypePath, - client_type: ClientType, - ) -> Result<(), ContextError>; - /// Called upon successful client creation and update fn store_client_state( &mut self, diff --git a/crates/ibc/src/core/ics02_client/handler/create_client.rs b/crates/ibc/src/core/ics02_client/handler/create_client.rs index 625a346ad..40d9fee45 100644 --- a/crates/ibc/src/core/ics02_client/handler/create_client.rs +++ b/crates/ibc/src/core/ics02_client/handler/create_client.rs @@ -9,8 +9,6 @@ use crate::core::ics24_host::path::ClientConsensusStatePath; use crate::core::ics24_host::path::ClientStatePath; -use crate::core::ics24_host::path::ClientTypePath; - use crate::core::ExecutionContext; use crate::core::ValidationContext; @@ -79,7 +77,6 @@ where })?; let consensus_state = client_state.initialise(consensus_state)?; - ctx.store_client_type(ClientTypePath::new(&client_id), client_type.clone())?; ctx.store_client_state(ClientStatePath::new(&client_id), client_state.clone())?; ctx.store_consensus_state( ClientConsensusStatePath::new(&client_id, &client_state.latest_height()), diff --git a/crates/ibc/src/core/ics24_host/path.rs b/crates/ibc/src/core/ics24_host/path.rs index 8abeae066..051e1f33c 100644 --- a/crates/ibc/src/core/ics24_host/path.rs +++ b/crates/ibc/src/core/ics24_host/path.rs @@ -29,7 +29,6 @@ const UPGRADED_CLIENT_CONSENSUS_STATE: &str = "upgradedConsState"; /// The Path enum abstracts out the different sub-paths. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, From, Display)] pub enum Path { - ClientType(ClientTypePath), ClientState(ClientStatePath), ClientConsensusState(ClientConsensusStatePath), ClientConnection(ClientConnectionPath), @@ -45,16 +44,6 @@ pub enum Path { Upgrade(ClientUpgradePath), } -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] -#[display(fmt = "clients/{_0}/clientType")] -pub struct ClientTypePath(pub ClientId); - -impl ClientTypePath { - pub fn new(client_id: &ClientId) -> ClientTypePath { - ClientTypePath(client_id.clone()) - } -} - #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] #[display(fmt = "clients/{_0}/clientState")] pub struct ClientStatePath(pub ClientId); @@ -278,7 +267,6 @@ fn parse_client_paths(components: &[&str]) -> Option { if components.len() == 3 { match components[2] { - "clientType" => Some(ClientTypePath(client_id).into()), "clientState" => Some(ClientStatePath(client_id).into()), "connections" => Some(ClientConnectionPath(client_id).into()), _ => None, @@ -681,14 +669,6 @@ mod tests { #[test] fn test_parse_client_paths_fn() { - let path = "clients/07-tendermint-0/clientType"; - let components: Vec<&str> = path.split('/').collect(); - - assert_eq!( - parse_client_paths(&components), - Some(Path::ClientType(ClientTypePath(ClientId::default()))) - ); - let path = "clients/07-tendermint-0/clientState"; let components: Vec<&str> = path.split('/').collect(); @@ -710,18 +690,6 @@ mod tests { ); } - #[test] - fn client_type_path_parses() { - let path = "clients/07-tendermint-0/clientType"; - let path = Path::from_str(path); - - assert!(path.is_ok()); - assert_eq!( - path.unwrap(), - Path::ClientType(ClientTypePath(ClientId::default())) - ); - } - #[test] fn client_state_path_parses() { let path = "clients/07-tendermint-0/clientState"; diff --git a/crates/ibc/src/mock/client_state.rs b/crates/ibc/src/mock/client_state.rs index 63c0f19ce..cd0683c18 100644 --- a/crates/ibc/src/mock/client_state.rs +++ b/crates/ibc/src/mock/client_state.rs @@ -40,9 +40,6 @@ pub fn client_type() -> ClientType { /// For testing ICS02 handlers mostly, cf. `MockClientContext`. #[derive(Clone, Debug)] pub struct MockClientRecord { - /// The type of this client. - pub client_type: ClientType, - /// The client state (representing only the latest height at the moment). pub client_state: Option>, diff --git a/crates/ibc/src/mock/context.rs b/crates/ibc/src/mock/context.rs index 97d5a5046..91f7e5810 100644 --- a/crates/ibc/src/mock/context.rs +++ b/crates/ibc/src/mock/context.rs @@ -8,8 +8,7 @@ use crate::applications::transfer::PrefixedCoin; use crate::clients::ics07_tendermint::TENDERMINT_CLIENT_TYPE; use crate::core::ics24_host::path::{ AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, ClientStatePath, - ClientTypePath, CommitmentPath, ConnectionPath, ReceiptPath, SeqAckPath, SeqRecvPath, - SeqSendPath, + CommitmentPath, ConnectionPath, ReceiptPath, SeqAckPath, SeqRecvPath, SeqSendPath, }; use crate::prelude::*; @@ -262,7 +261,6 @@ impl MockContext { debug!("consensus states: {:?}", consensus_states); let client_record = MockClientRecord { - client_type, client_state, consensus_states, }; @@ -347,7 +345,6 @@ impl MockContext { debug!("consensus states: {:?}", consensus_states); let client_record = MockClientRecord { - client_type, client_state, consensus_states, }; @@ -1112,28 +1109,6 @@ impl ValidationContext for MockContext { } impl ExecutionContext for MockContext { - fn store_client_type( - &mut self, - client_type_path: ClientTypePath, - client_type: ClientType, - ) -> Result<(), ContextError> { - let mut ibc_store = self.ibc_store.lock(); - - let client_id = client_type_path.0; - let client_record = ibc_store - .clients - .entry(client_id) - .or_insert(MockClientRecord { - client_type: client_type.clone(), - consensus_states: Default::default(), - client_state: Default::default(), - }); - - client_record.client_type = client_type; - - Ok(()) - } - fn store_client_state( &mut self, client_state_path: ClientStatePath, @@ -1146,7 +1121,6 @@ impl ExecutionContext for MockContext { .clients .entry(client_id) .or_insert(MockClientRecord { - client_type: client_state.client_type(), consensus_states: Default::default(), client_state: Default::default(), }); @@ -1167,7 +1141,6 @@ impl ExecutionContext for MockContext { .clients .entry(consensus_state_path.client_id) .or_insert(MockClientRecord { - client_type: mock_client_type(), consensus_states: Default::default(), client_state: Default::default(), });