Skip to main content

LedgerEntry

Struct LedgerEntry 

Source
pub struct LedgerEntry {
    pub seq: u64,
    pub prev: Digest,
    pub run: RunId,
    pub step: StepId,
    pub grant: GrantDelta,
    pub cost: CostRecord,
    pub evidence: Option<Evidence>,
    pub journal: Option<JournalRef>,
    pub isolation: Option<Isolation>,
}
Expand description

λ — one append-only, hash-chained ledger record.

§Example

use boundgraph_core::{Canonical, CostRecord, Digest, GrantDelta, GrantSet,
                 LedgerEntry, RunId, StepId};

let run = RunId::new();
let step = StepId::new(Digest::of(b"step-1"));
let delta = GrantDelta::new(GrantSet::EMPTY, GrantSet::EMPTY, GrantSet::EMPTY);

let first = LedgerEntry::genesis(run, step, delta.clone(), CostRecord::default(), None, None);
let second = LedgerEntry::following(&first, step, delta, CostRecord::default(), None, None)?;

// Each entry commits to the one before it.
assert_eq!(second.prev, first.digest()?);
assert!(second.follows(&first)?);

Fields§

§seq: u64

Position in the chain, starting at zero and gapless.

§prev: Digest

Digest of entry seq - 1. The genesis entry links to all-zero.

§run: RunId

Which run this belongs to.

§step: StepId

Which step this records.

§grant: GrantDelta

What was requested, granted, and attenuated.

§cost: CostRecord

What it cost.

§evidence: Option<Evidence>

The verdict, where the step reached one.

§journal: Option<JournalRef>

Where the journalled nondeterministic inputs live.

§isolation: Option<Isolation>

What actually confined the step, where the runner said (US-0508).

In the entry rather than beside it, because it is a fact about the step’s authority and belongs where GrantDelta is: the chain commits to it, so a confinement record cannot be edited afterwards without giving itself away. That is the whole difference between “this ran confined” being checkable and being trusted.

None means the runner did not say, and is deliberately distinct from Confinement::NONE, which means it ran with nothing enforced. Skipped when absent, so an entry from a runner that says nothing encodes exactly as it did before this field existed and every digest already written stays valid.

Implementations§

Source§

impl LedgerEntry

Source

pub fn genesis( run: RunId, step: StepId, grant: GrantDelta, cost: CostRecord, evidence: Option<Evidence>, journal: Option<JournalRef>, ) -> Self

The first entry in a chain.

Source

pub fn following( previous: &Self, step: StepId, grant: GrantDelta, cost: CostRecord, evidence: Option<Evidence>, journal: Option<JournalRef>, ) -> Result<Self, CanonicalError>

The next entry after previous, linked to it by digest.

§Errors

Returns CanonicalError if previous cannot be canonically encoded, which would make the link uncomputable.

Source

pub fn confined_by(self, isolation: Isolation) -> Self

Record what actually confined the step (US-0508).

A builder rather than a seventh constructor argument: the two constructors are what every sink calls, most transitions are not an execution, and a parameter that was None on five appends out of six would be noise at every call site that never had one to give.

Setting it changes the entry’s digest, so this belongs before the entry is handed to a chain rather than after.

Source

pub const fn confinement(&self) -> Option<Isolation>

What confined this step, where the runner said.

None means unrecorded. See isolation: a step that ran with nothing enforced returns Some.

Source

pub const fn is_confinement_recorded(&self) -> bool

Whether this entry records what confined the step at all.

Source

pub const fn ran_virtualised(&self) -> bool

Whether this step ran in a virtualising tier — what Profile C asks for.

false for a step whose confinement was never recorded, because an unrecorded step is not evidence that anything virtualised it. A caller that needs to tell the two apart reads is_confinement_recorded.

Source

pub fn follows(&self, previous: &Self) -> Result<bool, CanonicalError>

Whether this entry genuinely follows previous.

Checks both the sequence number and the digest link. A gap or a broken link means the chain has been altered.

§Errors

Returns CanonicalError if previous cannot be canonically encoded.

Source

pub fn is_genesis(&self) -> bool

Whether this is the first entry in a chain.

Trait Implementations§

Source§

impl Clone for LedgerEntry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LedgerEntry

Source§

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

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

impl<'de> Deserialize<'de> for LedgerEntry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LedgerEntry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for LedgerEntry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LedgerEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> Canonical for T
where T: Serialize + ?Sized,

Source§

fn canonical_bytes(&self) -> Result<Vec<u8>, CanonicalError>

The canonical CBOR encoding of this value.
Source§

fn digest(&self) -> Result<Digest, CanonicalError>

The blake3 digest of this value’s canonical encoding.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

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

Source§

fn vzip(self) -> V