pub fn verify_packet_recv_proofs(
    ctx: &dyn ChannelReader,
    packet: &Packet,
    client_id: ClientId,
    proofs: &Proofs,
) -> Result<(), Error> {
    let client_state = ctx
        .client_state(&client_id)
        .ok_or_else(|| Kind::MissingClientState(client_id.clone()))?;

    // The client must not be frozen.
    if client_state.is_frozen() {
        return Err(Kind::FrozenClient(client_id).into());
    }

    if ctx
        .client_consensus_state(&client_id, proofs.height())
        .is_none()
    {
        return Err(Kind::MissingClientConsensusState(client_id, proofs.height()).into());
    }

    let client_def = AnyClient::from_client_type(client_state.client_type());

    let input = format!(
        "{:?},{:?},{:?}",
        packet.timeout_timestamp, packet.timeout_height, packet.data
    );
    let commitment = ctx.hash(input);

    // Verify the proof for the packet against the chain store.
    Ok(client_def
        .verify_packet_data(
            &client_state,
            proofs.height(),
            proofs.object_proof(),
            &packet.source_port,
            &packet.source_channel,
            &packet.sequence,
            commitment,
        )
        .map_err(|_| Kind::PacketVerificationFailed(packet.sequence))?)
}
/// Entry point for verifying all proofs bundled in a ICS4 packet recv. message.
Entry point for verifying all proofs bundled in a ICS4 packet recv. message.
Entry point for verifying all proofs bundled in a ICS4 packet recv . message .
pub fn verify_packet_recv_proofs(
    ctx: &dyn ChannelReader,
    packet: &Packet,
    client_id: ClientId,
    proofs: &Proofs,
) -> Result<(), Error> {
    let client_state = ctx
        .client_state(&client_id)
        .ok_or_else(|| Kind::MissingClientState(client_id.clone()))?;
    // The client must not be frozen.
    if client_state.is_frozen() {
        return Err(Kind::FrozenClient(client_id).into());
    }
    if ctx
        .client_consensus_state(&client_id, proofs.height())
        .is_none()
    {
        return Err(Kind::MissingClientConsensusState(client_id, proofs.height()).into());
    }
    let client_def = AnyClient::from_client_type(client_state.client_type());
    let input = format!(
        "{:?},{:?},{:?}",
        packet.timeout_timestamp, packet.timeout_height, packet.data
    );
    let commitment = ctx.hash(input);
    // Verify the proof for the packet against the chain store.
    Ok(client_def
        .verify_packet_data(
            &client_state,
            proofs.height(),
            proofs.object_proof(),
            &packet.source_port,
            &packet.source_channel,
            &packet.sequence,
            commitment,
        )
        .map_err(|_| Kind::PacketVerificationFailed(packet.sequence))?)
}
pub fn verify_packet_recv_proofs ( ctx : & dyn ChannelReader , packet : & Packet , client_id : ClientId , proofs : & Proofs , ) -> Result < ( ) , Error > { let client_state = ctx . client_state ( & client_id ) . ok_or_else ( | | Kind :: MissingClientState ( client_id . clone ( ) ) ) ? ; // The client must not be frozen. if client_state . is_frozen ( ) { return Err ( Kind :: FrozenClient ( client_id ) . into ( ) ) ; } if ctx . client_consensus_state ( & client_id , proofs . height ( ) ) . is_none ( ) { return Err ( Kind :: MissingClientConsensusState ( client_id , proofs . height ( ) ) . into ( ) ) ; } let client_def = AnyClient :: from_client_type ( client_state . client_type ( ) ) ; let input = format ! ( " " packet timeout_timestamp packet timeout_height packet data ) ; let commitment = ctx . hash ( input ) ; // Verify the proof for the packet against the chain store. Ok ( client_def . verify_packet_data ( & client_state , proofs . height ( ) , proofs . object_proof ( ) , & packet . source_port , & packet . source_channel , & packet . sequence , commitment , ) . map_err ( | _ | Kind :: PacketVerificationFailed ( packet . sequence ) ) ? ) }
Entry point for verifying all proofs bundled in a ICS4 packet recv.
Entry point for verifying all proofs bundled in a ICS4 packet recv .
ctx
&dyn ChannelReader
packet
&Packet
client_id
ClientId
proofs
&Proofs
ctx
&dyn ChannelReader
packet
&Packet
client_id
ClientId
proofs
&Proofs