Support custom genesis block (#12291)

* Set genesis block data using the built genesis block

* Make resolve_state_version_from_wasm a separate function and some small refactorings

Useful for the commit following.

* Introduce trait BuildGenesisBlock

Substrate users can use this trait to implement their custom genesis block when constructing the
client.

* Make call_executor test compile

* cargo +nightly fmt --all

* Fix test

* Remove unnecessary clone

* FMT

* Apply review suggestions

* Revert changes to new_full_client() and new_full_parts() signature

* Remove needless `Block` type in `resolve_state_version_from_wasm`
This commit is contained in:
Liu-Cheng Xu
2022-12-19 22:26:31 +08:00
committed by GitHub
parent 1be51ccb5c
commit b92aa3dbdc
10 changed files with 260 additions and 112 deletions
+20 -10
View File
@@ -397,24 +397,34 @@ impl BenchDb {
let task_executor = TaskExecutor::new();
let backend = sc_service::new_db_backend(db_config).expect("Should not fail");
let executor = NativeElseWasmExecutor::new(
WasmExecutionMethod::Compiled {
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
},
None,
8,
2,
);
let client_config = sc_service::ClientConfig::default();
let genesis_block_builder = sc_service::GenesisBlockBuilder::new(
&keyring.generate_genesis(),
!client_config.no_genesis,
backend.clone(),
executor.clone(),
)
.expect("Failed to create genesis block builder");
let client = sc_service::new_client(
backend.clone(),
NativeElseWasmExecutor::new(
WasmExecutionMethod::Compiled {
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
},
None,
8,
2,
),
&keyring.generate_genesis(),
executor,
genesis_block_builder,
None,
None,
ExecutionExtensions::new(profile.into_execution_strategies(), None, None),
Box::new(task_executor.clone()),
None,
None,
Default::default(),
client_config,
)
.expect("Should not fail");