Skip to main content

CommitmentPipeline

Struct CommitmentPipeline 

Source
pub struct CommitmentPipeline<S, M = MemoryMmrStore> {
    state_store: S,
    risk_store: S,
    command_mmr: HypercallMmr<M>,
    obligation_mmr: HypercallMmr<M>,
    intent_mmr: HypercallMmr<M>,
    version: Version,
    prune_window: u64,
}
Expand description

The commitment pipeline.

Generic over the store backend (S) so it works with both FastMemoryStore (tests) and RocksDbStore (production).

Two separate JMTs:

  • State tree: accounts, positions, orders, instruments, oracles, global
  • Risk tree: per-account risk metrics (equity, margin, scanning risk)

Plus three MMRs for append-only data (command log, obligations, intents).

Fields§

§state_store: S§risk_store: S§command_mmr: HypercallMmr<M>§obligation_mmr: HypercallMmr<M>§intent_mmr: HypercallMmr<M>§version: Version§prune_window: u64

Implementations§

Source§

impl CommitmentPipeline<RocksDbStore, RocksDbMmrStore>

Source

pub fn checkpoint_inherited_state_root(&self, version: Version) -> Result<bool>

Source

pub fn checkpoint_inherited_risk_root(&self, version: Version) -> Result<bool>

Source

pub fn prune_stores(&self, prune_to: Version) -> Result<(usize, usize)>

Source

pub fn compact_stores(&self) -> Result<()>

Source§

impl<S: TreeReader + TreeWriter> CommitmentPipeline<S, MemoryMmrStore>

Source

pub fn new(state_store: S, risk_store: S, prune_window: u64) -> Self

Create a new pipeline starting at version 0.

Source§

impl<S, M> CommitmentPipeline<S, M>
where S: TreeReader + TreeWriter, M: MmrMetadataStore + SupportedMmrStore + PrepareMmrStore, for<'a> &'a M: MMRStoreReadOps<MmrHash> + MMRStoreWriteOps<MmrHash>,

Source

pub fn new_with_mmrs( state_store: S, risk_store: S, command_mmr_store: M, obligation_mmr_store: M, intent_mmr_store: M, prune_window: u64, ) -> Result<Self>

Source

pub fn with_version(self, version: Version) -> Self

Resume from a known version (e.g., after loading from disk).

Source

pub fn version(&self) -> Version

Current version (number of committed batches).

Source

pub fn prune_window(&self) -> u64

Configured number of recent versions to keep available for proofs.

Source

pub fn prepare_commit( &self, delta: &StateDelta, ) -> Result<PreparedBatchCommitment>

Prepare a batch commitment without mutating the backing stores.

Source

pub fn apply_prepared_commit( &mut self, prepared: PreparedBatchCommitment, ) -> Result<BatchCommitment>

Apply a prepared batch commitment after the caller’s durability boundary.

Source

pub fn commit(&mut self, delta: &StateDelta) -> Result<BatchCommitment>

Commit a batch of state changes and return the new roots.

This is the main entry point for callers that do not need to interpose another durability boundary between root computation and store mutation.

Source

pub fn append_command(&mut self, command_hash: [u8; 32]) -> Result<()>

Append a command hash to the command MMR.

Source

pub fn append_obligation(&mut self, obligation_hash: [u8; 32]) -> Result<()>

Append an obligation to the obligation MMR.

Source

pub fn append_intent(&mut self, intent_hash: [u8; 32]) -> Result<()>

Append a user intent to the intent MMR.

Source

fn latest_root(&self, store: &S, version: Version) -> Result<RootHash>

Source

fn prepare_state_delta( &self, delta: &StateDelta, version: Version, ) -> Result<(RootHash, usize, Option<TreeUpdateBatch>)>

Source

fn prepare_risk_delta( &self, risk_updates: &[RiskUpdate], version: Version, ) -> Result<(RootHash, usize, Option<TreeUpdateBatch>)>

Auto Trait Implementations§

§

impl<S, M> Freeze for CommitmentPipeline<S, M>
where S: Freeze, M: Freeze,

§

impl<S, M> RefUnwindSafe for CommitmentPipeline<S, M>

§

impl<S, M> Send for CommitmentPipeline<S, M>
where S: Send, M: Send,

§

impl<S, M> Sync for CommitmentPipeline<S, M>
where S: Sync, M: Sync,

§

impl<S, M> Unpin for CommitmentPipeline<S, M>
where S: Unpin, M: Unpin,

§

impl<S, M> UnsafeUnpin for CommitmentPipeline<S, M>
where S: UnsafeUnpin, M: UnsafeUnpin,

§

impl<S, M> UnwindSafe for CommitmentPipeline<S, M>
where S: UnwindSafe, M: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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