git.delta.rocks / unique-network / refs/commits / 37e76bc01ac1

difftreelog

fix make runtime build on 0.9.42

Yaroslav Bolyukin2023-05-22parent: #6f7886b.patch.diff
in: master

11 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13701,6 +13701,7 @@
 dependencies = [
  "app-promotion-rpc",
  "fc-db",
+ "fc-mapping-sync",
  "fc-rpc",
  "fc-rpc-core",
  "fp-rpc",
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -4,7 +4,7 @@
 	traits::{FindAuthor},
 	parameter_types, ConsensusEngineId,
 };
-use sp_runtime::{RuntimeAppPublic, Perbill};
+use sp_runtime::{RuntimeAppPublic, Perbill, traits::ConstU32};
 use crate::{
 	runtime_common::{
 		config::sponsoring::DefaultSponsoringRateLimit,
@@ -84,6 +84,8 @@
 	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;
 	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
 	type FindAuthor = EthereumFindAuthor<Aura>;
+	type Timestamp = crate::Timestamp;
+	type WeightInfo = pallet_evm::weights::SubstrateWeight<Self>;
 }
 
 impl pallet_evm_migration::Config for Runtime {
@@ -99,6 +101,9 @@
 	type RuntimeEvent = RuntimeEvent;
 	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
 	type PostLogContent = PostBlockAndTxnHashes;
+	// Space for revert reason. Ethereum transactions are not cheap, and overall size is much less
+	// than the substrate tx size, so we can afford this
+	type ExtraDataLength = ConstU32<32>;
 }
 
 parameter_types! {
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	traits::{Everything, ConstU32, NeverEnsureOrigin},19	weights::{20		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21		ConstantMultiplier,22	},23	dispatch::DispatchClass,24	parameter_types, PalletId,25};26use sp_runtime::{27	generic,28	traits::{BlakeTwo256, AccountIdLookup},29	Perbill, Permill, Percent,30};31use sp_arithmetic::traits::One;32use frame_system::{33	limits::{BlockLength, BlockWeights},34	EnsureRoot,35};36use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};37use crate::{38	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, PalletInfo,39	System, Balances, Treasury, SS58Prefix, Version,40};41use up_common::{types::*, constants::*};4243parameter_types! {44	pub const BlockHashCount: BlockNumber = 2400;45	pub RuntimeBlockLength: BlockLength =46		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);47	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);48	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;49	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()50		.base_block(BlockExecutionWeight::get())51		.for_class(DispatchClass::all(), |weights| {52			weights.base_extrinsic = ExtrinsicBaseWeight::get();53		})54		.for_class(DispatchClass::Normal, |weights| {55			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);56		})57		.for_class(DispatchClass::Operational, |weights| {58			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);59			// Operational transactions have some extra reserved space, so that they60			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.61			weights.reserved = Some(62				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT63			);64		})65		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)66		.build_or_panic();67}6869impl frame_system::Config for Runtime {70	/// The data to be stored in an account.71	type AccountData = pallet_balances::AccountData<Balance>;72	/// The identifier used to distinguish between accounts.73	type AccountId = AccountId;74	/// The basic call filter to use in dispatchable.75	type BaseCallFilter = Everything;76	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).77	type BlockHashCount = BlockHashCount;78	/// The maximum length of a block (in bytes).79	type BlockLength = RuntimeBlockLength;80	/// The index type for blocks.81	type BlockNumber = BlockNumber;82	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.83	type BlockWeights = RuntimeBlockWeights;84	/// The aggregated dispatch type that is available for extrinsics.85	type RuntimeCall = RuntimeCall;86	/// The weight of database operations that the runtime can invoke.87	type DbWeight = RocksDbWeight;88	/// The ubiquitous event type.89	type RuntimeEvent = RuntimeEvent;90	/// The type for hashing blocks and tries.91	type Hash = Hash;92	/// The hashing algorithm used.93	type Hashing = BlakeTwo256;94	/// The header type.95	type Header = generic::Header<BlockNumber, BlakeTwo256>;96	/// The index type for storing how many extrinsics an account has signed.97	type Index = Index;98	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.99	type Lookup = AccountIdLookup<AccountId, ()>;100	/// What to do if an account is fully reaped from the system.101	type OnKilledAccount = ();102	/// What to do if a new account is created.103	type OnNewAccount = ();104	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;105	/// The ubiquitous origin type.106	type RuntimeOrigin = RuntimeOrigin;107	/// This type is being generated by `construct_runtime!`.108	type PalletInfo = PalletInfo;109	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.110	type SS58Prefix = SS58Prefix;111	/// Weight information for the extrinsics of this pallet.112	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;113	/// Version of the runtime.114	type Version = Version;115	type MaxConsumers = ConstU32<16>;116}117118parameter_types! {119	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;120}121122impl pallet_timestamp::Config for Runtime {123	/// A timestamp: milliseconds since the unix epoch.124	type Moment = u64;125	type OnTimestampSet = ();126	type MinimumPeriod = MinimumPeriod;127	type WeightInfo = ();128}129130parameter_types! {131	// pub const ExistentialDeposit: u128 = 500;132	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;133	pub const MaxLocks: u32 = 50;134	pub const MaxReserves: u32 = 50;135}136137impl pallet_balances::Config for Runtime {138	type MaxLocks = MaxLocks;139	type MaxReserves = MaxReserves;140	type ReserveIdentifier = [u8; 16];141	/// The type for recording an account's balance.142	type Balance = Balance;143	/// The ubiquitous event type.144	type RuntimeEvent = RuntimeEvent;145	type DustRemoval = Treasury;146	type ExistentialDeposit = ExistentialDeposit;147	type AccountStore = System;148	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;149}150151parameter_types! {152	/// This value increases the priority of `Operational` transactions by adding153	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.154	pub const OperationalFeeMultiplier: u8 = 5;155156	pub FeeMultiplier: Multiplier = Multiplier::one();157}158159impl pallet_transaction_payment::Config for Runtime {160	type RuntimeEvent = RuntimeEvent;161	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;162	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;163	type OperationalFeeMultiplier = OperationalFeeMultiplier;164	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;165	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;166}167168parameter_types! {169	pub const ProposalBond: Permill = Permill::from_percent(5);170	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;171	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;172	pub const SpendPeriod: BlockNumber = 5 * MINUTES;173	pub const Burn: Permill = Permill::from_percent(0);174	pub const TipCountdown: BlockNumber = 1 * DAYS;175	pub const TipFindersFee: Percent = Percent::from_percent(20);176	pub const TipReportDepositBase: Balance = 1 * UNIQUE;177	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;178	pub const BountyDepositBase: Balance = 1 * UNIQUE;179	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;180	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");181	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;182	pub const MaximumReasonLength: u32 = 16384;183	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);184	pub const BountyValueMinimum: Balance = 5 * UNIQUE;185	pub const MaxApprovals: u32 = 100;186}187188impl pallet_treasury::Config for Runtime {189	type PalletId = TreasuryModuleId;190	type Currency = Balances;191	type ApproveOrigin = EnsureRoot<AccountId>;192	type RejectOrigin = EnsureRoot<AccountId>;193	type SpendOrigin = NeverEnsureOrigin<u128>;194	type RuntimeEvent = RuntimeEvent;195	type OnSlash = ();196	type ProposalBond = ProposalBond;197	type ProposalBondMinimum = ProposalBondMinimum;198	type ProposalBondMaximum = ProposalBondMaximum;199	type SpendPeriod = SpendPeriod;200	type Burn = Burn;201	type BurnDestination = ();202	type SpendFunds = ();203	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;204	type MaxApprovals = MaxApprovals;205}206207impl pallet_sudo::Config for Runtime {208	type RuntimeEvent = RuntimeEvent;209	type RuntimeCall = RuntimeCall;210}211212parameter_types! {213	pub const MaxAuthorities: u32 = 100_000;214}215216impl pallet_aura::Config for Runtime {217	type AuthorityId = AuraId;218	type DisabledValidators = ();219	type MaxAuthorities = MaxAuthorities;220}
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	traits::{Everything, Nothing, Get, ConstU32},
+	traits::{Everything, Nothing, Get, ConstU32, ProcessMessageError},
 	parameter_types,
 };
 use frame_system::EnsureRoot;
