runtime_eden/
pallets_system.rs#![allow(clippy::identity_op)]
use crate::{
constants, implementations::DealWithFees, version::VERSION, Balances, Block, PalletInfo, Runtime, RuntimeCall,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, SignedExtra, SignedPayload,
System, UncheckedExtrinsic,
};
use codec::Encode;
use frame_support::{
derive_impl, parameter_types,
traits::ConstU32,
weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee},
};
use frame_system::limits::BlockLength;
use pallet_transaction_payment::{FungibleAdapter, Multiplier};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use primitives::{AccountId, Balance, Hash, Moment, Nonce, Signature};
use sp_runtime::{
generic,
traits::{SaturatedConversion, StaticLookup},
FixedPointNumber, Perquintill,
};
use sp_version::RuntimeVersion;
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, constants::NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u8 = 37;
}
#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
impl frame_system::Config for Runtime {
type BlockWeights = constants::RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type AccountId = AccountId;
type Nonce = Nonce;
type Hash = Hash;
type Block = Block;
type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight;
type Version = Version;
type AccountData = pallet_balances::AccountData<Balance>;
type SystemWeightInfo = crate::weights::frame_system::WeightInfo<Runtime>;
type SS58Prefix = SS58Prefix;
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const MinimumPeriod: u64 = constants::SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
type Moment = Moment;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type WeightInfo = crate::weights::pallet_timestamp::WeightInfo<Runtime>;
}
parameter_types! {
pub const ExistentialDeposit: Balance = constants::EXISTENTIAL_DEPOSIT;
}
impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Pallet<Runtime>;
type WeightInfo = crate::weights::pallet_balances::WeightInfo<Runtime>;
type MaxFreezes = ConstU32<0>;
type FreezeIdentifier = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
}
parameter_types! {
pub const TransactionByteFee: Balance = 1 * constants::MICRO_NODL;
pub const OperationalFeeMultiplier: u8 = 5;
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
}
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = FungibleAdapter<Balances, DealWithFees>;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
}
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
call: RuntimeCall,
public: <Signature as sp_runtime::traits::Verify>::Signer,
account: AccountId,
nonce: Nonce,
) -> Option<(
RuntimeCall,
<UncheckedExtrinsic as sp_runtime::traits::Extrinsic>::SignaturePayload,
)> {
let period = BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let current_block = System::block_number()
.saturated_into::<u64>()
.saturating_sub(1);
let era = generic::Era::mortal(period, current_block);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
frame_system::CheckEra::<Runtime>::from(era),
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
pallet_sponsorship::ChargeSponsor::<Runtime>::default(),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(true),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|_e| {
})
.ok()?;
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
let (call, extra, _) = raw_payload.deconstruct();
Some((call, (address, signature, extra)))
}
}
impl frame_system::offchain::SigningTypes for Runtime {
type Public = <Signature as sp_runtime::traits::Verify>::Signer;
type Signature = Signature;
}
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
RuntimeCall: From<C>,
{
type OverarchingCall = RuntimeCall;
type Extrinsic = UncheckedExtrinsic;
}