Skip to content

Commit

Permalink
import sam-tasks branch from old substrate repository
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0x17 committed Sep 6, 2023
1 parent 1e2a2f0 commit df81863
Show file tree
Hide file tree
Showing 126 changed files with 828 additions and 8 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ members = [
"substrate/frame/examples/kitchensink",
"substrate/frame/examples/offchain-worker",
"substrate/frame/examples/split",
"substrate/frame/examples/tasks-example",
"substrate/frame/executive",
"substrate/frame/fast-unstake",
"substrate/frame/glutton",
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl frame_system::Config for Test {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down
3 changes: 3 additions & 0 deletions substrate/bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type RuntimeCall = RuntimeCall;
/// The aggregated task type that is available for extrinsics.
type RuntimeTask = RuntimeTask;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The type for storing how many extrinsics an account has signed.
Expand Down Expand Up @@ -243,6 +245,7 @@ impl pallet_balances::Config for Runtime {
type Balance = Balance;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type AccountStore = System;
Expand Down
9 changes: 9 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use tasks_example;

#[cfg(any(feature = "std", test))]
pub use frame_system::Call as SystemCall;
Expand Down Expand Up @@ -287,6 +288,7 @@ impl frame_system::Config for Runtime {
type DbWeight = RocksDbWeight;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = Nonce;
type Hash = Hash;
type Hashing = BlakeTwo256;
Expand All @@ -308,6 +310,11 @@ impl frame_system::Config for Runtime {

impl pallet_insecure_randomness_collective_flip::Config for Runtime {}

impl tasks_example::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
}

impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
Expand Down Expand Up @@ -512,6 +519,7 @@ impl pallet_balances::Config for Runtime {
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Pallet<Runtime>;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
Expand Down Expand Up @@ -2171,6 +2179,7 @@ mod benches {
[pallet_conviction_voting, ConvictionVoting]
[pallet_contracts, Contracts]
[pallet_core_fellowship, CoreFellowship]
[tasks_example, TasksExample]
[pallet_democracy, Democracy]
[pallet_asset_conversion, AssetConversion]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down Expand Up @@ -79,6 +80,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/asset-conversion/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down Expand Up @@ -88,6 +89,7 @@ impl pallet_balances::Config for Test {
type MaxFreezes = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type RuntimeTask = RuntimeTask;
}

impl pallet_assets::Config<Instance1> for Test {
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/asset-rate/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeTask = RuntimeTask;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
Expand Down Expand Up @@ -76,6 +77,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxHolds = ();
type MaxFreezes = ();
type RuntimeTask = RuntimeTask;
}

impl pallet_asset_rate::Config for Test {
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down Expand Up @@ -86,6 +87,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxHolds = ();
type MaxFreezes = ();
type RuntimeTask = RuntimeTask;
}

pub struct AssetsCallbackHandle;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl frame_system::Config for Test {
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
Expand Down Expand Up @@ -78,6 +79,7 @@ impl pallet_balances::Config for Test {
type MaxFreezes = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type RuntimeTask = RuntimeTask;
}

impl Config for Test {
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = u64;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AuthorityId;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mod tests {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = RuntimeTask;
}

impl pallet::Config for Test {
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Version = ();
type Hashing = sp_runtime::traits::BlakeTwo256;
Expand Down Expand Up @@ -139,6 +140,7 @@ impl pallet_balances::Config for Test {
type Balance = u128;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/bags-list/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = sp_core::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
Expand Down
4 changes: 4 additions & 0 deletions substrate/frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// The overarching task type.
#[pallet::no_default]
type RuntimeTask: AggregatedTask;

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/balances/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = u64;
Expand Down Expand Up @@ -135,6 +136,7 @@ impl Config for Test {
type FreezeIdentifier = TestId;
type MaxFreezes = ConstU32<2>;
type MaxHolds = ConstU32<2>;
type RuntimeTask = RuntimeTask;
}

#[derive(Clone)]
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl frame_system::Config for Test {
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl frame_system::Config for Test {
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
Expand Down Expand Up @@ -155,6 +156,7 @@ impl pallet_balances::Config for Test {
type Balance = u128;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/benchmarking/pov/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ mod mock {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u32;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = u32;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl frame_system::Config for Test {
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/benchmarking/src/tests_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account
Expand All @@ -88,6 +89,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/broker/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl frame_system::Config for Test {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u128;
Expand All @@ -91,6 +92,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = RuntimeTask;
}
impl Config<Instance1> for Test {
type RuntimeOrigin = RuntimeOrigin;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ impl frame_system::Config for Test {
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hashing = BlakeTwo256;
type AccountId = AccountId32;
type Lookup = IdentityLookup<Self::AccountId>;
Expand All @@ -363,6 +364,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/conviction-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand All @@ -83,6 +84,7 @@ impl pallet_balances::Config for Test {
type MaxLocks = ConstU32<10>;
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type RuntimeTask = RuntimeTask;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/core-fellowship/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = RuntimeTask;
}

thread_local! {
Expand Down
Loading

0 comments on commit df81863

Please sign in to comment.