genesis-builder: implemented for all runtimes (#1492)

This PR implements [`GenesisBuilder`
API](https://github.com/paritytech/polkadot-sdk/blob/a414ea7515c9cdc81f1d12410e646afc148250e8/substrate/primitives/genesis-builder/src/lib.rs#L38)
for all the runtimes in polkadot repo.

Step towards: paritytech/polkadot-sdk#25

---------

Co-authored-by: ordian <write@reusable.software>
This commit is contained in:
Michal Kucharczyk
2023-09-27 11:59:19 +02:00
committed by GitHub
parent ab3a3bc278
commit 5a2833cceb
46 changed files with 307 additions and 27 deletions
-3
View File
@@ -107,6 +107,3 @@ std = [
]
# Special feature to disable logging
disable-logging = [ "sp-api/disable-logging" ]
#Enabling this flag will disable GenesisBuilder API implementation in runtime.
disable-genesis-builder = []
-15
View File
@@ -15,8 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
const BUILD_NO_GENESIS_BUILDER_SUPPORT_ENV: &str = "BUILD_NO_GENESIS_BUILDER_SUPPORT";
fn main() {
#[cfg(feature = "std")]
{
@@ -31,19 +29,6 @@ fn main() {
.build();
}
#[cfg(feature = "std")]
if std::env::var(BUILD_NO_GENESIS_BUILDER_SUPPORT_ENV).is_ok() {
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.append_to_rust_flags("-Clink-arg=-zstack-size=1048576")
.set_file_name("wasm_binary_no_genesis_builder")
.import_memory()
.enable_feature("disable-genesis-builder")
.build();
}
println!("cargo:rerun-if-env-changed={}", BUILD_NO_GENESIS_BUILDER_SUPPORT_ENV);
#[cfg(feature = "std")]
{
substrate_wasm_builder::WasmBuilder::new()
+1 -4
View File
@@ -26,11 +26,10 @@ pub mod genesismap;
pub mod substrate_test_pallet;
use codec::{Decode, Encode};
#[cfg(not(feature = "disable-genesis-builder"))]
use frame_support::genesis_builder_helper::{build_config, create_default_config};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{ConstU32, ConstU64},
weights::{
@@ -722,7 +721,6 @@ impl_runtime_apis! {
}
}
#[cfg(not(feature = "disable-genesis-builder"))]
impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn create_default_config() -> Vec<u8> {
create_default_config::<RuntimeGenesisConfig>()
@@ -1203,7 +1201,6 @@ mod tests {
})
}
#[cfg(not(feature = "disable-genesis-builder"))]
mod genesis_builder_tests {
use super::*;
use crate::genesismap::GenesisStorageBuilder;