From 2d40e4b9dc141ff1b9f876544a7b929dd097bb91 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Fri, 3 Apr 2020 14:05:21 +0300 Subject: [PATCH 1/5] Adds an offchain call to submit double vote reports --- Cargo.lock | 2 + primitives/src/parachain.rs | 27 +++++++++++ runtime/common/Cargo.toml | 1 + runtime/common/src/parachains.rs | 82 ++++++++++++++++++++++++++++++-- runtime/common/src/registrar.rs | 58 +++++++++++++++++++++- runtime/kusama/src/lib.rs | 50 ++++++++++++++++++- runtime/polkadot/Cargo.toml | 1 + runtime/polkadot/src/lib.rs | 47 +++++++++++++++++- runtime/test-runtime/src/lib.rs | 50 ++++++++++++++++++- 9 files changed, 308 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54218adcc278..dda9e8dbae77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4361,6 +4361,7 @@ dependencies = [ "serde_derive", "serde_json", "sp-api", + "sp-application-crypto", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", @@ -4410,6 +4411,7 @@ dependencies = [ "serde_derive", "serde_json", "sp-api", + "sp-application-crypto", "sp-core", "sp-inherents", "sp-io", diff --git a/primitives/src/parachain.rs b/primitives/src/parachain.rs index de05063387a3..0e36c02e21d1 100644 --- a/primitives/src/parachain.rs +++ b/primitives/src/parachain.rs @@ -64,6 +64,14 @@ pub const PARACHAIN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"para"); mod validator_app { use application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::PARACHAIN_KEY_TYPE_ID); + + impl runtime_primitives::traits::IdentifyAccount for Public { + type AccountId = crate::AccountId; + + fn into_account(self) -> Self::AccountId { + runtime_primitives::MultiSigner::from(self.0).into_account() + } + } } /// Identity that parachain validators use when signing validation messages. @@ -86,6 +94,25 @@ application_crypto::with_pair! { /// so we define it to be the same type as `SessionKey`. In the future it may have different crypto. pub type ValidatorSignature = validator_app::Signature; +/// The key type ID for a fisherman key. +pub const FISHERMAN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"fish"); + +mod fisherman_app { + use application_crypto::{app_crypto, sr25519}; + app_crypto!(sr25519, super::FISHERMAN_KEY_TYPE_ID); + + impl runtime_primitives::traits::IdentifyAccount for Public { + type AccountId = crate::AccountId; + + fn into_account(self) -> Self::AccountId { + runtime_primitives::MultiSigner::from(self.0).into_account() + } + } +} + +/// Identity that fishermen use when generating reports. +pub type FishermanId = fisherman_app::Public; + /// Retriability for a given active para. #[derive(Clone, Eq, PartialEq, Encode, Decode)] #[cfg_attr(feature = "std", derive(Debug))] diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 3079ea3e4eca..8d630ce93fb7 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -19,6 +19,7 @@ sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", de sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } diff --git a/runtime/common/src/parachains.rs b/runtime/common/src/parachains.rs index d9fd0ecb1082..704c36d0582b 100644 --- a/runtime/common/src/parachains.rs +++ b/runtime/common/src/parachains.rs @@ -55,7 +55,10 @@ use sp_runtime::transaction_validity::InvalidTransaction; use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifier}; -use system::{ensure_none, ensure_signed}; +use system::{ + ensure_none, ensure_signed, + offchain::SubmitSignedTransaction, +}; use crate::attestations::{self, IncludedBlocks}; use crate::registrar::Registrar; @@ -220,7 +223,7 @@ pub trait Trait: attestations::Trait + session::historical::Trait { type Origin: From + From>; /// The outer call dispatch type. - type Call: Parameter + Dispatchable::Origin>; + type Call: Parameter + Dispatchable::Origin> + From>; /// Some way of interacting with balances for fees. type ParachainCurrency: ParachainCurrency; @@ -268,6 +271,9 @@ pub trait Trait: attestations::Trait + session::historical::Trait { /// A type that converts the opaque hash type to exact one. type BlockHashConversion: Convert; + + /// Submit a signed transaction. + type SubmitSignedTransaction: SubmitSignedTransaction::Call>; } /// Origin for the parachains module. @@ -543,6 +549,23 @@ fn localized_payload( encoded } +impl> Module { + /// Submit a double vote report. + pub fn submit_double_vote_report( + report: DoubleVoteReport, + ) -> Option<()> { + let call = Call::report_double_vote(report); + + let res = T::SubmitSignedTransaction::submit_signed(call); + + if res.iter().any(|(_, r)| r.is_ok()) { + Some(()) + } else { + None + } + } +} + impl Module { /// Initialize the state of a new parachain/parathread. pub fn initialize_para( @@ -1107,6 +1130,13 @@ impl sp_std::fmt::Debug for ValidateDoubleVoteReports where } } +impl ValidateDoubleVoteReports { + /// Create a new `ValidateDoubleVoteReports` struct. + pub fn new() -> Self { + ValidateDoubleVoteReports(sp_std::marker::PhantomData) + } +} + /// Custom validity error used while validating double vote reports. #[derive(RuntimeDebug)] #[repr(u8)] @@ -1204,7 +1234,7 @@ mod tests { Perbill, curve::PiecewiseLinear, testing::Header, traits::{ BlakeTwo256, IdentityLookup, SaturatedConversion, - OpaqueKeys, + OpaqueKeys, Extrinsic as ExtrinsicT, }, testing::TestXt, }; @@ -1460,6 +1490,31 @@ mod tests { pub const MaxCodeSize: u32 = 100; } + // This is needed for a custom `AccountId` type which is `u64` in testing here. + pub mod test_keys { + use sp_core::crypto::KeyTypeId; + + pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test"); + + mod app { + use sp_application_crypto::{app_crypto, sr25519}; + use super::super::Parachains; + + app_crypto!(sr25519, super::KEY_TYPE); + + impl sp_runtime::traits::IdentifyAccount for Public { + type AccountId = u64; + + fn into_account(self) -> Self::AccountId { + Parachains::authorities().iter().position(|b| *b == self.0.clone().into()).unwrap() as u64 + } + } + } + + pub type ReporterId = app::Public; + pub type ReporterSignature = app::Signature; + } + impl Trait for Test { type Origin = Origin; type Call = Call; @@ -1476,6 +1531,27 @@ mod tests { type ReportOffence = Offences; type BlockHashConversion = sp_runtime::traits::Identity; type KeyOwnerProofSystem = Historical; + type SubmitSignedTransaction = system::offchain::TransactionSubmitter< + test_keys::ReporterId, + Test, + Extrinsic, + >; + } + + type Extrinsic = TestXt; + + impl system::offchain::CreateTransaction for Test { + type Public = test_keys::ReporterId; + type Signature = test_keys::ReporterSignature; + + fn create_transaction>( + call: ::Call, + _public: Self::Public, + _account: ::AccountId, + nonce: ::Index, + ) -> Option<(::Call, ::SignaturePayload)> { + Some((call, (nonce, ()))) + } } type Parachains = Module; diff --git a/runtime/common/src/registrar.rs b/runtime/common/src/registrar.rs index 5722d9155d10..f4feca97e863 100644 --- a/runtime/common/src/registrar.rs +++ b/runtime/common/src/registrar.rs @@ -556,6 +556,15 @@ impl ActiveParas for Module { pub struct LimitParathreadCommits(sp_std::marker::PhantomData) where ::Call: IsSubType, T>; +impl LimitParathreadCommits where + ::Call: IsSubType, T> +{ + /// Create a new `LimitParathreadCommits` struct. + pub fn new() -> Self { + LimitParathreadCommits(sp_std::marker::PhantomData) + } +} + impl sp_std::fmt::Debug for LimitParathreadCommits where ::Call: IsSubType, T> { @@ -652,7 +661,7 @@ mod tests { use sp_runtime::{ traits::{ BlakeTwo256, IdentityLookup, Dispatchable, - AccountIdConversion, + AccountIdConversion, Extrinsic as ExtrinsicT, }, testing::{UintAuthorityId, Header, TestXt}, KeyTypeId, Perbill, curve::PiecewiseLinear, }; use primitives::{ @@ -826,6 +835,32 @@ mod tests { type FullIdentificationOf = staking::ExposureOf; } + // This is needed for a custom `AccountId` type which is `u64` in testing here. + pub mod test_keys { + use sp_core::crypto::KeyTypeId; + + pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test"); + + mod app { + use super::super::Parachains; + use sp_application_crypto::{app_crypto, sr25519}; + + app_crypto!(sr25519, super::KEY_TYPE); + + impl sp_runtime::traits::IdentifyAccount for Public { + type AccountId = u64; + + fn into_account(self) -> Self::AccountId { + let id = self.0.clone().into(); + Parachains::authorities().iter().position(|b| *b == id).unwrap() as u64 + } + } + } + + pub type ReporterId = app::Public; + pub type ReporterSignature = app::Signature; + } + impl parachains::Trait for Test { type Origin = Origin; type Call = Call; @@ -840,6 +875,27 @@ mod tests { type IdentificationTuple = )>>::IdentificationTuple; type ReportOffence = (); type BlockHashConversion = sp_runtime::traits::Identity; + type SubmitSignedTransaction = system::offchain::TransactionSubmitter< + test_keys::ReporterId, + Test, + Extrinsic, + >; + } + + type Extrinsic = TestXt; + + impl system::offchain::CreateTransaction for Test { + type Public = test_keys::ReporterId; + type Signature = test_keys::ReporterSignature; + + fn create_transaction>( + call: ::Call, + _public: Self::Public, + _account: ::AccountId, + nonce: ::Index, + ) -> Option<(::Call, ::SignaturePayload)> { + Some((call, (nonce, ()))) + } } parameter_types! { diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 4fbd5809234f..166af2826a7e 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -39,7 +39,10 @@ use sp_runtime::{ TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, }, curve::PiecewiseLinear, - traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup}, + traits::{ + BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup, + Extrinsic as ExtrinsicT, SaturatedConversion, + }, }; #[cfg(feature = "runtime-benchmarks")] use sp_runtime::RuntimeString; @@ -50,7 +53,8 @@ use version::NativeVersion; use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ - parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, + parameter_types, construct_runtime, debug, + traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, weights::DispatchInfo, }; use im_online::sr25519::AuthorityId as ImOnlineId; @@ -515,6 +519,46 @@ impl parachains::Trait for Runtime { type IdentificationTuple = )>>::IdentificationTuple; type ReportOffence = Offences; type BlockHashConversion = sp_runtime::traits::Identity; + type SubmitSignedTransaction = TransactionSubmitter; +} + +impl system::offchain::CreateTransaction for Runtime { + type Public = ::Signer; + type Signature = primitives::Signature; + + fn create_transaction>( + call: ::Call, + public: Self::Public, + account: ::AccountId, + nonce: ::Index, + ) -> Option<(Call, ::SignaturePayload)> { + let period = BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + + let current_block = System::block_number() + .saturated_into::() + .saturating_sub(1); + let tip = 0; + let extra: SignedExtra = ( + RestrictFunctionality, + system::CheckVersion::::new(), + system::CheckGenesis::::new(), + system::CheckEra::::from(generic::Era::mortal(period, current_block)), + system::CheckNonce::::from(nonce), + system::CheckWeight::::new(), + transaction_payment::ChargeTransactionPayment::::from(tip), + registrar::LimitParathreadCommits::::new(), + parachains::ValidateDoubleVoteReports::::new(), + ); + let raw_payload = SignedPayload::new(call, extra).map_err(|e| { + debug::warn!("Unable to create signed payload: {:?}", e) + }).ok()?; + let signature = TSigner::sign(public, &raw_payload)?; + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (account, signature, extra))) + } } parameter_types! { @@ -745,6 +789,8 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = executive::Executive, Runtime, AllModules>; +/// The payload being signed in the transactions. +pub type SignedPayload = generic::SignedPayload; sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index 350184a2ea71..1cc3a8b2619c 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -18,6 +18,7 @@ babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/par sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 71c221ae6266..57397c2e2a51 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -42,7 +42,7 @@ use sp_runtime::{ curve::PiecewiseLinear, traits::{ BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, - IdentityLookup + IdentityLookup, Extrinsic as ExtrinsicT, SaturatedConversion, }, }; #[cfg(feature = "runtime-benchmarks")] @@ -54,7 +54,8 @@ use version::NativeVersion; use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ - parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, + parameter_types, construct_runtime, debug, + traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, weights::DispatchInfo, }; use im_online::sr25519::AuthorityId as ImOnlineId; @@ -523,6 +524,46 @@ impl parachains::Trait for Runtime { type IdentificationTuple = )>>::IdentificationTuple; type ReportOffence = Offences; type BlockHashConversion = sp_runtime::traits::Identity; + type SubmitSignedTransaction = TransactionSubmitter; +} + +impl system::offchain::CreateTransaction for Runtime { + type Public = ::Signer; + type Signature = primitives::Signature; + + fn create_transaction>( + call: ::Call, + public: Self::Public, + account: ::AccountId, + nonce: ::Index, + ) -> Option<(Call, ::SignaturePayload)> { + let period = BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + + let current_block = System::block_number() + .saturated_into::() + .saturating_sub(1); + let tip = 0; + let extra: SignedExtra = ( + OnlyStakingAndClaims, + system::CheckVersion::::new(), + system::CheckGenesis::::new(), + system::CheckEra::::from(generic::Era::mortal(period, current_block)), + system::CheckNonce::::from(nonce), + system::CheckWeight::::new(), + transaction_payment::ChargeTransactionPayment::::from(tip), + registrar::LimitParathreadCommits::::new(), + parachains::ValidateDoubleVoteReports::::new(), + ); + let raw_payload = SignedPayload::new(call, extra).map_err(|e| { + debug::warn!("Unable to create signed payload: {:?}", e) + }).ok()?; + let signature = TSigner::sign(public, &raw_payload)?; + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (account, signature, extra))) + } } parameter_types! { @@ -665,6 +706,8 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = executive::Executive, Runtime, AllModules>; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 8230c4ad6581..cd173ffc9f63 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -39,7 +39,10 @@ use sp_runtime::{ TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, }, curve::PiecewiseLinear, - traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto}, + traits::{ + BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto, + Extrinsic as ExtrinsicT, SaturatedConversion, + }, }; use version::RuntimeVersion; use grandpa::{AuthorityId as GrandpaId, fg_primitives}; @@ -48,12 +51,13 @@ use version::NativeVersion; use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ - parameter_types, construct_runtime, + parameter_types, construct_runtime, debug, traits::{KeyOwnerProofSystem, Randomness}, weights::DispatchInfo, }; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use session::{historical as session_historical}; +use system::offchain::TransactionSubmitter; #[cfg(feature = "std")] pub use staking::StakerStatus; @@ -328,6 +332,46 @@ impl parachains::Trait for Runtime { >::IdentificationTuple; type ReportOffence = Offences; type BlockHashConversion = sp_runtime::traits::Identity; + type SubmitSignedTransaction = TransactionSubmitter; +} + +impl system::offchain::CreateTransaction for Runtime { + type Public = ::Signer; + type Signature = primitives::Signature; + + fn create_transaction>( + call: ::Call, + public: Self::Public, + account: ::AccountId, + nonce: ::Index, + ) -> Option<(Call, ::SignaturePayload)> { + let period = BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + + let current_block = System::block_number() + .saturated_into::() + .saturating_sub(1); + let tip = 0; + let extra: SignedExtra = ( + RestrictFunctionality, + system::CheckVersion::::new(), + system::CheckGenesis::::new(), + system::CheckEra::::from(generic::Era::mortal(period, current_block)), + system::CheckNonce::::from(nonce), + system::CheckWeight::::new(), + transaction_payment::ChargeTransactionPayment::::from(tip), + registrar::LimitParathreadCommits::::new(), + ); + let raw_payload = SignedPayload::new(call, extra).map_err(|e| { + debug::warn!("Unable to create signed payload: {:?}", e) + }).ok()?; + let signature = TSigner::sign(public, &raw_payload)?; + let (call, extra, _) = raw_payload.deconstruct(); + let address = Indices::unlookup(account); + Some((call, (address, signature, extra))) + } } impl offences::Trait for Runtime { @@ -455,6 +499,8 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = executive::Executive, Runtime, AllModules>; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; pub type Hash = ::Hash; pub type Extrinsic = ::Extrinsic; From 62bf42131bb99e8f1ce41c1fc5e7a76556c02885 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Fri, 3 Apr 2020 16:04:05 +0300 Subject: [PATCH 2/5] Some tweaks --- runtime/common/src/parachains.rs | 32 +++++++++++++++----------------- runtime/kusama/src/lib.rs | 4 ++-- runtime/polkadot/src/lib.rs | 2 +- runtime/test-runtime/src/lib.rs | 4 ++-- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/runtime/common/src/parachains.rs b/runtime/common/src/parachains.rs index 704c36d0582b..e11a3c449f05 100644 --- a/runtime/common/src/parachains.rs +++ b/runtime/common/src/parachains.rs @@ -549,23 +549,6 @@ fn localized_payload( encoded } -impl> Module { - /// Submit a double vote report. - pub fn submit_double_vote_report( - report: DoubleVoteReport, - ) -> Option<()> { - let call = Call::report_double_vote(report); - - let res = T::SubmitSignedTransaction::submit_signed(call); - - if res.iter().any(|(_, r)| r.is_ok()) { - Some(()) - } else { - None - } - } -} - impl Module { /// Initialize the state of a new parachain/parathread. pub fn initialize_para( @@ -595,6 +578,21 @@ impl Module { } } + /// Submit a double vote report. + pub fn submit_double_vote_report( + report: DoubleVoteReport, + ) -> Option<()> { + let call = Call::report_double_vote(report); + + let res = T::SubmitSignedTransaction::submit_signed(call); + + if res.iter().any(|(_, r)| r.is_ok()) { + Some(()) + } else { + None + } + } + /// Dispatch some messages from a parachain. fn dispatch_message( id: ParaId, diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 166af2826a7e..7ee0314b8e18 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -85,8 +85,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kusama"), impl_name: create_runtime_str!("parity-kusama"), authoring_version: 2, - spec_version: 1057, - impl_version: 1, + spec_version: 1058, + impl_version: 0, apis: RUNTIME_API_VERSIONS, }; diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 57397c2e2a51..75026bf79d58 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -87,7 +87,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("polkadot"), impl_name: create_runtime_str!("parity-polkadot"), authoring_version: 2, - spec_version: 1006, + spec_version: 1007, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index cd173ffc9f63..d33048000561 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("polkadot-test-runtime"), impl_name: create_runtime_str!("parity-polkadot-test-runtime"), authoring_version: 2, - spec_version: 1049, + spec_version: 1050, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; @@ -332,7 +332,7 @@ impl parachains::Trait for Runtime { >::IdentificationTuple; type ReportOffence = Offences; type BlockHashConversion = sp_runtime::traits::Identity; - type SubmitSignedTransaction = TransactionSubmitter; + type SubmitSignedTransaction = TransactionSubmitter; } impl system::offchain::CreateTransaction for Runtime { From 45062eb58aa0da552b74ca322524eaa5eeb3821b Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Fri, 3 Apr 2020 21:53:23 +0300 Subject: [PATCH 3/5] Remove unnecessary IdentifyAccount impls --- primitives/src/parachain.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/primitives/src/parachain.rs b/primitives/src/parachain.rs index 0e36c02e21d1..73bb5e681f1b 100644 --- a/primitives/src/parachain.rs +++ b/primitives/src/parachain.rs @@ -64,14 +64,6 @@ pub const PARACHAIN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"para"); mod validator_app { use application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::PARACHAIN_KEY_TYPE_ID); - - impl runtime_primitives::traits::IdentifyAccount for Public { - type AccountId = crate::AccountId; - - fn into_account(self) -> Self::AccountId { - runtime_primitives::MultiSigner::from(self.0).into_account() - } - } } /// Identity that parachain validators use when signing validation messages. @@ -100,14 +92,6 @@ pub const FISHERMAN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"fish"); mod fisherman_app { use application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::FISHERMAN_KEY_TYPE_ID); - - impl runtime_primitives::traits::IdentifyAccount for Public { - type AccountId = crate::AccountId; - - fn into_account(self) -> Self::AccountId { - runtime_primitives::MultiSigner::from(self.0).into_account() - } - } } /// Identity that fishermen use when generating reports. From 0925fb1acc0500d0d8b9386d81e9e6c1b99600da Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Thu, 16 Apr 2020 16:36:46 +0300 Subject: [PATCH 4/5] Adds ValidateDoubleVoteReports to test runtime --- runtime/test-runtime/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 32d098626bac..9271fedd6526 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -380,6 +380,7 @@ impl system::offchain::CreateTransaction for Runtim system::CheckWeight::::new(), transaction_payment::ChargeTransactionPayment::::from(tip), registrar::LimitParathreadCommits::::new(), + parachains::ValidateDoubleVoteReports::::new(), ); let raw_payload = SignedPayload::new(call, extra).map_err(|e| { debug::warn!("Unable to create signed payload: {:?}", e) @@ -508,7 +509,8 @@ pub type SignedExtra = ( system::CheckNonce, system::CheckWeight, transaction_payment::ChargeTransactionPayment::, - registrar::LimitParathreadCommits + registrar::LimitParathreadCommits, + parachains::ValidateDoubleVoteReports, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; From 186c1c8b955688f1550b68c51bc93b17df462d8a Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Thu, 16 Apr 2020 17:44:25 +0300 Subject: [PATCH 5/5] sp-application-crypto is only a dev dependency --- Cargo.lock | 1 - runtime/common/Cargo.toml | 2 +- runtime/polkadot/Cargo.toml | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3b51f922b50..85406fd71241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4307,7 +4307,6 @@ dependencies = [ "serde_derive", "serde_json", "sp-api", - "sp-application-crypto", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index d9a476bd0e5b..88d7519dfa6d 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -19,7 +19,6 @@ sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", de sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -40,6 +39,7 @@ hex-literal = "0.2.1" keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "master" } treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index dcb6b7ed3eaa..24e16d08a878 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -18,7 +18,6 @@ babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/par sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }