[][src]Struct tendermint_light_client::light_client::LightClient

pub struct LightClient {
    pub peer: PeerId,
    pub options: Options,
    // some fields omitted
}

The light client implements a read operation of a header from the blockchain, by communicating with full nodes. As full nodes may be faulty, it cannot trust the received information, but the light client has to check whether the header it receives coincides with the one generated by Tendermint consensus.

In the Tendermint blockchain, the validator set may change with every new block. The staking and unbonding mechanism induces a security model: starting at time of the header, more than two-thirds of the next validators of a new block are correct for the duration of the trusted period. The fault-tolerant read operation is designed for this security model.

Fields

peer: PeerId

The peer id of the peer this client is connected to

options: Options

Options for this light client

Implementations

impl LightClient[src]

pub fn new(
    peer: PeerId,
    options: Options,
    clock: impl Clock + 'static,
    scheduler: impl Scheduler + 'static,
    verifier: impl Verifier + 'static,
    io: impl Io + 'static
) -> Self
[src]

Constructs a new light client

pub fn from_boxed(
    peer: PeerId,
    options: Options,
    clock: Box<dyn Clock>,
    scheduler: Box<dyn Scheduler>,
    verifier: Box<dyn Verifier>,
    io: Box<dyn Io>
) -> Self
[src]

Constructs a new light client from boxed components

pub fn verify_to_highest(
    &mut self,
    state: &mut State
) -> Result<LightBlock, Error>
[src]

Attempt to update the light client to the highest block of the primary node.

Note: This function delegates the actual work to verify_to_target.

pub fn verify_to_target(
    &self,
    target_height: Height,
    state: &mut State
) -> Result<LightBlock, Error>
[src]

Update the light client to a block of the primary node at the given height.

This is the main function and uses the following components:

  • The I/O component is called to fetch the next light block. It is the only component that communicates with other nodes.
  • The Verifier component checks whether a header is valid and checks if a new light block should be trusted based on a previously verified light block.
  • The Scheduler component decides which height to try to verify next, in case the current block pass verification but cannot be trusted yet.

Implements

  • [LCV-DIST-SAFE.1]
  • [LCV-DIST-LIFE.1]
  • [LCV-PRE-TP.1]
  • [LCV-POST-LS.1]
  • [LCV-INV-TP.1]

Postcondition

  • The light store contains a light block that corresponds to a block of the blockchain of height target_height [LCV-POST-LS.1]

Error conditions

  • The light store does not contains a trusted light block within the trusting period [LCV-PRE-TP.1]
  • If the core verification loop invariant is violated [LCV-INV-TP.1]
  • If verification of a light block fails
  • If the fetching a light block from the primary node fails

Contracts

Post-condition: ret . is_ok() == > trusted_store_contains_block_at_target_height(state . light_store . as_ref(), target_height,)

pub fn get_or_fetch_block(
    &self,
    height: Height,
    state: &mut State
) -> Result<(LightBlock, Status), Error>
[src]

Look in the light store for a block from the given peer at the given height, which has not previously failed verification (ie. its status is not Failed).

If one cannot be found, fetch the block from the given peer and store it in the light store with Unverified status.

Postcondition

  • The provider of block that is returned matches the given peer.

Contracts

Post-condition: ret . as_ref() . map(| (lb, _) | lb . provider == self . peer) . unwrap_or(true)

Trait Implementations

impl Debug for LightClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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