rustfmt service and fix typos

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-07-29 14:49:16 +03:00
parent 8f20b7ef5c
commit 48ff511685
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
4 changed files with 242 additions and 166 deletions

View File

@ -17,7 +17,7 @@ homepage.workspace = true
[workspace.package]
license = "GPL-3.0-only"
authors = ["571nky", "57r37ch", "f4750"]
version = "0.7.206"
version = "0.7.207"
edition = "2021"
homepage = "https://ghostchain.io"
repository = "https://git.ghostchain.io/ghostchain/ghost-node"

View File

@ -1,7 +1,7 @@
use keyring::Sr25519Keyring;
use primitives::AccountId;
use sc_client_api::UsageProvider;
use sp_runtime::OpaqueExtrinsic;
use keyring::Sr25519Keyring;
use crate::*;
@ -21,27 +21,41 @@ macro_rules! identify_chain {
{
use ghost_runtime as runtime;
let call = $generic_code;
Ok(ghost_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
Ok(ghost_sign_call(
call,
$nonce,
$current_block,
$period,
$genesis,
$signer,
))
}
#[cfg(not(feature = "ghost-native"))]
{
Err("`ghost-native` feature not enabled")
}
},
}
Chain::Casper => {
#[cfg(feature = "casper-native")]
{
use casper_runtime as runtime;
let call = $generic_code;
Ok(casper_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
Ok(casper_sign_call(
call,
$nonce,
$current_block,
$period,
$genesis,
$signer,
))
}
#[cfg(not(feature = "casper-native"))]
{
Err("`casper-native` feature not enabled")
}
},
}
Chain::Unknown => {
let _ = $nonce;
let _ = $current_block;
@ -50,7 +64,7 @@ macro_rules! identify_chain {
let _ = $signer;
Err("Unknown chain")
},
}
}
};
}
@ -105,7 +119,11 @@ pub struct TransferKeepAliveBuilder {
impl TransferKeepAliveBuilder {
pub fn new(client: Arc<FullClient>, dest: AccountId, chain: Chain) -> Self {
Self { client, dest, chain }
Self {
client,
dest,
chain,
}
}
}
@ -159,10 +177,9 @@ fn casper_sign_call(
frame_system::CheckSpecVersion::<casper_runtime::Runtime>::new(),
frame_system::CheckTxVersion::<casper_runtime::Runtime>::new(),
frame_system::CheckGenesis::<casper_runtime::Runtime>::new(),
frame_system::CheckMortality::<casper_runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
period,
current_block,
)),
frame_system::CheckMortality::<casper_runtime::Runtime>::from(
sp_runtime::generic::Era::mortal(period, current_block),
),
frame_system::CheckNonce::<casper_runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<casper_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<casper_runtime::Runtime>::from(0),
@ -189,7 +206,8 @@ fn casper_sign_call(
sp_runtime::AccountId32::from(acc.public()).into(),
primitives::Signature::Sr25519(signature),
extra,
).into()
)
.into()
}
pub fn benchmark_inherent_data() -> std::result::Result<inherents::InherentData, inherents::Error> {

View File

@ -2,13 +2,13 @@
use codec::Encode;
use ghost_slow_clap::sr25519::AuthorityId as SlowClapId;
use primitives::{AccountId, AccountPublic};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use grandpa_primitives::AuthorityId as GrandpaId;
use babe_primitives::AuthorityId as BabeId;
use ghost_slow_clap::sr25519::AuthorityId as SlowClapId;
use grandpa_primitives::AuthorityId as GrandpaId;
#[cfg(feature = "casper-native")]
use pallet_staking::Forcing;
use primitives::{AccountId, AccountPublic};
#[cfg(feature = "casper-native")]
use casper_runtime as casper;
@ -58,7 +58,7 @@ pub type CasperChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type CasperChainSpec = GenericChainSpec;
pub fn casper_config() -> Result<CasperChainSpec, String> {
CasperChainSpec::from_json_bytes(&include_bytes!("../chain-specs/casper.json")[..])
CasperChainSpec::from_json_bytes(&include_bytes!("../chain-specs/casper.json")[..])
}
#[cfg(feature = "casper-native")]
@ -76,7 +76,6 @@ fn casper_session_keys(
}
}
pub fn casper_chain_spec_properties() -> serde_json::map::Map<String, serde_json::Value> {
serde_json::json!({
"ss58Format": 1996,
@ -161,20 +160,37 @@ fn casper_testnet_accounts() -> Vec<AccountId> {
fn casper_testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> {
vec![
// 01c928771aea942a1e7ac06adf2b73dfbc9a25d9eaa516e3673116af7f345198
(get_account_id_from_seed::<sr25519::Public>("1A69d2D5568D1878023EeB121a73d33B9116A760"), 1337 * CSPR, 1),
(
get_account_id_from_seed::<sr25519::Public>("1A69d2D5568D1878023EeB121a73d33B9116A760"),
1337 * CSPR,
1,
),
// b19a435901872f817185f7234a1484eae837613f9d10cf21927a23c2d8cb9139
(get_account_id_from_seed::<sr25519::Public>("2f86cfBED3fbc1eCf2989B9aE5fc019a837A9C12"), 1337 * CSPR, 2),
(
get_account_id_from_seed::<sr25519::Public>("2f86cfBED3fbc1eCf2989B9aE5fc019a837A9C12"),
1337 * CSPR,
2,
),
// d3baf57b74d65719b2dc33f5a464176022d0cc5edbca002234229f3e733875fc
(get_account_id_from_seed::<sr25519::Public>("e83f67361Ac74D42A48E2DAfb6706eb047D8218D"), 69 * CSPR, 3),
(
get_account_id_from_seed::<sr25519::Public>("e83f67361Ac74D42A48E2DAfb6706eb047D8218D"),
69 * CSPR,
3,
),
// c4683d566436af6b58b4a59c8f501319226e85b21869bf93d5eeb4596d4791d4
(get_account_id_from_seed::<sr25519::Public>("827ee4ad9b259b6fa1390ed60921508c78befd63"), 69 * CSPR, 4),
(
get_account_id_from_seed::<sr25519::Public>("827ee4ad9b259b6fa1390ed60921508c78befd63"),
69 * CSPR,
4,
),
]
}
#[cfg(feature = "casper-native")]
fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
vec![
(11155111, ghost_networks::NetworkData {
vec![(
11155111,
ghost_networks::NetworkData {
chain_name: "sepolia-ethereum-testnet".into(),
default_endpoints: vec![
"https://sepolia.drpc.org".into(),
@ -195,8 +211,9 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
topic_name: "0x7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a6".into(),
incoming_fee: 69_000_000u32,
outgoing_fee: 0u32,
}.encode()),
]
}
.encode(),
)]
}
/// Helper function to create casper `GenesisConfig` for testing
@ -214,14 +231,11 @@ pub fn testnet_config_genesis(
ghost_accounts: Option<Vec<(AccountId, u128, u8)>>,
evm_networks: Option<Vec<(u32, Vec<u8>)>>,
) -> serde_json::Value {
let endowed_accounts: Vec<AccountId> = endowed_accounts
.unwrap_or_else(casper_testnet_accounts);
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(casper_testnet_accounts);
let ghost_accounts: Vec<(AccountId, u128, u8)> = ghost_accounts
.unwrap_or_default();
let ghost_accounts: Vec<(AccountId, u128, u8)> = ghost_accounts.unwrap_or_default();
let evm_networks: Vec<(u32, Vec<u8>)> = evm_networks
.unwrap_or_default();
let evm_networks: Vec<(u32, Vec<u8>)> = evm_networks.unwrap_or_default();
const ENDOWMENT: u128 = 1_000 * CSPR;
const STASH: u128 = 500 * CSPR;
@ -320,13 +334,17 @@ fn casper_staging_config_genesis() -> serde_json::Value {
// sfFXZmnDVnkQ781J2gbqUpi7K5KgMWMdM4eeii74xxGgKYnNN
hex!["507045c82be367f95408466cd054ca39bfa52697a3ef22809af14cf9de304f02"].into(),
// sfJeojACBa7WiH6tBwikBKAMU2oKmseEBD1GYUYATvfWuLcPa
hex!["daaaaab6a6e574099e24ae9bb75b543610edef9d374fa85a378edb573b47615f"].unchecked_into(),
hex!["daaaaab6a6e574099e24ae9bb75b543610edef9d374fa85a378edb573b47615f"]
.unchecked_into(),
// sfFdtzNxJdeEkgHxvk144rJKxf7wcYvgX5tqfgZRutW9YvAKE
hex!["55446f9a7aa99ced06b317c80ce90d56b84e56526775683af2525969e8da0b64"].unchecked_into(),
hex!["55446f9a7aa99ced06b317c80ce90d56b84e56526775683af2525969e8da0b64"]
.unchecked_into(),
// sfE8gsMYAjAJHk5gyYZN7AW6pfmJ7V9H7xxWto24nmhzCUXaQ
hex!["12c14850562021eb99f58f90ab624fb6cfaf3ac9228a92f8b60115fe6a6af15a"].unchecked_into(),
hex!["12c14850562021eb99f58f90ab624fb6cfaf3ac9228a92f8b60115fe6a6af15a"]
.unchecked_into(),
// sfE3GKSrKZzrZpdapJ2VGRpPor45T4D4i8QBZNumSNGqGv7PX
hex!["0e9e698c7b2bf5ce3861cb4bc4ddf9e200237c282025b093ada850d764d12a35"].unchecked_into(),
hex!["0e9e698c7b2bf5ce3861cb4bc4ddf9e200237c282025b093ada850d764d12a35"]
.unchecked_into(),
),
(
// sfHLqWNC4hMKHhwvPWmWcxZsDPhCTQKgh1Ap7pm3qML5GBTBa
@ -334,13 +352,17 @@ fn casper_staging_config_genesis() -> serde_json::Value {
// sfHLqWNC4hMKHhwvPWmWcxZsDPhCTQKgh1Ap7pm3qML5GBTBa
hex!["a0ba0196e6ee7e6b5b0553035c5cb5c04e9725001b5732839d0529cbc00c9600"].into(),
// sfGA6tPPF8dAc8QpMCMjxitG3j8sXPhkdpm5bwz4UsXAApUiw
hex!["6c4dd88b43e2011cf9a6a73d53446336ac9e04cdd4ca23587df63187ac455e49"].unchecked_into(),
hex!["6c4dd88b43e2011cf9a6a73d53446336ac9e04cdd4ca23587df63187ac455e49"]
.unchecked_into(),
// sfGxQZXFUQH1AXv82rpjiJHFs7YsdEuVGdyvKiS2Tajpvw6Se
hex!["8f9ea20bf4a807a8e710f7559dece86e94672b5b361de157bdaa5c1f37849f8d"].unchecked_into(),
hex!["8f9ea20bf4a807a8e710f7559dece86e94672b5b361de157bdaa5c1f37849f8d"]
.unchecked_into(),
// sfGz2enFUR22cQ5ey61MdtPqbCeEWZA1wsCFFSLGaK7vKnv8C
hex!["90db5ed339a559ed157995a48d781f44c7df972dfba4bc855e4b59fa46438e17"].unchecked_into(),
hex!["90db5ed339a559ed157995a48d781f44c7df972dfba4bc855e4b59fa46438e17"]
.unchecked_into(),
// sfEtwe5BoroNjkdLsvnjnMemUKiw8MS1X4YW8bepbbGvhS4LZ
hex!["3481cdcbcf37a4669c29a78cf9ceb39383a10ef0a18b36b92d149fdd0c24ae00"].unchecked_into(),
hex!["3481cdcbcf37a4669c29a78cf9ceb39383a10ef0a18b36b92d149fdd0c24ae00"]
.unchecked_into(),
),
(
// sfG9iWUS7AKBzvqdz3uDZv7f1t79vvSTYL1VxzYPHjhmLnQVn
@ -348,13 +370,17 @@ fn casper_staging_config_genesis() -> serde_json::Value {
// sfG9iWUS7AKBzvqdz3uDZv7f1t79vvSTYL1VxzYPHjhmLnQVn
hex!["6c0283f4c688f0e75ad546c790bbd5961c1a6931543aa589f368f8272c44b758"].into(),
// sfGMUYXSjHgwGBpbGiHFoqT1DdJwZdHk49H5ViaQM7HUnayvZ
hex!["74fa7381a7a74b316afb6793a00387eed9d95d46a69866cbb316b5d9c918af0e"].unchecked_into(),
hex!["74fa7381a7a74b316afb6793a00387eed9d95d46a69866cbb316b5d9c918af0e"]
.unchecked_into(),
// sfEWYhczV6PbmeNXZTcA4LvhpzvCfNMatYoSNKvDphmNaQzqB
hex!["236d2fa03f4ed8cb65de7e514d7540159b328f1c170dd402b094ad7fbf547218"].unchecked_into(),
hex!["236d2fa03f4ed8cb65de7e514d7540159b328f1c170dd402b094ad7fbf547218"]
.unchecked_into(),
// sfDirg32ityDvrjxh4822unhP4qm4S9yTqN99gesN322swn7h
hex!["00946618c353e4c6546b87f9ca1089b846b0ea4658ee8e6d9d1200c24cb5ee27"].unchecked_into(),
hex!["00946618c353e4c6546b87f9ca1089b846b0ea4658ee8e6d9d1200c24cb5ee27"]
.unchecked_into(),
// sfFZgp1Z5diFAZ16swuQD5GojGCsMMFVR19uWnCrppMLuYjRv
hex!["520e74f8c5853ec8577932327ad3247656db25b74c79ad09adb431b271002401"].unchecked_into(),
hex!["520e74f8c5853ec8577932327ad3247656db25b74c79ad09adb431b271002401"]
.unchecked_into(),
),
(
// sfHjtrXFzRmxwjE4rjVxFJXpvVv7furjdymZS7PQRFiANpodz
@ -362,13 +388,17 @@ fn casper_staging_config_genesis() -> serde_json::Value {
// sfHjtrXFzRmxwjE4rjVxFJXpvVv7furjdymZS7PQRFiANpodz
hex!["b24feb55b2cac4b365a9245c2a97525b01bd1a594d2d42b91f6bc38c9c2e6517"].into(),
// sfF5XWwvNPjZEsBz1HWs5Ys5zcE85UHnN1BV8TBBectqFQZRm
hex!["3c944c704cae203619b9e7a5a4b6742736da6a8e76c762291bebdc7652cfec2f"].unchecked_into(),
hex!["3c944c704cae203619b9e7a5a4b6742736da6a8e76c762291bebdc7652cfec2f"]
.unchecked_into(),
// sfDx3gj4wFHg3cK6bopnypHQ6TxW1VgyPsYVbXKhRHtLDLxQb
hex!["0aa3a88f6b777c95c3dfe7e997b76798413f16aa325f34824cae0c9102b281d5"].unchecked_into(),
hex!["0aa3a88f6b777c95c3dfe7e997b76798413f16aa325f34824cae0c9102b281d5"]
.unchecked_into(),
// sfHXZbnZV3YWwnH28q2xumm7stvuC8LweYYxPNuHGonnX7QHL
hex!["a8e828d10cf7b74481b6e746e5532d4740ea8014a0d3d856540a59847f8a6b76"].unchecked_into(),
hex!["a8e828d10cf7b74481b6e746e5532d4740ea8014a0d3d856540a59847f8a6b76"]
.unchecked_into(),
// sfEaHBrBgeMhRTA3WHE9Nbyvn3h7xkhYKi7go4yo81L88o9zJ
hex!["2645f1f6820dd3a917eebbdab033088d8862477c1c14759b218685f9a0893377"].unchecked_into(),
hex!["2645f1f6820dd3a917eebbdab033088d8862477c1c14759b218685f9a0893377"]
.unchecked_into(),
),
];
@ -449,7 +479,9 @@ fn casper_staging_config_genesis() -> serde_json::Value {
fn casper_development_config_genesis() -> serde_json::Value {
testnet_config_genesis(
vec![get_authority_keys_from_seed("Alice")],
None, None, None,
None,
None,
None,
)
}

View File

@ -7,15 +7,15 @@ pub mod chain_spec;
use {
grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider},
sc_client_api::BlockBackend,
tx_pool_api::OffchainTransactionPoolFactory,
sp_blockchain::HeaderBackend,
sc_service::{KeystoreContainer, RpcHandlers},
sp_blockchain::HeaderBackend,
telemetry::{Telemetry, TelemetryWorkerHandle},
tx_pool_api::OffchainTransactionPoolFactory,
};
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use std::{sync::Arc, time::Duration};
use telemetry::TelemetryWorker;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
pub use chain_spec::GenericChainSpec;
pub use consensus_common::{Proposal, SelectChain};
@ -23,27 +23,23 @@ pub use primitives::{Block, BlockId, BlockNumber, Hash};
pub use sc_client_api::{Backend, CallExecutor};
pub use sc_consensus::BlockImport;
pub use sc_executor::NativeExecutionDispatch;
pub use sp_api::{ApiRef, ConstructRuntimeApi, Core as CoreApi, ProvideRuntimeApi};
pub use sc_service::{
config::{DatabaseSource, PrometheusConfig},
ChainSpec, Configuration, Error as SubstrateServiceError, PruningMode, Role,
RuntimeGenesis, TFullBackend, TFullCallExecutor, TFullClient, TaskManager,
TransactionPoolOptions,
ChainSpec, Configuration, Error as SubstrateServiceError, PruningMode, Role, RuntimeGenesis,
TFullBackend, TFullCallExecutor, TFullClient, TaskManager, TransactionPoolOptions,
};
pub use sp_api::{ApiRef, ConstructRuntimeApi, Core as CoreApi, ProvideRuntimeApi};
pub use sp_runtime::{
generic,
traits::{
self as runtime_traits, BlakeTwo256, Block as BlockT, Header as HeaderT,
NumberFor,
},
traits::{self as runtime_traits, BlakeTwo256, Block as BlockT, Header as HeaderT, NumberFor},
};
#[cfg(feature = "casper-native")]
use casper_runtime::RuntimeApi;
#[cfg(feature = "casper-native")]
pub use chain_spec::CasperChainSpec;
#[cfg(feature = "casper-native")]
pub use {casper_runtime, casper_runtime_constants};
#[cfg(feature = "casper-native")]
use casper_runtime::RuntimeApi;
#[cfg(feature = "full-node")]
pub type FullBackend = sc_service::TFullBackend<Block>;
@ -177,9 +173,13 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
}
fn identify_chain(&self) -> Chain {
if self.is_ghost() { Chain::Ghost }
else if self.is_casper() { Chain::Casper }
else { Chain::Unknown }
if self.is_ghost() {
Chain::Ghost
} else if self.is_casper() {
Chain::Casper
} else {
Chain::Unknown
}
}
}
@ -222,7 +222,9 @@ fn new_partial_basics(
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});
let executor = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
@ -251,13 +253,25 @@ fn new_partial_basics(
telemetry
});
Ok(Basics { task_manager, client, backend, keystore_container, telemetry })
Ok(Basics {
task_manager,
client,
backend,
keystore_container,
telemetry,
})
}
#[cfg(feature = "full-node")]
fn new_partial<ChainSelection>(
config: &mut Configuration,
Basics { task_manager, backend, client, keystore_container, telemetry }: Basics,
Basics {
task_manager,
backend,
client,
keystore_container,
telemetry,
}: Basics,
select_chain: ChainSelection,
) -> Result<
sc_service::PartialComponents<
@ -272,11 +286,7 @@ fn new_partial<ChainSelection>(
ghost_rpc::SubscriptionTaskExecutor,
) -> Result<ghost_rpc::RpcExtension, SubstrateServiceError>,
(
babe::BabeBlockImport<
Block,
FullClient,
FullGrandpaBlockImport<ChainSelection>,
>,
babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport<ChainSelection>>,
grandpa::LinkHalf<Block, FullClient, ChainSelection>,
babe::BabeLink<Block>,
),
@ -297,14 +307,13 @@ where
client.clone(),
);
let (grandpa_block_import, grandpa_link) =
grandpa::block_import(
client.clone(),
GRANDPA_JUSTIFICATION_PERIOD,
&(client.clone() as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(),
GRANDPA_JUSTIFICATION_PERIOD,
&(client.clone() as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
let justification_import = grandpa_block_import.clone();
let babe_config = babe::configuration(&*client)?;
@ -312,27 +321,26 @@ where
babe::block_import(babe_config.clone(), grandpa_block_import, client.clone())?;
let slot_duration = babe_link.config().slot_duration();
let (import_queue, babe_worker_handle) =
babe::import_queue(babe::ImportQueueParams {
link: babe_link.clone(),
block_import: block_import.clone(),
justification_import: Some(Box::new(justification_import)),
client: client.clone(),
select_chain: select_chain.clone(),
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
babe_primitives::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
},
spawner: &task_manager.spawn_essential_handle(),
registry: config.prometheus_registry(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
})?;
let (import_queue, babe_worker_handle) = babe::import_queue(babe::ImportQueueParams {
link: babe_link.clone(),
block_import: block_import.clone(),
justification_import: Some(Box::new(justification_import)),
client: client.clone(),
select_chain: select_chain.clone(),
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
babe_primitives::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
},
spawner: &task_manager.spawn_essential_handle(),
registry: config.prometheus_registry(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
})?;
let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
@ -353,10 +361,9 @@ where
let chain_spec = config.chain_spec.cloned_box();
let backend = backend.clone();
move |
deny_unsafe,
subscription_executor: ghost_rpc::SubscriptionTaskExecutor,
| -> Result<ghost_rpc::RpcExtension, sc_service::Error> {
move |deny_unsafe,
subscription_executor: ghost_rpc::SubscriptionTaskExecutor|
-> Result<ghost_rpc::RpcExtension, sc_service::Error> {
let deps = ghost_rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
@ -428,8 +435,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let backoff_authoring_blocks = if !force_authoring_backoff {
None
} else {
let mut backoff =
sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();
if config.chain_spec.is_dev() {
backoff.max_interval = 10;
@ -446,7 +452,14 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let prometheus_registry = config.prometheus_registry().cloned();
let select_chain = sc_consensus::LongestChain::new(basics.backend.clone());
let sc_service::PartialComponents::<_, _, sc_consensus::LongestChain<FullBackend, Block>, _, _, _,> {
let sc_service::PartialComponents::<
_,
_,
sc_consensus::LongestChain<FullBackend, Block>,
_,
_,
_,
> {
client,
backend,
mut task_manager,
@ -454,12 +467,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
select_chain,
import_queue,
transaction_pool,
other: (
rpc_extensions_builder,
import_setup,
rpc_setup,
mut telemetry,
),
other: (rpc_extensions_builder, import_setup, rpc_setup, mut telemetry),
} = new_partial::<sc_consensus::LongestChain<FullBackend, Block>>(
&mut config,
basics,
@ -476,7 +484,11 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let mut net_config =
sc_network::config::FullNetworkConfiguration::<_, _, Network>::new(&config.network);
let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
let genesis_hash = client
.block_hash(0)
.ok()
.flatten()
.expect("Genesis block exists; qed");
let peer_store_handle = net_config.peer_store_handle();
let grandpa_protocol_name = grandpa::protocol_standard_name(&genesis_hash, &config.chain_spec);
@ -554,8 +566,8 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'",
err
);
},
_ => {},
}
_ => {}
}
if let Some(ref mut telemetry) = telemetry {
@ -563,10 +575,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
task_manager.spawn_handle().spawn(
"telemetry_hwbench",
None,
sc_sysinfo::initialize_hwbench_telemetry(
telemetry_handle,
hwbench,
),
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
);
}
}
@ -580,12 +589,14 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let authority_discovery_role =
sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore());
let dht_event_stream =
network.event_stream("authority-discovery").filter_map(|e| async move {
match e {
Event::Dht(e) => Some(e),
_ => None,
}
});
network
.event_stream("authority-discovery")
.filter_map(|e| async move {
match e {
Event::Dht(e) => Some(e),
_ => None,
}
});
let (worker, _service) = sc_authority_discovery::new_worker_and_service_with_config(
sc_authority_discovery::WorkerConfig {
publish_non_global_ips: auth_disc_publish_non_global_ips,
@ -597,7 +608,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
Arc::new(network.clone()),
Box::pin(dht_event_stream),
authority_discovery_role,
prometheus_registry.clone()
prometheus_registry.clone(),
);
task_manager.spawn_handle().spawn(
@ -625,16 +636,14 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
env: proposer,
sync_oracle: sync_service.clone(),
justification_sync_link: sync_service.clone(),
create_inherent_data_providers: move |_, ()| {
async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
babe_primitives::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
}
Ok((slot, timestamp))
},
force_authoring,
backoff_authoring_blocks,
@ -646,7 +655,9 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let babe = babe::start_babe(babe_config)?;
task_manager.spawn_essential_handle().spawn_blocking("babe", None, babe);
task_manager
.spawn_essential_handle()
.spawn_blocking("babe", None, babe);
}
let keystore_opt = if role.is_authority() {
@ -711,8 +722,17 @@ macro_rules! chain_ops {
let chain_selection = sc_consensus::LongestChain::new(basics.backend.clone());
let sc_service::PartialComponents { client, backend, import_queue, task_manager, .. } =
new_partial::<sc_consensus::LongestChain<FullBackend, Block>>(&mut config, basics, chain_selection)?;
let sc_service::PartialComponents {
client,
backend,
import_queue,
task_manager,
..
} = new_partial::<sc_consensus::LongestChain<FullBackend, Block>>(
&mut config,
basics,
chain_selection,
)?;
Ok((client, backend, import_queue, task_manager))
}};
}
@ -720,22 +740,28 @@ macro_rules! chain_ops {
#[cfg(feature = "full-node")]
pub fn new_chain_ops(
config: &mut Configuration,
) -> Result<(Arc<FullClient>, Arc<FullBackend>, sc_consensus::BasicQueue<Block>, TaskManager), Error>
{
) -> Result<
(
Arc<FullClient>,
Arc<FullBackend>,
sc_consensus::BasicQueue<Block>,
TaskManager,
),
Error,
> {
config.keystore = sc_service::config::KeystoreConfig::InMemory;
chain_ops!(config, None)
}
#[cfg(feature = "full-node")]
pub fn build_full(
config: Configuration,
params: NewFullParams,
) -> Result<NewFull, Error> {
pub fn build_full(config: Configuration, params: NewFullParams) -> Result<NewFull, Error> {
match config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p =>
new_full::<sc_network::NetworkWorker<Block, Hash>>(config, params),
sc_network::config::NetworkBackendType::Litep2p =>
new_full::<sc_network::Litep2pNetworkBackend>(config, params),
sc_network::config::NetworkBackendType::Libp2p => {
new_full::<sc_network::NetworkWorker<Block, Hash>>(config, params)
}
sc_network::config::NetworkBackendType::Litep2p => {
new_full::<sc_network::Litep2pNetworkBackend>(config, params)
}
}
}
@ -750,7 +776,7 @@ pub fn revert_backend(
let revertible = blocks.min(best_number - finalized);
if revertible == 0 {
return Ok(())
return Ok(());
}
babe::revert(client.clone(), backend, blocks)?;