pub struct BlockDataManager {
    pub db_manager: DBManager,
    pub pow: Arc<PowComputer>,
    pub true_genesis: Arc<Block>,
    pub storage_manager: Arc<StorageManager>,
    pub target_difficulty_manager: TargetDifficultyManager,
    pub state_availability_boundary: RwLock<StateAvailabilityBoundary>,
    /* private fields */
}

Fields§

§db_manager: DBManager§pow: Arc<PowComputer>§true_genesis: Arc<Block>

This is the original genesis block.

§storage_manager: Arc<StorageManager>§target_difficulty_manager: TargetDifficultyManager§state_availability_boundary: RwLock<StateAvailabilityBoundary>

This maintains the boundary height of available state and commitments (executed but not deleted or in ExecutionTaskQueue). The upper bound always equal to latest executed epoch height. As for the lower bound:

  1. For archive node, it always equals cur_era_stable_height.
  2. For full node, it equals the height of remotely synchronized state at start, and equals cur_era_stable_height after making a new checkpoint.

The lower boundary height will be updated when:

  1. New checkpoint
  2. Full Node snapshot syncing
  3. New Snapshot

The upper boundary height will be updated when:

  1. Pivot chain switch
  2. Execution of new epoch

The state of an epoch is valid if and only if the height of the epoch is inside the boundary.

Implementations§

source§

impl BlockDataManager

source

pub fn new( cache_conf: CacheConfig, true_genesis: Arc<Block>, db: Arc<SystemDB>, storage_manager: Arc<StorageManager>, worker_pool: Arc<Mutex<ThreadPool>>, config: DataManagerConfiguration, pow: Arc<PowComputer> ) -> Self

source

pub fn get_instance_id(&self) -> u64

source

pub fn initialize_instance_id(&self)

source

pub fn true_genesis_state_root(&self) -> StateRootWithAuxInfo

This will return the state root of true genesis block.

source

pub fn transaction_by_hash(&self, hash: &H256) -> Option<Arc<SignedTransaction>>

source

pub fn insert_block_body(&self, hash: H256, block: Arc<Block>, persistent: bool)

insert block body in memory cache and db

source

pub fn remove_block_body(&self, hash: &H256, remove_db: bool)

remove block body in memory cache and db

source

pub fn block_by_hash( &self, hash: &H256, update_cache: bool ) -> Option<Arc<Block>>

TODO Also set block header

source

pub fn block_from_db(&self, hash: &H256) -> Option<Block>

This function returns the block from db without wrapping it in Arc.

source

pub fn blocks_by_hash_list( &self, hashes: &Vec<H256>, update_cache: bool ) -> Option<Vec<Arc<Block>>>

source

pub fn insert_block(&self, block: Arc<Block>, persistent: bool)

insert block/header into memory cache, block/header into db

source

pub fn remove_useless_block(&self, hash: &H256, remove_db: bool)

Remove block body and block header in memory cache and db. This is used to delete invalid blocks or dangling blocks never connected to the pivot chain.

source

pub fn block_traces_by_hash(&self, hash: &H256) -> Option<BlockTracesWithEpoch>

Get the traces for a single block without checking the assumed pivot block

source

pub fn transactions_traces_by_block_hash( &self, hash: &H256 ) -> Option<(H256, Vec<TransactionExecTraces>)>

Return (pivot_hash, tx_traces).

source

pub fn block_traces_by_hash_with_epoch( &self, hash: &H256, assumed_epoch: &H256, update_pivot_assumption: bool, update_cache: bool ) -> Option<BlockExecTraces>

source

pub fn insert_block_traces( &self, hash: H256, trace: BlockExecTraces, pivot_hash: H256, persistent: bool )

source

pub fn remove_block_traces(&self, hash: &H256, remove_db: bool)

remove block traces in memory cache and db

source

pub fn block_header_by_hash(&self, hash: &H256) -> Option<Arc<BlockHeader>>

source

pub fn insert_block_header( &self, hash: H256, header: Arc<BlockHeader>, persistent: bool )

source

pub fn remove_block_header(&self, hash: &H256, remove_db: bool)

remove block header in memory cache and db

source

pub fn block_height_by_hash(&self, hash: &H256) -> Option<u64>

source

pub fn pos_reference_by_hash(&self, hash: &H256) -> Option<Option<PosBlockId>>

