Weight v1.5: Opaque Struct (#12138)

* initial idea

* update frame_support

* update a bunch more

* add ord

* adjust RuntimeDbWeight

* frame_system builds

* re-export

* frame_support tests pass

* frame_executive compile

* frame_executive builds

* frame_system tests passing

* pallet-utility tests pass

* fix a bunch of pallets

* more

* phragmen

* state-trie-migration

* scheduler and referenda

* pallet-election-provider-multi-phase

* aura

* staking

* more

* babe

* balances

* bunch more

* sudo

* transaction-payment

* asset-tx-payment

* last pallets

* fix alliance merge

* fix node template runtime

* fix pallet-contracts cc @athei

* fix node runtime

* fix compile on runtime-benchmarks feature

* comment

* fix frame-support-test

* fix more tests

* weight regex

* frame system works

* fix a bunch

* more

* more

* more

* more

* more

* more fixes

* update templates

* fix contracts benchmarks

* Update lib.rs

* Update lib.rs

* fix ui

* make scalar saturating mul const

* more const functions

* scalar div

* refactor using constant functions

* move impl

* fix overhead template

* use compactas

* Update lib.rs
This commit is contained in:
Shawn Tabrizi
2022-08-31 12:26:13 +01:00
committed by GitHub
parent 299f4ba541
commit 30951822ba
187 changed files with 5932 additions and 4930 deletions
@@ -54,10 +54,10 @@ pub mod pallet {
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
if TypeId::of::<I>() == TypeId::of::<()>() {
Self::deposit_event(Event::Something(10));
10
Weight::from_ref_time(10)
} else {
Self::deposit_event(Event::Something(11));
11
Weight::from_ref_time(11)
}
}
fn on_finalize(_: BlockNumberFor<T>) {
@@ -70,10 +70,10 @@ pub mod pallet {
fn on_runtime_upgrade() -> Weight {
if TypeId::of::<I>() == TypeId::of::<()>() {
Self::deposit_event(Event::Something(30));
30
Weight::from_ref_time(30)
} else {
Self::deposit_event(Event::Something(31));
31
Weight::from_ref_time(31)
}
}
fn integrity_test() {}
@@ -82,7 +82,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Doc comment put in metadata
#[pallet::weight(Weight::from(*_foo))]
#[pallet::weight(Weight::from_ref_time(*_foo as u64))]
pub fn foo(
origin: OriginFor<T>,
#[pallet::compact] _foo: u32,
@@ -345,12 +345,18 @@ frame_support::construct_runtime!(
}
);
use frame_support::weights::Weight;
#[test]
fn call_expand() {
let call_foo = pallet::Call::<Runtime>::foo { foo: 3 };
assert_eq!(
call_foo.get_dispatch_info(),
DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }
DispatchInfo {
weight: Weight::from_ref_time(3),
class: DispatchClass::Normal,
pays_fee: Pays::Yes
}
);
assert_eq!(call_foo.get_call_name(), "foo");
assert_eq!(pallet::Call::<Runtime>::get_call_names(), &["foo", "foo_storage_layer"]);
@@ -358,7 +364,11 @@ fn call_expand() {
let call_foo = pallet::Call::<Runtime, pallet::Instance1>::foo { foo: 3 };
assert_eq!(
call_foo.get_dispatch_info(),
DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }
DispatchInfo {
weight: Weight::from_ref_time(3),
class: DispatchClass::Normal,
pays_fee: Pays::Yes
}
);
assert_eq!(call_foo.get_call_name(), "foo");
assert_eq!(
@@ -651,10 +661,10 @@ fn pallet_hooks_expand() {
TestExternalities::default().execute_with(|| {
frame_system::Pallet::<Runtime>::set_block_number(1);
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), 21);
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_ref_time(21));
AllPalletsWithoutSystem::on_finalize(1);
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), 61);
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_ref_time(61));
assert_eq!(
frame_system::Pallet::<Runtime>::events()[0].event,