Trait ClientStateCommon

Source
pub trait ClientStateCommon: Convertible<Any> {
    // Required methods
    fn verify_consensus_state(
        &self,
        consensus_state: Any,
        host_timestamp: &Timestamp,
    ) -> Result<(), ClientError>;
    fn client_type(&self) -> ClientType;
    fn latest_height(&self) -> Height;
    fn validate_proof_height(
        &self,
        proof_height: Height,
    ) -> Result<(), ClientError>;
    fn verify_upgrade_client(
        &self,
        upgraded_client_state: Any,
        upgraded_consensus_state: Any,
        proof_upgrade_client: CommitmentProofBytes,
        proof_upgrade_consensus_state: CommitmentProofBytes,
        root: &CommitmentRoot,
    ) -> Result<(), ClientError>;
    fn serialize_path(&self, path: Path) -> Result<PathBytes, ClientError>;
    fn verify_membership_raw(
        &self,
        prefix: &CommitmentPrefix,
        proof: &CommitmentProofBytes,
        root: &CommitmentRoot,
        path: PathBytes,
        value: Vec<u8>,
    ) -> Result<(), ClientError>;
    fn verify_non_membership_raw(
        &self,
        prefix: &CommitmentPrefix,
        proof: &CommitmentProofBytes,
        root: &CommitmentRoot,
        path: PathBytes,
    ) -> Result<(), ClientError>;

    // Provided methods
    fn verify_membership(
        &self,
        prefix: &CommitmentPrefix,
        proof: &CommitmentProofBytes,
        root: &CommitmentRoot,
        path: Path,
        value: Vec<u8>,
    ) -> Result<(), ClientError> { ... }
    fn verify_non_membership(
        &self,
        prefix: &CommitmentPrefix,
        proof: &CommitmentProofBytes,
        root: &CommitmentRoot,
        path: Path,
    ) -> Result<(), ClientError> { ... }
}
Expand description

ClientState methods needed in both validation and execution.

They do not require access to a client ValidationContext nor ExecutionContext.

Required Methods§

Source

fn verify_consensus_state( &self, consensus_state: Any, host_timestamp: &Timestamp, ) -> Result<(), ClientError>

Performs basic validation on the consensus_state.

Notably, an implementation should verify that it can properly deserialize the object into the expected format.

Source

fn client_type(&self) -> ClientType

Type of client associated with this state (eg. Tendermint)

Source

fn latest_height(&self) -> Height

The latest height the client was updated to

Source

fn validate_proof_height(&self, proof_height: Height) -> Result<(), ClientError>

Validate that the client is at a sufficient height

Source

fn verify_upgrade_client( &self, upgraded_client_state: Any, upgraded_consensus_state: Any, proof_upgrade_client: CommitmentProofBytes, proof_upgrade_consensus_state: CommitmentProofBytes, root: &CommitmentRoot, ) -> Result<(), ClientError>

Verify the upgraded client and consensus states and validate proofs against the given root.

NOTE: proof heights are not included, as upgrade to a new revision is expected to pass only on the last height committed by the current revision. Clients are responsible for ensuring that the planned last height of the current revision is somehow encoded in the proof verification process. This is to ensure that no premature upgrades occur, since upgrade plans committed to by the counterparty may be cancelled or modified before the last planned height.

Source

fn serialize_path(&self, path: Path) -> Result<PathBytes, ClientError>

Serializes a given path object into a raw path bytes.

This method provides essential information for IBC modules, enabling them to understand how path serialization is performed on the chain this light client represents it before passing the path bytes to either verify_membership_raw() or verify_non_membership_raw().

Source

fn verify_membership_raw( &self, prefix: &CommitmentPrefix, proof: &CommitmentProofBytes, root: &CommitmentRoot, path: PathBytes, value: Vec<u8>, ) -> Result<(), ClientError>

Verifies a proof of the existence of a value at a given raw path bytes.

Source

fn verify_non_membership_raw( &self, prefix: &CommitmentPrefix, proof: &CommitmentProofBytes, root: &CommitmentRoot, path: PathBytes, ) -> Result<(), ClientError>

Verifies the absence of a given proof at a given raw path bytes.

Provided Methods§

Source

fn verify_membership( &self, prefix: &CommitmentPrefix, proof: &CommitmentProofBytes, root: &CommitmentRoot, path: Path, value: Vec<u8>, ) -> Result<(), ClientError>

Verifies a proof of the existence of a value at a given path object.

Source

fn verify_non_membership( &self, prefix: &CommitmentPrefix, proof: &CommitmentProofBytes, root: &CommitmentRoot, path: Path, ) -> Result<(), ClientError>

Verifies the absence of a given proof at a given path object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§