Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate codec indexes #7446

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context: The void type can't be instantiated, it can't be decoded as well. So skipping the variant keeps the same behavior.

}

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
Loading