diff --git a/ibc-eureka-core/ics04-channel/src/context.rs b/ibc-eureka-core/ics04-channel/src/context.rs index cf5ecfe46..f752dbc1e 100644 --- a/ibc-eureka-core/ics04-channel/src/context.rs +++ b/ibc-eureka-core/ics04-channel/src/context.rs @@ -3,10 +3,9 @@ use ibc_eureka_core_channel_types::channel::ChannelEnd; use ibc_eureka_core_channel_types::commitment::PacketCommitment; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::types::ConnectionEnd; use ibc_eureka_core_handler_types::events::IbcEvent; use ibc_eureka_core_host::types::error::HostError; -use ibc_eureka_core_host::types::identifiers::{ConnectionId, Sequence}; +use ibc_eureka_core_host::types::identifiers::Sequence; use ibc_eureka_core_host::types::path::{ChannelEndPath, CommitmentPath, SeqSendPath}; use ibc_eureka_core_host::{ExecutionContext, ValidationContext}; use ibc_primitives::prelude::*; @@ -21,9 +20,6 @@ pub trait SendPacketValidationContext { /// Returns the ChannelEnd for the given `port_id` and `chan_id`. fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result; - /// Returns the ConnectionState for the given identifier `connection_id`. - fn connection_end(&self, connection_id: &ConnectionId) -> Result; - fn get_next_sequence_send(&self, seq_send_path: &SeqSendPath) -> Result; } @@ -41,10 +37,6 @@ where self.channel_end(channel_end_path) } - fn connection_end(&self, connection_id: &ConnectionId) -> Result { - self.connection_end(connection_id) - } - fn get_next_sequence_send(&self, seq_send_path: &SeqSendPath) -> Result { self.get_next_sequence_send(seq_send_path) } diff --git a/ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs b/ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs index e14618cb3..563de668d 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs @@ -6,8 +6,6 @@ use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::events::AcknowledgePacket; use ibc_eureka_core_channel_types::msgs::MsgAcknowledgement; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::delay::verify_conn_delay_passed; -use ibc_eureka_core_connection::types::State as ConnectionState; use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent}; use ibc_eureka_core_host::types::path::{ AckPath, ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, SeqAckPath, @@ -45,13 +43,11 @@ where let chan_end_path_on_a = ChannelEndPath::new(port_id_on_a, channel_id_on_a); let chan_end_on_a = ctx_a.channel_end(&chan_end_path_on_a)?; - let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; // In all cases, this event is emitted let event = IbcEvent::AcknowledgePacket(AcknowledgePacket::new( msg.packet.clone(), chan_end_on_a.ordering, - conn_id_on_a.clone(), )); ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; ctx_a.emit_ibc_event(event)?; @@ -112,9 +108,9 @@ where let packet = &msg.packet; let payload = &packet.payloads[0]; - let port_id_on_a = &payload.header.source_port.1; + let (prefix_on_a, port_id_on_a) = &payload.header.source_port; let channel_id_on_a = &packet.header.source_client; - let port_id_on_b = &payload.header.target_port.1; + let (_, port_id_on_b) = &payload.header.target_port; let channel_id_on_b = &packet.header.target_client; let seq_on_a = &packet.header.seq_on_a; let data = &payload.data; @@ -128,11 +124,6 @@ where chan_end_on_a.verify_counterparty_matches(&counterparty)?; - let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; - let conn_end_on_a = ctx_a.connection_end(conn_id_on_a)?; - - conn_end_on_a.verify_state_matches(&ConnectionState::Open)?; - let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a); // Verify packet commitment @@ -170,7 +161,8 @@ where // Verify proofs { - let client_id_on_a = conn_end_on_a.client_id(); + // TODO(rano): avoid a vs b confusion + let client_id_on_a = channel_id_on_b.as_ref(); let client_val_ctx_a = ctx_a.get_client_validation_context(); @@ -192,11 +184,9 @@ where let ack_commitment = compute_ack_commitment(&msg.acknowledgement); let ack_path_on_b = AckPath::new(port_id_on_b, channel_id_on_b, *seq_on_a); - verify_conn_delay_passed(ctx_a, msg.proof_height_on_b, &conn_end_on_a)?; - // Verify the proof for the packet against the chain store. client_state_of_b_on_a.verify_membership( - conn_end_on_a.counterparty().prefix(), + prefix_on_a, &msg.proof_acked_on_b, consensus_state_of_b_on_a.root(), Path::Ack(ack_path_on_b), diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_close_confirm.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_close_confirm.rs index 04c694b2c..a0ce1113b 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_close_confirm.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_close_confirm.rs @@ -7,8 +7,6 @@ use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::events::CloseConfirm; use ibc_eureka_core_channel_types::msgs::MsgChannelCloseConfirm; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::types::error::ConnectionError; -use ibc_eureka_core_connection::types::State as ConnectionState; use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent}; use ibc_eureka_core_host::types::path::{ChannelEndPath, ClientConsensusStatePath, Path}; use ibc_eureka_core_host::{ExecutionContext, ValidationContext}; @@ -64,14 +62,12 @@ where .channel_id .clone() .ok_or(ChannelError::MissingCounterparty)?; - let conn_id_on_b = chan_end_on_b.connection_hops[0].clone(); IbcEvent::CloseConfirmChannel(CloseConfirm::new( msg.port_id_on_b.clone(), msg.chan_id_on_b.clone(), port_id_on_a, chan_id_on_a, - conn_id_on_b, )) }; ctx_b.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -102,10 +98,6 @@ where // Validate that the channel end is in a state where it can be closed. chan_end_on_b.verify_not_closed()?; - let conn_end_on_b = ctx_b.connection_end(&chan_end_on_b.connection_hops()[0])?; - - conn_end_on_b.verify_state_matches(&ConnectionState::Open)?; - // Verify proofs { let client_id_on_b = conn_end_on_b.client_id(); @@ -142,7 +134,6 @@ where ChannelState::Closed, *chan_end_on_b.ordering(), Counterparty::new(msg.port_id_on_b.clone(), Some(msg.chan_id_on_b.clone())), - vec![conn_id_on_a.clone()], chan_end_on_b.version().clone(), )?; let chan_end_path_on_a = ChannelEndPath::new(port_id_on_a, chan_id_on_a); diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_close_init.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_close_init.rs index acee3b3e1..057b5312f 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_close_init.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_close_init.rs @@ -4,7 +4,6 @@ use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::events::CloseInit; use ibc_eureka_core_channel_types::msgs::MsgChannelCloseInit; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::types::State as ConnectionState; use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent}; use ibc_eureka_core_host::types::path::ChannelEndPath; use ibc_eureka_core_host::{ExecutionContext, ValidationContext}; @@ -60,14 +59,12 @@ where .channel_id .clone() .ok_or(ChannelError::MissingCounterparty)?; - let conn_id_on_a = chan_end_on_a.connection_hops[0].clone(); IbcEvent::CloseInitChannel(CloseInit::new( msg.port_id_on_a.clone(), msg.chan_id_on_a.clone(), port_id_on_b, chan_id_on_b, - conn_id_on_a, )) }; ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -97,13 +94,6 @@ where // Validate that the channel end is in a state where it can be closed. chan_end_on_a.verify_not_closed()?; - // An OPEN IBC connection running on the local (host) chain should exist. - chan_end_on_a.verify_connection_hops_length()?; - - let conn_end_on_a = ctx_a.connection_end(&chan_end_on_a.connection_hops()[0])?; - - conn_end_on_a.verify_state_matches(&ConnectionState::Open)?; - let client_id_on_a = conn_end_on_a.client_id(); let client_val_ctx_a = ctx_a.get_client_validation_context(); diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_open_ack.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_open_ack.rs index 729cd27d7..e85f0347f 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_open_ack.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_open_ack.rs @@ -70,7 +70,6 @@ where msg.chan_id_on_a.clone(), port_id_on_b, msg.chan_id_on_b, - conn_id_on_a, )) }; ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -100,13 +99,6 @@ where // Validate that the channel end is in a state where it can be ack. chan_end_on_a.verify_state_matches(&ChannelState::Init)?; - // An OPEN IBC connection running on the local (host) chain should exist. - chan_end_on_a.verify_connection_hops_length()?; - - let conn_end_on_a = ctx_a.connection_end(&chan_end_on_a.connection_hops()[0])?; - - conn_end_on_a.verify_state_matches(&ConnectionState::Open)?; - // Verify proofs { let client_id_on_a = conn_end_on_a.client_id(); @@ -139,7 +131,6 @@ where // fine to use A's ordering here *chan_end_on_a.ordering(), Counterparty::new(msg.port_id_on_a.clone(), Some(msg.chan_id_on_a.clone())), - vec![conn_id_on_b.clone()], msg.version_on_b.clone(), )?; let chan_end_path_on_b = ChannelEndPath::new(port_id_on_b, &msg.chan_id_on_b); diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_open_confirm.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_open_confirm.rs index 4347c3bb0..c7f1ec73e 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_open_confirm.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_open_confirm.rs @@ -71,7 +71,6 @@ where msg.chan_id_on_b.clone(), port_id_on_a, chan_id_on_a, - conn_id_on_b, )); ctx_b.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; ctx_b.emit_ibc_event(core_event)?; @@ -142,7 +141,6 @@ where ChannelState::Open, *chan_end_on_b.ordering(), Counterparty::new(msg.port_id_on_b.clone(), Some(msg.chan_id_on_b.clone())), - vec![conn_id_on_a.clone()], chan_end_on_b.version.clone(), )?; let chan_end_path_on_a = ChannelEndPath::new(port_id_on_a, chan_id_on_a); diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_open_init.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_open_init.rs index f6ba84811..ec8e22467 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_open_init.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_open_init.rs @@ -28,7 +28,6 @@ where module.on_chan_open_init_validate( msg.ordering, - &msg.connection_hops_on_a, &msg.port_id_on_a, &chan_id_on_a, &Counterparty::new(msg.port_id_on_b.clone(), None), @@ -50,7 +49,6 @@ where let chan_id_on_a = ChannelId::from_str("00-dummy-0")?; let (extras, version) = module.on_chan_open_init_execute( msg.ordering, - &msg.connection_hops_on_a, &msg.port_id_on_a, &chan_id_on_a, &Counterparty::new(msg.port_id_on_b.clone(), None), @@ -65,7 +63,6 @@ where State::Init, msg.ordering, Counterparty::new(msg.port_id_on_b.clone(), None), - msg.connection_hops_on_a.clone(), msg.version_proposal.clone(), )?; let chan_end_path_on_a = ChannelEndPath::new(&msg.port_id_on_a, &chan_id_on_a); @@ -93,7 +90,6 @@ where msg.port_id_on_a.clone(), chan_id_on_a.clone(), msg.port_id_on_b, - conn_id_on_a, version, )); ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -117,10 +113,6 @@ where { ctx_a.validate_message_signer(&msg.signer)?; - msg.verify_connection_hops_length()?; - // An IBC connection running on the local (host) chain should exist. - let conn_end_on_a = ctx_a.connection_end(&msg.connection_hops_on_a[0])?; - // Note: Not needed check if the connection end is OPEN. Optimistic channel handshake is allowed. let client_id_on_a = conn_end_on_a.client_id(); @@ -131,9 +123,5 @@ where .status(ctx_a.get_client_validation_context(), client_id_on_a)? .verify_is_active()?; - let conn_version = conn_end_on_a.versions(); - - conn_version[0].verify_feature_supported(msg.ordering.to_string())?; - Ok(()) } diff --git a/ibc-eureka-core/ics04-channel/src/handler/chan_open_try.rs b/ibc-eureka-core/ics04-channel/src/handler/chan_open_try.rs index b6c2dec68..bbe453c14 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/chan_open_try.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/chan_open_try.rs @@ -34,7 +34,6 @@ where module.on_chan_open_try_validate( msg.ordering, - &msg.connection_hops_on_b, &msg.port_id_on_b, &chan_id_on_b, &Counterparty::new(msg.port_id_on_a.clone(), Some(msg.chan_id_on_a.clone())), @@ -56,22 +55,18 @@ where let chan_id_on_b = ChannelId::from_str("00-dummy-0")?; let (extras, version) = module.on_chan_open_try_execute( msg.ordering, - &msg.connection_hops_on_b, &msg.port_id_on_b, &chan_id_on_b, &Counterparty::new(msg.port_id_on_a.clone(), Some(msg.chan_id_on_a.clone())), &msg.version_supported_on_a, )?; - let conn_id_on_b = msg.connection_hops_on_b[0].clone(); - // state changes { let chan_end_on_b = ChannelEnd::new( ChannelState::TryOpen, msg.ordering, Counterparty::new(msg.port_id_on_a.clone(), Some(msg.chan_id_on_a.clone())), - msg.connection_hops_on_b.clone(), version.clone(), )?; @@ -101,7 +96,6 @@ where chan_id_on_b.clone(), msg.port_id_on_a.clone(), msg.chan_id_on_a.clone(), - conn_id_on_b, version, )); ctx_b.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -125,16 +119,6 @@ where { ctx_b.validate_message_signer(&msg.signer)?; - msg.verify_connection_hops_length()?; - - let conn_end_on_b = ctx_b.connection_end(&msg.connection_hops_on_b[0])?; - - conn_end_on_b.verify_state_matches(&ConnectionState::Open)?; - - let conn_version = conn_end_on_b.versions(); - - conn_version[0].verify_feature_supported(msg.ordering.to_string())?; - // Verify proofs { let client_id_on_b = conn_end_on_b.client_id(); @@ -166,7 +150,6 @@ where ChannelState::Init, msg.ordering, Counterparty::new(msg.port_id_on_b.clone(), None), - vec![conn_id_on_a.clone()], msg.version_supported_on_a.clone(), )?; let chan_end_path_on_a = ChannelEndPath::new(&port_id_on_a, &chan_id_on_a); diff --git a/ibc-eureka-core/ics04-channel/src/handler/recv_packet.rs b/ibc-eureka-core/ics04-channel/src/handler/recv_packet.rs index 4cf70bf11..b652e0d0e 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/recv_packet.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/recv_packet.rs @@ -7,8 +7,6 @@ use ibc_eureka_core_channel_types::events::{ReceivePacket, WriteAcknowledgement} use ibc_eureka_core_channel_types::msgs::MsgRecvPacket; use ibc_eureka_core_channel_types::packet::Receipt; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::delay::verify_conn_delay_passed; -use ibc_eureka_core_connection::types::State as ConnectionState; use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent}; use ibc_eureka_core_host::types::path::{ AckPath, ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, ReceiptPath, @@ -107,19 +105,14 @@ where ctx_b.log_message("success: packet receive".to_string())?; ctx_b.log_message("success: packet write acknowledgement".to_string())?; - let conn_id_on_b = &chan_end_on_b.connection_hops()[0]; let event = IbcEvent::ReceivePacket(ReceivePacket::new( msg.packet.clone(), chan_end_on_b.ordering, - conn_id_on_b.clone(), )); ctx_b.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; ctx_b.emit_ibc_event(event)?; - let event = IbcEvent::WriteAcknowledgement(WriteAcknowledgement::new( - msg.packet, - acknowledgement, - conn_id_on_b.clone(), - )); + let event = + IbcEvent::WriteAcknowledgement(WriteAcknowledgement::new(msg.packet, acknowledgement)); ctx_b.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; ctx_b.emit_ibc_event(event)?; @@ -144,9 +137,9 @@ where let packet = &msg.packet; let payload = &packet.payloads[0]; - let port_id_on_a = &payload.header.source_port.1; + let (_, port_id_on_a) = &payload.header.source_port; let channel_id_on_a = &packet.header.source_client; - let port_id_on_b = &payload.header.target_port.1; + let (prefix_on_b, port_id_on_b) = &payload.header.target_port; let channel_id_on_b = &packet.header.target_client; let seq_on_a = &packet.header.seq_on_a; let data = &payload.data; @@ -160,11 +153,6 @@ where chan_end_on_b.verify_counterparty_matches(&counterparty)?; - let conn_id_on_b = &chan_end_on_b.connection_hops()[0]; - let conn_end_on_b = ctx_b.connection_end(conn_id_on_b)?; - - conn_end_on_b.verify_state_matches(&ConnectionState::Open)?; - let latest_height = ctx_b.host_height()?; if packet.header.timeout_height_on_b.has_expired(latest_height) { return Err(ChannelError::InsufficientPacketHeight { @@ -184,7 +172,7 @@ where // Verify proofs { - let client_id_on_b = conn_end_on_b.client_id(); + let client_id_on_b = channel_id_on_a.as_ref(); let client_val_ctx_b = ctx_b.get_client_validation_context(); let client_state_of_a_on_b = client_val_ctx_b.client_state(client_id_on_b)?; @@ -210,11 +198,9 @@ where ); let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a); - verify_conn_delay_passed(ctx_b, msg.proof_height_on_a, &conn_end_on_b)?; - // Verify the proof for the packet against the chain store. client_state_of_a_on_b.verify_membership( - conn_end_on_b.counterparty().prefix(), + prefix_on_b, &msg.proof_commitment_on_a, consensus_state_of_a_on_b.root(), Path::Commitment(commitment_path_on_a), diff --git a/ibc-eureka-core/ics04-channel/src/handler/send_packet.rs b/ibc-eureka-core/ics04-channel/src/handler/send_packet.rs index 1415ca2b1..3c7f270e1 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/send_packet.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/send_packet.rs @@ -52,11 +52,7 @@ pub fn send_packet_validate( chan_end_on_a.verify_counterparty_matches(&counterparty)?; - let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; - - let conn_end_on_a = ctx_a.connection_end(conn_id_on_a)?; - - let client_id_on_a = conn_end_on_a.client_id(); + let client_id_on_a = channel_id_on_b.as_ref(); let client_val_ctx_a = ctx_a.get_client_validation_context(); @@ -139,14 +135,9 @@ pub fn send_packet_execute( { let chan_end_path_on_a = ChannelEndPath::new(port_id_on_a, channel_id_on_a); let chan_end_on_a = ctx_a.channel_end(&chan_end_path_on_a)?; - let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; ctx_a.log_message("success: packet send".to_string())?; - let event = IbcEvent::SendPacket(SendPacket::new( - packet, - chan_end_on_a.ordering, - conn_id_on_a.clone(), - )); + let event = IbcEvent::SendPacket(SendPacket::new(packet, chan_end_on_a.ordering)); ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; ctx_a.emit_ibc_event(event)?; } diff --git a/ibc-eureka-core/ics04-channel/src/handler/timeout.rs b/ibc-eureka-core/ics04-channel/src/handler/timeout.rs index 3ac0190e8..b137399a8 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/timeout.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/timeout.rs @@ -4,7 +4,6 @@ use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::events::{ChannelClosed, TimeoutPacket}; use ibc_eureka_core_channel_types::msgs::{MsgTimeout, MsgTimeoutOnClose}; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::delay::verify_conn_delay_passed; use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent}; use ibc_eureka_core_host::types::path::{ ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, ReceiptPath, SeqRecvPath, @@ -103,14 +102,11 @@ where ctx_a.log_message("success: packet timeout".to_string())?; if let Order::Ordered = chan_end_on_a.ordering { - let conn_id_on_a = chan_end_on_a.connection_hops()[0].clone(); - let event = IbcEvent::ChannelClosed(ChannelClosed::new( port_id_on_a.clone(), channel_id_on_a.clone(), chan_end_on_a.counterparty().port_id.clone(), chan_end_on_a.counterparty().channel_id.clone(), - conn_id_on_a, chan_end_on_a.ordering, )); ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?; @@ -138,9 +134,9 @@ where let packet = &msg.packet; let payload = &packet.payloads[0]; - let port_id_on_a = &payload.header.source_port.1; + let (_, port_id_on_a) = &payload.header.source_port; let channel_id_on_a = &packet.header.source_client; - let port_id_on_b = &payload.header.target_port.1; + let (prefix_on_a, port_id_on_b) = &payload.header.target_port; let channel_id_on_b = &packet.header.target_client; let seq_on_a = &packet.header.seq_on_a; let data = &payload.data; @@ -153,9 +149,6 @@ where chan_end_on_a.verify_counterparty_matches(&counterparty)?; - let conn_id_on_a = chan_end_on_a.connection_hops()[0].clone(); - let conn_end_on_a = ctx_a.connection_end(&conn_id_on_a)?; - //verify packet commitment let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a); let Ok(commitment_on_a) = ctx_a.get_packet_commitment(&commitment_path_on_a) else { @@ -181,7 +174,7 @@ where // Verify proofs { - let client_id_on_a = conn_end_on_a.client_id(); + let client_id_on_a = channel_id_on_b.as_ref(); let client_val_ctx_a = ctx_a.get_client_validation_context(); let client_state_of_b_on_a = client_val_ctx_a.client_state(client_id_on_a)?; @@ -210,8 +203,6 @@ where }); } - verify_conn_delay_passed(ctx_a, msg.proof_height_on_b, &conn_end_on_a)?; - let next_seq_recv_verification_result = match chan_end_on_a.ordering { Order::Ordered => { if seq_on_a < &msg.next_seq_recv_on_b { @@ -223,7 +214,7 @@ where let seq_recv_path_on_b = SeqRecvPath::new(port_id_on_b, channel_id_on_b); client_state_of_b_on_a.verify_membership( - conn_end_on_a.counterparty().prefix(), + prefix_on_a, &msg.proof_unreceived_on_b, consensus_state_of_b_on_a.root(), Path::SeqRecv(seq_recv_path_on_b), @@ -234,7 +225,7 @@ where let receipt_path_on_b = ReceiptPath::new(port_id_on_b, channel_id_on_b, *seq_on_a); client_state_of_b_on_a.verify_non_membership( - conn_end_on_a.counterparty().prefix(), + prefix_on_a, &msg.proof_unreceived_on_b, consensus_state_of_b_on_a.root(), Path::Receipt(receipt_path_on_b), diff --git a/ibc-eureka-core/ics04-channel/src/handler/timeout_on_close.rs b/ibc-eureka-core/ics04-channel/src/handler/timeout_on_close.rs index 353e2b44b..0fa707416 100644 --- a/ibc-eureka-core/ics04-channel/src/handler/timeout_on_close.rs +++ b/ibc-eureka-core/ics04-channel/src/handler/timeout_on_close.rs @@ -3,8 +3,6 @@ use ibc_eureka_core_channel_types::commitment::compute_packet_commitment; use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::msgs::MsgTimeoutOnClose; use ibc_eureka_core_client::context::prelude::*; -use ibc_eureka_core_connection::delay::verify_conn_delay_passed; -use ibc_eureka_core_connection::types::error::ConnectionError; use ibc_eureka_core_host::types::path::{ ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, ReceiptPath, SeqRecvPath, }; @@ -21,9 +19,9 @@ where let packet = &msg.packet; let payload = &packet.payloads[0]; - let port_id_on_a = &payload.header.source_port.1; + let (prefix_on_a, port_id_on_a) = &payload.header.source_port; let channel_id_on_a = &packet.header.source_client; - let port_id_on_b = &payload.header.target_port.1; + let (_, port_id_on_b) = &payload.header.target_port; let channel_id_on_b = &packet.header.target_client; let seq_on_a = &packet.header.seq_on_a; let data = &payload.data; @@ -58,12 +56,9 @@ where }); } - let conn_id_on_a = chan_end_on_a.connection_hops()[0].clone(); - let conn_end_on_a = ctx_a.connection_end(&conn_id_on_a)?; - // Verify proofs { - let client_id_on_a = conn_end_on_a.client_id(); + let client_id_on_a = channel_id_on_b.as_ref(); let client_val_ctx_a = ctx_a.get_client_validation_context(); let client_state_of_b_on_a = client_val_ctx_a.client_state(client_id_on_a)?; @@ -80,24 +75,17 @@ where ); let consensus_state_of_b_on_a = client_val_ctx_a.consensus_state(&client_cons_state_path_on_a)?; - let prefix_on_b = conn_end_on_a.counterparty().prefix(); let port_id_on_b = chan_end_on_a.counterparty().port_id.clone(); let channel_id_on_b = chan_end_on_a .counterparty() .channel_id() .ok_or(ChannelError::MissingCounterparty)?; - let conn_id_on_b = conn_end_on_a - .counterparty() - .connection_id() - .ok_or(ConnectionError::MissingCounterparty)?; - let expected_conn_hops_on_b = vec![conn_id_on_b.clone()]; let expected_counterparty = Counterparty::new(port_id_on_a.clone(), Some(channel_id_on_a.clone())); let expected_chan_end_on_b = ChannelEnd::new( State::Closed, *chan_end_on_a.ordering(), expected_counterparty, - expected_conn_hops_on_b, chan_end_on_a.version().clone(), )?; @@ -106,15 +94,13 @@ where // Verify the proof for the channel state against the expected channel end. // A counterparty channel id of None in not possible, and is checked by validate_basic in msg. client_state_of_b_on_a.verify_membership( - prefix_on_b, + prefix_on_a, &msg.proof_close_on_b, consensus_state_of_b_on_a.root(), Path::ChannelEnd(chan_end_path_on_b), expected_chan_end_on_b.encode_vec(), )?; - verify_conn_delay_passed(ctx_a, msg.proof_height_on_b, &conn_end_on_a)?; - let next_seq_recv_verification_result = match chan_end_on_a.ordering { Order::Ordered => { if seq_on_a < &msg.next_seq_recv_on_b { @@ -126,7 +112,7 @@ where let seq_recv_path_on_b = SeqRecvPath::new(&port_id_on_b, channel_id_on_b); client_state_of_b_on_a.verify_membership( - conn_end_on_a.counterparty().prefix(), + prefix_on_a, &msg.proof_unreceived_on_b, consensus_state_of_b_on_a.root(), Path::SeqRecv(seq_recv_path_on_b), @@ -137,7 +123,7 @@ where let receipt_path_on_b = ReceiptPath::new(&port_id_on_b, channel_id_on_b, *seq_on_a); client_state_of_b_on_a.verify_non_membership( - conn_end_on_a.counterparty().prefix(), + prefix_on_a, &msg.proof_unreceived_on_b, consensus_state_of_b_on_a.root(), Path::Receipt(receipt_path_on_b), diff --git a/ibc-eureka-core/ics04-channel/types/src/channel.rs b/ibc-eureka-core/ics04-channel/types/src/channel.rs index 5aa0208b2..1c60dc3e9 100644 --- a/ibc-eureka-core/ics04-channel/types/src/channel.rs +++ b/ibc-eureka-core/ics04-channel/types/src/channel.rs @@ -4,9 +4,8 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use core::str::FromStr; use ibc_eureka_core_host_types::error::DecodingError; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId}; use ibc_primitives::prelude::*; -use ibc_primitives::utils::PrettySlice; use ibc_proto::ibc::core::channel::v1::{ Channel as RawChannel, Counterparty as RawCounterparty, IdentifiedChannel as RawIdentifiedChannel, @@ -83,12 +82,7 @@ impl From for RawIdentifiedChannel { state: value.channel_end.state as i32, ordering: value.channel_end.ordering as i32, counterparty: Some(value.channel_end.counterparty().clone().into()), - connection_hops: value - .channel_end - .connection_hops - .iter() - .map(|v| v.as_str().to_string()) - .collect(), + connection_hops: vec![], version: value.channel_end.version.to_string(), port_id: value.port_id.to_string(), channel_id: value.channel_id.to_string(), @@ -117,7 +111,6 @@ pub struct ChannelEnd { pub state: State, pub ordering: Order, pub remote: Counterparty, - pub connection_hops: Vec, pub version: Version, } @@ -125,8 +118,8 @@ impl Display for ChannelEnd { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { write!( f, - "ChannelEnd {{ state: {}, ordering: {}, remote: {}, connection_hops: {}, version: {} }}", - self.state, self.ordering, self.remote, PrettySlice(&self.connection_hops), self.version + "ChannelEnd {{ state: {}, ordering: {}, remote: {}, version: {} }}", + self.state, self.ordering, self.remote, self.version ) } } @@ -148,16 +141,9 @@ impl TryFrom for ChannelEnd { .ok_or(DecodingError::missing_raw_data("channel counterparty"))? .try_into()?; - // Parse each item in connection_hops into a ConnectionId. - let connection_hops = value - .connection_hops - .into_iter() - .map(|conn_id| ConnectionId::from_str(conn_id.as_str())) - .collect::, _>>()?; - let version = value.version.into(); - let channel = ChannelEnd::new(chan_state, chan_ordering, remote, connection_hops, version) + let channel = ChannelEnd::new(chan_state, chan_ordering, remote, version) .map_err(|e| DecodingError::invalid_raw_data(format!("channel end: {e}")))?; Ok(channel) @@ -170,11 +156,7 @@ impl From for RawChannel { state: value.state as i32, ordering: value.ordering as i32, counterparty: Some(value.counterparty().clone().into()), - connection_hops: value - .connection_hops - .iter() - .map(|v| v.as_str().to_string()) - .collect(), + connection_hops: vec![], version: value.version.to_string(), upgrade_sequence: 0, } @@ -191,14 +173,12 @@ impl ChannelEnd { state: State, ordering: Order, remote: Counterparty, - connection_hops: Vec, version: Version, ) -> Self { Self { state, ordering, remote, - connection_hops, version, } } @@ -208,11 +188,9 @@ impl ChannelEnd { state: State, ordering: Order, remote: Counterparty, - connection_hops: Vec, version: Version, ) -> Result { - let channel_end = - Self::new_without_validation(state, ordering, remote, connection_hops, version); + let channel_end = Self::new_without_validation(state, ordering, remote, version); channel_end.validate_basic()?; Ok(channel_end) } @@ -247,10 +225,6 @@ impl ChannelEnd { &self.remote } - pub fn connection_hops(&self) -> &Vec { - &self.connection_hops - } - pub fn version(&self) -> &Version { &self.version } @@ -304,10 +278,6 @@ impl ChannelEnd { self.ordering.eq(other) } - pub fn connection_hops_matches(&self, other: &Vec) -> bool { - self.connection_hops.eq(other) - } - /// Checks if the counterparty of this channel end matches with an expected counterparty. pub fn verify_counterparty_matches(&self, expected: &Counterparty) -> Result<(), ChannelError> { if !self.counterparty().eq(expected) { @@ -319,32 +289,11 @@ impl ChannelEnd { Ok(()) } - /// Checks if the `connection_hops` has a length of `expected`. - /// - /// Note: The current IBC version only supports one connection hop. - pub fn verify_connection_hops_length(&self) -> Result<(), ChannelError> { - verify_connection_hops_length(&self.connection_hops, 1) - } - pub fn version_matches(&self, other: &Version) -> bool { self.version().eq(other) } } -/// Checks if the `connection_hops` has a length of `expected`. -pub(crate) fn verify_connection_hops_length( - connection_hops: &[ConnectionId], - expected: u64, -) -> Result<(), ChannelError> { - if connection_hops.len() as u64 != expected { - return Err(ChannelError::InvalidConnectionHopsLength { - expected, - actual: connection_hops.len() as u64, - }); - } - Ok(()) -} - #[cfg_attr( feature = "parity-scale-codec", derive( diff --git a/ibc-eureka-core/ics04-channel/types/src/error.rs b/ibc-eureka-core/ics04-channel/types/src/error.rs index 7792494a2..b1d81600d 100644 --- a/ibc-eureka-core/ics04-channel/types/src/error.rs +++ b/ibc-eureka-core/ics04-channel/types/src/error.rs @@ -3,7 +3,6 @@ use displaydoc::Display; use ibc_eureka_core_client_types::error::ClientError; use ibc_eureka_core_client_types::Height; -use ibc_eureka_core_connection_types::error::ConnectionError; use ibc_eureka_core_host_types::error::{DecodingError, HostError, IdentifierError}; use ibc_eureka_core_host_types::identifiers::Sequence; use ibc_primitives::prelude::*; @@ -24,8 +23,6 @@ pub enum ChannelError { Host(HostError), /// client error: {0} Client(ClientError), - /// connection error: {0} - Connection(ConnectionError), /// timestamp error: {0} Timestamp(TimestampError), /// packet acknowledgment for sequence `{0}` already exists @@ -87,7 +84,6 @@ impl std::error::Error for ChannelError { match &self { Self::Decoding(e) => Some(e), Self::Client(e) => Some(e), - Self::Connection(e) => Some(e), Self::Host(e) => Some(e), Self::Timestamp(e) => Some(e), _ => None, diff --git a/ibc-eureka-core/ics04-channel/types/src/events/channel_attributes.rs b/ibc-eureka-core/ics04-channel/types/src/events/channel_attributes.rs index b8b993be8..cc6cfa5e2 100644 --- a/ibc-eureka-core/ics04-channel/types/src/events/channel_attributes.rs +++ b/ibc-eureka-core/ics04-channel/types/src/events/channel_attributes.rs @@ -1,12 +1,12 @@ //! This module holds all the abci event attributes for IBC events emitted //! during the channel handshake. use derive_more::From; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId}; use tendermint::abci; use crate::Version; -const CONNECTION_ID_ATTRIBUTE_KEY: &str = "connection_id"; +// const CONNECTION_ID_ATTRIBUTE_KEY: &str = "connection_id"; const CHANNEL_ID_ATTRIBUTE_KEY: &str = "channel_id"; const PORT_ID_ATTRIBUTE_KEY: &str = "port_id"; /// This attribute key is public so that OpenInit can use it to convert itself @@ -123,30 +123,6 @@ impl AsRef for CounterpartyChannelIdAttribute { } } -#[cfg_attr( - feature = "parity-scale-codec", - derive( - parity_scale_codec::Encode, - parity_scale_codec::Decode, - scale_info::TypeInfo - ) -)] -#[cfg_attr( - feature = "borsh", - derive(borsh::BorshSerialize, borsh::BorshDeserialize) -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Clone, Debug, From, PartialEq, Eq)] -pub struct ConnectionIdAttribute { - pub connection_id: ConnectionId, -} - -impl From for abci::EventAttribute { - fn from(attr: ConnectionIdAttribute) -> Self { - (CONNECTION_ID_ATTRIBUTE_KEY, attr.connection_id.as_str()).into() - } -} - #[cfg_attr( feature = "parity-scale-codec", derive( diff --git a/ibc-eureka-core/ics04-channel/types/src/events/mod.rs b/ibc-eureka-core/ics04-channel/types/src/events/mod.rs index 252a76f73..3748bb028 100644 --- a/ibc-eureka-core/ics04-channel/types/src/events/mod.rs +++ b/ibc-eureka-core/ics04-channel/types/src/events/mod.rs @@ -4,19 +4,18 @@ mod channel_attributes; mod packet_attributes; use ibc_eureka_core_host_types::error::DecodingError; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId, Sequence}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId, Sequence}; use ibc_primitives::prelude::*; use tendermint::abci; use self::channel_attributes::{ - ChannelIdAttribute, ConnectionIdAttribute, CounterpartyChannelIdAttribute, - CounterpartyPortIdAttribute, PortIdAttribute, VersionAttribute, - COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, + ChannelIdAttribute, CounterpartyChannelIdAttribute, CounterpartyPortIdAttribute, + PortIdAttribute, VersionAttribute, COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, }; use self::packet_attributes::{ AcknowledgementAttribute, ChannelOrderingAttribute, DstChannelIdAttribute, DstPortIdAttribute, - PacketConnectionIdAttribute, PacketDataAttribute, SequenceAttribute, SrcChannelIdAttribute, - SrcPortIdAttribute, TimeoutHeightAttribute, TimeoutTimestampAttribute, + PacketDataAttribute, SequenceAttribute, SrcChannelIdAttribute, SrcPortIdAttribute, + TimeoutHeightAttribute, TimeoutTimestampAttribute, }; use super::acknowledgement::Acknowledgement; use super::channel::Order; @@ -60,7 +59,6 @@ pub struct OpenInit { port_id_attr_on_a: PortIdAttribute, chan_id_attr_on_a: ChannelIdAttribute, port_id_attr_on_b: CounterpartyPortIdAttribute, - conn_id_attr_on_a: ConnectionIdAttribute, version_attr_on_a: VersionAttribute, } @@ -69,14 +67,12 @@ impl OpenInit { port_id_on_a: PortId, chan_id_on_a: ChannelId, port_id_on_b: PortId, - conn_id_on_a: ConnectionId, version_on_a: Version, ) -> Self { Self { port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), port_id_attr_on_b: port_id_on_b.into(), - conn_id_attr_on_a: conn_id_on_a.into(), version_attr_on_a: version_on_a.into(), } } @@ -89,9 +85,6 @@ impl OpenInit { pub fn port_id_on_b(&self) -> &PortId { &self.port_id_attr_on_b.counterparty_port_id } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } pub fn version_on_a(&self) -> &Version { &self.version_attr_on_a.version } @@ -110,7 +103,6 @@ impl From for abci::Event { o.chan_id_attr_on_a.into(), o.port_id_attr_on_b.into(), (COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, "").into(), - o.conn_id_attr_on_a.into(), o.version_attr_on_a.into(), ], } @@ -136,7 +128,6 @@ pub struct OpenTry { chan_id_attr_on_b: ChannelIdAttribute, port_id_attr_on_a: CounterpartyPortIdAttribute, chan_id_attr_on_a: CounterpartyChannelIdAttribute, - conn_id_attr_on_b: ConnectionIdAttribute, version_attr_on_b: VersionAttribute, } @@ -146,7 +137,6 @@ impl OpenTry { chan_id_on_b: ChannelId, port_id_on_a: PortId, chan_id_on_a: ChannelId, - conn_id_on_b: ConnectionId, version_on_b: Version, ) -> Self { Self { @@ -154,7 +144,6 @@ impl OpenTry { chan_id_attr_on_b: chan_id_on_b.into(), port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), - conn_id_attr_on_b: conn_id_on_b.into(), version_attr_on_b: version_on_b.into(), } } @@ -170,9 +159,6 @@ impl OpenTry { pub fn chan_id_on_a(&self) -> &ChannelId { &self.chan_id_attr_on_a.counterparty_channel_id } - pub fn conn_id_on_b(&self) -> &ConnectionId { - &self.conn_id_attr_on_b.connection_id - } pub fn version_on_b(&self) -> &Version { &self.version_attr_on_b.version } @@ -191,7 +177,6 @@ impl From for abci::Event { o.chan_id_attr_on_b.into(), o.port_id_attr_on_a.into(), o.chan_id_attr_on_a.into(), - o.conn_id_attr_on_b.into(), o.version_attr_on_b.into(), ], } @@ -217,7 +202,6 @@ pub struct OpenAck { chan_id_attr_on_a: ChannelIdAttribute, port_id_attr_on_b: CounterpartyPortIdAttribute, chan_id_attr_on_b: CounterpartyChannelIdAttribute, - conn_id_attr_on_a: ConnectionIdAttribute, } impl OpenAck { @@ -226,14 +210,12 @@ impl OpenAck { chan_id_on_a: ChannelId, port_id_on_b: PortId, chan_id_on_b: ChannelId, - conn_id_on_a: ConnectionId, ) -> Self { Self { port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), port_id_attr_on_b: port_id_on_b.into(), chan_id_attr_on_b: chan_id_on_b.into(), - conn_id_attr_on_a: conn_id_on_a.into(), } } pub fn port_id_on_a(&self) -> &PortId { @@ -248,9 +230,6 @@ impl OpenAck { pub fn chan_id_on_b(&self) -> &ChannelId { &self.chan_id_attr_on_b.counterparty_channel_id } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } pub fn event_type(&self) -> &str { CHANNEL_OPEN_ACK_EVENT @@ -266,7 +245,6 @@ impl From for abci::Event { o.chan_id_attr_on_a.into(), o.port_id_attr_on_b.into(), o.chan_id_attr_on_b.into(), - o.conn_id_attr_on_a.into(), ], } } @@ -291,7 +269,6 @@ pub struct OpenConfirm { chan_id_attr_on_b: ChannelIdAttribute, port_id_attr_on_a: CounterpartyPortIdAttribute, chan_id_attr_on_a: CounterpartyChannelIdAttribute, - conn_id_attr_on_b: ConnectionIdAttribute, } impl OpenConfirm { @@ -300,14 +277,12 @@ impl OpenConfirm { chan_id_on_b: ChannelId, port_id_on_a: PortId, chan_id_on_a: ChannelId, - conn_id_on_b: ConnectionId, ) -> Self { Self { port_id_attr_on_b: port_id_on_b.into(), chan_id_attr_on_b: chan_id_on_b.into(), port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), - conn_id_attr_on_b: conn_id_on_b.into(), } } pub fn port_id_on_b(&self) -> &PortId { @@ -322,9 +297,6 @@ impl OpenConfirm { pub fn chan_id_on_a(&self) -> &ChannelId { &self.chan_id_attr_on_a.counterparty_channel_id } - pub fn conn_id_on_b(&self) -> &ConnectionId { - &self.conn_id_attr_on_b.connection_id - } pub fn event_type(&self) -> &str { CHANNEL_OPEN_CONFIRM_EVENT @@ -340,7 +312,6 @@ impl From for abci::Event { o.chan_id_attr_on_b.into(), o.port_id_attr_on_a.into(), o.chan_id_attr_on_a.into(), - o.conn_id_attr_on_b.into(), ], } } @@ -365,7 +336,6 @@ pub struct CloseInit { chan_id_attr_on_a: ChannelIdAttribute, port_id_attr_on_b: CounterpartyPortIdAttribute, chan_id_attr_on_b: CounterpartyChannelIdAttribute, - conn_id_attr_on_a: ConnectionIdAttribute, } impl CloseInit { @@ -374,14 +344,12 @@ impl CloseInit { chan_id_on_a: ChannelId, port_id_on_b: PortId, chan_id_on_b: ChannelId, - conn_id_on_a: ConnectionId, ) -> Self { Self { port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), port_id_attr_on_b: port_id_on_b.into(), chan_id_attr_on_b: chan_id_on_b.into(), - conn_id_attr_on_a: conn_id_on_a.into(), } } pub fn port_id_on_a(&self) -> &PortId { @@ -396,10 +364,6 @@ impl CloseInit { pub fn chan_id_on_b(&self) -> &ChannelId { &self.chan_id_attr_on_b.counterparty_channel_id } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } - pub fn event_type(&self) -> &str { CHANNEL_CLOSE_INIT_EVENT } @@ -414,7 +378,6 @@ impl From for abci::Event { o.chan_id_attr_on_a.into(), o.port_id_attr_on_b.into(), o.chan_id_attr_on_b.into(), - o.conn_id_attr_on_a.into(), ], } } @@ -439,7 +402,6 @@ pub struct CloseConfirm { chan_id_attr_on_b: ChannelIdAttribute, port_id_attr_on_a: CounterpartyPortIdAttribute, chan_id_attr_on_a: CounterpartyChannelIdAttribute, - conn_id_attr_on_b: ConnectionIdAttribute, } impl CloseConfirm { @@ -448,14 +410,12 @@ impl CloseConfirm { chan_id_on_b: ChannelId, port_id_on_a: PortId, chan_id_on_a: ChannelId, - conn_id_on_b: ConnectionId, ) -> Self { Self { port_id_attr_on_b: port_id_on_b.into(), chan_id_attr_on_b: chan_id_on_b.into(), port_id_attr_on_a: port_id_on_a.into(), chan_id_attr_on_a: chan_id_on_a.into(), - conn_id_attr_on_b: conn_id_on_b.into(), } } pub fn port_id_on_b(&self) -> &PortId { @@ -470,10 +430,6 @@ impl CloseConfirm { pub fn chan_id_on_a(&self) -> &ChannelId { &self.chan_id_attr_on_a.counterparty_channel_id } - pub fn conn_id_on_b(&self) -> &ConnectionId { - &self.conn_id_attr_on_b.connection_id - } - pub fn event_type(&self) -> &str { CHANNEL_CLOSE_CONFIRM_EVENT } @@ -488,7 +444,6 @@ impl From for abci::Event { o.chan_id_attr_on_b.into(), o.port_id_attr_on_a.into(), o.chan_id_attr_on_a.into(), - o.conn_id_attr_on_b.into(), ], } } @@ -517,7 +472,6 @@ pub struct ChannelClosed { chan_id_attr_on_a: ChannelIdAttribute, port_id_attr_on_b: CounterpartyPortIdAttribute, maybe_chan_id_attr_on_b: Option, - conn_id_attr_on_a: ConnectionIdAttribute, channel_ordering_attr: ChannelOrderingAttribute, } @@ -527,7 +481,6 @@ impl ChannelClosed { chan_id_on_a: ChannelId, port_id_on_b: PortId, maybe_chan_id_on_b: Option, - conn_id_on_a: ConnectionId, channel_ordering: Order, ) -> Self { Self { @@ -535,7 +488,6 @@ impl ChannelClosed { chan_id_attr_on_a: chan_id_on_a.into(), port_id_attr_on_b: port_id_on_b.into(), maybe_chan_id_attr_on_b: maybe_chan_id_on_b.map(Into::into), - conn_id_attr_on_a: conn_id_on_a.into(), channel_ordering_attr: channel_ordering.into(), } } @@ -551,9 +503,6 @@ impl ChannelClosed { pub fn chan_id_on_a(&self) -> Option<&ChannelId> { self.maybe_chan_id_attr_on_b.as_ref().map(AsRef::as_ref) } - pub fn conn_id_on_b(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } pub fn channel_ordering(&self) -> &Order { &self.channel_ordering_attr.order } @@ -575,7 +524,6 @@ impl From for abci::Event { || (COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, "").into(), Into::into, ), - ev.conn_id_attr_on_a.into(), ev.channel_ordering_attr.into(), ], } @@ -606,11 +554,10 @@ pub struct SendPacket { port_id_attr_on_b: DstPortIdAttribute, chan_id_attr_on_b: DstChannelIdAttribute, channel_ordering_attr: ChannelOrderingAttribute, - conn_id_attr_on_a: PacketConnectionIdAttribute, } impl SendPacket { - pub fn new(packet: Packet, channel_ordering: Order, src_connection_id: ConnectionId) -> Self { + pub fn new(packet: Packet, channel_ordering: Order) -> Self { let payload = packet.payloads[0].clone(); Self { packet_data_attr: payload.data.into(), @@ -622,7 +569,6 @@ impl SendPacket { port_id_attr_on_b: payload.header.target_port.1.into(), chan_id_attr_on_b: packet.header.target_client.into(), channel_ordering_attr: channel_ordering.into(), - conn_id_attr_on_a: src_connection_id.into(), } } @@ -662,10 +608,6 @@ impl SendPacket { &self.channel_ordering_attr.order } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } - pub fn event_type(&self) -> &str { SEND_PACKET_EVENT } @@ -685,7 +627,6 @@ impl TryFrom for abci::Event { attributes.push(v.port_id_attr_on_b.into()); attributes.push(v.chan_id_attr_on_b.into()); attributes.push(v.channel_ordering_attr.into()); - attributes.push(v.conn_id_attr_on_a.into()); Ok(abci::Event { kind: SEND_PACKET_EVENT.to_string(), @@ -718,11 +659,10 @@ pub struct ReceivePacket { port_id_attr_on_b: DstPortIdAttribute, chan_id_attr_on_b: DstChannelIdAttribute, channel_ordering_attr: ChannelOrderingAttribute, - conn_id_attr_on_b: PacketConnectionIdAttribute, } impl ReceivePacket { - pub fn new(packet: Packet, channel_ordering: Order, dst_connection_id: ConnectionId) -> Self { + pub fn new(packet: Packet, channel_ordering: Order) -> Self { let payload = packet.payloads[0].clone(); Self { packet_data_attr: payload.data.into(), @@ -734,7 +674,6 @@ impl ReceivePacket { port_id_attr_on_b: payload.header.target_port.1.into(), chan_id_attr_on_b: packet.header.target_client.into(), channel_ordering_attr: channel_ordering.into(), - conn_id_attr_on_b: dst_connection_id.into(), } } @@ -774,10 +713,6 @@ impl ReceivePacket { &self.channel_ordering_attr.order } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_b.connection_id - } - pub fn event_type(&self) -> &str { RECEIVE_PACKET_EVENT } @@ -797,7 +732,6 @@ impl TryFrom for abci::Event { attributes.push(v.port_id_attr_on_b.into()); attributes.push(v.chan_id_attr_on_b.into()); attributes.push(v.channel_ordering_attr.into()); - attributes.push(v.conn_id_attr_on_b.into()); Ok(abci::Event { kind: RECEIVE_PACKET_EVENT.to_string(), @@ -830,15 +764,10 @@ pub struct WriteAcknowledgement { port_id_attr_on_b: DstPortIdAttribute, chan_id_attr_on_b: DstChannelIdAttribute, acknowledgement: AcknowledgementAttribute, - conn_id_attr_on_b: PacketConnectionIdAttribute, } impl WriteAcknowledgement { - pub fn new( - packet: Packet, - acknowledgement: Acknowledgement, - conn_id_on_b: ConnectionId, - ) -> Self { + pub fn new(packet: Packet, acknowledgement: Acknowledgement) -> Self { let payload = packet.payloads[0].clone(); Self { packet_data: payload.data.into(), @@ -850,7 +779,6 @@ impl WriteAcknowledgement { port_id_attr_on_b: payload.header.target_port.1.into(), chan_id_attr_on_b: packet.header.target_client.into(), acknowledgement: acknowledgement.into(), - conn_id_attr_on_b: conn_id_on_b.into(), } } @@ -890,10 +818,6 @@ impl WriteAcknowledgement { &self.acknowledgement.acknowledgement } - pub fn conn_id_on_b(&self) -> &ConnectionId { - &self.conn_id_attr_on_b.connection_id - } - pub fn event_type(&self) -> &str { WRITE_ACK_EVENT } @@ -913,7 +837,6 @@ impl TryFrom for abci::Event { attributes.push(v.port_id_attr_on_b.into()); attributes.push(v.chan_id_attr_on_b.into()); attributes.append(&mut v.acknowledgement.try_into()?); - attributes.push(v.conn_id_attr_on_b.into()); Ok(abci::Event { kind: WRITE_ACK_EVENT.to_string(), @@ -945,11 +868,10 @@ pub struct AcknowledgePacket { port_id_attr_on_b: DstPortIdAttribute, chan_id_attr_on_b: DstChannelIdAttribute, channel_ordering_attr: ChannelOrderingAttribute, - conn_id_attr_on_a: PacketConnectionIdAttribute, } impl AcknowledgePacket { - pub fn new(packet: Packet, channel_ordering: Order, src_connection_id: ConnectionId) -> Self { + pub fn new(packet: Packet, channel_ordering: Order) -> Self { let payload = packet.payloads[0].clone(); Self { timeout_height_attr_on_b: packet.header.timeout_height_on_b.into(), @@ -960,7 +882,6 @@ impl AcknowledgePacket { port_id_attr_on_b: payload.header.target_port.1.into(), chan_id_attr_on_b: packet.header.target_client.into(), channel_ordering_attr: channel_ordering.into(), - conn_id_attr_on_a: src_connection_id.into(), } } @@ -996,10 +917,6 @@ impl AcknowledgePacket { &self.channel_ordering_attr.order } - pub fn conn_id_on_a(&self) -> &ConnectionId { - &self.conn_id_attr_on_a.connection_id - } - pub fn event_type(&self) -> &str { ACK_PACKET_EVENT } @@ -1020,7 +937,6 @@ impl TryFrom for abci::Event { v.port_id_attr_on_b.into(), v.chan_id_attr_on_b.into(), v.channel_ordering_attr.into(), - v.conn_id_attr_on_a.into(), ], }) } diff --git a/ibc-eureka-core/ics04-channel/types/src/events/packet_attributes.rs b/ibc-eureka-core/ics04-channel/types/src/events/packet_attributes.rs index f27941ccf..5c599422b 100644 --- a/ibc-eureka-core/ics04-channel/types/src/events/packet_attributes.rs +++ b/ibc-eureka-core/ics04-channel/types/src/events/packet_attributes.rs @@ -5,7 +5,7 @@ use core::str; use derive_more::From; use ibc_eureka_core_host_types::error::DecodingError; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId, Sequence}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId, Sequence}; use ibc_primitives::prelude::*; use subtle_encoding::hex; use tendermint::abci; @@ -26,7 +26,7 @@ const PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY: &str = "packet_timeout_height"; const PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY: &str = "packet_timeout_timestamp"; const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack"; const PKT_ACK_HEX_ATTRIBUTE_KEY: &str = "packet_ack_hex"; -const PKT_CONNECTION_ID_ATTRIBUTE_KEY: &str = "packet_connection"; +// const PKT_CONNECTION_ID_ATTRIBUTE_KEY: &str = "packet_connection"; #[cfg_attr( feature = "parity-scale-codec", @@ -265,30 +265,6 @@ impl From for abci::EventAttribute { } } -#[cfg_attr( - feature = "parity-scale-codec", - derive( - parity_scale_codec::Encode, - parity_scale_codec::Decode, - scale_info::TypeInfo - ) -)] -#[cfg_attr( - feature = "borsh", - derive(borsh::BorshSerialize, borsh::BorshDeserialize) -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Clone, Debug, From, PartialEq, Eq)] -pub struct PacketConnectionIdAttribute { - pub connection_id: ConnectionId, -} - -impl From for abci::EventAttribute { - fn from(attr: PacketConnectionIdAttribute) -> Self { - (PKT_CONNECTION_ID_ATTRIBUTE_KEY, attr.connection_id.as_str()).into() - } -} - #[cfg_attr( feature = "parity-scale-codec", derive( diff --git a/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_init.rs b/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_init.rs index 526ad2fe1..d7eb8c58a 100644 --- a/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_init.rs +++ b/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_init.rs @@ -1,12 +1,11 @@ use ibc_eureka_core_host_types::error::DecodingError; -use ibc_eureka_core_host_types::identifiers::{ConnectionId, PortId}; +use ibc_eureka_core_host_types::identifiers::PortId; use ibc_primitives::prelude::*; use ibc_primitives::Signer; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenInit as RawMsgChannelOpenInit; use ibc_proto::Protobuf; -use crate::channel::{verify_connection_hops_length, ChannelEnd, Counterparty, Order, State}; -use crate::error::ChannelError; +use crate::channel::{ChannelEnd, Counterparty, Order, State}; use crate::Version; pub const CHAN_OPEN_INIT_TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenInit"; @@ -23,7 +22,6 @@ pub const CHAN_OPEN_INIT_TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenIn #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenInit { pub port_id_on_a: PortId, - pub connection_hops_on_a: Vec, pub port_id_on_b: PortId, pub ordering: Order, pub signer: Signer, @@ -31,15 +29,6 @@ pub struct MsgChannelOpenInit { pub version_proposal: Version, } -impl MsgChannelOpenInit { - /// Checks if the `connection_hops` has a length of `expected`. - /// - /// Note: Current IBC version only supports one connection hop. - pub fn verify_connection_hops_length(&self) -> Result<(), ChannelError> { - verify_connection_hops_length(&self.connection_hops_on_a, 1) - } -} - impl Protobuf for MsgChannelOpenInit {} impl TryFrom for MsgChannelOpenInit { @@ -68,7 +57,6 @@ impl TryFrom for MsgChannelOpenInit { Ok(MsgChannelOpenInit { port_id_on_a: raw_msg.port_id.parse()?, - connection_hops_on_a: chan_end_on_a.connection_hops, port_id_on_b: chan_end_on_a.remote.port_id, ordering: chan_end_on_a.ordering, signer: raw_msg.signer.into(), @@ -83,7 +71,6 @@ impl From for RawMsgChannelOpenInit { State::Init, domain_msg.ordering, Counterparty::new(domain_msg.port_id_on_b, None), - domain_msg.connection_hops_on_a, domain_msg.version_proposal, ); RawMsgChannelOpenInit { diff --git a/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_try.rs b/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_try.rs index cbdebfcea..d510bea87 100644 --- a/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_try.rs +++ b/ibc-eureka-core/ics04-channel/types/src/msgs/chan_open_try.rs @@ -1,14 +1,13 @@ use ibc_eureka_core_client_types::Height; use ibc_eureka_core_commitment_types::commitment::CommitmentProofBytes; use ibc_eureka_core_host_types::error::DecodingError; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId}; use ibc_primitives::prelude::*; use ibc_primitives::Signer; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenTry as RawMsgChannelOpenTry; use ibc_proto::Protobuf; -use crate::channel::{verify_connection_hops_length, ChannelEnd, Counterparty, Order, State}; -use crate::error::ChannelError; +use crate::channel::{ChannelEnd, Counterparty, Order, State}; use crate::Version; pub const CHAN_OPEN_TRY_TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenTry"; @@ -25,7 +24,6 @@ pub const CHAN_OPEN_TRY_TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenTry #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenTry { pub port_id_on_b: PortId, - pub connection_hops_on_b: Vec, pub port_id_on_a: PortId, pub chan_id_on_a: ChannelId, pub version_supported_on_a: Version, @@ -39,15 +37,6 @@ pub struct MsgChannelOpenTry { pub version_proposal: Version, } -impl MsgChannelOpenTry { - /// Checks if the `connection_hops` has a length of `expected`. - /// - /// Note: The current IBC version only supports one connection hop. - pub fn verify_connection_hops_length(&self) -> Result<(), ChannelError> { - verify_connection_hops_length(&self.connection_hops_on_b, 1) - } -} - impl Protobuf for MsgChannelOpenTry {} impl TryFrom for MsgChannelOpenTry { @@ -77,7 +66,6 @@ impl TryFrom for MsgChannelOpenTry { let msg = MsgChannelOpenTry { port_id_on_b: raw_msg.port_id.parse()?, ordering: chan_end_on_b.ordering, - connection_hops_on_b: chan_end_on_b.connection_hops, port_id_on_a: chan_end_on_b.remote.port_id, chan_id_on_a: chan_end_on_b.remote.channel_id.ok_or( DecodingError::missing_raw_data("msg channel open try counterparty channel ID"), @@ -104,7 +92,6 @@ impl From for RawMsgChannelOpenTry { State::TryOpen, domain_msg.ordering, Counterparty::new(domain_msg.port_id_on_a, Some(domain_msg.chan_id_on_a)), - domain_msg.connection_hops_on_b, Version::empty(), // Excessive field to satisfy the type conversion ); #[allow(deprecated)] diff --git a/ibc-eureka-core/ics24-host/src/context.rs b/ibc-eureka-core/ics24-host/src/context.rs index 8b9440d6a..46991b9b9 100644 --- a/ibc-eureka-core/ics24-host/src/context.rs +++ b/ibc-eureka-core/ics24-host/src/context.rs @@ -6,14 +6,11 @@ use ibc_eureka_core_channel_types::packet::Receipt; use ibc_eureka_core_client_context::prelude::*; use ibc_eureka_core_client_types::Height; use ibc_eureka_core_commitment_types::commitment::CommitmentPrefix; -use ibc_eureka_core_connection_types::version::{pick_version, Version as ConnectionVersion}; -use ibc_eureka_core_connection_types::ConnectionEnd; use ibc_eureka_core_handler_types::events::IbcEvent; use ibc_eureka_core_host_types::error::HostError; -use ibc_eureka_core_host_types::identifiers::{ConnectionId, Sequence}; +use ibc_eureka_core_host_types::identifiers::Sequence; use ibc_eureka_core_host_types::path::{ - AckPath, ChannelEndPath, ClientConnectionPath, CommitmentPath, ConnectionPath, ReceiptPath, - SeqAckPath, SeqRecvPath, SeqSendPath, + AckPath, ChannelEndPath, CommitmentPath, ReceiptPath, SeqAckPath, SeqRecvPath, SeqSendPath, }; use ibc_primitives::prelude::*; use ibc_primitives::{Signer, Timestamp}; @@ -47,9 +44,6 @@ pub trait ValidationContext { /// `ExecutionContext::increase_client_counter`. fn client_counter(&self) -> Result; - /// Returns the ConnectionEnd for the given identifier `conn_id`. - fn connection_end(&self, conn_id: &ConnectionId) -> Result; - /// Validates the `ClientState` of the host chain stored on the counterparty /// chain against the host's internal state. /// @@ -70,25 +64,6 @@ pub trait ValidationContext { /// Returns a counter on how many connections have been created thus far. fn connection_counter(&self) -> Result; - /// Function required by ICS-03. Returns the list of all possible versions that the connection - /// handshake protocol supports. - fn get_compatible_versions(&self) -> Vec { - ConnectionVersion::compatibles() - } - - /// Function required by ICS-03. Returns one version out of the supplied list of versions, which the - /// connection handshake protocol prefers. - fn pick_version( - &self, - counterparty_candidate_versions: &[ConnectionVersion], - ) -> Result { - pick_version( - &self.get_compatible_versions(), - counterparty_candidate_versions, - ) - .map_err(HostError::missing_state) - } - /// Returns the `ChannelEnd` for the given `port_id` and `chan_id`. fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result; @@ -155,20 +130,6 @@ pub trait ExecutionContext: ValidationContext { /// Increases the counter, that keeps track of how many clients have been created. fn increase_client_counter(&mut self) -> Result<(), HostError>; - /// Stores the given connection_end at path - fn store_connection( - &mut self, - connection_path: &ConnectionPath, - connection_end: ConnectionEnd, - ) -> Result<(), HostError>; - - /// Stores the given connection_id at a path associated with the client_id. - fn store_connection_to_client( - &mut self, - client_connection_path: &ClientConnectionPath, - conn_id: ConnectionId, - ) -> Result<(), HostError>; - /// Called upon connection identifier creation (Init or Try process). /// Increases the counter which keeps track of how many connections have been created. fn increase_connection_counter(&mut self) -> Result<(), HostError>; diff --git a/ibc-eureka-core/ics24-host/types/src/path.rs b/ibc-eureka-core/ics24-host/types/src/path.rs index bbc8c79c6..750fb3bf6 100644 --- a/ibc-eureka-core/ics24-host/types/src/path.rs +++ b/ibc-eureka-core/ics24-host/types/src/path.rs @@ -9,7 +9,7 @@ use core::str::FromStr; use derive_more::{Display, From}; use ibc_primitives::prelude::*; -use crate::identifiers::{ChannelId, ClientId, ConnectionId, PortId, Sequence}; +use crate::identifiers::{ChannelId, ClientId, PortId, Sequence}; pub const NEXT_CLIENT_SEQUENCE: &str = "nextClientSequence"; pub const NEXT_CONNECTION_SEQUENCE: &str = "nextConnectionSequence"; @@ -90,7 +90,6 @@ pub enum Path { ClientUpdateTime(ClientUpdateTimePath), ClientUpdateHeight(ClientUpdateHeightPath), ClientConnection(ClientConnectionPath), - Connection(ConnectionPath), Ports(PortPath), ChannelEnd(ChannelEndPath), SeqSend(SeqSendPath), @@ -392,35 +391,6 @@ impl ClientConnectionPath { } } -#[cfg_attr( - feature = "parity-scale-codec", - derive( - parity_scale_codec::Encode, - parity_scale_codec::Decode, - scale_info::TypeInfo - ) -)] -#[cfg_attr( - feature = "borsh", - derive(borsh::BorshSerialize, borsh::BorshDeserialize) -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] -#[display(fmt = "{CONNECTION_PREFIX}/{_0}")] -pub struct ConnectionPath(pub ConnectionId); - -impl ConnectionPath { - pub fn new(connection_id: &ConnectionId) -> ConnectionPath { - ConnectionPath(connection_id.clone()) - } - - /// Returns the connection store prefix under which all the connections are - /// stored: "connections". - pub fn prefix() -> String { - CONNECTION_PREFIX.to_string() - } -} - #[cfg_attr( feature = "parity-scale-codec", derive( @@ -792,7 +762,6 @@ impl FromStr for Path { parse_next_sequence(&components) .or_else(|| parse_client_paths(&components)) - .or_else(|| parse_connections(&components)) .or_else(|| parse_ports(&components)) .or_else(|| parse_channel_ends(&components)) .or_else(|| parse_seqs(&components)) @@ -889,24 +858,6 @@ fn parse_client_paths(components: &[&str]) -> Option { } } -fn parse_connections(components: &[&str]) -> Option { - if components.len() != 2 { - return None; - } - - let first = *components.first()?; - - if first != CONNECTION_PREFIX { - return None; - } - - let connection_id = *components.last()?; - - let connection_id = ConnectionId::from_str(connection_id).ok()?; - - Some(ConnectionPath(connection_id).into()) -} - fn parse_ports(components: &[&str]) -> Option { if components.len() != 2 { return None; diff --git a/ibc-eureka-core/ics24-host/types/src/validate.rs b/ibc-eureka-core/ics24-host/types/src/validate.rs index 614cfd8a4..8090cd02f 100644 --- a/ibc-eureka-core/ics24-host/types/src/validate.rs +++ b/ibc-eureka-core/ics24-host/types/src/validate.rs @@ -1,7 +1,7 @@ use ibc_primitives::prelude::*; use crate::error::IdentifierError as Error; -use crate::identifiers::{ChannelId, ConnectionId}; +use crate::identifiers::ChannelId; const VALID_SPECIAL_CHARS: &str = "._+-#[]<>"; @@ -97,16 +97,16 @@ pub fn validate_client_identifier(id: &str) -> Result<(), Error> { validate_identifier_length(id, 9, 64) } -/// Default validator function for Connection identifiers. -/// -/// A valid connection identifier must be between 10-64 characters, as specified -/// in the ICS-24 spec. -pub fn validate_connection_identifier(id: &str) -> Result<(), Error> { - validate_identifier_chars(id)?; - validate_identifier_length(id, 10, 64)?; - validate_named_u64_index(id, ConnectionId::prefix())?; - Ok(()) -} +// /// Default validator function for Connection identifiers. +// /// +// /// A valid connection identifier must be between 10-64 characters, as specified +// /// in the ICS-24 spec. +// pub fn validate_connection_identifier(id: &str) -> Result<(), Error> { +// validate_identifier_chars(id)?; +// validate_identifier_length(id, 10, 64)?; +// validate_named_u64_index(id, ConnectionId::prefix())?; +// Ok(()) +// } /// Default validator function for Port identifiers. /// @@ -150,39 +150,39 @@ mod tests { assert!(id.is_err()) } - #[test] - fn parse_invalid_connection_id_min() { - // invalid min connection id - let id = validate_connection_identifier("connect01"); - assert!(id.is_err()) - } - - #[test] - fn parse_connection_id_max() { - // invalid max connection id (test string length is 65) - let id = validate_connection_identifier( - "ihhankr30iy4nna65hjl2wjod7182io1t2s7u3ip3wqtbbn1sl0rgcntqc540r36r", - ); - assert!(id.is_err()) - } - - #[test] - fn parse_invalid_connection_id_indexed() { - // valid connection id with index - validate_connection_identifier("connection-0").expect("success"); - validate_connection_identifier("connection-123").expect("success"); - validate_connection_identifier("connection-18446744073709551615").expect("success"); - } - - #[test] - fn parse_invalid_connection_id_non_indexed() { - // invalid indexing for connection id - validate_connection_identifier("connection-0123").expect_err("failure"); - validate_connection_identifier("connection0123").expect_err("failure"); - validate_connection_identifier("connection000").expect_err("failure"); - // 1 << 64 = 18446744073709551616 - validate_connection_identifier("connection-18446744073709551616").expect_err("failure"); - } + // #[test] + // fn parse_invalid_connection_id_min() { + // // invalid min connection id + // let id = validate_connection_identifier("connect01"); + // assert!(id.is_err()) + // } + + // #[test] + // fn parse_connection_id_max() { + // // invalid max connection id (test string length is 65) + // let id = validate_connection_identifier( + // "ihhankr30iy4nna65hjl2wjod7182io1t2s7u3ip3wqtbbn1sl0rgcntqc540r36r", + // ); + // assert!(id.is_err()) + // } + + // #[test] + // fn parse_invalid_connection_id_indexed() { + // // valid connection id with index + // validate_connection_identifier("connection-0").expect("success"); + // validate_connection_identifier("connection-123").expect("success"); + // validate_connection_identifier("connection-18446744073709551615").expect("success"); + // } + + // #[test] + // fn parse_invalid_connection_id_non_indexed() { + // // invalid indexing for connection id + // validate_connection_identifier("connection-0123").expect_err("failure"); + // validate_connection_identifier("connection0123").expect_err("failure"); + // validate_connection_identifier("connection000").expect_err("failure"); + // // 1 << 64 = 18446744073709551616 + // validate_connection_identifier("connection-18446744073709551616").expect_err("failure"); + // } #[test] fn parse_invalid_channel_id_min() { diff --git a/ibc-eureka-core/ics25-handler/types/src/error.rs b/ibc-eureka-core/ics25-handler/types/src/error.rs index 2ce21e1b9..5a3477408 100644 --- a/ibc-eureka-core/ics25-handler/types/src/error.rs +++ b/ibc-eureka-core/ics25-handler/types/src/error.rs @@ -4,7 +4,6 @@ use derive_more::From; use displaydoc::Display; use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_client_types::error::ClientError; -use ibc_eureka_core_connection_types::error::ConnectionError; use ibc_eureka_core_router_types::error::RouterError; use ibc_primitives::prelude::*; @@ -13,8 +12,6 @@ use ibc_primitives::prelude::*; pub enum HandlerError { /// ICS02 Client error: {0} Client(ClientError), - /// ICS03 Connection error: {0} - Connection(ConnectionError), /// ICS04 Channel error: {0} Channel(ChannelError), /// ICS26 Routing error: {0} @@ -26,7 +23,6 @@ impl std::error::Error for HandlerError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Self::Client(e) => Some(e), - Self::Connection(e) => Some(e), Self::Channel(e) => Some(e), Self::Router(e) => Some(e), } diff --git a/ibc-eureka-core/ics25-handler/types/src/events.rs b/ibc-eureka-core/ics25-handler/types/src/events.rs index 40c29e456..6a86ad948 100644 --- a/ibc-eureka-core/ics25-handler/types/src/events.rs +++ b/ibc-eureka-core/ics25-handler/types/src/events.rs @@ -2,7 +2,6 @@ use ibc_eureka_core_channel_types::events as ChannelEvents; use ibc_eureka_core_client_types::events::{self as ClientEvents}; -use ibc_eureka_core_connection_types::events as ConnectionEvents; use ibc_eureka_core_host_types::error::DecodingError; use ibc_eureka_core_router_types::event::ModuleEvent; use ibc_primitives::prelude::*; @@ -31,11 +30,6 @@ pub enum IbcEvent { UpgradeClient(ClientEvents::UpgradeClient), ClientMisbehaviour(ClientEvents::ClientMisbehaviour), - OpenInitConnection(ConnectionEvents::OpenInit), - OpenTryConnection(ConnectionEvents::OpenTry), - OpenAckConnection(ConnectionEvents::OpenAck), - OpenConfirmConnection(ConnectionEvents::OpenConfirm), - OpenInitChannel(ChannelEvents::OpenInit), OpenTryChannel(ChannelEvents::OpenTry), OpenAckChannel(ChannelEvents::OpenAck), @@ -63,10 +57,6 @@ impl TryFrom for abci::Event { IbcEvent::UpdateClient(event) => event.into(), IbcEvent::UpgradeClient(event) => event.into(), IbcEvent::ClientMisbehaviour(event) => event.into(), - IbcEvent::OpenInitConnection(event) => event.into(), - IbcEvent::OpenTryConnection(event) => event.into(), - IbcEvent::OpenAckConnection(event) => event.into(), - IbcEvent::OpenConfirmConnection(event) => event.into(), IbcEvent::OpenInitChannel(event) => event.into(), IbcEvent::OpenTryChannel(event) => event.into(), IbcEvent::OpenAckChannel(event) => event.into(), @@ -95,10 +85,6 @@ impl IbcEvent { IbcEvent::UpdateClient(event) => event.event_type(), IbcEvent::ClientMisbehaviour(event) => event.event_type(), IbcEvent::UpgradeClient(event) => event.event_type(), - IbcEvent::OpenInitConnection(event) => event.event_type(), - IbcEvent::OpenTryConnection(event) => event.event_type(), - IbcEvent::OpenAckConnection(event) => event.event_type(), - IbcEvent::OpenConfirmConnection(event) => event.event_type(), IbcEvent::OpenInitChannel(event) => event.event_type(), IbcEvent::OpenTryChannel(event) => event.event_type(), IbcEvent::OpenAckChannel(event) => event.event_type(), diff --git a/ibc-eureka-core/ics25-handler/types/src/msgs.rs b/ibc-eureka-core/ics25-handler/types/src/msgs.rs index e615328d9..b360232ec 100644 --- a/ibc-eureka-core/ics25-handler/types/src/msgs.rs +++ b/ibc-eureka-core/ics25-handler/types/src/msgs.rs @@ -12,11 +12,6 @@ use ibc_eureka_core_client_types::msgs::{ CREATE_CLIENT_TYPE_URL, SUBMIT_MISBEHAVIOUR_TYPE_URL, UPDATE_CLIENT_TYPE_URL, UPGRADE_CLIENT_TYPE_URL, }; -use ibc_eureka_core_connection_types::msgs::{ - ConnectionMsg, MsgConnectionOpenAck, MsgConnectionOpenConfirm, MsgConnectionOpenInit, - MsgConnectionOpenTry, CONN_OPEN_ACK_TYPE_URL, CONN_OPEN_CONFIRM_TYPE_URL, - CONN_OPEN_INIT_TYPE_URL, CONN_OPEN_TRY_TYPE_URL, -}; use ibc_eureka_core_host_types::error::DecodingError; use ibc_primitives::prelude::*; use ibc_proto::google::protobuf::Any; @@ -31,7 +26,6 @@ use ibc_proto::Protobuf; #[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum MsgEnvelope { Client(ClientMsg), - Connection(ConnectionMsg), Channel(ChannelMsg), Packet(PacketMsg), } diff --git a/ibc-eureka-core/ics26-routing/src/module.rs b/ibc-eureka-core/ics26-routing/src/module.rs index c488a5c04..ebc14490b 100644 --- a/ibc-eureka-core/ics26-routing/src/module.rs +++ b/ibc-eureka-core/ics26-routing/src/module.rs @@ -6,7 +6,7 @@ use ibc_eureka_core_channel_types::channel::{Counterparty, Order}; use ibc_eureka_core_channel_types::error::ChannelError; use ibc_eureka_core_channel_types::packet::Packet; use ibc_eureka_core_channel_types::Version; -use ibc_eureka_core_host_types::identifiers::{ChannelId, ConnectionId, PortId}; +use ibc_eureka_core_host_types::identifiers::{ChannelId, PortId}; use ibc_eureka_core_router_types::module::ModuleExtras; use ibc_primitives::prelude::*; use ibc_primitives::Signer; @@ -15,7 +15,6 @@ pub trait Module: Debug { fn on_chan_open_init_validate( &self, order: Order, - connection_hops: &[ConnectionId], port_id: &PortId, channel_id: &ChannelId, counterparty: &Counterparty, @@ -25,7 +24,6 @@ pub trait Module: Debug { fn on_chan_open_init_execute( &mut self, order: Order, - connection_hops: &[ConnectionId], port_id: &PortId, channel_id: &ChannelId, counterparty: &Counterparty, @@ -35,7 +33,6 @@ pub trait Module: Debug { fn on_chan_open_try_validate( &self, order: Order, - connection_hops: &[ConnectionId], port_id: &PortId, channel_id: &ChannelId, counterparty: &Counterparty, @@ -45,7 +42,6 @@ pub trait Module: Debug { fn on_chan_open_try_execute( &mut self, order: Order, - connection_hops: &[ConnectionId], port_id: &PortId, channel_id: &ChannelId, counterparty: &Counterparty,