Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove store_client_type interface #642

Merged
merged 1 commit into from
Apr 24, 2023
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 @@
- Remove `store_client_type` interface as it is not included in the IBC spec anymore.
([#592](https://github.com/cosmos/ibc-rs/issues/592))
11 changes: 1 addition & 10 deletions crates/ibc/src/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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::{
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions crates/ibc/src/core/ics02_client/handler/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()),
Expand Down
32 changes: 0 additions & 32 deletions crates/ibc/src/core/ics24_host/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -278,7 +267,6 @@ fn parse_client_paths(components: &[&str]) -> Option<Path> {

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,
Expand Down Expand Up @@ -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();

Expand All @@ -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";
Expand Down
3 changes: 0 additions & 3 deletions crates/ibc/src/mock/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn ClientState>>,

Expand Down
29 changes: 1 addition & 28 deletions crates/ibc/src/mock/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -262,7 +261,6 @@ impl MockContext {
debug!("consensus states: {:?}", consensus_states);

let client_record = MockClientRecord {
client_type,
client_state,
consensus_states,
};
Expand Down Expand Up @@ -347,7 +345,6 @@ impl MockContext {
debug!("consensus states: {:?}", consensus_states);

let client_record = MockClientRecord {
client_type,
client_state,
consensus_states,
};
Expand Down Expand Up @@ -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,
Expand All @@ -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(),
});
Expand All @@ -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(),
});
Expand Down