Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions chain-extensions/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use core::num::NonZeroU64;

use frame_support::dispatch::DispatchResult;
use frame_support::pallet_prelude::Zero;
use frame_support::traits::{Contains, Everything, InherentBuilder, InsideBoth};
use frame_support::traits::{Contains, Everything, InsideBoth};
use frame_support::weights::Weight;
use frame_support::weights::constants::RocksDbWeight;
use frame_support::{PalletId, derive_impl};
use frame_support::{assert_ok, parameter_types, traits::PrivilegeCmp};
use frame_system as system;
use frame_system::{EnsureRoot, RawOrigin, limits, offchain::CreateTransactionBase};
use frame_system::{EnsureRoot, RawOrigin, limits};
use pallet_contracts::HoldReason as ContractsHoldReason;
use pallet_subtensor::*;
use pallet_subtensor_proxy as pallet_proxy;
Expand Down Expand Up @@ -618,28 +618,12 @@ where
type RuntimeCall = RuntimeCall;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Test
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_inherent(call)
}
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_signed_transaction<
C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
>(
call: <Self as CreateTransactionBase<LocalCall>>::RuntimeCall,
_public: Self::Public,
_account: Self::AccountId,
nonce: Self::Nonce,
) -> Option<Self::Extrinsic> {
Some(UncheckedExtrinsic::new_signed(call, nonce.into(), (), ()))
UncheckedExtrinsic::new_bare(call)
}
}

Expand Down
24 changes: 4 additions & 20 deletions eco-tests/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use core::num::NonZeroU64;

use frame_support::dispatch::DispatchResult;
use frame_support::traits::{Contains, Everything, InherentBuilder, InsideBoth, InstanceFilter};
use frame_support::traits::{Contains, Everything, InsideBoth, InstanceFilter};
use frame_support::weights::Weight;
use frame_support::weights::constants::RocksDbWeight;
use frame_support::{PalletId, derive_impl};
use frame_support::{parameter_types, traits::PrivilegeCmp};
use frame_system as system;
use frame_system::{EnsureRoot, limits, offchain::CreateTransactionBase};
use frame_system::{EnsureRoot, limits};
use pallet_subtensor::*;
use pallet_subtensor_proxy as pallet_proxy;
use pallet_subtensor_utility as pallet_utility;
Expand Down Expand Up @@ -546,28 +546,12 @@ where
type RuntimeCall = RuntimeCall;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Test
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_inherent(call)
}
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_signed_transaction<
C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
>(
call: <Self as CreateTransactionBase<LocalCall>>::RuntimeCall,
_public: Self::Public,
_account: Self::AccountId,
nonce: Self::Nonce,
) -> Option<Self::Extrinsic> {
Some(UncheckedExtrinsic::new_signed(call, nonce.into(), (), ()))
UncheckedExtrinsic::new_bare(call)
}
}

Expand Down
24 changes: 4 additions & 20 deletions pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use core::num::NonZeroU64;

use frame_support::{
PalletId, assert_ok, derive_impl, parameter_types,
traits::{Everything, Hooks, InherentBuilder, PrivilegeCmp},
traits::{Everything, Hooks, PrivilegeCmp},
};
use frame_system::{self as system, offchain::CreateTransactionBase};
use frame_system::{self as system};
use frame_system::{EnsureRoot, limits};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityList as GrandpaAuthorityList;
Expand Down Expand Up @@ -469,28 +469,12 @@ where
type RuntimeCall = RuntimeCall;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Test
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_inherent(call)
}
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_signed_transaction<
C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
>(
call: <Self as CreateTransactionBase<LocalCall>>::RuntimeCall,
_public: Self::Public,
_account: Self::AccountId,
nonce: Self::Nonce,
) -> Option<Self::Extrinsic> {
Some(UncheckedExtrinsic::new_signed(call, nonce, (), ()))
UncheckedExtrinsic::new_bare(call)
}
}

