Skip to content

Commit

Permalink
Merge branch 'open-web3-stack:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwangningbo authored May 14, 2024
2 parents 4f7a5ad + f2fc5ee commit 03149f2
Show file tree
Hide file tree
Showing 46 changed files with 342 additions and 181 deletions.
60 changes: 30 additions & 30 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
serde = { version = "1.0.189" }
parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] }

cumulus-pallet-xcm = { version = "0.8.0", default-features = false }
cumulus-primitives-core = { version = "0.8.0", default-features = false }
frame-benchmarking = { version = "29.0.0", default-features = false }
frame-support = { version = "29.0.0", default-features = false }
frame-system = { version = "29.0.0", default-features = false }
pallet-balances = { version = "29.0.0", default-features = false }
pallet-elections-phragmen = { version = "30.0.0", default-features = false }
pallet-message-queue = { version = "32.0.0", default-features = false }
pallet-preimage = { version = "29.0.0", default-features = false }
pallet-root-testing = { version = "5.0.0", default-features = false }
pallet-scheduler = { version = "30.0.0", default-features = false }
pallet-timestamp = { version = "28.0.0", default-features = false }
pallet-treasury = { version = "28.0.0", default-features = false }
pallet-xcm = { version = "8.0.0", default-features = false }
polkadot-parachain-primitives = { version = "7.0.0", default-features = false }
polkadot-runtime-common = { version = "8.0.0", default-features = false }
polkadot-runtime-parachains = { version = "8.0.0", default-features = false }
sp-api = { version = "27.0.0", default-features = false }
sp-application-crypto = { version = "31.0.0", default-features = false }
sp-arithmetic = { version = "24.0.0", default-features = false }
sp-core = { version = "29.0.0", default-features = false }
sp-io = { version = "31.0.0", default-features = false }
sp-runtime = { version = "32.0.0", default-features = false }
sp-runtime-interface = { version = "25.0.0", default-features = false }
sp-staking = { version = "27.0.0", default-features = false }
cumulus-pallet-xcm = { version = "0.11.0", default-features = false }
cumulus-primitives-core = { version = "0.11.0", default-features = false }
frame-benchmarking = { version = "32.0.0", default-features = false }
frame-support = { version = "32.0.0", default-features = false }
frame-system = { version = "32.0.0", default-features = false }
pallet-balances = { version = "33.0.0", default-features = false }
pallet-elections-phragmen = { version = "33.0.0", default-features = false }
pallet-message-queue = { version = "35.0.0", default-features = false }
pallet-preimage = { version = "32.0.0", default-features = false }
pallet-root-testing = { version = "8.0.0", default-features = false }
pallet-scheduler = { version = "33.0.0", default-features = false }
pallet-timestamp = { version = "31.0.0", default-features = false }
pallet-treasury = { version = "31.0.0", default-features = false }
pallet-xcm = { version = "11.0.0", default-features = false }
polkadot-parachain-primitives = { version = "10.0.0", default-features = false }
polkadot-runtime-common = { version = "11.0.0", default-features = false }
polkadot-runtime-parachains = { version = "11.0.0", default-features = false }
sp-api = { version = "30.0.0", default-features = false }
sp-application-crypto = { version = "34.0.0", default-features = false }
sp-arithmetic = { version = "26.0.0", default-features = false }
sp-core = { version = "32.0.0", default-features = false }
sp-io = { version = "34.0.0", default-features = false }
sp-runtime = { version = "35.0.0", default-features = false }
sp-runtime-interface = { version = "27.0.0", default-features = false }
sp-staking = { version = "30.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "20.0.0", default-features = false }
xcm = { package = "staging-xcm", version = "8.0.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", version = "8.0.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", version = "8.0.0", default-features = false }
sp-storage = { version = "21.0.0", default-features = false }
xcm = { version = "11.0.0", package = "staging-xcm", default-features = false }
xcm-builder = { version = "11.0.0", package = "staging-xcm-builder", default-features = false }
xcm-executor = { version = "11.0.0", package = "staging-xcm-executor", default-features = false }

xcm-simulator = { version = "8.0.0" }
xcm-simulator = { version = "11.0.0" }
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ benchmark-all:
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_tokens --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./tokens/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_vesting --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./vesting/src/weights.rs --template ../templates/orml-weight-template.hbs

release: Cargo.toml
cargo release --execute
4 changes: 2 additions & 2 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "orml-asset-registry"
description = "Registry for (foreign) assets"
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/asset-registry"
license = "Apache-2.0"
version = "0.8.0"
version = "0.10.0"
authors = ["Interlay Ltd, etc"]
edition = "2021"

Expand All @@ -27,7 +27,7 @@ xcm-builder = { workspace = true }
xcm-executor = { workspace = true }

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

# for runtime-benchmarks
polkadot-runtime-common = { workspace = true, optional = true }
Expand Down
3 changes: 3 additions & 0 deletions asset-registry/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = ();
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
}

