Skip to content

Commit

Permalink
Merge branch 'sv-upgrade-from-2_0-to-3_0' of https://github.com/svyat…
Browse files Browse the repository at this point in the history
…onik/runtimes into sv-upgrade-from-2_0-to-3_0
  • Loading branch information
svyatonik committed Nov 23, 2023
2 parents 587937e + 8970c33 commit 3b003d4
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Implemented GenesisBuilder API for all runtimes ([polkadot-fellows/runtimes#87](https://github.com/polkadot-fellows/runtimes/pull/87)). Context: https://github.com/paritytech/polkadot-sdk/pull/1492
- XCM transport fees are now exponential and are sent to a treasury account ([polkadot-fellows/runtimes#87](https://github.com/polkadot-fellows/runtimes/pull/87)). Context: https://github.com/paritytech/polkadot-sdk/pull/1234
- System parachains are now trusted teleporters of each other ([polkadot-fellows/runtimes#87](https://github.com/polkadot-fellows/runtimes/pull/87)). Context: https://github.com/paritytech/polkadot-sdk/pull/1368
- Treasury spends various asset kinds ([polkadot-fellows/runtimes#87](https://github.com/polkadot-fellows/runtimes/pull/87))

### Fixed

Expand Down
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.

4 changes: 4 additions & 0 deletions relay/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tx-pool-api = { package = "sp-transaction-pool", default-features = false , vers
block-builder-api = { package = "sp-block-builder", default-features = false , version = "23.0.0" }
sp-npos-elections = { default-features = false , version = "23.0.0" }

pallet-asset-rate = { default-features = false , version = "4.0.0" }
pallet-authority-discovery = { default-features = false , version = "25.0.0" }
pallet-authorship = { default-features = false , version = "25.0.0" }
pallet-babe = { default-features = false , version = "25.0.0" }
Expand Down Expand Up @@ -150,6 +151,7 @@ std = [
"kusama-runtime-constants/std",
"log/std",
"offchain-primitives/std",
"pallet-asset-rate/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
"pallet-babe/std",
Expand Down Expand Up @@ -236,6 +238,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand Down Expand Up @@ -294,6 +297,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime",
"frame-try-runtime/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
Expand Down
47 changes: 19 additions & 28 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
Keccak256, OpaqueKeys, SaturatedConversion, Verify,
IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
Expand Down Expand Up @@ -763,28 +763,6 @@ parameter_types! {
pub const MaxPeerInHeartbeats: u32 = 10_000;
}

#[cfg(not(feature = "runtime-benchmarks"))]
mod disable_new_treasury_functionality {
use super::*;

/// Temporary workaround that disables new functionality from
/// https://github.com/paritytech/polkadot-sdk/pull/1333
pub struct NeverLookup;

impl sp_runtime::traits::StaticLookup for NeverLookup {
type Source = VersionedMultiLocation;
type Target = VersionedMultiLocation;

fn lookup(_s: Self::Source) -> Result<Self::Target, frame_support::error::LookupError> {
Err(frame_support::error::LookupError)
}

fn unlookup(t: Self::Target) -> Self::Source {
t
}
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -804,10 +782,7 @@ impl pallet_treasury::Config for Runtime {
type SpendOrigin = TreasurySpender;
type AssetKind = VersionedLocatableAsset;
type Beneficiary = VersionedMultiLocation;
#[cfg(not(feature = "runtime-benchmarks"))]
type BeneficiaryLookup = disable_new_treasury_functionality::NeverLookup;
#[cfg(feature = "runtime-benchmarks")]
type BeneficiaryLookup = sp_runtime::traits::IdentityLookup<Self::Beneficiary>;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayOverXcm<
TreasuryInteriorLocation,
crate::xcm_config::XcmRouter,
Expand All @@ -818,7 +793,7 @@ impl pallet_treasury::Config for Runtime {
LocatableAssetConverter,
VersionedMultiLocationConverter,
>;
type BalanceConverter = frame_support::traits::tokens::UnityAssetBalanceConversion;
type BalanceConverter = AssetRate;
type PayoutPeriod = PayoutSpendPeriod;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::benchmarks::TreasuryArguments;
Expand Down Expand Up @@ -1553,6 +1528,18 @@ impl pallet_state_trie_migration::Config for Runtime {
type MaxKeyLen = MigrationMaxKeyLen;
}

impl pallet_asset_rate::Config for Runtime {
type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type CreateOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RemoveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type UpdateOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type Currency = Balances;
type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments;
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1683,6 +1670,9 @@ construct_runtime! {

// Generalized message queue
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 100,

// Asset rate.
AssetRate: pallet_asset_rate::{Pallet, Call, Storage, Event<T>} = 101,
}
}

Expand Down Expand Up @@ -1901,6 +1891,7 @@ mod benches {
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_whitelist, Whitelist]
[pallet_asset_rate, AssetRate]
// XCM
[pallet_xcm, XcmPallet]
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
Expand Down
1 change: 1 addition & 0 deletions relay/kusama/src/weights/mod.rs

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

86 changes: 86 additions & 0 deletions relay/kusama/src/weights/pallet_asset_rate.rs

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

6 changes: 5 additions & 1 deletion relay/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sp-storage = { default-features = false , version = "17.0.0" }
sp-version = { default-features = false , version = "26.0.0" }
sp-npos-elections = { default-features = false , version = "23.0.0" }

pallet-asset-rate = { default-features = false , version = "4.0.0" }
pallet-authority-discovery = { default-features = false , version = "25.0.0" }
pallet-authorship = { default-features = false , version = "25.0.0" }
pallet-babe = { default-features = false , version = "25.0.0" }
Expand Down Expand Up @@ -140,6 +141,7 @@ std = [
"inherents/std",
"log/std",
"offchain-primitives/std",
"pallet-asset-rate/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
"pallet-babe/std",
Expand Down Expand Up @@ -172,8 +174,8 @@ std = [
"pallet-scheduler/std",
"pallet-session-benchmarking?/std",
"pallet-session/std",
"pallet-staking-runtime-api/std",
"pallet-staking-reward-fn/std",
"pallet-staking-runtime-api/std",
"pallet-staking/std",
"pallet-timestamp/std",
"pallet-tips/std",
Expand Down Expand Up @@ -220,6 +222,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-asset-rate/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand Down Expand Up @@ -272,6 +275,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime",
"frame-try-runtime/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
Expand Down
47 changes: 19 additions & 28 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use sp_runtime::{
generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, Verify,
IdentityLookup, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
Expand Down Expand Up @@ -728,28 +728,6 @@ parameter_types! {
pub const CouncilSpendOriginMaxAmount: Balance = Balance::MAX;
}

#[cfg(not(feature = "runtime-benchmarks"))]
mod disable_new_treasury_functionality {
use super::*;

/// Temporary workaround that disables new functionality from
/// https://github.com/paritytech/polkadot-sdk/pull/1333
pub struct NeverLookup;

impl sp_runtime::traits::StaticLookup for NeverLookup {
type Source = VersionedMultiLocation;
type Target = VersionedMultiLocation;

fn lookup(_s: Self::Source) -> Result<Self::Target, frame_support::error::LookupError> {
Err(frame_support::error::LookupError)
}

fn unlookup(t: Self::Target) -> Self::Source {
t
}
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -769,10 +747,7 @@ impl pallet_treasury::Config for Runtime {
type SpendOrigin = TreasurySpender;
type AssetKind = VersionedLocatableAsset;
type Beneficiary = VersionedMultiLocation;
#[cfg(not(feature = "runtime-benchmarks"))]
type BeneficiaryLookup = disable_new_treasury_functionality::NeverLookup;
#[cfg(feature = "runtime-benchmarks")]
type BeneficiaryLookup = sp_runtime::traits::IdentityLookup<Self::Beneficiary>;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayOverXcm<
TreasuryInteriorLocation,
crate::xcm_config::XcmRouter,
Expand All @@ -783,7 +758,7 @@ impl pallet_treasury::Config for Runtime {
LocatableAssetConverter,
VersionedMultiLocationConverter,
>;
type BalanceConverter = frame_support::traits::tokens::UnityAssetBalanceConversion;
type BalanceConverter = AssetRate;
type PayoutPeriod = PayoutSpendPeriod;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::benchmarks::TreasuryArguments;
Expand Down Expand Up @@ -1438,6 +1413,18 @@ impl frame_support::traits::OnRuntimeUpgrade for InitiateNominationPools {
}
}

impl pallet_asset_rate::Config for Runtime {
type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type CreateOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RemoveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type UpdateOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type Currency = Balances;
type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments;
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1533,6 +1520,9 @@ construct_runtime! {

// Generalized message queue
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 100,

// Asset rate.
AssetRate: pallet_asset_rate::{Pallet, Call, Storage, Event<T>} = 101,
}
}

Expand Down Expand Up @@ -1728,6 +1718,7 @@ mod benches {
[pallet_conviction_voting, ConvictionVoting]
[pallet_referenda, Referenda]
[pallet_whitelist, Whitelist]
[pallet_asset_rate, AssetRate]
// XCM
[pallet_xcm, XcmPallet]
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
Expand Down
1 change: 1 addition & 0 deletions relay/polkadot/src/weights/mod.rs

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

Loading

0 comments on commit 3b003d4

Please sign in to comment.