From ace68f6ed494c5f9a780534c84aef6380e7e2bb0 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Mon, 3 Feb 2025 17:20:29 +0200 Subject: [PATCH] Fix duplicate codec indexes --- substrate/frame/parameters/src/tests/mock.rs | 2 +- .../src/construct_runtime/expand/origin.rs | 1 + .../support/test/tests/enum_deprecation.rs | 22 +++++++------------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/substrate/frame/parameters/src/tests/mock.rs b/substrate/frame/parameters/src/tests/mock.rs index 53a3b3e394c4..8d6f7d25ceac 100644 --- a/substrate/frame/parameters/src/tests/mock.rs +++ b/substrate/frame/parameters/src/tests/mock.rs @@ -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; diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs index 4742e68e2e2a..aada9f7af75b 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs @@ -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) } diff --git a/substrate/frame/support/test/tests/enum_deprecation.rs b/substrate/frame/support/test/tests/enum_deprecation.rs index c1167dfe339c..72b14dad9629 100644 --- a/substrate/frame/support/test/tests/enum_deprecation.rs +++ b/substrate/frame/support/test/tests/enum_deprecation.rs @@ -85,6 +85,7 @@ pub mod pallet { T::AccountId: SomeAssociation1 + From, { #[deprecated = "second"] + #[codec(index = 1)] A, #[deprecated = "first"] #[codec(index = 0)] @@ -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 ); }