pub struct DKGWorker<B, BE, C, GE>where
    B: Block,
    BE: Backend<B>,
    C: Client<B, BE>,
    GE: GossipEngineIface,{
Show 21 fields pub client: Arc<C>, pub backend: Arc<BE>, pub key_store: DKGKeystore, pub gossip_engine: Arc<GE>, pub db: Arc<dyn DKGDbBackend>, pub metrics: Arc<Option<Metrics>>, pub best_authorities: Shared<Vec<(u16, Public)>>, pub next_best_authorities: Shared<Vec<(u16, Public)>>, pub latest_header: Shared<Option<B::Header>>, pub current_validator_set: Shared<AuthoritySet<Public, MaxAuthorities>>, pub queued_validator_set: Shared<AuthoritySet<Public, MaxAuthorities>>, pub aggregated_public_keys: Shared<AggregatedPublicKeysAndSigs>, pub aggregated_misbehaviour_reports: Shared<AggregatedMisbehaviourReportStore>, pub local_keystore: Shared<Option<Arc<LocalKeystore>>>, pub network: Option<Arc<NetworkService<B, B::Hash>>>, pub sync_service: Option<Arc<SyncingService<B>>>, pub test_bundle: Option<TestBundle>, pub logger: DebugLogger, pub dkg_modules: DKGModules<B, BE, C, GE>, pub signing_manager: SigningManager<B, BE, C, GE>, pub keygen_manager: KeygenManager<B, BE, C, GE>, /* private fields */
}
Expand description

A DKG worker plays the DKG protocol

Fields§

§client: Arc<C>§backend: Arc<BE>§key_store: DKGKeystore§gossip_engine: Arc<GE>§db: Arc<dyn DKGDbBackend>§metrics: Arc<Option<Metrics>>§best_authorities: Shared<Vec<(u16, Public)>>

Cached best authorities

§next_best_authorities: Shared<Vec<(u16, Public)>>

Cached next best authorities

§latest_header: Shared<Option<B::Header>>

Latest block header

§current_validator_set: Shared<AuthoritySet<Public, MaxAuthorities>>

Current validator set

§queued_validator_set: Shared<AuthoritySet<Public, MaxAuthorities>>

Queued validator set

§aggregated_public_keys: Shared<AggregatedPublicKeysAndSigs>

Tracking for the broadcasted public keys and signatures

§aggregated_misbehaviour_reports: Shared<AggregatedMisbehaviourReportStore>

Tracking for the misbehaviour reports

§local_keystore: Shared<Option<Arc<LocalKeystore>>>

Concrete type that points to the actual local keystore if it exists

§network: Option<Arc<NetworkService<B, B::Hash>>>

Used to keep track of network status

§sync_service: Option<Arc<SyncingService<B>>>

Used to keep track of sync status

§test_bundle: Option<TestBundle>§logger: DebugLogger§dkg_modules: DKGModules<B, BE, C, GE>§signing_manager: SigningManager<B, BE, C, GE>§keygen_manager: KeygenManager<B, BE, C, GE>

Implementations§

source§

impl<B, BE, C, GE> DKGWorker<B, BE, C, GE>where B: Block + Codec, BE: Backend<B> + Unpin + 'static, GE: GossipEngineIface + 'static, C: Client<B, BE> + 'static, C::Api: DKGApi<B, AuthorityId, NumberFor<B>, MaxProposalLength, MaxAuthorities>,

source

pub fn new( worker_params: WorkerParams<B, BE, C, GE>, logger: DebugLogger ) -> Self

Return a new DKG worker instance.

Note that a DKG worker is only fully functional if a corresponding DKG pallet has been deployed on-chain.

The DKG pallet is needed in order to keep track of the DKG authority set.

source§

impl<B, BE, C, GE> DKGWorker<B, BE, C, GE>where B: Block, BE: Backend<B> + Unpin + 'static, GE: GossipEngineIface + 'static, C: Client<B, BE> + 'static, C::Api: DKGApi<B, AuthorityId, NumberFor<B>, MaxProposalLength, MaxAuthorities>,

source

pub async fn get_party_index(&self, header: &B::Header) -> Option<u16>

Get the party index of our worker

Returns None if we are not in the best authority set

source

pub async fn get_next_party_index(&self, header: &B::Header) -> Option<u16>

Get the next party index of our worker for possible queued keygen

Returns None if we are not in the next best authority set

source

pub async fn get_keygen_threshold(&self, header: &B::Header) -> u16

Get the keygen threshold at a specific block

source

pub async fn get_next_keygen_threshold(&self, header: &B::Header) -> u16

Get the next keygen threshold at a specific block

source

pub async fn get_signature_threshold(&self, header: &B::Header) -> u16

Get the signature threshold at a specific block

source

pub async fn get_next_signature_threshold(&self, header: &B::Header) -> u16

Get the next signature threshold at a specific block

source

pub async fn get_dkg_pub_key( &self, header: &B::Header ) -> (AuthoritySetId, Vec<u8>)

