Storage Layer for All FRAME Extrinsics (#11431)

* add new trait

* implement DispatchableWithStorageLayer

* at least one transactional

* all dispatch is at least transactional

* storage_layer api

* add test

* storage layer tests

* deprecate transactional tag

* i guess no reason to deprecate

* remove transactional from batch_all

* update tests

* extend trait

* cargo run --quiet --profile=production --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --profile=production --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --profile=production --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fix copy paste name

* cargo run --quiet --profile=production --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_utility --extrinsic=* --execution=wasm --wasm-execution=compiled --output=./frame/utility/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Create run_all_benchmarks.sh

* uncomment build

* update number of steps and repeats

* add skip build

* Update run_all_benchmarks.sh

* Update run_all_benchmarks.sh

* new benchmarks

* Update frame/support/src/traits/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/support/src/traits/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/support/test/tests/storage_layers.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/support/test/tests/storage_layers.rs

* weights

* Update dispatch.rs

* doc link

* decl_macro support

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Shawn Tabrizi
2022-05-26 15:28:32 -04:00
committed by GitHub
parent ea469886f8
commit 8e7adaf283
52 changed files with 1741 additions and 1355 deletions
-2
View File
@@ -60,7 +60,6 @@ use codec::{Decode, Encode};
use frame_support::{
dispatch::PostDispatchInfo,
traits::{IsSubType, OriginTrait, UnfilteredDispatchable},
transactional,
weights::{extract_actual_weight, GetDispatchInfo},
};
use sp_core::TypeId;
@@ -316,7 +315,6 @@ pub mod pallet {
};
(dispatch_weight, dispatch_class)
})]
#[transactional]
pub fn batch_all(
origin: OriginFor<T>,
calls: Vec<<T as Config>::Call>,
+4 -4
View File
@@ -471,11 +471,11 @@ fn batch_all_revert() {
assert_eq!(Balances::free_balance(1), 10);
assert_eq!(Balances::free_balance(2), 10);
let batch_all_calls = Call::Utility(crate::Call::<Test>::batch_all {
calls: vec![call_transfer(2, 5), call_transfer(2, 10), call_transfer(2, 5)],
});
assert_noop!(
Utility::batch_all(
Origin::signed(1),
vec![call_transfer(2, 5), call_transfer(2, 10), call_transfer(2, 5),]
),
batch_all_calls.dispatch(Origin::signed(1)),
DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(
+19 -19
View File
@@ -18,7 +18,7 @@
//! Autogenerated weights for pallet_utility
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-05-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2022-05-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
@@ -55,49 +55,49 @@ pub trait WeightInfo {
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn batch(c: u32, ) -> Weight {
(14_744_000 as Weight)
(20_307_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_549_000 as Weight).saturating_mul(c as Weight))
.saturating_add((2_701_000 as Weight).saturating_mul(c as Weight))
}
fn as_derivative() -> Weight {
(1_412_000 as Weight)
(4_082_000 as Weight)
}
fn batch_all(c: u32, ) -> Weight {
(20_835_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_704_000 as Weight).saturating_mul(c as Weight))
(3_087_000 as Weight)
// Standard Error: 2_000
.saturating_add((2_842_000 as Weight).saturating_mul(c as Weight))
}
fn dispatch_as() -> Weight {
(8_889_000 as Weight)
(11_832_000 as Weight)
}
fn force_batch(c: u32, ) -> Weight {
(13_155_000 as Weight)
(19_750_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_555_000 as Weight).saturating_mul(c as Weight))
.saturating_add((2_715_000 as Weight).saturating_mul(c as Weight))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
fn batch(c: u32, ) -> Weight {
(14_744_000 as Weight)
(20_307_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_549_000 as Weight).saturating_mul(c as Weight))
.saturating_add((2_701_000 as Weight).saturating_mul(c as Weight))
}
fn as_derivative() -> Weight {
(1_412_000 as Weight)
(4_082_000 as Weight)
}
fn batch_all(c: u32, ) -> Weight {
(20_835_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_704_000 as Weight).saturating_mul(c as Weight))
(3_087_000 as Weight)
// Standard Error: 2_000
.saturating_add((2_842_000 as Weight).saturating_mul(c as Weight))
}
fn dispatch_as() -> Weight {
(8_889_000 as Weight)
(11_832_000 as Weight)
}
fn force_batch(c: u32, ) -> Weight {
(13_155_000 as Weight)
(19_750_000 as Weight)
// Standard Error: 1_000
.saturating_add((2_555_000 as Weight).saturating_mul(c as Weight))
.saturating_add((2_715_000 as Weight).saturating_mul(c as Weight))
}
}