Skip to main content

WorkerState

Struct WorkerState 

Source
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,

Source

pub fn new( nickname: String, key_pair: Option<ValidatorSecretKey>, storage: StorageClient, ) -> Self

Source

pub fn new_for_client( nickname: String, storage: StorageClient, chain_modes: Arc<RwLock<BTreeMap<ChainId, ListeningMode>>>, ) -> Self

Source

pub fn with_allow_inactive_chains(self, value: bool) -> Self

Source

pub fn with_allow_messages_from_deprecated_epochs(self, value: bool) -> Self

Source

pub fn with_long_lived_services(self, value: bool) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn nickname(&self) -> &str

Source§

impl<StorageClient> WorkerState<StorageClient>
where StorageClient: Storage + Clone + 'static,

Source

pub async fn fully_handle_certificate_with_notifications<T>( &self, certificate: GenericCertificate<T>, notifier: &impl Notifier, ) -> Result<ChainInfoResponse, WorkerError>

Source

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.

Source

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.

Source

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.

Source

pub async fn describe_application( &self, chain_id: ChainId, application_id: ApplicationId, ) -> Result<ApplicationDescription, WorkerError>

Source

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.

Source

pub async fn handle_block_proposal( &self, proposal: BlockProposal, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>

Source

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.

Source

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.

Source

pub async fn handle_validated_certificate( &self, certificate: ValidatedBlockCertificate, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>

Processes a validated block certificate.

Source

pub async fn handle_timeout_certificate( &self, certificate: TimeoutCertificate, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>

Processes a timeout certificate

Source

pub async fn handle_chain_info_query( &self, query: ChainInfoQuery, ) -> Result<(ChainInfoResponse, NetworkActions), WorkerError>

Source

pub async fn download_pending_blob( &self, chain_id: ChainId, blob_id: BlobId, ) -> Result<Blob, WorkerError>

Source

pub async fn handle_pending_blob( &self, chain_id: ChainId, blob: Blob, ) -> Result<ChainInfoResponse, WorkerError>

Source

pub async fn handle_cross_chain_request( &self, request: CrossChainRequest, ) -> Result<NetworkActions, WorkerError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn get_block_hashes( &self, chain_id: ChainId, heights: Vec<BlockHeight>, ) -> Result<Vec<CryptoHash>, WorkerError>

Gets block hashes for the given heights.

Source

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.

Source

pub async fn get_event_subscriptions( &self, chain_id: ChainId, ) -> Result<Vec<((ChainId, StreamId), EventSubscriptions)>, WorkerError>

Gets event subscriptions from the chain.

Source

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.

Source

pub async fn get_received_certificate_trackers( &self, chain_id: ChainId, ) -> Result<HashMap<ValidatorPublicKey, u64>, WorkerError>

Gets received certificate trackers.

Source

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.

Source

pub async fn get_next_height_to_preprocess( &self, chain_id: ChainId, ) -> Result<BlockHeight, WorkerError>

Gets the next height to preprocess.

Source

pub async fn get_manager_seed( &self, chain_id: ChainId, ) -> Result<u64, WorkerError>

Gets the chain manager’s seed for leader election.

Trait Implementations§

Source§

impl<StorageClient> Clone for WorkerState<StorageClient>
where StorageClient: Storage + Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<To, From> DynInto<To> for From
where From: Into<To>,

Source§

fn into_box(self: Box<From>) -> To

Converts a boxed object into the target type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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.

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<M, I> RuntimeMemory<&mut I> for M
where M: RuntimeMemory<I>,

Source§

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>

Writes the bytes to memory at the provided location.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
Source§

impl<AnyTail> Split<HNil> for AnyTail

Source§

type Remainder = AnyTail

The tail of remaining elements after splitting up the list.
Source§

fn split(self) -> (HNil, <AnyTail as Split<HNil>>::Remainder)

Splits the current heterogeneous list in two.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

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

impl<_INNER> AutoTraits for _INNER
where _INNER: Send + Sync + 'static,

Source§

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

Source§

impl<T> Post for T
where T: Send + 'static,