This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Enable signature verification in background task #10946
Closed
librelois
wants to merge
22
commits into
paritytech:master
from
moonbeam-foundation:elois-background-sig-verif
Closed
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1d9df92
Enable signature verification in background task
librelois 9a73a44
optimize : spawn all background checks before extrinsics execution
librelois 77a767e
Merge branch 'master' into elois-background-sig-verif
librelois 1ded1ba
Merge branch 'master' into elois-background-sig-verif
librelois 9b974d8
fix warning: fn execute_extrinsics_with_book_keeping not used
librelois 37fcf55
Merge branch 'master' into elois-background-sig-verif
librelois a222e60
fmt
librelois 80baeb1
refactor in a more generic way
librelois 4a02772
add ci job test-frame-executive-features-compile-to-wasm
librelois 9409c4c
apply review suggestions
librelois a4765f4
apply review suggestions 2
librelois f3f30d0
Merge branch 'master' into elois-background-sig-verif
librelois 787db84
Merge branch 'master' into elois-background-sig-verif
librelois 0c4b002
rename SignatureBatching -> BackgroundVerifyContext
librelois f3557c4
Merge branch 'master' into elois-background-sig-verif
librelois 1bde334
fix try runtime build
librelois f5a85b0
Merge branch 'master' into elois-background-sig-verif
librelois 5727533
fix tests
librelois 625ce06
fmt
librelois df3636e
fix warnings
librelois 38a5d82
Merge branch 'master' into elois-background-sig-verif
librelois 6062fa1
Merge branch 'master' into elois-background-sig-verif
librelois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -164,6 +164,57 @@ where | |||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /// A signature that supports background verification. | ||||||||||||||||||||||||||||||||||||||||||||
|
librelois marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||
| pub trait BackgroundVerify: Verify { | ||||||||||||||||||||||||||||||||||||||||||||
|
bkchr marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||
| /// Register a signature for background verification. | ||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||
| /// This requires that background verification is enabled by doing XYZ. | ||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||
| /// Returns `true` when the signature was successfully registered for background verification | ||||||||||||||||||||||||||||||||||||||||||||
| /// or if background verification is not enabled the signature could be verified successfully | ||||||||||||||||||||||||||||||||||||||||||||
| /// immediately. | ||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||
| /// # Warning | ||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||
| /// This requires that the background verification is finished by calling finalize_verify to | ||||||||||||||||||||||||||||||||||||||||||||
| /// check the result of all submitted signature verifications. | ||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The |
||||||||||||||||||||||||||||||||||||||||||||
| fn background_verify<L: Lazy<[u8]>>( | ||||||||||||||||||||||||||||||||||||||||||||
| &self, | ||||||||||||||||||||||||||||||||||||||||||||
| msg: L, | ||||||||||||||||||||||||||||||||||||||||||||
| signer: &<Self::Signer as IdentifyAccount>::AccountId, | ||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| impl BackgroundVerify for sp_core::ed25519::Signature { | ||||||||||||||||||||||||||||||||||||||||||||
| fn background_verify<L: Lazy<[u8]>>( | ||||||||||||||||||||||||||||||||||||||||||||
| &self, | ||||||||||||||||||||||||||||||||||||||||||||
| mut msg: L, | ||||||||||||||||||||||||||||||||||||||||||||
| signer: &<Self::Signer as IdentifyAccount>::AccountId, | ||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||
| sp_io::crypto::ed25519_batch_verify(self, msg.get(), signer) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| impl BackgroundVerify for sp_core::sr25519::Signature { | ||||||||||||||||||||||||||||||||||||||||||||
| fn background_verify<L: Lazy<[u8]>>( | ||||||||||||||||||||||||||||||||||||||||||||
| &self, | ||||||||||||||||||||||||||||||||||||||||||||
| mut msg: L, | ||||||||||||||||||||||||||||||||||||||||||||
| signer: &<Self::Signer as IdentifyAccount>::AccountId, | ||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||
| sp_io::crypto::sr25519_batch_verify(self, msg.get(), signer) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| impl BackgroundVerify for sp_core::ecdsa::Signature { | ||||||||||||||||||||||||||||||||||||||||||||
| fn background_verify<L: Lazy<[u8]>>( | ||||||||||||||||||||||||||||||||||||||||||||
| &self, | ||||||||||||||||||||||||||||||||||||||||||||
| mut msg: L, | ||||||||||||||||||||||||||||||||||||||||||||
| signer: &<Self::Signer as IdentifyAccount>::AccountId, | ||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||
| sp_io::crypto::ecdsa_batch_verify(self, msg.get(), signer) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /// An error type that indicates that the origin is invalid. | ||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Encode, Decode, RuntimeDebug)] | ||||||||||||||||||||||||||||||||||||||||||||
| pub struct BadOrigin; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -769,6 +820,18 @@ pub trait Checkable<Context>: Sized { | |||||||||||||||||||||||||||||||||||||||||||
| fn check(self, c: &Context) -> Result<Self::Checked, TransactionValidityError>; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /// A piece of information "checkable" in a background task, used by the standard Substrate | ||||||||||||||||||||||||||||||||||||||||||||
| /// Executive in order to check the validity of a piece of extrinsic information, usually by | ||||||||||||||||||||||||||||||||||||||||||||
| /// verifying the signature. Implement for pieces of information that require some additional | ||||||||||||||||||||||||||||||||||||||||||||
|
librelois marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||
| /// context `Context` in order to be checked. | ||||||||||||||||||||||||||||||||||||||||||||
| pub trait BackgroundCheckable<Context>: Checkable<Context> { | ||||||||||||||||||||||||||||||||||||||||||||
| /// Check self in a background tas, given an instance of Context. | ||||||||||||||||||||||||||||||||||||||||||||
| fn background_check( | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1048
to
+1049
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||||||||||||
| c: &Context, | ||||||||||||||||||||||||||||||||||||||||||||
| ) -> Result<<Self as Checkable<Context>>::Checked, TransactionValidityError>; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /// A "checkable" piece of information, used by the standard Substrate Executive in order to | ||||||||||||||||||||||||||||||||||||||||||||
| /// check the validity of a piece of extrinsic information, usually by verifying the signature. | ||||||||||||||||||||||||||||||||||||||||||||
| /// Implement for pieces of information that don't require additional context in order to be | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
Uh oh!
There was an error while loading. Please reload this page.