From 0bf104ef5807be0dc034a92021daffefb762736e Mon Sep 17 00:00:00 2001 From: vobradovich Date: Tue, 20 Aug 2024 13:12:10 +0200 Subject: [PATCH 01/22] remove voucher call_deprecated --- gsdk/src/metadata/generated.rs | 9 - pallets/gear-voucher/src/internal.rs | 26 --- pallets/gear-voucher/src/lib.rs | 30 +-- pallets/gear-voucher/src/tests.rs | 49 ----- pallets/payment/src/tests.rs | 293 --------------------------- 5 files changed, 1 insertion(+), 406 deletions(-) diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index e32efdd40d5..7e7813a3618 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -3058,13 +3058,6 @@ pub mod runtime_types { code_uploading: ::core::option::Option<::core::primitive::bool>, prolong_duration: ::core::option::Option<::core::primitive::u32>, }, - #[codec(index = 4)] - #[doc = "See [`Pallet::call_deprecated`]."] - call_deprecated { - call: runtime_types::pallet_gear_voucher::internal::PrepaidCall< - ::core::primitive::u128, - >, - }, #[codec(index = 5)] #[doc = "See [`Pallet::decline`]."] decline { @@ -8259,7 +8252,6 @@ pub mod calls { Call, Revoke, Update, - CallDeprecated, Decline, } impl CallInfo for GearVoucherCall { @@ -8270,7 +8262,6 @@ pub mod calls { Self::Call => "call", Self::Revoke => "revoke", Self::Update => "update", - Self::CallDeprecated => "call_deprecated", Self::Decline => "decline", } } diff --git a/pallets/gear-voucher/src/internal.rs b/pallets/gear-voucher/src/internal.rs index acfbf3ecc0e..1623fa4a63c 100644 --- a/pallets/gear-voucher/src/internal.rs +++ b/pallets/gear-voucher/src/internal.rs @@ -42,11 +42,6 @@ where /// determined destination; /// * For codes uploading: The voucher allows code uploading. /// - /// * Call is [`Self::call_deprecated`]: - /// * For messaging calls: The destination program of the given prepaid - /// call can be determined. - /// * For codes uploading: NEVER. - /// /// Returns [`None`] for other cases. pub fn get_sponsor(&self, caller: AccountIdOf) -> Option> { match self { @@ -57,11 +52,6 @@ where .map(|_| (*voucher_id).cast()) .ok(), - #[allow(deprecated)] - Self::call_deprecated { call: prepaid_call } => { - Pallet::::call_deprecated_sponsor(&caller, prepaid_call) - } - _ => None, } } @@ -84,22 +74,6 @@ impl Pallet { Ok(voucher) } - /// Return the account id of a synthetical account used to sponsor gas - /// and transaction fee for legacy vouchers implementation. - #[deprecated = "Legacy voucher issuing logic is deprecated, and this and \ - `call_deprecated` extrinsic exist only for backward support"] - pub fn call_deprecated_sponsor( - who: &T::AccountId, - call: &PrepaidCall>, - ) -> Option { - #[allow(deprecated)] - Self::prepaid_call_destination(who, call).map(|program_id| { - let entropy = (b"modlpy/voucher__", who, program_id).using_encoded(blake2_256); - Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) - .expect("infinite length input; no invalid inputs for type; qed") - }) - } - /// Validate prepaid call with related params of voucher: origin, expiration. pub fn validate_prepaid( origin: AccountIdOf, diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index 8bc08ea0cef..54f116594a1 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -57,8 +57,6 @@ use frame_support::{ }; use gear_core::ids::{MessageId, ProgramId}; pub use primitive_types::H256; -use sp_io::hashing::blake2_256; -use sp_runtime::traits::TrailingZeroInput; use sp_std::{convert::TryInto, vec::Vec}; pub use weights::WeightInfo; @@ -557,33 +555,7 @@ pub mod pallet { Ok(().into()) } - /// Legacy call for using irrevocable vouchers. - #[pallet::call_index(4)] - #[pallet::weight(T::CallsDispatcher::weight(call).saturating_add(T::DbWeight::get().reads(1)))] - pub fn call_deprecated( - origin: OriginFor, - call: PrepaidCall>, - ) -> DispatchResultWithPostInfo { - // Ensuring origin. - let origin = ensure_signed(origin)?; - - // Validating the call for legacy implementation. - match call { - PrepaidCall::UploadCode { .. } => { - return Err(Error::::CodeUploadingDisabled.into()) - } - PrepaidCall::DeclineVoucher => return Err(Error::::InexistentVoucher.into()), - PrepaidCall::SendMessage { .. } | PrepaidCall::SendReply { .. } => (), - }; - - // Looking for sponsor synthetic account. - #[allow(deprecated)] - let sponsor = Self::call_deprecated_sponsor(&origin, &call) - .ok_or(Error::::UnknownDestination)?; - - // Dispatching call. - T::CallsDispatcher::dispatch(origin, sponsor.clone(), sponsor.cast(), call) - } + /// Legacy call with call_index(4) removed /// Decline existing and not expired voucher. /// diff --git a/pallets/gear-voucher/src/tests.rs b/pallets/gear-voucher/src/tests.rs index b15aee3c469..b7453b20921 100644 --- a/pallets/gear-voucher/src/tests.rs +++ b/pallets/gear-voucher/src/tests.rs @@ -141,31 +141,6 @@ fn voucher_call_works() { }, )); - // Always ok, because legacy call doesn't access vouchers storage - // and just proxies payment to specific synthetic account. - assert_ok!(Voucher::call_deprecated( - RuntimeOrigin::signed(ALICE), - PrepaidCall::SendMessage { - destination: H256::random().cast(), - payload: vec![], - gas_limit: 0, - value: 0, - keep_alive: false - } - )); - - // Ok, if message exists in mailbox. - assert_ok!(Voucher::call_deprecated( - RuntimeOrigin::signed(ALICE), - PrepaidCall::SendReply { - reply_to_id: MAILBOXED_MESSAGE, - payload: vec![], - gas_limit: 0, - value: 0, - keep_alive: false - }, - )); - // Checking case of any program. assert_ok!(Voucher::issue( RuntimeOrigin::signed(ALICE), @@ -336,30 +311,6 @@ fn voucher_call_err_cases() { ), Error::::VoucherExpired ); - - // Message doesn't exist in mailbox. - assert_noop!( - Voucher::call_deprecated( - RuntimeOrigin::signed(BOB), - PrepaidCall::SendReply { - reply_to_id: H256::random().cast(), - payload: vec![], - gas_limit: 0, - value: 0, - keep_alive: false - }, - ), - Error::::UnknownDestination - ); - - // Code uploading is always forbidden for `call_deprecated`. - assert_noop!( - Voucher::call_deprecated( - RuntimeOrigin::signed(BOB), - PrepaidCall::UploadCode { code: vec![] }, - ), - Error::::CodeUploadingDisabled - ); }) } diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index 3d00febb256..d3e87c0a061 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -919,86 +919,6 @@ fn voucher_call_send_payer_expiry_err() { }); } -#[test] -fn voucher_call_deprecated_send_payer_ok() { - new_test_ext().execute_with(|| { - // Snapshot of the initial data. - let bob_initial_balance = Balances::free_balance(BOB); - let validator_initial_balance = Balances::free_balance(BLOCK_AUTHOR); - let voucher_initial_balance = 1_000_000_000; - let program_id = H256::random().cast(); - - // Mocking of legacy voucher issue. - #[allow(deprecated)] - let voucher_account_id = - GearVoucher::call_deprecated_sponsor(&BOB, &prepaid_send(program_id)) - .expect("Shouldn't return None"); - - assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(ALICE), - voucher_account_id, - voucher_initial_balance, - )); - - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - ); - - // Creating a RuntimeCall (deprecated) that should be free for caller. - let call = voucher_call_deprecated_send(program_id); - - // Creating simulation of weight params for call to calculate fee. - let len = 100usize; - let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); - - let weight = Weight::from_parts(1_000, 0); - let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); - - let call_fee = fee_length + fee_weight; - - // Pre-dispatch of the call. - let pre = CustomChargeTransactionPayment::::from(0) - .pre_dispatch(&BOB, &call, &info_from_weight(weight), len) - .unwrap(); - - // Bob hasn't paid fees. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance); - - // But the voucher has. - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - call_fee, - ); - - // Validator hasn't received fee yet. - assert_eq!( - Balances::free_balance(BLOCK_AUTHOR), - validator_initial_balance - ); - - // Post-dispatch of the call. - assert_ok!(CustomChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(weight), - &default_post_info(), - len, - &Ok(()) - )); - - // Validating balances and validator reward. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance); - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - call_fee, - ); - assert_eq!( - Balances::free_balance(BLOCK_AUTHOR), - validator_initial_balance + call_fee, - ); - }); -} - #[test] fn voucher_call_reply_payer_ok() { new_test_ext().execute_with(|| { @@ -1092,133 +1012,6 @@ fn voucher_call_reply_payer_ok() { }); } -#[test] -fn voucher_call_deprecated_reply_payer_ok() { - new_test_ext().execute_with(|| { - // Snapshot of the initial data. - let bob_initial_balance = Balances::free_balance(BOB); - let validator_initial_balance = Balances::free_balance(BLOCK_AUTHOR); - let voucher_initial_balance = 1_000_000_000; - let program_id = H256::random().cast(); - let reply_to_id = H256::random().cast(); - - // Inserting message into Bob-s mailbox. - assert_ok!(MailboxOf::::insert( - UserStoredMessage::new( - reply_to_id, - program_id, - BOB.cast(), - Default::default(), - Default::default(), - ), - 1_000, - )); - - // Mocking of legacy voucher issue. - #[allow(deprecated)] - let voucher_account_id = - GearVoucher::call_deprecated_sponsor(&BOB, &prepaid_reply(reply_to_id)) - .expect("Shouldn't return None"); - - assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(ALICE), - voucher_account_id, - voucher_initial_balance, - )); - - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - ); - - // Creating a RuntimeCall (deprecated) that should be free for caller. - let call = voucher_call_deprecated_reply(reply_to_id); - - // Creating simulation of weight params for call to calculate fee. - let len = 100usize; - let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); - - let weight = Weight::from_parts(1_000, 0); - let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); - - let call_fee = fee_length + fee_weight; - - // Pre-dispatch of the call. - let pre = CustomChargeTransactionPayment::::from(0) - .pre_dispatch(&BOB, &call, &info_from_weight(weight), len) - .unwrap(); - - // Bob hasn't paid fees. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance); - - // But the voucher has. - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - call_fee, - ); - - // Validator hasn't received fee yet. - assert_eq!( - Balances::free_balance(BLOCK_AUTHOR), - validator_initial_balance - ); - - // Post-dispatch of the call. - assert_ok!(CustomChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(weight), - &default_post_info(), - len, - &Ok(()) - )); - - // Validating balances and validator reward. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance); - assert_eq!( - Balances::free_balance(voucher_account_id), - voucher_initial_balance - call_fee, - ); - assert_eq!( - Balances::free_balance(BLOCK_AUTHOR), - validator_initial_balance + call_fee, - ); - }); -} - -#[test] -fn voucher_call_deprecated_reply_payer_err() { - new_test_ext().execute_with(|| { - // Snapshot of the initial data. - let bob_initial_balance = Balances::free_balance(BOB); - let reply_to_id = H256::random().cast(); - - // Creating a RuntimeCall (deprecated) that should not be free for caller. - let call = voucher_call_deprecated_reply(reply_to_id); - - // Creating simulation of weight params for call to calculate fee. - let len = 1usize; - let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); - - let weight = Weight::from_parts(1, 0); - let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); - - let call_fee = fee_length + fee_weight; - - // Pre-dispatch of the call. - assert_ok!( - CustomChargeTransactionPayment::::from(0).pre_dispatch( - &BOB, - &call, - &info_from_weight(weight), - len - ) - ); - - // Bob has paid fees due to lack of destination for the call. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance - call_fee); - }); -} - #[test] fn voucher_call_upload_payer_ok() { new_test_ext().execute_with(|| { @@ -1355,39 +1148,6 @@ fn voucher_call_upload_payer_forbidden_err() { }); } -#[test] -fn voucher_call_deprecated_upload_payer_err() { - new_test_ext().execute_with(|| { - // Snapshot of the initial data. - let bob_initial_balance = Balances::free_balance(BOB); - - // Creating a RuntimeCall (deprecated) that should not be free for caller. - let call = voucher_call_deprecated_upload(vec![]); - - // Creating simulation of weight params for call to calculate fee. - let len = 1usize; - let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); - - let weight = Weight::from_parts(1, 0); - let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); - - let call_fee = fee_length + fee_weight; - - // Pre-dispatch of the call. - assert_ok!( - CustomChargeTransactionPayment::::from(0).pre_dispatch( - &BOB, - &call, - &info_from_weight(weight), - len - ) - ); - - // Bob has paid fees due forbid for the code uploading in call_deprecated. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance - call_fee); - }); -} - #[test] fn voucher_call_decline_payer_ok() { new_test_ext().execute_with(|| { @@ -1532,41 +1292,6 @@ fn voucher_call_decline_payer_expired_err() { }); } -#[test] -fn voucher_call_deprecated_decline_payer_err() { - new_test_ext().execute_with(|| { - // Snapshot of the initial data. - let bob_initial_balance = Balances::free_balance(BOB); - - // Creating a RuntimeCall (deprecated) that should not be free for caller. - let call = RuntimeCall::GearVoucher(VoucherCall::call_deprecated { - call: PrepaidCall::DeclineVoucher, - }); - - // Creating simulation of weight params for call to calculate fee. - let len = 1usize; - let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); - - let weight = Weight::from_parts(1, 0); - let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); - - let call_fee = fee_length + fee_weight; - - // Pre-dispatch of the call. - assert_ok!( - CustomChargeTransactionPayment::::from(0).pre_dispatch( - &BOB, - &call, - &info_from_weight(weight), - len - ) - ); - - // Bob has paid fees due forbid for the code uploading in call_deprecated. - assert_eq!(Balances::free_balance(BOB), bob_initial_balance - call_fee); - }); -} - mod utils { use super::*; use crate::BalanceOf; @@ -1585,12 +1310,6 @@ mod utils { }) } - pub fn voucher_call_deprecated_send(destination: ProgramId) -> RuntimeCall { - RuntimeCall::GearVoucher(VoucherCall::call_deprecated { - call: prepaid_send(destination), - }) - } - pub fn voucher_call_reply(voucher_id: VoucherId, reply_to_id: MessageId) -> RuntimeCall { RuntimeCall::GearVoucher(VoucherCall::call { voucher_id, @@ -1598,12 +1317,6 @@ mod utils { }) } - pub fn voucher_call_deprecated_reply(reply_to_id: MessageId) -> RuntimeCall { - RuntimeCall::GearVoucher(VoucherCall::call_deprecated { - call: prepaid_reply(reply_to_id), - }) - } - pub fn voucher_call_upload(voucher_id: VoucherId, code: Vec) -> RuntimeCall { RuntimeCall::GearVoucher(VoucherCall::call { voucher_id, @@ -1611,12 +1324,6 @@ mod utils { }) } - pub fn voucher_call_deprecated_upload(code: Vec) -> RuntimeCall { - RuntimeCall::GearVoucher(VoucherCall::call_deprecated { - call: PrepaidCall::UploadCode { code }, - }) - } - pub fn prepaid_send(destination: ProgramId) -> PrepaidCall> { PrepaidCall::SendMessage { destination, From 8d7d19e750d25a16156a4f86d54a549d0e1c9d6b Mon Sep 17 00:00:00 2001 From: vobradovich Date: Tue, 20 Aug 2024 16:59:46 +0200 Subject: [PATCH 02/22] wip: vocuher create program --- pallets/gear-voucher/src/internal.rs | 22 +++++++- pallets/gear-voucher/src/lib.rs | 20 +++++++- pallets/gear-voucher/src/mock.rs | 1 + pallets/gear-voucher/src/tests.rs | 9 +++- pallets/gear/src/lib.rs | 76 +++++++++++++++++++++++----- pallets/gear/src/mock.rs | 1 + pallets/gear/src/tests.rs | 2 + pallets/payment/src/mock.rs | 1 + pallets/payment/src/tests.rs | 10 ++++ runtime/vara/src/lib.rs | 1 + 10 files changed, 125 insertions(+), 18 deletions(-) diff --git a/pallets/gear-voucher/src/internal.rs b/pallets/gear-voucher/src/internal.rs index 1623fa4a63c..b068e761e26 100644 --- a/pallets/gear-voucher/src/internal.rs +++ b/pallets/gear-voucher/src/internal.rs @@ -22,7 +22,7 @@ use common::{ Origin, }; use frame_system::pallet_prelude::BlockNumberFor; -use gear_core::ids; +use gear_core::ids::{self, CodeId, MessageId, ProgramId}; use sp_std::collections::btree_set::BTreeSet; impl crate::Call @@ -98,6 +98,11 @@ impl Pallet { ); } } + PrepaidCall::CreateProgram { code_id, .. } => { + if let Some(code_ids) = voucher.code_ids { + ensure!(code_ids.contains(code_id), Error::::InappropriateCodeId); + } + } } Ok(()) @@ -113,7 +118,9 @@ impl Pallet { PrepaidCall::SendReply { reply_to_id, .. } => { T::Mailbox::peek(who, reply_to_id).map(|stored_message| stored_message.source()) } - PrepaidCall::UploadCode { .. } | PrepaidCall::DeclineVoucher => None, + PrepaidCall::UploadCode { .. } + | PrepaidCall::DeclineVoucher + | PrepaidCall::CreateProgram { .. } => None, } } } @@ -191,6 +198,9 @@ pub struct VoucherInfo { /// The block number at and after which voucher couldn't be used and /// can be revoked by owner. pub expiry: BlockNumber, + /// Set of CodeId this voucher could be used to create program. + /// In case of [`None`] means any uploaded code. + pub code_ids: Option>, } impl VoucherInfo { @@ -222,4 +232,12 @@ pub enum PrepaidCall { code: Vec, }, DeclineVoucher, + CreateProgram { + code_id: CodeId, + salt: Vec, + payload: Vec, + gas_limit: u64, + value: Balance, + keep_alive: bool, + }, } diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index 54f116594a1..06d1b640bfb 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -55,7 +55,7 @@ use frame_support::{ traits::{Currency, ExistenceRequirement, ReservableCurrency, StorageVersion}, PalletId, }; -use gear_core::ids::{MessageId, ProgramId}; +use gear_core::ids::{CodeId, MessageId, ProgramId}; pub use primitive_types::H256; use sp_std::{convert::TryInto, vec::Vec}; pub use weights::WeightInfo; @@ -120,6 +120,10 @@ pub mod pallet { /// Maximal duration in blocks voucher could be issued/prolonged for. #[pallet::constant] type MaxDuration: Get>; + + /// Maximal amount of programs to be specified to interact with. + #[pallet::constant] + type MaxCodeIdsAmount: Get; } #[pallet::pallet] @@ -195,6 +199,10 @@ pub mod pallet { CodeUploadingEnabled, /// Voucher is disabled for code uploading, but requested. CodeUploadingDisabled, + /// CodeId is not in whitelisted set for voucher. + InappropriateCodeId, + /// Try to whitelist more CodeId than allowed. + MaxCodeIdsLimitExceeded, } /// Storage containing amount of the total vouchers issued. @@ -252,6 +260,7 @@ pub mod pallet { programs: Option>, code_uploading: bool, duration: BlockNumberFor, + code_ids: Option>, ) -> DispatchResultWithPostInfo { // Ensuring origin. let owner = ensure_signed(origin)?; @@ -270,6 +279,14 @@ pub mod pallet { ) } + // Asserting amount of code_ids. + if let Some(ref code_ids) = code_ids { + ensure!( + code_ids.len() <= T::MaxCodeIdsAmount::get().saturated_into(), + Error::::MaxCodeIdsLimitExceeded + ) + } + // Creating voucher id. let voucher_id = VoucherId::generate::(); @@ -293,6 +310,7 @@ pub mod pallet { programs, code_uploading, expiry, + code_ids, }; // Inserting voucher data into storage, associated with spender and voucher ids. diff --git a/pallets/gear-voucher/src/mock.rs b/pallets/gear-voucher/src/mock.rs index 332db6502e4..805502b13cc 100644 --- a/pallets/gear-voucher/src/mock.rs +++ b/pallets/gear-voucher/src/mock.rs @@ -142,6 +142,7 @@ impl pallet_gear_voucher::Config for Test { type MaxProgramsAmount = ConstU8<3>; type MaxDuration = MaxVoucherDuration; type MinDuration = MinVoucherDuration; + type MaxCodeIdsAmount = ConstU8<3>; } // Build genesis storage according to the mock runtime. diff --git a/pallets/gear-voucher/src/tests.rs b/pallets/gear-voucher/src/tests.rs index b7453b20921..c3647cdcab1 100644 --- a/pallets/gear-voucher/src/tests.rs +++ b/pallets/gear-voucher/src/tests.rs @@ -78,7 +78,8 @@ fn voucher_issue_err_cases() { 1_000, Some(set), false, - 100 + 100, + None ), Error::::MaxProgramsLimitExceeded, ); @@ -99,6 +100,7 @@ fn voucher_issue_err_cases() { Some([program_id].into()), false, duration, + None ), Error::::DurationOutOfBounds, ); @@ -149,6 +151,7 @@ fn voucher_call_works() { None, false, DEFAULT_VALIDITY, + None )); let voucher_id_any = utils::get_last_voucher_id(); @@ -184,6 +187,7 @@ fn voucher_call_works() { Some(Default::default()), true, DEFAULT_VALIDITY, + None )); let voucher_id_code = utils::get_last_voucher_id(); @@ -732,6 +736,7 @@ fn voucher_decline_works() { None, false, DEFAULT_VALIDITY, + None )); let voucher_id = utils::get_last_voucher_id(); @@ -771,6 +776,7 @@ fn voucher_decline_err_cases() { None, false, DEFAULT_VALIDITY, + None )); let voucher_id = utils::get_last_voucher_id(); @@ -816,6 +822,7 @@ mod utils { Some([program].into()), code_uploading, DEFAULT_VALIDITY, + None, ) .map(|_| get_last_voucher_id()) } diff --git a/pallets/gear/src/lib.rs b/pallets/gear/src/lib.rs index 16be57aa59e..2f81afe1d5e 100644 --- a/pallets/gear/src/lib.rs +++ b/pallets/gear/src/lib.rs @@ -1198,6 +1198,7 @@ pub mod pallet { gas_limit: u64, value: BalanceOf, keep_alive: bool, + gas_sponsor: Option, ) -> Result { let packet = InitPacket::new_from_user( code_id, @@ -1220,7 +1221,10 @@ pub mod pallet { // First we reserve enough funds on the account to pay for `gas_limit` // and to transfer declared value. - GearBank::::deposit_gas(&who, gas_limit, keep_alive)?; + // If voucher or any other prepaid mechanism is not used, + // gas limit is taken from user's account. + let gas_sponsor = gas_sponsor.unwrap_or_else(|| who.clone()); + GearBank::::deposit_gas(&gas_sponsor, gas_limit, keep_alive)?; GearBank::::deposit_value(&who, value, keep_alive)?; Ok(packet) @@ -1410,6 +1414,7 @@ pub mod pallet { gas_limit, value, keep_alive, + None, )?; if !T::CodeStorage::exists(code_and_id.code_id()) { @@ -1461,25 +1466,16 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - // Check if code exists. - let code = T::CodeStorage::get_code(code_id).ok_or(Error::::CodeDoesntExist)?; - - // Check `gas_limit` - Self::check_gas_limit(gas_limit)?; - - // Construct packet. - let packet = Self::init_packet( - who.clone(), + Self::create_program_impl( + who, code_id, salt, init_payload, gas_limit, value, keep_alive, - )?; - - Self::do_create_program(who, packet, CodeInfo::from_code(&code_id, &code))?; - Ok(().into()) + None, + ) } /// Sends a message to a program or to another account. @@ -1972,6 +1968,38 @@ pub mod pallet { Ok(().into()) } + + pub fn create_program_impl( + origin: AccountIdOf, + code_id: CodeId, + salt: Vec, + init_payload: Vec, + gas_limit: u64, + value: BalanceOf, + keep_alive: bool, + gas_sponsor: Option>, + ) -> DispatchResultWithPostInfo { + // Check if code exists. + let code = T::CodeStorage::get_code(code_id).ok_or(Error::::CodeDoesntExist)?; + + // Check `gas_limit` + Self::check_gas_limit(gas_limit)?; + + // Construct packet. + let packet = Self::init_packet( + origin.clone(), + code_id, + salt, + init_payload, + gas_limit, + value, + keep_alive, + gas_sponsor, + )?; + + Self::do_create_program(origin, packet, CodeInfo::from_code(&code_id, &code))?; + Ok(().into()) + } } /// Dispatcher for all types of prepaid calls: gear or gear-voucher pallets. @@ -1998,6 +2026,9 @@ pub mod pallet { PrepaidCall::DeclineVoucher => { ::WeightInfo::decline() } + PrepaidCall::CreateProgram { salt, .. } => { + ::WeightInfo::create_program(salt.len() as u32) + } } } @@ -2043,6 +2074,23 @@ pub mod pallet { RawOrigin::Signed(account_id).into(), voucher_id, ), + PrepaidCall::CreateProgram { + code_id, + salt, + payload, + gas_limit, + value, + keep_alive, + } => Pallet::::create_program_impl( + account_id, + code_id, + salt, + payload, + gas_limit, + value, + keep_alive, + Some(sponsor_id), + ), } } } diff --git a/pallets/gear/src/mock.rs b/pallets/gear/src/mock.rs index 7be27b58b61..fac891d37ae 100644 --- a/pallets/gear/src/mock.rs +++ b/pallets/gear/src/mock.rs @@ -191,6 +191,7 @@ impl pallet_gear_voucher::Config for Test { type MaxProgramsAmount = ConstU8<32>; type MaxDuration = MaxVoucherDuration; type MinDuration = MinVoucherDuration; + type MaxCodeIdsAmount = ConstU8<32>; } // Build genesis storage according to the mock runtime. diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index 893271cf9fe..5d945f40c11 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -14118,6 +14118,7 @@ fn send_gasless_message_works() { Some([program_id].into()), false, 100, + None, )); // Balances check @@ -14220,6 +14221,7 @@ fn send_gasless_reply_works() { Some([prog_id].into()), false, 100, + None, )); let voucher_id = utils::get_last_voucher_id(); diff --git a/pallets/payment/src/mock.rs b/pallets/payment/src/mock.rs index 6a0929ae290..ce8d5f3fc37 100644 --- a/pallets/payment/src/mock.rs +++ b/pallets/payment/src/mock.rs @@ -187,6 +187,7 @@ impl pallet_gear_voucher::Config for Test { type MaxProgramsAmount = ConstU8<32>; type MaxDuration = MaxVoucherDuration; type MinDuration = MinVoucherDuration; + type MaxCodeIdsAmount = ConstU8<32>; } // Build genesis storage according to the mock runtime. diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index d3e87c0a061..112d8cbb676 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -529,6 +529,7 @@ fn fee_payer_replacement_works() { Some([program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); @@ -617,6 +618,7 @@ fn reply_with_voucher_pays_fee_from_voucher_ok() { Some([program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); @@ -702,6 +704,7 @@ fn voucher_call_send_payer_ok() { Some([program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -816,6 +819,7 @@ fn voucher_call_send_payer_wrong_program_err() { Some([voucher_program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -874,6 +878,7 @@ fn voucher_call_send_payer_expiry_err() { Some([program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -949,6 +954,7 @@ fn voucher_call_reply_payer_ok() { Some([program_id].into()), false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1028,6 +1034,7 @@ fn voucher_call_upload_payer_ok() { None, true, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1106,6 +1113,7 @@ fn voucher_call_upload_payer_forbidden_err() { None, false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1164,6 +1172,7 @@ fn voucher_call_decline_payer_ok() { None, true, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1245,6 +1254,7 @@ fn voucher_call_decline_payer_expired_err() { None, false, 100, + None, )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index f927ef46050..5d531f2a063 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -1248,6 +1248,7 @@ impl pallet_gear_voucher::Config for Runtime { type MaxProgramsAmount = ConstU8<32>; type MaxDuration = MaxVoucherDuration; type MinDuration = MinVoucherDuration; + type MaxCodeIdsAmount = ConstU8<32>; } impl frame_system::offchain::SendTransactionTypes for Runtime From e27c851c942923cddcc1ed63fbbb6ac4eb7983fb Mon Sep 17 00:00:00 2001 From: vobradovich Date: Tue, 20 Aug 2024 19:24:17 +0200 Subject: [PATCH 03/22] wip: update voucher & tests --- pallets/gear-voucher/src/lib.rs | 26 +++++ pallets/gear-voucher/src/tests.rs | 156 ++++++++++++++++++++++++++---- 2 files changed, 165 insertions(+), 17 deletions(-) diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index 06d1b640bfb..a0878c43cb1 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -456,6 +456,7 @@ pub mod pallet { append_programs: Option>>, code_uploading: Option, prolong_duration: Option>, + append_code_ids: Option>>, ) -> DispatchResultWithPostInfo { // Ensuring origin. let origin = ensure_signed(origin)?; @@ -557,6 +558,31 @@ pub mod pallet { updated = true; } + // Optionally extends whitelisted code_ids. + match append_code_ids { + // Adding given destination set to voucher, + // if it has destinations limit. + Some(Some(mut extra_code_ids)) if voucher.code_ids.is_some() => { + let code_ids = voucher.code_ids.as_mut().expect("Infallible; qed"); + let initial_len = code_ids.len(); + + code_ids.append(&mut extra_code_ids); + + ensure!( + code_ids.len() <= T::MaxCodeIdsAmount::get().into(), + Error::::MaxCodeIdsLimitExceeded + ); + + updated |= code_ids.len() != initial_len; + } + + // Extending vouchers to any CodeId. + Some(None) => updated |= voucher.code_ids.take().is_some(), + + // Noop. + _ => (), + } + // Check for Noop. if updated { // Inserting updated voucher back in storage. diff --git a/pallets/gear-voucher/src/tests.rs b/pallets/gear-voucher/src/tests.rs index c3647cdcab1..71aad9417ce 100644 --- a/pallets/gear-voucher/src/tests.rs +++ b/pallets/gear-voucher/src/tests.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use std::collections::BTreeSet; + use super::*; use crate::mock::*; use common::Origin; @@ -31,9 +33,15 @@ fn voucher_issue_works() { let initial_balance = Balances::free_balance(ALICE); - let voucher_id = - utils::issue_w_balance_and_uploading(ALICE, BOB, DEFAULT_BALANCE, program_id, false) - .expect("Failed to issue voucher"); + let voucher_id = utils::issue_w_balance_and_uploading( + ALICE, + BOB, + DEFAULT_BALANCE, + program_id, + false, + None, + ) + .expect("Failed to issue voucher"); assert_eq!( initial_balance, @@ -41,9 +49,15 @@ fn voucher_issue_works() { + Balances::free_balance(ALICE) ); - let voucher_id_2 = - utils::issue_w_balance_and_uploading(ALICE, BOB, DEFAULT_BALANCE, program_id, true) - .expect("Failed to issue voucher"); + let voucher_id_2 = utils::issue_w_balance_and_uploading( + ALICE, + BOB, + DEFAULT_BALANCE, + program_id, + true, + None, + ) + .expect("Failed to issue voucher"); assert_ne!(voucher_id, voucher_id_2); @@ -86,7 +100,14 @@ fn voucher_issue_err_cases() { // Not enough balance. assert_noop!( - utils::issue_w_balance_and_uploading(ALICE, BOB, 1_000_000_000_000, program_id, false), + utils::issue_w_balance_and_uploading( + ALICE, + BOB, + 1_000_000_000_000, + program_id, + false, + None + ), Error::::BalanceTransfer ); @@ -117,7 +138,8 @@ fn voucher_call_works() { new_test_ext().execute_with(|| { let program_id = MAILBOXED_PROGRAM; - let voucher_id = utils::issue(ALICE, BOB, program_id).expect("Failed to issue voucher"); + let voucher_id = + utils::issue(ALICE, BOB, program_id, None).expect("Failed to issue voucher"); assert_ok!(Voucher::call( RuntimeOrigin::signed(BOB), @@ -199,6 +221,19 @@ fn voucher_call_works() { voucher_id_code, PrepaidCall::UploadCode { code: vec![] }, )); + + assert_ok!(Voucher::call( + RuntimeOrigin::signed(BOB), + voucher_id_any, + PrepaidCall::CreateProgram { + code_id: CodeId::zero(), + salt: vec![], + payload: vec![], + gas_limit: 0, + value: 0, + keep_alive: true + }, + )); }) } @@ -206,6 +241,7 @@ fn voucher_call_works() { fn voucher_call_err_cases() { new_test_ext().execute_with(|| { let program_id = H256::random().cast(); + let code_id: CodeId = H256::random().cast(); // Voucher doesn't exist at all. assert_noop!( @@ -223,7 +259,8 @@ fn voucher_call_err_cases() { Error::::InexistentVoucher ); - let voucher_id = utils::issue(ALICE, BOB, program_id).expect("Failed to issue voucher"); + let voucher_id = + utils::issue(ALICE, BOB, program_id, Some(code_id)).expect("Failed to issue voucher"); // Voucher doesn't exist for the user. assert_noop!( @@ -298,6 +335,23 @@ fn voucher_call_err_cases() { Error::::CodeUploadingDisabled ); + // Voucher doesn't allow crate program with invalid code_id + assert_noop!( + Voucher::call( + RuntimeOrigin::signed(BOB), + voucher_id, + PrepaidCall::CreateProgram { + code_id: CodeId::zero(), + salt: vec![], + payload: vec![], + gas_limit: 0, + value: 0, + keep_alive: true + }, + ), + Error::::InappropriateCodeId + ); + // Voucher is out of date. System::set_block_number(System::block_number() + DEFAULT_VALIDITY + 1); @@ -323,7 +377,8 @@ fn voucher_revoke_works() { new_test_ext().execute_with(|| { let program_id = H256::random().cast(); - let voucher_id = utils::issue(ALICE, BOB, program_id).expect("Failed to issue voucher"); + let voucher_id = + utils::issue(ALICE, BOB, program_id, None).expect("Failed to issue voucher"); let voucher_id_acc = voucher_id.cast::>(); System::set_block_number(System::block_number() + DEFAULT_VALIDITY + 1); @@ -368,7 +423,8 @@ fn voucher_revoke_err_cases() { new_test_ext().execute_with(|| { let program_id = H256::random().cast(); - let voucher_id = utils::issue(ALICE, BOB, program_id).expect("Failed to issue voucher"); + let voucher_id = + utils::issue(ALICE, BOB, program_id, None).expect("Failed to issue voucher"); // Voucher doesn't exist assert_noop!( @@ -400,14 +456,17 @@ fn voucher_revoke_err_cases() { fn voucher_update_works() { new_test_ext().execute_with(|| { let program_id = H256::random().cast(); + let code_id: CodeId = H256::random().cast(); - let voucher_id = utils::issue(ALICE, BOB, program_id).expect("Failed to issue voucher"); + let voucher_id = + utils::issue(ALICE, BOB, program_id, Some(code_id)).expect("Failed to issue voucher"); let voucher_id_acc = voucher_id.cast::>(); let alice_balance = Balances::free_balance(ALICE); let voucher_balance = Balances::free_balance(voucher_id_acc); let new_program_id = H256::random().cast(); + let new_code_id: CodeId = H256::random().cast(); let duration_prolong = 10; let balance_top_up = 1_000; @@ -425,6 +484,8 @@ fn voucher_update_works() { Some(false), // prolong duration Some(0), + // extra code_id + Some(Some([code_id].into())) ))); assert_ok!(Voucher::update( @@ -441,6 +502,8 @@ fn voucher_update_works() { Some(true), // prolong duration Some(duration_prolong), + // extra code_id + Some(Some([new_code_id].into())) )); System::assert_has_event( @@ -464,6 +527,7 @@ fn voucher_update_works() { ); assert_eq!(voucher.owner, BOB); assert_eq!(voucher.programs, Some([program_id, new_program_id].into())); + assert_eq!(voucher.code_ids, Some([code_id, new_code_id].into())); assert!(voucher.code_uploading); assert_eq!( voucher.expiry, @@ -486,6 +550,8 @@ fn voucher_update_works() { None, // prolong duration None, + // extra code_id + Some(None) )); System::assert_has_event( @@ -502,6 +568,7 @@ fn voucher_update_works() { assert_eq!(Balances::free_balance(voucher_id_acc), voucher_balance); assert_eq!(voucher.owner, BOB); assert_eq!(voucher.programs, None); + assert_eq!(voucher.code_ids, None); assert_eq!( voucher.expiry, System::block_number() + DEFAULT_VALIDITY + 1 + duration_prolong @@ -521,6 +588,8 @@ fn voucher_update_works() { Some(true), // prolong duration None, + // extra code_id + Some(Some([code_id].into())), ))); let huge_block = 10_000_000_000; @@ -541,6 +610,8 @@ fn voucher_update_works() { None, // prolong duration Some(duration_prolong), + // extra code_id + None )); let voucher = Vouchers::::get(BOB, voucher_id).expect("Failed to get voucher"); @@ -569,6 +640,8 @@ fn voucher_update_works() { None, // prolong duration Some(valid_prolong + 1), + // extra code_id + None ), Error::::DurationOutOfBounds ); @@ -587,6 +660,8 @@ fn voucher_update_works() { None, // prolong duration Some(valid_prolong), + // extra code_id + None ),); }); } @@ -595,10 +670,17 @@ fn voucher_update_works() { fn voucher_update_err_cases() { new_test_ext().execute_with(|| { let program_id = H256::random().cast(); + let code_id: CodeId = H256::random().cast(); - let voucher_id = - utils::issue_w_balance_and_uploading(ALICE, BOB, DEFAULT_BALANCE, program_id, true) - .expect("Failed to issue voucher"); + let voucher_id = utils::issue_w_balance_and_uploading( + ALICE, + BOB, + DEFAULT_BALANCE, + program_id, + true, + Some(code_id), + ) + .expect("Failed to issue voucher"); // Inexistent voucher. assert_noop!( @@ -616,6 +698,8 @@ fn voucher_update_err_cases() { None, // prolong duration None, + // extra code_id + None ), Error::::InexistentVoucher ); @@ -636,6 +720,8 @@ fn voucher_update_err_cases() { None, // prolong duration None, + // extra code_id + None ), Error::::BadOrigin ); @@ -656,6 +742,8 @@ fn voucher_update_err_cases() { None, // prolong duration None, + // extra code_id + None ), Error::::BalanceTransfer ); @@ -680,6 +768,8 @@ fn voucher_update_err_cases() { None, // prolong duration None, + // extra code_id + None ), Error::::MaxProgramsLimitExceeded ); @@ -700,6 +790,8 @@ fn voucher_update_err_cases() { Some(false), // prolong duration None, + // extra code_id + None ), Error::::CodeUploadingEnabled ); @@ -720,9 +812,37 @@ fn voucher_update_err_cases() { None, // prolong duration Some(MaxVoucherDuration::get().saturating_sub(DEFAULT_VALIDITY)), + // extra code_id + None ), Error::::DurationOutOfBounds ); + + // Programs limit exceed. + let set: BTreeSet = (0..=<::MaxCodeIdsAmount as Get>::get()) + .map(|_| H256::random().cast()) + .collect(); + + assert_noop!( + Voucher::update( + RuntimeOrigin::signed(ALICE), + BOB, + voucher_id, + // move ownership + None, + // balance top up + None, + // extra programs + None, + // code uploading + None, + // prolong duration + None, + // extra code_id + Some(Some(set)), + ), + Error::::MaxCodeIdsLimitExceeded + ); }); } @@ -803,8 +923,9 @@ mod utils { from: AccountIdOf, to: AccountIdOf, program: ProgramId, + code_id: Option, ) -> Result { - issue_w_balance_and_uploading(from, to, DEFAULT_BALANCE, program, false) + issue_w_balance_and_uploading(from, to, DEFAULT_BALANCE, program, false, code_id) } #[track_caller] @@ -814,6 +935,7 @@ mod utils { balance: BalanceOf, program: ProgramId, code_uploading: bool, + code_id: Option, ) -> Result { Voucher::issue( RuntimeOrigin::signed(from), @@ -822,7 +944,7 @@ mod utils { Some([program].into()), code_uploading, DEFAULT_VALIDITY, - None, + code_id.map(|id| [id].into()), ) .map(|_| get_last_voucher_id()) } From 1369f48f9c13ccaa399a70617e207f4010e0d976 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 12:21:13 +0200 Subject: [PATCH 04/22] voucher payment tests --- pallets/payment/src/tests.rs | 160 ++++++++++++++++++++++++++++++++++- 1 file changed, 159 insertions(+), 1 deletion(-) diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index 112d8cbb676..c4bff881d20 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -1302,16 +1302,156 @@ fn voucher_call_decline_payer_expired_err() { }); } +#[test] +fn voucher_call_create_program_payer_ok() { + new_test_ext().execute_with(|| { + // Snapshot of the initial data. + let bob_initial_balance = Balances::free_balance(BOB); + let validator_initial_balance = Balances::free_balance(BLOCK_AUTHOR); + let voucher_initial_balance = 1_000_000_000; + + // Issuing a voucher to Bob from Alice. + assert_ok!(GearVoucher::issue( + RuntimeOrigin::signed(ALICE), + BOB, + voucher_initial_balance, + None, + true, + 100, + None, + )); + let voucher_id = get_last_voucher_id(); + let voucher_account_id = voucher_id.cast::>(); + + assert_eq!( + Balances::free_balance(voucher_account_id), + voucher_initial_balance + ); + + // Creating a RuntimeCall that should be free for caller. + let call = voucher_call_create_program(voucher_id); + + // Creating simulation of weight params for call to calculate fee. + let len = 100usize; + let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); + + let weight = Weight::from_parts(1_000, 0); + let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); + + let call_fee = fee_length + fee_weight; + + // Pre-dispatch of the call. + let pre = CustomChargeTransactionPayment::::from(0) + .pre_dispatch(&BOB, &call, &info_from_weight(weight), len) + .unwrap(); + + // Bob hasn't paid fees. + assert_eq!(Balances::free_balance(BOB), bob_initial_balance); + + // But the voucher has. + assert_eq!( + Balances::free_balance(voucher_account_id), + voucher_initial_balance - call_fee, + ); + + // Validator hasn't received fee yet. + assert_eq!( + Balances::free_balance(BLOCK_AUTHOR), + validator_initial_balance + ); + + // Post-dispatch of the call. + assert_ok!(CustomChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(weight), + &default_post_info(), + len, + &Err(pallet_gear::Error::::ProgramConstructionFailed.into()) + )); + + // Validating balances and validator reward. + assert_eq!(Balances::free_balance(BOB), bob_initial_balance); + assert_eq!( + Balances::free_balance(voucher_account_id), + voucher_initial_balance - call_fee, + ); + assert_eq!( + Balances::free_balance(BLOCK_AUTHOR), + validator_initial_balance + call_fee, + ); + }); +} + +#[test] +fn voucher_call_create_program_payer_forbidden_err() { + new_test_ext().execute_with(|| { + // Snapshot of the initial data. + let bob_initial_balance = Balances::free_balance(BOB); + let voucher_initial_balance = 1_000_000_000; + + // Issuing a voucher to Bob from Alice. + assert_ok!(GearVoucher::issue( + RuntimeOrigin::signed(ALICE), + BOB, + voucher_initial_balance, + None, + false, + 100, + Some([].into()), + )); + let voucher_id = get_last_voucher_id(); + let voucher_account_id = voucher_id.cast::>(); + + assert_eq!( + Balances::free_balance(voucher_account_id), + voucher_initial_balance + ); + + // Creating a RuntimeCall that should not be free for caller (voucher is invalid for call). + let call = voucher_call_create_program(voucher_id); + + // Creating simulation of weight params for call to calculate fee. + let len = 1usize; + let fee_length = LengthToFeeFor::::weight_to_fee(&Weight::from_parts(len as u64, 0)); + + let weight = Weight::from_parts(1, 0); + let fee_weight = WeightToFeeFor::::weight_to_fee(&weight); + + let call_fee = fee_length + fee_weight; + + // Pre-dispatch of the call. + assert_ok!( + CustomChargeTransactionPayment::::from(0).pre_dispatch( + &BOB, + &call, + &info_from_weight(weight), + len + ) + ); + + // Bob has paid fees. + assert_eq!(Balances::free_balance(BOB), bob_initial_balance - call_fee); + + // While voucher is kept the same. + assert_eq!( + Balances::free_balance(voucher_account_id), + voucher_initial_balance + ); + }); +} + mod utils { use super::*; use crate::BalanceOf; - use gear_core::ids::{MessageId, ProgramId}; + use gear_core::ids::{CodeId, MessageId, ProgramId}; use pallet_gear_voucher::{PrepaidCall, VoucherId}; const DEFAULT_PAYLOAD: &[u8] = &[]; + const DEFAULT_SALT: &[u8] = &[]; const DEFAULT_GAS_LIMIT: u64 = 100_000; const DEFAULT_VALUE: u128 = 0; const DEFAULT_KEEP_ALIVE: bool = false; + pub const DEFAULT_CODE_ID: CodeId = CodeId::zero(); pub fn voucher_call_send(voucher_id: VoucherId, destination: ProgramId) -> RuntimeCall { RuntimeCall::GearVoucher(VoucherCall::call { @@ -1334,6 +1474,13 @@ mod utils { }) } + pub fn voucher_call_create_program(voucher_id: VoucherId) -> RuntimeCall { + RuntimeCall::GearVoucher(VoucherCall::call { + voucher_id, + call: prepaid_create_program(DEFAULT_CODE_ID), + }) + } + pub fn prepaid_send(destination: ProgramId) -> PrepaidCall> { PrepaidCall::SendMessage { destination, @@ -1354,6 +1501,17 @@ mod utils { } } + pub fn prepaid_create_program(code_id: CodeId) -> PrepaidCall> { + PrepaidCall::CreateProgram { + code_id, + salt: DEFAULT_SALT.to_vec(), + payload: DEFAULT_PAYLOAD.to_vec(), + gas_limit: DEFAULT_GAS_LIMIT, + value: DEFAULT_VALUE, + keep_alive: DEFAULT_KEEP_ALIVE, + } + } + pub fn info_from_weight(weight: Weight) -> DispatchInfo { // DispatchInfo { weight: w, class: DispatchClass::Normal, pays_fee: Pays::Yes } DispatchInfo { From bb3defa6850d7542b77348d52f9c29aada748a90 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 15:29:11 +0200 Subject: [PATCH 05/22] pallet gear add prepaid create_program, test --- pallets/gear/src/lib.rs | 65 ++++++++++++------------- pallets/gear/src/tests.rs | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 34 deletions(-) diff --git a/pallets/gear/src/lib.rs b/pallets/gear/src/lib.rs index 2f81afe1d5e..20919395cd4 100644 --- a/pallets/gear/src/lib.rs +++ b/pallets/gear/src/lib.rs @@ -1191,14 +1191,11 @@ pub mod pallet { } pub(crate) fn init_packet( - who: T::AccountId, code_id: CodeId, salt: Vec, init_payload: Vec, gas_limit: u64, value: BalanceOf, - keep_alive: bool, - gas_sponsor: Option, ) -> Result { let packet = InitPacket::new_from_user( code_id, @@ -1219,14 +1216,6 @@ pub mod pallet { Error::::ProgramAlreadyExists ); - // First we reserve enough funds on the account to pay for `gas_limit` - // and to transfer declared value. - // If voucher or any other prepaid mechanism is not used, - // gas limit is taken from user's account. - let gas_sponsor = gas_sponsor.unwrap_or_else(|| who.clone()); - GearBank::::deposit_gas(&gas_sponsor, gas_limit, keep_alive)?; - GearBank::::deposit_value(&who, value, keep_alive)?; - Ok(packet) } @@ -1234,7 +1223,25 @@ pub mod pallet { who: T::AccountId, packet: InitPacket, code_info: CodeInfo, + keep_alive: bool, + gas_sponsor: Option, ) -> Result<(), DispatchError> { + // First we reserve enough funds on the account to pay for `gas_limit` + // and to transfer declared value. + // If voucher or any other prepaid mechanism is not used, + // gas limit is taken from user's account. + let gas_sponsor = gas_sponsor.unwrap_or_else(|| who.clone()); + GearBank::::deposit_gas( + &gas_sponsor, + packet.gas_limit().expect("Infallible"), + keep_alive, + )?; + GearBank::::deposit_value( + &gas_sponsor, + packet.value().unique_saturated_into(), + keep_alive, + )?; + let origin = who.clone().into_origin(); let message_id = Self::next_message_id(origin); @@ -1252,7 +1259,7 @@ pub mod pallet { let program_account = program_id.cast(); let ed = CurrencyOf::::minimum_balance(); CurrencyOf::::transfer( - &who, + &gas_sponsor, &program_account, ed, ExistenceRequirement::AllowDeath, @@ -1276,7 +1283,7 @@ pub mod pallet { }; Self::create( - who.clone(), + gas_sponsor, message_id, packet.gas_limit().expect("Infallible"), false, @@ -1406,16 +1413,8 @@ pub mod pallet { let code_and_id = Self::try_new_code(code)?; let code_info = CodeInfo::from_code_and_id(&code_and_id); - let packet = Self::init_packet( - who.clone(), - code_and_id.code_id(), - salt, - init_payload, - gas_limit, - value, - keep_alive, - None, - )?; + let packet = + Self::init_packet(code_and_id.code_id(), salt, init_payload, gas_limit, value)?; if !T::CodeStorage::exists(code_and_id.code_id()) { // By that call we follow the guarantee that we have in `Self::upload_code` - @@ -1432,7 +1431,7 @@ pub mod pallet { }); } - Self::do_create_program(who, packet, code_info)?; + Self::do_create_program(who, packet, code_info, keep_alive, None)?; Ok(().into()) } @@ -1969,7 +1968,8 @@ pub mod pallet { Ok(().into()) } - pub fn create_program_impl( + #[allow(clippy::too_many_arguments)] + fn create_program_impl( origin: AccountIdOf, code_id: CodeId, salt: Vec, @@ -1986,18 +1986,15 @@ pub mod pallet { Self::check_gas_limit(gas_limit)?; // Construct packet. - let packet = Self::init_packet( - origin.clone(), - code_id, - salt, - init_payload, - gas_limit, - value, + let packet = Self::init_packet(code_id, salt, init_payload, gas_limit, value)?; + + Self::do_create_program( + origin, + packet, + CodeInfo::from_code(&code_id, &code), keep_alive, gas_sponsor, )?; - - Self::do_create_program(origin, packet, CodeInfo::from_code(&code_id, &code))?; Ok(().into()) } } diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index 5d945f40c11..a4bd3e5105f 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -15911,6 +15911,106 @@ fn use_big_memory() { }); } +#[test] +fn test_prepaid_upload_code_create_program_works() { + use demo_init_wait::WASM_BINARY; + init_logger(); + + new_test_ext().execute_with(|| { + let user1_initial_balance = Balances::free_balance(USER_1); + let user2_initial_balance = Balances::free_balance(USER_2); + + // USER_2 issues a voucher for USER_1 enough to upload code and create program + let voucher_balance = gas_price(100_000_000_000u64); + assert_ok!(GearVoucher::issue( + RuntimeOrigin::signed(USER_2), + USER_1, + voucher_balance, + None, + true, + 100, + None, + )); + let voucher_id = utils::get_last_voucher_id(); + + // Balance check + assert_eq!( + Balances::free_balance(voucher_id.cast::>()), + voucher_balance + ); + + run_to_next_block(None); + + let code = WASM_BINARY.to_vec(); + + // USER_1 Upload code with voucher + assert_ok!(GearVoucher::call( + RuntimeOrigin::signed(USER_1), + voucher_id, + PrepaidCall::UploadCode { code: code.clone() } + )); + let code_id = utils::get_last_code_id(); + + run_to_next_block(None); + + // USER_1 create program with prepaid call + let gas_limit = 10_000_000_000u64; + assert_ok!(GearVoucher::call( + RuntimeOrigin::signed(USER_1), + voucher_id, + PrepaidCall::CreateProgram { + code_id, + salt: vec![], + payload: vec![], + gas_limit, + value: 0, + keep_alive: false + } + )); + + let program_id = utils::get_last_program_id(); + + assert!(utils::is_active(program_id)); + assert!(!Gear::is_initialized(program_id)); + + run_to_next_block(None); + + // there should be one message for the program author + let message_id = MailboxOf::::iter_key(USER_1) + .next() + .map(|(msg, _bn)| msg.id()) + .expect("Element should be"); + assert_eq!(MailboxOf::::len(&USER_1), 1); + + // USER_1 send reply to program with prepaid call + assert_ok!(GearVoucher::call( + RuntimeOrigin::signed(USER_1), + voucher_id, + PrepaidCall::SendReply { + reply_to_id: message_id, + payload: b"PONG".to_vec(), + gas_limit, + value: 0, + keep_alive: false, + } + )); + + run_to_next_block(None); + + // Ensure that program is uploaded and initialized correctly + assert!(utils::is_active(program_id)); + assert!(Gear::is_initialized(program_id)); + + // USER_1 balance not changed + assert_eq!(Balances::free_balance(USER_1), user1_initial_balance); + // USER_2 balance is initial minus voucher_balance + assert_eq!( + Balances::free_balance(USER_2), + user2_initial_balance - voucher_balance + ); + }) +} + pub(crate) mod utils { #![allow(unused)] From db2a5333571fb611d94876cbbda5149f293a7aa6 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 15:45:50 +0200 Subject: [PATCH 06/22] do_create_program deposit value from origin --- pallets/gear/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pallets/gear/src/lib.rs b/pallets/gear/src/lib.rs index 20919395cd4..bf06a67e7f0 100644 --- a/pallets/gear/src/lib.rs +++ b/pallets/gear/src/lib.rs @@ -1236,11 +1236,7 @@ pub mod pallet { packet.gas_limit().expect("Infallible"), keep_alive, )?; - GearBank::::deposit_value( - &gas_sponsor, - packet.value().unique_saturated_into(), - keep_alive, - )?; + GearBank::::deposit_value(&who, packet.value().unique_saturated_into(), keep_alive)?; let origin = who.clone().into_origin(); From a80928a5a1707481b67bd6fcdf5d823e3e575b6a Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 16:07:13 +0200 Subject: [PATCH 07/22] fix benchmarking --- pallets/gear-voucher/src/benchmarking.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/gear-voucher/src/benchmarking.rs b/pallets/gear-voucher/src/benchmarking.rs index ab558537ae1..84b4be9cb44 100644 --- a/pallets/gear-voucher/src/benchmarking.rs +++ b/pallets/gear-voucher/src/benchmarking.rs @@ -57,7 +57,7 @@ benchmarks! { // Voucher validity. let validity = <::MinDuration as Get>>::get(); - }: _(RawOrigin::Signed(origin.clone()), spender.clone(), balance, Some(set), code_uploading, validity) + }: _(RawOrigin::Signed(origin.clone()), spender.clone(), balance, Some(set), code_uploading, validity, None) verify { let (key_spender, voucher_id, voucher_info) = Vouchers::::iter().next().expect("Couldn't find voucher"); @@ -90,7 +90,7 @@ benchmarks! { let validity = <::MinDuration as Get>>::get(); // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity, None).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); frame_system::Pallet::::set_block_number(frame_system::Pallet::::block_number() + validity + One::one()); @@ -126,7 +126,7 @@ benchmarks! { let validity = <::MinDuration as Get>>::get(); // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, Some(set), code_uploading, validity).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, Some(set), code_uploading, validity, None).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); // New owner account. @@ -146,7 +146,7 @@ benchmarks! { // prolong duration. let prolong_duration = Some(validity); - }: _(RawOrigin::Signed(origin.clone()), spender.clone(), voucher_id, move_ownership, balance_top_up, append_programs, code_uploading, prolong_duration) + }: _(RawOrigin::Signed(origin.clone()), spender.clone(), voucher_id, move_ownership, balance_top_up, append_programs, code_uploading, prolong_duration, None) verify { let voucher_info = Vouchers::::get(spender, voucher_id).expect("Must be"); assert_eq!(voucher_info.programs.map(|v| v.len()), Some(<::MaxProgramsAmount as Get>::get() as usize)); @@ -174,7 +174,7 @@ benchmarks! { let validity = <::MinDuration as Get>>::get(); // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity, None).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); }: _(RawOrigin::Signed(spender.clone()), voucher_id) verify { From 1949523dadbc335d1e3368a633368cc44f2fe2d0 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 17:35:42 +0200 Subject: [PATCH 08/22] gsdk voucher create program --- gsdk/src/metadata/generated.rs | 20 ++++++++++++++++++++ gsdk/src/metadata/impls.rs | 18 ++++++++++++++++++ gsdk/src/signer/calls.rs | 20 ++++++++++++++++++++ gsdk/tests/voucher.rs | 28 +++++++++++++++++++++++++--- 4 files changed, 83 insertions(+), 3 deletions(-) diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index 7e7813a3618..d4c73feac10 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -3000,6 +3000,15 @@ pub mod runtime_types { }, #[codec(index = 3)] DeclineVoucher, + #[codec(index = 4)] + CreateProgram { + code_id: runtime_types::gprimitives::CodeId, + salt: ::std::vec::Vec<::core::primitive::u8>, + payload: ::std::vec::Vec<::core::primitive::u8>, + gas_limit: ::core::primitive::u64, + value: _0, + keep_alive: ::core::primitive::bool, + }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct VoucherId(pub [::core::primitive::u8; 32usize]); @@ -3011,6 +3020,8 @@ pub mod runtime_types { >, pub code_uploading: ::core::primitive::bool, pub expiry: _1, + pub code_ids: + ::core::option::Option<::std::vec::Vec>, } } pub mod pallet { @@ -3028,6 +3039,9 @@ pub mod runtime_types { >, code_uploading: ::core::primitive::bool, duration: ::core::primitive::u32, + code_ids: ::core::option::Option< + ::std::vec::Vec, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::call`]."] @@ -3100,6 +3114,12 @@ pub mod runtime_types { #[codec(index = 10)] #[doc = "Voucher is disabled for code uploading, but requested."] CodeUploadingDisabled, + #[codec(index = 11)] + #[doc = "CodeId is not in whitelisted set for voucher."] + InappropriateCodeId, + #[codec(index = 12)] + #[doc = "Try to whitelist more CodeId than allowed."] + MaxCodeIdsLimitExceeded, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] #[doc = "Pallet Gear Voucher event."] diff --git a/gsdk/src/metadata/impls.rs b/gsdk/src/metadata/impls.rs index 9095a606cf6..58daffd99f9 100644 --- a/gsdk/src/metadata/impls.rs +++ b/gsdk/src/metadata/impls.rs @@ -402,6 +402,24 @@ fn prepaid_call_to_scale_value(call: PrepaidCall) -> Value { Value::named_variant("UploadCode", [("code", Value::from_bytes(code))]) } PrepaidCall::DeclineVoucher => Value::unnamed_variant("DeclineVoucher", []), + PrepaidCall::CreateProgram { + code_id, + salt, + payload, + gas_limit, + value, + keep_alive, + } => Value::named_variant( + "CreateProgram", + [ + ("code_id", Value::from_bytes(code_id.0)), + ("salt", Value::from_bytes(salt)), + ("payload", Value::from_bytes(payload)), + ("gas_limit", Value::u128(gas_limit as u128)), + ("value", Value::u128(value as u128)), + ("keep_alive", Value::bool(keep_alive)), + ], + ), _ => unreachable!("other prepaid calls aren't supported"), } } diff --git a/gsdk/src/signer/calls.rs b/gsdk/src/signer/calls.rs index d889828a263..5858804fef6 100644 --- a/gsdk/src/signer/calls.rs +++ b/gsdk/src/signer/calls.rs @@ -248,12 +248,18 @@ impl SignerCalls { programs: Option>, code_uploading: bool, duration: u32, + code_ids: Option>, ) -> Result { let programs_value = programs .map(|vec| { Value::unnamed_composite(vec.into_iter().map(Value::from_bytes).collect::>()) }) .convert(); + let code_ids_value = code_ids + .map(|vec| { + Value::unnamed_composite(vec.into_iter().map(Value::from_bytes).collect::>()) + }) + .convert(); self.0 .run_tx( @@ -264,6 +270,7 @@ impl SignerCalls { programs_value, Value::bool(code_uploading), Value::from(duration), + code_ids_value, ], ) .await @@ -280,6 +287,7 @@ impl SignerCalls { append_programs: Option>>, code_uploading: Option, prolong_duration: u32, + append_code_ids: Option>>, ) -> Result { let append_programs_value = append_programs .map(|o| { @@ -292,6 +300,17 @@ impl SignerCalls { }) .convert(); + let append_code_ids_value = append_code_ids + .map(|o| { + o.map(|vec| { + Value::unnamed_composite( + vec.into_iter().map(Value::from_bytes).collect::>(), + ) + }) + .convert() + }) + .convert(); + self.0 .run_tx( GearVoucherCall::Update, @@ -305,6 +324,7 @@ impl SignerCalls { append_programs_value, code_uploading.map(Value::bool).convert(), Value::from(prolong_duration), + append_code_ids_value, ], ) .await diff --git a/gsdk/tests/voucher.rs b/gsdk/tests/voucher.rs index e90d86cd14c..ccf966cf260 100644 --- a/gsdk/tests/voucher.rs +++ b/gsdk/tests/voucher.rs @@ -47,6 +47,7 @@ async fn test_issue_voucher() -> Result<()> { None, false, 100, + None, ) .await?; @@ -74,7 +75,14 @@ async fn test_decline_revoke_voucher() -> Result<()> { // issue voucher let tx = signer .calls - .issue_voucher(account_id.clone(), voucher_initial_balance, None, true, 100) + .issue_voucher( + account_id.clone(), + voucher_initial_balance, + None, + true, + 100, + None, + ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; let _voucher_address = AccountId32::new(voucher_id.0).to_ss58check(); @@ -111,7 +119,14 @@ async fn test_upload_code_with_voucher() -> Result<()> { // issue voucher let tx = signer .calls - .issue_voucher(account_id.clone(), voucher_initial_balance, None, true, 100) + .issue_voucher( + account_id.clone(), + voucher_initial_balance, + None, + true, + 100, + None, + ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; let voucher_address = AccountId32::new(voucher_id.0).to_ss58check(); @@ -154,7 +169,14 @@ async fn test_send_message_with_voucher() -> Result<()> { // 1. issue voucher let tx = signer .calls - .issue_voucher(account_id.clone(), voucher_initial_balance, None, true, 100) + .issue_voucher( + account_id.clone(), + voucher_initial_balance, + None, + true, + 100, + None, + ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; let voucher_address = AccountId32::new(voucher_id.0).to_ss58check(); From c01612463069ed71574555146140618a6edc7343 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Wed, 21 Aug 2024 19:55:53 +0200 Subject: [PATCH 09/22] wip: introduce VoucherPermissions --- pallets/gear-voucher/src/internal.rs | 81 ++++++++++++++++++++++++---- pallets/gear-voucher/src/lib.rs | 45 ++++++++-------- pallets/gear-voucher/src/tests.rs | 62 ++++++++++----------- pallets/gear/src/tests.rs | 14 ++--- pallets/payment/src/tests.rs | 50 +++++------------ 5 files changed, 143 insertions(+), 109 deletions(-) diff --git a/pallets/gear-voucher/src/internal.rs b/pallets/gear-voucher/src/internal.rs index b068e761e26..07d699b33ee 100644 --- a/pallets/gear-voucher/src/internal.rs +++ b/pallets/gear-voucher/src/internal.rs @@ -85,10 +85,13 @@ impl Pallet { match call { PrepaidCall::DeclineVoucher => (), PrepaidCall::UploadCode { .. } => { - ensure!(voucher.code_uploading, Error::::CodeUploadingDisabled) + ensure!( + voucher.permissions.code_uploading, + Error::::CodeUploadingDisabled + ) } PrepaidCall::SendMessage { .. } | PrepaidCall::SendReply { .. } => { - if let Some(ref programs) = voucher.programs { + if let Some(ref programs) = voucher.permissions.programs { let destination = Self::prepaid_call_destination(&origin, call) .ok_or(Error::::UnknownDestination)?; @@ -99,7 +102,7 @@ impl Pallet { } } PrepaidCall::CreateProgram { code_id, .. } => { - if let Some(code_ids) = voucher.code_ids { + if let Some(code_ids) = voucher.permissions.code_ids { ensure!(code_ids.contains(code_id), Error::::InappropriateCodeId); } } @@ -190,22 +193,18 @@ pub struct VoucherInfo { /// May be different to original issuer. /// Owner manages and claims back remaining balance of the voucher. pub owner: AccountId, - /// Set of programs this voucher could be used to interact with. - /// In case of [`None`] means any gear program. - pub programs: Option>, - /// Flag if this voucher's covers uploading codes as prepaid call. - pub code_uploading: bool, /// The block number at and after which voucher couldn't be used and /// can be revoked by owner. pub expiry: BlockNumber, /// Set of CodeId this voucher could be used to create program. /// In case of [`None`] means any uploaded code. - pub code_ids: Option>, + pub permissions: VoucherPermissions, } impl VoucherInfo { pub fn contains(&self, program_id: ProgramId) -> bool { - self.programs + self.permissions + .programs .as_ref() .map_or(true, |v| v.contains(&program_id)) } @@ -241,3 +240,65 @@ pub enum PrepaidCall { keep_alive: bool, }, } + +/// Voucher Permissions: +/// * programs: pool of programs spender can interact with, +/// if None - means any program, +/// limited by Config param; +/// * code_uploading: +/// allow voucher to be used as payer for `upload_code` +/// transactions fee; +/// * code_ids: pool of code identifiers spender can create program from, +/// if None - means any code, +/// limited by Config param; +#[derive(Debug, Clone, Encode, Decode, TypeInfo, PartialEq)] +pub struct VoucherPermissions { + /// Set of programs this voucher could be used to interact with. + /// In case of [`None`] means any gear program. + pub programs: Option>, + /// Flag if this voucher's covers uploading codes as prepaid call. + pub code_uploading: bool, + /// Set of CodeId this voucher could be used to create program. + /// In case of [`None`] means any uploaded code. + pub code_ids: Option>, +} + +impl VoucherPermissions { + pub const fn none() -> Self { + Self { + programs: Some(BTreeSet::new()), + code_uploading: false, + code_ids: Some(BTreeSet::new()), + } + } + + pub const fn all() -> Self { + Self { + programs: None, + code_uploading: true, + code_ids: None, + } + } + + pub fn allow_code_uploading(self, code_uploading: bool) -> Self { + Self { + code_uploading, + ..self + } + } + + pub fn allow_programs(self, programs: Option>) -> Self { + Self { programs, ..self } + } + + pub fn allow_code_ids(self, code_ids: Option>) -> Self { + Self { code_ids, ..self } + } +} + +impl Default for VoucherPermissions { + /// Default permissions don't allow anything + fn default() -> Self { + Self::none() + } +} diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index a0878c43cb1..b7a2d085aba 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -240,27 +240,21 @@ pub mod pallet { /// * spender: user id that is eligible to use the voucher; /// * balance: voucher balance could be used for transactions /// fees and gas; - /// * programs: pool of programs spender can interact with, - /// if None - means any program, - /// limited by Config param; - /// * code_uploading: - /// allow voucher to be used as payer for `upload_code` - /// transactions fee; /// * duration: amount of blocks voucher could be used by spender /// and couldn't be revoked by owner. /// Must be out in [MinDuration; MaxDuration] constants. /// Expiration block of the voucher calculates as: /// current bn (extrinsic exec bn) + duration + 1. + /// * permissions: + /// set of permissions voucher could be used #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::issue())] pub fn issue( origin: OriginFor, spender: AccountIdOf, balance: BalanceOf, - programs: Option>, - code_uploading: bool, duration: BlockNumberFor, - code_ids: Option>, + permissions: VoucherPermissions, ) -> DispatchResultWithPostInfo { // Ensuring origin. let owner = ensure_signed(origin)?; @@ -272,7 +266,7 @@ pub mod pallet { ); // Asserting amount of programs. - if let Some(ref programs) = programs { + if let Some(ref programs) = permissions.programs { ensure!( programs.len() <= T::MaxProgramsAmount::get().saturated_into(), Error::::MaxProgramsLimitExceeded @@ -280,7 +274,7 @@ pub mod pallet { } // Asserting amount of code_ids. - if let Some(ref code_ids) = code_ids { + if let Some(ref code_ids) = permissions.code_ids { ensure!( code_ids.len() <= T::MaxCodeIdsAmount::get().saturated_into(), Error::::MaxCodeIdsLimitExceeded @@ -307,10 +301,8 @@ pub mod pallet { // Aggregating vouchers data. let voucher_info = VoucherInfo { owner: owner.clone(), - programs, - code_uploading, expiry, - code_ids, + permissions, }; // Inserting voucher data into storage, associated with spender and voucher ids. @@ -475,7 +467,8 @@ pub mod pallet { let new_owner = move_ownership.filter(|addr| *addr != voucher.owner); // Flattening code uploading. - let code_uploading = code_uploading.filter(|v| *v != voucher.code_uploading); + let code_uploading = + code_uploading.filter(|v| *v != voucher.permissions.code_uploading); // Flattening duration prolongation. let prolong_duration = prolong_duration.filter(|dur| !dur.is_zero()); @@ -503,8 +496,12 @@ pub mod pallet { match append_programs { // Adding given destination set to voucher, // if it has destinations limit. - Some(Some(mut extra_programs)) if voucher.programs.is_some() => { - let programs = voucher.programs.as_mut().expect("Infallible; qed"); + Some(Some(mut extra_programs)) if voucher.permissions.programs.is_some() => { + let programs = voucher + .permissions + .programs + .as_mut() + .expect("Infallible; qed"); let initial_len = programs.len(); programs.append(&mut extra_programs); @@ -518,7 +515,7 @@ pub mod pallet { } // Extending vouchers to unlimited destinations. - Some(None) => updated |= voucher.programs.take().is_some(), + Some(None) => updated |= voucher.permissions.programs.take().is_some(), // Noop. _ => (), @@ -528,7 +525,7 @@ pub mod pallet { if let Some(code_uploading) = code_uploading { ensure!(code_uploading, Error::::CodeUploadingEnabled); - voucher.code_uploading = true; + voucher.permissions.code_uploading = true; updated = true; } @@ -562,8 +559,12 @@ pub mod pallet { match append_code_ids { // Adding given destination set to voucher, // if it has destinations limit. - Some(Some(mut extra_code_ids)) if voucher.code_ids.is_some() => { - let code_ids = voucher.code_ids.as_mut().expect("Infallible; qed"); + Some(Some(mut extra_code_ids)) if voucher.permissions.code_ids.is_some() => { + let code_ids = voucher + .permissions + .code_ids + .as_mut() + .expect("Infallible; qed"); let initial_len = code_ids.len(); code_ids.append(&mut extra_code_ids); @@ -577,7 +578,7 @@ pub mod pallet { } // Extending vouchers to any CodeId. - Some(None) => updated |= voucher.code_ids.take().is_some(), + Some(None) => updated |= voucher.permissions.code_ids.take().is_some(), // Noop. _ => (), diff --git a/pallets/gear-voucher/src/tests.rs b/pallets/gear-voucher/src/tests.rs index 71aad9417ce..0fd9a962ad8 100644 --- a/pallets/gear-voucher/src/tests.rs +++ b/pallets/gear-voucher/src/tests.rs @@ -24,7 +24,7 @@ use common::Origin; use frame_support::{assert_noop, assert_ok, assert_storage_noop}; use primitive_types::H256; use sp_runtime::traits::{One, Zero}; -use utils::{DEFAULT_BALANCE, DEFAULT_VALIDITY}; +use utils::{DEFAULT_BALANCE, DEFAULT_PERMISSIONS, DEFAULT_VALIDITY}; #[test] fn voucher_issue_works() { @@ -63,15 +63,15 @@ fn voucher_issue_works() { let voucher_info = Vouchers::::get(BOB, voucher_id).expect("Voucher isn't found"); assert_eq!(voucher_info.owner, ALICE); - assert_eq!(voucher_info.programs, Some([program_id].into())); + assert_eq!(voucher_info.permissions.programs, Some([program_id].into())); assert_eq!( voucher_info.expiry, System::block_number().saturating_add(DEFAULT_VALIDITY + 1) ); - assert!(!voucher_info.code_uploading); + assert!(!voucher_info.permissions.code_uploading); let voucher_info = Vouchers::::get(BOB, voucher_id_2).expect("Voucher isn't found"); - assert!(voucher_info.code_uploading); + assert!(voucher_info.permissions.code_uploading); }); } @@ -90,10 +90,12 @@ fn voucher_issue_err_cases() { RuntimeOrigin::signed(ALICE), BOB, 1_000, - Some(set), - false, 100, - None + VoucherPermissions { + programs: Some(set), + code_uploading: false, + code_ids: None + } ), Error::::MaxProgramsLimitExceeded, ); @@ -118,10 +120,8 @@ fn voucher_issue_err_cases() { RuntimeOrigin::signed(ALICE), BOB, 1_000, - Some([program_id].into()), - false, duration, - None + DEFAULT_PERMISSIONS ), Error::::DurationOutOfBounds, ); @@ -170,10 +170,8 @@ fn voucher_call_works() { RuntimeOrigin::signed(ALICE), BOB, 1_000, - None, - false, DEFAULT_VALIDITY, - None + VoucherPermissions::all().allow_code_uploading(false), )); let voucher_id_any = utils::get_last_voucher_id(); @@ -206,10 +204,8 @@ fn voucher_call_works() { RuntimeOrigin::signed(ALICE), BOB, 1_000, - Some(Default::default()), - true, DEFAULT_VALIDITY, - None + VoucherPermissions::all(), )); let voucher_id_code = utils::get_last_voucher_id(); @@ -526,9 +522,15 @@ fn voucher_update_works() { voucher_balance + balance_top_up ); assert_eq!(voucher.owner, BOB); - assert_eq!(voucher.programs, Some([program_id, new_program_id].into())); - assert_eq!(voucher.code_ids, Some([code_id, new_code_id].into())); - assert!(voucher.code_uploading); + assert_eq!( + voucher.permissions.programs, + Some([program_id, new_program_id].into()) + ); + assert_eq!( + voucher.permissions.code_ids, + Some([code_id, new_code_id].into()) + ); + assert!(voucher.permissions.code_uploading); assert_eq!( voucher.expiry, System::block_number() + DEFAULT_VALIDITY + 1 + duration_prolong @@ -567,8 +569,8 @@ fn voucher_update_works() { assert_eq!(Balances::free_balance(voucher_id_acc), voucher_balance); assert_eq!(voucher.owner, BOB); - assert_eq!(voucher.programs, None); - assert_eq!(voucher.code_ids, None); + assert_eq!(voucher.permissions.programs, None); + assert_eq!(voucher.permissions.code_ids, None); assert_eq!( voucher.expiry, System::block_number() + DEFAULT_VALIDITY + 1 + duration_prolong @@ -853,10 +855,8 @@ fn voucher_decline_works() { RuntimeOrigin::signed(ALICE), BOB, DEFAULT_BALANCE, - None, - false, DEFAULT_VALIDITY, - None + DEFAULT_PERMISSIONS )); let voucher_id = utils::get_last_voucher_id(); @@ -893,10 +893,8 @@ fn voucher_decline_err_cases() { RuntimeOrigin::signed(ALICE), BOB, DEFAULT_BALANCE, - None, - false, DEFAULT_VALIDITY, - None + DEFAULT_PERMISSIONS, )); let voucher_id = utils::get_last_voucher_id(); @@ -917,6 +915,7 @@ mod utils { pub(crate) const DEFAULT_VALIDITY: BlockNumberFor = 100; pub(crate) const DEFAULT_BALANCE: BalanceOf = ExistentialDeposit::get() * 1_000; + pub(crate) const DEFAULT_PERMISSIONS: VoucherPermissions = VoucherPermissions::none(); #[track_caller] pub(crate) fn issue( @@ -937,14 +936,17 @@ mod utils { code_uploading: bool, code_id: Option, ) -> Result { + let permissions = VoucherPermissions { + programs: Some([program].into()), + code_uploading, + code_ids: code_id.map(|id| [id].into()), + }; Voucher::issue( RuntimeOrigin::signed(from), to, balance, - Some([program].into()), - code_uploading, DEFAULT_VALIDITY, - code_id.map(|id| [id].into()), + permissions, ) .map(|_| get_last_voucher_id()) } diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index a4bd3e5105f..14ac8fb16e0 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -69,7 +69,7 @@ use gstd::{ collections::BTreeMap, errors::{CoreError, Error as GstdError}, }; -use pallet_gear_voucher::PrepaidCall; +use pallet_gear_voucher::{PrepaidCall, VoucherPermissions}; use sp_runtime::{ codec::{Decode, Encode}, traits::{Dispatchable, One, UniqueSaturatedInto}, @@ -14115,10 +14115,8 @@ fn send_gasless_message_works() { RuntimeOrigin::signed(USER_1), USER_2, gas_price(DEFAULT_GAS_LIMIT), - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); // Balances check @@ -14218,10 +14216,8 @@ fn send_gasless_reply_works() { RuntimeOrigin::signed(USER_2), USER_1, gas_price(DEFAULT_GAS_LIMIT), - Some([prog_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([prog_id].into())), )); let voucher_id = utils::get_last_voucher_id(); @@ -15926,10 +15922,8 @@ fn test_prepaid_upload_code_create_program_works() { RuntimeOrigin::signed(USER_2), USER_1, voucher_balance, - None, - true, 100, - None, + VoucherPermissions::all(), )); let voucher_id = utils::get_last_voucher_id(); diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index c4bff881d20..f6d093a21b6 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -26,7 +26,7 @@ use frame_support::{ weights::{Weight, WeightToFee}, }; use gear_core::message::{Dispatch, DispatchKind, Message, StoredDispatch, UserStoredMessage}; -use pallet_gear_voucher::{Call as VoucherCall, PrepaidCall}; +use pallet_gear_voucher::{Call as VoucherCall, PrepaidCall, VoucherPermissions}; use pallet_transaction_payment::{FeeDetails, InclusionFee, Multiplier, RuntimeDispatchInfo}; use primitive_types::H256; use sp_runtime::{codec::Encode, testing::TestXt, traits::SignedExtension, FixedPointNumber}; @@ -526,10 +526,8 @@ fn fee_payer_replacement_works() { RuntimeOrigin::signed(ALICE), BOB, synthesized_initial_balance, - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); let voucher_id = get_last_voucher_id(); @@ -615,10 +613,8 @@ fn reply_with_voucher_pays_fee_from_voucher_ok() { RuntimeOrigin::signed(ALICE), BOB, 200_000_000, - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); let voucher_id = get_last_voucher_id(); @@ -701,10 +697,8 @@ fn voucher_call_send_payer_ok() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -816,10 +810,8 @@ fn voucher_call_send_payer_wrong_program_err() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - Some([voucher_program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([voucher_program_id].into())), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -875,10 +867,8 @@ fn voucher_call_send_payer_expiry_err() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -951,10 +941,8 @@ fn voucher_call_reply_payer_ok() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - Some([program_id].into()), - false, 100, - None, + VoucherPermissions::none().allow_programs(Some([program_id].into())), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1031,10 +1019,8 @@ fn voucher_call_upload_payer_ok() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::all(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1110,10 +1096,8 @@ fn voucher_call_upload_payer_forbidden_err() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - false, 100, - None, + VoucherPermissions::none(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1169,10 +1153,8 @@ fn voucher_call_decline_payer_ok() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::none(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1251,10 +1233,8 @@ fn voucher_call_decline_payer_expired_err() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - false, 100, - None, + VoucherPermissions::none(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1315,10 +1295,8 @@ fn voucher_call_create_program_payer_ok() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::all(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); @@ -1394,10 +1372,8 @@ fn voucher_call_create_program_payer_forbidden_err() { RuntimeOrigin::signed(ALICE), BOB, voucher_initial_balance, - None, - false, 100, - Some([].into()), + VoucherPermissions::none(), )); let voucher_id = get_last_voucher_id(); let voucher_account_id = voucher_id.cast::>(); From 43e5e0d61cfdd8f09d8dcffe103779f8db099168 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 22 Aug 2024 13:30:51 +0200 Subject: [PATCH 10/22] wip: introduce VoucherPermissionsExtend --- pallets/gear-voucher/src/benchmarking.rs | 38 ++++-- pallets/gear-voucher/src/internal.rs | 98 ++++++++++++++ pallets/gear-voucher/src/lib.rs | 78 +---------- pallets/gear-voucher/src/tests.rs | 162 +++++++++++------------ 4 files changed, 206 insertions(+), 170 deletions(-) diff --git a/pallets/gear-voucher/src/benchmarking.rs b/pallets/gear-voucher/src/benchmarking.rs index 84b4be9cb44..853e721a07e 100644 --- a/pallets/gear-voucher/src/benchmarking.rs +++ b/pallets/gear-voucher/src/benchmarking.rs @@ -57,7 +57,13 @@ benchmarks! { // Voucher validity. let validity = <::MinDuration as Get>>::get(); - }: _(RawOrigin::Signed(origin.clone()), spender.clone(), balance, Some(set), code_uploading, validity, None) + // Permissions + let permissions = VoucherPermissions { + programs: Some(set), + code_uploading, + code_ids: None, + }; + }: _(RawOrigin::Signed(origin.clone()), spender.clone(), balance, validity, permissions) verify { let (key_spender, voucher_id, voucher_info) = Vouchers::::iter().next().expect("Couldn't find voucher"); @@ -83,14 +89,11 @@ benchmarks! { // Voucher balance. let balance = 10_000_000_000_000_u128.unique_saturated_into(); - // Forbid uploading codes. - let code_uploading = false; - // Voucher validity. let validity = <::MinDuration as Get>>::get(); // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity, None).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, validity, VoucherPermissions::none()).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); frame_system::Pallet::::set_block_number(frame_system::Pallet::::block_number() + validity + One::one()); @@ -125,8 +128,15 @@ benchmarks! { // Voucher validity. let validity = <::MinDuration as Get>>::get(); + // Permissions + let permissions = VoucherPermissions { + programs: Some(set), + code_uploading, + code_ids: None, + }; + // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, Some(set), code_uploading, validity, None).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, validity, permissions).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); // New owner account. @@ -146,10 +156,17 @@ benchmarks! { // prolong duration. let prolong_duration = Some(validity); - }: _(RawOrigin::Signed(origin.clone()), spender.clone(), voucher_id, move_ownership, balance_top_up, append_programs, code_uploading, prolong_duration, None) + + // Permissions + let permissions_extend = VoucherPermissionsExtend { + append_programs, + code_uploading, + append_code_ids: None, + }; + }: _(RawOrigin::Signed(origin.clone()), spender.clone(), voucher_id, move_ownership, balance_top_up, prolong_duration, permissions_extend) verify { let voucher_info = Vouchers::::get(spender, voucher_id).expect("Must be"); - assert_eq!(voucher_info.programs.map(|v| v.len()), Some(<::MaxProgramsAmount as Get>::get() as usize)); + assert_eq!(voucher_info.permissions.programs.map(|v| v.len()), Some(<::MaxProgramsAmount as Get>::get() as usize)); assert_eq!(CurrencyOf::::free_balance(&voucher_id.cast::()), balance * 2u128.unique_saturated_into()); } @@ -167,14 +184,11 @@ benchmarks! { // Voucher balance. let balance = 10_000_000_000_000_u128.unique_saturated_into(); - // Forbid uploading codes. - let code_uploading = false; - // Voucher validity. let validity = <::MinDuration as Get>>::get(); // Issue voucher. - assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, None, code_uploading, validity, None).is_ok()); + assert!(Pallet::::issue(RawOrigin::Signed(origin.clone()).into(), spender.clone(), balance, validity, VoucherPermissions::none()).is_ok()); let (_, voucher_id, _) = Vouchers::::iter().next().expect("Couldn't find voucher"); }: _(RawOrigin::Signed(spender.clone()), voucher_id) verify { diff --git a/pallets/gear-voucher/src/internal.rs b/pallets/gear-voucher/src/internal.rs index 07d699b33ee..340247e7ff0 100644 --- a/pallets/gear-voucher/src/internal.rs +++ b/pallets/gear-voucher/src/internal.rs @@ -294,6 +294,80 @@ impl VoucherPermissions { pub fn allow_code_ids(self, code_ids: Option>) -> Self { Self { code_ids, ..self } } + + /// Extend permissions + /// + /// Returns `true` if permissions extended + pub fn extend( + &mut self, + extend: VoucherPermissionsExtend, + ) -> Result> { + // Flag if permissions needs update in storage. + let mut updated = false; + + // Flattening code uploading. + let code_uploading = extend.code_uploading.filter(|v| *v != self.code_uploading); + // Optionally enabling code uploading. + if let Some(code_uploading) = code_uploading { + ensure!(code_uploading, Error::::CodeUploadingEnabled); + + self.code_uploading = true; + updated = true; + } + + // Optionally extends whitelisted programs with amount validation. + match extend.append_programs { + // Adding given destination set to voucher, + // if it has destinations limit. + Some(Some(mut extra_programs)) if self.programs.is_some() => { + let programs = self.programs.as_mut().expect("Infallible"); + let initial_len = programs.len(); + + programs.append(&mut extra_programs); + + ensure!( + programs.len() <= T::MaxProgramsAmount::get().into(), + Error::::MaxProgramsLimitExceeded + ); + + updated |= programs.len() != initial_len; + } + + // Extending vouchers to unlimited destinations. + Some(None) => updated |= self.programs.take().is_some(), + + // Noop. + _ => (), + } + + // Optionally extends whitelisted code_ids. + match extend.append_code_ids { + // Adding given destination set to voucher, + // if it has destinations limit. + Some(Some(mut extra_code_ids)) if self.code_ids.is_some() => { + let code_ids = self.code_ids.as_mut().expect("Infallible; qed"); + let initial_len = code_ids.len(); + + code_ids.append(&mut extra_code_ids); + + ensure!( + code_ids.len() <= T::MaxCodeIdsAmount::get().into(), + Error::::MaxCodeIdsLimitExceeded + ); + + updated |= code_ids.len() != initial_len; + } + + // Extending vouchers to any CodeId. + Some(None) => updated |= self.code_ids.take().is_some(), + + // Noop. + _ => (), + } + + // Return updated flag + Ok(updated) + } } impl Default for VoucherPermissions { @@ -302,3 +376,27 @@ impl Default for VoucherPermissions { Self::none() } } + +/// Voucher Permissions Extend +/// * append_programs: optionally extends pool of programs by +/// `Some(programs_set)` passed or allows +/// it to interact with any program by +/// `None` passed; +/// * code_uploading: optionally allows voucher to be used to pay +/// fees for `upload_code` extrinsics; +/// * append_code_ids: optionally extends pool of code identifiers +/// `Some(code_ids)` passed or allows +/// it to interact with any program by +/// `None` passed; +#[derive(Debug, Default, Clone, Encode, Decode, TypeInfo, PartialEq)] +pub struct VoucherPermissionsExtend { + pub append_programs: Option>>, + pub code_uploading: Option, + pub append_code_ids: Option>>, +} + +impl From> for VoucherPermissionsExtend { + fn from(value: Option) -> Self { + value.unwrap_or_default() + } +} diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index b7a2d085aba..52e01066553 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -55,7 +55,7 @@ use frame_support::{ traits::{Currency, ExistenceRequirement, ReservableCurrency, StorageVersion}, PalletId, }; -use gear_core::ids::{CodeId, MessageId, ProgramId}; +use gear_core::ids::MessageId; pub use primitive_types::H256; use sp_std::{convert::TryInto, vec::Vec}; pub use weights::WeightInfo; @@ -83,7 +83,6 @@ pub mod pallet { traits::{CheckedSub, One, Zero}, SaturatedConversion, Saturating, }; - use sp_std::collections::btree_set::BTreeSet; #[pallet::config] pub trait Config: frame_system::Config { @@ -445,10 +444,8 @@ pub mod pallet { voucher_id: VoucherId, move_ownership: Option>, balance_top_up: Option>, - append_programs: Option>>, - code_uploading: Option, prolong_duration: Option>, - append_code_ids: Option>>, + permissions_extend: VoucherPermissionsExtend, ) -> DispatchResultWithPostInfo { // Ensuring origin. let origin = ensure_signed(origin)?; @@ -466,10 +463,6 @@ pub mod pallet { // Flattening move ownership back to current owner. let new_owner = move_ownership.filter(|addr| *addr != voucher.owner); - // Flattening code uploading. - let code_uploading = - code_uploading.filter(|v| *v != voucher.permissions.code_uploading); - // Flattening duration prolongation. let prolong_duration = prolong_duration.filter(|dur| !dur.is_zero()); @@ -492,43 +485,6 @@ pub mod pallet { updated = true; } - // Optionally extends whitelisted programs with amount validation. - match append_programs { - // Adding given destination set to voucher, - // if it has destinations limit. - Some(Some(mut extra_programs)) if voucher.permissions.programs.is_some() => { - let programs = voucher - .permissions - .programs - .as_mut() - .expect("Infallible; qed"); - let initial_len = programs.len(); - - programs.append(&mut extra_programs); - - ensure!( - programs.len() <= T::MaxProgramsAmount::get().into(), - Error::::MaxProgramsLimitExceeded - ); - - updated |= programs.len() != initial_len; - } - - // Extending vouchers to unlimited destinations. - Some(None) => updated |= voucher.permissions.programs.take().is_some(), - - // Noop. - _ => (), - } - - // Optionally enabling code uploading. - if let Some(code_uploading) = code_uploading { - ensure!(code_uploading, Error::::CodeUploadingEnabled); - - voucher.permissions.code_uploading = true; - updated = true; - } - // Optionally prolongs validity of the voucher. if let Some(duration) = prolong_duration { let current_bn = >::block_number(); @@ -555,34 +511,8 @@ pub mod pallet { updated = true; } - // Optionally extends whitelisted code_ids. - match append_code_ids { - // Adding given destination set to voucher, - // if it has destinations limit. - Some(Some(mut extra_code_ids)) if voucher.permissions.code_ids.is_some() => { - let code_ids = voucher - .permissions - .code_ids - .as_mut() - .expect("Infallible; qed"); - let initial_len = code_ids.len(); - - code_ids.append(&mut extra_code_ids); - - ensure!( - code_ids.len() <= T::MaxCodeIdsAmount::get().into(), - Error::::MaxCodeIdsLimitExceeded - ); - - updated |= code_ids.len() != initial_len; - } - - // Extending vouchers to any CodeId. - Some(None) => updated |= voucher.permissions.code_ids.take().is_some(), - - // Noop. - _ => (), - } + // extend permissions + updated |= voucher.permissions.extend::(permissions_extend)?; // Check for Noop. if updated { diff --git a/pallets/gear-voucher/src/tests.rs b/pallets/gear-voucher/src/tests.rs index 0fd9a962ad8..0d81d073178 100644 --- a/pallets/gear-voucher/src/tests.rs +++ b/pallets/gear-voucher/src/tests.rs @@ -22,6 +22,7 @@ use super::*; use crate::mock::*; use common::Origin; use frame_support::{assert_noop, assert_ok, assert_storage_noop}; +use gear_core::ids::{CodeId, ProgramId}; use primitive_types::H256; use sp_runtime::traits::{One, Zero}; use utils::{DEFAULT_BALANCE, DEFAULT_PERMISSIONS, DEFAULT_VALIDITY}; @@ -474,14 +475,17 @@ fn voucher_update_works() { Some(ALICE), // balance top up Some(0), - // extra programs - Some(Some([program_id].into())), - // forbid code uploading (already forbidden) - Some(false), // prolong duration Some(0), - // extra code_id - Some(Some([code_id].into())) + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: Some(Some([program_id].into())), + // allow code uploading + code_uploading: Some(false), + // extra code_id + append_code_ids: Some(Some([code_id].into())), + } ))); assert_ok!(Voucher::update( @@ -492,14 +496,17 @@ fn voucher_update_works() { Some(BOB), // balance top up Some(balance_top_up), - // extra programs - Some(Some([new_program_id].into())), - // allow code uploading - Some(true), // prolong duration Some(duration_prolong), - // extra code_id - Some(Some([new_code_id].into())) + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: Some(Some([new_program_id].into())), + // allow code uploading + code_uploading: Some(true), + // extra code_id + append_code_ids: Some(Some([new_code_id].into())), + } )); System::assert_has_event( @@ -546,14 +553,17 @@ fn voucher_update_works() { None, // balance top up None, - // extra programs - Some(None), - // code uploading - None, // prolong duration None, - // extra code_id - Some(None) + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: Some(None), + // allow code uploading + code_uploading: None, + // extra code_id + append_code_ids: Some(None), + } )); System::assert_has_event( @@ -584,14 +594,17 @@ fn voucher_update_works() { None, // balance top up None, - // extra programs - Some(Some([program_id].into())), - // code uploading - Some(true), // prolong duration None, - // extra code_id - Some(Some([code_id].into())), + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: Some(Some([program_id].into())), + // allow code uploading + code_uploading: Some(true), + // extra code_id + append_code_ids: Some(Some([code_id].into())), + } ))); let huge_block = 10_000_000_000; @@ -606,14 +619,10 @@ fn voucher_update_works() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration Some(duration_prolong), - // extra code_id - None + // extend permissions + None.into(), )); let voucher = Vouchers::::get(BOB, voucher_id).expect("Failed to get voucher"); @@ -636,14 +645,10 @@ fn voucher_update_works() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration Some(valid_prolong + 1), - // extra code_id - None + // extend permissions + None.into(), ), Error::::DurationOutOfBounds ); @@ -656,14 +661,10 @@ fn voucher_update_works() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration Some(valid_prolong), - // extra code_id - None + // extend permissions + None.into(), ),); }); } @@ -694,14 +695,10 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration None, - // extra code_id - None + // extend permissions + None.into(), ), Error::::InexistentVoucher ); @@ -716,14 +713,10 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration None, - // extra code_id - None + // extend permissions + None.into(), ), Error::::BadOrigin ); @@ -738,14 +731,10 @@ fn voucher_update_err_cases() { None, // balance top up Some(100_000_000_000_000), - // extra programs - None, - // code uploading - None, // prolong duration None, - // extra code_id - None + // extend permissions + None.into(), ), Error::::BalanceTransfer ); @@ -764,14 +753,17 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - Some(Some(set)), - // code uploading - None, // prolong duration None, - // extra code_id - None + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: Some(Some(set)), + // allow code uploading + code_uploading: None, + // extra code_id + append_code_ids: None, + } ), Error::::MaxProgramsLimitExceeded ); @@ -786,14 +778,17 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - None, - // code uploading - Some(false), // prolong duration None, - // extra code_id - None + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: None, + // allow code uploading + code_uploading: Some(false), + // extra code_id + append_code_ids: None, + } ), Error::::CodeUploadingEnabled ); @@ -808,14 +803,10 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration Some(MaxVoucherDuration::get().saturating_sub(DEFAULT_VALIDITY)), - // extra code_id - None + // extend permissions + None.into(), ), Error::::DurationOutOfBounds ); @@ -834,14 +825,17 @@ fn voucher_update_err_cases() { None, // balance top up None, - // extra programs - None, - // code uploading - None, // prolong duration None, - // extra code_id - Some(Some(set)), + // extend permissions + VoucherPermissionsExtend { + // extra programs + append_programs: None, + // allow code uploading + code_uploading: None, + // extra code_id + append_code_ids: Some(Some(set)), + } ), Error::::MaxCodeIdsLimitExceeded ); From f3467efa359935177655d494905263679c57fc73 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 22 Aug 2024 15:46:32 +0200 Subject: [PATCH 11/22] wip: gsdk update metadata & tests --- gclient/src/api/voucher.rs | 50 +++--------- gclient/tests/voucher.rs | 8 +- gsdk/src/metadata/generated.rs | 36 +++++---- gsdk/src/metadata/impls.rs | 134 ++++++++++++++++++++++++++++++++- gsdk/src/signer/calls.rs | 53 ++----------- gsdk/tests/voucher.rs | 20 ++--- 6 files changed, 185 insertions(+), 116 deletions(-) diff --git a/gclient/src/api/voucher.rs b/gclient/src/api/voucher.rs index 9babd056f4a..c3e08416c7e 100644 --- a/gclient/src/api/voucher.rs +++ b/gclient/src/api/voucher.rs @@ -22,7 +22,10 @@ use gear_core::ids::ProgramId; use gsdk::{ ext::sp_core::H256, metadata::{ - runtime_types::pallet_gear_voucher::{internal::VoucherId, pallet::Event as VoucherEvent}, + runtime_types::pallet_gear_voucher::{ + internal::{VoucherId, VoucherPermissions, VoucherPermissionsExtend}, + pallet::Event as VoucherEvent, + }, Event, }, }; @@ -30,33 +33,22 @@ use gsdk::{ impl GearApi { /// Issue a new voucher. /// - /// Returns issued `voucher_id` at specified `at_block_hash`. + /// See [`pallet_gear_voucher::pallet::Call::issue`] /// - /// Arguments: - /// * spender: user id that is eligible to use the voucher; - /// * balance: voucher balance could be used for transactions fees and gas; - /// * programs: pool of programs spender can interact with, if None - means - /// any program, limited by Config param; - /// * code_uploading: allow voucher to be used as payer for `upload_code` - /// transactions fee; - /// * duration: amount of blocks voucher could be used by spender and - /// couldn't be revoked by owner. Must be out in [MinDuration; - /// MaxDuration] constants. Expiration block of the voucher calculates as: - /// current bn (extrinsic exec bn) + duration + 1. + /// Returns issued `voucher_id` at specified `at_block_hash`. pub async fn issue_voucher( &self, spender: ProgramId, balance: u128, - programs: Option>, - code_uploading: bool, duration: u32, + permissions: VoucherPermissions, ) -> Result<(VoucherId, H256)> { let spender: [u8; 32] = spender.into(); let tx = self .0 .calls - .issue_voucher(spender, balance, programs, code_uploading, duration) + .issue_voucher(spender, balance, duration, permissions) .await?; for event in tx.wait_for_success().await?.iter() { @@ -72,27 +64,9 @@ impl GearApi { /// Update existing voucher. /// - /// This extrinsic updates existing voucher: it can only extend vouchers - /// rights in terms of balance, validity or programs to interact pool. + /// See [`pallet_gear_voucher::pallet::Call::update`] /// /// Can only be called by the voucher owner. - /// - /// Arguments: - /// * spender: account id of the voucher spender; - /// * voucher_id: voucher id to be updated; - /// * move_ownership: optionally moves ownership to another account; - /// * balance_top_up: optionally top ups balance of the voucher from - /// origins balance; - /// * append_programs: optionally extends pool of programs by - /// `Some(programs_set)` passed or allows it to interact with any program - /// by `None` passed; - /// * code_uploading: optionally allows voucher to be used to pay fees for - /// `upload_code` extrinsics; - /// * prolong_duration: optionally increases expiry block number. If voucher - /// is expired, prolongs since current bn. Validity prolongation (since - /// current block number for expired or since storage written expiry) - /// should be in [MinDuration; MaxDuration], in other words voucher - /// couldn't have expiry greater than current block number + MaxDuration. #[allow(clippy::too_many_arguments)] pub async fn update_voucher( &self, @@ -100,9 +74,8 @@ impl GearApi { voucher_id: VoucherId, move_ownership: Option, balance_top_up: Option, - append_programs: Option>>, - code_uploading: Option, prolong_duration: u32, + permissions_extnend: VoucherPermissionsExtend, ) -> Result<(VoucherId, H256)> { let spender: [u8; 32] = spender.into(); let move_ownership: Option<[u8; 32]> = move_ownership.map(|v| v.into()); @@ -115,9 +88,8 @@ impl GearApi { voucher_id, move_ownership, balance_top_up, - append_programs, - code_uploading, prolong_duration, + permissions_extnend, ) .await?; diff --git a/gclient/tests/voucher.rs b/gclient/tests/voucher.rs index ec358674af6..466563bb73c 100644 --- a/gclient/tests/voucher.rs +++ b/gclient/tests/voucher.rs @@ -21,6 +21,7 @@ use demo_custom::{InitMessage, WASM_BINARY}; use gclient::{EventProcessor, GearApi}; use gear_core::ids::ProgramId; +use gsdk::metadata::runtime_types::pallet_gear_voucher::internal::VoucherPermissions; use parity_scale_codec::Encode; #[tokio::test] @@ -42,7 +43,12 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> // Issue voucher let (voucher_id, ..) = api - .issue_voucher(actor_id, voucher_initial_balance, None, true, 100) + .issue_voucher( + actor_id, + voucher_initial_balance, + 100, + VoucherPermissions::all(), + ) .await?; // Upload code with voucher diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index d4c73feac10..ccb8542d9ad 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -3015,14 +3015,31 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct VoucherInfo<_0, _1> { pub owner: _0, + pub expiry: _1, + pub permissions: + runtime_types::pallet_gear_voucher::internal::VoucherPermissions, + } + #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] + pub struct VoucherPermissions { pub programs: ::core::option::Option< ::std::vec::Vec, >, pub code_uploading: ::core::primitive::bool, - pub expiry: _1, pub code_ids: ::core::option::Option<::std::vec::Vec>, } + #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] + pub struct VoucherPermissionsExtend { + pub append_programs: ::core::option::Option< + ::core::option::Option< + ::std::vec::Vec, + >, + >, + pub code_uploading: ::core::option::Option<::core::primitive::bool>, + pub append_code_ids: ::core::option::Option< + ::core::option::Option<::std::vec::Vec>, + >, + } } pub mod pallet { use super::runtime_types; @@ -3034,14 +3051,9 @@ pub mod runtime_types { issue { spender: ::subxt::utils::AccountId32, balance: ::core::primitive::u128, - programs: ::core::option::Option< - ::std::vec::Vec, - >, - code_uploading: ::core::primitive::bool, duration: ::core::primitive::u32, - code_ids: ::core::option::Option< - ::std::vec::Vec, - >, + permissions: + runtime_types::pallet_gear_voucher::internal::VoucherPermissions, }, #[codec(index = 1)] #[doc = "See [`Pallet::call`]."] @@ -3064,13 +3076,9 @@ pub mod runtime_types { voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, move_ownership: ::core::option::Option<::subxt::utils::AccountId32>, balance_top_up: ::core::option::Option<::core::primitive::u128>, - append_programs: ::core::option::Option< - ::core::option::Option< - ::std::vec::Vec, - >, - >, - code_uploading: ::core::option::Option<::core::primitive::bool>, prolong_duration: ::core::option::Option<::core::primitive::u32>, + permissions_extend: + runtime_types::pallet_gear_voucher::internal::VoucherPermissionsExtend, }, #[codec(index = 5)] #[doc = "See [`Pallet::decline`]."] diff --git a/gsdk/src/metadata/impls.rs b/gsdk/src/metadata/impls.rs index 58daffd99f9..3c53897e791 100644 --- a/gsdk/src/metadata/impls.rs +++ b/gsdk/src/metadata/impls.rs @@ -27,13 +27,19 @@ use super::{ gear_core_errors as generated_core_errors, gprimitives as generated_ids, pallet_balances::pallet::Call as BalancesCall, pallet_gear::pallet::Call as GearCall, - pallet_gear_voucher::internal::{PrepaidCall, VoucherId}, + pallet_gear_voucher::internal::{ + PrepaidCall, VoucherId, VoucherPermissions, VoucherPermissionsExtend, + }, pallet_sudo::pallet::Call as SudoCall, }, vara_runtime::{RuntimeCall, RuntimeEvent}, }; use core::ops::{Index, IndexMut}; -use gear_core::{ids, message, message::UserMessage}; +use gear_core::{ + ids::{self, *}, + message::{self, UserMessage}, + program, +}; use parity_scale_codec::{Decode, Encode}; use subxt::{dynamic::Value, utils::MultiAddress}; @@ -432,3 +438,127 @@ impl Convert> for Option> { } } } + +impl VoucherPermissions { + pub const fn none() -> Self { + Self { + programs: Some(Vec::new()), + code_uploading: false, + code_ids: Some(Vec::new()), + } + } + + pub const fn all() -> Self { + Self { + programs: None, + code_uploading: true, + code_ids: None, + } + } + + pub fn allow_code_uploading(self, code_uploading: bool) -> Self { + Self { + code_uploading, + ..self + } + } + + pub fn allow_programs(self, programs: Option>) -> Self { + let programs = programs.map(|v| v.into_iter().map(|id| id.into()).collect()); + Self { programs, ..self } + } + + pub fn allow_code_ids(self, code_ids: Option>) -> Self { + let code_ids = code_ids.map(|v| v.into_iter().map(|id| id.into()).collect()); + Self { code_ids, ..self } + } +} + +impl Default for VoucherPermissions { + /// Default permissions don't allow anything + fn default() -> Self { + Self::none() + } +} + +impl From for Value { + fn from(value: VoucherPermissions) -> Self { + let programs_value = value + .programs + .map(|vec| { + Value::unnamed_composite( + vec.into_iter() + .map(|v| Value::from_bytes(v.0)) + .collect::>(), + ) + }) + .convert(); + let code_ids_value = value + .code_ids + .map(|vec| { + Value::unnamed_composite( + vec.into_iter() + .map(|v| Value::from_bytes(v.0)) + .collect::>(), + ) + }) + .convert(); + + Value::named_composite([ + ("programs", programs_value), + ("code_uploading", Value::bool(value.code_uploading)), + ("code_ids", code_ids_value), + ]) + } +} + +impl Default for VoucherPermissionsExtend { + fn default() -> Self { + Self { + append_programs: Default::default(), + code_uploading: Default::default(), + append_code_ids: Default::default(), + } + } +} + +impl From for Value { + fn from(value: VoucherPermissionsExtend) -> Self { + let append_programs_value = value + .append_programs + .map(|o| { + o.map(|vec| { + Value::unnamed_composite( + vec.into_iter() + .map(|v| Value::from_bytes(v.0)) + .collect::>(), + ) + }) + .convert() + }) + .convert(); + + let append_code_ids_value = value + .append_code_ids + .map(|o| { + o.map(|vec| { + Value::unnamed_composite( + vec.into_iter() + .map(|v| Value::from_bytes(v.0)) + .collect::>(), + ) + }) + .convert() + }) + .convert(); + + Value::named_composite([ + ("append_programs", append_programs_value), + ( + "code_uploading", + value.code_uploading.map(Value::bool).convert(), + ), + ("append_code_ids", append_code_ids_value), + ]) + } +} diff --git a/gsdk/src/signer/calls.rs b/gsdk/src/signer/calls.rs index 5858804fef6..5d533ddf1a2 100644 --- a/gsdk/src/signer/calls.rs +++ b/gsdk/src/signer/calls.rs @@ -23,7 +23,9 @@ use crate::{ metadata::{ calls::{BalancesCall, GearCall, GearVoucherCall, SudoCall, UtilityCall}, runtime_types::{ - pallet_gear_voucher::internal::{PrepaidCall, VoucherId}, + pallet_gear_voucher::internal::{ + PrepaidCall, VoucherId, VoucherPermissions, VoucherPermissionsExtend, + }, sp_weights::weight_v2::Weight, }, vara_runtime::RuntimeCall, @@ -245,32 +247,17 @@ impl SignerCalls { &self, spender: impl Into, balance: u128, - programs: Option>, - code_uploading: bool, duration: u32, - code_ids: Option>, + permissions: VoucherPermissions, ) -> Result { - let programs_value = programs - .map(|vec| { - Value::unnamed_composite(vec.into_iter().map(Value::from_bytes).collect::>()) - }) - .convert(); - let code_ids_value = code_ids - .map(|vec| { - Value::unnamed_composite(vec.into_iter().map(Value::from_bytes).collect::>()) - }) - .convert(); - self.0 .run_tx( GearVoucherCall::Issue, vec![ Value::from_bytes(spender.into()), Value::u128(balance), - programs_value, - Value::bool(code_uploading), Value::from(duration), - code_ids_value, + Value::from(permissions), ], ) .await @@ -284,33 +271,9 @@ impl SignerCalls { voucher_id: VoucherId, move_ownership: Option>, balance_top_up: Option, - append_programs: Option>>, - code_uploading: Option, prolong_duration: u32, - append_code_ids: Option>>, + permissions_extend: VoucherPermissionsExtend, ) -> Result { - let append_programs_value = append_programs - .map(|o| { - o.map(|vec| { - Value::unnamed_composite( - vec.into_iter().map(Value::from_bytes).collect::>(), - ) - }) - .convert() - }) - .convert(); - - let append_code_ids_value = append_code_ids - .map(|o| { - o.map(|vec| { - Value::unnamed_composite( - vec.into_iter().map(Value::from_bytes).collect::>(), - ) - }) - .convert() - }) - .convert(); - self.0 .run_tx( GearVoucherCall::Update, @@ -321,10 +284,8 @@ impl SignerCalls { .map(|v| Value::from_bytes(v.into())) .convert(), balance_top_up.map(Value::u128).convert(), - append_programs_value, - code_uploading.map(Value::bool).convert(), Value::from(prolong_duration), - append_code_ids_value, + Value::from(permissions_extend), ], ) .await diff --git a/gsdk/tests/voucher.rs b/gsdk/tests/voucher.rs index ccf966cf260..e3832a8183f 100644 --- a/gsdk/tests/voucher.rs +++ b/gsdk/tests/voucher.rs @@ -18,8 +18,8 @@ use gear_core::ids::{prelude::CodeIdExt, CodeId, MessageId, ProgramId}; use gsdk::{ - metadata::runtime_types::pallet_gear_voucher::internal::VoucherId, Api, Event, Result, - TxInBlock, + metadata::runtime_types::pallet_gear_voucher::internal::{VoucherId, VoucherPermissions}, + Api, Event, Result, TxInBlock, }; use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; @@ -44,10 +44,8 @@ async fn test_issue_voucher() -> Result<()> { .issue_voucher( account_id.clone(), voucher_initial_balance, - None, - false, 100, - None, + VoucherPermissions::none(), ) .await?; @@ -78,10 +76,8 @@ async fn test_decline_revoke_voucher() -> Result<()> { .issue_voucher( account_id.clone(), voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::none(), ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; @@ -122,10 +118,8 @@ async fn test_upload_code_with_voucher() -> Result<()> { .issue_voucher( account_id.clone(), voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::all(), ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; @@ -172,10 +166,8 @@ async fn test_send_message_with_voucher() -> Result<()> { .issue_voucher( account_id.clone(), voucher_initial_balance, - None, - true, 100, - None, + VoucherPermissions::all(), ) .await?; let voucher_id = get_issued_voucher_id(tx).await?; From 36f8689d569c777616459cf751b996c5a7224515 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 22 Aug 2024 18:28:53 +0200 Subject: [PATCH 12/22] gsdk create_program_with_voucher and tests --- gsdk/src/signer/calls.rs | 37 +++++++++++++++-- gsdk/tests/voucher.rs | 86 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 115 insertions(+), 8 deletions(-) diff --git a/gsdk/src/signer/calls.rs b/gsdk/src/signer/calls.rs index c75f9005e31..6f0a101cf56 100644 --- a/gsdk/src/signer/calls.rs +++ b/gsdk/src/signer/calls.rs @@ -316,7 +316,7 @@ impl SignerCalls { .await } - /// `pallet_gear_voucher::call` + /// `pallet_gear_voucher::call` `PrepaidCall::UploadCode` pub async fn upload_code_with_voucher( &self, voucher_id: VoucherId, @@ -332,7 +332,36 @@ impl SignerCalls { .await } - /// `pallet_gear_voucher::call` + /// `pallet_gear_voucher::call` `PrepaidCall::CreateProgram` + #[allow(clippy::too_many_arguments)] + pub async fn create_program_with_voucher( + &self, + voucher_id: VoucherId, + code_id: CodeId, + salt: Vec, + payload: Vec, + gas_limit: u64, + value: u128, + keep_alive: bool, + ) -> Result { + let call = PrepaidCall::::CreateProgram { + code_id: code_id.into(), + salt, + payload, + gas_limit, + value, + keep_alive, + }; + + self.0 + .run_tx( + GearVoucherCall::Call, + vec![Value::from_bytes(voucher_id.0), call.into()], + ) + .await + } + + /// `pallet_gear_voucher::call` `PrepaidCall::SendMessage` pub async fn send_message_with_voucher( &self, voucher_id: VoucherId, @@ -358,7 +387,7 @@ impl SignerCalls { .await } - /// `pallet_gear_voucher::call` + /// `pallet_gear_voucher::call` `PrepaidCall::SendReply` pub async fn send_reply_with_voucher( &self, voucher_id: VoucherId, @@ -384,7 +413,7 @@ impl SignerCalls { .await } - /// `pallet_gear_voucher::call` + /// `pallet_gear_voucher::call` `PrepaidCall::DeclineVoucher` pub async fn decline_voucher_with_voucher(&self, voucher_id: VoucherId) -> Result { let call = PrepaidCall::::DeclineVoucher; diff --git a/gsdk/tests/voucher.rs b/gsdk/tests/voucher.rs index e3832a8183f..0b4e7c951ae 100644 --- a/gsdk/tests/voucher.rs +++ b/gsdk/tests/voucher.rs @@ -19,10 +19,11 @@ use gear_core::ids::{prelude::CodeIdExt, CodeId, MessageId, ProgramId}; use gsdk::{ metadata::runtime_types::pallet_gear_voucher::internal::{VoucherId, VoucherPermissions}, - Api, Event, Result, TxInBlock, + Api, Error, Event, Result, TxInBlock, }; use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; +use subxt::Error as SubxtError; use utils::{alice_account_id, dev_node}; mod utils; @@ -149,6 +150,7 @@ async fn test_upload_code_with_voucher() -> Result<()> { Ok(()) } +/// Upload code, Create program and Send messages with voucher #[tokio::test] async fn test_send_message_with_voucher() -> Result<()> { // arrange @@ -180,14 +182,22 @@ async fn test_send_message_with_voucher() -> Result<()> { .await?; let code_id = get_last_code_id(tx).await?; - // 3. calculate create gas and create program + // 3. calculate create gas and create program with voucher let gas_info = signer .rpc .calculate_create_gas(None, code_id, vec![], 0, true, None) .await?; let tx = signer .calls - .create_program(code_id, vec![], vec![], gas_info.min_limit, 0) + .create_program_with_voucher( + voucher_id.clone(), + code_id, + vec![], + vec![], + gas_info.min_limit, + 0, + false, + ) .await?; let program_id = get_last_program_id(tx).await?; @@ -224,6 +234,75 @@ async fn test_send_message_with_voucher() -> Result<()> { Ok(()) } +#[tokio::test] +async fn test_voucher_balance_transfer_error() -> Result<()> { + // arrange + let node = dev_node(); + + let signer = Api::new(node.ws().as_str()) + .await? + .signer("//Alice", None)?; + let account_id = signer.account_id(); + + // 1. issue voucher + let tx = signer + .calls + .issue_voucher( + account_id.clone(), + 100_000_000_000_000_000_000, + 100, + VoucherPermissions::all(), + ) + .await?; + + let error = get_issued_voucher_id(tx) + .await + .expect_err("Error: Subxt(Runtime(Module(ModuleError())))"); + + assert!(matches!( + error, + Error::Subxt(SubxtError::Runtime(subxt::error::DispatchError::Module( + err + ))) if err.to_string() == "GearVoucher::BalanceTransfer".to_string() + )); + Ok(()) +} + +#[tokio::test] +async fn test_voucher_duration_error() -> Result<()> { + // arrange + let node = dev_node(); + + let signer = Api::new(node.ws().as_str()) + .await? + .signer("//Alice", None)?; + let account_id = signer.account_id(); + let voucher_initial_balance = 100_000_000_000_000; + + // 1. issue voucher + let tx = signer + .calls + .issue_voucher( + account_id.clone(), + voucher_initial_balance, + 0, + VoucherPermissions::all(), + ) + .await?; + + let error = get_issued_voucher_id(tx).await.expect_err( + "Error: Subxt(Runtime(Module(ModuleError())))", + ); + + assert!(matches!( + error, + Error::Subxt(SubxtError::Runtime(subxt::error::DispatchError::Module( + err + ))) if err.to_string() == "GearVoucher::DurationOutOfBounds".to_string() + )); + Ok(()) +} + async fn get_issued_voucher_id(tx: TxInBlock) -> Result { for event in tx.wait_for_success().await?.iter() { if let Event::GearVoucher( @@ -233,7 +312,6 @@ async fn get_issued_voucher_id(tx: TxInBlock) -> Result { }, ) = event?.as_root_event::()? { - dbg!(&voucher_id); return Ok(voucher_id); } } From 2b5fcff554b4cc25c0bc9e699c4043bc845985aa Mon Sep 17 00:00:00 2001 From: vobradovich Date: Fri, 23 Aug 2024 12:15:18 +0200 Subject: [PATCH 13/22] fix generated & docs --- gclient/src/api/voucher.rs | 25 +- gsdk/src/metadata/generated.rs | 1362 +++++++++++++++++++------------- 2 files changed, 815 insertions(+), 572 deletions(-) diff --git a/gclient/src/api/voucher.rs b/gclient/src/api/voucher.rs index c3e08416c7e..f3e9187da22 100644 --- a/gclient/src/api/voucher.rs +++ b/gclient/src/api/voucher.rs @@ -33,7 +33,17 @@ use gsdk::{ impl GearApi { /// Issue a new voucher. /// - /// See [`pallet_gear_voucher::pallet::Call::issue`] + /// Arguments: + /// * spender: user id that is eligible to use the voucher; + /// * balance: voucher balance could be used for transactions fees and + /// gas; + /// * programs: pool of programs spender can interact with, if None - + /// means + /// * duration: amount of blocks voucher could be used by spender and + /// couldn't be revoked by owner. Must be out in [MinDuration; + /// MaxDuration] constants. Expiration block of the voucher calculates as: + /// current bn (extrinsic exec bn) + duration + 1. + /// * permissions: voucher permissions /// /// Returns issued `voucher_id` at specified `at_block_hash`. pub async fn issue_voucher( @@ -64,7 +74,18 @@ impl GearApi { /// Update existing voucher. /// - /// See [`pallet_gear_voucher::pallet::Call::update`] + /// Arguments: + /// * spender: account id of the voucher spender; + /// * voucher_id: voucher id to be updated; + /// * move_ownership: optionally moves ownership to another account; + /// * balance_top_up: optionally top ups balance of the voucher from + /// origins balance; + /// * prolong_duration: optionally increases expiry block number. If voucher + /// is expired, prolongs since current bn. Validity prolongation (since + /// current block number for expired or since storage written expiry) + /// should be in [MinDuration; MaxDuration], in other words voucher + /// couldn't have expiry greater than current block number + MaxDuration. + /// * permissions_extnend: optionally extned perimissions for voucher /// /// Can only be called by the voucher owner. #[allow(clippy::too_many_arguments)] diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index ccb8542d9ad..84d78a863a0 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -31,17 +31,19 @@ pub mod runtime_types { pub mod bounded_btree_map { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] - pub struct BoundedBTreeMap<_0, _1>(pub ::subxt::utils::KeyedVec<_0, _1>); + pub struct BoundedBTreeMap<_0, _1>( + pub ::subxt::ext::subxt_core::utils::KeyedVec<_0, _1>, + ); } pub mod bounded_vec { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] - pub struct BoundedVec<_0>(pub ::std::vec::Vec<_0>); + pub struct BoundedVec<_0>(pub ::subxt::ext::subxt_core::alloc::vec::Vec<_0>); } pub mod weak_bounded_vec { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] - pub struct WeakBoundedVec<_0>(pub ::std::vec::Vec<_0>); + pub struct WeakBoundedVec<_0>(pub ::subxt::ext::subxt_core::alloc::vec::Vec<_0>); } } pub mod finality_grandpa { @@ -122,7 +124,7 @@ pub mod runtime_types { pub enum Bounded<_0, _1> { #[codec(index = 0)] Legacy { - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 1)] Inline( @@ -132,7 +134,7 @@ pub mod runtime_types { ), #[codec(index = 2)] Lookup { - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, len: ::core::primitive::u32, }, __Ignore(::core::marker::PhantomData<(_0, _1)>), @@ -155,7 +157,7 @@ pub mod runtime_types { pub mod fungible { use super::runtime_types; #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -262,7 +264,7 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::remark`]."] remark { - remark: ::std::vec::Vec<::core::primitive::u8>, + remark: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::set_heap_pages`]."] @@ -270,36 +272,38 @@ pub mod runtime_types { #[codec(index = 2)] #[doc = "See [`Pallet::set_code`]."] set_code { - code: ::std::vec::Vec<::core::primitive::u8>, + code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 3)] #[doc = "See [`Pallet::set_code_without_checks`]."] set_code_without_checks { - code: ::std::vec::Vec<::core::primitive::u8>, + code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 4)] #[doc = "See [`Pallet::set_storage`]."] set_storage { - items: ::std::vec::Vec<( - ::std::vec::Vec<::core::primitive::u8>, - ::std::vec::Vec<::core::primitive::u8>, + items: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, )>, }, #[codec(index = 5)] #[doc = "See [`Pallet::kill_storage`]."] kill_storage { - keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, + keys: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + >, }, #[codec(index = 6)] #[doc = "See [`Pallet::kill_prefix`]."] kill_prefix { - prefix: ::std::vec::Vec<::core::primitive::u8>, + prefix: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, subkeys: ::core::primitive::u32, }, #[codec(index = 7)] #[doc = "See [`Pallet::remark_with_event`]."] remark_with_event { - remark: ::std::vec::Vec<::core::primitive::u8>, + remark: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -348,18 +352,18 @@ pub mod runtime_types { #[codec(index = 3)] #[doc = "A new account was created."] NewAccount { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 4)] #[doc = "An account was reaped."] KilledAccount { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 5)] #[doc = "On on-chain remark happened."] Remarked { - sender: ::subxt::utils::AccountId32, - hash: ::subxt::utils::H256, + sender: ::subxt::ext::subxt_core::utils::AccountId32, + hash: ::subxt::ext::subxt_core::utils::H256, }, } } @@ -375,13 +379,13 @@ pub mod runtime_types { pub struct EventRecord<_0, _1> { pub phase: runtime_types::frame_system::Phase, pub event: _0, - pub topics: ::std::vec::Vec<_1>, + pub topics: ::subxt::ext::subxt_core::alloc::vec::Vec<_1>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct LastRuntimeUpgradeInfo { #[codec(compact)] pub spec_version: ::core::primitive::u32, - pub spec_name: ::std::string::String, + pub spec_name: ::subxt::ext::subxt_core::alloc::string::String, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum Phase { @@ -636,7 +640,7 @@ pub mod runtime_types { } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct CodeMetadata { - pub author: ::subxt::utils::H256, + pub author: ::subxt::ext::subxt_core::utils::H256, #[codec(compact)] pub block_number: ::core::primitive::u32, } @@ -654,7 +658,7 @@ pub mod runtime_types { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct LimitedVec<_0, _1>( - pub ::std::vec::Vec<_0>, + pub ::subxt::ext::subxt_core::alloc::vec::Vec<_0>, #[codec(skip)] pub ::core::marker::PhantomData<_1>, ); } @@ -677,13 +681,14 @@ pub mod runtime_types { Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode, )] pub struct InstrumentedCode { - pub code: ::std::vec::Vec<::core::primitive::u8>, + pub code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, pub original_code_len: ::core::primitive::u32, - pub exports: - ::std::vec::Vec, + pub exports: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gear_core::message::DispatchKind, + >, pub static_pages: runtime_types::gear_core::pages::PagesAmount, pub stack_end: - ::core::option::Option, + ::core::option::Option, pub instantiated_section_sizes: runtime_types::gear_core::code::instrumented::InstantiatedSectionSizes, pub version: ::core::primitive::u32, @@ -736,7 +741,7 @@ pub mod runtime_types { Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode, )] pub struct ContextStore { - pub outgoing: ::subxt::utils::KeyedVec< + pub outgoing: ::subxt::ext::subxt_core::utils::KeyedVec< ::core::primitive::u32, ::core::option::Option< runtime_types::gear_core::buffer::LimitedVec< @@ -751,7 +756,9 @@ pub mod runtime_types { runtime_types::gear_core::message::PayloadSizeError, >, >, - pub initialized: ::std::vec::Vec, + pub initialized: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::ActorId, + >, pub reservation_nonce: runtime_types::gear_core::reservation::ReservationNonce, pub system_reservation: ::core::option::Option<::core::primitive::u64>, @@ -845,7 +852,7 @@ pub mod runtime_types { pub mod pages { use super::runtime_types; #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -853,15 +860,7 @@ pub mod runtime_types { )] pub struct Page(pub ::core::primitive::u32); #[derive( - ::subxt::ext::codec::CompactAs, - Debug, - crate::gp::Decode, - crate::gp::DecodeAsType, - crate::gp::Encode, - )] - pub struct Page2(pub ::core::primitive::u32); - #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -872,7 +871,7 @@ pub mod runtime_types { pub mod percent { use super::runtime_types; #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -886,19 +885,20 @@ pub mod runtime_types { pub struct ActiveProgram<_0> { pub allocations_tree_len: ::core::primitive::u32, pub memory_infix: runtime_types::gear_core::program::MemoryInfix, - pub gas_reservation_map: ::subxt::utils::KeyedVec< + pub gas_reservation_map: ::subxt::ext::subxt_core::utils::KeyedVec< runtime_types::gprimitives::ReservationId, runtime_types::gear_core::reservation::GasReservationSlot, >, - pub code_hash: ::subxt::utils::H256, - pub code_exports: - ::std::vec::Vec, + pub code_hash: ::subxt::ext::subxt_core::utils::H256, + pub code_exports: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gear_core::message::DispatchKind, + >, pub static_pages: runtime_types::gear_core::pages::PagesAmount, pub state: runtime_types::gear_core::program::ProgramState, pub expiration_block: _0, } #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -933,7 +933,7 @@ pub mod runtime_types { pub finish: ::core::primitive::u32, } #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -1039,7 +1039,7 @@ pub mod runtime_types { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct IntervalsTree<_0> { - pub inner: ::subxt::utils::KeyedVec<_0, _0>, + pub inner: ::subxt::ext::subxt_core::utils::KeyedVec<_0, _0>, } } } @@ -1053,7 +1053,7 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::report_equivocation`]."] report_equivocation { - equivocation_proof: ::std::boxed::Box< + equivocation_proof: ::subxt::ext::subxt_core::alloc::boxed::Box< runtime_types::sp_consensus_slots::EquivocationProof< runtime_types::sp_runtime::generic::header::Header< ::core::primitive::u32, @@ -1066,7 +1066,7 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "See [`Pallet::report_equivocation_unsigned`]."] report_equivocation_unsigned { - equivocation_proof: ::std::boxed::Box< + equivocation_proof: ::subxt::ext::subxt_core::alloc::boxed::Box< runtime_types::sp_consensus_slots::EquivocationProof< runtime_types::sp_runtime::generic::header::Header< ::core::primitive::u32, @@ -1106,8 +1106,8 @@ pub mod runtime_types { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct Bag { - pub head: ::core::option::Option<::subxt::utils::AccountId32>, - pub tail: ::core::option::Option<::subxt::utils::AccountId32>, + pub head: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, + pub tail: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum ListError { @@ -1122,9 +1122,9 @@ pub mod runtime_types { } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct Node { - pub id: ::subxt::utils::AccountId32, - pub prev: ::core::option::Option<::subxt::utils::AccountId32>, - pub next: ::core::option::Option<::subxt::utils::AccountId32>, + pub id: ::subxt::ext::subxt_core::utils::AccountId32, + pub prev: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, + pub next: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, pub bag_upper: ::core::primitive::u64, pub score: ::core::primitive::u64, } @@ -1137,18 +1137,30 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::rebag`]."] rebag { - dislocated: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + dislocated: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::put_in_front_of`]."] put_in_front_of { - lighter: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + lighter: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 2)] #[doc = "See [`Pallet::put_in_front_of_other`]."] put_in_front_of_other { - heavier: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - lighter: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + heavier: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + lighter: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -1164,14 +1176,14 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "Moved an account from one bag to another."] Rebagged { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, from: ::core::primitive::u64, to: ::core::primitive::u64, }, #[codec(index = 1)] #[doc = "Updated the score of some account to the given amount."] ScoreUpdated { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, new_score: ::core::primitive::u64, }, } @@ -1187,46 +1199,69 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::transfer_allow_death`]."] transfer_allow_death { - dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + dest: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] value: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "See [`Pallet::force_transfer`]."] force_transfer { - source: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + source: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + dest: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] value: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "See [`Pallet::transfer_keep_alive`]."] transfer_keep_alive { - dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + dest: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] value: ::core::primitive::u128, }, #[codec(index = 4)] #[doc = "See [`Pallet::transfer_all`]."] transfer_all { - dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + dest: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, keep_alive: ::core::primitive::bool, }, #[codec(index = 5)] #[doc = "See [`Pallet::force_unreserve`]."] force_unreserve { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, amount: ::core::primitive::u128, }, #[codec(index = 6)] #[doc = "See [`Pallet::upgrade_accounts`]."] upgrade_accounts { - who: ::std::vec::Vec<::subxt::utils::AccountId32>, + who: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, }, #[codec(index = 8)] #[doc = "See [`Pallet::force_set_balance`]."] force_set_balance { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] new_free: ::core::primitive::u128, }, @@ -1271,47 +1306,47 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "An account was created with some free balance."] Endowed { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, free_balance: ::core::primitive::u128, }, #[codec(index = 1)] #[doc = "An account was removed whose balance was non-zero but below ExistentialDeposit,"] #[doc = "resulting in an outright loss."] DustLost { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "Transfer succeeded."] Transfer { - from: ::subxt::utils::AccountId32, - to: ::subxt::utils::AccountId32, + from: ::subxt::ext::subxt_core::utils::AccountId32, + to: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "A balance was set by root."] BalanceSet { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, free: ::core::primitive::u128, }, #[codec(index = 4)] #[doc = "Some balance was reserved (moved from free to reserved)."] Reserved { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 5)] #[doc = "Some balance was unreserved (moved from reserved to free)."] Unreserved { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 6)] #[doc = "Some balance was moved from the reserve of the first account to the second account."] #[doc = "Final argument indicates the destination balance type."] ReserveRepatriated { - from: ::subxt::utils::AccountId32, - to: ::subxt::utils::AccountId32, + from: ::subxt::ext::subxt_core::utils::AccountId32, + to: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, destination_status: runtime_types::frame_support::traits::tokens::misc::BalanceStatus, @@ -1319,48 +1354,50 @@ pub mod runtime_types { #[codec(index = 7)] #[doc = "Some amount was deposited (e.g. for transaction fees)."] Deposit { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 8)] #[doc = "Some amount was withdrawn from the account (e.g. for transaction fees)."] Withdraw { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 9)] #[doc = "Some amount was removed from the account (e.g. for misbehavior)."] Slashed { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 10)] #[doc = "Some amount was minted into an account."] Minted { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 11)] #[doc = "Some amount was burned from an account."] Burned { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 12)] #[doc = "Some amount was suspended from an account (it can be restored later)."] Suspended { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 13)] #[doc = "Some amount was restored into an account."] Restored { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 14)] #[doc = "An account was upgraded."] - Upgraded { who: ::subxt::utils::AccountId32 }, + Upgraded { + who: ::subxt::ext::subxt_core::utils::AccountId32, + }, #[codec(index = 15)] #[doc = "Total issuance was increased by `amount`, creating a credit to be balanced."] Issued { amount: ::core::primitive::u128 }, @@ -1370,25 +1407,25 @@ pub mod runtime_types { #[codec(index = 17)] #[doc = "Some balance was locked."] Locked { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 18)] #[doc = "Some balance was unlocked."] Unlocked { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 19)] #[doc = "Some balance was frozen."] Frozen { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 20)] #[doc = "Some balance was thawed."] Thawed { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, } @@ -1409,7 +1446,7 @@ pub mod runtime_types { pub reasons: runtime_types::pallet_balances::types::Reasons, } #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -1449,7 +1486,8 @@ pub mod runtime_types { propose_bounty { #[codec(compact)] value: ::core::primitive::u128, - description: ::std::vec::Vec<::core::primitive::u8>, + description: + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::approve_bounty`]."] @@ -1462,7 +1500,10 @@ pub mod runtime_types { propose_curator { #[codec(compact)] bounty_id: ::core::primitive::u32, - curator: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + curator: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] fee: ::core::primitive::u128, }, @@ -1483,7 +1524,10 @@ pub mod runtime_types { award_bounty { #[codec(compact)] bounty_id: ::core::primitive::u32, - beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + beneficiary: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 6)] #[doc = "See [`Pallet::claim_bounty`]."] @@ -1502,7 +1546,7 @@ pub mod runtime_types { extend_bounty_expiry { #[codec(compact)] bounty_id: ::core::primitive::u32, - remark: ::std::vec::Vec<::core::primitive::u8>, + remark: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -1562,14 +1606,14 @@ pub mod runtime_types { #[doc = "A bounty is awarded to a beneficiary."] BountyAwarded { index: ::core::primitive::u32, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 4)] #[doc = "A bounty is claimed by beneficiary."] BountyClaimed { index: ::core::primitive::u32, payout: ::core::primitive::u128, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 5)] #[doc = "A bounty is cancelled."] @@ -1584,7 +1628,7 @@ pub mod runtime_types { #[doc = "A bounty curator is proposed."] CuratorProposed { bounty_id: ::core::primitive::u32, - curator: ::subxt::utils::AccountId32, + curator: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 9)] #[doc = "A bounty curator is unassigned."] @@ -1593,7 +1637,7 @@ pub mod runtime_types { #[doc = "A bounty curator is accepted."] CuratorAccepted { bounty_id: ::core::primitive::u32, - curator: ::subxt::utils::AccountId32, + curator: ::subxt::ext::subxt_core::utils::AccountId32, }, } } @@ -1640,7 +1684,8 @@ pub mod runtime_types { parent_bounty_id: ::core::primitive::u32, #[codec(compact)] value: ::core::primitive::u128, - description: ::std::vec::Vec<::core::primitive::u8>, + description: + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::propose_curator`]."] @@ -1649,7 +1694,10 @@ pub mod runtime_types { parent_bounty_id: ::core::primitive::u32, #[codec(compact)] child_bounty_id: ::core::primitive::u32, - curator: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + curator: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] fee: ::core::primitive::u128, }, @@ -1676,7 +1724,10 @@ pub mod runtime_types { parent_bounty_id: ::core::primitive::u32, #[codec(compact)] child_bounty_id: ::core::primitive::u32, - beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + beneficiary: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 5)] #[doc = "See [`Pallet::claim_child_bounty`]."] @@ -1722,7 +1773,7 @@ pub mod runtime_types { Awarded { index: ::core::primitive::u32, child_index: ::core::primitive::u32, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 2)] #[doc = "A child-bounty is claimed by beneficiary."] @@ -1730,7 +1781,7 @@ pub mod runtime_types { index: ::core::primitive::u32, child_index: ::core::primitive::u32, payout: ::core::primitive::u128, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 3)] #[doc = "A child-bounty is cancelled."] @@ -1804,7 +1855,10 @@ pub mod runtime_types { #[doc = "See [`Pallet::delegate`]."] delegate { class: ::core::primitive::u16, - to: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + to: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, conviction: runtime_types::pallet_conviction_voting::conviction::Conviction, balance: ::core::primitive::u128, }, @@ -1815,7 +1869,10 @@ pub mod runtime_types { #[doc = "See [`Pallet::unlock`]."] unlock { class: ::core::primitive::u16, - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 4)] #[doc = "See [`Pallet::remove_vote`]."] @@ -1826,7 +1883,10 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::remove_other_vote`]."] remove_other_vote { - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, class: ::core::primitive::u16, index: ::core::primitive::u32, }, @@ -1877,10 +1937,13 @@ pub mod runtime_types { pub enum Event { #[codec(index = 0)] #[doc = "An account has delegated their vote to another account. \\[who, target\\]"] - Delegated(::subxt::utils::AccountId32, ::subxt::utils::AccountId32), + Delegated( + ::subxt::ext::subxt_core::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, + ), #[codec(index = 1)] #[doc = "An \\[account\\] has cancelled a previous delegation operation."] - Undelegated(::subxt::utils::AccountId32), + Undelegated(::subxt::ext::subxt_core::utils::AccountId32), } } pub mod types { @@ -1921,7 +1984,7 @@ pub mod runtime_types { runtime_types::pallet_conviction_voting::types::Delegations<_0>, pub prior: runtime_types::pallet_conviction_voting::vote::PriorLock<_1, _0>, #[codec(skip)] - pub __subxt_unused_type_params: ::core::marker::PhantomData<_2>, + pub __ignore: ::core::marker::PhantomData<_2>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct Delegating<_0, _1, _2> { @@ -1935,7 +1998,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct PriorLock<_0, _1>(pub _0, pub _1); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -1961,7 +2024,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] pub enum Call { - # [codec (index = 0)] # [doc = "See [`Pallet::submit_unsigned`]."] submit_unsigned { raw_solution: ::std::boxed::Box < runtime_types::pallet_election_provider_multi_phase::RawSolution < runtime_types::vara_runtime::NposSolution16 > > , witness : runtime_types::pallet_election_provider_multi_phase::SolutionOrSnapshotSize , } , # [codec (index = 1)] # [doc = "See [`Pallet::set_minimum_untrusted_score`]."] set_minimum_untrusted_score { maybe_next_score: ::core::option::Option < runtime_types::sp_npos_elections::ElectionScore > , } , # [codec (index = 2)] # [doc = "See [`Pallet::set_emergency_election_result`]."] set_emergency_election_result { supports: ::std::vec::Vec < (::subxt::utils::AccountId32 , runtime_types::sp_npos_elections::Support < ::subxt::utils::AccountId32 > ,) > , } , # [codec (index = 3)] # [doc = "See [`Pallet::submit`]."] submit { raw_solution: ::std::boxed::Box < runtime_types::pallet_election_provider_multi_phase::RawSolution < runtime_types::vara_runtime::NposSolution16 > > , } , # [codec (index = 4)] # [doc = "See [`Pallet::governance_fallback`]."] governance_fallback { maybe_max_voters: ::core::option::Option <::core::primitive::u32 > , maybe_max_targets: ::core::option::Option <::core::primitive::u32 > , } , } + # [codec (index = 0)] # [doc = "See [`Pallet::submit_unsigned`]."] submit_unsigned { raw_solution : ::subxt::ext ::subxt_core::alloc::boxed::Box < runtime_types::pallet_election_provider_multi_phase::RawSolution < runtime_types::vara_runtime::NposSolution16 > > , witness : runtime_types::pallet_election_provider_multi_phase::SolutionOrSnapshotSize , } , # [codec (index = 1)] # [doc = "See [`Pallet::set_minimum_untrusted_score`]."] set_minimum_untrusted_score { maybe_next_score: ::core::option::Option < runtime_types::sp_npos_elections::ElectionScore > , } , # [codec (index = 2)] # [doc = "See [`Pallet::set_emergency_election_result`]."] set_emergency_election_result { supports : ::subxt::ext ::subxt_core::alloc::vec::Vec < (::subxt::ext ::subxt_core::utils::AccountId32 , runtime_types::sp_npos_elections::Support < ::subxt::ext ::subxt_core::utils::AccountId32 > ,) > , } , # [codec (index = 3)] # [doc = "See [`Pallet::submit`]."] submit { raw_solution : ::subxt::ext ::subxt_core::alloc::boxed::Box < runtime_types::pallet_election_provider_multi_phase::RawSolution < runtime_types::vara_runtime::NposSolution16 > > , } , # [codec (index = 4)] # [doc = "See [`Pallet::governance_fallback`]."] governance_fallback { maybe_max_voters: ::core::option::Option <::core::primitive::u32 > , maybe_max_targets: ::core::option::Option <::core::primitive::u32 > , } , } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] #[doc = "Error of the pallet that can be returned in response to dispatches."] pub enum Error { @@ -2022,7 +2085,8 @@ pub mod runtime_types { SolutionStored { compute: runtime_types::pallet_election_provider_multi_phase::ElectionCompute, - origin: ::core::option::Option<::subxt::utils::AccountId32>, + origin: + ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, prev_ejected: ::core::primitive::bool, }, #[codec(index = 1)] @@ -2040,13 +2104,13 @@ pub mod runtime_types { #[codec(index = 3)] #[doc = "An account has been rewarded for their signed submission being finalized."] Rewarded { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, value: ::core::primitive::u128, }, #[codec(index = 4)] #[doc = "An account has been slashed for submitting an invalid signed submission."] Slashed { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, value: ::core::primitive::u128, }, #[codec(index = 5)] @@ -2106,16 +2170,18 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct ReadySolution { pub supports: runtime_types::bounded_collections::bounded_vec::BoundedVec<( - ::subxt::utils::AccountId32, - runtime_types::sp_npos_elections::Support<::subxt::utils::AccountId32>, + ::subxt::ext::subxt_core::utils::AccountId32, + runtime_types::sp_npos_elections::Support< + ::subxt::ext::subxt_core::utils::AccountId32, + >, )>, pub score: runtime_types::sp_npos_elections::ElectionScore, pub compute: runtime_types::pallet_election_provider_multi_phase::ElectionCompute, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct RoundSnapshot<_0, _1> { - pub voters: ::std::vec::Vec<_1>, - pub targets: ::std::vec::Vec<_0>, + pub voters: ::subxt::ext::subxt_core::alloc::vec::Vec<_1>, + pub targets: ::subxt::ext::subxt_core::alloc::vec::Vec<_0>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct SolutionOrSnapshotSize { @@ -2135,14 +2201,15 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::upload_code`]."] upload_code { - code: ::std::vec::Vec<::core::primitive::u8>, + code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::upload_program`]."] upload_program { - code: ::std::vec::Vec<::core::primitive::u8>, - salt: ::std::vec::Vec<::core::primitive::u8>, - init_payload: ::std::vec::Vec<::core::primitive::u8>, + code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + salt: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + init_payload: + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, keep_alive: ::core::primitive::bool, @@ -2151,8 +2218,9 @@ pub mod runtime_types { #[doc = "See [`Pallet::create_program`]."] create_program { code_id: runtime_types::gprimitives::CodeId, - salt: ::std::vec::Vec<::core::primitive::u8>, - init_payload: ::std::vec::Vec<::core::primitive::u8>, + salt: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + init_payload: + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, keep_alive: ::core::primitive::bool, @@ -2161,7 +2229,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::send_message`]."] send_message { destination: runtime_types::gprimitives::ActorId, - payload: ::std::vec::Vec<::core::primitive::u8>, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, keep_alive: ::core::primitive::bool, @@ -2170,7 +2238,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::send_reply`]."] send_reply { reply_to_id: runtime_types::gprimitives::MessageId, - payload: ::std::vec::Vec<::core::primitive::u8>, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, keep_alive: ::core::primitive::bool, @@ -2270,7 +2338,7 @@ pub mod runtime_types { #[doc = "added to the Gear message queue."] MessageQueued { id: runtime_types::gprimitives::MessageId, - source: ::subxt::utils::AccountId32, + source: ::subxt::ext::subxt_core::utils::AccountId32, destination: runtime_types::gprimitives::ActorId, entry: runtime_types::gear_common::event::MessageEntry, }, @@ -2295,11 +2363,13 @@ pub mod runtime_types { #[doc = "The result of processing the messages within the block."] MessagesDispatched { total: ::core::primitive::u32, - statuses: ::subxt::utils::KeyedVec< + statuses: ::subxt::ext::subxt_core::utils::KeyedVec< runtime_types::gprimitives::MessageId, runtime_types::gear_common::event::DispatchStatus, >, - state_changes: ::std::vec::Vec, + state_changes: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::ActorId, + >, }, #[codec(index = 4)] #[doc = "Messages execution delayed (waited) and successfully"] @@ -2634,10 +2704,12 @@ pub mod runtime_types { } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct DebugData { - pub dispatch_queue: - ::std::vec::Vec, - pub programs: - ::std::vec::Vec, + pub dispatch_queue: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gear_core::message::stored::StoredDispatch, + >, + pub programs: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::pallet_gear_debug::pallet::ProgramDetails, + >, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] #[doc = "The `Error` enum of this pallet."] @@ -2659,11 +2731,11 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct ProgramInfo { pub static_pages: runtime_types::gear_core::pages::PagesAmount, - pub persistent_pages: ::subxt::utils::KeyedVec< + pub persistent_pages: ::subxt::ext::subxt_core::utils::KeyedVec< runtime_types::gear_core::pages::Page, runtime_types::gear_core::memory::PageBuf, >, - pub code_hash: ::subxt::utils::H256, + pub code_hash: ::subxt::ext::subxt_core::utils::H256, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum ProgramState { @@ -2681,9 +2753,9 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct EthMessage { pub nonce: runtime_types::primitive_types::U256, - pub source: ::subxt::utils::H256, - pub destination: ::subxt::utils::H160, - pub payload: ::std::vec::Vec<::core::primitive::u8>, + pub source: ::subxt::ext::subxt_core::utils::H256, + pub destination: ::subxt::ext::subxt_core::utils::H160, + pub payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, } } pub mod pallet { @@ -2700,8 +2772,8 @@ pub mod runtime_types { #[codec(index = 2)] #[doc = "See [`Pallet::send_eth_message`]."] send_eth_message { - destination: ::subxt::utils::H160, - payload: ::std::vec::Vec<::core::primitive::u8>, + destination: ::subxt::ext::subxt_core::utils::H160, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -2732,7 +2804,7 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "Grandpa validator's keys set was hashed and set in storage at"] #[doc = "first block of the last session in the era."] - AuthoritySetHashChanged(::subxt::utils::H256), + AuthoritySetHashChanged(::subxt::ext::subxt_core::utils::H256), #[codec(index = 1)] #[doc = "Bridge got cleared on initialization of the second block in a new era."] BridgeCleared, @@ -2751,11 +2823,11 @@ pub mod runtime_types { #[doc = "A new message was queued for bridging."] MessageQueued { message: runtime_types::pallet_gear_eth_bridge::internal::EthMessage, - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 6)] #[doc = "Merkle root of the queue changed: new messages queued within the block."] - QueueMerkleRootChanged(::subxt::utils::H256), + QueueMerkleRootChanged(::subxt::ext::subxt_core::utils::H256), } } } @@ -2931,13 +3003,19 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "See [`Pallet::force_refill`]."] force_refill { - from: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + from: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, value: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "See [`Pallet::withdraw`]."] withdraw { - to: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + to: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, value: ::core::primitive::u128, }, #[codec(index = 3)] @@ -2981,7 +3059,7 @@ pub mod runtime_types { #[codec(index = 0)] SendMessage { destination: runtime_types::gprimitives::ActorId, - payload: ::std::vec::Vec<::core::primitive::u8>, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: _0, keep_alive: ::core::primitive::bool, @@ -2989,22 +3067,22 @@ pub mod runtime_types { #[codec(index = 1)] SendReply { reply_to_id: runtime_types::gprimitives::MessageId, - payload: ::std::vec::Vec<::core::primitive::u8>, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: _0, keep_alive: ::core::primitive::bool, }, #[codec(index = 2)] UploadCode { - code: ::std::vec::Vec<::core::primitive::u8>, + code: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 3)] DeclineVoucher, #[codec(index = 4)] CreateProgram { code_id: runtime_types::gprimitives::CodeId, - salt: ::std::vec::Vec<::core::primitive::u8>, - payload: ::std::vec::Vec<::core::primitive::u8>, + salt: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + payload: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: _0, keep_alive: ::core::primitive::bool, @@ -3022,22 +3100,33 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct VoucherPermissions { pub programs: ::core::option::Option< - ::std::vec::Vec, + ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::ActorId, + >, >, pub code_uploading: ::core::primitive::bool, - pub code_ids: - ::core::option::Option<::std::vec::Vec>, + pub code_ids: ::core::option::Option< + ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::CodeId, + >, + >, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct VoucherPermissionsExtend { pub append_programs: ::core::option::Option< ::core::option::Option< - ::std::vec::Vec, + ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::ActorId, + >, >, >, pub code_uploading: ::core::option::Option<::core::primitive::bool>, pub append_code_ids: ::core::option::Option< - ::core::option::Option<::std::vec::Vec>, + ::core::option::Option< + ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::gprimitives::CodeId, + >, + >, >, } } @@ -3049,7 +3138,7 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::issue`]."] issue { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, balance: ::core::primitive::u128, duration: ::core::primitive::u32, permissions: @@ -3066,15 +3155,16 @@ pub mod runtime_types { #[codec(index = 2)] #[doc = "See [`Pallet::revoke`]."] revoke { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, }, #[codec(index = 3)] #[doc = "See [`Pallet::update`]."] update { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, - move_ownership: ::core::option::Option<::subxt::utils::AccountId32>, + move_ownership: + ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, balance_top_up: ::core::option::Option<::core::primitive::u128>, prolong_duration: ::core::option::Option<::core::primitive::u32>, permissions_extend: @@ -3135,8 +3225,8 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "Voucher has been issued."] VoucherIssued { - owner: ::subxt::utils::AccountId32, - spender: ::subxt::utils::AccountId32, + owner: ::subxt::ext::subxt_core::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, }, #[codec(index = 1)] @@ -3144,20 +3234,21 @@ pub mod runtime_types { #[doc = ""] #[doc = "NOTE: currently means only \"refunded\"."] VoucherRevoked { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, }, #[codec(index = 2)] #[doc = "Voucher has been updated."] VoucherUpdated { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, - new_owner: ::core::option::Option<::subxt::utils::AccountId32>, + new_owner: + ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, }, #[codec(index = 3)] #[doc = "Voucher has been declined (set to expired state)."] VoucherDeclined { - spender: ::subxt::utils::AccountId32, + spender: ::subxt::ext::subxt_core::utils::AccountId32, voucher_id: runtime_types::pallet_gear_voucher::internal::VoucherId, }, } @@ -3173,9 +3264,9 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::report_equivocation`]."] report_equivocation { - equivocation_proof: ::std::boxed::Box< + equivocation_proof: ::subxt::ext::subxt_core::alloc::boxed::Box< runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, + ::subxt::ext::subxt_core::utils::H256, ::core::primitive::u32, >, >, @@ -3184,9 +3275,9 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "See [`Pallet::report_equivocation_unsigned`]."] report_equivocation_unsigned { - equivocation_proof: ::std::boxed::Box< + equivocation_proof: ::subxt::ext::subxt_core::alloc::boxed::Box< runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, + ::subxt::ext::subxt_core::utils::H256, ::core::primitive::u32, >, >, @@ -3232,7 +3323,7 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "New authority set has been applied."] NewAuthorities { - authority_set: ::std::vec::Vec<( + authority_set: ::subxt::ext::subxt_core::alloc::vec::Vec<( runtime_types::sp_consensus_grandpa::app::Public, ::core::primitive::u64, )>, @@ -3296,19 +3387,23 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::add_registrar`]."] add_registrar { - account: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + account: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::set_identity`]."] set_identity { - info: - ::std::boxed::Box, + info: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::pallet_identity::legacy::IdentityInfo, + >, }, #[codec(index = 2)] #[doc = "See [`Pallet::set_subs`]."] set_subs { - subs: ::std::vec::Vec<( - ::subxt::utils::AccountId32, + subs: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::utils::AccountId32, runtime_types::pallet_identity::types::Data, )>, }, @@ -3339,7 +3434,10 @@ pub mod runtime_types { set_account_id { #[codec(compact)] index: ::core::primitive::u32, - new: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + new: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 8)] #[doc = "See [`Pallet::set_fields`]."] @@ -3353,33 +3451,48 @@ pub mod runtime_types { provide_judgement { #[codec(compact)] reg_index: ::core::primitive::u32, - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, judgement: runtime_types::pallet_identity::types::Judgement< ::core::primitive::u128, >, - identity: ::subxt::utils::H256, + identity: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 10)] #[doc = "See [`Pallet::kill_identity`]."] kill_identity { - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 11)] #[doc = "See [`Pallet::add_sub`]."] add_sub { - sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + sub: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, data: runtime_types::pallet_identity::types::Data, }, #[codec(index = 12)] #[doc = "See [`Pallet::rename_sub`]."] rename_sub { - sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + sub: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, data: runtime_types::pallet_identity::types::Data, }, #[codec(index = 13)] #[doc = "See [`Pallet::remove_sub`]."] remove_sub { - sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + sub: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 14)] #[doc = "See [`Pallet::quit_sub`]."] @@ -3445,35 +3558,37 @@ pub mod runtime_types { pub enum Event { #[codec(index = 0)] #[doc = "A name was set or reset (which will remove all judgements)."] - IdentitySet { who: ::subxt::utils::AccountId32 }, + IdentitySet { + who: ::subxt::ext::subxt_core::utils::AccountId32, + }, #[codec(index = 1)] #[doc = "A name was cleared, and the given balance returned."] IdentityCleared { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, deposit: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "A name was removed and the given balance slashed."] IdentityKilled { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, deposit: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "A judgement was asked from a registrar."] JudgementRequested { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, registrar_index: ::core::primitive::u32, }, #[codec(index = 4)] #[doc = "A judgement request was retracted."] JudgementUnrequested { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, registrar_index: ::core::primitive::u32, }, #[codec(index = 5)] #[doc = "A judgement was given by a registrar."] JudgementGiven { - target: ::subxt::utils::AccountId32, + target: ::subxt::ext::subxt_core::utils::AccountId32, registrar_index: ::core::primitive::u32, }, #[codec(index = 6)] @@ -3484,23 +3599,23 @@ pub mod runtime_types { #[codec(index = 7)] #[doc = "A sub-identity was added to an identity and the deposit paid."] SubIdentityAdded { - sub: ::subxt::utils::AccountId32, - main: ::subxt::utils::AccountId32, + sub: ::subxt::ext::subxt_core::utils::AccountId32, + main: ::subxt::ext::subxt_core::utils::AccountId32, deposit: ::core::primitive::u128, }, #[codec(index = 8)] #[doc = "A sub-identity was removed from an identity and the deposit freed."] SubIdentityRemoved { - sub: ::subxt::utils::AccountId32, - main: ::subxt::utils::AccountId32, + sub: ::subxt::ext::subxt_core::utils::AccountId32, + main: ::subxt::ext::subxt_core::utils::AccountId32, deposit: ::core::primitive::u128, }, #[codec(index = 9)] #[doc = "A sub-identity was cleared, and the given deposit repatriated from the"] #[doc = "main identity account to the sub-identity account."] SubIdentityRevoked { - sub: ::subxt::utils::AccountId32, - main: ::subxt::utils::AccountId32, + sub: ::subxt::ext::subxt_core::utils::AccountId32, + main: ::subxt::ext::subxt_core::utils::AccountId32, deposit: ::core::primitive::u128, }, } @@ -3659,10 +3774,10 @@ pub mod runtime_types { #[codec(index = 2)] #[doc = "At the end of the session, at least one validator was found to be offline."] SomeOffline { - offline: ::std::vec::Vec<( - ::subxt::utils::AccountId32, + offline: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::utils::AccountId32, runtime_types::sp_staking::Exposure< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, ::core::primitive::u128, >, )>, @@ -3701,25 +3816,35 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::as_multi_threshold_1`]."] as_multi_threshold_1 { - other_signatories: ::std::vec::Vec<::subxt::utils::AccountId32>, - call: ::std::boxed::Box, + other_signatories: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::as_multi`]."] as_multi { threshold: ::core::primitive::u16, - other_signatories: ::std::vec::Vec<::subxt::utils::AccountId32>, + other_signatories: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, maybe_timepoint: ::core::option::Option< runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, >, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, max_weight: runtime_types::sp_weights::weight_v2::Weight, }, #[codec(index = 2)] #[doc = "See [`Pallet::approve_as_multi`]."] approve_as_multi { threshold: ::core::primitive::u16, - other_signatories: ::std::vec::Vec<::subxt::utils::AccountId32>, + other_signatories: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, maybe_timepoint: ::core::option::Option< runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, >, @@ -3730,7 +3855,9 @@ pub mod runtime_types { #[doc = "See [`Pallet::cancel_as_multi`]."] cancel_as_multi { threshold: ::core::primitive::u16, - other_signatories: ::std::vec::Vec<::subxt::utils::AccountId32>, + other_signatories: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, timepoint: runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, call_hash: [::core::primitive::u8; 32usize], @@ -3788,26 +3915,26 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "A new multisig operation has begun."] NewMultisig { - approving: ::subxt::utils::AccountId32, - multisig: ::subxt::utils::AccountId32, + approving: ::subxt::ext::subxt_core::utils::AccountId32, + multisig: ::subxt::ext::subxt_core::utils::AccountId32, call_hash: [::core::primitive::u8; 32usize], }, #[codec(index = 1)] #[doc = "A multisig operation has been approved by someone."] MultisigApproval { - approving: ::subxt::utils::AccountId32, + approving: ::subxt::ext::subxt_core::utils::AccountId32, timepoint: runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, - multisig: ::subxt::utils::AccountId32, + multisig: ::subxt::ext::subxt_core::utils::AccountId32, call_hash: [::core::primitive::u8; 32usize], }, #[codec(index = 2)] #[doc = "A multisig operation has been executed."] MultisigExecuted { - approving: ::subxt::utils::AccountId32, + approving: ::subxt::ext::subxt_core::utils::AccountId32, timepoint: runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, - multisig: ::subxt::utils::AccountId32, + multisig: ::subxt::ext::subxt_core::utils::AccountId32, call_hash: [::core::primitive::u8; 32usize], result: ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, @@ -3815,10 +3942,10 @@ pub mod runtime_types { #[codec(index = 3)] #[doc = "A multisig operation has been cancelled."] MultisigCancelled { - cancelling: ::subxt::utils::AccountId32, + cancelling: ::subxt::ext::subxt_core::utils::AccountId32, timepoint: runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, - multisig: ::subxt::utils::AccountId32, + multisig: ::subxt::ext::subxt_core::utils::AccountId32, call_hash: [::core::primitive::u8; 32usize], }, } @@ -3863,8 +3990,10 @@ pub mod runtime_types { #[codec(index = 3)] #[doc = "See [`Pallet::unbond`]."] unbond { - member_account: - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + member_account: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, #[codec(compact)] unbonding_points: ::core::primitive::u128, }, @@ -3877,8 +4006,10 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::withdraw_unbonded`]."] withdraw_unbonded { - member_account: - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + member_account: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, num_slashing_spans: ::core::primitive::u32, }, #[codec(index = 6)] @@ -3886,25 +4017,45 @@ pub mod runtime_types { create { #[codec(compact)] amount: ::core::primitive::u128, - root: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - nominator: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - bouncer: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + root: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + nominator: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + bouncer: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 7)] #[doc = "See [`Pallet::create_with_pool_id`]."] create_with_pool_id { #[codec(compact)] amount: ::core::primitive::u128, - root: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - nominator: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - bouncer: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + root: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + nominator: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + bouncer: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, pool_id: ::core::primitive::u32, }, #[codec(index = 8)] #[doc = "See [`Pallet::nominate`]."] nominate { pool_id: ::core::primitive::u32, - validators: ::std::vec::Vec<::subxt::utils::AccountId32>, + validators: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, }, #[codec(index = 9)] #[doc = "See [`Pallet::set_state`]."] @@ -3916,7 +4067,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::set_metadata`]."] set_metadata { pool_id: ::core::primitive::u32, - metadata: ::std::vec::Vec<::core::primitive::u8>, + metadata: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 11)] #[doc = "See [`Pallet::set_configs`]."] @@ -3945,13 +4096,13 @@ pub mod runtime_types { update_roles { pool_id: ::core::primitive::u32, new_root: runtime_types::pallet_nomination_pools::ConfigOp< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, new_nominator: runtime_types::pallet_nomination_pools::ConfigOp< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, new_bouncer: runtime_types::pallet_nomination_pools::ConfigOp< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, }, #[codec(index = 13)] @@ -3960,7 +4111,10 @@ pub mod runtime_types { #[codec(index = 14)] #[doc = "See [`Pallet::bond_extra_other`]."] bond_extra_other { - member: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + member: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, extra: runtime_types::pallet_nomination_pools::BondExtra< ::core::primitive::u128, >, @@ -3972,14 +4126,16 @@ pub mod runtime_types { }, #[codec(index = 16)] #[doc = "See [`Pallet::claim_payout_other`]."] - claim_payout_other { other: ::subxt::utils::AccountId32 }, + claim_payout_other { + other: ::subxt::ext::subxt_core::utils::AccountId32, + }, #[codec(index = 17)] #[doc = "See [`Pallet::set_commission`]."] set_commission { pool_id: ::core::primitive::u32, new_commission: ::core::option::Option<( runtime_types::sp_arithmetic::per_things::Perbill, - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, )>, }, #[codec(index = 18)] @@ -4130,13 +4286,13 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "A pool has been created."] Created { - depositor: ::subxt::utils::AccountId32, + depositor: ::subxt::ext::subxt_core::utils::AccountId32, pool_id: ::core::primitive::u32, }, #[codec(index = 1)] #[doc = "A member has became bonded in a pool."] Bonded { - member: ::subxt::utils::AccountId32, + member: ::subxt::ext::subxt_core::utils::AccountId32, pool_id: ::core::primitive::u32, bonded: ::core::primitive::u128, joined: ::core::primitive::bool, @@ -4144,7 +4300,7 @@ pub mod runtime_types { #[codec(index = 2)] #[doc = "A payout has been made to a member."] PaidOut { - member: ::subxt::utils::AccountId32, + member: ::subxt::ext::subxt_core::utils::AccountId32, pool_id: ::core::primitive::u32, payout: ::core::primitive::u128, }, @@ -4161,7 +4317,7 @@ pub mod runtime_types { #[doc = "number of points that are issued in the unbonding pool will be less than the amount"] #[doc = "requested to be unbonded."] Unbonded { - member: ::subxt::utils::AccountId32, + member: ::subxt::ext::subxt_core::utils::AccountId32, pool_id: ::core::primitive::u32, balance: ::core::primitive::u128, points: ::core::primitive::u128, @@ -4175,7 +4331,7 @@ pub mod runtime_types { #[doc = "Similar to `Unbonded` event, in the absence of slashing, the ratio of point to balance"] #[doc = "will be 1."] Withdrawn { - member: ::subxt::utils::AccountId32, + member: ::subxt::ext::subxt_core::utils::AccountId32, pool_id: ::core::primitive::u32, balance: ::core::primitive::u128, points: ::core::primitive::u128, @@ -4195,15 +4351,17 @@ pub mod runtime_types { #[doc = "The removal can be voluntary (withdrawn all unbonded funds) or involuntary (kicked)."] MemberRemoved { pool_id: ::core::primitive::u32, - member: ::subxt::utils::AccountId32, + member: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 8)] #[doc = "The roles of a pool have been updated to the given new roles. Note that the depositor"] #[doc = "can never change."] RolesUpdated { - root: ::core::option::Option<::subxt::utils::AccountId32>, - bouncer: ::core::option::Option<::subxt::utils::AccountId32>, - nominator: ::core::option::Option<::subxt::utils::AccountId32>, + root: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, + bouncer: + ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, + nominator: + ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, }, #[codec(index = 9)] #[doc = "The active balance of pool `pool_id` has been slashed to `balance`."] @@ -4224,7 +4382,7 @@ pub mod runtime_types { pool_id: ::core::primitive::u32, current: ::core::option::Option<( runtime_types::sp_arithmetic::per_things::Perbill, - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, )>, }, #[codec(index = 12)] @@ -4278,8 +4436,9 @@ pub mod runtime_types { pub commission: runtime_types::pallet_nomination_pools::Commission, pub member_counter: ::core::primitive::u32, pub points: ::core::primitive::u128, - pub roles: - runtime_types::pallet_nomination_pools::PoolRoles<::subxt::utils::AccountId32>, + pub roles: runtime_types::pallet_nomination_pools::PoolRoles< + ::subxt::ext::subxt_core::utils::AccountId32, + >, pub state: runtime_types::pallet_nomination_pools::PoolState, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -4297,7 +4456,7 @@ pub mod runtime_types { pub struct Commission { pub current: ::core::option::Option<( runtime_types::sp_arithmetic::per_things::Perbill, - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, )>, pub max: ::core::option::Option, pub change_rate: ::core::option::Option< @@ -4386,7 +4545,7 @@ pub mod runtime_types { #[doc = "\\[kind, timeslot\\]."] Offence { kind: [::core::primitive::u8; 16usize], - timeslot: ::std::vec::Vec<::core::primitive::u8>, + timeslot: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, } } @@ -4401,21 +4560,29 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::note_preimage`]."] note_preimage { - bytes: ::std::vec::Vec<::core::primitive::u8>, + bytes: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::unnote_preimage`]."] - unnote_preimage { hash: ::subxt::utils::H256 }, + unnote_preimage { + hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 2)] #[doc = "See [`Pallet::request_preimage`]."] - request_preimage { hash: ::subxt::utils::H256 }, + request_preimage { + hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 3)] #[doc = "See [`Pallet::unrequest_preimage`]."] - unrequest_preimage { hash: ::subxt::utils::H256 }, + unrequest_preimage { + hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 4)] #[doc = "See [`Pallet::ensure_updated`]."] ensure_updated { - hashes: ::std::vec::Vec<::subxt::utils::H256>, + hashes: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::H256, + >, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -4451,13 +4618,19 @@ pub mod runtime_types { pub enum Event { #[codec(index = 0)] #[doc = "A preimage has been noted."] - Noted { hash: ::subxt::utils::H256 }, + Noted { + hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 1)] #[doc = "A preimage has been requested."] - Requested { hash: ::subxt::utils::H256 }, + Requested { + hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 2)] #[doc = "A preimage has ben cleared."] - Cleared { hash: ::subxt::utils::H256 }, + Cleared { + hash: ::subxt::ext::subxt_core::utils::H256, + }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum HoldReason { @@ -4504,22 +4677,33 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::proxy`]."] proxy { - real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + real: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, force_proxy_type: ::core::option::Option, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::add_proxy`]."] add_proxy { - delegate: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + delegate: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, proxy_type: runtime_types::vara_runtime::ProxyType, delay: ::core::primitive::u32, }, #[codec(index = 2)] #[doc = "See [`Pallet::remove_proxy`]."] remove_proxy { - delegate: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + delegate: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, proxy_type: runtime_types::vara_runtime::ProxyType, delay: ::core::primitive::u32, }, @@ -4536,7 +4720,10 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::kill_pure`]."] kill_pure { - spawner: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + spawner: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, proxy_type: runtime_types::vara_runtime::ProxyType, index: ::core::primitive::u16, #[codec(compact)] @@ -4547,29 +4734,46 @@ pub mod runtime_types { #[codec(index = 6)] #[doc = "See [`Pallet::announce`]."] announce { - real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - call_hash: ::subxt::utils::H256, + real: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + call_hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 7)] #[doc = "See [`Pallet::remove_announcement`]."] remove_announcement { - real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - call_hash: ::subxt::utils::H256, + real: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + call_hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 8)] #[doc = "See [`Pallet::reject_announcement`]."] reject_announcement { - delegate: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - call_hash: ::subxt::utils::H256, + delegate: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + call_hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 9)] #[doc = "See [`Pallet::proxy_announced`]."] proxy_announced { - delegate: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + delegate: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + real: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, force_proxy_type: ::core::option::Option, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -4613,31 +4817,31 @@ pub mod runtime_types { #[doc = "A pure account has been created by new proxy with given"] #[doc = "disambiguation index and proxy type."] PureCreated { - pure: ::subxt::utils::AccountId32, - who: ::subxt::utils::AccountId32, + pure: ::subxt::ext::subxt_core::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, proxy_type: runtime_types::vara_runtime::ProxyType, disambiguation_index: ::core::primitive::u16, }, #[codec(index = 2)] #[doc = "An announcement was placed to make a call in the future."] Announced { - real: ::subxt::utils::AccountId32, - proxy: ::subxt::utils::AccountId32, - call_hash: ::subxt::utils::H256, + real: ::subxt::ext::subxt_core::utils::AccountId32, + proxy: ::subxt::ext::subxt_core::utils::AccountId32, + call_hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 3)] #[doc = "A proxy was added."] ProxyAdded { - delegator: ::subxt::utils::AccountId32, - delegatee: ::subxt::utils::AccountId32, + delegator: ::subxt::ext::subxt_core::utils::AccountId32, + delegatee: ::subxt::ext::subxt_core::utils::AccountId32, proxy_type: runtime_types::vara_runtime::ProxyType, delay: ::core::primitive::u32, }, #[codec(index = 4)] #[doc = "A proxy was removed."] ProxyRemoved { - delegator: ::subxt::utils::AccountId32, - delegatee: ::subxt::utils::AccountId32, + delegator: ::subxt::ext::subxt_core::utils::AccountId32, + delegatee: ::subxt::ext::subxt_core::utils::AccountId32, proxy_type: runtime_types::vara_runtime::ProxyType, delay: ::core::primitive::u32, }, @@ -4666,22 +4870,34 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::add_member`]."] add_member { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::promote_member`]."] promote_member { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 2)] #[doc = "See [`Pallet::demote_member`]."] demote_member { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 3)] #[doc = "See [`Pallet::remove_member`]."] remove_member { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, min_rank: ::core::primitive::u16, }, #[codec(index = 4)] @@ -4733,24 +4949,26 @@ pub mod runtime_types { pub enum Event { #[codec(index = 0)] #[doc = "A member `who` has been added."] - MemberAdded { who: ::subxt::utils::AccountId32 }, + MemberAdded { + who: ::subxt::ext::subxt_core::utils::AccountId32, + }, #[codec(index = 1)] #[doc = "The member `who`se rank has been changed to the given `rank`."] RankChanged { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, rank: ::core::primitive::u16, }, #[codec(index = 2)] #[doc = "The member `who` of given `rank` has been removed from the collective."] MemberRemoved { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, rank: ::core::primitive::u16, }, #[codec(index = 3)] #[doc = "The member `who` has voted for the `poll` with the given `vote` leading to an updated"] #[doc = "`tally`."] Voted { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, poll: ::core::primitive::u32, vote: runtime_types::pallet_ranked_collective::VoteRecord, tally: runtime_types::pallet_ranked_collective::Tally, @@ -4758,7 +4976,7 @@ pub mod runtime_types { } } #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -4791,53 +5009,9 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::submit`]."] submit { - proposal_origin: - ::std::boxed::Box, - proposal: runtime_types::frame_support::traits::preimages::Bounded< - runtime_types::vara_runtime::RuntimeCall, - runtime_types::sp_runtime::traits::BlakeTwo256, + proposal_origin: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::OriginCaller, >, - enactment_moment: - runtime_types::frame_support::traits::schedule::DispatchTime< - ::core::primitive::u32, - >, - }, - #[codec(index = 1)] - #[doc = "See [`Pallet::place_decision_deposit`]."] - place_decision_deposit { index: ::core::primitive::u32 }, - #[codec(index = 2)] - #[doc = "See [`Pallet::refund_decision_deposit`]."] - refund_decision_deposit { index: ::core::primitive::u32 }, - #[codec(index = 3)] - #[doc = "See [`Pallet::cancel`]."] - cancel { index: ::core::primitive::u32 }, - #[codec(index = 4)] - #[doc = "See [`Pallet::kill`]."] - kill { index: ::core::primitive::u32 }, - #[codec(index = 5)] - #[doc = "See [`Pallet::nudge_referendum`]."] - nudge_referendum { index: ::core::primitive::u32 }, - #[codec(index = 6)] - #[doc = "See [`Pallet::one_fewer_deciding`]."] - one_fewer_deciding { track: ::core::primitive::u16 }, - #[codec(index = 7)] - #[doc = "See [`Pallet::refund_submission_deposit`]."] - refund_submission_deposit { index: ::core::primitive::u32 }, - #[codec(index = 8)] - #[doc = "See [`Pallet::set_metadata`]."] - set_metadata { - index: ::core::primitive::u32, - maybe_hash: ::core::option::Option<::subxt::utils::H256>, - }, - } - #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub enum Call2 { - #[codec(index = 0)] - #[doc = "See [`Pallet::submit`]."] - submit { - proposal_origin: - ::std::boxed::Box, proposal: runtime_types::frame_support::traits::preimages::Bounded< runtime_types::vara_runtime::RuntimeCall, runtime_types::sp_runtime::traits::BlakeTwo256, @@ -4872,7 +5046,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::set_metadata`]."] set_metadata { index: ::core::primitive::u32, - maybe_hash: ::core::option::Option<::subxt::utils::H256>, + maybe_hash: ::core::option::Option<::subxt::ext::subxt_core::utils::H256>, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -4919,51 +5093,8 @@ pub mod runtime_types { PreimageNotExist, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] - #[doc = "The `Error` enum of this pallet."] - pub enum Error2 { - #[codec(index = 0)] - #[doc = "Referendum is not ongoing."] - NotOngoing, - #[codec(index = 1)] - #[doc = "Referendum's decision deposit is already paid."] - HasDeposit, - #[codec(index = 2)] - #[doc = "The track identifier given was invalid."] - BadTrack, - #[codec(index = 3)] - #[doc = "There are already a full complement of referenda in progress for this track."] - Full, - #[codec(index = 4)] - #[doc = "The queue of the track is empty."] - QueueEmpty, - #[codec(index = 5)] - #[doc = "The referendum index provided is invalid in this context."] - BadReferendum, - #[codec(index = 6)] - #[doc = "There was nothing to do in the advancement."] - NothingToDo, - #[codec(index = 7)] - #[doc = "No track exists for the proposal origin."] - NoTrack, - #[codec(index = 8)] - #[doc = "Any deposit cannot be refunded until after the decision is over."] - Unfinished, - #[codec(index = 9)] - #[doc = "The deposit refunder is not the depositor."] - NoPermission, - #[codec(index = 10)] - #[doc = "The deposit cannot be refunded since none was made."] - NoDeposit, - #[codec(index = 11)] - #[doc = "The referendum status is invalid for this operation."] - BadStatus, - #[codec(index = 12)] - #[doc = "The preimage does not exist."] - PreimageNotExist, - } - #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] #[doc = "The `Event` enum of this pallet"] - pub enum Event { + pub enum Event1 { #[codec(index = 0)] #[doc = "A referendum has been submitted."] Submitted { @@ -4978,20 +5109,20 @@ pub mod runtime_types { #[doc = "The decision deposit has been placed."] DecisionDepositPlaced { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "The decision deposit has been refunded."] DecisionDepositRefunded { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "A deposit has been slashed."] DepositSlashed { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 4)] @@ -5058,20 +5189,20 @@ pub mod runtime_types { #[doc = "The submission deposit has been refunded."] SubmissionDepositRefunded { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 14)] #[doc = "Metadata for a referendum has been set."] MetadataSet { index: ::core::primitive::u32, - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 15)] #[doc = "Metadata for a referendum has been cleared."] MetadataCleared { index: ::core::primitive::u32, - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -5091,20 +5222,20 @@ pub mod runtime_types { #[doc = "The decision deposit has been placed."] DecisionDepositPlaced { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "The decision deposit has been refunded."] DecisionDepositRefunded { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "A deposit has been slashed."] DepositSlashed { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 4)] @@ -5159,20 +5290,20 @@ pub mod runtime_types { #[doc = "The submission deposit has been refunded."] SubmissionDepositRefunded { index: ::core::primitive::u32, - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 14)] #[doc = "Metadata for a referendum has been set."] MetadataSet { index: ::core::primitive::u32, - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, #[codec(index = 15)] #[doc = "Metadata for a referendum has been cleared."] MetadataCleared { index: ::core::primitive::u32, - hash: ::subxt::utils::H256, + hash: ::subxt::ext::subxt_core::utils::H256, }, } } @@ -5288,7 +5419,7 @@ pub mod runtime_types { } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct TrackInfo<_0, _1> { - pub name: ::std::string::String, + pub name: ::subxt::ext::subxt_core::alloc::string::String, pub max_deciding: ::core::primitive::u32, pub decision_deposit: _0, pub prepare_period: _1, @@ -5316,7 +5447,9 @@ pub mod runtime_types { ::core::primitive::u32, )>, priority: ::core::primitive::u8, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::cancel`]."] @@ -5334,7 +5467,9 @@ pub mod runtime_types { ::core::primitive::u32, )>, priority: ::core::primitive::u8, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 3)] #[doc = "See [`Pallet::cancel_named`]."] @@ -5350,7 +5485,9 @@ pub mod runtime_types { ::core::primitive::u32, )>, priority: ::core::primitive::u8, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 5)] #[doc = "See [`Pallet::schedule_named_after`]."] @@ -5362,7 +5499,9 @@ pub mod runtime_types { ::core::primitive::u32, )>, priority: ::core::primitive::u8, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -5435,7 +5574,7 @@ pub mod runtime_types { pub maybe_periodic: ::core::option::Option<(_2, _2)>, pub origin: _3, #[codec(skip)] - pub __subxt_unused_type_params: ::core::marker::PhantomData<_4>, + pub __ignore: ::core::marker::PhantomData<_4>, } } pub mod pallet_session { @@ -5449,7 +5588,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::set_keys`]."] set_keys { keys: runtime_types::vara_runtime::SessionKeys, - proof: ::std::vec::Vec<::core::primitive::u8>, + proof: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, }, #[codec(index = 1)] #[doc = "See [`Pallet::purge_keys`]."] @@ -5503,7 +5642,7 @@ pub mod runtime_types { #[codec(compact)] value: ::core::primitive::u128, payee: runtime_types::pallet_staking::RewardDestination< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, }, #[codec(index = 1)] @@ -5531,8 +5670,11 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::nominate`]."] nominate { - targets: ::std::vec::Vec< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + targets: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, >, }, #[codec(index = 6)] @@ -5542,7 +5684,7 @@ pub mod runtime_types { #[doc = "See [`Pallet::set_payee`]."] set_payee { payee: runtime_types::pallet_staking::RewardDestination< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, }, #[codec(index = 8)] @@ -5574,12 +5716,14 @@ pub mod runtime_types { #[codec(index = 14)] #[doc = "See [`Pallet::set_invulnerables`]."] set_invulnerables { - invulnerables: ::std::vec::Vec<::subxt::utils::AccountId32>, + invulnerables: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::AccountId32, + >, }, #[codec(index = 15)] #[doc = "See [`Pallet::force_unstake`]."] force_unstake { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, num_slashing_spans: ::core::primitive::u32, }, #[codec(index = 16)] @@ -5589,12 +5733,13 @@ pub mod runtime_types { #[doc = "See [`Pallet::cancel_deferred_slash`]."] cancel_deferred_slash { era: ::core::primitive::u32, - slash_indices: ::std::vec::Vec<::core::primitive::u32>, + slash_indices: + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u32>, }, #[codec(index = 18)] #[doc = "See [`Pallet::payout_stakers`]."] payout_stakers { - validator_stash: ::subxt::utils::AccountId32, + validator_stash: ::subxt::ext::subxt_core::utils::AccountId32, era: ::core::primitive::u32, }, #[codec(index = 19)] @@ -5606,14 +5751,17 @@ pub mod runtime_types { #[codec(index = 20)] #[doc = "See [`Pallet::reap_stash`]."] reap_stash { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, num_slashing_spans: ::core::primitive::u32, }, #[codec(index = 21)] #[doc = "See [`Pallet::kick`]."] kick { - who: ::std::vec::Vec< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + who: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, >, }, #[codec(index = 22)] @@ -5646,12 +5794,12 @@ pub mod runtime_types { #[codec(index = 23)] #[doc = "See [`Pallet::chill_other`]."] chill_other { - controller: ::subxt::utils::AccountId32, + controller: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 24)] #[doc = "See [`Pallet::force_apply_min_commission`]."] force_apply_min_commission { - validator_stash: ::subxt::utils::AccountId32, + validator_stash: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 25)] #[doc = "See [`Pallet::set_min_commission`]."] @@ -5661,7 +5809,7 @@ pub mod runtime_types { #[codec(index = 26)] #[doc = "See [`Pallet::payout_stakers_by_page`]."] payout_stakers_by_page { - validator_stash: ::subxt::utils::AccountId32, + validator_stash: ::subxt::ext::subxt_core::utils::AccountId32, era: ::core::primitive::u32, page: ::core::primitive::u32, }, @@ -5781,23 +5929,23 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "The nominator has been rewarded by this amount to this destination."] Rewarded { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, dest: runtime_types::pallet_staking::RewardDestination< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, amount: ::core::primitive::u128, }, #[codec(index = 2)] #[doc = "A staker (validator or nominator) has been slashed by the given amount."] Slashed { - staker: ::subxt::utils::AccountId32, + staker: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 3)] #[doc = "A slash for the given validator, for the given percentage of their stake, at the given"] #[doc = "era as been reported."] SlashReported { - validator: ::subxt::utils::AccountId32, + validator: ::subxt::ext::subxt_core::utils::AccountId32, fraction: runtime_types::sp_arithmetic::per_things::Perbill, slash_era: ::core::primitive::u32, }, @@ -5816,44 +5964,46 @@ pub mod runtime_types { #[doc = "NOTE: This event is only emitted when funds are bonded via a dispatchable. Notably,"] #[doc = "it will not be emitted for staking rewards when they are added to stake."] Bonded { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 7)] #[doc = "An account has unbonded this amount."] Unbonded { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 8)] #[doc = "An account has called `withdraw_unbonded` and removed unbonding chunks worth `Balance`"] #[doc = "from the unlocking queue."] Withdrawn { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, amount: ::core::primitive::u128, }, #[codec(index = 9)] #[doc = "A nominator has been kicked from a validator."] Kicked { - nominator: ::subxt::utils::AccountId32, - stash: ::subxt::utils::AccountId32, + nominator: ::subxt::ext::subxt_core::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 10)] #[doc = "The election failed. No new era is planned."] StakingElectionFailed, #[codec(index = 11)] #[doc = "An account has stopped participating as either a validator or nominator."] - Chilled { stash: ::subxt::utils::AccountId32 }, + Chilled { + stash: ::subxt::ext::subxt_core::utils::AccountId32, + }, #[codec(index = 12)] #[doc = "The stakers' rewards are getting paid."] PayoutStarted { era_index: ::core::primitive::u32, - validator_stash: ::subxt::utils::AccountId32, + validator_stash: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 13)] #[doc = "A validator has set their preferences."] ValidatorPrefsSet { - stash: ::subxt::utils::AccountId32, + stash: ::subxt::ext::subxt_core::utils::AccountId32, prefs: runtime_types::pallet_staking::ValidatorPrefs, }, #[codec(index = 14)] @@ -5877,7 +6027,7 @@ pub mod runtime_types { pub span_index: ::core::primitive::u32, pub last_start: ::core::primitive::u32, pub last_nonzero_slash: ::core::primitive::u32, - pub prior: ::std::vec::Vec<::core::primitive::u32>, + pub prior: ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u32>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct SpanRecord<_0> { @@ -5893,7 +6043,8 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct EraRewardPoints<_0> { pub total: ::core::primitive::u32, - pub individual: ::subxt::utils::KeyedVec<_0, ::core::primitive::u32>, + pub individual: + ::subxt::ext::subxt_core::utils::KeyedVec<_0, ::core::primitive::u32>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum Forcing { @@ -5909,7 +6060,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct Nominations { pub targets: runtime_types::bounded_collections::bounded_vec::BoundedVec< - ::subxt::utils::AccountId32, + ::subxt::ext::subxt_core::utils::AccountId32, >, pub submitted_in: ::core::primitive::u32, pub suppressed: ::core::primitive::bool, @@ -5929,7 +6080,7 @@ pub mod runtime_types { } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct StakingLedger { - pub stash: ::subxt::utils::AccountId32, + pub stash: ::subxt::ext::subxt_core::utils::AccountId32, #[codec(compact)] pub total: ::core::primitive::u128, #[codec(compact)] @@ -5946,8 +6097,8 @@ pub mod runtime_types { pub struct UnappliedSlash<_0, _1> { pub validator: _0, pub own: _1, - pub others: ::std::vec::Vec<(_0, _1)>, - pub reporters: ::std::vec::Vec<_0>, + pub others: ::subxt::ext::subxt_core::alloc::vec::Vec<(_0, _1)>, + pub reporters: ::subxt::ext::subxt_core::alloc::vec::Vec<_0>, pub payout: _1, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -5974,24 +6125,36 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::sudo`]."] sudo { - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::sudo_unchecked_weight`]."] sudo_unchecked_weight { - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, weight: runtime_types::sp_weights::weight_v2::Weight, }, #[codec(index = 2)] #[doc = "See [`Pallet::set_key`]."] set_key { - new: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + new: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 3)] #[doc = "See [`Pallet::sudo_as`]."] sudo_as { - who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - call: ::std::boxed::Box, + who: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 4)] #[doc = "See [`Pallet::remove_key`]."] @@ -6016,8 +6179,8 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "The sudo key has been updated."] KeyChanged { - old: ::core::option::Option<::subxt::utils::AccountId32>, - new: ::subxt::utils::AccountId32, + old: ::core::option::Option<::subxt::ext::subxt_core::utils::AccountId32>, + new: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 2)] #[doc = "The key was permanently removed."] @@ -6058,7 +6221,7 @@ pub mod runtime_types { #[doc = "A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,"] #[doc = "has been paid by `who`."] TransactionFeePaid { - who: ::subxt::utils::AccountId32, + who: ::subxt::ext::subxt_core::utils::AccountId32, actual_fee: ::core::primitive::u128, tip: ::core::primitive::u128, }, @@ -6086,7 +6249,10 @@ pub mod runtime_types { propose_spend { #[codec(compact)] value: ::core::primitive::u128, - beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + beneficiary: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::reject_proposal`]."] @@ -6105,7 +6271,10 @@ pub mod runtime_types { spend_local { #[codec(compact)] amount: ::core::primitive::u128, - beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + beneficiary: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 4)] #[doc = "See [`Pallet::remove_approval`]."] @@ -6116,10 +6285,12 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::spend`]."] spend { - asset_kind: ::std::boxed::Box<()>, + asset_kind: ::subxt::ext::subxt_core::alloc::boxed::Box<()>, #[codec(compact)] amount: ::core::primitive::u128, - beneficiary: ::std::boxed::Box<::subxt::utils::AccountId32>, + beneficiary: ::subxt::ext::subxt_core::alloc::boxed::Box< + ::subxt::ext::subxt_core::utils::AccountId32, + >, valid_from: ::core::option::Option<::core::primitive::u32>, }, #[codec(index = 6)] @@ -6191,7 +6362,7 @@ pub mod runtime_types { Awarded { proposal_index: ::core::primitive::u32, award: ::core::primitive::u128, - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 3)] #[doc = "A proposal was rejected; funds were slashed."] @@ -6217,7 +6388,7 @@ pub mod runtime_types { SpendApproved { proposal_index: ::core::primitive::u32, amount: ::core::primitive::u128, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, }, #[codec(index = 8)] #[doc = "The inactive funds of the pallet have been updated."] @@ -6231,7 +6402,7 @@ pub mod runtime_types { index: ::core::primitive::u32, asset_kind: (), amount: ::core::primitive::u128, - beneficiary: ::subxt::utils::AccountId32, + beneficiary: ::subxt::ext::subxt_core::utils::AccountId32, valid_from: ::core::primitive::u32, expire_at: ::core::primitive::u32, }, @@ -6281,7 +6452,7 @@ pub mod runtime_types { pub expire_at: _3, pub status: runtime_types::pallet_treasury::PaymentState<_0>, #[codec(skip)] - pub __subxt_unused_type_params: ::core::marker::PhantomData<_4>, + pub __ignore: ::core::marker::PhantomData<_4>, } } pub mod pallet_utility { @@ -6294,34 +6465,48 @@ pub mod runtime_types { #[codec(index = 0)] #[doc = "See [`Pallet::batch`]."] batch { - calls: ::std::vec::Vec, + calls: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 1)] #[doc = "See [`Pallet::as_derivative`]."] as_derivative { index: ::core::primitive::u16, - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 2)] #[doc = "See [`Pallet::batch_all`]."] batch_all { - calls: ::std::vec::Vec, + calls: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 3)] #[doc = "See [`Pallet::dispatch_as`]."] dispatch_as { - as_origin: ::std::boxed::Box, - call: ::std::boxed::Box, + as_origin: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::OriginCaller, + >, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 4)] #[doc = "See [`Pallet::force_batch`]."] force_batch { - calls: ::std::vec::Vec, + calls: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::vara_runtime::RuntimeCall, + >, }, #[codec(index = 5)] #[doc = "See [`Pallet::with_weight`]."] with_weight { - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, weight: runtime_types::sp_weights::weight_v2::Weight, }, } @@ -6378,12 +6563,18 @@ pub mod runtime_types { #[codec(index = 1)] #[doc = "See [`Pallet::vest_other`]."] vest_other { - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, }, #[codec(index = 2)] #[doc = "See [`Pallet::vested_transfer`]."] vested_transfer { - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, schedule: runtime_types::pallet_vesting::vesting_info::VestingInfo< ::core::primitive::u128, ::core::primitive::u32, @@ -6392,8 +6583,14 @@ pub mod runtime_types { #[codec(index = 3)] #[doc = "See [`Pallet::force_vested_transfer`]."] force_vested_transfer { - source: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + source: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, schedule: runtime_types::pallet_vesting::vesting_info::VestingInfo< ::core::primitive::u128, ::core::primitive::u32, @@ -6408,7 +6605,10 @@ pub mod runtime_types { #[codec(index = 5)] #[doc = "See [`Pallet::force_remove_vesting_schedule`]."] force_remove_vesting_schedule { - target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, + target: ::subxt::ext::subxt_core::utils::MultiAddress< + ::subxt::ext::subxt_core::utils::AccountId32, + (), + >, schedule_index: ::core::primitive::u32, }, } @@ -6439,13 +6639,13 @@ pub mod runtime_types { #[doc = "The amount vested has been updated. This could indicate a change in funds available."] #[doc = "The balance given is the amount which is left unvested (and thus locked)."] VestingUpdated { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, unvested: ::core::primitive::u128, }, #[codec(index = 1)] #[doc = "An \\[account\\] has become fully vested."] VestingCompleted { - account: ::subxt::utils::AccountId32, + account: ::subxt::ext::subxt_core::utils::AccountId32, }, } } @@ -6475,21 +6675,27 @@ pub mod runtime_types { pub enum Call { #[codec(index = 0)] #[doc = "See [`Pallet::whitelist_call`]."] - whitelist_call { call_hash: ::subxt::utils::H256 }, + whitelist_call { + call_hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 1)] #[doc = "See [`Pallet::remove_whitelisted_call`]."] - remove_whitelisted_call { call_hash: ::subxt::utils::H256 }, + remove_whitelisted_call { + call_hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 2)] #[doc = "See [`Pallet::dispatch_whitelisted_call`]."] dispatch_whitelisted_call { - call_hash: ::subxt::utils::H256, + call_hash: ::subxt::ext::subxt_core::utils::H256, call_encoded_len: ::core::primitive::u32, call_weight_witness: runtime_types::sp_weights::weight_v2::Weight, }, #[codec(index = 3)] #[doc = "See [`Pallet::dispatch_whitelisted_call_with_preimage`]."] dispatch_whitelisted_call_with_preimage { - call: ::std::boxed::Box, + call: ::subxt::ext::subxt_core::alloc::boxed::Box< + runtime_types::vara_runtime::RuntimeCall, + >, }, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -6515,12 +6721,16 @@ pub mod runtime_types { #[doc = "The `Event` enum of this pallet"] pub enum Event { #[codec(index = 0)] - CallWhitelisted { call_hash: ::subxt::utils::H256 }, + CallWhitelisted { + call_hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 1)] - WhitelistedCallRemoved { call_hash: ::subxt::utils::H256 }, + WhitelistedCallRemoved { + call_hash: ::subxt::ext::subxt_core::utils::H256, + }, #[codec(index = 2)] WhitelistedCallDispatched { - call_hash: ::subxt::utils::H256, + call_hash: ::subxt::ext::subxt_core::utils::H256, result: ::core::result::Result< runtime_types::frame_support::dispatch::PostDispatchInfo, runtime_types::sp_runtime::DispatchErrorWithPostInfo< @@ -6543,7 +6753,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct FixedI64(pub ::core::primitive::i64); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6554,7 +6764,7 @@ pub mod runtime_types { pub mod per_things { use super::runtime_types; #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6562,7 +6772,7 @@ pub mod runtime_types { )] pub struct PerU16(pub ::core::primitive::u16); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6570,7 +6780,7 @@ pub mod runtime_types { )] pub struct Perbill(pub ::core::primitive::u32); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6578,7 +6788,7 @@ pub mod runtime_types { )] pub struct Percent(pub ::core::primitive::u8); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6586,7 +6796,7 @@ pub mod runtime_types { )] pub struct Permill(pub ::core::primitive::u32); #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6717,7 +6927,7 @@ pub mod runtime_types { pub second_header: _0, } #[derive( - ::subxt::ext::codec::CompactAs, + ::subxt::ext ::subxt_core::ext::codec::CompactAs, Debug, crate::gp::Decode, crate::gp::DecodeAsType, @@ -6775,7 +6985,8 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct Support<_0> { pub total: ::core::primitive::u128, - pub voters: ::std::vec::Vec<(_0, ::core::primitive::u128)>, + pub voters: + ::subxt::ext::subxt_core::alloc::vec::Vec<(_0, ::core::primitive::u128)>, } } pub mod sp_runtime { @@ -6788,8 +6999,9 @@ pub mod runtime_types { Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode, )] pub struct Digest { - pub logs: - ::std::vec::Vec, + pub logs: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::sp_runtime::generic::digest::DigestItem, + >, } #[derive( Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode, @@ -6798,20 +7010,20 @@ pub mod runtime_types { #[codec(index = 6)] PreRuntime( [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, ), #[codec(index = 4)] Consensus( [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, ), #[codec(index = 5)] Seal( [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, ), #[codec(index = 0)] - Other(::std::vec::Vec<::core::primitive::u8>), + Other(::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>), #[codec(index = 8)] RuntimeEnvironmentUpdated, } @@ -7342,11 +7554,11 @@ pub mod runtime_types { Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode, )] pub struct Header<_0> { - pub parent_hash: ::subxt::utils::H256, + pub parent_hash: ::subxt::ext::subxt_core::utils::H256, #[codec(compact)] pub number: _0, - pub state_root: ::subxt::utils::H256, - pub extrinsics_root: ::subxt::utils::H256, + pub state_root: ::subxt::ext::subxt_core::utils::H256, + pub extrinsics_root: ::subxt::ext::subxt_core::utils::H256, pub digest: runtime_types::sp_runtime::generic::digest::Digest, } } @@ -7442,7 +7654,9 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct MembershipProof { pub session: ::core::primitive::u32, - pub trie_nodes: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, + pub trie_nodes: ::subxt::ext::subxt_core::alloc::vec::Vec< + ::subxt::ext::subxt_core::alloc::vec::Vec<::core::primitive::u8>, + >, pub validator_count: ::core::primitive::u32, } } @@ -7453,7 +7667,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct OffenceDetails<_0, _1> { pub offender: _1, - pub reporters: ::std::vec::Vec<_0>, + pub reporters: ::subxt::ext::subxt_core::alloc::vec::Vec<_0>, } } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] @@ -7462,13 +7676,17 @@ pub mod runtime_types { pub total: _1, #[codec(compact)] pub own: _1, - pub others: ::std::vec::Vec>, + pub others: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::sp_staking::IndividualExposure<_0, _1>, + >, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct ExposurePage<_0, _1> { #[codec(compact)] pub page_total: _1, - pub others: ::std::vec::Vec>, + pub others: ::subxt::ext::subxt_core::alloc::vec::Vec< + runtime_types::sp_staking::IndividualExposure<_0, _1>, + >, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct IndividualExposure<_0, _1> { @@ -7490,13 +7708,15 @@ pub mod runtime_types { use super::runtime_types; #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct RuntimeVersion { - pub spec_name: ::std::string::String, - pub impl_name: ::std::string::String, + pub spec_name: ::subxt::ext::subxt_core::alloc::string::String, + pub impl_name: ::subxt::ext::subxt_core::alloc::string::String, pub authoring_version: ::core::primitive::u32, pub spec_version: ::core::primitive::u32, pub impl_version: ::core::primitive::u32, - pub apis: - ::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32)>, + pub apis: ::subxt::ext::subxt_core::alloc::vec::Vec<( + [::core::primitive::u8; 8usize], + ::core::primitive::u32, + )>, pub transaction_version: ::core::primitive::u32, pub state_version: ::core::primitive::u8, } @@ -7589,166 +7809,168 @@ pub mod runtime_types { pub struct CustomCheckNonce(#[codec(compact)] pub ::core::primitive::u32); #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct NposSolution16 { - pub votes1: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, - ::subxt::ext::codec::Compact<::core::primitive::u16>, + pub votes1: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes2: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes2: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, ( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ), - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes3: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes3: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 2usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes4: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes4: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 3usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes5: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes5: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 4usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes6: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes6: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 5usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes7: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes7: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 6usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes8: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes8: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 7usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes9: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes9: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 8usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes10: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes10: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 9usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes11: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes11: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 10usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes12: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes12: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 11usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes13: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes13: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 12usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes14: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes14: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 13usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes15: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes15: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 14usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, - pub votes16: ::std::vec::Vec<( - ::subxt::ext::codec::Compact<::core::primitive::u32>, + pub votes16: ::subxt::ext::subxt_core::alloc::vec::Vec<( + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u32>, [( - ::subxt::ext::codec::Compact<::core::primitive::u16>, - ::subxt::ext::codec::Compact< + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact< runtime_types::sp_arithmetic::per_things::PerU16, >, ); 15usize], - ::subxt::ext::codec::Compact<::core::primitive::u16>, + ::subxt::ext::subxt_core::ext::codec::Compact<::core::primitive::u16>, )>, } #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub enum OriginCaller { #[codec(index = 0)] system( - runtime_types::frame_support::dispatch::RawOrigin<::subxt::utils::AccountId32>, + runtime_types::frame_support::dispatch::RawOrigin< + ::subxt::ext::subxt_core::utils::AccountId32, + >, ), #[codec(index = 20)] Origins( @@ -7807,7 +8029,7 @@ pub mod runtime_types { #[codec(index = 18)] FellowshipCollective(runtime_types::pallet_ranked_collective::pallet::Call), #[codec(index = 19)] - FellowshipReferenda(runtime_types::pallet_referenda::pallet::Call2), + FellowshipReferenda(runtime_types::pallet_referenda::pallet::Call), #[codec(index = 21)] Whitelist(runtime_types::pallet_whitelist::pallet::Call), #[codec(index = 22)] @@ -7874,7 +8096,7 @@ pub mod runtime_types { #[codec(index = 18)] FellowshipCollective(runtime_types::pallet_ranked_collective::pallet::Error), #[codec(index = 19)] - FellowshipReferenda(runtime_types::pallet_referenda::pallet::Error2), + FellowshipReferenda(runtime_types::pallet_referenda::pallet::Error), #[codec(index = 21)] Whitelist(runtime_types::pallet_whitelist::pallet::Error), #[codec(index = 22)] @@ -7947,7 +8169,7 @@ pub mod runtime_types { #[codec(index = 16)] ConvictionVoting(runtime_types::pallet_conviction_voting::pallet::Event), #[codec(index = 17)] - Referenda(runtime_types::pallet_referenda::pallet::Event), + Referenda(runtime_types::pallet_referenda::pallet::Event1), #[codec(index = 18)] FellowshipCollective(runtime_types::pallet_ranked_collective::pallet::Event), #[codec(index = 19)] @@ -9718,7 +9940,7 @@ pub mod exports { pub use super::runtime_types::pallet_conviction_voting::pallet::Event; } pub mod referenda { - pub use super::runtime_types::pallet_referenda::pallet::Event; + pub use super::runtime_types::pallet_referenda::pallet::Event1 as Event; } pub mod fellowship_collective { pub use super::runtime_types::pallet_ranked_collective::pallet::Event; From 02ca2a76eb6f2da959a64043c3b8f3c469bad7e1 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Fri, 23 Aug 2024 13:09:49 +0200 Subject: [PATCH 14/22] gclient create_program_bytes_with_voucher, tesst --- gclient/src/api/calls.rs | 66 ++++++++++++++++++++++++++++++++++++++++ gclient/tests/voucher.rs | 22 ++++++++++++-- gsdk/tests/voucher.rs | 8 ++--- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/gclient/src/api/calls.rs b/gclient/src/api/calls.rs index faa3e06226a..7f7a0177193 100644 --- a/gclient/src/api/calls.rs +++ b/gclient/src/api/calls.rs @@ -1469,6 +1469,72 @@ impl GearApi { Err(Error::EventNotFound) } + /// Same as [`create_program_bytes`](Self::create_program_bytes), but creates program + /// using voucher. + /// + /// # See also + /// - [`upload_code_with_voucher`](Self::upload_code_with_voucher) function uploads + #[allow(clippy::too_many_arguments)] + pub async fn create_program_bytes_with_voucher( + &self, + voucher_id: VoucherId, + code_id: CodeId, + salt: impl AsRef<[u8]>, + payload: impl AsRef<[u8]>, + gas_limit: u64, + value: u128, + keep_alive: bool, + ) -> Result<(MessageId, ProgramId, H256)> { + let salt = salt.as_ref().to_vec(); + let payload = payload.as_ref().to_vec(); + + let tx = self + .0 + .calls + .create_program_with_voucher( + voucher_id, code_id, salt, payload, gas_limit, value, keep_alive, + ) + .await?; + + for event in tx.wait_for_success().await?.iter() { + if let Event::Gear(GearEvent::MessageQueued { + id, + destination, + entry: MessageEntry::Init, + .. + }) = event?.as_root_event::()? + { + return Ok((id.into(), destination.into(), tx.block_hash())); + } + } + + Err(Error::EventNotFound) + } + + /// Same as [`create_program_bytes_with_voucher`](Self::create_program_bytes_with_voucher), but + /// initializes a newly created program with an encoded `payload`. + pub async fn create_program_with_voucher( + &self, + voucher_id: VoucherId, + code_id: CodeId, + salt: impl AsRef<[u8]>, + payload: impl Encode, + gas_limit: u64, + value: u128, + keep_alive: bool, + ) -> Result<(MessageId, ProgramId, H256)> { + self.create_program_bytes_with_voucher( + voucher_id, + code_id, + salt, + payload.encode(), + gas_limit, + value, + keep_alive, + ) + .await + } + /// Same as [`send_message_bytes`](Self::send_message_bytes), but sends a /// message using voucher. pub async fn send_message_bytes_with_voucher( diff --git a/gclient/tests/voucher.rs b/gclient/tests/voucher.rs index 466563bb73c..c6117c17456 100644 --- a/gclient/tests/voucher.rs +++ b/gclient/tests/voucher.rs @@ -36,10 +36,12 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> let gas_limit = api.block_gas_limit()?; // Taking account balance. - let _balance = api.total_balance(api.account_id()).await?; + let initial_balance = api.free_balance(api.account_id()).await?; + dbg!(api.free_balance(api.account_id()).await?); // Subscribing for events. let mut listener = api.subscribe().await?; + dbg!(api.free_balance(api.account_id()).await?); // Issue voucher let (voucher_id, ..) = api @@ -50,16 +52,25 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> VoucherPermissions::all(), ) .await?; + dbg!(api.free_balance(api.account_id()).await?); // Upload code with voucher let (code_id, _) = api .upload_code_with_voucher(voucher_id.clone(), WASM_BINARY) .await?; - // Create program + // Create program with voucher let payload = InitMessage::Capacitor("15".to_string()).encode(); let (message_id, program_id, ..) = api - .create_program_bytes(code_id, vec![], payload, gas_limit, 0) + .create_program_bytes_with_voucher( + voucher_id.clone(), + code_id, + vec![], + payload, + gas_limit, + 0, + false, + ) .await?; // Asserting message succeed @@ -83,6 +94,11 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> // Decline voucher let (_voucher_id, ..) = api.decline_voucher_with_voucher(voucher_id.clone()).await?; + dbg!(api.free_balance(api.account_id()).await?); + + // Revoke voucher + let (_voucher_id, ..) = api.revoke_voucher(actor_id, voucher_id.clone()).await?; + dbg!(api.free_balance(api.account_id()).await?); Ok(()) } diff --git a/gsdk/tests/voucher.rs b/gsdk/tests/voucher.rs index 0b4e7c951ae..0cff976f536 100644 --- a/gsdk/tests/voucher.rs +++ b/gsdk/tests/voucher.rs @@ -257,13 +257,13 @@ async fn test_voucher_balance_transfer_error() -> Result<()> { let error = get_issued_voucher_id(tx) .await - .expect_err("Error: Subxt(Runtime(Module(ModuleError())))"); + .expect_err("Expect: Subxt(Runtime(Module(ModuleError())))"); assert!(matches!( error, Error::Subxt(SubxtError::Runtime(subxt::error::DispatchError::Module( err - ))) if err.to_string() == "GearVoucher::BalanceTransfer".to_string() + ))) if err.to_string() == "GearVoucher::BalanceTransfer" )); Ok(()) } @@ -291,14 +291,14 @@ async fn test_voucher_duration_error() -> Result<()> { .await?; let error = get_issued_voucher_id(tx).await.expect_err( - "Error: Subxt(Runtime(Module(ModuleError())))", + "Expect: Subxt(Runtime(Module(ModuleError())))", ); assert!(matches!( error, Error::Subxt(SubxtError::Runtime(subxt::error::DispatchError::Module( err - ))) if err.to_string() == "GearVoucher::DurationOutOfBounds".to_string() + ))) if err.to_string() == "GearVoucher::DurationOutOfBounds" )); Ok(()) } From 67826650b5bbe71c5b5210d566461df92df0a2fc Mon Sep 17 00:00:00 2001 From: vobradovich Date: Fri, 23 Aug 2024 13:15:04 +0200 Subject: [PATCH 15/22] fix comments --- gclient/src/api/calls.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gclient/src/api/calls.rs b/gclient/src/api/calls.rs index 7f7a0177193..f0720ea4355 100644 --- a/gclient/src/api/calls.rs +++ b/gclient/src/api/calls.rs @@ -1469,11 +1469,12 @@ impl GearApi { Err(Error::EventNotFound) } - /// Same as [`create_program_bytes`](Self::create_program_bytes), but creates program - /// using voucher. + /// Same as [`create_program_bytes`](Self::create_program_bytes), but + /// creates program using voucher. /// /// # See also - /// - [`upload_code_with_voucher`](Self::upload_code_with_voucher) function uploads + /// - [`upload_code_with_voucher`](Self::upload_code_with_voucher) function + /// uploads #[allow(clippy::too_many_arguments)] pub async fn create_program_bytes_with_voucher( &self, From 3d3b34011a2ba348633bd6a96e636b5f8ba30fda Mon Sep 17 00:00:00 2001 From: vobradovich Date: Fri, 23 Aug 2024 13:28:35 +0200 Subject: [PATCH 16/22] fix clippy --- gclient/src/api/calls.rs | 1 + gclient/tests/voucher.rs | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gclient/src/api/calls.rs b/gclient/src/api/calls.rs index f0720ea4355..ce85bf10616 100644 --- a/gclient/src/api/calls.rs +++ b/gclient/src/api/calls.rs @@ -1514,6 +1514,7 @@ impl GearApi { /// Same as [`create_program_bytes_with_voucher`](Self::create_program_bytes_with_voucher), but /// initializes a newly created program with an encoded `payload`. + #[allow(clippy::too_many_arguments)] pub async fn create_program_with_voucher( &self, voucher_id: VoucherId, diff --git a/gclient/tests/voucher.rs b/gclient/tests/voucher.rs index c6117c17456..e48fa3e078f 100644 --- a/gclient/tests/voucher.rs +++ b/gclient/tests/voucher.rs @@ -36,12 +36,10 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> let gas_limit = api.block_gas_limit()?; // Taking account balance. - let initial_balance = api.free_balance(api.account_id()).await?; - dbg!(api.free_balance(api.account_id()).await?); + let _initial_balance = api.free_balance(api.account_id()).await?; // Subscribing for events. let mut listener = api.subscribe().await?; - dbg!(api.free_balance(api.account_id()).await?); // Issue voucher let (voucher_id, ..) = api @@ -52,7 +50,6 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> VoucherPermissions::all(), ) .await?; - dbg!(api.free_balance(api.account_id()).await?); // Upload code with voucher let (code_id, _) = api @@ -94,11 +91,9 @@ async fn voucher_issue_and_upload_code_and_send_message() -> anyhow::Result<()> // Decline voucher let (_voucher_id, ..) = api.decline_voucher_with_voucher(voucher_id.clone()).await?; - dbg!(api.free_balance(api.account_id()).await?); // Revoke voucher let (_voucher_id, ..) = api.revoke_voucher(actor_id, voucher_id.clone()).await?; - dbg!(api.free_balance(api.account_id()).await?); Ok(()) } From d8717e9f5fe72fab4018cef9615e6ca7694b3849 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 29 Aug 2024 12:40:58 +0200 Subject: [PATCH 17/22] add migration & test --- pallets/gear-voucher/Cargo.toml | 9 +- pallets/gear-voucher/src/lib.rs | 4 +- pallets/gear-voucher/src/migrations/mod.rs | 19 ++ .../src/migrations/voucher_permissions.rs | 230 ++++++++++++++++++ 4 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 pallets/gear-voucher/src/migrations/mod.rs create mode 100644 pallets/gear-voucher/src/migrations/voucher_permissions.rs diff --git a/pallets/gear-voucher/Cargo.toml b/pallets/gear-voucher/Cargo.toml index 8308fb1816b..76ee28870fe 100644 --- a/pallets/gear-voucher/Cargo.toml +++ b/pallets/gear-voucher/Cargo.toml @@ -13,7 +13,10 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } +parity-scale-codec = { workspace = true, features = [ + "derive", + "max-encoded-len", +] } scale-info = { workspace = true, features = ["derive"] } log.workspace = true parity-wasm = { workspace = true, optional = true } @@ -37,10 +40,10 @@ pallet-balances.workspace = true [dev-dependencies] env_logger.workspace = true common = { workspace = true, features = ["std"] } -sp-core = {workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } [features] -default = ['std'] +default = ["std"] std = [ "parity-scale-codec/std", "log/std", diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index 58079f97f52..bef78d5a17a 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -41,7 +41,7 @@ mod benchmarking; mod internal; - +pub mod migrations; pub mod weights; #[cfg(test)] @@ -68,7 +68,7 @@ type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; /// The current storage version. -const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); +const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[frame_support::pallet] pub mod pallet { diff --git a/pallets/gear-voucher/src/migrations/mod.rs b/pallets/gear-voucher/src/migrations/mod.rs new file mode 100644 index 00000000000..7c9388bc85a --- /dev/null +++ b/pallets/gear-voucher/src/migrations/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Gear. +// +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pub mod voucher_permissions; diff --git a/pallets/gear-voucher/src/migrations/voucher_permissions.rs b/pallets/gear-voucher/src/migrations/voucher_permissions.rs new file mode 100644 index 00000000000..87bed723e93 --- /dev/null +++ b/pallets/gear-voucher/src/migrations/voucher_permissions.rs @@ -0,0 +1,230 @@ +// This file is part of Gear. + +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use crate::{AccountIdOf, Config, Pallet, VoucherInfo, VoucherPermissions, Vouchers}; +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, StorageVersion}, + weights::Weight, +}; +use frame_system::pallet_prelude::BlockNumberFor; +use sp_std::marker::PhantomData; +use std::collections::BTreeSet; +#[cfg(feature = "try-runtime")] +use { + frame_support::ensure, + sp_runtime::{ + codec::{Decode, Encode}, + TryRuntimeError, + }, + sp_std::vec::Vec, +}; + +const MIGRATE_FROM_VERSION: u16 = 0; +const MIGRATE_TO_VERSION: u16 = 1; +const ALLOWED_CURRENT_STORAGE_VERSION: u16 = 1; + +pub struct VoucherPermissionsMigration(PhantomData); + +impl OnRuntimeUpgrade for VoucherPermissionsMigration { + fn on_runtime_upgrade() -> Weight { + let onchain = Pallet::::on_chain_storage_version(); + + // 1 read for onchain storage version + let mut weight = T::DbWeight::get().reads(1); + let mut counter = 0; + + if onchain == MIGRATE_FROM_VERSION { + let current = Pallet::::current_storage_version(); + if current != ALLOWED_CURRENT_STORAGE_VERSION { + log::error!("❌ Migration is not allowed for current storage version {current:?}."); + return weight; + } + + let update_to = StorageVersion::new(MIGRATE_TO_VERSION); + log::info!("🚚 Running migration from {onchain:?} to {update_to:?}, current storage version is {current:?}."); + + Vouchers::::translate( + |_, _, voucher_v0: v0::VoucherInfo, BlockNumberFor>| { + weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); + + counter += 1; + + let voucher = VoucherInfo { + owner: voucher_v0.owner, + expiry: voucher_v0.expiry, + permissions: VoucherPermissions { + programs: voucher_v0.programs, + code_uploading: voucher_v0.code_uploading, + // By default - deny create porgram from code + code_ids: Some(BTreeSet::new()), + }, + }; + Some(voucher) + }, + ); + + // Put new storage version + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + update_to.put::>(); + + log::info!("✅ Successfully migrated storage. {counter} codes have been migrated"); + } else { + log::info!("🟠 Migration requires onchain version {MIGRATE_FROM_VERSION}, so was skipped for {onchain:?}"); + } + + weight + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + let current = Pallet::::current_storage_version(); + let onchain = Pallet::::on_chain_storage_version(); + + let res = if onchain == MIGRATE_FROM_VERSION { + ensure!( + current == ALLOWED_CURRENT_STORAGE_VERSION, + "Current storage version is not allowed for migration, check migration code in order to allow it." + ); + + Some(v0::Vouchers::::iter_keys().count() as u64) + } else { + None + }; + + Ok(res.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(state: Vec) -> Result<(), TryRuntimeError> { + if let Some(old_count) = Option::::decode(&mut state.as_ref()) + .map_err(|_| "`pre_upgrade` provided an invalid state")? + { + let count = Vouchers::::iter_keys().count() as u64; + ensure!(old_count == count, "incorrect count of elements"); + } + + Ok(()) + } +} + +mod v0 { + use crate::AccountIdOf; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + use gear_core::ids::ProgramId; + use sp_runtime::{ + codec::{Decode, Encode}, + scale_info::TypeInfo, + }; + use sp_std::collections::btree_set::BTreeSet; + + #[cfg(feature = "try-runtime")] + use { + crate::{Config, Pallet, VoucherId}, + frame_support::traits::{PalletInfo, StorageInstance}, + sp_std::marker::PhantomData, + }; + + /// Type containing all data about voucher. + #[derive(Debug, Encode, Decode, TypeInfo)] + pub struct VoucherInfo { + /// Owner of the voucher. + /// May be different to original issuer. + /// Owner manages and claims back remaining balance of the voucher. + pub owner: AccountId, + /// Set of programs this voucher could be used to interact with. + /// In case of [`None`] means any gear program. + pub programs: Option>, + /// Flag if this voucher's covers uploading codes as prepaid call. + pub code_uploading: bool, + /// The block number at and after which voucher couldn't be used and + /// can be revoked by owner. + pub expiry: BlockNumber, + } + + #[cfg(feature = "try-runtime")] + pub struct VouchersPrefix(PhantomData); + + #[cfg(feature = "try-runtime")] + impl StorageInstance for VouchersPrefix { + const STORAGE_PREFIX: &'static str = "Vouchers"; + + fn pallet_prefix() -> &'static str { + <::PalletInfo as PalletInfo>::name::>() + .expect("No name found for the pallet in the runtime!") + } + } + + #[cfg(feature = "try-runtime")] + pub type Vouchers = StorageDoubleMap< + VouchersPrefix, + Identity, + AccountIdOf, + Identity, + VoucherId, + VoucherInfo, BlockNumberFor>, + >; +} + +#[cfg(test)] +#[cfg(feature = "try-runtime")] +mod test { + use super::*; + use crate::{mock::*, VoucherId}; + use frame_support::traits::StorageVersion; + use sp_runtime::traits::Zero; + + #[test] + fn voucher_migratge_permissions_works() { + let _ = env_logger::try_init(); + + new_test_ext().execute_with(|| { + StorageVersion::new(MIGRATE_FROM_VERSION).put::(); + + let owner = AccountIdOf::::from(0u64); + let spender = AccountIdOf::::from(1u64); + let expiry = >::block_number().saturating_add(100); + let voucher_id = VoucherId::generate::(); + + let voucher_v0 = v0::VoucherInfo { + owner, + programs: None, + code_uploading: true, + expiry, + }; + + v0::Vouchers::::insert(spender, voucher_id, voucher_v0); + + // act + let state = VoucherPermissionsMigration::::pre_upgrade().unwrap(); + let w = VoucherPermissionsMigration::::on_runtime_upgrade(); + VoucherPermissionsMigration::::post_upgrade(state).unwrap(); + + // assert + assert!(!w.is_zero()); + + let voucher_v1 = Vouchers::::get(spender, voucher_id).unwrap(); + assert_eq!(owner, voucher_v1.owner); + assert_eq!(expiry, voucher_v1.expiry); + assert_eq!(None, voucher_v1.permissions.programs); + assert_eq!(true, voucher_v1.permissions.code_uploading); + assert_eq!(Some(BTreeSet::new()), voucher_v1.permissions.code_ids); + }); + } +} From cc0e0f5e01d0590e2491773c674aa72d89da412b Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 29 Aug 2024 13:02:35 +0200 Subject: [PATCH 18/22] fix clippy --- pallets/gear-voucher/src/migrations/voucher_permissions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/gear-voucher/src/migrations/voucher_permissions.rs b/pallets/gear-voucher/src/migrations/voucher_permissions.rs index 87bed723e93..a5fd37d5bcd 100644 --- a/pallets/gear-voucher/src/migrations/voucher_permissions.rs +++ b/pallets/gear-voucher/src/migrations/voucher_permissions.rs @@ -223,7 +223,7 @@ mod test { assert_eq!(owner, voucher_v1.owner); assert_eq!(expiry, voucher_v1.expiry); assert_eq!(None, voucher_v1.permissions.programs); - assert_eq!(true, voucher_v1.permissions.code_uploading); + assert!(voucher_v1.permissions.code_uploading); assert_eq!(Some(BTreeSet::new()), voucher_v1.permissions.code_ids); }); } From 3089ce58b648212585500ee33744ec64fc5f12a6 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 29 Aug 2024 13:12:16 +0200 Subject: [PATCH 19/22] add min transfer test --- gsdk/tests/voucher.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gsdk/tests/voucher.rs b/gsdk/tests/voucher.rs index 0cff976f536..e45734df319 100644 --- a/gsdk/tests/voucher.rs +++ b/gsdk/tests/voucher.rs @@ -234,6 +234,35 @@ async fn test_send_message_with_voucher() -> Result<()> { Ok(()) } +#[tokio::test] +async fn test_voucher_transfer_below_minimum_error() -> Result<()> { + // arrange + let node = dev_node(); + + let signer = Api::new(node.ws().as_str()) + .await? + .signer("//Alice", None)?; + let account_id = signer.account_id(); + + // 1. issue voucher + let tx = signer + .calls + .issue_voucher(account_id.clone(), 1_000, 100, VoucherPermissions::all()) + .await?; + + let error = get_issued_voucher_id(tx) + .await + .expect_err("Expect: Subxt(Runtime(Module(ModuleError())))"); + + assert!(matches!( + error, + Error::Subxt(SubxtError::Runtime(subxt::error::DispatchError::Module( + err + ))) if err.to_string() == "GearVoucher::BalanceTransfer" + )); + Ok(()) +} + #[tokio::test] async fn test_voucher_balance_transfer_error() -> Result<()> { // arrange From 65ab77713905269bf64519fbab25ff52c2ea440c Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 29 Aug 2024 13:44:02 +0200 Subject: [PATCH 20/22] fix use --- .../src/migrations/voucher_permissions.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/gear-voucher/src/migrations/voucher_permissions.rs b/pallets/gear-voucher/src/migrations/voucher_permissions.rs index a5fd37d5bcd..a22b57b17cc 100644 --- a/pallets/gear-voucher/src/migrations/voucher_permissions.rs +++ b/pallets/gear-voucher/src/migrations/voucher_permissions.rs @@ -124,20 +124,20 @@ impl OnRuntimeUpgrade for VoucherPermissionsMigration { } mod v0 { - use crate::AccountIdOf; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; use gear_core::ids::ProgramId; use sp_runtime::{ codec::{Decode, Encode}, scale_info::TypeInfo, }; use sp_std::collections::btree_set::BTreeSet; - #[cfg(feature = "try-runtime")] use { - crate::{Config, Pallet, VoucherId}, - frame_support::traits::{PalletInfo, StorageInstance}, + crate::{AccountIdOf, Config, Pallet, VoucherId}, + frame_support::{ + pallet_prelude::*, + traits::{PalletInfo, StorageInstance}, + }, + frame_system::pallet_prelude::*, sp_std::marker::PhantomData, }; From 74a7cfeec9ef9398da743260a3c7aec3561c24e1 Mon Sep 17 00:00:00 2001 From: vobradovich Date: Thu, 29 Aug 2024 13:59:47 +0200 Subject: [PATCH 21/22] fix --- pallets/gear-voucher/src/migrations/voucher_permissions.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/gear-voucher/src/migrations/voucher_permissions.rs b/pallets/gear-voucher/src/migrations/voucher_permissions.rs index a22b57b17cc..9370572092d 100644 --- a/pallets/gear-voucher/src/migrations/voucher_permissions.rs +++ b/pallets/gear-voucher/src/migrations/voucher_permissions.rs @@ -22,8 +22,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use sp_std::marker::PhantomData; -use std::collections::BTreeSet; +use sp_std::{collections::btree_set::BTreeSet, marker::PhantomData}; #[cfg(feature = "try-runtime")] use { frame_support::ensure, From eaf7fd9d7962c30689fee490557d137cd400855a Mon Sep 17 00:00:00 2001 From: vobradovich Date: Tue, 3 Sep 2024 12:48:39 +0200 Subject: [PATCH 22/22] add to vara migrations --- runtime/vara/src/migrations.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/vara/src/migrations.rs b/runtime/vara/src/migrations.rs index 9b7aa1ddb0c..382cf9aafc4 100644 --- a/runtime/vara/src/migrations.rs +++ b/runtime/vara/src/migrations.rs @@ -27,6 +27,8 @@ pub type Migrations = ( pallet_grandpa::migrations::MigrateV4ToV5, // move allocations to a separate storage item and remove pages_with_data field from program pallet_gear_program::migrations::allocations::MigrateAllocations, + // move voucher permissions to a separate struct + pallet_gear_voucher::migrations::voucher_permissions::VoucherPermissionsMigration, ); mod staking {