diff --git a/runtime/common/src/parachains.rs b/runtime/common/src/parachains.rs index 33f197863970..d593b04d3b49 100644 --- a/runtime/common/src/parachains.rs +++ b/runtime/common/src/parachains.rs @@ -19,7 +19,7 @@ use sp_std::prelude::*; use sp_std::result; use codec::{Decode, Encode}; - +use sp_core::sr25519; use sp_runtime::{ KeyTypeId, Perbill, RuntimeDebug, traits::{ @@ -41,19 +41,23 @@ use frame_support::{ use primitives::{ Balance, BlockNumber, + Signature, parachain::{ Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement, ParachainDispatchOrigin, UpwardMessage, ValidatorId, ActiveParas, CollatorId, Retriable, OmittedValidationData, CandidateReceipt, GlobalValidationSchedule, AbridgedCandidateReceipt, LocalValidationData, Scheduling, ValidityAttestation, NEW_HEADS_IDENTIFIER, PARACHAIN_KEY_TYPE_ID, - ValidatorSignature, SigningContext, HeadData, ValidationCode, + ValidatorSignature, SigningContext, HeadData, ValidationCode, FishermanId, }, }; use frame_support::{ Parameter, dispatch::DispatchResult, decl_storage, decl_module, decl_error, ensure, traits::{Currency, Get, WithdrawReason, ExistenceRequirement, Randomness}, }; -use sp_runtime::transaction_validity::InvalidTransaction; +use sp_runtime::{ + transaction_validity::InvalidTransaction, + traits::Verify, +}; use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifier}; @@ -64,23 +68,12 @@ use system::{ use crate::attestations::{self, IncludedBlocks}; use crate::registrar::Registrar; -pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"para"); - -pub mod crypto { - use super::KEY_TYPE; - use sp_runtime::{ - app_crypto::{app_crypto, sr25519}, - traits::Verify, - }; - use sp_core::sr25519::Signature as Sr25519Signature; - app_crypto!(sr25519, KEY_TYPE); - - pub struct AuthorityId; - impl system::offchain::AppCrypto<::Signer, Sr25519Signature> for AuthorityId { - type RuntimeAppPublic = Public; - type GenericSignature = Sr25519Signature; - type GenericPublic = sp_core::sr25519::Public; - } +// An `AppCrypto` type to facilitate submitting signed transactions. +pub struct FishermanAuthorityId; +impl system::offchain::AppCrypto<::Signer, Signature> for FishermanAuthorityId { + type RuntimeAppPublic = FishermanId; + type GenericSignature = sr25519::Signature; + type GenericPublic = sp_core::sr25519::Public; } // ranges for iteration of general block number don't work, so this @@ -818,8 +811,9 @@ impl Module { move |_account| { Call::report_double_vote(report.clone()) } - ); - return Some(()) + ) + .iter() + .find_map(|(_, res)| res.ok().map(|_| ())) } /// Dispatch some messages from a parachain. diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index ab8e0b6c76ba..7b19200dcefc 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -32,7 +32,6 @@ use runtime_common::{attestations, claims, parachains, registrar, slots, NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength, }; -use sp_core::sr25519; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, @@ -517,7 +516,7 @@ parameter_types! { } impl parachains::Trait for Runtime { - type AuthorityId = FishermanAuthorityId; + type AuthorityId = parachains::FishermanAuthorityId; type Origin = Origin; type Call = Call; type ParachainCurrency = Balances; @@ -539,13 +538,6 @@ impl parachains::Trait for Runtime { type BlockHashConversion = sp_runtime::traits::Identity; } -pub struct FishermanAuthorityId; -impl system::offchain::AppCrypto<::Signer, Signature> for FishermanAuthorityId { - type RuntimeAppPublic = parachain::FishermanId; - type GenericSignature = sr25519::Signature; - type GenericPublic = sr25519::Public; -} - impl system::offchain::CreateSignedTransaction for Runtime where Call: From, { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index a37aa9418ea4..89d949d3ec1c 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -33,7 +33,6 @@ use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment, parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError, }; -use sp_core::sr25519; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, @@ -524,7 +523,7 @@ parameter_types! { } impl parachains::Trait for Runtime { - type AuthorityId = FishermanAuthorityId; + type AuthorityId = parachains::FishermanAuthorityId; type Origin = Origin; type Call = Call; type ParachainCurrency = Balances; @@ -546,13 +545,6 @@ impl parachains::Trait for Runtime { type BlockHashConversion = sp_runtime::traits::Identity; } -pub struct FishermanAuthorityId; -impl system::offchain::AppCrypto<::Signer, Signature> for FishermanAuthorityId { - type RuntimeAppPublic = parachain::FishermanId; - type GenericSignature = sr25519::Signature; - type GenericPublic = sr25519::Public; -} - impl system::offchain::CreateSignedTransaction for Runtime where Call: From, { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 94738af9e4c2..9d9df30385ba 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -30,7 +30,6 @@ use runtime_common::{attestations, parachains, registrar, impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength, }; -use sp_core::sr25519; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, KeyTypeId, Perbill, Perquintill, RuntimeDebug, @@ -387,7 +386,7 @@ parameter_types! { } impl parachains::Trait for Runtime { - type AuthorityId = FishermanAuthorityId; + type AuthorityId = parachains::FishermanAuthorityId; type Origin = Origin; type Call = Call; type ParachainCurrency = Balances; @@ -409,13 +408,6 @@ impl parachains::Trait for Runtime { type BlockHashConversion = sp_runtime::traits::Identity; } -pub struct FishermanAuthorityId; -impl system::offchain::AppCrypto<::Signer, Signature> for FishermanAuthorityId { - type RuntimeAppPublic = parachain::FishermanId; - type GenericSignature = sr25519::Signature; - type GenericPublic = sr25519::Public; -} - impl system::offchain::CreateSignedTransaction for Runtime where Call: From, {