mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
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:
@@ -205,8 +205,7 @@ pub mod pallet {
|
||||
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::weight(1)]
|
||||
#[frame_support::transactional]
|
||||
pub fn foo_transactional(
|
||||
pub fn foo_storage_layer(
|
||||
_origin: OriginFor<T>,
|
||||
#[pallet::compact] foo: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
@@ -373,7 +372,7 @@ pub mod pallet {
|
||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
let _ = T::AccountId::from(SomeType1); // Test for where clause
|
||||
let _ = T::AccountId::from(SomeType5); // Test for where clause
|
||||
if matches!(call, Call::foo_transactional { .. }) {
|
||||
if matches!(call, Call::foo_storage_layer { .. }) {
|
||||
return Ok(ValidTransaction::default())
|
||||
}
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
|
||||
@@ -611,13 +610,13 @@ fn transactional_works() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
frame_system::Pallet::<Runtime>::set_block_number(1);
|
||||
|
||||
pallet::Call::<Runtime>::foo_transactional { foo: 0 }
|
||||
pallet::Call::<Runtime>::foo_storage_layer { foo: 0 }
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.err()
|
||||
.unwrap();
|
||||
assert!(frame_system::Pallet::<Runtime>::events().is_empty());
|
||||
|
||||
pallet::Call::<Runtime>::foo_transactional { foo: 1 }
|
||||
pallet::Call::<Runtime>::foo_storage_layer { foo: 1 }
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
@@ -640,7 +639,7 @@ fn call_expand() {
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
pallet::Call::<Runtime>::get_call_names(),
|
||||
&["foo", "foo_transactional", "foo_no_post_info"],
|
||||
&["foo", "foo_storage_layer", "foo_no_post_info"],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -744,7 +743,7 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional { foo: 0 }),
|
||||
function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }),
|
||||
signature: None,
|
||||
}],
|
||||
);
|
||||
@@ -785,7 +784,7 @@ fn inherent_expand() {
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional { foo: 0 }),
|
||||
function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
@@ -807,7 +806,7 @@ fn inherent_expand() {
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional { foo: 0 }),
|
||||
function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
@@ -857,7 +856,7 @@ fn validate_unsigned_expand() {
|
||||
let validity = pallet::Pallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err();
|
||||
assert_eq!(validity, TransactionValidityError::Invalid(InvalidTransaction::Call));
|
||||
|
||||
let call = pallet::Call::<Runtime>::foo_transactional { foo: 0 };
|
||||
let call = pallet::Call::<Runtime>::foo_storage_layer { foo: 0 };
|
||||
|
||||
let validity = pallet::Pallet::validate_unsigned(TransactionSource::External, &call).unwrap();
|
||||
assert_eq!(validity, ValidTransaction::default());
|
||||
|
||||
Reference in New Issue
Block a user