Skip to content

Commit a4bf05e

Browse files
committed
Revert "xcm: Do not require Asset to be sorted on decode" (#10459)
Reverts #9842 Following on the discussion at #10391, we don't want to sort at decode level but rather to not require sorting at all among the codebase (cherry picked from commit 34034a9)
1 parent 66f9354 commit a4bf05e

File tree

4 files changed

+6
-24
lines changed

4 files changed

+6
-24
lines changed

polkadot/xcm/src/v3/multiasset.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,10 @@ impl MaxEncodedLen for MultiAssets {
587587

588588
impl Decode for MultiAssets {
589589
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
590-
let mut bounded_instructions =
590+
let bounded_instructions =
591591
BoundedVec::<MultiAsset, ConstU32<{ MAX_ITEMS_IN_MULTIASSETS as u32 }>>::decode(input)?;
592-
593-
bounded_instructions.sort();
594-
595592
Self::from_sorted_and_deduplicated(bounded_instructions.into_inner())
596-
.map_err(|()| "Duplicate items".into())
593+
.map_err(|()| "Out of order".into())
597594
}
598595
}
599596

@@ -685,7 +682,6 @@ impl MultiAssets {
685682
pub fn from_sorted_and_deduplicated_skip_checks(r: Vec<MultiAsset>) -> Self {
686683
Self::from_sorted_and_deduplicated(r).expect("Invalid input r is not sorted/deduped")
687684
}
688-
689685
/// Create a new instance of `MultiAssets` from a `Vec<MultiAsset>` whose contents are sorted
690686
/// and which contain no duplicates.
691687
///

polkadot/xcm/src/v4/asset.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,10 @@ impl MaxEncodedLen for Assets {
624624

625625
impl Decode for Assets {
626626
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
627-
let mut bounded_instructions =
627+
let bounded_instructions =
628628
BoundedVec::<Asset, ConstU32<{ MAX_ITEMS_IN_ASSETS as u32 }>>::decode(input)?;
629-
630-
bounded_instructions.sort();
631-
632629
Self::from_sorted_and_deduplicated(bounded_instructions.into_inner())
633-
.map_err(|()| "Duplicate items".into())
630+
.map_err(|()| "Out of order".into())
634631
}
635632
}
636633

polkadot/xcm/src/v5/asset.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,10 @@ impl MaxEncodedLen for Assets {
562562

563563
impl Decode for Assets {
564564
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
565-
let mut bounded_instructions =
565+
let bounded_instructions =
566566
BoundedVec::<Asset, ConstU32<{ MAX_ITEMS_IN_ASSETS as u32 }>>::decode(input)?;
567-
568-
bounded_instructions.sort();
569-
570567
Self::from_sorted_and_deduplicated(bounded_instructions.into_inner())
571-
.map_err(|()| "Duplicate items".into())
568+
.map_err(|()| "Out of order".into())
572569
}
573570
}
574571

prdoc/stable2512/pr_9842.prdoc

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)