Struct dkg_gadget::worker::DKGWorker
source · 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>>
Cached best authorities
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>,
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>,
sourcepub fn new(
worker_params: WorkerParams<B, BE, C, GE>,
logger: DebugLogger
) -> Self
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>,
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>,
sourcepub async fn get_party_index(&self, header: &B::Header) -> Option<u16>
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
sourcepub async fn get_next_party_index(&self, header: &B::Header) -> Option<u16>
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
sourcepub async fn get_keygen_threshold(&self, header: &B::Header) -> u16
pub async fn get_keygen_threshold(&self, header: &B::Header) -> u16
Get the keygen threshold at a specific block
sourcepub async fn get_next_keygen_threshold(&self, header: &B::Header) -> u16
pub async fn get_next_keygen_threshold(&self, header: &B::Header) -> u16
Get the next keygen threshold at a specific block
sourcepub async fn get_signature_threshold(&self, header: &B::Header) -> u16
pub async fn get_signature_threshold(&self, header: &B::Header) -> u16
Get the signature threshold at a specific block
sourcepub async fn get_next_signature_threshold(&self, header: &B::Header) -> u16
pub async fn get_next_signature_threshold(&self, header: &B::Header) -> u16
Get the next signature threshold at a specific block
sourcepub async fn get_dkg_pub_key(
&self,
header: &B::Header
) -> (AuthoritySetId, Vec<u8>)
pub async fn get_dkg_pub_key( &self, header: &B::Header ) -> (AuthoritySetId, Vec<u8>)
Get the active DKG public key
pub async fn dkg_pub_key_is_unset(&self, header: &B::Header) -> bool
sourcepub async fn get_next_dkg_pub_key(
&self,
header: &B::Header
) -> Option<(AuthoritySetId, Vec<u8>)>
pub async fn get_next_dkg_pub_key( &self, header: &B::Header ) -> Option<(AuthoritySetId, Vec<u8>)>
Get the next DKG public key
sourcepub async fn get_keygen_jailed(
&self,
header: &B::Header,
set: &[AuthorityId]
) -> Vec<AuthorityId>
pub async fn get_keygen_jailed( &self, header: &B::Header, set: &[AuthorityId] ) -> Vec<AuthorityId>
Get the jailed keygen authorities
Get the best authorities for keygen
Get the next best authorities for keygen
sourcepub async fn validator_set(
&self,
header: &B::Header
) -> Option<(AuthoritySet<Public, MaxAuthorities>, AuthoritySet<Public, MaxAuthorities>)>
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
pub async fn handle_dkg_error(&self, dkg_error: DKGError)
pub fn authenticate_msg_origin( &self, is_main_round: bool, authorities: (Vec<Public>, Vec<Public>), msg: &[u8], signature: &[u8] ) -> Result<Public, DKGError>
pub async fn should_execute_new_keygen( &self, header: &B::Header ) -> AnticipatedKeygenExecutionStatus
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>
sourcepub async fn exec_client_function<F, T>(&self, function: F) -> Twhere
for<'a> F: FnOnce(&'a C) -> T + Send + 'static,
T: Send + 'static,
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
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,
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§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>,
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>
fn get_latest_block_number(&self) -> NumberFor<B>
Gets latest block number from latest block header
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>,
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>,
fn get_keystore(&self) -> &DKGKeystore
fn get_sr25519_public_key(&self) -> Public
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> 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> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where Self: TryInto<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> 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>
§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§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> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read more§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.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.