diff --git a/Cargo.lock b/Cargo.lock index 5ffb73c9c677..935468746338 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9407,6 +9407,7 @@ dependencies = [ "pallet-proxy", "pallet-timestamp", "pallet-utility", + "pallet-xcm", "parity-scale-codec", "pretty_assertions", "rand 0.8.5", @@ -9423,6 +9424,8 @@ dependencies = [ "wasm-instrument 0.4.0", "wasmi 0.30.0", "wat", + "xcm", + "xcm-executor", ] [[package]] diff --git a/substrate/frame/contracts/src/benchmarking/mod.rs b/substrate/frame/contracts/src/benchmarking/mod.rs index ac5787e23404..3fa66b966b24 100644 --- a/substrate/frame/contracts/src/benchmarking/mod.rs +++ b/substrate/frame/contracts/src/benchmarking/mod.rs @@ -97,7 +97,7 @@ where data: Vec, ) -> Result, &'static str> { let value = Pallet::::min_balance(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); let salt = vec![0xff]; let addr = Contracts::::contract_address(&caller, &module.hash, &data, &salt); @@ -163,7 +163,7 @@ where /// Set the balance of the contract to the supplied amount. fn set_balance(&self, balance: BalanceOf) { - T::Currency::set_balance(&self.account_id, balance); + ::Currency::set_balance(&self.account_id, balance); } /// Returns `true` iff all storage entries related to code storage exist. @@ -291,7 +291,7 @@ benchmarks! { #[pov_mode = Measured] v14_migration_step { let account = account::("account", 0, 0); - T::Currency::set_balance(&account, caller_funding::()); + ::Currency::set_balance(&account, caller_funding::()); v14::store_dummy_code::>(account); let mut m = v14::Migration::>::default(); }: { @@ -406,21 +406,21 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); }: _(origin, value, Weight::MAX, None, code, input, salt) verify { - let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); + let deposit = ::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); // uploading the code reserves some balance in the callers account - let code_deposit = T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &caller); + let code_deposit = ::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &caller); assert_eq!( - T::Currency::balance(&caller), + ::Currency::balance(&caller), caller_funding::() - value - deposit - code_deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::balance(&addr), value + Pallet::::min_balance()); + assert_eq!(::Currency::balance(&addr), value + Pallet::::min_balance()); } // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. @@ -434,21 +434,21 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); Contracts::::store_code_raw(code, caller.clone())?; }: _(origin, value, Weight::MAX, None, hash, input, salt) verify { - let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); + let deposit = ::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); // value was removed from the caller assert_eq!( - T::Currency::balance(&caller), + ::Currency::balance(&caller), caller_funding::() - value - deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::balance(&addr), value + Pallet::::min_balance()); + assert_eq!(::Currency::balance(&addr), value + Pallet::::min_balance()); } // We just call a dummy contract to measure the overhead of the call extrinsic. @@ -467,17 +467,17 @@ benchmarks! { let value = Pallet::::min_balance(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); - let before = T::Currency::balance(&instance.account_id); + let before = ::Currency::balance(&instance.account_id); }: _(origin, callee, value, Weight::MAX, None, data) verify { - let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id); + let deposit = ::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id); // value and value transferred via call should be removed from the caller assert_eq!( - T::Currency::balance(&instance.caller), + ::Currency::balance(&instance.caller), caller_funding::() - instance.value - value - deposit - Pallet::::min_balance(), ); // contract should have received the value - assert_eq!(T::Currency::balance(&instance.account_id), before + value); + assert_eq!(::Currency::balance(&instance.account_id), before + value); // contract should still exist instance.info()?; } @@ -489,13 +489,13 @@ benchmarks! { upload_code { let c in 0 .. T::MaxCodeLen::get(); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); }: _(origin, code, None, Determinism::Enforced) verify { // uploading the code reserves some balance in the callers account - assert!(T::Currency::total_balance_on_hold(&caller) > 0u32.into()); + assert!(::Currency::total_balance_on_hold(&caller) > 0u32.into()); assert!(>::code_exists(&hash)); } @@ -505,17 +505,17 @@ benchmarks! { #[pov_mode = Measured] remove_code { let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?; assert_eq!(uploaded.code_hash, hash); - assert_eq!(uploaded.deposit, T::Currency::total_balance_on_hold(&caller)); + assert_eq!(uploaded.deposit, ::Currency::total_balance_on_hold(&caller)); assert!(>::code_exists(&hash)); }: _(origin, hash) verify { // removing the code should have unreserved the deposit - assert_eq!(T::Currency::total_balance_on_hold(&caller), 0u32.into()); + assert_eq!(::Currency::total_balance_on_hold(&caller), 0u32.into()); assert!(>::code_removed(&hash)); } @@ -889,7 +889,7 @@ benchmarks! { let beneficiary_len = beneficiary_bytes.len(); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); // Maximize the delegate_dependencies to account for the worst-case scenario. let code_hashes = (0..T::MaxDelegateDependencies::get()) @@ -941,15 +941,15 @@ benchmarks! { }); let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); - assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into()); - assert_eq!(T::Currency::balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); - assert_ne!(T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); + assert_eq!(::Currency::total_balance(&beneficiary), 0u32.into()); + assert_eq!(::Currency::balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); + assert_ne!(::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { - assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); - assert_eq!(T::Currency::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); + assert_eq!(::Currency::total_balance(&instance.account_id), 0u32.into()); + assert_eq!(::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); + assert_eq!(::Currency::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } @@ -1718,12 +1718,12 @@ benchmarks! { instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(T::Currency::total_balance(account), 0u32.into()); + assert_eq!(::Currency::total_balance(account), 0u32.into()); } }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) verify { for account in &accounts { - assert_eq!(T::Currency::total_balance(account), value); + assert_eq!(::Currency::total_balance(account), value); } } @@ -1812,7 +1812,7 @@ benchmarks! { .map(|i| { let code = WasmModule::::dummy_with_bytes(i); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(code.code, caller)?; Ok(code.hash) }) @@ -1934,7 +1934,7 @@ benchmarks! { .. Default::default() }); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(code.code, caller)?; Ok(code.hash) }) @@ -2040,7 +2040,7 @@ benchmarks! { let hash_bytes = callee_code.hash.encode(); let hash_len = hash_bytes.len(); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(callee_code.code, caller)?; let value: BalanceOf = t.into(); let value_bytes = value.encode(); @@ -2384,7 +2384,7 @@ benchmarks! { .map(|i| { let new_code = WasmModule::::dummy_with_bytes(i); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) @@ -2427,7 +2427,7 @@ benchmarks! { .map(|i| { let new_code = WasmModule::::dummy_with_bytes(65 + i); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) @@ -2465,7 +2465,7 @@ benchmarks! { .map(|i| { let new_code = WasmModule::::dummy_with_bytes(65 + i); let caller = whitelisted_caller(); - T::Currency::set_balance(&caller, caller_funding::()); + ::Currency::set_balance(&caller, caller_funding::()); Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) diff --git a/substrate/frame/contracts/src/exec.rs b/substrate/frame/contracts/src/exec.rs index 38c15a807c5d..1cb672c4d2ae 100644 --- a/substrate/frame/contracts/src/exec.rs +++ b/substrate/frame/contracts/src/exec.rs @@ -1102,7 +1102,7 @@ where value: BalanceOf, ) -> DispatchResult { if !value.is_zero() && from != to { - T::Currency::transfer(from, to, value, preservation) + ::Currency::transfer(from, to, value, preservation) .map_err(|_| Error::::TransferFailed)?; } Ok(()) @@ -1368,7 +1368,7 @@ where } fn balance(&self) -> BalanceOf { - T::Currency::balance(&self.top_frame().account_id) + ::Currency::balance(&self.top_frame().account_id) } fn value_transferred(&self) -> BalanceOf { @@ -1384,7 +1384,7 @@ where } fn minimum_balance(&self) -> BalanceOf { - T::Currency::minimum_balance() + ::Currency::minimum_balance() } fn deposit_event(&mut self, topics: Vec, data: Vec) { @@ -1441,7 +1441,8 @@ where } fn call_runtime(&self, call: ::RuntimeCall) -> DispatchResultWithPostInfo { - let mut origin: T::RuntimeOrigin = RawOrigin::Signed(self.address().clone()).into(); + let mut origin: ::RuntimeOrigin = + RawOrigin::Signed(self.address().clone()).into(); origin.add_filter(T::CallFilter::contains); call.dispatch(origin) } diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index e22e4a3f9ff8..5176e4baa13a 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -253,8 +253,10 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type RuntimeCall: Dispatchable - + GetDispatchInfo + type RuntimeCall: Dispatchable< + RuntimeOrigin = ::RuntimeOrigin, + PostInfo = PostDispatchInfo, + > + GetDispatchInfo + codec::Decode + IsType<::RuntimeCall>; @@ -425,7 +427,7 @@ pub mod pallet { } ContractInfo::::process_deletion_queue_batch(remaining_weight) - .saturating_add(T::WeightInfo::on_process_deletion_queue_batch()) + .saturating_add(::WeightInfo::on_process_deletion_queue_batch()) } fn integrity_test() { @@ -503,7 +505,7 @@ pub mod pallet { { /// Deprecated version if [`Self::call`] for use in an in-storage `Call`. #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::call().saturating_add(>::compat_weight_limit(*gas_limit)))] + #[pallet::weight(::WeightInfo::call().saturating_add(>::compat_weight_limit(*gas_limit)))] #[allow(deprecated)] #[deprecated(note = "1D weight is used in this extrinsic, please migrate to `call`")] pub fn call_old_weight( @@ -527,7 +529,7 @@ pub mod pallet { /// Deprecated version if [`Self::instantiate_with_code`] for use in an in-storage `Call`. #[pallet::call_index(1)] #[pallet::weight( - T::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32) + ::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32) .saturating_add(>::compat_weight_limit(*gas_limit)) )] #[allow(deprecated)] @@ -557,7 +559,7 @@ pub mod pallet { /// Deprecated version if [`Self::instantiate`] for use in an in-storage `Call`. #[pallet::call_index(2)] #[pallet::weight( - T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(>::compat_weight_limit(*gas_limit)) + ::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(>::compat_weight_limit(*gas_limit)) )] #[allow(deprecated)] #[deprecated(note = "1D weight is used in this extrinsic, please migrate to `instantiate`")] @@ -602,7 +604,7 @@ pub mod pallet { /// only be instantiated by permissioned entities. The same is true when uploading /// through [`Self::instantiate_with_code`]. #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::upload_code(code.len() as u32))] + #[pallet::weight(::WeightInfo::upload_code(code.len() as u32))] pub fn upload_code( origin: OriginFor, code: Vec, @@ -620,7 +622,7 @@ pub mod pallet { /// A code can only be removed by its original uploader (its owner) and only if it is /// not used by any contract. #[pallet::call_index(4)] - #[pallet::weight(T::WeightInfo::remove_code())] + #[pallet::weight(::WeightInfo::remove_code())] pub fn remove_code( origin: OriginFor, code_hash: CodeHash, @@ -643,7 +645,7 @@ pub mod pallet { /// that the contract address is no longer derived from its code hash after calling /// this dispatchable. #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::set_code())] + #[pallet::weight(::WeightInfo::set_code())] pub fn set_code( origin: OriginFor, dest: AccountIdLookupOf, @@ -690,7 +692,7 @@ pub mod pallet { /// * If no account exists and the call value is not less than `existential_deposit`, /// a regular account will be created and any value will be transferred. #[pallet::call_index(6)] - #[pallet::weight(T::WeightInfo::call().saturating_add(*gas_limit))] + #[pallet::weight(::WeightInfo::call().saturating_add(*gas_limit))] pub fn call( origin: OriginFor, dest: AccountIdLookupOf, @@ -716,7 +718,9 @@ pub mod pallet { output.result = Err(>::ContractReverted.into()); } } - output.gas_meter.into_dispatch_result(output.result, T::WeightInfo::call()) + output + .gas_meter + .into_dispatch_result(output.result, ::WeightInfo::call()) } /// Instantiates a new contract from the supplied `code` optionally transferring @@ -746,7 +750,7 @@ pub mod pallet { /// - The `deploy` function is executed in the context of the newly-created account. #[pallet::call_index(7)] #[pallet::weight( - T::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32) + ::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32) .saturating_add(*gas_limit) )] pub fn instantiate_with_code( @@ -795,7 +799,9 @@ pub mod pallet { output.gas_meter.into_dispatch_result( output.result.map(|(_address, output)| output), - T::WeightInfo::instantiate_with_code(code_len, data_len, salt_len), + ::WeightInfo::instantiate_with_code( + code_len, data_len, salt_len, + ), ) } @@ -806,7 +812,7 @@ pub mod pallet { /// must be supplied. #[pallet::call_index(8)] #[pallet::weight( - T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(*gas_limit) + ::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(*gas_limit) )] pub fn instantiate( origin: OriginFor, @@ -837,7 +843,7 @@ pub mod pallet { } output.gas_meter.into_dispatch_result( output.result.map(|(_address, output)| output), - T::WeightInfo::instantiate(data_len, salt_len), + ::WeightInfo::instantiate(data_len, salt_len), ) } @@ -846,12 +852,13 @@ pub mod pallet { /// for the chain. Note that while the migration is in progress, the pallet will also /// leverage the `on_idle` hooks to run migration steps. #[pallet::call_index(9)] - #[pallet::weight(T::WeightInfo::migrate().saturating_add(*weight_limit))] + #[pallet::weight(::WeightInfo::migrate().saturating_add(*weight_limit))] pub fn migrate(origin: OriginFor, weight_limit: Weight) -> DispatchResultWithPostInfo { use migration::MigrateResult::*; ensure_signed(origin)?; - let weight_limit = weight_limit.saturating_add(T::WeightInfo::migrate()); + let weight_limit = + weight_limit.saturating_add(::WeightInfo::migrate()); let (result, weight) = Migration::::migrate(weight_limit); match result { @@ -863,7 +870,7 @@ pub mod pallet { Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::Yes }), NoMigrationInProgress | NoMigrationPerformed => { let err: DispatchError = >::NoMigrationPerformed.into(); - Err(err.with_weight(T::WeightInfo::migrate())) + Err(err.with_weight(::WeightInfo::migrate())) }, } } @@ -1648,7 +1655,7 @@ impl Pallet { /// Return the existential deposit of [`Config::Currency`]. fn min_balance() -> BalanceOf { - >>::minimum_balance() + <::Currency as Inspect>>::minimum_balance() } /// Convert gas_limit from 1D Weight to a 2D Weight. diff --git a/substrate/frame/contracts/src/migration.rs b/substrate/frame/contracts/src/migration.rs index 3e3d6f37884c..8c3e048cd625 100644 --- a/substrate/frame/contracts/src/migration.rs +++ b/substrate/frame/contracts/src/migration.rs @@ -272,7 +272,7 @@ impl OnRuntimeUpgrade for Migration::WeightInfo::on_runtime_upgrade_noop() } // In case a migration is already in progress we create the next migration @@ -284,7 +284,7 @@ impl OnRuntimeUpgrade for Migration::WeightInfo::on_runtime_upgrade_in_progress() } log::info!( @@ -300,7 +300,7 @@ impl OnRuntimeUpgrade for Migration::WeightInfo::on_runtime_upgrade() } #[cfg(feature = "try-runtime")] @@ -364,13 +364,13 @@ impl Migration { let name = >::name(); let mut weight_left = weight_limit; - if weight_left.checked_reduce(T::WeightInfo::migrate()).is_none() { + if weight_left.checked_reduce(::WeightInfo::migrate()).is_none() { return (MigrateResult::NoMigrationPerformed, Weight::zero()) } MigrationInProgress::::mutate_exists(|progress| { let Some(cursor_before) = progress.as_mut() else { - return (MigrateResult::NoMigrationInProgress, T::WeightInfo::migration_noop()) + return (MigrateResult::NoMigrationInProgress, ::WeightInfo::migration_noop()) }; // if a migration is running it is always upgrading to the next version diff --git a/substrate/frame/contracts/src/migration/v09.rs b/substrate/frame/contracts/src/migration/v09.rs index 98fcccc2c0be..3761c9e90a8a 100644 --- a/substrate/frame/contracts/src/migration/v09.rs +++ b/substrate/frame/contracts/src/migration/v09.rs @@ -84,7 +84,7 @@ impl MigrationStep for Migration { const VERSION: u16 = 9; fn max_step_weight() -> Weight { - T::WeightInfo::v9_migration_step(T::MaxCodeLen::get()) + ::WeightInfo::v9_migration_step(T::MaxCodeLen::get()) } fn step(&mut self) -> (IsFinished, Weight) { @@ -106,10 +106,10 @@ impl MigrationStep for Migration { }; CodeStorage::::insert(key, module); self.last_code_hash = Some(key); - (IsFinished::No, T::WeightInfo::v9_migration_step(len)) + (IsFinished::No, ::WeightInfo::v9_migration_step(len)) } else { log::debug!(target: LOG_TARGET, "No more contracts code to migrate"); - (IsFinished::Yes, T::WeightInfo::v9_migration_step(0)) + (IsFinished::Yes, ::WeightInfo::v9_migration_step(0)) } } diff --git a/substrate/frame/contracts/src/migration/v10.rs b/substrate/frame/contracts/src/migration/v10.rs index f02e28f6fde3..8a6a933ed1f2 100644 --- a/substrate/frame/contracts/src/migration/v10.rs +++ b/substrate/frame/contracts/src/migration/v10.rs @@ -154,7 +154,7 @@ where const VERSION: u16 = 10; fn max_step_weight() -> Weight { - T::WeightInfo::v10_migration_step() + ::WeightInfo::v10_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -264,10 +264,10 @@ where // Store last key for next migration step self.last_account = Some(account); - (IsFinished::No, T::WeightInfo::v10_migration_step()) + (IsFinished::No, ::WeightInfo::v10_migration_step()) } else { log::debug!(target: LOG_TARGET, "Done Migrating contract info"); - (IsFinished::Yes, T::WeightInfo::v10_migration_step()) + (IsFinished::Yes, ::WeightInfo::v10_migration_step()) } } diff --git a/substrate/frame/contracts/src/migration/v11.rs b/substrate/frame/contracts/src/migration/v11.rs index a5b11f6e0897..8b7f70a1963b 100644 --- a/substrate/frame/contracts/src/migration/v11.rs +++ b/substrate/frame/contracts/src/migration/v11.rs @@ -76,7 +76,7 @@ impl MigrationStep for Migration { // but in practice the queue is always empty, so 128 is a good enough approximation for not // underestimating the weight of our migration. fn max_step_weight() -> Weight { - T::WeightInfo::v11_migration_step(128) + ::WeightInfo::v11_migration_step(128) } fn step(&mut self) -> (IsFinished, Weight) { @@ -101,7 +101,7 @@ impl MigrationStep for Migration { >::set(queue); } - (IsFinished::Yes, T::WeightInfo::v11_migration_step(len as u32)) + (IsFinished::Yes, ::WeightInfo::v11_migration_step(len as u32)) } #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/contracts/src/migration/v12.rs b/substrate/frame/contracts/src/migration/v12.rs index eb045aa42e9d..919636b353b7 100644 --- a/substrate/frame/contracts/src/migration/v12.rs +++ b/substrate/frame/contracts/src/migration/v12.rs @@ -143,7 +143,7 @@ where const VERSION: u16 = 12; fn max_step_weight() -> Weight { - T::WeightInfo::v12_migration_step(T::MaxCodeLen::get()) + ::WeightInfo::v12_migration_step(T::MaxCodeLen::get()) } fn step(&mut self) -> (IsFinished, Weight) { @@ -230,10 +230,10 @@ where self.last_code_hash = Some(hash); - (IsFinished::No, T::WeightInfo::v12_migration_step(code_len as u32)) + (IsFinished::No, ::WeightInfo::v12_migration_step(code_len as u32)) } else { log::debug!(target: LOG_TARGET, "No more OwnerInfo to migrate"); - (IsFinished::Yes, T::WeightInfo::v12_migration_step(0)) + (IsFinished::Yes, ::WeightInfo::v12_migration_step(0)) } } diff --git a/substrate/frame/contracts/src/migration/v13.rs b/substrate/frame/contracts/src/migration/v13.rs index dd2eb12eb62a..6a9f225a5bfe 100644 --- a/substrate/frame/contracts/src/migration/v13.rs +++ b/substrate/frame/contracts/src/migration/v13.rs @@ -99,7 +99,7 @@ impl MigrationStep for Migration { const VERSION: u16 = 13; fn max_step_weight() -> Weight { - T::WeightInfo::v13_migration_step() + ::WeightInfo::v13_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -126,10 +126,10 @@ impl MigrationStep for Migration { }; ContractInfoOf::::insert(key.clone(), info); self.last_account = Some(key); - (IsFinished::No, T::WeightInfo::v13_migration_step()) + (IsFinished::No, ::WeightInfo::v13_migration_step()) } else { log::debug!(target: LOG_TARGET, "No more contracts to migrate"); - (IsFinished::Yes, T::WeightInfo::v13_migration_step()) + (IsFinished::Yes, ::WeightInfo::v13_migration_step()) } } } diff --git a/substrate/frame/contracts/src/migration/v14.rs b/substrate/frame/contracts/src/migration/v14.rs index efb49dff4f10..3e1ded534e42 100644 --- a/substrate/frame/contracts/src/migration/v14.rs +++ b/substrate/frame/contracts/src/migration/v14.rs @@ -129,7 +129,7 @@ where const VERSION: u16 = 14; fn max_step_weight() -> Weight { - T::WeightInfo::v14_migration_step() + ::WeightInfo::v14_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -168,7 +168,7 @@ where hash, ); - T::Currency::hold( + ::Currency::hold( &HoldReason::CodeUploadDepositReserve.into(), &code_info.owner, amount, @@ -185,10 +185,10 @@ where }); self.last_code_hash = Some(hash); - (IsFinished::No, T::WeightInfo::v14_migration_step()) + (IsFinished::No, ::WeightInfo::v14_migration_step()) } else { log::debug!(target: LOG_TARGET, "No more code upload deposit to migrate"); - (IsFinished::Yes, T::WeightInfo::v14_migration_step()) + (IsFinished::Yes, ::WeightInfo::v14_migration_step()) } } @@ -228,7 +228,7 @@ where let count = owner_balance_allocation.len(); for (owner, old_balance_allocation) in owner_balance_allocation { let held = - T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &owner); + ::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &owner); log::debug!( target: LOG_TARGET, "Validating code upload deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", @@ -242,11 +242,11 @@ where target: LOG_TARGET, "Validating total balance for owner 0x{:?}, new: {:?}, old: {:?}", HexDisplay::from(&owner.encode()), - T::Currency::total_balance(&owner), + ::Currency::total_balance(&owner), old_balance_allocation.total ); ensure!( - T::Currency::total_balance(&owner) == + ::Currency::total_balance(&owner) == BalanceOf::::decode(&mut &old_balance_allocation.total.encode()[..]) .unwrap(), "Balance mismatch " diff --git a/substrate/frame/contracts/src/migration/v15.rs b/substrate/frame/contracts/src/migration/v15.rs index 180fe855ca66..018d6f3c838e 100644 --- a/substrate/frame/contracts/src/migration/v15.rs +++ b/substrate/frame/contracts/src/migration/v15.rs @@ -122,7 +122,7 @@ impl MigrationStep for Migration { const VERSION: u16 = 15; fn max_step_weight() -> Weight { - T::WeightInfo::v15_migration_step() + ::WeightInfo::v15_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -139,8 +139,8 @@ impl MigrationStep for Migration { System::::dec_consumers(deposit_account); // Get the deposit balance to transfer. - let total_deposit_balance = T::Currency::total_balance(deposit_account); - let reducible_deposit_balance = T::Currency::reducible_balance( + let total_deposit_balance = ::Currency::total_balance(deposit_account); + let reducible_deposit_balance = ::Currency::reducible_balance( deposit_account, Preservation::Expendable, Fortitude::Force, @@ -169,7 +169,7 @@ impl MigrationStep for Migration { HexDisplay::from(&deposit_account.encode()), HexDisplay::from(&account.encode()) ); - let transferred_deposit_balance = T::Currency::transfer( + let transferred_deposit_balance = ::Currency::transfer( deposit_account, &account, reducible_deposit_balance, @@ -202,7 +202,7 @@ impl MigrationStep for Migration { HexDisplay::from(&account.encode()) ); - T::Currency::hold( + ::Currency::hold( &HoldReason::StorageDepositReserve.into(), &account, transferred_deposit_balance, @@ -234,10 +234,10 @@ impl MigrationStep for Migration { // Store last key for next migration step self.last_account = Some(account); - (IsFinished::No, T::WeightInfo::v15_migration_step()) + (IsFinished::No, ::WeightInfo::v15_migration_step()) } else { log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); - (IsFinished::Yes, T::WeightInfo::v15_migration_step()) + (IsFinished::Yes, ::WeightInfo::v15_migration_step()) } } @@ -253,8 +253,8 @@ impl MigrationStep for Migration { ( account.clone(), contract.clone(), - T::Currency::total_balance(&account), - T::Currency::total_balance(&contract.deposit_account), + ::Currency::total_balance(&account), + ::Currency::total_balance(&contract.deposit_account), ) }) .collect(); @@ -276,8 +276,8 @@ impl MigrationStep for Migration { log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); let on_hold = - T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &account); - let account_balance = T::Currency::total_balance(&account); + ::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &account); + let account_balance = ::Currency::total_balance(&account); log::debug!( target: LOG_TARGET, diff --git a/substrate/frame/contracts/src/schedule.rs b/substrate/frame/contracts/src/schedule.rs index 5ca18af026a4..71b50f5c913e 100644 --- a/substrate/frame/contracts/src/schedule.rs +++ b/substrate/frame/contracts/src/schedule.rs @@ -348,13 +348,13 @@ macro_rules! replace_token { macro_rules! call_zero { ($name:ident, $( $arg:expr ),*) => { - T::WeightInfo::$name($( replace_token!($arg 0) ),*) + ::WeightInfo::$name($( replace_token!($arg 0) ),*) }; } macro_rules! cost_args { ($name:ident, $( $arg: expr ),+) => { - (T::WeightInfo::$name($( $arg ),+).saturating_sub(call_zero!($name, $( $arg ),+))) + (::WeightInfo::$name($( $arg ),+).saturating_sub(call_zero!($name, $( $arg ),+))) } } diff --git a/substrate/frame/contracts/src/storage.rs b/substrate/frame/contracts/src/storage.rs index d4d261f4ec1f..f678d3468056 100644 --- a/substrate/frame/contracts/src/storage.rs +++ b/substrate/frame/contracts/src/storage.rs @@ -275,9 +275,9 @@ impl ContractInfo { /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied weight limit. pub fn deletion_budget(weight_limit: Weight) -> (Weight, u32) { - let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); - let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - - T::WeightInfo::on_initialize_per_trie_key(0); + let base_weight = ::WeightInfo::on_process_deletion_queue_batch(); + let weight_per_key = ::WeightInfo::on_initialize_per_trie_key(1) - + ::WeightInfo::on_initialize_per_trie_key(0); // `weight_per_key` being zero makes no sense and would constitute a failure to // benchmark properly. We opt for not removing any keys at all in this case. diff --git a/substrate/frame/contracts/src/storage/meter.rs b/substrate/frame/contracts/src/storage/meter.rs index 9f098090bc8b..11f12593aed0 100644 --- a/substrate/frame/contracts/src/storage/meter.rs +++ b/substrate/frame/contracts/src/storage/meter.rs @@ -452,7 +452,7 @@ where self.total_deposit = Deposit::Charge(ed); // We need to make sure that the contract's account exists. - T::Currency::transfer(origin, contract, ed, Preservation::Preserve)?; + ::Currency::transfer(origin, contract, ed, Preservation::Preserve)?; // A consumer is added at account creation and removed it on termination, otherwise the // runtime could remove the account. As long as a contract exists its account must exist. @@ -526,14 +526,14 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Currency::reducible_balance(origin, Preservation::Preserve, Polite) + let max = ::Currency::reducible_balance(origin, Preservation::Preserve, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let default = max.min(T::DefaultDepositLimit::get()); let limit = limit.unwrap_or(default); ensure!( limit <= max && - matches!(T::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success), + matches!(::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success), >::StorageDepositNotEnoughFunds, ); Ok(limit) @@ -550,7 +550,7 @@ impl Ext for ReservingExt { Deposit::Charge(amount) => { // This could fail if the `origin` does not have enough liquidity. Ideally, though, // this should have been checked before with `check_limit`. - T::Currency::transfer_and_hold( + ::Currency::transfer_and_hold( &HoldReason::StorageDepositReserve.into(), origin, contract, @@ -570,7 +570,7 @@ impl Ext for ReservingExt { ); }, Deposit::Refund(amount) => { - let transferred = T::Currency::transfer_on_hold( + let transferred = ::Currency::transfer_on_hold( &HoldReason::StorageDepositReserve.into(), contract, origin, @@ -604,10 +604,10 @@ impl Ext for ReservingExt { if let ContractState::::Terminated { beneficiary } = state { System::::dec_consumers(&contract); // Whatever is left in the contract is sent to the termination beneficiary. - T::Currency::transfer( + ::Currency::transfer( &contract, &beneficiary, - T::Currency::reducible_balance(&contract, Preservation::Expendable, Polite), + ::Currency::reducible_balance(&contract, Preservation::Expendable, Polite), Preservation::Expendable, )?; } diff --git a/substrate/frame/contracts/src/wasm/mod.rs b/substrate/frame/contracts/src/wasm/mod.rs index 5fc65e314ad9..d999f497535a 100644 --- a/substrate/frame/contracts/src/wasm/mod.rs +++ b/substrate/frame/contracts/src/wasm/mod.rs @@ -139,8 +139,8 @@ impl Token for CodeLoadToken { // contract code. This is why we subtract `T::*::(0)`. We need to do this at this // point because when charging the general weight for calling the contract we don't know the // size of the contract. - T::WeightInfo::call_with_code_per_byte(self.0) - .saturating_sub(T::WeightInfo::call_with_code_per_byte(0)) + ::WeightInfo::call_with_code_per_byte(self.0) + .saturating_sub(::WeightInfo::call_with_code_per_byte(0)) } } @@ -237,7 +237,7 @@ impl WasmBlob { // the `owner` is always the origin of the current transaction. None => { let deposit = self.code_info.deposit; - T::Currency::hold( + ::Currency::hold( &HoldReason::CodeUploadDepositReserve.into(), &self.code_info.owner, deposit, @@ -267,7 +267,7 @@ impl WasmBlob { if let Some(code_info) = existing { ensure!(code_info.refcount == 0, >::CodeInUse); ensure!(&code_info.owner == origin, BadOrigin); - let _ = T::Currency::release( + let _ = ::Currency::release( &HoldReason::CodeUploadDepositReserve.into(), &code_info.owner, code_info.deposit,