git.delta.rocks / unique-network / refs/commits / 955f1bd67788

difftreelog

fix node for release

Yaroslav Bolyukin2024-06-24parents: #efce288 #5a77207.patch.diff
in: master

5 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6304,7 +6304,7 @@
 
 [[package]]
 name = "opal-runtime"
-version = "1.3.0"
+version = "1.9.0"
 dependencies = [
  "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
@@ -10188,7 +10188,7 @@
 
 [[package]]
 name = "quartz-runtime"
-version = "1.3.0"
+version = "1.9.0"
 dependencies = [
  "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
@@ -14976,7 +14976,7 @@
 
 [[package]]
 name = "unique-node"
-version = "1.3.0"
+version = "1.9.0"
 dependencies = [
  "app-promotion-rpc",
  "clap",
@@ -15063,7 +15063,7 @@
 
 [[package]]
 name = "unique-runtime"
-version = "1.3.0"
+version = "1.9.0"
 dependencies = [
  "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
@@ -15210,7 +15210,7 @@
 
 [[package]]
 name = "up-common"
-version = "1.3.0"
+version = "1.9.0"
 dependencies = [
  "cumulus-primitives-core",
  "fp-rpc",
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -185,20 +185,24 @@
 				.collect::<Vec<_>>(),
 		},
 
-		"session": {
-			"keys": invulnerables.into_iter()
-				.map(|name| {
-					let account = get_account_id_from_seed::<sr25519::Public>(name);
-					let aura = get_from_seed::<AuraId>(name);
-
-					(
-						/*   account id: */ account.clone(),
-						/* validator id: */ account,
-						/* session keys: */ SessionKeys { aura },
-					)
-				})
-				.collect::<Vec<_>>()
-		},
+		// We don't have Session pallet in production anywhere,
+		// Adding this config makes baedeker think we have pallet-session, and it tries to
+		// reconfigure chain using it, which makes no sense, because then aura knows no
+		// authority, as baedeker expects them to be configured by session pallet.
+		// "session": {
+		// 	"keys": invulnerables.into_iter()
+		// 		.map(|name| {
+		// 			let account = get_account_id_from_seed::<sr25519::Public>(name);
+		// 			let aura = get_from_seed::<AuraId>(name);
+		//
+		// 			(
+		// 				/*   account id: */ account.clone(),
+		// 				/* validator id: */ account,
+		// 				/* session keys: */ SessionKeys { aura },
+		// 			)
+		// 		})
+		// 		.collect::<Vec<_>>()
+		// },
 
 		"sudo": {
 			"key": get_account_id_from_seed::<sr25519::Public>("Alice"),
modifiednode/cli/src/rpc.rsdiffbeforeafterboth
--- a/node/cli/src/rpc.rs
+++ b/node/cli/src/rpc.rs
@@ -43,18 +43,13 @@
 type FullBackend = sc_service::TFullBackend<Block>;
 
 /// Full client dependencies.
-pub struct FullDeps<C, P, SC> {
+pub struct FullDeps<C, P> {
 	/// The client instance to use.
 	pub client: Arc<C>,
 	/// Transaction pool instance.
 	pub pool: Arc<P>,
-	/// The SelectChain Strategy
-	pub select_chain: SC,
 	/// Whether to deny unsafe calls
 	pub deny_unsafe: DenyUnsafe,
-
-	/// Runtime identification (read from the chain spec)
-	pub runtime_id: RuntimeId,
 	/// Executor params for PoV estimating
 	#[cfg(feature = "pov-estimate")]
 	pub exec_params: uc_rpc::pov_estimate::ExecutorParams,
@@ -64,9 +59,9 @@
 }
 
 /// Instantiate all Full RPC extensions.
-pub fn create_full<C, P, SC, R, B>(
+pub fn create_full<C, P, R, B>(
 	io: &mut RpcModule<()>,
-	deps: FullDeps<C, P, SC>,
+	deps: FullDeps<C, P>,
 ) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
 where
 	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,
@@ -93,10 +88,7 @@
 	let FullDeps {
 		client,
 		pool,
-		select_chain: _,
 		deny_unsafe,
-
-		runtime_id: _,
 
 		#[cfg(feature = "pov-estimate")]
 		exec_params,
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -36,8 +36,8 @@
 use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
 use cumulus_client_consensus_proposer::Proposer;
 use cumulus_client_service::{
-	build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, DARecoveryProfile,
-	StartRelayChainTasksParams,
+	build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
+	CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
 };
 use cumulus_primitives_core::ParaId;
 use cumulus_primitives_parachain_inherent::ParachainInherentData;
@@ -85,10 +85,7 @@
 use cumulus_primitives_core::PersistedValidationData;
 use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
 
-use crate::{
-	chain_spec::RuntimeIdentification,
-	rpc::{create_eth, create_full, EthDeps, FullDeps},
-};
+use crate::rpc::{create_eth, create_full, EthDeps, FullDeps};
 
 /// Unique native executor instance.
 #[cfg(feature = "unique-runtime")]
@@ -238,7 +235,7 @@
 	pub trait LookaheadApiDep: cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> {}
 );
 
-fn ethereum_parachain_inherent() -> ParachainInherentData {
+fn ethereum_parachain_inherent() -> (sp_timestamp::InherentDataProvider, ParachainInherentData) {
 	let (relay_parent_storage_root, relay_chain_state) =
 		RelayStateSproofBuilder::default().into_state_root_and_proof();
 	let vfp = PersistedValidationData {
@@ -249,12 +246,15 @@
 		..Default::default()
 	};
 
-	ParachainInherentData {
-		validation_data: vfp,
-		relay_chain_state,
-		downward_messages: Default::default(),
-		horizontal_messages: Default::default(),
-	}
+	(
+		sp_timestamp::InherentDataProvider::from_system_time(),
+		ParachainInherentData {
+			validation_data: vfp,
+			relay_chain_state,
+			downward_messages: Default::default(),
+			horizontal_messages: Default::default(),
+		},
+	)
 }
 
 /// Starts a `ServiceBuilder` for a full service.
@@ -426,34 +426,26 @@
 	.await
 	.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
 
-	// Aura is sybil-resistant, collator-selection is generally too.
-	let block_announce_validator =
-		cumulus_client_network::AssumeSybilResistance::allow_seconded_messages();
-
 	let validator = parachain_config.role.is_authority();
 	let prometheus_registry = parachain_config.prometheus_registry().cloned();
 	let transaction_pool = params.transaction_pool.clone();
 	let import_queue_service = params.import_queue.service();
 
 	let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
-		sc_service::build_network(sc_service::BuildNetworkParams {
-			config: &parachain_config,
+		cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
+			parachain_config: &parachain_config,
 			net_config,
 			client: client.clone(),
 			transaction_pool: transaction_pool.clone(),
+			para_id,
 			spawn_handle: task_manager.spawn_handle(),
+			relay_chain_interface: relay_chain_interface.clone(),
 			import_queue: params.import_queue,
-			block_announce_validator_builder: Some(Box::new(|_| {
-				Box::new(block_announce_validator)
-			})),
-			warp_sync_params: None,
-			block_relay: None,
-		})?;
-
-	let select_chain = params.select_chain.clone();
+			// Aura is sybil-resistant, collator-selection is generally too.
+			sybil_resistance_level: CollatorSybilResistance::Resistant,
+		})
+		.await?;
 
-	let runtime_id = parachain_config.chain_spec.runtime_id();
-
 	// Frontier
 	let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
 	let fee_history_limit = 2048;
@@ -505,9 +497,7 @@
 				fee_history_cache,
 				eth_block_data_cache,
 				network,
-				runtime_id,
 				transaction_pool,
-				select_chain,
 				overrides,
 			);
 
@@ -518,7 +508,6 @@
 
 			let full_deps = FullDeps {
 				client: client.clone(),
-				runtime_id,
 
 				#[cfg(feature = "pov-estimate")]
 				exec_params: uc_rpc::pov_estimate::ExecutorParams {
@@ -533,10 +522,9 @@
 
 				deny_unsafe,
 				pool: transaction_pool.clone(),
-				select_chain,
 			};
 
-			create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;
+			create_full::<_, _, Runtime, _>(&mut rpc_handle, full_deps)?;
 
 			let eth_deps = EthDeps {
 				client,
@@ -557,7 +545,7 @@
 				overrides,
 				sync: sync_service.clone(),
 				pending_create_inherent_data_providers: |_, ()| async move {
-					Ok((ethereum_parachain_inherent(),))
+					Ok(ethereum_parachain_inherent())
 				},
 			};
 
@@ -1040,8 +1028,6 @@
 
 	#[cfg(feature = "pov-estimate")]
 	let rpc_backend = backend.clone();
-
-	let runtime_id = config.chain_spec.runtime_id();
 
 	// Frontier
 	let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
@@ -1094,9 +1080,7 @@
 				fee_history_cache,
 				eth_block_data_cache,
 				network,
-				runtime_id,
 				transaction_pool,
-				select_chain,
 				overrides,
 			);
 
@@ -1106,8 +1090,6 @@
 			let mut rpc_module = RpcModule::new(());
 
 			let full_deps = FullDeps {
-				runtime_id,
-
 				#[cfg(feature = "pov-estimate")]
 				exec_params: uc_rpc::pov_estimate::ExecutorParams {
 					wasm_method: config.wasm_method,
@@ -1122,10 +1104,9 @@
 				deny_unsafe,
 				client: client.clone(),
 				pool: transaction_pool.clone(),
-				select_chain,
 			};
 
-			create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;
+			create_full::<_, _, Runtime, _>(&mut rpc_module, full_deps)?;
 
 			let eth_deps = EthDeps {
 				client,
@@ -1147,7 +1128,7 @@
 				sync: sync_service.clone(),
 				// We don't have any inherents except parachain built-ins, which we can't even extract from inside `run_aura`.
 				pending_create_inherent_data_providers: |_, ()| async move {
-					Ok((ethereum_parachain_inherent(),))
+					Ok(ethereum_parachain_inherent())
 				},
 			};
 
modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
before · runtime/common/config/substrate.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	dispatch::DispatchClass,19	ord_parameter_types, parameter_types,20	traits::{21		tokens::{PayFromAccount, UnityAssetBalanceConversion},22		ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin,23	},24	weights::{25		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},26		ConstantMultiplier,27	},28	PalletId,29};30use frame_system::{31	limits::{BlockLength, BlockWeights},32	EnsureRoot, EnsureSignedBy,33};34use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};35use sp_arithmetic::traits::One;36use sp_runtime::{37	traits::{AccountIdLookup, BlakeTwo256, IdentityLookup},38	Perbill, Percent, Permill,39};40use sp_std::vec;41use up_common::{constants::*, types::*};4243use crate::{44	runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,45	RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System,46	Treasury, Version,47};4849parameter_types! {50	pub const BlockHashCount: BlockNumber = 2400;51	pub RuntimeBlockLength: BlockLength =52		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);53	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);54	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;55	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()56		.base_block(BlockExecutionWeight::get())57		.for_class(DispatchClass::all(), |weights| {58			weights.base_extrinsic = ExtrinsicBaseWeight::get();59		})60		.for_class(DispatchClass::Normal, |weights| {61			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);62		})63		.for_class(DispatchClass::Operational, |weights| {64			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);65			// Operational transactions have some extra reserved space, so that they66			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.67			weights.reserved = Some(68				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT69			);70		})71		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)72		.build_or_panic();73}7475impl frame_system::Config for Runtime {76	/// The data to be stored in an account.77	type AccountData = pallet_balances::AccountData<Balance>;78	/// The identifier used to distinguish between accounts.79	type AccountId = AccountId;80	/// The basic call filter to use in dispatchable.81	type BaseCallFilter = Everything;82	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).83	type BlockHashCount = BlockHashCount;84	/// The block type.85	type Block = Block;86	/// The maximum length of a block (in bytes).87	type BlockLength = RuntimeBlockLength;88	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.89	type BlockWeights = RuntimeBlockWeights;90	/// The aggregated dispatch type that is available for extrinsics.91	type RuntimeCall = RuntimeCall;92	/// The weight of database operations that the runtime can invoke.93	type DbWeight = RocksDbWeight;94	/// The ubiquitous event type.95	type RuntimeEvent = RuntimeEvent;96	/// The type for hashing blocks and tries.97	type Hash = Hash;98	/// The hashing algorithm used.99	type Hashing = BlakeTwo256;100	/// The index type for storing how many extrinsics an account has signed.101	type Nonce = Nonce;102	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.103	type Lookup = AccountIdLookup<AccountId, ()>;104	/// What to do if an account is fully reaped from the system.105	type OnKilledAccount = ();106	/// What to do if a new account is created.107	type OnNewAccount = ();108	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;109	/// The ubiquitous origin type.110	type RuntimeOrigin = RuntimeOrigin;111	/// This type is being generated by `construct_runtime!`.112	type PalletInfo = PalletInfo;113	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.114	type SS58Prefix = SS58Prefix;115	/// Weight information for the extrinsics of this pallet.116	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;117	/// Version of the runtime.118	type Version = Version;119	type MaxConsumers = ConstU32<16>;120121	type RuntimeTask = ();122123	type SingleBlockMigrations = ();124	type MultiBlockMigrator = ();125	type PreInherents = ();126	type PostInherents = ();127	type PostTransactions = ();128}129130parameter_types! {131	pub const MigrationMaxKeyLen: u32 = 512;132}133ord_parameter_types! {134	pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));135}136137impl pallet_state_trie_migration::Config for Runtime {138	type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;139	type RuntimeEvent = RuntimeEvent;140	type Currency = Balances;141	type SignedDepositPerItem = ();142	type SignedDepositBase = ();143	type ControlOrigin = EnsureRoot<AccountId>;144	// Only root can perform this migration145	type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;146	type MaxKeyLen = MigrationMaxKeyLen;147	type RuntimeHoldReason = RuntimeHoldReason;148}149150impl pallet_timestamp::Config for Runtime {151	/// A timestamp: milliseconds since the unix epoch.152	type Moment = u64;153	type OnTimestampSet = ();154	#[cfg(not(feature = "lookahead"))]155	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;156	#[cfg(feature = "lookahead")]157	type MinimumPeriod = ConstU64<0>;158	type WeightInfo = ();159}160161parameter_types! {162	// pub const ExistentialDeposit: u128 = 500;163	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;164	pub const MaxLocks: u32 = 50;165	pub const MaxReserves: u32 = 50;166	pub const MaxHolds: u32 = 10;167	pub const MaxFreezes: u32 = 10;168}169170impl pallet_balances::Config for Runtime {171	type MaxLocks = MaxLocks;172	type MaxReserves = MaxReserves;173	type ReserveIdentifier = [u8; 16];174	/// The type for recording an account's balance.175	type Balance = Balance;176	/// The ubiquitous event type.177	type RuntimeEvent = RuntimeEvent;178	// FIXME: Is () the new treasury?179	// Switch to real treasury once we start having dust removals180	// Related issue: https://github.com/paritytech/polkadot/issues/7323181	type DustRemoval = ();182	type ExistentialDeposit = ExistentialDeposit;183	type AccountStore = System;184	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;185	type RuntimeHoldReason = RuntimeHoldReason;186	type RuntimeFreezeReason = RuntimeFreezeReason;187	type FreezeIdentifier = [u8; 16];188	type MaxFreezes = MaxFreezes;189}190191parameter_types! {192	/// This value increases the priority of `Operational` transactions by adding193	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.194	pub const OperationalFeeMultiplier: u8 = 5;195196	pub FeeMultiplier: Multiplier = Multiplier::one();197}198199impl pallet_transaction_payment::Config for Runtime {200	type RuntimeEvent = RuntimeEvent;201	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;202	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;203	type OperationalFeeMultiplier = OperationalFeeMultiplier;204	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;205	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;206}207208parameter_types! {209	pub const ProposalBond: Permill = Permill::from_percent(5);210	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;211	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;212	pub const SpendPeriod: BlockNumber = 5 * MINUTES;213	pub const Burn: Permill = Permill::from_percent(0);214	pub const TipCountdown: BlockNumber = 1 * DAYS;215	pub const TipFindersFee: Percent = Percent::from_percent(20);216	pub const TipReportDepositBase: Balance = 1 * UNIQUE;217	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;218	pub const BountyDepositBase: Balance = 1 * UNIQUE;219	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;220	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");221	pub TreasuryAccount: AccountId = Treasury::account_id();222	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;223	pub const MaximumReasonLength: u32 = 16384;224	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);225	pub const BountyValueMinimum: Balance = 5 * UNIQUE;226	pub const MaxApprovals: u32 = 100;227}228229impl pallet_treasury::Config for Runtime {230	type PalletId = TreasuryModuleId;231	type Currency = Balances;232	type ApproveOrigin = EnsureRoot<AccountId>;233	type RejectOrigin = EnsureRoot<AccountId>;234	type SpendOrigin = NeverEnsureOrigin<u128>;235	type RuntimeEvent = RuntimeEvent;236	type OnSlash = ();237	type ProposalBond = ProposalBond;238	type ProposalBondMinimum = ProposalBondMinimum;239	type ProposalBondMaximum = ProposalBondMaximum;240	type SpendPeriod = SpendPeriod;241	type Burn = Burn;242	type BurnDestination = ();243	type SpendFunds = ();244	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;245	type MaxApprovals = MaxApprovals;246	type AssetKind = ();247	type Beneficiary = AccountId;248	type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;249	type Paymaster = PayFromAccount<Balances, TreasuryAccount>;250	type BalanceConverter = UnityAssetBalanceConversion;251	type PayoutPeriod = ConstU32<10>;252	#[cfg(feature = "runtime-benchmarks")]253	type BenchmarkHelper = ();254}255256impl pallet_sudo::Config for Runtime {257	type RuntimeEvent = RuntimeEvent;258	type RuntimeCall = RuntimeCall;259	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;260}261262parameter_types! {263	pub const MaxAuthorities: u32 = 100_000;264}265266impl pallet_aura::Config for Runtime {267	type AuthorityId = AuraId;268	type DisabledValidators = ();269	type MaxAuthorities = MaxAuthorities;270	type AllowMultipleBlocksPerSlot = ConstBool<true>;271	#[cfg(feature = "lookahead")]272	type SlotDuration = ConstU64<SLOT_DURATION>;273}274275impl pallet_utility::Config for Runtime {276	type RuntimeEvent = RuntimeEvent;277	type RuntimeCall = RuntimeCall;278	type PalletsOrigin = OriginCaller;279	type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;280}
after · runtime/common/config/substrate.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	derive_impl,19	dispatch::DispatchClass,20	ord_parameter_types, parameter_types,21	traits::{22		tokens::{PayFromAccount, UnityAssetBalanceConversion},23		ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin,24	},25	weights::{26		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},27		ConstantMultiplier,28	},29	PalletId,30};31use frame_system::{32	limits::{BlockLength, BlockWeights},33	EnsureRoot, EnsureSignedBy,34};35use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};36use sp_arithmetic::traits::One;37use sp_runtime::{38	traits::{AccountIdLookup, BlakeTwo256, IdentityLookup},39	Perbill, Percent, Permill,40};41use sp_std::vec;42use up_common::{constants::*, types::*};4344use crate::{45	runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,46	RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, SS58Prefix,47	System, Treasury, Version,48};4950parameter_types! {51	pub const BlockHashCount: BlockNumber = 2400;52	pub RuntimeBlockLength: BlockLength =53		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);54	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);55	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;56	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()57		.base_block(BlockExecutionWeight::get())58		.for_class(DispatchClass::all(), |weights| {59			weights.base_extrinsic = ExtrinsicBaseWeight::get();60		})61		.for_class(DispatchClass::Normal, |weights| {62			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);63		})64		.for_class(DispatchClass::Operational, |weights| {65			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);66			// Operational transactions have some extra reserved space, so that they67			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.68			weights.reserved = Some(69				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT70			);71		})72		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)73		.build_or_panic();74}7576#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]77impl frame_system::Config for Runtime {78	/// The data to be stored in an account.79	type AccountData = pallet_balances::AccountData<Balance>;80	/// The identifier used to distinguish between accounts.81	type AccountId = AccountId;82	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).83	type BlockHashCount = BlockHashCount;84	/// The block type.85	type Block = Block;86	/// The maximum length of a block (in bytes).87	type BlockLength = RuntimeBlockLength;88	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.89	type BlockWeights = RuntimeBlockWeights;90	/// The weight of database operations that the runtime can invoke.91	type DbWeight = RocksDbWeight;92	/// The type for hashing blocks and tries.93	type Hash = Hash;94	/// The hashing algorithm used.95	type Hashing = BlakeTwo256;96	/// The index type for storing how many extrinsics an account has signed.97	type Nonce = Nonce;98	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.99	type Lookup = AccountIdLookup<AccountId, ()>;100	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;101	/// The ubiquitous origin type.102	type RuntimeOrigin = RuntimeOrigin;103	/// This type is being generated by `construct_runtime!`.104	type PalletInfo = PalletInfo;105	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.106	type SS58Prefix = SS58Prefix;107	/// Weight information for the extrinsics of this pallet.108	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;109	/// Version of the runtime.110	type Version = Version;111	type MaxConsumers = ConstU32<16>;112}113114parameter_types! {115	pub const MigrationMaxKeyLen: u32 = 512;116}117ord_parameter_types! {118	pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));119}120121impl pallet_state_trie_migration::Config for Runtime {122	type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;123	type RuntimeEvent = RuntimeEvent;124	type Currency = Balances;125	type SignedDepositPerItem = ();126	type SignedDepositBase = ();127	type ControlOrigin = EnsureRoot<AccountId>;128	// Only root can perform this migration129	type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;130	type MaxKeyLen = MigrationMaxKeyLen;131	type RuntimeHoldReason = RuntimeHoldReason;132}133134impl pallet_timestamp::Config for Runtime {135	/// A timestamp: milliseconds since the unix epoch.136	type Moment = u64;137	type OnTimestampSet = ();138	#[cfg(not(feature = "lookahead"))]139	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;140	#[cfg(feature = "lookahead")]141	type MinimumPeriod = ConstU64<0>;142	type WeightInfo = ();143}144145parameter_types! {146	// pub const ExistentialDeposit: u128 = 500;147	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;148	pub const MaxLocks: u32 = 50;149	pub const MaxReserves: u32 = 50;150	pub const MaxHolds: u32 = 10;151	pub const MaxFreezes: u32 = 10;152}153154impl pallet_balances::Config for Runtime {155	type MaxLocks = MaxLocks;156	type MaxReserves = MaxReserves;157	type ReserveIdentifier = [u8; 16];158	/// The type for recording an account's balance.159	type Balance = Balance;160	/// The ubiquitous event type.161	type RuntimeEvent = RuntimeEvent;162	// FIXME: Is () the new treasury?163	// Switch to real treasury once we start having dust removals164	// Related issue: https://github.com/paritytech/polkadot/issues/7323165	type DustRemoval = ();166	type ExistentialDeposit = ExistentialDeposit;167	type AccountStore = System;168	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;169	type RuntimeHoldReason = RuntimeHoldReason;170	type RuntimeFreezeReason = RuntimeFreezeReason;171	type FreezeIdentifier = [u8; 16];172	type MaxFreezes = MaxFreezes;173}174175parameter_types! {176	/// This value increases the priority of `Operational` transactions by adding177	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.178	pub const OperationalFeeMultiplier: u8 = 5;179180	pub FeeMultiplier: Multiplier = Multiplier::one();181}182183impl pallet_transaction_payment::Config for Runtime {184	type RuntimeEvent = RuntimeEvent;185	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;186	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;187	type OperationalFeeMultiplier = OperationalFeeMultiplier;188	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;189	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;190}191192parameter_types! {193	pub const ProposalBond: Permill = Permill::from_percent(5);194	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;195	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;196	pub const SpendPeriod: BlockNumber = 5 * MINUTES;197	pub const Burn: Permill = Permill::from_percent(0);198	pub const TipCountdown: BlockNumber = 1 * DAYS;199	pub const TipFindersFee: Percent = Percent::from_percent(20);200	pub const TipReportDepositBase: Balance = 1 * UNIQUE;201	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;202	pub const BountyDepositBase: Balance = 1 * UNIQUE;203	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;204	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");205	pub TreasuryAccount: AccountId = Treasury::account_id();206	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;207	pub const MaximumReasonLength: u32 = 16384;208	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);209	pub const BountyValueMinimum: Balance = 5 * UNIQUE;210	pub const MaxApprovals: u32 = 100;211}212213impl pallet_treasury::Config for Runtime {214	type PalletId = TreasuryModuleId;215	type Currency = Balances;216	type ApproveOrigin = EnsureRoot<AccountId>;217	type RejectOrigin = EnsureRoot<AccountId>;218	type SpendOrigin = NeverEnsureOrigin<u128>;219	type RuntimeEvent = RuntimeEvent;220	type OnSlash = ();221	type ProposalBond = ProposalBond;222	type ProposalBondMinimum = ProposalBondMinimum;223	type ProposalBondMaximum = ProposalBondMaximum;224	type SpendPeriod = SpendPeriod;225	type Burn = Burn;226	type BurnDestination = ();227	type SpendFunds = ();228	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;229	type MaxApprovals = MaxApprovals;230	type AssetKind = ();231	type Beneficiary = AccountId;232	type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;233	type Paymaster = PayFromAccount<Balances, TreasuryAccount>;234	type BalanceConverter = UnityAssetBalanceConversion;235	type PayoutPeriod = ConstU32<10>;236	#[cfg(feature = "runtime-benchmarks")]237	type BenchmarkHelper = ();238}239240impl pallet_sudo::Config for Runtime {241	type RuntimeEvent = RuntimeEvent;242	type RuntimeCall = RuntimeCall;243	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;244}245246parameter_types! {247	pub const MaxAuthorities: u32 = 100_000;248}249250impl pallet_aura::Config for Runtime {251	type AuthorityId = AuraId;252	type DisabledValidators = ();253	type MaxAuthorities = MaxAuthorities;254	type AllowMultipleBlocksPerSlot = ConstBool<true>;255	#[cfg(feature = "lookahead")]256	type SlotDuration = ConstU64<SLOT_DURATION>;257}258259impl pallet_utility::Config for Runtime {260	type RuntimeEvent = RuntimeEvent;261	type RuntimeCall = RuntimeCall;262	type PalletsOrigin = OriginCaller;263	type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;264}