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

impl: packet handler for eureka #1373

Draft
wants to merge 13 commits into
base: rano/eureka/1371
Choose a base branch
from
18 changes: 18 additions & 0 deletions ibc-eureka-core/ics02-client/context/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ibc_eureka_core_client_types::Height;
use ibc_eureka_core_commitment_types::commitment::CommitmentPrefix;
use ibc_eureka_core_host_types::error::HostError;
use ibc_eureka_core_host_types::identifiers::ClientId;
use ibc_eureka_core_host_types::path::{ClientConsensusStatePath, ClientStatePath};
Expand Down Expand Up @@ -39,6 +40,12 @@
client_id: &ClientId,
height: &Height,
) -> Result<(Timestamp, Height), HostError>;

/// Returns the client identifier and the commitment prefix of the counterparty client.
fn counterparty_meta(
&self,
client_id: &ClientId,
) -> Result<Option<(ClientId, CommitmentPrefix)>, HostError>;
}

/// Defines the methods that all client `ExecutionContext`s (precisely the
Expand All @@ -54,9 +61,9 @@
{
type ClientStateMut: ClientStateExecution<Self>;

fn client_state_mut(&self, client_id: &ClientId) -> Result<Self::ClientStateMut, HostError> {
self.client_state(client_id)
}

Check warning on line 66 in ibc-eureka-core/ics02-client/context/src/context.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/context/src/context.rs#L64-L66

Added lines #L64 - L66 were not covered by tests

/// Called upon successful client creation and update
fn store_client_state(
Expand Down Expand Up @@ -98,6 +105,17 @@
///
/// Note that this timestamp is determined by the host.
fn delete_update_meta(&mut self, client_id: ClientId, height: Height) -> Result<(), HostError>;

/// Store the client identifier and the commitment prefix of the counterparty client.
fn store_counterparty_meta(
&self,
client_id: &ClientId,
counterparty_client_id: &ClientId,
counterparty_prefix: &CommitmentPrefix,
) -> Result<(), HostError>;

/// Delete the client identifier and the commitment prefix of the counterparty client.
fn delete_counterparty_meta(&self, client_id: &ClientId) -> Result<(), HostError>;
}

/// An optional trait that extends the client validation context capabilities by
Expand Down
1 change: 1 addition & 0 deletions ibc-eureka-core/ics02-client/src/handler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This module implements the processing logic for ICS2 (client abstractions and functions) msgs.

pub mod create_client;
pub mod provide_counterparty;
pub mod recover_client;
pub mod update_client;
pub mod upgrade_client;
57 changes: 57 additions & 0 deletions ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Protocol logic specific to processing ICS2 messages of type `MsgProvideCouterparty`.

use ibc_eureka_core_client_context::prelude::*;
use ibc_eureka_core_client_types::error::ClientError;
use ibc_eureka_core_client_types::msgs::MsgProvideCouterparty;
use ibc_eureka_core_host::{ExecutionContext, ValidationContext};
use ibc_primitives::prelude::*;

pub fn validate<Ctx>(ctx: &Ctx, msg: MsgProvideCouterparty) -> Result<(), ClientError>
where
Ctx: ValidationContext,
{
let MsgProvideCouterparty {
client_id, signer, ..
} = &msg;

ctx.validate_message_signer(signer)?;

Check warning on line 17 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L9-L17

Added lines #L9 - L17 were not covered by tests

let client_val_ctx = ctx.get_client_validation_context();

Check warning on line 19 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L19

Added line #L19 was not covered by tests

// Read client state from the host chain store. The client should already exist.
let client_state = client_val_ctx.client_state(client_id)?;

Check warning on line 22 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L22

Added line #L22 was not covered by tests

client_state
.status(client_val_ctx, client_id)?
.verify_is_active()?;

Check warning on line 26 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L24-L26

Added lines #L24 - L26 were not covered by tests

if client_val_ctx.counterparty_meta(client_id)?.is_some() {
return Err(ClientError::ClientSpecific {
description: "counterparty is already provided".into(),
});
}

Ok(())
}

Check warning on line 35 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L28-L35

Added lines #L28 - L35 were not covered by tests

pub fn execute<Ctx>(ctx: &mut Ctx, msg: MsgProvideCouterparty) -> Result<(), ClientError>
where
Ctx: ExecutionContext,
{
let MsgProvideCouterparty {
client_id,
counterparty_client_id,
counterparty_commitment_prefix,
..
} = &msg;

let client_exec_ctx = ctx.get_client_execution_context();

client_exec_ctx.store_counterparty_meta(
client_id,
counterparty_client_id,
counterparty_commitment_prefix,
)?;

Check warning on line 54 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L37-L54

Added lines #L37 - L54 were not covered by tests

Ok(())
}

Check warning on line 57 in ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs#L56-L57

Added lines #L56 - L57 were not covered by tests
3 changes: 3 additions & 0 deletions ibc-eureka-core/ics02-client/types/src/msgs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

mod create_client;
mod misbehaviour;
mod provide_counterparty;
mod recover_client;
mod update_client;
mod upgrade_client;

pub use create_client::*;
pub use misbehaviour::*;
pub use provide_counterparty::*;
pub use recover_client::*;
pub use update_client::*;
pub use upgrade_client::*;
Expand All @@ -23,7 +25,7 @@
#[allow(dead_code)]
#[cfg_attr(
feature = "borsh",
derive(borsh::BorshSerialize, borsh::BorshDeserialize)

Check warning on line 28 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L28

Added line #L28 was not covered by tests
)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)]
Expand All @@ -33,6 +35,7 @@
Misbehaviour(MsgSubmitMisbehaviour),
UpgradeClient(MsgUpgradeClient),
RecoverClient(MsgRecoverClient),
ProvideCounterparty(MsgProvideCouterparty),
}

