Enum diem_sdk::types::trusted_state::TrustedState[][src]

pub enum TrustedState {
    EpochWaypoint(Waypoint),
    EpochState {
        waypoint: Waypoint,
        epoch_state: EpochState,
        accumulator: TransactionAccumulatorSummary,
    },
}
Expand description

TrustedState keeps track of light clients’ latest, trusted view of the ledger state. Light clients can use proofs from a state proof to “ratchet” their view forward to a newer state.

Variants

EpochWaypoint(Waypoint)

The current trusted state is an epoch waypoint, which is a commitment to an epoch change ledger info. Most light clients will start here when syncing for the first time.

Tuple Fields of EpochWaypoint

0: Waypoint
EpochState

The current trusted state is inside a verified epoch (which includes the validator set inside that epoch).

Fields of EpochState

waypoint: Waypoint

The current trusted version and a commitment to a ledger info inside the current trusted epoch.

epoch_state: EpochState

The current epoch and validator set inside that epoch.

accumulator: TransactionAccumulatorSummary

The current verified view of the transaction accumulator. Note that this is not the complete accumulator; rather, it is a summary containing only the frozen subtrees at the currently verified state version. We use the accumulator summary to verify accumulator consistency proofs when applying state proofs.

Implementations

Create an initial trusted state from a trusted epoch waypoint constructed from an epoch-change ledger info.

Note: we can’t actually guarantee this waypoint is actually an epoch waypoint, but the sync will always fail to verify it’s not.

Try to create a trusted state from an epoch-change ledger info and an accumulator summary at the same version.

Fails if the ledger info is not actually an epoch-change ledger info or if the accumulator summary is not consistent with the ledger info.

Verify and ratchet forward our trusted state using an EpochChangeProof (that moves us into the latest epoch), a LedgerInfoWithSignatures inside that epoch, and an AccumulatorConsistencyProof from our current version to that last verifiable ledger info.

If our current trusted state doesn’t have an accumulator summary yet (for example, a client may be starting with an epoch waypoint), then an initial accumulator summary must be provided.

For example, a client sends a GetStateProof request to an upstream FullNode and receives some epoch change proof along with a latest ledger info inside the StateProof response. This function verifies the change proof and ratchets the trusted state version forward if the response successfully moves us into a new epoch or a new latest ledger info within our current epoch.

  • If there was a validation error, e.g., the epoch change proof was invalid, we return an Err.

  • If the message was well formed but stale (i.e., the returned latest ledger is behind our trusted version), we also return an Err since stale responses should always be rejected.

  • If the response is fresh and there is no epoch change, we just ratchet our trusted version to the latest ledger info and return Ok(TrustedStateChange::Version { .. }).

  • If there is a new epoch and the server provides a correct proof, we ratchet our trusted version forward, update our verifier to contain the new validator set, and return Ok(TrustedStateChange::Epoch { .. }).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The associated Hasher type which comes with a unique salt for this type.

Hashes the object and produces a HashValue.

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Verify if the ledger_info is trust worthy.

Returns true in case the given epoch is larger than the existing verifier can support. In this case the EpochChangeProof should be verified and the verifier updated. Read more

Returns true if the given LedgerInfo is stale and probably in our trusted prefix. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

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

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

Performs the conversion.

Should always be Self

Generates a hash used only for tests.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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