From 307833d3aa2a0e6a985a9a37f122d3263c0bd35b Mon Sep 17 00:00:00 2001 From: nasihudeen04 Date: Wed, 1 Jul 2026 16:59:29 +0100 Subject: [PATCH 1/6] Remove deprecated GenesisBuild trait. Use BuildGenesisConfig for pallet genesis builds; drop legacy trait, re-export, and macro support. --- .../src/pallet/parse/genesis_build.rs | 2 +- .../procedural/src/pallet/parse/helper.rs | 39 ++++--------------- substrate/frame/support/src/lib.rs | 28 ------------- substrate/frame/support/src/traits.rs | 2 - substrate/frame/support/src/traits/hooks.rs | 30 +------------- .../pallet_ui/genesis_invalid_generic.stderr | 2 +- substrate/test-utils/runtime/src/lib.rs | 2 +- 7 files changed, 12 insertions(+), 93 deletions(-) diff --git a/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs b/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs index c382789ca41b1..f724a6b95b4a9 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs @@ -41,7 +41,7 @@ impl GenesisBuildDef { .trait_ .as_ref() .ok_or_else(|| { - let msg = "Invalid pallet::genesis_build, expected impl<..> GenesisBuild<..> \ + let msg = "Invalid pallet::genesis_build, expected impl<..> BuildGenesisConfig \ for GenesisConfig<..>"; syn::Error::new(item.span(), msg) })? diff --git a/substrate/frame/support/procedural/src/pallet/parse/helper.rs b/substrate/frame/support/procedural/src/pallet/parse/helper.rs index 4001a811a840e..ffd4d866ec769 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/helper.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/helper.rs @@ -23,7 +23,6 @@ use syn::spanned::Spanned; mod keyword { syn::custom_keyword!(I); syn::custom_keyword!(compact); - syn::custom_keyword!(GenesisBuild); syn::custom_keyword!(BuildGenesisConfig); syn::custom_keyword!(Config); syn::custom_keyword!(T); @@ -493,48 +492,26 @@ pub fn check_type_def_gen( Ok(i) } -/// Check the syntax: -/// * either `GenesisBuild` -/// * or `GenesisBuild` -/// * or `BuildGenesisConfig` -/// -/// return the instance if found for `GenesisBuild` -/// return None for BuildGenesisConfig +/// Check the syntax is `BuildGenesisConfig`. pub fn check_genesis_builder_usage(type_: &syn::Path) -> syn::Result> { - let expected = "expected `BuildGenesisConfig` (or the deprecated `GenesisBuild` or `GenesisBuild`)"; - pub struct Checker(Option); + let expected = "expected `BuildGenesisConfig`"; + pub struct Checker; impl syn::parse::Parse for Checker { fn parse(input: syn::parse::ParseStream) -> syn::Result { - let mut instance_usage = InstanceUsage { span: input.span(), has_instance: false }; - - if input.peek(keyword::GenesisBuild) { - input.parse::()?; - input.parse::()?; - input.parse::()?; - if input.peek(syn::Token![,]) { - instance_usage.has_instance = true; - input.parse::()?; - input.parse::()?; - } - input.parse::]>()?; - return Ok(Self(Some(instance_usage))); - } else { - input.parse::()?; - return Ok(Self(None)); - } + input.parse::()?; + Ok(Self) } } - let i = syn::parse2::(type_.to_token_stream()) + syn::parse2::(type_.to_token_stream()) .map_err(|e| { let msg = format!("Invalid genesis builder: {}", expected); let mut err = syn::Error::new(type_.span(), msg); err.combine(e); err - })? - .0; + })?; - Ok(i) + Ok(None) } /// Check the syntax: diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index 554ebc9fc87a4..c57eba4754b76 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -1928,34 +1928,6 @@ pub mod pallet_macros { /// } /// } /// ``` - /// - /// ## Former Usage - /// - /// Prior to , the following syntax was used. - /// This is deprecated and will soon be removed. - /// - /// ``` - /// #[frame_support::pallet] - /// pub mod pallet { - /// # #[pallet::config] - /// # pub trait Config: frame_system::Config {} - /// # #[pallet::pallet] - /// # pub struct Pallet(_); - /// # use frame_support::traits::GenesisBuild; - /// #[pallet::genesis_config] - /// #[derive(frame_support::DefaultNoBound)] - /// pub struct GenesisConfig { - /// foo: Vec - /// } - /// - /// #[pallet::genesis_build] - /// impl GenesisBuild for GenesisConfig { - /// fn build(&self) { - /// todo!() - /// } - /// } - /// } - /// ``` pub use frame_support_procedural::genesis_build; /// Allows adding an associated type trait bounded by diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index cb34382c69f07..9dd6b920f5137 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -83,8 +83,6 @@ pub use metadata::{ }; mod hooks; -#[allow(deprecated)] -pub use hooks::GenesisBuild; pub use hooks::{ BeforeAllRuntimeMigrations, BuildGenesisConfig, Hooks, IntegrityTest, OnFinalize, OnGenesis, OnIdle, OnInitialize, OnPoll, OnRuntimeUpgrade, OnTimestampSet, PostInherents, diff --git a/substrate/frame/support/src/traits/hooks.rs b/substrate/frame/support/src/traits/hooks.rs index 07ad76244c715..c732301abe6a3 100644 --- a/substrate/frame/support/src/traits/hooks.rs +++ b/substrate/frame/support/src/traits/hooks.rs @@ -572,7 +572,7 @@ pub trait Hooks { /// A trait to define the build function of a genesis config for both runtime and pallets. /// -/// Replaces deprecated [`GenesisBuild`]. +/// A trait to define the build function of a genesis config. pub trait BuildGenesisConfig: sp_runtime::traits::MaybeSerializeDeserialize { /// The build function puts initial `GenesisConfig` keys/values pairs into the storage. fn build(&self); @@ -582,34 +582,6 @@ impl BuildGenesisConfig for () { fn build(&self) {} } -/// A trait to define the build function of a genesis config, T and I are placeholder for pallet -/// trait and pallet instance. -#[deprecated( - note = "GenesisBuild is planned to be removed in December 2023. Use BuildGenesisConfig instead of it." -)] -pub trait GenesisBuild: sp_runtime::traits::MaybeSerializeDeserialize { - /// The build function is called within an externalities allowing storage APIs. - /// Thus one can write to storage using regular pallet storages. - fn build(&self); - - /// Build the storage using `build` inside default storage. - #[cfg(feature = "std")] - fn build_storage(&self) -> Result { - let mut storage = Default::default(); - self.assimilate_storage(&mut storage)?; - Ok(storage) - } - - /// Assimilate the storage for this module into pre-existing overlays. - #[cfg(feature = "std")] - fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { - sp_state_machine::BasicExternalities::execute_with_storage(storage, || { - self.build(); - Ok(()) - }) - } -} - impl_for_tuples_attr! { /// A trait which is called when the timestamp is set in the runtime. pub trait OnTimestampSet { diff --git a/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr b/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr index b54a23c91b4ee..835089240a942 100644 --- a/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr @@ -1,4 +1,4 @@ -error: Invalid genesis builder: expected `BuildGenesisConfig` (or the deprecated `GenesisBuild` or `GenesisBuild`) +error: Invalid genesis builder: expected `BuildGenesisConfig` --> tests/pallet_ui/genesis_invalid_generic.rs:36:7 | 36 | impl GenesisBuild for GenesisConfig {} diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index a432322aed8f1..2eff733eb8728 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -1494,7 +1494,7 @@ mod tests { let mut keys = t.into_storages().top.keys().cloned().map(hex).collect::>(); - // following keys are not placed during `::build` + // following keys are not placed during `::build` // process, add them `keys` to assert against known keys. keys.push(hex(b":code")); keys.sort(); From de89db8d680baa42b709861eb41983dd83d070b6 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 16:08:21 +0000 Subject: [PATCH 2/6] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump major' --- prdoc/pr_12529.prdoc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 prdoc/pr_12529.prdoc diff --git a/prdoc/pr_12529.prdoc b/prdoc/pr_12529.prdoc new file mode 100644 index 0000000000000..cec0652738034 --- /dev/null +++ b/prdoc/pr_12529.prdoc @@ -0,0 +1,31 @@ +title: Remove deprecated GenesisBuild trait. +doc: +- audience: Runtime Dev + description: |- + ## Summary + + - Removed the deprecated `GenesisBuild` trait from `frame_support::traits` + - Dropped the re-export and macro support for `GenesisBuild` / `GenesisBuild` + - Pallet `#[pallet::genesis_build]` now only accepts `BuildGenesisConfig` + - Updated docs and UI test expectations accordingly + + Part of #11561 + + ## Migration + + If you still use the old genesis build syntax: + + ```rust + // Before + impl GenesisBuild for GenesisConfig { ... } + + // After + impl BuildGenesisConfig for GenesisConfig { ... } + ``` + + `BuildStorage` / `assimilate_storage` for genesis configs is still generated by the pallet macro only the trait name changes. +crates: +- name: frame-support-procedural + bump: major +- name: frame-support + bump: major From f0144dd7157a431b7fedda0dd64569e49fae0e1d Mon Sep 17 00:00:00 2001 From: nasihudeen04 Date: Wed, 1 Jul 2026 17:17:05 +0100 Subject: [PATCH 3/6] fmt: fix CI-reported formatting in GenesisBuild removal --- .../support/procedural/src/pallet/parse/helper.rs | 13 ++++++------- substrate/test-utils/runtime/src/lib.rs | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/substrate/frame/support/procedural/src/pallet/parse/helper.rs b/substrate/frame/support/procedural/src/pallet/parse/helper.rs index ffd4d866ec769..07d45b3830f45 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/helper.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/helper.rs @@ -503,13 +503,12 @@ pub fn check_genesis_builder_usage(type_: &syn::Path) -> syn::Result(type_.to_token_stream()) - .map_err(|e| { - let msg = format!("Invalid genesis builder: {}", expected); - let mut err = syn::Error::new(type_.span(), msg); - err.combine(e); - err - })?; + syn::parse2::(type_.to_token_stream()).map_err(|e| { + let msg = format!("Invalid genesis builder: {}", expected); + let mut err = syn::Error::new(type_.span(), msg); + err.combine(e); + err + })?; Ok(None) } diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index 2eff733eb8728..6ff20ef57eee7 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -1494,8 +1494,8 @@ mod tests { let mut keys = t.into_storages().top.keys().cloned().map(hex).collect::>(); - // following keys are not placed during `::build` - // process, add them `keys` to assert against known keys. + // following keys are not placed during `::build` process, add them `keys` to assert against known keys. keys.push(hex(b":code")); keys.sort(); From be201f74de481d464d937858bccfceef102c7369 Mon Sep 17 00:00:00 2001 From: Nasihudeen Jimoh Date: Wed, 1 Jul 2026 17:18:01 +0100 Subject: [PATCH 4/6] clean prdoc --- prdoc/pr_12529.prdoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/prdoc/pr_12529.prdoc b/prdoc/pr_12529.prdoc index cec0652738034..ce47ac4cc0988 100644 --- a/prdoc/pr_12529.prdoc +++ b/prdoc/pr_12529.prdoc @@ -9,8 +9,6 @@ doc: - Pallet `#[pallet::genesis_build]` now only accepts `BuildGenesisConfig` - Updated docs and UI test expectations accordingly - Part of #11561 - ## Migration If you still use the old genesis build syntax: From a628c19b73fe6a5bf9de7308055386f69e5f4350 Mon Sep 17 00:00:00 2001 From: nasihudeen04 Date: Thu, 2 Jul 2026 16:16:25 +0100 Subject: [PATCH 5/6] Update pallet_ui stderr for BuildGenesisConfig error message. --- .../support/test/tests/pallet_ui/genesis_wrong_name.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/support/test/tests/pallet_ui/genesis_wrong_name.stderr b/substrate/frame/support/test/tests/pallet_ui/genesis_wrong_name.stderr index 4d1c09ec5edf5..ccf27be0963af 100644 --- a/substrate/frame/support/test/tests/pallet_ui/genesis_wrong_name.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/genesis_wrong_name.stderr @@ -1,4 +1,4 @@ -error: Invalid pallet::genesis_build, expected impl<..> GenesisBuild<..> for GenesisConfig<..> +error: Invalid pallet::genesis_build, expected impl<..> BuildGenesisConfig for GenesisConfig<..> --> tests/pallet_ui/genesis_wrong_name.rs:36:2 | 36 | impl Foo {} From febb5b28c7b3f51dc85c6f839ca04079ca508eb5 Mon Sep 17 00:00:00 2001 From: nasihudeen04 Date: Thu, 2 Jul 2026 21:57:34 +0100 Subject: [PATCH 6/6] Update pallet_ui stderr for BuildGenesisConfig trait errors. Match CI compiler output for genesis_invalid_generic and genesis_inconsistent_build_config UI tests. --- .../genesis_inconsistent_build_config.stderr | 14 ++++++++++---- .../tests/pallet_ui/genesis_invalid_generic.stderr | 10 ++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/substrate/frame/support/test/tests/pallet_ui/genesis_inconsistent_build_config.stderr b/substrate/frame/support/test/tests/pallet_ui/genesis_inconsistent_build_config.stderr index d515547ec3a06..91fff55ce0716 100644 --- a/substrate/frame/support/test/tests/pallet_ui/genesis_inconsistent_build_config.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/genesis_inconsistent_build_config.stderr @@ -1,5 +1,11 @@ -error: `#[pallet::genesis_config]` and `#[pallet::genesis_build]` attributes must be either both used or both not used, instead genesis_config is unused and genesis_build is used - --> tests/pallet_ui/genesis_inconsistent_build_config.rs:19:1 +error: Invalid genesis builder: expected `BuildGenesisConfig` + --> tests/pallet_ui/genesis_inconsistent_build_config.rs:36:18 | -19 | mod pallet { - | ^^^ +36 | impl GenesisBuild for GenesisConfig {} + | ^^^^^^^^^^^^ + +error: expected `BuildGenesisConfig` + --> tests/pallet_ui/genesis_inconsistent_build_config.rs:36:18 + | +36 | impl GenesisBuild for GenesisConfig {} + | ^^^^^^^^^^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr b/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr index 835089240a942..22343e8c470f2 100644 --- a/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/genesis_invalid_generic.stderr @@ -4,10 +4,8 @@ error: Invalid genesis builder: expected `BuildGenesisConfig` 36 | impl GenesisBuild for GenesisConfig {} | ^^^^^^^^^^^^ -error: expected `<` - --> tests/pallet_ui/genesis_invalid_generic.rs:18:1 - | -18 | #[frame_support::pallet] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +error: expected `BuildGenesisConfig` + --> tests/pallet_ui/genesis_invalid_generic.rs:36:7 | - = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info) +36 | impl GenesisBuild for GenesisConfig {} + | ^^^^^^^^^^^^