pub enum MsgUpdateOrMisbehaviour {
Expand All @@ -41,24 +44,24 @@
}

impl MsgUpdateOrMisbehaviour {
pub fn client_id(&self) -> &ClientId {
match self {
MsgUpdateOrMisbehaviour::UpdateClient(msg) => &msg.client_id,
MsgUpdateOrMisbehaviour::Misbehaviour(msg) => &msg.client_id,

Check warning on line 50 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L47-L50

Added lines #L47 - L50 were not covered by tests
}
}

Check warning on line 52 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L52

Added line #L52 was not covered by tests

pub fn client_message(self) -> Any {
match self {
MsgUpdateOrMisbehaviour::UpdateClient(msg) => msg.client_message,
MsgUpdateOrMisbehaviour::Misbehaviour(msg) => msg.misbehaviour,

Check warning on line 57 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L54-L57

Added lines #L54 - L57 were not covered by tests
}
}

Check warning on line 59 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L59

Added line #L59 was not covered by tests

pub fn signer(&self) -> &Signer {
match self {
MsgUpdateOrMisbehaviour::UpdateClient(msg) => &msg.signer,
MsgUpdateOrMisbehaviour::Misbehaviour(msg) => &msg.signer,

Check warning on line 64 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L61-L64

Added lines #L61 - L64 were not covered by tests
}
}

Check warning on line 66 in ibc-eureka-core/ics02-client/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/mod.rs#L66

Added line #L66 was not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! Definition of domain type message `MsgProvideCouterparty`.

use ibc_eureka_core_commitment_types::commitment::CommitmentPrefix;
use ibc_eureka_core_host_types::identifiers::ClientId;
use ibc_primitives::prelude::*;
use ibc_primitives::Signer;

pub const _PROVIDE_COUNTERPARTY_TYPE_URL: &str = "/ibc.core.client.v1.MsgProvideCouterparty";

/// A type of message that links an on-chain (IBC) client to its counterparty.
#[cfg_attr(
feature = "borsh",
derive(borsh::BorshSerialize, borsh::BorshDeserialize)

Check warning on line 13 in ibc-eureka-core/ics02-client/types/src/msgs/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/provide_counterparty.rs#L13

Added line #L13 was not covered by tests
)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MsgProvideCouterparty {
pub client_id: ClientId,
pub counterparty_client_id: ClientId,
pub counterparty_commitment_prefix: CommitmentPrefix,
pub signer: Signer,
}

impl MsgProvideCouterparty {
pub fn new(
client_id: ClientId,
counterparty_client_id: ClientId,
counterparty_commitment_prefix: CommitmentPrefix,
signer: Signer,
) -> Self {
MsgProvideCouterparty {
client_id,
counterparty_client_id,
counterparty_commitment_prefix,
signer,
}
}

Check warning on line 37 in ibc-eureka-core/ics02-client/types/src/msgs/provide_counterparty.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics02-client/types/src/msgs/provide_counterparty.rs#L25-L37

Added lines #L25 - L37 were not covered by tests
}
4 changes: 3 additions & 1 deletion ibc-eureka-core/ics04-channel/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use ibc_eureka_core_handler_types::events::IbcEvent;
use ibc_eureka_core_host::types::error::HostError;
use ibc_eureka_core_host::types::identifiers::Sequence;
use ibc_eureka_core_host::types::path::{CommitmentPath, SeqSendPath};
use ibc_eureka_core_host::types::path::{
CommitmentPathV2 as CommitmentPath, SeqSendPathV2 as SeqSendPath,
};
use ibc_eureka_core_host::{ExecutionContext, ValidationContext};
use ibc_primitives::prelude::*;

