Skip to content

Commit fd8b1d7

Browse files
muracabkontur
andauthored
Removed pallet:getter from XCM pallets (paritytech#7916)
# Description Part of paritytech#3326 As per title, the `pallet:getter` usage has been removed from: - `pallet-xcm` - `xcm-simulator-fuzzer` Getters have been implemented manually for all storage items where an auto-generated one has been removed. polkadot address: 12poSUQPtcF1HUPQGY3zZu2P8emuW9YnsPduA4XG3oCEfJVp --------- Co-authored-by: Branislav Kontur <[email protected]>
1 parent 1a514f6 commit fd8b1d7

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

polkadot/xcm/pallet-xcm/src/lib.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use frame_support::{
4646
use frame_system::pallet_prelude::{BlockNumberFor, *};
4747
pub use pallet::*;
4848
use scale_info::TypeInfo;
49+
use sp_core::H256;
4950
use sp_runtime::{
5051
traits::{
5152
AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Dispatchable, Hash,
@@ -192,7 +193,6 @@ pub mod pallet {
192193
parameter_types,
193194
};
194195
use frame_system::Config as SysConfig;
195-
use sp_core::H256;
196196
use sp_runtime::traits::Dispatchable;
197197
use xcm_executor::traits::{MatchesFungible, WeightBounds};
198198

@@ -698,7 +698,6 @@ pub mod pallet {
698698

699699
/// The ongoing queries.
700700
#[pallet::storage]
701-
#[pallet::getter(fn query)]
702701
pub(super) type Queries<T: Config> =
703702
StorageMap<_, Blake2_128Concat, QueryId, QueryStatus<BlockNumberFor<T>>, OptionQuery>;
704703

@@ -707,7 +706,6 @@ pub mod pallet {
707706
/// Key is the blake2 256 hash of (origin, versioned `Assets`) pair. Value is the number of
708707
/// times this pair has been trapped (usually just 1 if it exists at all).
709708
#[pallet::storage]
710-
#[pallet::getter(fn asset_trap)]
711709
pub(super) type AssetTraps<T: Config> = StorageMap<_, Identity, H256, u32, ValueQuery>;
712710

713711
/// Default version to encode XCM when latest version of destination is unknown. If `None`,
@@ -1565,6 +1563,20 @@ impl<T: Config> QueryHandler for Pallet<T> {
15651563
}
15661564

15671565
impl<T: Config> Pallet<T> {
1566+
/// The ongoing queries.
1567+
pub fn query(query_id: &QueryId) -> Option<QueryStatus<BlockNumberFor<T>>> {
1568+
Queries::<T>::get(query_id)
1569+
}
1570+
1571+
/// The existing asset traps.
1572+
///
1573+
/// Key is the blake2 256 hash of (origin, versioned `Assets`) pair.
1574+
/// Value is the number of times this pair has been trapped
1575+
/// (usually just 1 if it exists at all).
1576+
pub fn asset_trap(trap_id: &H256) -> u32 {
1577+
AssetTraps::<T>::get(trap_id)
1578+
}
1579+
15681580
/// Find `TransferType`s for `assets` and fee identified through `fee_asset_item`, when
15691581
/// transferring to `dest`.
15701582
///

polkadot/xcm/xcm-executor/integration-tests/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn query_response_fires() {
239239
}) if q == query_id,
240240
)));
241241
assert_eq!(
242-
polkadot_test_runtime::Xcm::query(query_id),
242+
polkadot_test_runtime::Xcm::query(&query_id),
243243
Some(QueryStatus::Ready {
244244
response: VersionedResponse::from(Response::ExecutionResult(None)),
245245
at: 2u32.into()

polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,9 @@ pub mod mock_msg_queue {
169169
impl<T: Config> Pallet<T> {}
170170

171171
#[pallet::storage]
172-
#[pallet::getter(fn parachain_id)]
173172
pub(super) type ParachainId<T: Config> = StorageValue<_, ParaId, ValueQuery>;
174173

175174
#[pallet::storage]
176-
#[pallet::getter(fn received_dmp)]
177175
/// A queue of received DMP messages
178176
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
179177

@@ -208,6 +206,14 @@ pub mod mock_msg_queue {
208206
}
209207

210208
impl<T: Config> Pallet<T> {
209+
pub fn parachain_id() -> ParaId {
210+
ParachainId::<T>::get()
211+
}
212+
213+
pub fn received_dmp() -> Vec<Xcm<T::RuntimeCall>> {
214+
ReceivedDmp::<T>::get()
215+
}
216+
211217
pub fn set_para_id(para_id: ParaId) {
212218
ParachainId::<T>::put(para_id);
213219
}

prdoc/pr_7916.prdoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: Removed pallet::getter from XCM pallets
2+
doc:
3+
- audience: Runtime Dev
4+
description: |
5+
This pr removes all pallet::getter occurrences from XCM pallets, replacing them with explicit implementations.
6+
7+
crates:
8+
- name: pallet-xcm
9+
bump: patch
10+
- name: xcm-simulator-fuzzer
11+
bump: patch

0 commit comments

Comments
 (0)