mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 11:38:01 +00:00
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:
@@ -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();
|
||||
|
||||
@@ -168,6 +168,7 @@ fn import_block_to_queue<TBl, TImpQu>(
|
||||
hash,
|
||||
header: Some(header),
|
||||
body: Some(extrinsics),
|
||||
indexed_body: None,
|
||||
justifications: signed_block.justifications,
|
||||
origin: None,
|
||||
allow_missing_state: false,
|
||||
|
||||
@@ -355,6 +355,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
genesis_block.deconstruct().0,
|
||||
Some(vec![]),
|
||||
None,
|
||||
None,
|
||||
block_state,
|
||||
)?;
|
||||
backend.commit_operation(op)?;
|
||||
@@ -657,6 +658,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
justifications,
|
||||
post_digests,
|
||||
body,
|
||||
indexed_body,
|
||||
finalized,
|
||||
auxiliary,
|
||||
fork_choice,
|
||||
@@ -695,6 +697,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
import_headers,
|
||||
justifications,
|
||||
body,
|
||||
indexed_body,
|
||||
storage_changes,
|
||||
new_cache,
|
||||
finalized,
|
||||
@@ -734,6 +737,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
import_headers: PrePostHeader<Block::Header>,
|
||||
justifications: Option<Justifications>,
|
||||
body: Option<Vec<Block::Extrinsic>>,
|
||||
indexed_body: Option<Vec<Vec<u8>>>,
|
||||
storage_changes: Option<sp_consensus::StorageChanges<Block, backend::TransactionFor<B, Block>>>,
|
||||
new_cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||
finalized: bool,
|
||||
@@ -871,6 +875,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
operation.op.set_block_data(
|
||||
import_headers.post().clone(),
|
||||
body,
|
||||
indexed_body,
|
||||
justifications,
|
||||
leaf_state,
|
||||
)?;
|
||||
|
||||
Reference in New Issue
Block a user