mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 19:07:57 +00:00
add warp_sync_params (#1909)
* wait for relay chain to sync then get parachain header * Spawn new thread to wait for the target block * second round of comments from the PR on substrate * third round of pr comments * add zombienet tests * rebase issues * refactor tests based on pr comments * rebase issues * pr comments * passing zombienet test * cargo +nightly fmt * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * use cargo lock from master * pr comments * cargo fmt * use finalised block instead of best block * use import notification stream * rebase changes * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/relay-chain-interface/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/relay-chain-interface/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * pr comments * use new file names * db snaphots moved to google cloud storage * Update client/network/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/service/src/lib.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * pr comments * Update zombienet/tests/0007-full_node_warp_sync.toml Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Update zombienet/tests/0007-full_node_warp_sync.toml Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Scenario 1 Parachain node and in-node relay chain both start with --sync warp. This ensures that the waiting logic works as expected. Scenario 2 Parachain node starts with warp sync, relay chain points to a node already synced up scenario 3 Parachain node starts with warp sync, relay chain points to a node that uses warp sync * Use test-parachain * use test-parachain chainspecs * remove relay chain spec as it is no longer required * add back relaychain spec file * pr comments * Upload snapshots to google cloud * Update zombienet/tests/0007-prepare-warp-sync-db-snapshot.md Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * update documentation * Fix snapshot URLs * use master lock file * add finalized_block_hash * Patch diener for CI * Bump Zombienet * Add 0007 zombienet test * Bump zombienet * Revert "Patch diener for CI" This reverts commit 9ece6c9fc9b17058b61cd7e9dee29d3a9af87841. * merge fixes * use master lock file * Update Substrate & Polkadot --------- Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -30,7 +30,7 @@ variables:
|
||||
CI_IMAGE: "paritytech/ci-linux:production"
|
||||
DOCKER_OS: "debian:stretch"
|
||||
ARCH: "x86_64"
|
||||
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.29"
|
||||
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.34"
|
||||
|
||||
.collect-artifacts:
|
||||
artifacts:
|
||||
|
||||
Generated
+280
-292
File diff suppressed because it is too large
Load Diff
@@ -85,6 +85,10 @@ impl RelayChainInterface for Relaychain {
|
||||
unimplemented!("Not needed for test")
|
||||
}
|
||||
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<PHash> {
|
||||
unimplemented!("Not needed for test")
|
||||
}
|
||||
|
||||
async fn retrieve_dmq_contents(
|
||||
&self,
|
||||
_: ParaId,
|
||||
|
||||
@@ -36,7 +36,6 @@ use polkadot_primitives::{
|
||||
|
||||
use codec::{Decode, DecodeAll, Encode};
|
||||
use futures::{channel::oneshot, future::FutureExt, Future};
|
||||
|
||||
use std::{convert::TryFrom, fmt, marker::PhantomData, pin::Pin, sync::Arc};
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -84,6 +84,9 @@ impl RelayChainInterface for DummyRelayChainInterface {
|
||||
async fn best_block_hash(&self) -> RelayChainResult<PHash> {
|
||||
Ok(self.relay_backend.blockchain().info().best_hash)
|
||||
}
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<PHash> {
|
||||
Ok(self.relay_backend.blockchain().info().finalized_hash)
|
||||
}
|
||||
|
||||
async fn retrieve_dmq_contents(
|
||||
&self,
|
||||
|
||||
@@ -167,6 +167,10 @@ where
|
||||
Ok(self.backend.blockchain().info().best_hash)
|
||||
}
|
||||
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<PHash> {
|
||||
Ok(self.backend.blockchain().info().finalized_hash)
|
||||
}
|
||||
|
||||
async fn is_major_syncing(&self) -> RelayChainResult<bool> {
|
||||
Ok(self.sync_oracle.is_major_syncing())
|
||||
}
|
||||
|
||||
@@ -105,6 +105,9 @@ pub trait RelayChainInterface: Send + Sync {
|
||||
/// Get the hash of the current best block.
|
||||
async fn best_block_hash(&self) -> RelayChainResult<PHash>;
|
||||
|
||||
/// Get the hash of the finalized block.
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<PHash>;
|
||||
|
||||
/// Returns the whole contents of the downward message queue for the parachain we are collating
|
||||
/// for.
|
||||
///
|
||||
@@ -248,6 +251,10 @@ where
|
||||
(**self).best_block_hash().await
|
||||
}
|
||||
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<PHash> {
|
||||
(**self).finalized_block_hash().await
|
||||
}
|
||||
|
||||
async fn is_major_syncing(&self) -> RelayChainResult<bool> {
|
||||
(**self).is_major_syncing().await
|
||||
}
|
||||
|
||||
@@ -123,6 +123,10 @@ impl RelayChainInterface for RelayChainRpcInterface {
|
||||
self.rpc_client.chain_get_head(None).await
|
||||
}
|
||||
|
||||
async fn finalized_block_hash(&self) -> RelayChainResult<RelayHash> {
|
||||
self.rpc_client.chain_get_finalized_head().await
|
||||
}
|
||||
|
||||
async fn is_major_syncing(&self) -> RelayChainResult<bool> {
|
||||
self.rpc_client.system_health().await.map(|h| h.is_syncing)
|
||||
}
|
||||
|
||||
@@ -11,14 +11,20 @@ futures = "0.3.26"
|
||||
# Substrate
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-network-transactions = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
@@ -28,7 +34,8 @@ cumulus-client-cli = { path = "../cli" }
|
||||
cumulus-client-collator = { path = "../collator" }
|
||||
cumulus-client-consensus-common = { path = "../consensus/common" }
|
||||
cumulus-client-pov-recovery = { path = "../pov-recovery" }
|
||||
cumulus-client-network = { path = "../network" }
|
||||
cumulus-primitives-core = { path = "../../primitives/core" }
|
||||
cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
|
||||
cumulus-relay-chain-inprocess-interface = { path = "../relay-chain-inprocess-interface" }
|
||||
cumulus-relay-chain-minimal-node = { path = "../relay-chain-minimal-node" }
|
||||
cumulus-relay-chain-minimal-node = { path = "../relay-chain-minimal-node" }
|
||||
@@ -20,31 +20,37 @@
|
||||
|
||||
use cumulus_client_cli::CollatorOptions;
|
||||
use cumulus_client_consensus_common::ParachainConsensus;
|
||||
use cumulus_client_network::BlockAnnounceValidator;
|
||||
use cumulus_client_pov_recovery::{PoVRecovery, RecoveryDelayRange, RecoveryHandle};
|
||||
use cumulus_primitives_core::{CollectCollationInfo, ParaId};
|
||||
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
|
||||
use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult};
|
||||
use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
|
||||
use polkadot_primitives::CollatorPair;
|
||||
|
||||
use sc_client_api::{
|
||||
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
FutureExt, StreamExt,
|
||||
};
|
||||
use sc_consensus::{import_queue::ImportQueueService, BlockImport};
|
||||
use sc_service::{Configuration, TaskManager};
|
||||
use sc_telemetry::TelemetryWorkerHandle;
|
||||
use polkadot_primitives::{CollatorPair, OccupiedCoreAssumption};
|
||||
use sc_client_api::{
|
||||
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, ProofProvider, UsageProvider,
|
||||
};
|
||||
use sc_consensus::{import_queue::ImportQueueService, BlockImport, ImportQueue};
|
||||
use sc_network::{config::SyncMode, NetworkService};
|
||||
use sc_network_transactions::TransactionsHandlerController;
|
||||
use sc_service::{Configuration, NetworkStarter, SpawnTaskHandle, TaskManager, WarpSyncParams};
|
||||
use sc_telemetry::{log, TelemetryWorkerHandle};
|
||||
use sc_utils::mpsc::TracingUnboundedSender;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
|
||||
use futures::channel::mpsc;
|
||||
use sp_blockchain::{HeaderBackend, HeaderMetadata};
|
||||
use sp_core::{traits::SpawnNamed, Decode};
|
||||
use sp_runtime::traits::{Block as BlockT, BlockIdTo};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
// Given the sporadic nature of the explicit recovery operation and the
|
||||
// possibility to retry infinite times this value is more than enough.
|
||||
// In practice here we expect no more than one queued messages.
|
||||
const RECOVERY_CHAN_SIZE: usize = 8;
|
||||
const LOG_TARGET_SYNC: &str = "sync::cumulus";
|
||||
|
||||
/// Parameters given to [`start_collator`].
|
||||
pub struct StartCollatorParams<'a, Block: BlockT, BS, Client, RCInterface, Spawner> {
|
||||
@@ -268,3 +274,172 @@ pub async fn build_relay_chain_interface(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters given to [`build_network`].
|
||||
pub struct BuildNetworkParams<
|
||||
'a,
|
||||
Block: BlockT,
|
||||
Client: ProvideRuntimeApi<Block>
|
||||
+ BlockBackend<Block>
|
||||
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
|
||||
+ HeaderBackend<Block>
|
||||
+ BlockIdTo<Block>
|
||||
+ 'static,
|
||||
RCInterface,
|
||||
IQ,
|
||||
> where
|
||||
Client::Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
|
||||
{
|
||||
pub parachain_config: &'a Configuration,
|
||||
pub client: Arc<Client>,
|
||||
pub transaction_pool: Arc<sc_transaction_pool::FullPool<Block, Client>>,
|
||||
pub para_id: ParaId,
|
||||
pub relay_chain_interface: RCInterface,
|
||||
pub spawn_handle: SpawnTaskHandle,
|
||||
pub import_queue: IQ,
|
||||
}
|
||||
|
||||
/// Build the network service, the network status sinks and an RPC sender.
|
||||
pub async fn build_network<'a, Block, Client, RCInterface, IQ>(
|
||||
BuildNetworkParams {
|
||||
parachain_config,
|
||||
client,
|
||||
transaction_pool,
|
||||
para_id,
|
||||
spawn_handle,
|
||||
relay_chain_interface,
|
||||
import_queue,
|
||||
}: BuildNetworkParams<'a, Block, Client, RCInterface, IQ>,
|
||||
) -> sc_service::error::Result<(
|
||||
Arc<NetworkService<Block, Block::Hash>>,
|
||||
TracingUnboundedSender<sc_rpc::system::Request<Block>>,
|
||||
TransactionsHandlerController<Block::Hash>,
|
||||
NetworkStarter,
|
||||
)>
|
||||
where
|
||||
Block: BlockT,
|
||||
Client: UsageProvider<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ sp_consensus::block_validation::Chain<Block>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ BlockBackend<Block>
|
||||
+ BlockchainEvents<Block>
|
||||
+ ProvideRuntimeApi<Block>
|
||||
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
|
||||
+ BlockIdTo<Block, Error = sp_blockchain::Error>
|
||||
+ ProofProvider<Block>
|
||||
+ 'static,
|
||||
Client::Api: CollectCollationInfo<Block>
|
||||
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
|
||||
for<'b> &'b Client: BlockImport<Block>,
|
||||
RCInterface: RelayChainInterface + Clone + 'static,
|
||||
IQ: ImportQueue<Block> + 'static,
|
||||
{
|
||||
let warp_sync_params = match parachain_config.network.sync_mode {
|
||||
SyncMode::Warp => {
|
||||
let target_block = warp_sync_get::<Block, RCInterface>(
|
||||
para_id,
|
||||
relay_chain_interface.clone(),
|
||||
spawn_handle.clone(),
|
||||
);
|
||||
Some(WarpSyncParams::WaitForTarget(target_block))
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface, para_id);
|
||||
let block_announce_validator_builder = move |_| Box::new(block_announce_validator) as Box<_>;
|
||||
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: parachain_config,
|
||||
client,
|
||||
transaction_pool,
|
||||
spawn_handle,
|
||||
import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
|
||||
warp_sync_params,
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a new background task to wait for the relay chain to sync up and retrieve the parachain header
|
||||
fn warp_sync_get<B, RCInterface>(
|
||||
para_id: ParaId,
|
||||
relay_chain_interface: RCInterface,
|
||||
spawner: SpawnTaskHandle,
|
||||
) -> oneshot::Receiver<<B as BlockT>::Header>
|
||||
where
|
||||
B: BlockT + 'static,
|
||||
RCInterface: RelayChainInterface + 'static,
|
||||
{
|
||||
let (sender, receiver) = oneshot::channel::<B::Header>();
|
||||
spawner.spawn(
|
||||
"cumulus-parachain-wait-for-target-block",
|
||||
None,
|
||||
async move {
|
||||
log::debug!(
|
||||
target: "cumulus-network",
|
||||
"waiting for announce block in a background task...",
|
||||
);
|
||||
|
||||
let _ = wait_for_target_block::<B, _>(sender, para_id, relay_chain_interface)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!(
|
||||
target: LOG_TARGET_SYNC,
|
||||
"Unable to determine parachain target block {:?}",
|
||||
e
|
||||
)
|
||||
});
|
||||
}
|
||||
.boxed(),
|
||||
);
|
||||
|
||||
receiver
|
||||
}
|
||||
|
||||
/// Waits for the relay chain to have finished syncing and then gets the parachain header that corresponds to the last finalized relay chain block.
|
||||
async fn wait_for_target_block<B, RCInterface>(
|
||||
sender: oneshot::Sender<<B as BlockT>::Header>,
|
||||
para_id: ParaId,
|
||||
relay_chain_interface: RCInterface,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
|
||||
where
|
||||
B: BlockT + 'static,
|
||||
RCInterface: RelayChainInterface + Send + 'static,
|
||||
{
|
||||
let mut imported_blocks = relay_chain_interface.import_notification_stream().await?.fuse();
|
||||
while imported_blocks.next().await.is_some() {
|
||||
let is_syncing = relay_chain_interface.is_major_syncing().await.map_err(|e| {
|
||||
Box::<dyn std::error::Error + Send + Sync>::from(format!(
|
||||
"Unable to determine sync status. {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
if !is_syncing {
|
||||
let relay_chain_best_hash = relay_chain_interface
|
||||
.finalized_block_hash()
|
||||
.await
|
||||
.map_err(|e| Box::new(e) as Box<_>)?;
|
||||
|
||||
let validation_data = relay_chain_interface
|
||||
.persisted_validation_data(
|
||||
relay_chain_best_hash,
|
||||
para_id,
|
||||
OccupiedCoreAssumption::TimedOut,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("{e:?}"))?
|
||||
.ok_or_else(|| "Could not find parachain head in relay chain")?;
|
||||
|
||||
let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..])
|
||||
.map_err(|e| format!("Failed to decode parachain head: {e}"))?;
|
||||
|
||||
log::debug!(target: LOG_TARGET_SYNC, "Target block reached {:?}", target_block);
|
||||
let _ = sender.send(target_block);
|
||||
return Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Err("Stopping following imported blocks. Could not determine parachain target block".into())
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, Slo
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainBlockImport as TParachainBlockImport, ParachainConsensus,
|
||||
};
|
||||
use cumulus_client_network::BlockAnnounceValidator;
|
||||
use cumulus_client_service::{
|
||||
build_relay_chain_interface, prepare_node_config, start_collator, start_full_node,
|
||||
StartCollatorParams, StartFullNodeParams,
|
||||
build_network, build_relay_chain_interface, prepare_node_config, start_collator,
|
||||
start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams,
|
||||
};
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
|
||||
@@ -168,9 +167,6 @@ async fn start_node_impl(
|
||||
s => s.to_string().into(),
|
||||
})?;
|
||||
|
||||
let block_announce_validator =
|
||||
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
|
||||
|
||||
let force_authoring = parachain_config.force_authoring;
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
@@ -178,17 +174,16 @@ async fn start_node_impl(
|
||||
let import_queue_service = params.import_queue.service();
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: ¶chain_config,
|
||||
build_network(BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(|_| {
|
||||
Box::new(block_announce_validator)
|
||||
})),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
})
|
||||
.await?;
|
||||
|
||||
if parachain_config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
|
||||
@@ -20,10 +20,9 @@ use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, Slo
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||
};
|
||||
use cumulus_client_network::BlockAnnounceValidator;
|
||||
use cumulus_client_service::{
|
||||
build_relay_chain_interface, prepare_node_config, start_collator, start_full_node,
|
||||
StartCollatorParams, StartFullNodeParams,
|
||||
build_network, build_relay_chain_interface, prepare_node_config, start_collator,
|
||||
start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams,
|
||||
};
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain::{Hash as PHash, PersistedValidationData},
|
||||
@@ -390,9 +389,6 @@ where
|
||||
s => s.to_string().into(),
|
||||
})?;
|
||||
|
||||
let block_announce_validator =
|
||||
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
|
||||
|
||||
let force_authoring = parachain_config.force_authoring;
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
@@ -400,17 +396,16 @@ where
|
||||
let import_queue_service = params.import_queue.service();
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: ¶chain_config,
|
||||
build_network(BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(|_| {
|
||||
Box::new(block_announce_validator)
|
||||
})),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
})
|
||||
.await?;
|
||||
|
||||
let rpc_client = client.clone();
|
||||
let rpc_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
|
||||
@@ -583,9 +578,6 @@ where
|
||||
s => s.to_string().into(),
|
||||
})?;
|
||||
|
||||
let block_announce_validator =
|
||||
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
|
||||
|
||||
let force_authoring = parachain_config.force_authoring;
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
@@ -593,17 +585,16 @@ where
|
||||
let import_queue_service = params.import_queue.service();
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: ¶chain_config,
|
||||
build_network(cumulus_client_service::BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(|_| {
|
||||
Box::new(block_announce_validator)
|
||||
})),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
})
|
||||
.await?;
|
||||
|
||||
let rpc_builder = {
|
||||
let client = client.clone();
|
||||
@@ -1362,9 +1353,6 @@ where
|
||||
s => s.to_string().into(),
|
||||
})?;
|
||||
|
||||
let block_announce_validator =
|
||||
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
|
||||
|
||||
let force_authoring = parachain_config.force_authoring;
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
@@ -1372,17 +1360,16 @@ where
|
||||
let import_queue_service = params.import_queue.service();
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: ¶chain_config,
|
||||
build_network(BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(|_| {
|
||||
Box::new(block_announce_validator)
|
||||
})),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
})
|
||||
.await?;
|
||||
|
||||
let rpc_builder = {
|
||||
let client = client.clone();
|
||||
|
||||
@@ -127,3 +127,15 @@ zombienet-0006-rpc_collator_builds_blocks:
|
||||
--github-remote-dir="${GH_DIR}"
|
||||
--concurrency=1
|
||||
--test="0006-rpc_collator_builds_blocks.feature"
|
||||
|
||||
zombienet-0007-full_node_warp_sync:
|
||||
extends:
|
||||
- .zombienet-common
|
||||
- .zombienet-refs
|
||||
- .zombienet-before-script
|
||||
- .zombienet-after-script
|
||||
script:
|
||||
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
|
||||
--github-remote-dir="${GH_DIR}"
|
||||
--concurrency=1
|
||||
--test="0007-full_node_warp_sync.feature"
|
||||
|
||||
@@ -33,10 +33,10 @@ use cumulus_client_cli::CollatorOptions;
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||
};
|
||||
use cumulus_client_network::BlockAnnounceValidator;
|
||||
use cumulus_client_pov_recovery::RecoveryHandle;
|
||||
use cumulus_client_service::{
|
||||
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
||||
build_network, prepare_node_config, start_collator, start_full_node, BuildNetworkParams,
|
||||
StartCollatorParams, StartFullNodeParams,
|
||||
};
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_relay_chain_inprocess_interface::RelayChainInProcessInterface;
|
||||
@@ -314,23 +314,21 @@ where
|
||||
s => s.to_string().into(),
|
||||
})?;
|
||||
|
||||
let block_announce_validator =
|
||||
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
|
||||
let block_announce_validator_builder = move |_| Box::new(block_announce_validator) as Box<_>;
|
||||
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
let import_queue_service = params.import_queue.service();
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: ¶chain_config,
|
||||
build_network(BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
})
|
||||
.await?;
|
||||
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
|
||||
let rpc_builder = {
|
||||
let client = client.clone();
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
Description: Full node catching up using warp sync
|
||||
Network: ./0007-full_node_warp_sync.toml
|
||||
Creds: config
|
||||
|
||||
alice: is up within 30 seconds
|
||||
bob: is up within 30 seconds
|
||||
charlie: is up within 30 seconds
|
||||
dave: is up within 30 seconds
|
||||
eve: is up within 30 seconds
|
||||
ferdie: is up within 30 seconds
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
one: reports block height is at least 770 within 225 seconds
|
||||
two: reports block height is at least 770 within 225 seconds
|
||||
three: reports block height is at least 770 within 225 seconds
|
||||
@@ -0,0 +1,77 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
chain = "rococo-local"
|
||||
chain_spec_path = "zombienet/tests/0007-warp-sync-relaychain-spec.json"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/relaychain-1964f8b557f10085cdc18f4105ad0bbb3df4c4c6.tgz"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/relaychain-1964f8b557f10085cdc18f4105ad0bbb3df4c4c6.tgz"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/relaychain-1964f8b557f10085cdc18f4105ad0bbb3df4c4c6.tgz"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "dave"
|
||||
validator = true
|
||||
args = ["--sync warp", "--reserved-only", "--reserved-nodes {{'alice'|zombie('multiAddress')}} {{'bob'|zombie('multiAddress')}} {{'charlie'|zombie('multiAddress')}}"]
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
chain_spec_path = "zombienet/tests/0007-warp-sync-parachain-spec.json"
|
||||
add_to_genesis = false
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/parachain-587c1ed24ddd7de05c237cf7c158fff53b8f5b26.tgz"
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "eve"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/parachain-587c1ed24ddd7de05c237cf7c158fff53b8f5b26.tgz"
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "ferdie"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
db_snapshot = "https://storage.googleapis.com/zombienet-db-snaps/cumulus/0007-full_node_warp_sync/parachain-587c1ed24ddd7de05c237cf7c158fff53b8f5b26.tgz"
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "one"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lsync=debug","--sync warp","--","--sync warp"]
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "two"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lsync=debug","--sync warp","--relay-chain-rpc-urls {{'alice'|zombie('wsUri')}}"]
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "three"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lsync=debug","--sync warp","--relay-chain-rpc-urls {{'dave'|zombie('wsUri')}}"]
|
||||
@@ -0,0 +1,37 @@
|
||||
# Database snapshot guide
|
||||
|
||||
For this guide we will be taking a snapshot of a parachain and relay chain. Please note we are using a local chain here `rococo_local_testnet` and `local_testnet`. Live chains will have different values
|
||||
|
||||
*Please ensure that the database is not in current use, i.e no nodes are writing to it*
|
||||
|
||||
# How to prepare database for a relaychain
|
||||
To prepare snapshot for a relay chain we need to copy the database.
|
||||
|
||||
```
|
||||
mkdir -p relaychain-snapshot/alice/data/chains/rococo_local_testnet/db/
|
||||
|
||||
cp -r chain-data/alice/data/chains/rococo_local_testnet/db/. relaychain-snapshot/alice/data/chains/rococo_local_testnet/db/
|
||||
|
||||
tar -C relaychain-snapshot/alice/ -czf relaychain.tgz data
|
||||
```
|
||||
# How to prepare database for a parachain
|
||||
|
||||
To prepare snapshot for a parachain we need to copy the database for both the collator node (parachain data) and validator (relay data)
|
||||
|
||||
```
|
||||
#Parachain data
|
||||
mkdir -p parachain-snapshot/charlie/data/chains/local_testnet/db/
|
||||
|
||||
# Relay data
|
||||
mkdir -p parachain-snapshot/charlie/relay-data/chains/rococo_local_testnet/db/
|
||||
|
||||
cp -r chain-data/charlie/data/chains/local_testnet/db/. parachain-snapshot/charlie/data/chains/local_testnet/db/
|
||||
|
||||
cp -r chain-data/charlie/relay-data/chains/rococo_local_testnet/db/. parachain-snapshot/charlie/relay-data/chains/rococo_local_testnet/db/
|
||||
|
||||
tar -C parachain-snapshot/charlie/ -czf parachain.tgz data relay-data
|
||||
```
|
||||
|
||||
# Restoring a snapshot
|
||||
Zombienet will automatically download the `*.tgz` file to the respective folder for a run. However you can also download it manually, just ensure you extract the tar file in the correct directory, i.e. the root directory
|
||||
`chain-data/charlie/`
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user