Expand All @@ -25,13 +27,13 @@
{
type V = T::V;

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L30 - L32 were not covered by tests

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 36 in ibc-eureka-core/ics04-channel/src/context.rs

View check run for this annotation

Codecov / codecov/patch

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

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

/// Methods required in send packet execution, to be implemented by the host
Expand Down Expand Up @@ -59,27 +61,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 70 in ibc-eureka-core/ics04-channel/src/context.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L64 - L70 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 78 in ibc-eureka-core/ics04-channel/src/context.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L72 - L78 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L80 - L82 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L84 - L86 were not covered by tests
}
67 changes: 47 additions & 20 deletions ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,157 +6,184 @@
use ibc_eureka_core_channel_types::msgs::MsgAcknowledgement;
use ibc_eureka_core_client::context::prelude::*;
use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent};
use ibc_eureka_core_host::types::path::{AckPath, ClientConsensusStatePath, CommitmentPath, Path};
use ibc_eureka_core_host::types::identifiers::ClientId;
use ibc_eureka_core_host::types::path::{
AckPathV2 as AckPath, ClientConsensusStatePath, CommitmentPathV2 as 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 25 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L17 - L25 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L27 - L28 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 packet = &msg.packet;
let payload = &packet.payloads[0];

let (_, port_id_on_a) = &payload.header.source_port;
let channel_id_on_a = &packet.header.target_client_on_source;
let channel_target_client_on_source = &packet.header.target_client_on_source;
let channel_source_client_on_target = &packet.header.source_client_on_target;
let seq_on_a = &packet.header.seq_on_a;

// In all cases, this event is emitted
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 47 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L30 - L47 were not covered by tests

let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a);
let commitment_path_on_a = CommitmentPath::new(
channel_source_client_on_target.as_ref(),
channel_target_client_on_source.as_ref(),
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 56 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L49 - L56 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(packet, &msg.acknowledgement, &msg.signer);

cb_result?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L61 - L67 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L71 was not covered by tests
}

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L76 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 81 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L80 - L81 were not covered by tests
}

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L84 - L85 were not covered by tests
}
}

Ok(())
}

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L89 - L90 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 96 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L92 - L96 were not covered by tests

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

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 channel_target_client_on_source = &packet.header.target_client_on_source;
let channel_source_client_on_target = &packet.header.source_client_on_target;
let seq_on_a = &packet.header.seq_on_a;
let data = &payload.data;

let commitment_path_on_a = CommitmentPath::new(port_id_on_a, channel_id_on_a, *seq_on_a);
let commitment_path_on_a = CommitmentPath::new(
channel_source_client_on_target.as_ref(),
channel_target_client_on_source.as_ref(),
seq_on_a,
);

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L98 - L110 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 113 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L113 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 118 in ibc-eureka-core/ics04-channel/src/handler/acknowledgement.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L118 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,
});
}

// Verify proofs
{
// TODO(rano): avoid a vs b confusion
let client_id_on_a = channel_id_on_b.as_ref();
let id_target_client_on_source = channel_target_client_on_source.as_ref();
let id_source_client_on_target: &ClientId = channel_source_client_on_target.as_ref();

let client_val_ctx_a = ctx_a.get_client_validation_context();

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L121 - L140 were not covered by tests

let client_state_of_b_on_a = client_val_ctx_a.client_state(client_id_on_a)?;
let (stored_id_source_client_on_target, target_prefix) = client_val_ctx_a
.counterparty_meta(id_target_client_on_source)?
.ok_or(ChannelError::MissingCounterparty)?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L142 - L144 were not covered by tests

client_state_of_b_on_a
.status(ctx_a.get_client_validation_context(), client_id_on_a)?
if &stored_id_source_client_on_target != id_source_client_on_target {
return Err(ChannelError::MismatchCounterparty {
expected: stored_id_source_client_on_target.clone(),
actual: id_source_client_on_target.clone(),
});
}

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L146 - L151 were not covered by tests

let target_client_on_source = client_val_ctx_a.client_state(id_target_client_on_source)?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L153 was not covered by tests

target_client_on_source
.status(
ctx_a.get_client_validation_context(),
id_target_client_on_source,
)?
.verify_is_active()?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L155 - L160 were not covered by tests

client_state_of_b_on_a.validate_proof_height(msg.proof_height_on_b)?;
target_client_on_source.validate_proof_height(msg.proof_height_on_b)?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L162 was not covered by tests

let client_cons_state_path_on_a = ClientConsensusStatePath::new(
client_id_on_a.clone(),
id_target_client_on_source.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);
let ack_path_on_b = AckPath::new(
channel_source_client_on_target.as_ref(),
channel_target_client_on_source.as_ref(),
seq_on_a,
);

// Verify the proof for the packet against the chain store.
client_state_of_b_on_a.verify_membership(
prefix_on_a,
target_client_on_source.verify_membership(
&target_prefix,
&msg.proof_acked_on_b,
consensus_state_of_b_on_a.root(),
Path::Ack(ack_path_on_b),
Path::AckV2(ack_path_on_b),
ack_commitment.into_vec(),
)?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L164 - L185 were not covered by tests
}

Ok(())
}

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L188 - L189 were not covered by tests
Loading
Loading