Return None if the header does not exist. Return Some(None) if the header exist but it does not have a PoS reference field.

source

pub fn compact_block_by_hash(&self, hash: &H256) -> Option<CompactBlock>

source

pub fn insert_compact_block(&self, cb: CompactBlock)

source

pub fn contains_compact_block(&self, hash: &H256) -> bool

source

pub fn block_execution_result_by_hash_with_epoch( &self, hash: &H256, assumed_epoch: &H256, update_pivot_assumption: bool, update_cache: bool ) -> Option<BlockExecutionResult>

Return None if receipts for corresponding epoch is not computed before or has been overwritten by another new pivot chain in db. If update_pivot_assumption is true and we have execution results of assumed_epoch in memory, we will also ensure assumed_epoch is persisted as the pivot hash in db.

This function will require lock of block_receipts.

source

pub fn block_execution_result_by_hash_from_db( &self, hash: &H256 ) -> Option<BlockExecutionResultWithEpoch>

source

pub fn block_epoch_number(&self, hash: &H256) -> Option<u64>

source

pub fn insert_block_execution_result( &self, hash: H256, epoch: H256, block_receipts: Arc<BlockReceipts>, persistent: bool )

source

pub fn insert_block_reward_result( &self, hash: H256, epoch: &H256, block_reward: BlockRewardResult, persistent: bool )

source

pub fn block_reward_result_by_hash_with_epoch( &self, hash: &H256, assumed_epoch_later: &H256, update_pivot_assumption: bool, update_cache: bool ) -> Option<BlockRewardResult>

source

pub fn remove_block_result(&self, hash: &H256, remove_db: bool)

source

pub fn transaction_index_by_hash( &self, hash: &H256, update_cache: bool ) -> Option<TransactionIndex>

source

pub fn insert_transaction_index(&self, hash: &H256, tx_index: &TransactionIndex)

source

pub fn hash_by_block_number( &self, block_number: u64, update_cache: bool ) -> Option<H256>

source

pub fn insert_hash_by_block_number(&self, block_number: u64, block_hash: &H256)

source

pub fn insert_local_block_info(&self, hash: &H256, info: LocalBlockInfo)

source

pub fn local_block_info_by_hash(&self, hash: &H256) -> Option<LocalBlockInfo>

source

pub fn insert_blamed_header_verified_roots( &self, height: u64, roots: BlamedHeaderVerifiedRoots )

source

pub fn verified_blamed_roots_by_height( &self, height: u64 ) -> Option<BlamedHeaderVerifiedRoots>

Get correct roots of blamed headers from db. These are maintained on light nodes only.

source

pub fn remove_blamed_header_verified_roots(&self, height: u64)

source

pub fn insert_terminals_to_db(&self, terminals: Vec<H256>)

source

pub fn terminals_from_db(&self) -> Option<Vec<H256>>

source

pub fn insert_executed_epoch_set_hashes_to_db( &self, epoch_number: u64, epoch_set: &Vec<H256> )

source

pub fn insert_skipped_epoch_set_hashes_to_db( &self, epoch_number: u64, skipped_set: &Vec<H256> )

source

pub fn executed_epoch_set_hashes_from_db( &self, epoch_number: u64 ) -> Option<Vec<H256>>

source

pub fn skipped_epoch_set_hashes_from_db( &self, epoch_number: u64 ) -> Option<Vec<H256>>

source

pub fn all_epoch_set_hashes_from_db( &self, epoch_number: u64 ) -> Option<Vec<H256>>

source

pub fn receipts_retain_epoch(&self, block_hash: &H256, epoch: &H256) -> bool

Return false if there is no executed results for given block_hash

source

pub fn insert_epoch_execution_context( &self, hash: H256, ctx: EpochExecutionContext, persistent: bool )

source

pub fn get_epoch_execution_context( &self, hash: &H256 ) -> Option<EpochExecutionContext>

The in-memory state will not be updated because it’s only garbage collected explicitly when we make checkpoints.

source

pub fn insert_epoch_execution_commitment( &self, block_hash: H256, state_root_with_aux_info: StateRootWithAuxInfo, receipts_root: H256, logs_bloom_hash: H256 )

TODO We can avoid persisting execution_commitments for blocks not on the pivot chain after a checkpoint

source

