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
+17
View File
@@ -34,6 +34,7 @@ pub use sc_network_common::{
use prometheus_endpoint::Registry;
use sc_chain_spec::ChainSpec;
use sc_network::config::SyncMode;
pub use sc_telemetry::TelemetryEndpoints;
pub use sc_transaction_pool::Options as TransactionPoolOptions;
use sp_core::crypto::SecretString;
@@ -238,6 +239,22 @@ impl Configuration {
};
ProtocolId::from(protocol_id_full)
}
/// Returns true if the genesis state writting will be skipped while initializing the genesis
/// block.
pub fn no_genesis(&self) -> bool {
matches!(self.network.sync_mode, SyncMode::Fast { .. } | SyncMode::Warp { .. })
}
/// Returns the database config for creating the backend.
pub fn db_config(&self) -> sc_client_db::DatabaseSettings {
sc_client_db::DatabaseSettings {
trie_cache_maximum_size: self.trie_cache_maximum_size,
state_pruning: self.state_pruning.clone(),
source: self.database.clone(),
blocks_pruning: self.blocks_pruning,
}
}
}
/// Available RPC methods.