Expand Down
32 changes: 3 additions & 29 deletions pallets/commitments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate as pallet_commitments;
use frame_support::{
derive_impl,
pallet_prelude::{Get, TypeInfo},
traits::{ConstU32, ConstU64, InherentBuilder},
traits::{ConstU32, ConstU64},
};
use frame_system::offchain::CreateTransactionBase;
use sp_core::H256;
use sp_runtime::{
BuildStorage,
Expand Down Expand Up @@ -169,37 +168,12 @@ where
type RuntimeCall = RuntimeCall;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Test
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_inherent(call)
}
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_signed_transaction<
C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
>(
call: <Self as CreateTransactionBase<LocalCall>>::RuntimeCall,
_public: Self::Public,
_account: Self::AccountId,
nonce: Self::Nonce,
) -> Option<Self::Extrinsic> {
// Create a dummy sr25519 signature from a raw byte array
let dummy_raw = [0u8; 64];
let dummy_signature = sp_core::sr25519::Signature::from(dummy_raw);
let signature = test_crypto::Signature::from(dummy_signature);
Some(UncheckedExtrinsic::new_signed(
call,
nonce.into(),
signature,
(),
))
UncheckedExtrinsic::new_bare(call)
}
}

Expand Down
7 changes: 2 additions & 5 deletions pallets/drand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ use codec::Encode;
use frame_support::{pallet_prelude::*, traits::Randomness};
use frame_system::{
offchain::{
AppCrypto, CreateInherent, CreateSignedTransaction, SendUnsignedTransaction, SignedPayload,
Signer, SigningTypes,
AppCrypto, CreateBare, SendUnsignedTransaction, SignedPayload, Signer, SigningTypes,
},
pallet_prelude::BlockNumberFor,
};
Expand Down Expand Up @@ -162,9 +161,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config:
CreateSignedTransaction<Call<Self>> + CreateInherent<Call<Self>> + frame_system::Config
{
pub trait Config: CreateBare<Call<Self>> + SigningTypes + frame_system::Config {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Update all drand mock runtimes to implement CreateBare

pallet_drand::Config now requires CreateBare<Call<Self>>, but this PR only converts part of the repo. Existing pallet_drand::Config implementors in pallets/subtensor/src/tests/mock_high_ed.rs, precompiles/src/mock.rs, and eco-tests/src/mock.rs still implement CreateInherent/CreateSignedTransaction and do not implement CreateBare, so crates that compile those mocks will no longer satisfy this bound. Convert those remaining mocks the same way as the files in this PR: implement frame_system::offchain::CreateBare, use UncheckedExtrinsic::new_bare(...), and remove the now-unused CreateSignedTransaction implementations.

/// The identifier type for an offchain worker.
type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
/// something that knows how to verify beacon pulses
Expand Down
25 changes: 4 additions & 21 deletions pallets/drand/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use crate::verifier::*;
use crate::*;
use frame_support::{
derive_impl, parameter_types,
traits::{ConstU16, ConstU64, InherentBuilder},
traits::{ConstU16, ConstU64},
};
use sp_core::{H256, sr25519::Signature};
use sp_keystore::{KeystoreExt, testing::MemoryKeystore};
use sp_runtime::{
BuildStorage,
testing::TestXt,
traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify},
traits::{BlakeTwo256, IdentityLookup, Verify},
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down Expand Up @@ -52,7 +52,6 @@ impl frame_system::Config for Test {
}

type Extrinsic = TestXt<RuntimeCall, ()>;
type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

impl frame_system::offchain::SigningTypes for Test {
type Public = <Signature as Verify>::Signer;
Expand All @@ -67,28 +66,12 @@ where
type Extrinsic = Extrinsic;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Test
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: RuntimeCall) -> Self::Extrinsic {
Extrinsic::new_inherent(call)
}
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Test
where
RuntimeCall: From<LocalCall>,
{
fn create_signed_transaction<
C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
>(
call: RuntimeCall,
_public: <Signature as Verify>::Signer,
_account: AccountId,
nonce: u64,
) -> Option<Self::Extrinsic> {
Some(Extrinsic::new_signed(call, nonce, (), ()))
Extrinsic::new_bare(call)
}
}

Expand Down
Loading
Loading