@@ -114,26 +114,18 @@
 );
 
 pub trait TryPass {
-<<<<<<< HEAD
-	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()>;
-=======
 	fn try_pass<Call>(
 		origin: &MultiLocation,
 		message: &mut [Instruction<Call>],
 	) -> Result<(), ProcessMessageError>;
->>>>>>> fd33b0ac (fixup pallets)
 }
 
 #[impl_trait_for_tuples::impl_for_tuples(30)]
 impl TryPass for Tuple {
-<<<<<<< HEAD
-	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()> {
-=======
 	fn try_pass<Call>(
 		origin: &MultiLocation,
 		message: &mut [Instruction<Call>],
 	) -> Result<(), ProcessMessageError> {
->>>>>>> fd33b0ac (fixup pallets)
 		for_tuples!( #(
 			Tuple::try_pass(origin, message)?;
 		)* );
@@ -159,7 +151,7 @@
 		message: &mut [Instruction<Call>],
 		max_weight: Weight,
 		weight_credit: &mut Weight,
-	) -> Result<(), ()> {
+	) -> Result<(), ProcessMessageError> {
 		Deny::try_pass(origin, message)?;
 		Allow::should_execute(origin, message, max_weight, weight_credit)
 	}
@@ -227,6 +219,7 @@
 	type SovereignAccountOf = LocationToAccountId;
 	type MaxLockers = ConstU32<8>;
 	type WeightInfo = crate::weights::xcm::SubstrateWeight<Runtime>;
+	type AdminOrigin = EnsureRoot<AccountId>;
 	#[cfg(feature = "runtime-benchmarks")]
 	type ReachableDest = ReachableDest;
 }
modifiedruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/nativeassets.rs
+++ b/runtime/common/config/xcm/nativeassets.rs
@@ -102,7 +102,8 @@
 	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
 {
 	fn new() -> Self {
-		Self(0, Zero::zero(), PhantomData)
+		// FIXME: benchmark
+		Self(Weight::from_parts(0, 0), Zero::zero(), PhantomData)
 	}
 
 	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -35,7 +35,7 @@
     ) => {
         use sp_std::prelude::*;
         use sp_api::impl_runtime_apis;
-        use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160, Bytes};
+        use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};
         use sp_runtime::{
             Permill,
             traits::Block as BlockT,
@@ -250,6 +250,14 @@
                 fn metadata() -> OpaqueMetadata {
                     OpaqueMetadata::new(Runtime::metadata().into())
                 }
+
+                fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
+                    Runtime::metadata_at_version(version)
+                }
+
+                fn metadata_versions() -> sp_std::vec::Vec<u32> {
+                    Runtime::metadata_versions()
+                }
             }
 
             impl sp_block_builder::BlockBuilder<Block> for Runtime {
@@ -311,7 +319,7 @@
                 fn account_code_at(address: H160) -> Vec<u8> {
                     use pallet_evm::OnMethodCall;
                     <Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)
-                        .unwrap_or_else(|| EVM::account_codes(address))
+                        .unwrap_or_else(|| pallet_evm::AccountCodes::<Runtime>::get(address))
                 }
 
                 fn author() -> H160 {
@@ -321,7 +329,7 @@
                 fn storage_at(address: H160, index: U256) -> H256 {
                     let mut tmp = [0u8; 32];
                     index.to_big_endian(&mut tmp);
-                    EVM::account_storages(address, H256::from_slice(&tmp[..]))
+                    pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
                 }
 
                 #[allow(clippy::redundant_closure)]
@@ -401,15 +409,15 @@
                 }
 
                 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
