-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Finish splitting
Runtime
config (#440)
* chore(kreivo-runtime): finish splitting runtime config * change(kreivo-runtime): move `contracts` to its own folder, in preparation to adding `ChainExtensions` config * fix: fmt * chore: re-sort imports and cut down unused imports * fix: fmt * fix(kreivo-runtime): re-export `DAYS`, `HOURS` and `MINUTES` from `runtime_constants`
- Loading branch information
Showing
23 changed files
with
466 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
use super::*; | ||
|
||
use frame_support::traits::EitherOfDiverse; | ||
use pallet_xcm::IsVoiceOfBody; | ||
|
||
// #[runtime::pallet_index(20)] | ||
// pub type Authorship | ||
impl pallet_authorship::Config for Runtime { | ||
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>; | ||
type EventHandler = (CollatorSelection,); | ||
} | ||
|
||
// #[runtime::pallet_index(21)] | ||
// pub type CollatorSelection | ||
parameter_types! { | ||
pub const PotId: PalletId = PalletId(*b"PotStake"); | ||
pub const MaxCandidates: u32 = 1000; | ||
pub const MinEligibleCollators: u32 = 1; | ||
pub const MaxInvulnerables: u32 = 100; | ||
// StakingAdmin pluralistic body. | ||
pub const StakingAdminBodyId: BodyId = BodyId::Defense; | ||
} | ||
|
||
/// We allow root and the StakingAdmin to execute privileged collator selection | ||
/// operations. | ||
pub type CollatorSelectionUpdateOrigin = | ||
EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>>; | ||
|
||
impl pallet_collator_selection::Config for Runtime { | ||
type RuntimeEvent = RuntimeEvent; | ||
type Currency = Balances; | ||
type UpdateOrigin = CollatorSelectionUpdateOrigin; | ||
type PotId = PotId; | ||
type MaxCandidates = MaxCandidates; | ||
type MinEligibleCollators = MinEligibleCollators; | ||
type MaxInvulnerables = MaxInvulnerables; | ||
// should be a multiple of session or things will get inconsistent | ||
type KickThreshold = Period; | ||
type ValidatorId = <Self as frame_system::Config>::AccountId; | ||
type ValidatorIdOf = pallet_collator_selection::IdentityCollator; | ||
type ValidatorRegistration = Session; | ||
type WeightInfo = (); | ||
} | ||
|
||
// #[runtime::pallet_index(22)] | ||
// pub type Session | ||
parameter_types! { | ||
pub const Period: u32 = 6 * HOURS; | ||
pub const Offset: u32 = 0; | ||
} | ||
|
||
impl pallet_session::Config for Runtime { | ||
type RuntimeEvent = RuntimeEvent; | ||
type ValidatorId = <Self as frame_system::Config>::AccountId; | ||
// we don't have stash and controller, thus we don't need the convert as well. | ||
type ValidatorIdOf = pallet_collator_selection::IdentityCollator; | ||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>; | ||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>; | ||
type SessionManager = CollatorSelection; | ||
// Essentially just Aura, but let's be pedantic. | ||
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders; | ||
type Keys = SessionKeys; | ||
type WeightInfo = (); | ||
} | ||
|
||
// #[runtime::pallet_index(23)] | ||
// pub type Aura | ||
|
||
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked | ||
/// up by `pallet_aura` to implement `fn slot_duration()`. | ||
/// | ||
/// Change this to adjust the block time. | ||
pub const MILLISECONDS_PER_BLOCK: u64 = 6_000; | ||
pub const SLOT_DURATION: u64 = MILLISECONDS_PER_BLOCK; | ||
|
||
impl pallet_aura::Config for Runtime { | ||
type AuthorityId = AuraId; | ||
type MaxAuthorities = ConstU32<100_000>; | ||
type DisabledValidators = (); | ||
type AllowMultipleBlocksPerSlot = ConstBool<true>; | ||
type SlotDuration = ConstU64<SLOT_DURATION>; | ||
} | ||
|
||
// #[runtime::pallet_index(24)] | ||
// pub type AuraExt | ||
impl cumulus_pallet_aura_ext::Config for Runtime {} | ||
|
||
mod async_backing_params { | ||
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet | ||
/// included into the relay chain. | ||
pub(crate) const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; | ||
/// How many parachain blocks are processed by the relay chain per parent. | ||
/// Limits the number of blocks authored per slot. | ||
pub(crate) const BLOCK_PROCESSING_VELOCITY: u32 = 1; | ||
/// Relay chain slot duration, in milliseconds. | ||
pub(crate) const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6_000; | ||
} | ||
|
||
/// Aura consensus hook | ||
pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< | ||
Runtime, | ||
{ async_backing_params::RELAY_CHAIN_SLOT_DURATION_MILLIS }, | ||
{ async_backing_params::BLOCK_PROCESSING_VELOCITY }, | ||
{ async_backing_params::UNINCLUDED_SEGMENT_CAPACITY }, | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use super::*; | ||
|
||
pub mod origins; | ||
|
||
use crate::{Balances, Runtime, RuntimeEvent}; | ||
use frame_support::parameter_types; | ||
use frame_support::traits::tokens::{PayFromAccount, UnityAssetBalanceConversion}; | ||
pub use origins::*; | ||
use parachains_common::Balance; | ||
use sp_runtime::{traits::IdentityLookup, Permill}; | ||
|
||
// #[runtime::pallet_index(50)] | ||
// pub type Treasury | ||
parameter_types! { | ||
pub const ProposalBond: Permill = Permill::from_percent(5); | ||
pub const ProposalBondMinimum: Balance = 2000 * CENTS; | ||
pub const ProposalBondMaximum: Balance = GRAND; | ||
pub const SpendPeriod: BlockNumber = 6 * DAYS; | ||
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); | ||
pub const TipCountdown: BlockNumber = DAYS; | ||
pub const TipFindersFee: Percent = Percent::from_percent(20); | ||
pub const TipReportDepositBase: Balance = 100 * CENTS; | ||
pub const DataDepositPerByte: Balance = CENTS; | ||
pub const MaxApprovals: u32 = 100; | ||
pub const MaxAuthorities: u32 = 100_000; | ||
pub const MaxKeys: u32 = 10_000; | ||
pub const MaxPeerInHeartbeats: u32 = 10_000; | ||
pub const MaxPeerDataEncodingSize: u32 = 1_000; | ||
pub TreasuryAccount: AccountId = Treasury::account_id(); | ||
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS; | ||
} | ||
|
||
impl pallet_treasury::Config for Runtime { | ||
type Currency = Balances; | ||
type RejectOrigin = frame_system::EnsureRoot<Self::AccountId>; | ||
type RuntimeEvent = RuntimeEvent; | ||
type SpendPeriod = SpendPeriod; | ||
type Burn = (); | ||
type PalletId = TreasuryPalletId; | ||
type BurnDestination = (); | ||
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>; | ||
type SpendFunds = (); | ||
type MaxApprovals = MaxApprovals; | ||
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; | ||
type AssetKind = (); | ||
type Beneficiary = Self::AccountId; | ||
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>; | ||
type Paymaster = PayFromAccount<Balances, TreasuryAccount>; | ||
type BalanceConverter = UnityAssetBalanceConversion; | ||
type PayoutPeriod = PayoutSpendPeriod; | ||
#[cfg(feature = "runtime-benchmarks")] | ||
/// TODO: fix this benchmark helper in next release. We can proceed with the | ||
/// empty implementation. type BenchmarkHelper = | ||
/// polkadot_runtime_common::impls::benchmarks::TreasuryArguments; | ||
type BenchmarkHelper = (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.