mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 18:58:01 +00:00
* Implement offchain::SendTransactionTypes * Fix test-runtime * Fix Kusama * Add SendTransactiontypes to Kusama * impl SendTransactiontypes for parachains and registrar * Fix typos * Provided extrinsic type * Implement AppCrypto for signing transactions * Add signing capabilities to runtime * Fix test runtimes * Implement CreateSignedtransaction for Test * Implement signing types for test runtimes * Fix test runtime create transaction impl * Fix build * Bump kusama's spec version * Update substrate * Use all_accounts
This commit is contained in:
Generated
+126
-126
File diff suppressed because it is too large
Load Diff
@@ -35,7 +35,7 @@ use sp_staking::{
|
||||
};
|
||||
use frame_support::{
|
||||
traits::KeyOwnerProofSystem,
|
||||
dispatch::{IsSubType},
|
||||
dispatch::IsSubType,
|
||||
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT},
|
||||
};
|
||||
use primitives::{
|
||||
@@ -59,11 +59,30 @@ use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifie
|
||||
|
||||
use system::{
|
||||
ensure_none, ensure_signed,
|
||||
offchain::SubmitSignedTransaction,
|
||||
offchain::{CreateSignedTransaction, SendSignedTransaction, Signer},
|
||||
};
|
||||
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<<Sr25519Signature as Verify>::Signer, Sr25519Signature> for AuthorityId {
|
||||
type RuntimeAppPublic = Public;
|
||||
type GenericSignature = Sr25519Signature;
|
||||
type GenericPublic = sp_core::sr25519::Public;
|
||||
}
|
||||
}
|
||||
|
||||
// ranges for iteration of general block number don't work, so this
|
||||
// is a utility to get around that.
|
||||
struct BlockNumberRange<N> {
|
||||
@@ -220,7 +239,10 @@ impl GetSessionNumber for session::historical::Proof {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: attestations::Trait + session::historical::Trait {
|
||||
pub trait Trait: CreateSignedTransaction<Call<Self>> + attestations::Trait + session::historical::Trait {
|
||||
// The transaction signing authority
|
||||
type AuthorityId: system::offchain::AppCrypto<Self::Public, Self::Signature>;
|
||||
|
||||
/// The outer origin type.
|
||||
type Origin: From<Origin> + From<system::RawOrigin<Self::AccountId>>;
|
||||
|
||||
@@ -293,9 +315,6 @@ pub trait Trait: attestations::Trait + session::historical::Trait {
|
||||
|
||||
/// A type that converts the opaque hash type to exact one.
|
||||
type BlockHashConversion: Convert<Self::Hash, primitives::Hash>;
|
||||
|
||||
/// Submit a signed transaction.
|
||||
type SubmitSignedTransaction: SubmitSignedTransaction<Self, <Self as Trait>::Call>;
|
||||
}
|
||||
|
||||
/// Origin for the parachains module.
|
||||
@@ -794,15 +813,13 @@ impl<T: Trait> Module<T> {
|
||||
pub fn submit_double_vote_report(
|
||||
report: DoubleVoteReport<T::Proof>,
|
||||
) -> 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
|
||||
}
|
||||
Signer::<T, T::AuthorityId>::all_accounts()
|
||||
.send_signed_transaction(
|
||||
move |_account| {
|
||||
Call::report_double_vote(report.clone())
|
||||
}
|
||||
);
|
||||
return Some(())
|
||||
}
|
||||
|
||||
/// Dispatch some messages from a parachain.
|
||||
@@ -1543,7 +1560,7 @@ mod tests {
|
||||
use super::Call as ParachainsCall;
|
||||
use bitvec::{bitvec, vec::BitVec};
|
||||
use sp_io::TestExternalities;
|
||||
use sp_core::{H256, Blake2Hasher};
|
||||
use sp_core::{H256, Blake2Hasher, sr25519};
|
||||
use sp_trie::NodeCodec;
|
||||
use sp_runtime::{
|
||||
impl_opaque_keys,
|
||||
@@ -1631,6 +1648,13 @@ mod tests {
|
||||
type OnKilledAccount = ();
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Test where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = TestXt<Call, ()>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Period: BlockNumber = 1;
|
||||
pub const Offset: BlockNumber = 0;
|
||||
@@ -1760,7 +1784,6 @@ mod tests {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = system::offchain::TransactionSubmitter<(), Test, TestXt<Call, ()>>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -1817,8 +1840,7 @@ mod tests {
|
||||
|
||||
// This is needed for a custom `AccountId` type which is `u64` in testing here.
|
||||
pub mod test_keys {
|
||||
use sp_core::crypto::KeyTypeId;
|
||||
|
||||
use sp_core::{crypto::KeyTypeId, sr25519};
|
||||
pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test");
|
||||
|
||||
mod app {
|
||||
@@ -1837,10 +1859,16 @@ mod tests {
|
||||
}
|
||||
|
||||
pub type ReporterId = app::Public;
|
||||
pub type ReporterSignature = app::Signature;
|
||||
pub struct ReporterAuthorityId;
|
||||
impl system::offchain::AppCrypto<ReporterId, sr25519::Signature> for ReporterAuthorityId {
|
||||
type RuntimeAppPublic = ReporterId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
}
|
||||
|
||||
impl Trait for Test {
|
||||
type AuthorityId = test_keys::ReporterAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
@@ -1860,29 +1888,28 @@ 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<Call, ()>;
|
||||
|
||||
impl system::offchain::CreateTransaction<Test, Extrinsic> for Test {
|
||||
type Public = test_keys::ReporterId;
|
||||
type Signature = test_keys::ReporterSignature;
|
||||
|
||||
fn create_transaction<F: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <Extrinsic as ExtrinsicT>::Call,
|
||||
_public: Self::Public,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Test where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
_public: test_keys::ReporterId,
|
||||
_account: <Test as system::Trait>::AccountId,
|
||||
nonce: <Test as system::Trait>::Index,
|
||||
) -> Option<(<Extrinsic as ExtrinsicT>::Call, <Extrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
) -> Option<(Call, <Extrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
Some((call, (nonce, ())))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Test {
|
||||
type Public = test_keys::ReporterId;
|
||||
type Signature = sr25519::Signature;
|
||||
}
|
||||
|
||||
type Parachains = Module<Test>;
|
||||
type Balances = balances::Module<Test>;
|
||||
type System = system::Module<Test>;
|
||||
|
||||
@@ -676,7 +676,7 @@ mod tests {
|
||||
CandidateReceipt, HeadData, ValidityAttestation, Statement, Chain,
|
||||
CollatorPair, CandidateCommitments,
|
||||
},
|
||||
Balance, BlockNumber, Header,
|
||||
Balance, BlockNumber, Header, Signature,
|
||||
};
|
||||
use frame_support::{
|
||||
traits::{KeyOwnerProofSystem, OnInitialize, OnFinalize},
|
||||
@@ -745,6 +745,13 @@ mod tests {
|
||||
type OnKilledAccount = Balances;
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Test where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = TestXt<Call, ()>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 1;
|
||||
}
|
||||
@@ -834,7 +841,6 @@ mod tests {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = system::offchain::TransactionSubmitter<(), Test, TestXt<Call, ()>>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -851,7 +857,8 @@ mod tests {
|
||||
|
||||
// This is needed for a custom `AccountId` type which is `u64` in testing here.
|
||||
pub mod test_keys {
|
||||
use sp_core::crypto::KeyTypeId;
|
||||
use sp_core::{crypto::KeyTypeId, sr25519};
|
||||
use primitives::Signature;
|
||||
|
||||
pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test");
|
||||
|
||||
@@ -872,10 +879,16 @@ mod tests {
|
||||
}
|
||||
|
||||
pub type ReporterId = app::Public;
|
||||
pub type ReporterSignature = app::Signature;
|
||||
pub struct ReporterAuthorityId;
|
||||
impl system::offchain::AppCrypto<ReporterId, Signature> for ReporterAuthorityId {
|
||||
type RuntimeAppPublic = ReporterId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
}
|
||||
|
||||
impl parachains::Trait for Test {
|
||||
type AuthorityId = test_keys::ReporterAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = balances::Module<Test>;
|
||||
@@ -893,29 +906,28 @@ mod tests {
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = ();
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
type SubmitSignedTransaction = system::offchain::TransactionSubmitter<
|
||||
test_keys::ReporterId,
|
||||
Test,
|
||||
Extrinsic,
|
||||
>;
|
||||
}
|
||||
|
||||
type Extrinsic = TestXt<Call, ()>;
|
||||
|
||||
impl system::offchain::CreateTransaction<Test, Extrinsic> for Test {
|
||||
type Public = test_keys::ReporterId;
|
||||
type Signature = test_keys::ReporterSignature;
|
||||
|
||||
fn create_transaction<F: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <Extrinsic as ExtrinsicT>::Call,
|
||||
_public: Self::Public,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Test where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
_public: test_keys::ReporterId,
|
||||
_account: <Test as system::Trait>::AccountId,
|
||||
nonce: <Test as system::Trait>::Index,
|
||||
) -> Option<(<Extrinsic as ExtrinsicT>::Call, <Extrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
) -> Option<(Call, <Extrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
Some((call, (nonce, ())))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Test {
|
||||
type Public = test_keys::ReporterId;
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 10;
|
||||
pub const QueueSize: usize = 2;
|
||||
|
||||
@@ -32,6 +32,7 @@ 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,
|
||||
@@ -41,7 +42,7 @@ use sp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup,
|
||||
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion,
|
||||
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
},
|
||||
};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -58,7 +59,6 @@ use frame_support::{
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use system::offchain::TransactionSubmitter;
|
||||
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use session::{historical as session_historical};
|
||||
|
||||
@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("kusama"),
|
||||
impl_name: create_runtime_str!("parity-kusama"),
|
||||
authoring_version: 2,
|
||||
spec_version: 1059,
|
||||
spec_version: 1060,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
@@ -322,7 +322,6 @@ impl staking::Trait for Runtime {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = TransactionSubmitter<(), Runtime, UncheckedExtrinsic>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -467,8 +466,6 @@ impl offences::Trait for Runtime {
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_BLOCKS as _;
|
||||
}
|
||||
@@ -481,8 +478,6 @@ parameter_types! {
|
||||
impl im_online::Trait for Runtime {
|
||||
type AuthorityId = ImOnlineId;
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = SubmitTransaction;
|
||||
type ReportUnresponsiveness = Offences;
|
||||
type SessionDuration = SessionDuration;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
@@ -522,6 +517,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = FishermanAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
@@ -541,17 +537,22 @@ impl parachains::Trait for Runtime {
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
type SubmitSignedTransaction = TransactionSubmitter<parachain::FishermanId, Runtime, UncheckedExtrinsic>;
|
||||
}
|
||||
|
||||
impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
type Public = <primitives::Signature as sp_runtime::traits::Verify>::Signer;
|
||||
type Signature = primitives::Signature;
|
||||
pub struct FishermanAuthorityId;
|
||||
impl system::offchain::AppCrypto<<Signature as Verify>::Signer, Signature> for FishermanAuthorityId {
|
||||
type RuntimeAppPublic = parachain::FishermanId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
|
||||
fn create_transaction<TSigner: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <UncheckedExtrinsic as ExtrinsicT>::Call,
|
||||
public: Self::Public,
|
||||
account: <Runtime as system::Trait>::AccountId,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
public: <Signature as Verify>::Signer,
|
||||
account: AccountId,
|
||||
nonce: <Runtime as system::Trait>::Index,
|
||||
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
let period = BlockHashCount::get()
|
||||
@@ -575,14 +576,28 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e)
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
}).ok()?;
|
||||
let signature = TSigner::sign(public, &raw_payload)?;
|
||||
let signature = raw_payload.using_encoded(|payload| {
|
||||
C::sign(payload, public)
|
||||
})?;
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
Some((call, (account, signature, extra)))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Runtime {
|
||||
type Public = <Signature as Verify>::Signer;
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
|
||||
@@ -33,6 +33,7 @@ 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,
|
||||
@@ -43,6 +44,7 @@ use sp_runtime::{
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto,
|
||||
DispatchInfoOf, IdentityLookup, Extrinsic as ExtrinsicT, SaturatedConversion,
|
||||
Verify,
|
||||
},
|
||||
};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -59,9 +61,8 @@ use frame_support::{
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use system::offchain::TransactionSubmitter;
|
||||
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use session::{historical as session_historical};
|
||||
use session::historical as session_historical;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use staking::StakerStatus;
|
||||
@@ -326,7 +327,6 @@ impl staking::Trait for Runtime {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = TransactionSubmitter<(), Runtime, UncheckedExtrinsic>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -472,8 +472,6 @@ impl offences::Trait for Runtime {
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_BLOCKS as _;
|
||||
}
|
||||
@@ -486,8 +484,6 @@ parameter_types! {
|
||||
impl im_online::Trait for Runtime {
|
||||
type AuthorityId = ImOnlineId;
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = SubmitTransaction;
|
||||
type SessionDuration = SessionDuration;
|
||||
type ReportUnresponsiveness = Offences;
|
||||
type UnsignedPriority = ImOnlineUnsignedPriority;
|
||||
@@ -528,6 +524,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = FishermanAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
@@ -547,17 +544,22 @@ impl parachains::Trait for Runtime {
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
type SubmitSignedTransaction = TransactionSubmitter<parachain::FishermanId, Runtime, UncheckedExtrinsic>;
|
||||
}
|
||||
|
||||
impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
type Public = <primitives::Signature as sp_runtime::traits::Verify>::Signer;
|
||||
type Signature = primitives::Signature;
|
||||
pub struct FishermanAuthorityId;
|
||||
impl system::offchain::AppCrypto<<Signature as Verify>::Signer, Signature> for FishermanAuthorityId {
|
||||
type RuntimeAppPublic = parachain::FishermanId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
|
||||
fn create_transaction<TSigner: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <UncheckedExtrinsic as ExtrinsicT>::Call,
|
||||
public: Self::Public,
|
||||
account: <Runtime as system::Trait>::AccountId,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
public: <Signature as Verify>::Signer,
|
||||
account: AccountId,
|
||||
nonce: <Runtime as system::Trait>::Index,
|
||||
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
let period = BlockHashCount::get()
|
||||
@@ -581,14 +583,28 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e)
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
}).ok()?;
|
||||
let signature = TSigner::sign(public, &raw_payload)?;
|
||||
let signature = raw_payload.using_encoded(|payload| {
|
||||
C::sign(payload, public)
|
||||
})?;
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
Some((call, (account, signature, extra)))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Runtime {
|
||||
type Public = <Signature as Verify>::Signer;
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 500 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
|
||||
@@ -31,7 +31,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
|
||||
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
|
||||
MaximumBlockLength,
|
||||
};
|
||||
|
||||
use sp_core::sr25519;
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
ApplyExtrinsicResult, Perbill, Perquintill, RuntimeDebug, KeyTypeId,
|
||||
@@ -41,7 +41,7 @@ use sp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto,
|
||||
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion,
|
||||
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
},
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
@@ -56,7 +56,6 @@ use frame_support::{
|
||||
};
|
||||
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;
|
||||
@@ -153,6 +152,13 @@ impl system::Trait for Runtime {
|
||||
type OnKilledAccount = ();
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64;
|
||||
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||
@@ -303,7 +309,6 @@ impl staking::Trait for Runtime {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = system::offchain::TransactionSubmitter<(), Runtime, Extrinsic>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -331,6 +336,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = FishermanAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
@@ -352,17 +358,22 @@ impl parachains::Trait for Runtime {
|
||||
>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
type SubmitSignedTransaction = TransactionSubmitter<parachain::FishermanId, Runtime, UncheckedExtrinsic>;
|
||||
}
|
||||
|
||||
impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
type Public = <primitives::Signature as sp_runtime::traits::Verify>::Signer;
|
||||
type Signature = primitives::Signature;
|
||||
pub struct FishermanAuthorityId;
|
||||
impl system::offchain::AppCrypto<<Signature as Verify>::Signer, Signature> for FishermanAuthorityId {
|
||||
type RuntimeAppPublic = parachain::FishermanId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
|
||||
fn create_transaction<TSigner: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <UncheckedExtrinsic as ExtrinsicT>::Call,
|
||||
public: Self::Public,
|
||||
account: <Runtime as system::Trait>::AccountId,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
public: <Signature as Verify>::Signer,
|
||||
account: AccountId,
|
||||
nonce: <Runtime as system::Trait>::Index,
|
||||
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
let period = BlockHashCount::get()
|
||||
@@ -386,15 +397,22 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e)
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
}).ok()?;
|
||||
let signature = TSigner::sign(public, &raw_payload)?;
|
||||
let signature = raw_payload.using_encoded(|payload| {
|
||||
C::sign(payload, public)
|
||||
})?;
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
let address = Indices::unlookup(account);
|
||||
Some((call, (address, signature, extra)))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Runtime {
|
||||
type Public = <Signature as Verify>::Signer;
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
|
||||
@@ -30,6 +30,7 @@ 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,
|
||||
@@ -40,7 +41,7 @@ use sp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup,
|
||||
DispatchInfoOf, StaticLookup, Extrinsic as ExtrinsicT, SaturatedConversion,
|
||||
DispatchInfoOf, StaticLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
},
|
||||
};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -57,9 +58,8 @@ use frame_support::{
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use system::offchain::TransactionSubmitter;
|
||||
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use session::{historical as session_historical};
|
||||
use session::historical as session_historical;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use staking::StakerStatus;
|
||||
@@ -313,7 +313,6 @@ impl staking::Trait for Runtime {
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = TransactionSubmitter<(), Runtime, UncheckedExtrinsic>;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
}
|
||||
|
||||
@@ -337,8 +336,6 @@ impl offences::Trait for Runtime {
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_BLOCKS as _;
|
||||
}
|
||||
@@ -351,8 +348,6 @@ parameter_types! {
|
||||
impl im_online::Trait for Runtime {
|
||||
type AuthorityId = ImOnlineId;
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type SubmitTransaction = SubmitTransaction;
|
||||
type ReportUnresponsiveness = Offences;
|
||||
type SessionDuration = SessionDuration;
|
||||
type UnsignedPriority = StakingUnsignedPriority;
|
||||
@@ -392,6 +387,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = FishermanAuthorityId;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
@@ -411,17 +407,22 @@ impl parachains::Trait for Runtime {
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
type SubmitSignedTransaction = TransactionSubmitter<parachain::FishermanId, Runtime, UncheckedExtrinsic>;
|
||||
}
|
||||
|
||||
impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
type Public = <primitives::Signature as sp_runtime::traits::Verify>::Signer;
|
||||
type Signature = primitives::Signature;
|
||||
pub struct FishermanAuthorityId;
|
||||
impl system::offchain::AppCrypto<<Signature as Verify>::Signer, Signature> for FishermanAuthorityId {
|
||||
type RuntimeAppPublic = parachain::FishermanId;
|
||||
type GenericSignature = sr25519::Signature;
|
||||
type GenericPublic = sr25519::Public;
|
||||
}
|
||||
|
||||
fn create_transaction<TSigner: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: <UncheckedExtrinsic as ExtrinsicT>::Call,
|
||||
public: Self::Public,
|
||||
account: <Runtime as system::Trait>::AccountId,
|
||||
impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
public: <Signature as Verify>::Signer,
|
||||
account: AccountId,
|
||||
nonce: <Runtime as system::Trait>::Index,
|
||||
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
let period = BlockHashCount::get()
|
||||
@@ -445,14 +446,28 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e)
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
}).ok()?;
|
||||
let signature = TSigner::sign(public, &raw_payload)?;
|
||||
let signature = raw_payload.using_encoded(|payload| {
|
||||
C::sign(payload, public)
|
||||
})?;
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
Some((call, (account, signature, extra)))
|
||||
}
|
||||
}
|
||||
|
||||
impl system::offchain::SigningTypes for Runtime {
|
||||
type Public = <Signature as Verify>::Signer;
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
impl<C> system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
Call: From<C>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
|
||||
Reference in New Issue
Block a user