Get the active DKG public key

source

pub async fn dkg_pub_key_is_unset(&self, header: &B::Header) -> bool

source

pub async fn get_next_dkg_pub_key( &self, header: &B::Header ) -> Option<(AuthoritySetId, Vec<u8>)>

Get the next DKG public key

source

pub async fn get_keygen_jailed( &self, header: &B::Header, set: &[AuthorityId] ) -> Vec<AuthorityId>

Get the jailed keygen authorities

source

pub async fn get_best_authorities( &self, header: &B::Header ) -> Vec<(u16, AuthorityId)>

Get the best authorities for keygen

source

pub async fn get_next_best_authorities( &self, header: &B::Header ) -> Vec<(u16, AuthorityId)>

Get the next best authorities for keygen

source

pub async fn validator_set( &self, header: &B::Header ) -> Option<(AuthoritySet<Public, MaxAuthorities>, AuthoritySet<Public, MaxAuthorities>)>

Return the next and queued validator set at header header.

Note that the validator set could be None. This is the case if we don’t find a DKG authority set change and we can’t fetch the authority set from the DKG on-chain state.

Such a failure is usually an indication that the DKG pallet has not been deployed (yet).

If the validators are None, we use the arbitrary validators gotten from the authority set and queued authority set in the given header

source

pub async fn verify_signature_against_authorities_inner( logger: &DebugLogger, signed_dkg_msg: SignedDKGMessage<Public>, latest_header: &Arc<RwLock<Option<B::Header>>>, client: &Arc<C> ) -> Result<DKGMessage<Public>, DKGError>

source

pub async fn handle_dkg_error(&self, dkg_error: DKGError)

source

pub fn authenticate_msg_origin( &self, is_main_round: bool, authorities: (Vec<Public>, Vec<Public>), msg: &[u8], signature: &[u8] ) -> Result<Public, DKGError>

source

pub async fn should_execute_new_keygen( &self, header: &B::Header ) -> AnticipatedKeygenExecutionStatus

source

pub async fn get_unsigned_proposal_batches( &self, header: &B::Header ) -> Result<Vec<StoredUnsignedProposalBatch<BatchId, MaxProposalLength, MaxProposalsInBatch, <<B as Block>::Header as Header>::Number>>, ApiError>

source

pub async fn exec_client_function<F, T>(&self, function: F) -> Twhere for<'a> F: FnOnce(&'a C) -> T + Send + 'static, T: Send + 'static,

Wraps the call in a SpawnBlocking task

source

pub async fn run(self)

Trait Implementations§

source§

impl<B, BE, C, GE> Clone for DKGWorker<B, BE, C, GE>where B: Block, BE: Backend<B> + 'static, C: Client<B, BE> + 'static, GE: GossipEngineIface,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<B, BE, C, GE> HasLatestHeader<B> for DKGWorker<B, BE, C, GE>where B: Block, BE: Backend<B> + 'static, GE: GossipEngineIface, C: Client<B, BE> + 'static, MaxProposalLength: Get<u32>, MaxAuthorities: Get<u32>,

source§

fn get_latest_block_number(&self) -> NumberFor<B>

Gets latest block number from latest block header

source§

fn get_latest_header(&self) -> &Arc<RwLock<Option<B::Header>>>

source§

impl<B, BE, C, GE> KeystoreExt for DKGWorker<B, BE, C, GE>where B: Block, BE: Backend<B>, GE: GossipEngineIface, C: Client<B, BE>, MaxProposalLength: Get<u32>, MaxAuthorities: Get<u32>,

Auto Trait Implementations§

§

impl<B, BE, C, GE> !RefUnwindSafe for DKGWorker<B, BE, C, GE>

§

impl<B, BE, C, GE> Send for DKGWorker<B, BE, C, GE>

§

impl<B, BE, C, GE> Sync for DKGWorker<B, BE, C, GE>

§

impl<B, BE, C, GE> Unpin for DKGWorker<B, BE, C, GE>where B: Unpin, BE: Unpin, C: Unpin, GE: Unpin,

§

impl<B, BE, C, GE> !UnwindSafe for DKGWorker<B, BE, C, GE>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

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

§

fn checked_from<T>(t: T) -> Option<Self>where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
§

fn checked_into<T>(self) -> Option<T>where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
§

impl<T> Conv for T

§

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

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

impl<T> DynClone for Twhere T: Clone,

source§

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

§

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> 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 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.

§

impl<T> IsType<T> for T

§

fn from_ref(t: &T) -> &T

Cast reference.
§

fn into_ref(&self) -> &T

Cast reference.
§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
§

fn into_mut(&mut self) -> &mut T

Cast mutable reference.
§

impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

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

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

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

§

type Output = T

Should always be Self
§

impl<T> SaturatedConversion for T

§

fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
§

fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
§

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

impl<T> ToOwned for Twhere T: Clone,

§

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
§

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<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,

§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,

§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

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

§

impl<T> MaybeSend for Twhere T: Send,