Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preimage and scheduler #101

Merged
merged 2 commits into from
Apr 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-featu
pallet-message-queue = { version = "31.0.0", default-features = false }
pallet-multisig = { version = "28.0.0", default-features = false }
pallet-proxy = { version = "28.0.0", default-features = false }
pallet-preimage = { version = "28.0.0", default-features = false }
pallet-scheduler = { version = "29.0.0", default-features = false }
pallet-utility = { version = "28.0.0", default-features = false }
sp-api = { version = "26.0.0", default-features = false }
sp-blockchain = { version = "28.0.0", default-features = false }
Expand Down
8 changes: 8 additions & 0 deletions runtime/regionx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ pallet-balances = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-proxy = { workspace = true }
pallet-preimage = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
Expand Down Expand Up @@ -134,8 +136,10 @@ std = [
"regionx-primitives/std",
"pallet-multisig/std",
"pallet-proxy/std",
"pallet-preimage/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-scheduler/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
Expand Down Expand Up @@ -185,8 +189,10 @@ runtime-benchmarks = [
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-regions/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
Expand Down Expand Up @@ -222,9 +228,11 @@ try-runtime = [
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-proxy/try-runtime",
"pallet-preimage/try-runtime",
"pallet-regions/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-utility/try-runtime",
Expand Down
45 changes: 44 additions & 1 deletion runtime/regionx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ use impls::*;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::traits::TransformOrigin;
use frame_support::traits::{
fungible::HoldConsideration, EqualPrivilegeOnly, LinearStoragePrice, TransformOrigin,
};
use pallet_regions::primitives::StateMachineHeightProvider as StateMachineHeightProviderT;
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
Expand Down Expand Up @@ -650,6 +652,43 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

parameter_types! {
pub const PreimageBaseDeposit: Balance = deposit(2, 64);
pub const PreimageByteDeposit: Balance = deposit(0, 1);
pub const PreimageHoldReason: RuntimeHoldReason =
RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
}

impl pallet_preimage::Config for Runtime {
type WeightInfo = ();
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type Consideration = HoldConsideration<
AccountId,
Balances,
PreimageHoldReason,
LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
>;
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
}

impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = ConstU32<10>;
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = Preimage;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand All @@ -659,6 +698,8 @@ construct_runtime!(
ParachainSystem: cumulus_pallet_parachain_system = 1,
Timestamp: pallet_timestamp = 2,
ParachainInfo: parachain_info = 3,
Preimage: pallet_preimage = 4,
Scheduler: pallet_scheduler = 5,

// Monetary stuff.
Balances: pallet_balances = 10,
Expand Down Expand Up @@ -707,9 +748,11 @@ mod benches {
[pallet_session, SessionBench::<Runtime>]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_proxy, Preimage]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
[pallet_sudo, Sudo]
[pallet_proxy, Scheduler]
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_regions, Regions]
Expand Down
Loading