Struct massa_final_state::final_state::FinalState
source · 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
impl FinalState
sourcepub fn new(
db: ShareableMassaDBController,
config: FinalStateConfig,
ledger: Box<dyn LedgerController>,
selector: Box<dyn SelectorController>,
mip_store: MipStore,
reset_final_state: bool
) -> Result<Self, FinalStateError>
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 initializationledger
: 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
sourcefn interpolate_downtime(&mut self) -> Result<(), FinalStateError>
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.
sourcefn interpolate_single_cycle(
&mut self,
current_slot: Slot,
end_slot: Slot
) -> Result<(), FinalStateError>
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
sourcefn interpolate_multiple_cycles(
&mut self,
current_slot: Slot,
end_slot: Slot,
current_slot_cycle: u64,
end_slot_cycle: u64
) -> Result<(), FinalStateError>
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
sourcefn feed_cycle_hash_and_selector_for_interpolation(
&mut self,
cycle: u64
) -> Result<(), FinalStateError>
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
fn _finalize(&mut self, slot: Slot, changes: StateChanges) -> AnyResult<()>
sourcefn _is_db_valid(&self) -> AnyResult<()>
fn _is_db_valid(&self) -> AnyResult<()>
Internal function called by is_db_valid
sourcepub 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>
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 theMassaDBController
trait. Used to read and write to the database.config
: the configuration of the final state to use for initializationledger
: 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
impl FinalStateController for FinalState
source§fn compute_initial_draws(&mut self) -> Result<(), FinalStateError>
fn compute_initial_draws(&mut self) -> Result<(), FinalStateError>
source§fn finalize(&mut self, slot: Slot, changes: StateChanges)
fn finalize(&mut self, slot: Slot, changes: StateChanges)
source§fn get_execution_trail_hash(&self) -> Hash
fn get_execution_trail_hash(&self) -> Hash
source§fn get_fingerprint(&self) -> Hash
fn get_fingerprint(&self) -> Hash
source§fn init_execution_trail_hash_to_batch(&mut self, batch: &mut DBBatch)
fn init_execution_trail_hash_to_batch(&mut self, batch: &mut DBBatch)
source§fn is_db_valid(&self) -> bool
fn is_db_valid(&self) -> bool
source§fn recompute_caches(&mut self)
fn recompute_caches(&mut self)
source§fn get_ledger(&self) -> &Box<dyn LedgerController>
fn get_ledger(&self) -> &Box<dyn LedgerController>
source§fn get_ledger_mut(&mut self) -> &mut Box<dyn LedgerController>
fn get_ledger_mut(&mut self) -> &mut Box<dyn LedgerController>
source§fn get_async_pool(&self) -> &AsyncPool
fn get_async_pool(&self) -> &AsyncPool
source§fn get_pos_state(&self) -> &PoSFinalState
fn get_pos_state(&self) -> &PoSFinalState
source§fn get_pos_state_mut(&mut self) -> &mut PoSFinalState
fn get_pos_state_mut(&mut self) -> &mut PoSFinalState
source§fn executed_ops_contains(&self, op_id: &OperationId) -> bool
fn executed_ops_contains(&self, op_id: &OperationId) -> bool
source§fn get_ops_exec_status(&self, batch: &[OperationId]) -> Vec<Option<bool>>
fn get_ops_exec_status(&self, batch: &[OperationId]) -> Vec<Option<bool>>
source§fn get_executed_denunciations(&self) -> &ExecutedDenunciations
fn get_executed_denunciations(&self) -> &ExecutedDenunciations
source§fn get_database(&self) -> &ShareableMassaDBController
fn get_database(&self) -> &ShareableMassaDBController
source§fn get_last_start_period(&self) -> u64
fn get_last_start_period(&self) -> u64
source§fn set_last_start_period(&mut self, last_start_period: u64)
fn set_last_start_period(&mut self, last_start_period: u64)
source§fn get_last_slot_before_downtime(&self) -> &Option<Slot>
fn get_last_slot_before_downtime(&self) -> &Option<Slot>
source§fn set_last_slot_before_downtime(
&mut self,
last_slot_before_downtime: Option<Slot>
)
fn set_last_slot_before_downtime( &mut self, last_slot_before_downtime: Option<Slot> )
source§fn get_mip_store_mut(&mut self) -> &mut MipStore
fn get_mip_store_mut(&mut self) -> &mut MipStore
source§fn get_mip_store(&self) -> &MipStore
fn get_mip_store(&self) -> &MipStore
source§fn get_deferred_call_registry(&self) -> &DeferredCallRegistry
fn get_deferred_call_registry(&self) -> &DeferredCallRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for FinalState
impl Send for FinalState
impl Sync for FinalState
impl Unpin for FinalState
impl !UnwindSafe for FinalState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
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,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
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,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§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,
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,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
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,
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,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
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,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
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,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.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,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.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,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.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,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.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,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.