pub struct ForeignClient<DstChain, SrcChain>where
    DstChain: ChainHandle,
    SrcChain: ChainHandle,{
    pub id: ClientId,
    pub dst_chain: DstChain,
    pub src_chain: SrcChain,
}

Fields§

§id: ClientId

The identifier of this client. The host chain determines this id upon client creation, so we may be using the default value temporarily.

§dst_chain: DstChain

A handle to the chain hosting this client, i.e., destination chain.

§src_chain: SrcChain

A handle to the chain whose headers this client is verifying, aka the source chain.

Implementations§

source§

impl<DstChain, SrcChain> ForeignClient<DstChain, SrcChain>where DstChain: ChainHandle, SrcChain: ChainHandle,

source

pub fn new( dst_chain: DstChain, src_chain: SrcChain ) -> Result<ForeignClient<DstChain, SrcChain>, ForeignClientError>

Creates a new foreign client on dst_chain. Blocks until the client is created, or an error occurs. Post-condition: dst_chain hosts an IBC client for src_chain.

source

pub fn restore( id: ClientId, dst_chain: DstChain, src_chain: SrcChain ) -> ForeignClient<DstChain, SrcChain>

source

pub fn find( expected_target_chain: SrcChain, host_chain: DstChain, client_id: &ClientId ) -> Result<ForeignClient<DstChain, SrcChain>, ForeignClientError>

Queries host_chain to verify that a client with identifier client_id exists. If the client does not exist, returns an error. If the client exists, cross-checks that the identifier for the target chain of this client (i.e., the chain whose headers this client is verifying) is consistent with expected_target_chain, and if so, return a new ForeignClient representing this client.

source

pub fn upgrade( &self, src_upgrade_height: Height ) -> Result<Vec<IbcEvent>, ForeignClientError>

Create and send a transaction to perform a client upgrade. src_upgrade_height: The height on the source chain at which the chain will halt for the upgrade.

source

pub fn dst_chain(&self) -> DstChain

Returns a handle to the chain hosting this client.

source

pub fn src_chain(&self) -> SrcChain

Returns a handle to the chain whose headers this client is sourcing (the source chain).

source

pub fn id(&self) -> &ClientId

source

pub fn build_create_client( &self, options: CreateOptions ) -> Result<MsgCreateClient, ForeignClientError>

Lower-level interface for preparing a message to create a client.

source

pub fn build_create_client_and_send( &self, options: CreateOptions ) -> Result<IbcEventWithHeight, ForeignClientError>

Returns the identifier of the newly created client.

source

pub fn validated_client_state( &self ) -> Result<(AnyClientState, Option<Duration>), ForeignClientError>

source

pub fn is_frozen(&self) -> bool

source

pub fn is_expired(&self) -> bool

source

pub fn is_expired_or_frozen(&self) -> bool

source

pub fn refresh(&mut self) -> Result<Option<Vec<IbcEvent>>, ForeignClientError>

source

pub fn wait_and_build_update_client( &self, target_height: Height ) -> Result<Vec<Any>, ForeignClientError>

Wrapper for build_update_client_with_trusted.

source

pub fn wait_and_build_update_client_with_trusted( &self, target_height: Height, trusted_height: Option<Height> ) -> Result<Vec<Any>, ForeignClientError>

Wait for the source chain application to reach height target_height before building the update client messages.

Returns a vector with a message for updating the client to height target_height. If the client already stores a consensus state for this height, returns an empty vector.

source

pub fn build_update_client_with_trusted( &self, target_height: Height, maybe_trusted_height: Option<Height> ) -> Result<Vec<MsgUpdateClient>, ForeignClientError>

source

pub fn build_latest_update_client_and_send( &self ) -> Result<Vec<IbcEvent>, ForeignClientError>

source

pub fn build_update_client_and_send( &self, target_query_height: QueryHeight, trusted_height: Option<Height> ) -> Result<Vec<IbcEvent>, ForeignClientError>

source

pub fn update(&self) -> Result<(), ForeignClientError>

Attempts to update a client using header from the latest height of its source chain.

source

pub fn fetch_update_client_event( &self, consensus_height: Height ) -> Result<Option<UpdateClient>, ForeignClientError>

Retrieves the client update event that was emitted when a consensus state at the specified height was created on chain. It is possible that the event cannot be retrieved if the information is not yet available on the full node. To handle this the query is retried a few times.

source

pub fn detect_misbehaviour( &self, update: Option<&UpdateClient> ) -> Result<Option<MisbehaviourEvidence>, ForeignClientError>

