Skip to content

Commit

Permalink
Fix duplicate codec indexes (#7446)
Browse files Browse the repository at this point in the history
Related to #7400 and
#7417

We need this in order to be able to update `parity-scale-codec` to the
latest version after it's released. That's because `parity-scale-codec`
added support for checking for duplicate indexes at compile time.
  • Loading branch information
serban300 authored Feb 4, 2025
1 parent d6aa157 commit 37446fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion substrate/frame/parameters/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub mod dynamic_params {
}

#[dynamic_pallet_params]
#[codec(index = 3)]
#[codec(index = 4)]
pub mod somE_weird_SPElLInG_s {
#[codec(index = 0)]
pub static V: u64 = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ pub fn expand_outer_origin(
system(#system_path::Origin<#runtime>),
#caller_variants
#[allow(dead_code)]
#[codec(skip)]
Void(#scrate::__private::Void)
}

Expand Down
22 changes: 8 additions & 14 deletions substrate/frame/support/test/tests/enum_deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub mod pallet {
T::AccountId: SomeAssociation1 + From<SomeType1>,
{
#[deprecated = "second"]
#[codec(index = 1)]
A,
#[deprecated = "first"]
#[codec(index = 0)]
Expand Down Expand Up @@ -157,20 +158,13 @@ fn pallet_metadata() {
// Example pallet events are partially and fully deprecated
let meta = example.event.unwrap();
assert_eq!(
// Result should be this, but instead we get the result below
// see: https://github.com/paritytech/parity-scale-codec/issues/507
//
// DeprecationInfoIR::VariantsDeprecated(BTreeMap::from([
// (codec::Compact(0), DeprecationStatusIR::Deprecated { note: "first", since: None
// }), (
// codec::Compact(1),
// DeprecationStatusIR::Deprecated { note: "second", since: None }
// )
// ])),
DeprecationInfoIR::VariantsDeprecated(BTreeMap::from([(
codec::Compact(0),
DeprecationStatusIR::Deprecated { note: "first", since: None }
),])),
DeprecationInfoIR::VariantsDeprecated(BTreeMap::from([
(codec::Compact(0), DeprecationStatusIR::Deprecated { note: "first", since: None }),
(
codec::Compact(1),
DeprecationStatusIR::Deprecated { note: "second", since: None }
)
])),
meta.deprecation_info
);
}
Expand Down

0 comments on commit 37446fc

Please sign in to comment.