Skip to content

Commit

Permalink
ProposerFactory impl Clone (paritytech#3389)
Browse files Browse the repository at this point in the history
In Tanssi, we need a way to stop the collator code and then start it
again. This is to support rotating the same collator between different
runtimes. Currently, this works very well, except for the proposer
metrics, because they only get registered the first time they are
started. Afterwards, we see this warning log:

> Failed to register proposer prometheus metrics: Duplicate metrics
collector registration attempted


~~So this PR adds a method to set metrics, to allow us to register
metrics manually before creating the `ProposerFactory`, and then clone
the same metrics every time we need to start the collator.~~ Implemented
Clone instead
  • Loading branch information
tmpolaczyk authored Feb 21, 2024
1 parent 3b11857 commit c937046
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions substrate/client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ pub struct ProposerFactory<A, C, PR> {
_phantom: PhantomData<PR>,
}

impl<A, C, PR> Clone for ProposerFactory<A, C, PR> {
fn clone(&self) -> Self {
Self {
spawn_handle: self.spawn_handle.clone(),
client: self.client.clone(),
transaction_pool: self.transaction_pool.clone(),
metrics: self.metrics.clone(),
default_block_size_limit: self.default_block_size_limit,
soft_deadline_percent: self.soft_deadline_percent,
telemetry: self.telemetry.clone(),
include_proof_in_block_size_estimation: self.include_proof_in_block_size_estimation,
_phantom: self._phantom,
}
}
}

impl<A, C> ProposerFactory<A, C, DisableProofRecording> {
/// Create a new proposer factory.
///
Expand Down

0 comments on commit c937046

Please sign in to comment.