impl cumulus_pallet_xcm::Config for Runtime {
Expand Down
4 changes: 4 additions & 0 deletions asset-registry/src/mock/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = ();
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
}

pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, KusamaNetwork>;
Expand Down Expand Up @@ -187,6 +190,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = ();
type QueuePausedQuery = ();
type WeightInfo = ();
type IdleMaxServiceWeight = ();
}

construct_runtime!(
Expand Down
4 changes: 2 additions & 2 deletions auction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "orml-auction"
description = "Auction module that implements `Auction` trait."
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction"
license = "Apache-2.0"
version = "0.8.0"
version = "0.10.0"
authors = ["Acala Developers"]
edition = "2021"

Expand All @@ -17,7 +17,7 @@ frame-system = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

orml-traits = { path = "../traits", version = "0.8.0", default-features = false }
orml-traits = { path = "../traits", version = "0.10.0", default-features = false }

[dev-dependencies]
sp-core = { workspace = true, features = ["std"] }
Expand Down
2 changes: 1 addition & 1 deletion authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "orml-authority"
description = "Utility pallet to perform ROOT calls in a PoA network"
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction"
license = "Apache-2.0"
version = "0.8.0"
version = "0.10.0"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
49 changes: 27 additions & 22 deletions authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@ use frame_support::{
dispatch::{DispatchClass, GetDispatchInfo, Pays},
pallet_prelude::*,
traits::{
schedule::{v1::Named as ScheduleNamed, DispatchTime, Priority},
EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait,
schedule::{DispatchTime, Priority},
Bounded, EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait,
},
};
use frame_system::{pallet_prelude::*, EnsureRoot, EnsureSigned};
use parity_scale_codec::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_core::defer;
use sp_io::hashing::blake2_256;
use sp_runtime::{
traits::{CheckedSub, Dispatchable, Hash, Saturating},
ArithmeticError, DispatchError, DispatchResult, Either, RuntimeDebug,
};
use sp_std::prelude::*;

use frame_support::traits::schedule::v3::Named as ScheduleNamed;

mod mock;
mod tests;
mod weights;
Expand Down Expand Up @@ -72,7 +75,9 @@ mod helper {
use std::cell::RefCell;

thread_local! {
static NESTED_MAX_ENCODED_LEN: RefCell<bool> = RefCell::new(false);
static NESTED_MAX_ENCODED_LEN: RefCell<bool> = const {
RefCell::new(false)
};
}

pub fn set_nested_max_encoded_len(val: bool) {
Expand Down Expand Up @@ -195,6 +200,7 @@ pub mod module {
#[pallet::origin]
pub type Origin<T> = DelayedOrigin<BlockNumberFor<T>, <T as Config>::PalletsOrigin>;
pub(crate) type CallOf<T> = <T as Config>::RuntimeCall;
pub(crate) type BoundedCallOf<T> = Bounded<CallOf<T>, <T as frame_system::Config>::Hashing>;

#[pallet::config]
pub trait Config: frame_system::Config {
Expand All @@ -215,7 +221,12 @@ pub mod module {
+ GetDispatchInfo;

/// The Scheduler.
type Scheduler: ScheduleNamed<BlockNumberFor<Self>, <Self as Config>::RuntimeCall, Self::PalletsOrigin>;
type Scheduler: ScheduleNamed<
BlockNumberFor<Self>,
<Self as Config>::RuntimeCall,
Self::PalletsOrigin,
Hasher = Self::Hashing,
>;

/// The type represent origin that can be dispatched by other origins.
type AsOriginId: Parameter + AsOriginId<<Self as frame_system::Config>::RuntimeOrigin, Self::PalletsOrigin>;
Expand Down Expand Up @@ -330,7 +341,7 @@ pub mod module {
when: DispatchTime<BlockNumberFor<T>>,
priority: Priority,
with_delayed_origin: bool,
call: Box<CallOf<T>>,
call: Box<BoundedCallOf<T>>,
) -> DispatchResult {
T::AuthorityConfig::check_schedule_dispatch(origin.clone(), priority)?;

Expand All @@ -357,15 +368,9 @@ pub mod module {
};
let pallets_origin = schedule_origin.caller().clone();

T::Scheduler::schedule_named(
Encode::encode(&(&pallets_origin, id)),
when,
None,
priority,
pallets_origin.clone(),
*call,
)
.map_err(|_| Error::<T>::FailedToSchedule)?;
let task_name = (&pallets_origin, id).using_encoded(blake2_256);
T::Scheduler::schedule_named(task_name, when, None, priority, pallets_origin.clone(), *call)
.map_err(|_| Error::<T>::FailedToSchedule)?;

Self::deposit_event(Event::Scheduled {
origin: pallets_origin,
Expand Down Expand Up @@ -394,8 +399,8 @@ pub mod module {
};

T::AuthorityConfig::check_fast_track_schedule(origin, &initial_origin, new_delay)?;
T::Scheduler::reschedule_named((&initial_origin, task_id).encode(), when)
.map_err(|_| Error::<T>::FailedToFastTrack)?;
let task_name = (&initial_origin, task_id).using_encoded(blake2_256);
T::Scheduler::reschedule_named(task_name, when).map_err(|_| Error::<T>::FailedToFastTrack)?;

Self::deposit_event(Event::FastTracked {
origin: *initial_origin,
Expand All @@ -416,11 +421,9 @@ pub mod module {
) -> DispatchResult {
T::AuthorityConfig::check_delay_schedule(origin, &initial_origin)?;

T::Scheduler::reschedule_named(
(&initial_origin, task_id).encode(),
DispatchTime::After(additional_delay),
)
.map_err(|_| Error::<T>::FailedToDelay)?;
let task_name = (&initial_origin, task_id).using_encoded(blake2_256);
T::Scheduler::reschedule_named(task_name, DispatchTime::After(additional_delay))
.map_err(|_| Error::<T>::FailedToDelay)?;

let now = frame_system::Pallet::<T>::block_number();
let dispatch_at = now.saturating_add(additional_delay);
Expand All @@ -442,7 +445,9 @@ pub mod module {
task_id: ScheduleTaskIndex,
) -> DispatchResult {
T::AuthorityConfig::check_cancel_schedule(origin, &initial_origin)?;
T::Scheduler::cancel_named((&initial_origin, task_id).encode()).map_err(|_| Error::<T>::FailedToCancel)?;

let task_name = (&initial_origin, task_id).using_encoded(blake2_256);
T::Scheduler::cancel_named(task_name).map_err(|_| Error::<T>::FailedToCancel)?;

Self::deposit_event(Event::Cancelled {
origin: *initial_origin,
Expand Down
30 changes: 15 additions & 15 deletions authority/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use super::*;
use frame_support::{
assert_noop, assert_ok,
dispatch::DispatchErrorWithPostInfo,
traits::{schedule::DispatchTime, OriginTrait},
traits::{schedule::DispatchTime, OriginTrait, StorePreimage},
};
use frame_system::RawOrigin;
use mock::{
authority, run_to_block, Authority, BlockNumber, ExtBuilder, MockAsOriginId, OriginCaller, Runtime, RuntimeCall,
RuntimeOrigin, System,
authority, run_to_block, Authority, BlockNumber, ExtBuilder, MockAsOriginId, OriginCaller, Preimage, Runtime,
RuntimeCall, RuntimeOrigin, System,
};
use parity_scale_codec::MaxEncodedLen;
use sp_io::hashing::blake2_256;
Expand Down Expand Up @@ -74,7 +74,7 @@ fn schedule_dispatch_at_work() {
DispatchTime::At(1),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
),
Error::<Runtime>::FailedToSchedule
);
Expand All @@ -84,7 +84,7 @@ fn schedule_dispatch_at_work() {
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::Authority(DelayedOrigin {
Expand All @@ -109,7 +109,7 @@ fn schedule_dispatch_at_work() {
DispatchTime::At(3),
0,
false,
Box::new(call)
Box::new(Preimage::bound(call).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::system(RawOrigin::Root),
Expand Down Expand Up @@ -144,7 +144,7 @@ fn schedule_dispatch_after_work() {
DispatchTime::At(0),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
),
ArithmeticError::Overflow
);
Expand All @@ -154,7 +154,7 @@ fn schedule_dispatch_after_work() {
DispatchTime::After(0),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::Authority(DelayedOrigin {
Expand All @@ -179,7 +179,7 @@ fn schedule_dispatch_after_work() {
DispatchTime::After(0),
0,
false,
Box::new(call)
Box::new(Preimage::bound(call).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::system(RawOrigin::Root),
Expand Down Expand Up @@ -214,7 +214,7 @@ fn fast_track_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::Authority(DelayedOrigin {
Expand Down Expand Up @@ -255,7 +255,7 @@ fn fast_track_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
false,
Box::new(call)
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::system(RawOrigin::Root),
Expand Down Expand Up @@ -293,7 +293,7 @@ fn delay_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::Authority(DelayedOrigin {
Expand Down Expand Up @@ -334,7 +334,7 @@ fn delay_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
false,
Box::new(call)
Box::new(Preimage::bound(call).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::system(RawOrigin::Root),
Expand Down Expand Up @@ -371,7 +371,7 @@ fn cancel_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
Box::new(Preimage::bound(call.clone()).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::Authority(DelayedOrigin {
Expand Down Expand Up @@ -410,7 +410,7 @@ fn cancel_scheduled_dispatch_work() {
DispatchTime::At(2),
0,
false,
Box::new(call)
Box::new(Preimage::bound(call).unwrap())
));
System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled {
origin: OriginCaller::system(RawOrigin::Root),
Expand Down
Loading

0 comments on commit 03149f2

Please sign in to comment.