pub struct WorkerState<StorageClient>where
StorageClient: Storage,{ /* private fields */ }Expand description
State of a worker in a validator or a local node.
Implementations§
Source§impl<StorageClient> WorkerState<StorageClient>where
StorageClient: Storage,
impl<StorageClient> WorkerState<StorageClient>where
StorageClient: Storage,
pub fn new( nickname: String, key_pair: Option<ValidatorSecretKey>, storage: StorageClient, ) -> Self
pub fn new_for_client( nickname: String, storage: StorageClient, chain_modes: Arc<RwLock<BTreeMap<ChainId, ListeningMode>>>, ) -> Self
pub fn with_allow_inactive_chains(self, value: bool) -> Self
pub fn with_allow_messages_from_deprecated_epochs(self, value: bool) -> Self
pub fn with_long_lived_services(self, value: bool) -> Self
Sourcepub fn with_block_time_grace_period(
self,
block_time_grace_period: Duration,
) -> Self
pub fn with_block_time_grace_period( self, block_time_grace_period: Duration, ) -> Self
Returns an instance with the specified block time grace period.
Blocks with a timestamp this far in the future will still be accepted, but the validator will wait until that timestamp before voting.
Sourcepub fn with_chain_worker_ttl(self, chain_worker_ttl: Duration) -> Self
pub fn with_chain_worker_ttl(self, chain_worker_ttl: Duration) -> Self
Returns an instance with the specified chain worker TTL.
Idle chain workers free their memory after that duration without requests.
Sourcepub fn with_sender_chain_worker_ttl(
self,
sender_chain_worker_ttl: Duration,
) -> Self
pub fn with_sender_chain_worker_ttl( self, sender_chain_worker_ttl: Duration, ) -> Self
Returns an instance with the specified sender chain worker TTL.
Idle sender chain workers free their memory after that duration without requests.
Sourcepub fn with_chain_info_max_received_log_entries(
self,
chain_info_max_received_log_entries: usize,
) -> Self
pub fn with_chain_info_max_received_log_entries( self, chain_info_max_received_log_entries: usize, ) -> Self
Returns an instance with the specified maximum size for received_log entries.
Sizes below CHAIN_INFO_MAX_RECEIVED_LOG_ENTRIES should be avoided.
pub fn nickname(&self) -> &str
Source§impl<StorageClient> WorkerState<StorageClient>
impl<StorageClient> WorkerState<StorageClient>
pub async fn fully_handle_certificate_with_notifications<T>(
&self,
certificate: GenericCertificate<T>,
notifier: &impl Notifier,
) -> Result<ChainInfoResponse, WorkerError>where
T: ProcessableCertificate,
Sourcepub async fn stage_block_execution(
&self,
block: ProposedBlock,
round: Option<u32>,
published_blobs: Vec<Blob>,
) -> Result<(Block, ChainInfoResponse, ResourceTracker), WorkerError>
pub async fn stage_block_execution( &self, block: ProposedBlock, round: Option<u32>, published_blobs: Vec<Blob>, ) -> Result<(Block, ChainInfoResponse, ResourceTracker), WorkerError>
Tries to execute a block proposal without any verification other than block execution.
Sourcepub async fn stage_block_execution_with_policy(
&self,
block: ProposedBlock,
round: Option<u32>,
published_blobs: Vec<Blob>,
policy: BundleExecutionPolicy,
) -> Result<(ProposedBlock, Block, ChainInfoResponse, ResourceTracker), WorkerError>
pub async fn stage_block_execution_with_policy( &self, block: ProposedBlock, round: Option<u32>, published_blobs: Vec<Blob>, policy: BundleExecutionPolicy, ) -> Result<(ProposedBlock, Block, ChainInfoResponse, ResourceTracker), WorkerError>
Tries to execute a block proposal with a policy for handling bundle failures.
Returns the modified block (bundles may be rejected/removed), the executed block, chain info response, and resource tracker.
Sourcepub async fn query_application(
&self,
chain_id: ChainId,
query: Query,
block_hash: Option<CryptoHash>,
) -> Result<(QueryOutcome, BlockHeight), WorkerError>
pub async fn query_application( &self, chain_id: ChainId, query: Query, block_hash: Option<CryptoHash>, ) -> Result<(QueryOutcome, BlockHeight), WorkerError>
Executes a Query for an application’s state on a specific chain.
If block_hash is specified, system will query the application’s state
at that block. If it doesn’t exist, it uses latest state.
pub async fn describe_application( &self, chain_id: ChainId, application_id: ApplicationId, ) -> Result<ApplicationDescription, WorkerError>
Sourcepub async fn chain_state_view(
&self,
chain_id: ChainId,
) -> Result<OwnedRwLockReadGuard<ChainStateView<StorageClient::Context>>, WorkerError>
pub async fn chain_state_view( &self, chain_id: ChainId, ) -> Result<OwnedRwLockReadGuard<ChainStateView<StorageClient::Context>>, WorkerError>
Returns a read-only view of the ChainStateView of a chain referenced by its
ChainId.
The returned view holds a lock on the chain state, which prevents the worker from changing the state of that chain.
pub async fn handle_block_proposal( &self, proposal: BlockProposal, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
Sourcepub async fn handle_lite_certificate(
&self,
certificate: LiteCertificate<'_>,
notify_when_messages_are_delivered: Option<Sender<()>>,
) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
pub async fn handle_lite_certificate( &self, certificate: LiteCertificate<'_>, notify_when_messages_are_delivered: Option<Sender<()>>, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
Processes a certificate, e.g. to extend a chain with a confirmed block.
Sourcepub async fn handle_confirmed_certificate(
&self,
certificate: ConfirmedBlockCertificate,
notify_when_messages_are_delivered: Option<Sender<()>>,
) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
pub async fn handle_confirmed_certificate( &self, certificate: ConfirmedBlockCertificate, notify_when_messages_are_delivered: Option<Sender<()>>, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
Processes a confirmed block certificate.
Sourcepub async fn handle_validated_certificate(
&self,
certificate: ValidatedBlockCertificate,
) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
pub async fn handle_validated_certificate( &self, certificate: ValidatedBlockCertificate, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
Processes a validated block certificate.
Sourcepub async fn handle_timeout_certificate(
&self,
certificate: TimeoutCertificate,
) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
pub async fn handle_timeout_certificate( &self, certificate: TimeoutCertificate, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
Processes a timeout certificate
pub async fn handle_chain_info_query( &self, query: ChainInfoQuery, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>
pub async fn download_pending_blob( &self, chain_id: ChainId, blob_id: BlobId, ) -> Result<Blob, WorkerError>
pub async fn handle_pending_blob( &self, chain_id: ChainId, blob: Blob, ) -> Result<ChainInfoResponse, WorkerError>
pub async fn handle_cross_chain_request( &self, request: CrossChainRequest, ) -> Result<NetworkActions, WorkerError>
Sourcepub async fn update_received_certificate_trackers(
&self,
chain_id: ChainId,
new_trackers: BTreeMap<ValidatorPublicKey, u64>,
) -> Result<(), WorkerError>
pub async fn update_received_certificate_trackers( &self, chain_id: ChainId, new_trackers: BTreeMap<ValidatorPublicKey, u64>, ) -> Result<(), WorkerError>
Updates the received certificate trackers to at least the given values.
Sourcepub async fn get_preprocessed_block_hashes(
&self,
chain_id: ChainId,
start: BlockHeight,
end: BlockHeight,
) -> Result<Vec<CryptoHash>, WorkerError>
pub async fn get_preprocessed_block_hashes( &self, chain_id: ChainId, start: BlockHeight, end: BlockHeight, ) -> Result<Vec<CryptoHash>, WorkerError>
Gets preprocessed block hashes in a given height range.
Sourcepub async fn get_inbox_next_height(
&self,
chain_id: ChainId,
origin: ChainId,
) -> Result<BlockHeight, WorkerError>
pub async fn get_inbox_next_height( &self, chain_id: ChainId, origin: ChainId, ) -> Result<BlockHeight, WorkerError>
Gets the next block height to receive from an inbox.
Sourcepub async fn get_locking_blobs(
&self,
chain_id: ChainId,
blob_ids: Vec<BlobId>,
) -> Result<Option<Vec<Blob>>, WorkerError>
pub async fn get_locking_blobs( &self, chain_id: ChainId, blob_ids: Vec<BlobId>, ) -> Result<Option<Vec<Blob>>, WorkerError>
Gets locking blobs for specific blob IDs.
Returns Ok(None) if any of the blobs is not found.
Sourcepub async fn get_block_hashes(
&self,
chain_id: ChainId,
heights: Vec<BlockHeight>,
) -> Result<Vec<CryptoHash>, WorkerError>
pub async fn get_block_hashes( &self, chain_id: ChainId, heights: Vec<BlockHeight>, ) -> Result<Vec<CryptoHash>, WorkerError>
Gets block hashes for the given heights.
Sourcepub async fn get_proposed_blobs(
&self,
chain_id: ChainId,
blob_ids: Vec<BlobId>,
) -> Result<Vec<Blob>, WorkerError>
pub async fn get_proposed_blobs( &self, chain_id: ChainId, blob_ids: Vec<BlobId>, ) -> Result<Vec<Blob>, WorkerError>
Gets proposed blobs from the manager for specified blob IDs.
Sourcepub async fn get_event_subscriptions(
&self,
chain_id: ChainId,
) -> Result<Vec<((ChainId, StreamId), EventSubscriptions)>, WorkerError>
pub async fn get_event_subscriptions( &self, chain_id: ChainId, ) -> Result<Vec<((ChainId, StreamId), EventSubscriptions)>, WorkerError>
Gets event subscriptions from the chain.
Sourcepub async fn get_stream_event_count(
&self,
chain_id: ChainId,
stream_id: StreamId,
) -> Result<Option<u32>, WorkerError>
pub async fn get_stream_event_count( &self, chain_id: ChainId, stream_id: StreamId, ) -> Result<Option<u32>, WorkerError>
Gets the stream event count for a stream.
Sourcepub async fn get_received_certificate_trackers(
&self,
chain_id: ChainId,
) -> Result<HashMap<ValidatorPublicKey, u64>, WorkerError>
pub async fn get_received_certificate_trackers( &self, chain_id: ChainId, ) -> Result<HashMap<ValidatorPublicKey, u64>, WorkerError>
Gets received certificate trackers.
Sourcepub async fn get_tip_state_and_outbox_info(
&self,
chain_id: ChainId,
receiver_id: ChainId,
) -> Result<(BlockHeight, Option<BlockHeight>), WorkerError>
pub async fn get_tip_state_and_outbox_info( &self, chain_id: ChainId, receiver_id: ChainId, ) -> Result<(BlockHeight, Option<BlockHeight>), WorkerError>
Gets tip state and outbox info for next_outbox_heights calculation.
Sourcepub async fn get_next_height_to_preprocess(
&self,
chain_id: ChainId,
) -> Result<BlockHeight, WorkerError>
pub async fn get_next_height_to_preprocess( &self, chain_id: ChainId, ) -> Result<BlockHeight, WorkerError>
Gets the next height to preprocess.
Sourcepub async fn get_manager_seed(
&self,
chain_id: ChainId,
) -> Result<u64, WorkerError>
pub async fn get_manager_seed( &self, chain_id: ChainId, ) -> Result<u64, WorkerError>
Gets the chain manager’s seed for leader election.
Trait Implementations§
Auto Trait Implementations§
impl<StorageClient> Freeze for WorkerState<StorageClient>where
StorageClient: Freeze,
impl<StorageClient> RefUnwindSafe for WorkerState<StorageClient>where
StorageClient: RefUnwindSafe,
impl<StorageClient> Send for WorkerState<StorageClient>
impl<StorageClient> Sync for WorkerState<StorageClient>
impl<StorageClient> Unpin for WorkerState<StorageClient>where
StorageClient: Unpin,
impl<StorageClient> UnsafeUnpin for WorkerState<StorageClient>where
StorageClient: UnsafeUnpin,
impl<StorageClient> UnwindSafe for WorkerState<StorageClient>where
StorageClient: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§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::RequestSource§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
Source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length bytes from memory from the provided location.
Source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes to memory at the provided location.