Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade polkadot-v0.9.31 #830

Merged
merged 4 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 65 additions & 65 deletions Cargo.dev.toml

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ serde = { version = "1.0.136", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] }

# substrate
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }

# polkadot
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.30" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.30" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.30" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.30" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.31" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.31" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.31" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.31" }

# orml
orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false }

[dev-dependencies]
# substrate
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }

# cumulus
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31" }

# polkadot
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31" }

# orml
orml-tokens = { path = "../tokens" }
Expand Down
11 changes: 4 additions & 7 deletions asset-registry/src/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
},
_ => None,
};
currency_id.or_else(|| AssetRegistry::location_to_asset_id(&l).map(|id| CurrencyId::RegisteredAsset(id)))
currency_id.or_else(|| AssetRegistry::location_to_asset_id(&l).map(CurrencyId::RegisteredAsset))
}
}
impl Convert<MultiAsset, Option<CurrencyId>> for CurrencyIdConvert {
Expand Down Expand Up @@ -208,12 +208,9 @@ pub fn para_ext(para_id: u32, asset_data: Option<(Vec<(u32, Vec<u8>)>, u32)>) ->
.unwrap();

if let Some((assets, last_asset_id)) = asset_data {
GenesisConfig::<Runtime> {
assets: assets,
last_asset_id: last_asset_id,
}
.assimilate_storage(&mut t)
.unwrap();
GenesisConfig::<Runtime> { assets, last_asset_id }
.assimilate_storage(&mut t)
.unwrap();
}

let mut ext = TestExternalities::new(t);
Expand Down
16 changes: 4 additions & 12 deletions asset-registry/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ fn test_register_duplicate_location_returns_error() {
None
));
let register_asset = RuntimeCall::AssetRegistry(crate::Call::<para::Runtime>::register_asset {
metadata: metadata.clone(),
metadata,
asset_id: None,
});
assert_noop!(
Expand Down Expand Up @@ -446,7 +446,7 @@ fn test_update_metadata_works() {
Some(new_metadata.additional.clone())
));

let old_location: MultiLocation = old_metadata.location.clone().unwrap().try_into().unwrap();
let old_location: MultiLocation = old_metadata.location.unwrap().try_into().unwrap();
let new_location: MultiLocation = new_metadata.location.clone().unwrap().try_into().unwrap();

// check that the old location was removed and the new one added
Expand All @@ -463,11 +463,7 @@ fn test_update_metadata_fails_with_unknown_asset() {

ParaA::execute_with(|| {
let old_metadata = dummy_metadata();
assert_ok!(AssetRegistry::register_asset(
RuntimeOrigin::root(),
old_metadata.clone(),
None
));
assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), old_metadata, None));

assert_noop!(
AssetRegistry::update_asset(RuntimeOrigin::root(), 4, None, None, None, None, None, None,),
Expand Down Expand Up @@ -518,11 +514,7 @@ fn test_asset_authority() {
let metadata = dummy_metadata();

// Assert that root can register an asset with id 1
assert_ok!(AssetRegistry::register_asset(
RuntimeOrigin::root(),
metadata.clone(),
Some(1)
));
assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), metadata, Some(1)));

// Assert that only Account42 can register asset with id 42
let metadata = AssetMetadata {
Expand Down
12 changes: 6 additions & 6 deletions auction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive"
serde = { version = "1.0.136", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }

sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }

orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }

[features]
default = ["std"]
Expand Down
20 changes: 11 additions & 9 deletions authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ edition = "2021"

[dependencies]
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", optional = true }
serde = { version = "1.0.145", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }

sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.30" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" }

[dev-dependencies]
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }

[features]
default = ["std"]
Expand All @@ -31,6 +32,7 @@ std = [
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"frame-support/std",
"frame-system/std",
]
Expand Down
36 changes: 34 additions & 2 deletions authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ use frame_support::{
dispatch::{DispatchClass, GetDispatchInfo, Pays},
pallet_prelude::*,
traits::{
schedule::{DispatchTime, Named as ScheduleNamed, Priority},
schedule::{v1::Named as ScheduleNamed, DispatchTime, Priority},
EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait,
},
weights::OldWeight,
};
use frame_system::{pallet_prelude::*, EnsureRoot, EnsureSigned};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -413,14 +414,45 @@ pub mod module {
})
}

#[pallet::weight((
T::WeightInfo::trigger_call().saturating_add((*call_weight_bound).into()),
DispatchClass::Operational,
))]
#[allow(deprecated)]
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to `trigger_call`")]
pub fn trigger_old_call(
origin: OriginFor<T>,
hash: T::Hash,
#[pallet::compact] call_weight_bound: OldWeight,
) -> DispatchResultWithPostInfo {
let call_weight_bound: Weight = call_weight_bound.into();
let who = ensure_signed(origin)?;
SavedCalls::<T>::try_mutate_exists(hash, |maybe_call| {
let (call, maybe_caller) = maybe_call.take().ok_or(Error::<T>::CallNotAuthorized)?;
if let Some(caller) = maybe_caller {
ensure!(who == caller, Error::<T>::TriggerCallNotPermitted);
}
ensure!(
call_weight_bound.ref_time() >= call.get_dispatch_info().weight.ref_time(),
Error::<T>::WrongCallWeightBound
);
let result = call.dispatch(OriginFor::<T>::root());
Self::deposit_event(Event::TriggeredCallBy { hash, caller: who });
Self::deposit_event(Event::Dispatched {
result: result.map(|_| ()).map_err(|e| e.error),
});
Ok(Pays::No.into())
})
}

#[pallet::weight((
T::WeightInfo::trigger_call().saturating_add(*call_weight_bound),
DispatchClass::Operational,
))]
pub fn trigger_call(
origin: OriginFor<T>,
hash: T::Hash,
#[pallet::compact] call_weight_bound: Weight,
call_weight_bound: Weight,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
SavedCalls::<T>::try_mutate_exists(hash, |maybe_call| {
Expand Down
21 changes: 14 additions & 7 deletions authority/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub type BlockNumber = u64;

parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(2_000_000_000_000));
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(2_000_000_000_000).set_proof_size(u64::MAX));
}

impl frame_system::Config for Runtime {
Expand All @@ -39,7 +39,7 @@ impl frame_system::Config for Runtime {
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockWeights = BlockWeights;
type BlockLength = ();
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -54,10 +54,17 @@ impl frame_system::Config for Runtime {
type MaxConsumers = ConstU32<16>;
}

impl pallet_preimage::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type Currency = ();
type ManagerOrigin = EnsureRoot<u128>;
type BaseDeposit = ();
type ByteDeposit = ();
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
// Retry a scheduled item every 10 blocks (1 minute) until the preimage exists.
pub const NoPreimagePostponement: Option<u64> = Some(10);
}
impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -66,11 +73,10 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<u128>;
type MaxScheduledPerBlock = ();
type MaxScheduledPerBlock = ConstU32<10>;
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PreimageProvider = ();
type NoPreimagePostponement = NoPreimagePostponement;
type Preimages = Preimage;
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)]
Expand Down Expand Up @@ -175,6 +181,7 @@ frame_support::construct_runtime!(
System: frame_system::{Pallet, Call, Config, Event<T>},
Authority: authority::{Pallet, Call, Origin<T>, Event<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down
Loading