Checks for evidence of misbehaviour. The check starts with and update_event emitted by chain B (dst_chain) for a client update with a header from chain A (src_chain). The algorithm goes backwards through the headers until it gets to the first misbehaviour.

The following cases are covered: 1 - fork: Assumes at least one consensus state before the fork point exists. Let existing consensus states on chain B be: [Sn,.., Sf, Sf-1, S0] with Sf-1 being the most recent state before fork. Chain A is queried for a header Hf' at Sf.height and if it is different than the Hf in the event for the client update (the one that has generated Sf on chain), then the two headers are included in the evidence and submitted. Note that in this case the headers are different but have the same height.

2 - BFT time violation for unavailable header (a.k.a. Future Lunatic Attack or FLA): Some header with a height that is higher than the latest height on A has been accepted and a consensus state was created on B. Note that this implies that the timestamp of this header must be within the clock_drift of the client. Assume the client on B has been updated with h2(not present on/ produced by chain A) and it has a timestamp of t2 that is at most clock_drift in the future. Then the latest header from A is fetched, let it be h1, with a timestamp of t1. If t1 >= t2 then evidence of misbehavior is submitted to A.

3 - BFT time violation for existing headers (TODO): Ensure that consensus state times are monotonically increasing with height.

Other notes:

  • the algorithm builds misbehavior at each consensus height, starting with the highest height assuming the previous one is trusted. It submits the first constructed evidence (the one with the highest height)
  • a lot of the logic here is derived from the behavior of the only implemented client (ics07-tendermint) and might not be general enough.
source

pub fn detect_misbehaviour_and_submit_evidence( &self, update_event: Option<UpdateClient> ) -> MisbehaviourResults

source

pub fn map_chain<DstChain2, SrcChain2>( self, map_dst: impl Fn(DstChain) -> DstChain2, map_src: impl Fn(SrcChain) -> SrcChain2 ) -> ForeignClient<DstChain2, SrcChain2>where DstChain2: ChainHandle, SrcChain2: ChainHandle,

Trait Implementations§

source§

impl<DstChain, SrcChain> Clone for ForeignClient<DstChain, SrcChain>where DstChain: Clone + ChainHandle, SrcChain: Clone + ChainHandle,

source§

fn clone(&self) -> ForeignClient<DstChain, SrcChain>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<DstChain, SrcChain> Debug for ForeignClient<DstChain, SrcChain>where DstChain: Debug + ChainHandle, SrcChain: Debug + ChainHandle,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<DstChain, SrcChain> Display for ForeignClient<DstChain, SrcChain>where DstChain: ChainHandle, SrcChain: ChainHandle,

Used in Output messages. Provides a concise description of a ForeignClient, using the format: {CHAIN-ID}->{CHAIN-ID}:{CLIENT} where the first chain identifier is for the source chain, and the second chain identifier is the destination (which hosts the client) chain.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<DstChain: ChainHandle, SrcChain: ChainHandle> TaggedForeignClientExt<DstChain, SrcChain> for ForeignClient<DstChain, SrcChain>

source§

fn tagged_src_chain_id(&self) -> TaggedChainId<SrcChain>

Get the source chain ID.
source§

fn tagged_dst_chain_id(&self) -> TaggedChainId<DstChain>

Get the destination chain ID.
source§

fn tagged_client_id(&self) -> TaggedClientIdRef<'_, DstChain, SrcChain>

Get the client ID of the destination chain that corresponds to the source chain.

Auto Trait Implementations§

§

impl<DstChain, SrcChain> RefUnwindSafe for ForeignClient<DstChain, SrcChain>where DstChain: RefUnwindSafe, SrcChain: RefUnwindSafe,

§

impl<DstChain, SrcChain> Send for ForeignClient<DstChain, SrcChain>

§

impl<DstChain, SrcChain> Sync for ForeignClient<DstChain, SrcChain>

§

impl<DstChain, SrcChain> Unpin for ForeignClient<DstChain, SrcChain>where DstChain: Unpin, SrcChain: Unpin,

§

impl<DstChain, SrcChain> UnwindSafe for ForeignClient<DstChain, SrcChain>where DstChain: UnwindSafe, SrcChain: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for Twhere T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Borrow this concrete type as a &dyn Any
§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Borrow this concrete type as a &mut dyn Any
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where C: Color,

Set the background color generically. Read more
§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SectionExt for Twhere T: Display + Send + Sync + 'static,

source§

fn header<C>(self, header: C) -> IndentedSection<C, T>where C: Display + Send + Sync + 'static,

Add a header to a Section and indent the body Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more