Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Revert "[Enhancement] Throw an error when there are too many pallets (#…
Browse files Browse the repository at this point in the history
…13763)"

This reverts commit 9b8e6e7.
  • Loading branch information
gilescope committed Apr 24, 2023
1 parent fff96ac commit 1282681
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 267 deletions.
40 changes: 3 additions & 37 deletions frame/support/procedural/src/construct_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use std::{collections::HashSet, str::FromStr};
use syn::{spanned::Spanned, Ident, Result};
use syn::{Ident, Result};

/// The fixed name of the system pallet.
const SYSTEM_PALLET_NAME: &str = "System";
Expand All @@ -170,12 +170,9 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream {

let res = match definition {
RuntimeDeclaration::Implicit(implicit_def) =>
check_pallet_number(input_copy.clone().into(), implicit_def.pallets.len()).and_then(
|_| construct_runtime_intermediary_expansion(input_copy.into(), implicit_def),
),
construct_runtime_intermediary_expansion(input_copy.into(), implicit_def),
RuntimeDeclaration::Explicit(explicit_decl) =>
check_pallet_number(input_copy.into(), explicit_decl.pallets.len())
.and_then(|_| construct_runtime_final_expansion(explicit_decl)),
construct_runtime_final_expansion(explicit_decl),
};

res.unwrap_or_else(|e| e.to_compile_error()).into()
Expand Down Expand Up @@ -656,34 +653,3 @@ fn decl_static_assertions(
#(#error_encoded_size_check)*
}
}

fn check_pallet_number(input: TokenStream2, pallet_num: usize) -> Result<()> {
let max_pallet_num = {
if cfg!(feature = "tuples-96") {
96
} else if cfg!(feature = "tuples-128") {
128
} else {
64
}
};

if pallet_num > max_pallet_num {
let no_feature = max_pallet_num == 128;
return Err(syn::Error::new(
input.span(),
format!(
"{} To increase this limit, enable the tuples-{} feature of [frame_support]. {}",
"The number of pallets exceeds the maximum number of tuple elements.",
max_pallet_num + 32,
if no_feature {
"If the feature does not exist - it needs to be implemented."
} else {
""
},
),
))
}

Ok(())
}

This file was deleted.

This file was deleted.

0 comments on commit 1282681

Please sign in to comment.