Storage chains sync (#9171)

* Sync storage chains

* Test

* Apply suggestions from code review

Co-authored-by: cheme <emericchevalier.pro@gmail.com>

* Separate block body and indexed body

* Update client/db/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: cheme <emericchevalier.pro@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2021-07-17 10:58:37 +02:00
committed by GitHub
parent f07a41e87d
commit 5a65bf5515
27 changed files with 221 additions and 59 deletions
+12 -3
View File
@@ -21,7 +21,7 @@ use crate::{
start_rpc_servers, build_network_future, TransactionPoolAdapter, TaskManager, SpawnTaskHandle,
metrics::MetricsService,
client::{light, Client, ClientConfig},
config::{Configuration, KeystoreConfig, PrometheusConfig},
config::{Configuration, KeystoreConfig, PrometheusConfig, TransactionStorageMode},
};
use sc_client_api::{
light::RemoteBlockchain, ForkBlocks, BadBlocks, UsageProvider, ExecutorProvider,
@@ -40,7 +40,7 @@ use futures::{
};
use sc_keystore::LocalKeystore;
use log::info;
use sc_network::config::{Role, OnDemand};
use sc_network::config::{Role, OnDemand, SyncMode};
use sc_network::NetworkService;
use sc_network::block_request_handler::{self, BlockRequestHandler};
use sc_network::state_request_handler::{self, StateRequestHandler};
@@ -946,7 +946,7 @@ pub fn build_network<TBl, TExPool, TImpQu, TCl>(
}
};
let network_params = sc_network::config::Params {
let mut network_params = sc_network::config::Params {
role: config.role.clone(),
executor: {
let spawn_handle = Clone::clone(&spawn_handle);
@@ -973,6 +973,15 @@ pub fn build_network<TBl, TExPool, TImpQu, TCl>(
light_client_request_protocol_config,
};
// Storage chains don't keep full block history and can't be synced in full mode.
// Force fast sync when storage chain mode is enabled.
if matches!(config.transaction_storage, TransactionStorageMode::StorageChain) {
network_params.network_config.sync_mode = SyncMode::Fast {
storage_chain_mode: true,
skip_proofs: false,
};
}
let has_bootnodes = !network_params.network_config.boot_nodes.is_empty();
let network_mut = sc_network::NetworkWorker::new(network_params)?;
let network = network_mut.service().clone();