This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Relax Send/Sync/Clone requirements for Pair #14647
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In general
Pair
trait is not strictly required to beSend/Sync/Clone
.Secrets throughout the codebase are constructed and destroyed asap (as should be).
In some situation these bounds could even be detrimental; some components may require the secrets to not be shared across threads (in practice silently moved to another stack without cleaning up the previous location) or cloned (e.g. in cases where the backend doesn't implement something like
zeroize
to clean-up memory).Furthermore, secrets provided by some backends may not allow for these bounds. For example the upcoming Bandersnatch
ring-vrf
secret is notSync
. So here there is not much space for options wrt this trait bound.The only place where these bounds are currently vacuously required is in AURA code.
Here some components are generic over the key type and these components are required to be
Send
.However the
Pair
is not part of the components struct instance and the generic is only used as a bound to a particular key type and thus authority id type (i.e. these structs contain aPhantomData<Pair>
).The issue is easily addressed by using
PhantomData<fn() -> Pair>
instead ofPhantomData<Pair>
.PhantomData<fn() -> Pair>
is bothSend
andSync
(regardless ofPair
bounds).That is, the types with
PhantomData
doesn't own aPair
, but instead they can potentially producePair
s (this is the big difference).The PR also contains trivial cleanups and removal of other bounds where possible
cumulus companion: paritytech/cumulus#2941
required by #14412
Nomicon ref (not published yet): rust-lang/nomicon#411