pub struct FinalState {
    pub(crate) config: FinalStateConfig,
    pub ledger: Box<dyn LedgerController>,
    pub async_pool: AsyncPool,
    pub deferred_call_registry: DeferredCallRegistry,
    pub pos_state: PoSFinalState,
    pub executed_ops: ExecutedOps,
    pub executed_denunciations: ExecutedDenunciations,
    pub mip_store: MipStore,
    pub last_start_period: u64,
    pub last_slot_before_downtime: Option<Slot>,
    pub db: ShareableMassaDBController,
}
Expand description

Represents a final state (ledger, async pool, executed_ops, executed_de and the state of the PoS)

Fields§

§config: FinalStateConfig

execution state configuration

§ledger: Box<dyn LedgerController>

final ledger associating addresses to their balance, executable bytecode and data

§async_pool: AsyncPool

asynchronous pool containing messages sorted by priority and their data

§deferred_call_registry: DeferredCallRegistry

deferred calls

§pos_state: PoSFinalState

proof of stake state containing cycle history and deferred credits

§executed_ops: ExecutedOps

executed operations

§executed_denunciations: ExecutedDenunciations

executed denunciations

§mip_store: MipStore

MIP store

§last_start_period: u64

last_start_period

  • If start new network: set to 0
  • If from snapshot: retrieve from args
  • If from bootstrap: set during bootstrap
§last_slot_before_downtime: Option<Slot>

last_slot_before_downtime

  • None if start new network
  • If from snapshot: retrieve from the slot attached to the snapshot
  • If from bootstrap: set during bootstrap
§db: ShareableMassaDBController

the RocksDB instance used to write every final_state struct on disk

Implementations§

source§

impl FinalState

source

pub fn new( db: ShareableMassaDBController, config: FinalStateConfig, ledger: Box<dyn LedgerController>, selector: Box<dyn SelectorController>, mip_store: MipStore, reset_final_state: bool ) -> Result<Self, FinalStateError>

Initializes a new FinalState

Arguments
  • config: the configuration of the final state to use for initialization
  • ledger: the instance of the ledger on disk. Used to apply changes to the ledger.
  • selector: the pos selector. Used to send draw inputs when a new cycle is completed.
  • reset_final_state: if true, we only keep the ledger, and we reset the other fields of the final state
source

fn interpolate_downtime(&mut self) -> Result<(), FinalStateError>

Once we created a FinalState from a snapshot, we need to edit it to attach at the end_slot and handle the downtime. This basically recreates the history of the final_state, without executing the slots.

source

fn interpolate_single_cycle( &mut self, current_slot: Slot, end_slot: Slot ) -> Result<(), FinalStateError>

This helper function is to be called if the downtime does not span over multiple cycles

source

fn interpolate_multiple_cycles( &mut self, current_slot: Slot, end_slot: Slot, current_slot_cycle: u64, end_slot_cycle: u64 ) -> Result<(), FinalStateError>

This helper function is to be called if the downtime spans over multiple cycles

source

fn feed_cycle_hash_and_selector_for_interpolation( &mut self, cycle: u64 ) -> Result<(), FinalStateError>

Used during interpolation, when a new cycle is set as completed

source

fn _finalize(&mut self, slot: Slot, changes: StateChanges) -> AnyResult<()>

source

fn _is_db_valid(&self) -> AnyResult<()>

Internal function called by is_db_valid

source

pub fn new_derived_from_snapshot( db: ShareableMassaDBController, config: FinalStateConfig, ledger: Box<dyn LedgerController>, selector: Box<dyn SelectorController>, mip_store: MipStore, last_start_period: u64 ) -> Result<Self, FinalStateError>

Initializes a FinalState from a snapshot.

Arguments
  • db: A type that implements the MassaDBController trait. Used to read and write to the database.
  • config: the configuration of the final state to use for initialization
  • ledger: the instance of the ledger on disk. Used to apply changes to the ledger.
  • selector: the pos selector. Used to send draw inputs when a new cycle is completed.
  • last_start_period: at what period we should attach the final_state

Trait Implementations§

source§

impl FinalStateController for FinalState

source§

fn compute_initial_draws(&mut self) -> Result<(), FinalStateError>

Performs the initial draws.
source§

fn finalize(&mut self, slot: Slot, changes: StateChanges)

Applies changes to the execution state at a given slot, and settles that slot forever. Once this is called, the state is attached at the output of the provided slot. Read more
source§

fn get_execution_trail_hash(&self) -> Hash

Gets the hash of the execution trail
source§

fn get_fingerprint(&self) -> Hash

Get the fingerprint (hash) of the final state. Note that only one atomic write per final slot occurs, so this can be safely queried at any time.
source§

fn get_slot(&self) -> Slot

Get the slot at the end of which the final state is attached
source§

fn init_execution_trail_hash_to_batch(&mut self, batch: &mut DBBatch)

Initialize the execution trail hash to zero.
source§

fn is_db_valid(&self) -> bool

Deserialize the entire DB and check the data. Useful to check after bootstrap.
source§

fn recompute_caches(&mut self)

After bootstrap or load from disk, recompute all the caches.
source§

fn reset(&mut self)

Reset the final state to the initial state. Read more
source§

fn get_ledger(&self) -> &Box<dyn LedgerController>

Get ledger
source§

fn get_ledger_mut(&mut self) -> &mut Box<dyn LedgerController>

Get ledger mut
source§

fn get_async_pool(&self) -> &AsyncPool

Get async pool
source§

fn get_pos_state(&self) -> &PoSFinalState

Get pos state
source§

fn get_pos_state_mut(&mut self) -> &mut PoSFinalState

Get pos state mut
source§

fn executed_ops_contains(&self, op_id: &OperationId) -> bool

check if an operation is in the executed ops
source§

fn get_ops_exec_status(&self, batch: &[OperationId]) -> Vec<Option<bool>>

Get the executed status ops
source§

fn get_executed_denunciations(&self) -> &ExecutedDenunciations

Get executed denunciations
source§

fn get_database(&self) -> &ShareableMassaDBController

Get the database
source§

fn get_last_start_period(&self) -> u64

Get last start period
source§

fn set_last_start_period(&mut self, last_start_period: u64)

Set last start period
source§

fn get_last_slot_before_downtime(&self) -> &Option<Slot>

Get last slot before downtime
source§

fn set_last_slot_before_downtime( &mut self, last_slot_before_downtime: Option<Slot> )

Set last slot before downtime
source§

fn get_mip_store_mut(&mut self) -> &mut MipStore

Get mutable reference to MIP Store
source§

fn get_mip_store(&self) -> &MipStore

Get MIP Store
source§

fn get_deferred_call_registry(&self) -> &DeferredCallRegistry

Get deferred call registry

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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
§

impl<T> Conv for T

§

fn conv<T>(self) -> Twhere Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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 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<T> Pipe for Twhere T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> Rwhere Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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

§

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