mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
pallet-multisig: Improve opaque call handling (#10060)
* pallet-multisig: Improve opaque call handling Before the opaque call was just a type redefinition of `Vec<u8>`. With metadata v14 that was breaking external tools, as they stopped looking at the type name. To improve the situation the `WrapperKeepOpaque` type is introduced that communicates to the outside the correct type info. * Cleanup * Fix benchmarks * FMT
This commit is contained in:
@@ -29,7 +29,10 @@ use crate::Pallet as Multisig;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
fn setup_multi<T: Config>(s: u32, z: u32) -> Result<(Vec<T::AccountId>, Vec<u8>), &'static str> {
|
||||
fn setup_multi<T: Config>(
|
||||
s: u32,
|
||||
z: u32,
|
||||
) -> Result<(Vec<T::AccountId>, OpaqueCall<T>), &'static str> {
|
||||
let mut signatories: Vec<T::AccountId> = Vec::new();
|
||||
for i in 0..s {
|
||||
let signatory = account("signatory", i, SEED);
|
||||
@@ -42,7 +45,7 @@ fn setup_multi<T: Config>(s: u32, z: u32) -> Result<(Vec<T::AccountId>, Vec<u8>)
|
||||
// Must first convert to outer call type.
|
||||
let call: <T as Config>::Call =
|
||||
frame_system::Call::<T>::remark { remark: vec![0; z as usize] }.into();
|
||||
let call_data = call.encode();
|
||||
let call_data = OpaqueCall::<T>::from_encoded(call.encode());
|
||||
return Ok((signatories, call_data))
|
||||
}
|
||||
|
||||
@@ -72,7 +75,7 @@ benchmarks! {
|
||||
// Transaction Length
|
||||
let z in 0 .. 10_000;
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
// Whitelist caller account from further DB operations.
|
||||
@@ -90,7 +93,7 @@ benchmarks! {
|
||||
// Transaction Length
|
||||
let z in 0 .. 10_000;
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
@@ -109,7 +112,7 @@ benchmarks! {
|
||||
// Transaction Length
|
||||
let z in 0 .. 10_000;
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let mut signatories2 = signatories.clone();
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
@@ -134,7 +137,7 @@ benchmarks! {
|
||||
// Transaction Length
|
||||
let z in 0 .. 10_000;
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let mut signatories2 = signatories.clone();
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
@@ -160,7 +163,7 @@ benchmarks! {
|
||||
// Transaction Length
|
||||
let z in 0 .. 10_000;
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let mut signatories2 = signatories.clone();
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
@@ -193,7 +196,7 @@ benchmarks! {
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
// Whitelist caller account from further DB operations.
|
||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||
@@ -212,7 +215,7 @@ benchmarks! {
|
||||
let mut signatories2 = signatories.clone();
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
// before the call, get the timepoint
|
||||
let timepoint = Multisig::<T>::timepoint();
|
||||
// Create the multi
|
||||
@@ -245,7 +248,7 @@ benchmarks! {
|
||||
let mut signatories2 = signatories.clone();
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
// before the call, get the timepoint
|
||||
let timepoint = Multisig::<T>::timepoint();
|
||||
// Create the multi
|
||||
@@ -282,7 +285,7 @@ benchmarks! {
|
||||
let (mut signatories, call) = setup_multi::<T>(s, z)?;
|
||||
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
|
||||
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
|
||||
let call_hash = blake2_256(&call);
|
||||
let call_hash = blake2_256(&call.encoded());
|
||||
let timepoint = Multisig::<T>::timepoint();
|
||||
// Create the multi
|
||||
let o = RawOrigin::Signed(caller.clone()).into();
|
||||
|
||||
Reference in New Issue
Block a user