Trait ClientStateValidation

Source
pub trait ClientStateValidation<V>: ClientStateCommon{
    // Required methods
    fn verify_client_message(
        &self,
        ctx: &V,
        client_id: &ClientId,
        client_message: Any,
    ) -> Result<(), ClientError>;
    fn check_for_misbehaviour(
        &self,
        ctx: &V,
        client_id: &ClientId,
        client_message: Any,
    ) -> Result<bool, ClientError>;
    fn status(
        &self,
        ctx: &V,
        client_id: &ClientId,
    ) -> Result<Status, ClientError>;
    fn check_substitute(
        &self,
        ctx: &V,
        substitute_client_state: Any,
    ) -> Result<(), ClientError>;
}
Expand description

ClientState methods which require access to the client’s validation context

The generic type V enables light client developers to expand the set of methods available under the ClientValidationContext trait and use them in their implementation for validating a client state transition.

impl<V> ClientStateValidation<V> for MyClientState
where
    V: ClientValidationContext + MyValidationContext,
{
  // `MyValidationContext` methods available
}

trait MyValidationContext {
  // My Context methods
}

Required Methods§

Source

fn verify_client_message( &self, ctx: &V, client_id: &ClientId, client_message: Any, ) -> Result<(), ClientError>

verify_client_message must verify a client_message. A client_message could be a Header, Misbehaviour. It must handle each type of client_message appropriately. Calls to check_for_misbehaviour, update_state, and update_state_on_misbehaviour will assume that the content of the client_message has been verified and can be trusted. An error should be returned if the client_message fails to verify.

Source

fn check_for_misbehaviour( &self, ctx: &V, client_id: &ClientId, client_message: Any, ) -> Result<bool, ClientError>

Checks for evidence of a misbehaviour in Header or Misbehaviour type. It assumes the client_message has already been verified.

Source

fn status(&self, ctx: &V, client_id: &ClientId) -> Result<Status, ClientError>

Returns the status of the client. Only Active clients are allowed to process packets.

Source

fn check_substitute( &self, ctx: &V, substitute_client_state: Any, ) -> Result<(), ClientError>

Verifies whether the calling (subject) client state matches the substitute client state for the purposes of client recovery.

Note that this validation function does not need to perform all of the validation steps necessary to confirm client recovery. Some checks, such as checking that the subject client state’s latest height < the substitute client’s latest height, as well as checking that the subject client is inactive and that the substitute client is active, are performed by the validate function in the recover_client module at the ics02-client level.

Returns Ok if the subject and substitute client states match, Err otherwise.

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§