-
Notifications
You must be signed in to change notification settings - Fork 134
Description
🎯 Core Issue
The beneficiary
field in treasury spends can contain XCM Location
structures with AccountId32
junctions that reference specific account IDs. These AccountIds need to be translated from RC format to AH format
#807 has introduced a mocked implemenation in system-parachains/asset-hubs/asset-hub-polkadot/src/ah_migration/mod.rs
of translate_location_account_ids()
which just returns the same location.
The proper final implementation needs to apply the correct account translation to AccountId32 junctions instead, see details later on.
It's also important to remember to enforce the requirement for idempotency as stated in #808.
See this thread.
Implementation details
Current flow
- RC Side: Sends
RcTreasuryMessage::Spends
with beneficiary asVersionedLocation
. Thetranslate_location_account_ids
introduced by [AHM / ah-migrator]: Implement RC->AH account translationmocked
migration across all involved pallets #807 is just a no-op for the time being - AH Side: Processes in
do_process_treasury_message()
usingT::RcToAhTreasurySpend::convert()
- Conversion:
RcToAhTreasurySpend::convert()
transforms:(VersionedLocatableAsset, VersionedLocation)
- →
(VersionedLocatableAsset, VersionedLocatableAccount)
Two Implementation Options
Option 1: Translate in Treasury.rs (Pallet Level)
Location: pallets/ah-migrator/src/treasury.rs
Approach: Add account translation in do_process_treasury_message()
before calling T::RcToAhTreasurySpend::convert()
.
RcTreasuryMessage::Spends { id: spend_index, status: spend } => {
// Extract beneficiary and apply account translation
let translated_beneficiary = Self::translate_beneficiary_location(spend.beneficiary);
// Create updated spend with translated beneficiary
let updated_spend = treasury_alias::SpendStatus {
asset_kind: spend.asset_kind,
amount: spend.amount,
beneficiary: translated_beneficiary,
valid_from: spend.valid_from,
expire_at: spend.expire_at,
status: spend.status,
};
// Apply high-level conversion
let (asset_kind, beneficiary) = T::RcToAhTreasurySpend::convert((
updated_spend.asset_kind,
updated_spend.beneficiary
))?;
// Store result...
}
Option 2: Translate in mod.rs (Runtime Level)
Location: system-parachains/asset-hubs/asset-hub-polkadot/src/ah_migration/mod.rs
Approach: Modify mocked translate_location_account_ids()
to apply the proper translation
Both options are fine.