pub fn get_epoch_execution_commitment( &self, block_hash: &H256 ) -> GuardedValue<RwLockReadGuard<'_, HashMap<H256, EpochExecutionCommitment>>, NonCopy<Option<&EpochExecutionCommitment>>>

Get in-mem execution commitment.

source

pub fn load_epoch_execution_commitment_from_db( &self, block_hash: &H256 ) -> Option<EpochExecutionCommitment>

Load commitment from db. The caller should ensure that the loaded commitment is after cur_era_genesis and can be garbage-collected by checkpoint.

source

pub fn get_epoch_execution_commitment_with_db( &self, block_hash: &H256 ) -> Option<EpochExecutionCommitment>

Get persisted execution commitment. It will check db if it’s missing in db.

source

pub fn insert_pos_reward(&self, pos_epoch: u64, pos_reward: &PosRewardInfo)

source

pub fn pos_reward_by_pos_epoch(&self, pos_epoch: u64) -> Option<PosRewardInfo>

source

pub fn remove_epoch_execution_commitment(&self, block_hash: &H256)

source

pub fn remove_epoch_execution_commitment_from_db(&self, block_hash: &H256)

source

pub fn remove_epoch_execution_context(&self, block_hash: &H256)

source

pub fn remove_epoch_execution_context_from_db(&self, block_hash: &H256)

source

pub fn epoch_executed(&self, epoch_hash: &H256) -> bool

source

pub fn epoch_executed_and_recovered( &self, epoch_hash: &H256, epoch_block_hashes: &Vec<H256>, on_local_pivot: bool, update_trace: bool, reward_execution_info: &Option<RewardExecutionInfo>, pos_verifier: &PosVerifier, evm_chain_id: u32 ) -> bool

Check if all executed results of an epoch exist

source

pub fn invalidate_block(&self, block_hash: H256)

source

pub fn verified_invalid( &self, block_hash: &H256 ) -> (bool, Option<LocalBlockInfo>)

Check if a block is already marked as invalid.

source

pub fn cached_block_count(&self) -> usize

source

pub fn cache_size(&self) -> CacheSize

Get current cache size.

source

pub fn cache_gc(&self)

source

pub fn set_cur_consensus_era_genesis_hash( &self, cur_era_hash: &H256, next_era_hash: &H256 )

source

pub fn get_cur_consensus_era_genesis_hash(&self) -> H256

source

pub fn get_cur_consensus_era_stable_hash(&self) -> H256

source

pub fn recover_unsigned_tx( &self, transactions: &Vec<TransactionWithSignature> ) -> Result<Vec<Arc<SignedTransaction>>, DecoderError>

source

pub fn recover_block(&self, block: &mut Block) -> Result<(), DecoderError>

source

pub fn recover_unsigned_tx_with_order( &self, transactions: &Vec<TransactionWithSignature> ) -> Result<Vec<Arc<SignedTransaction>>, DecoderError>

source

pub fn find_missing_tx_indices_encoded( &self, compact_block: &mut CompactBlock ) -> Vec<usize>

source

pub fn get_state_readonly_index( &self, block_hash: &EpochId ) -> Option<StateIndex>

Caller should make sure the state exists.

source

pub fn get_parent_epochs_for( &self, block: EpochId, count: u64 ) -> (EpochId, Vec<EpochId>)

source

pub fn get_snapshot_epoch_count(&self) -> u32

source

pub fn get_snapshot_blame_plus_depth(&self) -> usize

source

pub fn get_executed_state_root(&self, block_hash: &H256) -> Option<H256>

source

pub fn earliest_epoch_with_block_body(&self) -> u64

source

pub fn earliest_epoch_with_execution_result(&self) -> u64

source

pub fn earliest_epoch_with_trace(&self) -> u64

source

pub fn new_checkpoint(&self, new_checkpoint_height: u64, best_epoch_number: u64)

source

pub fn database_gc(&self, best_epoch: u64)

Trait Implementations§

source§

impl MallocSizeOf for BlockDataManager

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

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
§

impl<T> Conv for T

§

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

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

impl<T> ElementSatisfy<ElementNoConstrain> for T

§

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.

source§

impl<T> Instrument for T

source§

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

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

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.

§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where 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) -> R
where 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) -> R
where 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) -> R
where 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 ) -> R
where 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) -> R
where 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) -> R
where 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) -> R
where 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 ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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)) -> Self
where 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 T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T

§

impl<T> UnsafeAny for T
where T: Any,