-                    Ethereum::current_transaction_statuses()
+                    pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
                 }
 
                 fn current_block() -> Option<pallet_ethereum::Block> {
-                    Ethereum::current_block()
+                    pallet_ethereum::CurrentBlock::<Runtime>::get()
                 }
 
                 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
-                    Ethereum::current_receipts()
+                    pallet_ethereum::CurrentReceipts::<Runtime>::get()
                 }
 
                 fn current_all() -> (
@@ -418,9 +426,9 @@
                     Option<Vec<TransactionStatus>>
                 ) {
                     (
-                        Ethereum::current_block(),
-                        Ethereum::current_receipts(),
-                        Ethereum::current_transaction_statuses()
+                        pallet_ethereum::CurrentBlock::<Runtime>::get(),
+                        pallet_ethereum::CurrentReceipts::<Runtime>::get(),
+                        pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
                     )
                 }
 
@@ -653,12 +661,12 @@
 
             impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {
                 #[allow(unused_variables)]
-                fn pov_estimate(uxt: Bytes) -> ApplyExtrinsicResult {
+                fn pov_estimate(uxt: Vec<u8>) -> ApplyExtrinsicResult {
                     #[cfg(feature = "pov-estimate")]
                     {
                         use codec::Decode;
 
-                        let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &*uxt)
+                        let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &uxt)
                             .map_err(|_| DispatchError::Other("failed to decode the extrinsic"));
 
                         let uxt = match uxt_decode {
modifiedruntime/common/weights/xcm.rsdiffbeforeafterboth
--- a/runtime/common/weights/xcm.rs
+++ b/runtime/common/weights/xcm.rs
@@ -244,5 +244,9 @@
 			.saturating_add(T::DbWeight::get().reads(9_u64))
 			.saturating_add(T::DbWeight::get().writes(4_u64))
 	}
+
+	fn force_suspension() -> Weight {
+		Default::default()
+	}
 }
 
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -220,7 +220,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -212,7 +212,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -9,37 +9,37 @@
 refungible = []
 
 [dependencies]
-up-data-structs = { default-features = false, path = "../../primitives/data-structs" }
+up-data-structs = { workspace = true }
 
-sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+sp-core = { workspace = true }
+sp-io = { workspace = true }
+sp-runtime = { workspace = true }
+sp-std = { workspace = true }
 
-frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+frame-support = { workspace = true }
+frame-system = { workspace = true }
 
-pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
+pallet-timestamp = { workspace = true }
+pallet-transaction-payment = { workspace = true }
 
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
+pallet-ethereum = { workspace = true }
+pallet-evm = { workspace = true }
 
-pallet-common.path = "../../pallets/common"
-pallet-fungible.path = "../../pallets/fungible"
-pallet-nonfungible.path = "../../pallets/nonfungible"
-pallet-refungible.path = "../../pallets/refungible"
-pallet-structure.path = "../../pallets/structure"
-pallet-unique.path = "../../pallets/unique"
+pallet-common = { workspace = true }
+pallet-fungible = { workspace = true }
+pallet-nonfungible = { workspace = true }
+pallet-refungible = { workspace = true }
+pallet-structure = { workspace = true }
+pallet-unique = { workspace = true }
 
-pallet-evm-coder-substrate.path = "../../pallets/evm-coder-substrate"
+pallet-evm-coder-substrate = { workspace = true }
 
-parity-scale-codec = { version = "3.2.2", default-features = false, features = ["derive"] }
-scale-info = "*"
+codec = { workspace = true }
+scale-info = { workspace = true }
 
 evm-coder = { workspace = true }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.42" }
+up-sponsorship = { workspace = true }
 xcm = { workspace = true }
 pallet-xcm = { workspace = true }
 pallet-configuration = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -211,7 +211,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }