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

refactor: rm unnecessary code for eureka #1372

Open
wants to merge 17 commits into
base: rano/eureka/1364
Choose a base branch
from
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -95,12 +95,12 @@ ibc-core-handler = { version = "0.55.1", path = "./ibc-core/ics25-handler", d
ibc-core-router = { version = "0.55.1", path = "./ibc-core/ics26-routing", default-features = false }
ibc-query = { version = "0.55.1", path = "./ibc-query", default-features = false }

ibc-eureka-core-client = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client", default-features = false }
ibc-eureka-core-connection = { version = "0.55.1", path = "./ibc-eureka-core/ics03-connection", default-features = false }
ibc-eureka-core-channel = { version = "0.55.1", path = "./ibc-eureka-core/ics04-channel", default-features = false }
ibc-eureka-core-host = { version = "0.55.1", path = "./ibc-eureka-core/ics24-host", default-features = false }
ibc-eureka-core-handler = { version = "0.55.1", path = "./ibc-eureka-core/ics25-handler", default-features = false }
ibc-eureka-core-router = { version = "0.55.1", path = "./ibc-eureka-core/ics26-routing", default-features = false }
ibc-eureka-core-client = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client", default-features = false }
# ibc-eureka-core-connection = { version = "0.55.1", path = "./ibc-eureka-core/ics03-connection", default-features = false }
ibc-eureka-core-channel = { version = "0.55.1", path = "./ibc-eureka-core/ics04-channel", default-features = false }
ibc-eureka-core-host = { version = "0.55.1", path = "./ibc-eureka-core/ics24-host", default-features = false }
ibc-eureka-core-handler = { version = "0.55.1", path = "./ibc-eureka-core/ics25-handler", default-features = false }
ibc-eureka-core-router = { version = "0.55.1", path = "./ibc-eureka-core/ics26-routing", default-features = false }

ibc-client-tendermint = { version = "0.55.1", path = "./ibc-clients/ics07-tendermint", default-features = false }

@@ -121,10 +121,10 @@ ibc-client-wasm-types = { version = "0.55.1", path = "./ibc-clients/ics08-
ibc-app-transfer-types = { version = "0.55.1", path = "./ibc-apps/ics20-transfer/types", default-features = false }
ibc-app-nft-transfer-types = { version = "0.55.1", path = "./ibc-apps/ics721-nft-transfer/types", default-features = false }

ibc-eureka-core-client-context = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client/context", default-features = false }
ibc-eureka-core-client-types = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client/types", default-features = false }
ibc-eureka-core-channel-types = { version = "0.55.1", path = "./ibc-eureka-core/ics04-channel/types", default-features = false }
ibc-eureka-core-connection-types = { version = "0.55.1", path = "./ibc-eureka-core/ics03-connection/types", default-features = false }
ibc-eureka-core-client-context = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client/context", default-features = false }
ibc-eureka-core-client-types = { version = "0.55.1", path = "./ibc-eureka-core/ics02-client/types", default-features = false }
ibc-eureka-core-channel-types = { version = "0.55.1", path = "./ibc-eureka-core/ics04-channel/types", default-features = false }
# ibc-eureka-core-connection-types = { version = "0.55.1", path = "./ibc-eureka-core/ics03-connection/types", default-features = false }
ibc-eureka-core-commitment-types = { version = "0.55.1", path = "./ibc-eureka-core/ics23-commitment/types", default-features = false }
ibc-eureka-core-host-cosmos = { version = "0.55.1", path = "./ibc-eureka-core/ics24-host/cosmos", default-features = false }
ibc-eureka-core-host-types = { version = "0.55.1", path = "./ibc-eureka-core/ics24-host/types", default-features = false }
6 changes: 0 additions & 6 deletions ibc-eureka-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ all-features = true

[dependencies]
ibc-eureka-core-client = { workspace = true }
ibc-eureka-core-connection = { workspace = true }
ibc-eureka-core-channel = { workspace = true }
ibc-eureka-core-commitment-types = { workspace = true }
ibc-eureka-core-host = { workspace = true }
@@ -32,7 +31,6 @@ ibc-primitives = { workspace = true }
default = [ "std" ]
std = [
"ibc-eureka-core-client/std",
"ibc-eureka-core-connection/std",
"ibc-eureka-core-channel/std",
"ibc-eureka-core-commitment-types/std",
"ibc-eureka-core-host/std",
@@ -42,7 +40,6 @@ std = [
]
serde = [
"ibc-eureka-core-client/serde",
"ibc-eureka-core-connection/serde",
"ibc-eureka-core-channel/serde",
"ibc-eureka-core-commitment-types/serde",
"ibc-eureka-core-host/serde",
@@ -52,7 +49,6 @@ serde = [
]
borsh = [
"ibc-eureka-core-client/borsh",
"ibc-eureka-core-connection/borsh",
"ibc-eureka-core-channel/borsh",
"ibc-eureka-core-commitment-types/borsh",
"ibc-eureka-core-host/borsh",
@@ -62,7 +58,6 @@ borsh = [
]
schema = [
"ibc-eureka-core-client/schema",
"ibc-eureka-core-connection/schema",
"ibc-eureka-core-channel/schema",
"ibc-eureka-core-commitment-types/schema",
"ibc-eureka-core-host/schema",
@@ -74,7 +69,6 @@ schema = [
]
parity-scale-codec = [
"ibc-eureka-core-client/parity-scale-codec",
"ibc-eureka-core-connection/parity-scale-codec",
"ibc-eureka-core-channel/parity-scale-codec",
"ibc-eureka-core-commitment-types/parity-scale-codec",
"ibc-eureka-core-host/parity-scale-codec",
73 changes: 0 additions & 73 deletions ibc-eureka-core/ics03-connection/Cargo.toml

This file was deleted.

48 changes: 0 additions & 48 deletions ibc-eureka-core/ics03-connection/src/delay.rs

This file was deleted.

206 changes: 0 additions & 206 deletions ibc-eureka-core/ics03-connection/src/handler/conn_open_ack.rs

This file was deleted.

164 changes: 0 additions & 164 deletions ibc-eureka-core/ics03-connection/src/handler/conn_open_confirm.rs

This file was deleted.

85 changes: 0 additions & 85 deletions ibc-eureka-core/ics03-connection/src/handler/conn_open_init.rs

This file was deleted.

206 changes: 0 additions & 206 deletions ibc-eureka-core/ics03-connection/src/handler/conn_open_try.rs

This file was deleted.

82 changes: 0 additions & 82 deletions ibc-eureka-core/ics03-connection/src/handler/mod.rs

This file was deleted.

26 changes: 0 additions & 26 deletions ibc-eureka-core/ics03-connection/src/lib.rs

This file was deleted.

91 changes: 0 additions & 91 deletions ibc-eureka-core/ics03-connection/types/Cargo.toml

This file was deleted.

523 changes: 0 additions & 523 deletions ibc-eureka-core/ics03-connection/types/src/connection.rs

This file was deleted.

90 changes: 0 additions & 90 deletions ibc-eureka-core/ics03-connection/types/src/error.rs

This file was deleted.

413 changes: 0 additions & 413 deletions ibc-eureka-core/ics03-connection/types/src/events.rs

This file was deleted.

29 changes: 0 additions & 29 deletions ibc-eureka-core/ics03-connection/types/src/lib.rs

This file was deleted.

103 changes: 0 additions & 103 deletions ibc-eureka-core/ics03-connection/types/src/msgs/conn_open_ack.rs

This file was deleted.

This file was deleted.

126 changes: 0 additions & 126 deletions ibc-eureka-core/ics03-connection/types/src/msgs/conn_open_init.rs

This file was deleted.

226 changes: 0 additions & 226 deletions ibc-eureka-core/ics03-connection/types/src/msgs/conn_open_try.rs

This file was deleted.

39 changes: 0 additions & 39 deletions ibc-eureka-core/ics03-connection/types/src/msgs/mod.rs

This file was deleted.

403 changes: 0 additions & 403 deletions ibc-eureka-core/ics03-connection/types/src/version.rs

This file was deleted.

6 changes: 0 additions & 6 deletions ibc-eureka-core/ics04-channel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ all-features = true

[dependencies]
ibc-eureka-core-client = { workspace = true }
ibc-eureka-core-connection = { workspace = true }
ibc-eureka-core-channel-types = { workspace = true }
ibc-eureka-core-commitment-types = { workspace = true }
ibc-eureka-core-host = { workspace = true }
@@ -31,7 +30,6 @@ ibc-primitives = { workspace = true }
default = [ "std" ]
std = [
"ibc-eureka-core-client/std",
"ibc-eureka-core-connection/std",
"ibc-eureka-core-channel-types/std",
"ibc-eureka-core-commitment-types/std",
"ibc-eureka-core-host/std",
@@ -41,7 +39,6 @@ std = [
]
serde = [
"ibc-eureka-core-client/serde",
"ibc-eureka-core-connection/serde",
"ibc-eureka-core-channel-types/serde",
"ibc-eureka-core-commitment-types/serde",
"ibc-eureka-core-host/serde",
@@ -51,7 +48,6 @@ serde = [
]
schema = [
"ibc-eureka-core-client/schema",
"ibc-eureka-core-connection/schema",
"ibc-eureka-core-channel-types/schema",
"ibc-eureka-core-commitment-types/schema",
"ibc-eureka-core-host/schema",
@@ -63,7 +59,6 @@ schema = [
]
borsh = [
"ibc-eureka-core-client/borsh",
"ibc-eureka-core-connection/borsh",
"ibc-eureka-core-channel-types/borsh",
"ibc-eureka-core-commitment-types/borsh",
"ibc-eureka-core-host/borsh",
@@ -73,7 +68,6 @@ borsh = [
]
parity-scale-codec = [
"ibc-eureka-core-client/parity-scale-codec",
"ibc-eureka-core-connection/parity-scale-codec",
"ibc-eureka-core-channel-types/parity-scale-codec",
"ibc-eureka-core-commitment-types/parity-scale-codec",
"ibc-eureka-core-host/parity-scale-codec",
20 changes: 2 additions & 18 deletions ibc-eureka-core/ics04-channel/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
//! ICS4 (channel) context.
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::path::{ChannelEndPath, CommitmentPath, SeqSendPath};
use ibc_eureka_core_host::types::identifiers::Sequence;
use ibc_eureka_core_host::types::path::{CommitmentPath, SeqSendPath};
use ibc_eureka_core_host::{ExecutionContext, ValidationContext};
use ibc_primitives::prelude::*;

@@ -18,12 +16,6 @@
/// Retrieve the context that implements all clients' `ValidationContext`.
fn get_client_validation_context(&self) -> &Self::V;

/// Returns the ChannelEnd for the given `port_id` and `chan_id`.
fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result<ChannelEnd, HostError>;

/// Returns the ConnectionState for the given identifier `connection_id`.
fn connection_end(&self, connection_id: &ConnectionId) -> Result<ConnectionEnd, HostError>;

fn get_next_sequence_send(&self, seq_send_path: &SeqSendPath) -> Result<Sequence, HostError>;
}

@@ -33,21 +25,13 @@
{
type V = T::V;

fn get_client_validation_context(&self) -> &Self::V {
self.get_client_validation_context()
}

Check warning on line 30 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L28-L30

Added lines #L28 - L30 were not covered by tests

fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result<ChannelEnd, HostError> {
self.channel_end(channel_end_path)
}

fn connection_end(&self, connection_id: &ConnectionId) -> Result<ConnectionEnd, HostError> {
self.connection_end(connection_id)
}

fn get_next_sequence_send(&self, seq_send_path: &SeqSendPath) -> Result<Sequence, HostError> {
self.get_next_sequence_send(seq_send_path)
}

Check warning on line 34 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L32-L34

Added lines #L32 - L34 were not covered by tests
}

/// Methods required in send packet execution, to be implemented by the host
@@ -75,27 +59,27 @@
where
T: ExecutionContext,
{
fn store_next_sequence_send(
&mut self,
seq_send_path: &SeqSendPath,
seq: Sequence,
) -> Result<(), HostError> {
self.store_next_sequence_send(seq_send_path, seq)
}

Check warning on line 68 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L62-L68

Added lines #L62 - L68 were not covered by tests

fn store_packet_commitment(
&mut self,
commitment_path: &CommitmentPath,
commitment: PacketCommitment,
) -> Result<(), HostError> {
self.store_packet_commitment(commitment_path, commitment)
}

Check warning on line 76 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L70-L76

Added lines #L70 - L76 were not covered by tests

fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), HostError> {
self.emit_ibc_event(event)
}

Check warning on line 80 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L78-L80

Added lines #L78 - L80 were not covered by tests

fn log_message(&mut self, message: String) -> Result<(), HostError> {
self.log_message(message)
}

Check warning on line 84 in ibc-eureka-core/ics04-channel/src/context.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/context.rs#L82-L84

Added lines #L82 - L84 were not covered by tests
}
78 changes: 16 additions & 62 deletions ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs
Original file line number Diff line number Diff line change
@@ -1,208 +1,162 @@
use ibc_eureka_core_channel_types::channel::{Counterparty, Order, State as ChannelState};
use ibc_eureka_core_channel_types::commitment::{
compute_ack_commitment, compute_packet_commitment,
};
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,
};
use ibc_eureka_core_host::types::path::{AckPath, ClientConsensusStatePath, CommitmentPath, Path};
use ibc_eureka_core_host::{ExecutionContext, ValidationContext};
use ibc_eureka_core_router::module::Module;
use ibc_primitives::prelude::*;

pub fn acknowledgement_packet_validate<ValCtx>(
ctx_a: &ValCtx,
module: &dyn Module,
msg: MsgAcknowledgement,
) -> Result<(), ChannelError>
where
ValCtx: ValidationContext,
{
validate(ctx_a, &msg)?;

Check warning on line 22 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L14-L22

Added lines #L14 - L22 were not covered by tests

module.on_acknowledgement_packet_validate(&msg.packet, &msg.acknowledgement, &msg.signer)
}

Check warning on line 25 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L24-L25

Added lines #L24 - L25 were not covered by tests

pub fn acknowledgement_packet_execute<ExecCtx>(
ctx_a: &mut ExecCtx,
module: &mut dyn Module,
msg: MsgAcknowledgement,
) -> Result<(), ChannelError>
where
ExecCtx: ExecutionContext,
{
let payload = &msg.packet.payloads[0];

let port_id_on_a = &payload.header.source_port.1;
let channel_id_on_a = &msg.packet.header.source_client;
let seq_on_a = &msg.packet.header.seq_on_a;
let packet = &msg.packet;
let payload = &packet.payloads[0];

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];
let (_, port_id_on_a) = &payload.header.source_port;
let channel_id_on_a = &packet.header.target_client_on_source;
let seq_on_a = &packet.header.seq_on_a;

// 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(),
));
let event = IbcEvent::AcknowledgePacket(AcknowledgePacket::new(packet.clone()));
ctx_a.emit_ibc_event(IbcEvent::Message(MessageEvent::Channel))?;
ctx_a.emit_ibc_event(event)?;

Check warning on line 45 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L27-L45

Added lines #L27 - L45 were not covered by tests

let commitment_path_on_a =
CommitmentPath::new(port_id_on_a, channel_id_on_a, msg.packet.header.seq_on_a);
let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a);

// check if we're in the NO-OP case
if ctx_a.get_packet_commitment(&commitment_path_on_a).is_err() {

Check warning on line 50 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L47-L50

Added lines #L47 - L50 were not covered by tests
// This error indicates that the timeout has already been relayed
// or there is a misconfigured relayer attempting to prove a timeout
// for a packet never sent. Core IBC will treat this error as a no-op in order to
// prevent an entire relay transaction from failing and consuming unnecessary fees.
return Ok(());
};

let (extras, cb_result) =
module.on_acknowledgement_packet_execute(&msg.packet, &msg.acknowledgement, &msg.signer);
module.on_acknowledgement_packet_execute(packet, &msg.acknowledgement, &msg.signer);

cb_result?;

Check warning on line 61 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L55-L61

Added lines #L55 - L61 were not covered by tests

// apply state changes
{
ctx_a.delete_packet_commitment(&commitment_path_on_a)?;

Check warning on line 65 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L65

Added line #L65 was not covered by tests

if let Order::Ordered = chan_end_on_a.ordering {
// Note: in validation, we verified that `msg.packet.sequence == nextSeqRecv`
// (where `nextSeqRecv` is the value in the store)
let seq_ack_path_on_a = SeqAckPath::new(port_id_on_a, channel_id_on_a);
ctx_a.store_next_sequence_ack(&seq_ack_path_on_a, (*seq_on_a).increment())?;
}
}

// emit events and logs
{
ctx_a.log_message("success: packet acknowledgement".to_string())?;

Check warning on line 70 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L70

Added line #L70 was not covered by tests

// Note: Acknowledgement event was emitted at the beginning

for module_event in extras.events {
ctx_a.emit_ibc_event(IbcEvent::Module(module_event))?

Check warning on line 75 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L74-L75

Added lines #L74 - L75 were not covered by tests
}

for log_message in extras.log {
ctx_a.log_message(log_message)?;

Check warning on line 79 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L78-L79

Added lines #L78 - L79 were not covered by tests
}
}

Ok(())
}

Check warning on line 84 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L83-L84

Added lines #L83 - L84 were not covered by tests

fn validate<Ctx>(ctx_a: &Ctx, msg: &MsgAcknowledgement) -> Result<(), ChannelError>
where
Ctx: ValidationContext,
{
ctx_a.validate_message_signer(&msg.signer)?;

Check warning on line 90 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L86-L90

Added lines #L86 - L90 were not covered by tests

let packet = &msg.packet;
let payload = &packet.payloads[0];

let port_id_on_a = &payload.header.source_port.1;
let channel_id_on_a = &packet.header.source_client;
let port_id_on_b = &payload.header.target_port.1;
let channel_id_on_b = &packet.header.target_client;
let (prefix_on_a, port_id_on_a) = &payload.header.source_port;
let channel_id_on_a = &packet.header.target_client_on_source;
let (_, port_id_on_b) = &payload.header.target_port;
let channel_id_on_b = &packet.header.source_client_on_target;
let seq_on_a = &packet.header.seq_on_a;
let data = &payload.data;

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)?;

chan_end_on_a.verify_state_matches(&ChannelState::Open)?;

let counterparty = Counterparty::new(port_id_on_b.clone(), Some(channel_id_on_b.clone()));

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);

Check warning on line 102 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L92-L102

Added lines #L92 - L102 were not covered by tests

// Verify packet commitment
let Ok(commitment_on_a) = ctx_a.get_packet_commitment(&commitment_path_on_a) else {

Check warning on line 105 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L105

Added line #L105 was not covered by tests
// This error indicates that the timeout has already been relayed
// or there is a misconfigured relayer attempting to prove a timeout
// for a packet never sent. Core IBC will treat this error as a no-op in order to
// prevent an entire relay transaction from failing and consuming unnecessary fees.
return Ok(());

Check warning on line 110 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L110

Added line #L110 was not covered by tests
};

let expected_commitment_on_a = compute_packet_commitment(
data,
&packet.header.timeout_height_on_b,
&packet.header.timeout_timestamp_on_b,
);

if commitment_on_a != expected_commitment_on_a {
return Err(ChannelError::MismatchedPacketCommitment {
actual: commitment_on_a,
expected: expected_commitment_on_a,
});
}

if let Order::Ordered = chan_end_on_a.ordering {
let seq_ack_path_on_a = SeqAckPath::new(port_id_on_a, channel_id_on_a);
let next_seq_ack = ctx_a.get_next_sequence_ack(&seq_ack_path_on_a)?;
if seq_on_a != &next_seq_ack {
return Err(ChannelError::MismatchedPacketSequence {
actual: *seq_on_a,
expected: next_seq_ack,
});
}
}

// 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();

Check warning on line 131 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L113-L131

Added lines #L113 - L131 were not covered by tests

let client_state_of_b_on_a = client_val_ctx_a.client_state(client_id_on_a)?;

Check warning on line 133 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L133

Added line #L133 was not covered by tests

client_state_of_b_on_a
.status(ctx_a.get_client_validation_context(), client_id_on_a)?
.verify_is_active()?;

Check warning on line 137 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L135-L137

Added lines #L135 - L137 were not covered by tests

client_state_of_b_on_a.validate_proof_height(msg.proof_height_on_b)?;

Check warning on line 139 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L139

Added line #L139 was not covered by tests

let client_cons_state_path_on_a = ClientConsensusStatePath::new(
client_id_on_a.clone(),
msg.proof_height_on_b.revision_number(),
msg.proof_height_on_b.revision_height(),
);
let consensus_state_of_b_on_a =
client_val_ctx_a.consensus_state(&client_cons_state_path_on_a)?;
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),
ack_commitment.into_vec(),
)?;

Check warning on line 158 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L141-L158

Added lines #L141 - L158 were not covered by tests
}

Ok(())
}

Check warning on line 162 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs#L161-L162

Added lines #L161 - L162 were not covered by tests
162 changes: 0 additions & 162 deletions ibc-eureka-core/ics04-channel/src/handler/chan_close_confirm.rs

This file was deleted.

117 changes: 0 additions & 117 deletions ibc-eureka-core/ics04-channel/src/handler/chan_close_init.rs

This file was deleted.

159 changes: 0 additions & 159 deletions ibc-eureka-core/ics04-channel/src/handler/chan_open_ack.rs

This file was deleted.

162 changes: 0 additions & 162 deletions ibc-eureka-core/ics04-channel/src/handler/chan_open_confirm.rs

This file was deleted.

139 changes: 0 additions & 139 deletions ibc-eureka-core/ics04-channel/src/handler/chan_open_init.rs

This file was deleted.

186 changes: 0 additions & 186 deletions ibc-eureka-core/ics04-channel/src/handler/chan_open_try.rs

This file was deleted.

14 changes: 0 additions & 14 deletions ibc-eureka-core/ics04-channel/src/handler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
//! This module implements the processing logic for ICS4 (channel) messages.
mod acknowledgement;
mod chan_close_confirm;
mod chan_close_init;
mod chan_open_ack;
mod chan_open_confirm;
mod chan_open_init;
mod chan_open_try;
mod recv_packet;
mod send_packet;
mod timeout;
mod timeout_on_close;

pub use acknowledgement::*;
pub use chan_close_confirm::*;
pub use chan_close_init::*;
pub use chan_open_ack::*;
pub use chan_open_confirm::*;
pub use chan_open_init::*;
pub use chan_open_try::*;
pub use recv_packet::*;
pub use send_packet::*;
pub use timeout::*;
pub use timeout_on_close::*;
Loading
Loading