mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Update Substrate & Polkadot (#387)
* Update Substrate & Polkadot * Enforce `ParachainSetCode`
This commit is contained in:
@@ -31,18 +31,19 @@ use sp_runtime::{
|
||||
use sp_state_machine::InspectState;
|
||||
|
||||
use cumulus_client_consensus_common::ParachainConsensus;
|
||||
use polkadot_node_primitives::{Collation, CollationGenerationConfig, CollationResult};
|
||||
use polkadot_node_primitives::{
|
||||
BlockData, Collation, CollationGenerationConfig, CollationResult, PoV,
|
||||
};
|
||||
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
|
||||
use polkadot_overseer::OverseerHandler;
|
||||
use polkadot_primitives::v1::{
|
||||
BlockData, BlockNumber as PBlockNumber, CollatorPair, Hash as PHash, HeadData, Id as ParaId,
|
||||
PoV, UpwardMessage,
|
||||
BlockNumber as PBlockNumber, CollatorPair, Hash as PHash, HeadData, Id as ParaId, UpwardMessage,
|
||||
};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use std::sync::Arc;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use tracing::Instrument;
|
||||
|
||||
/// The logging target.
|
||||
@@ -429,6 +430,7 @@ mod tests {
|
||||
|
||||
self.client
|
||||
.import(BlockOrigin::Own, block.clone())
|
||||
.await
|
||||
.expect("Imports the block");
|
||||
|
||||
Some(ParachainCandidate {
|
||||
|
||||
@@ -204,7 +204,7 @@ where
|
||||
h,
|
||||
&*parachain,
|
||||
&mut unset_best_header,
|
||||
),
|
||||
).await,
|
||||
None => {
|
||||
tracing::debug!(
|
||||
target: "cumulus-consensus",
|
||||
@@ -221,7 +221,7 @@ where
|
||||
&mut unset_best_header,
|
||||
&*parachain,
|
||||
&*announce_block,
|
||||
),
|
||||
).await,
|
||||
None => {
|
||||
tracing::debug!(
|
||||
target: "cumulus-consensus",
|
||||
@@ -236,11 +236,11 @@ where
|
||||
}
|
||||
|
||||
/// Handle a new import block of the parachain.
|
||||
fn handle_new_block_imported<Block, P>(
|
||||
async fn handle_new_block_imported<Block, P>(
|
||||
notification: BlockImportNotification<Block>,
|
||||
unset_best_header_opt: &mut Option<Block::Header>,
|
||||
parachain: &P,
|
||||
announce_block: &dyn Fn(Block::Hash, Option<Vec<u8>>),
|
||||
announce_block: &(dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync),
|
||||
) where
|
||||
Block: BlockT,
|
||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||
@@ -280,7 +280,7 @@ fn handle_new_block_imported<Block, P>(
|
||||
.take()
|
||||
.expect("We checked above that the value is set; qed");
|
||||
|
||||
import_block_as_new_best(unset_hash, unset_best_header, parachain);
|
||||
import_block_as_new_best(unset_hash, unset_best_header, parachain).await;
|
||||
}
|
||||
state => tracing::debug!(
|
||||
target: "cumulus-consensus",
|
||||
@@ -293,7 +293,7 @@ fn handle_new_block_imported<Block, P>(
|
||||
}
|
||||
|
||||
/// Handle the new best parachain head as extracted from the new best relay chain.
|
||||
fn handle_new_best_parachain_head<Block, P>(
|
||||
async fn handle_new_best_parachain_head<Block, P>(
|
||||
head: Vec<u8>,
|
||||
parachain: &P,
|
||||
unset_best_header: &mut Option<Block::Header>,
|
||||
@@ -328,7 +328,7 @@ fn handle_new_best_parachain_head<Block, P>(
|
||||
Ok(BlockStatus::InChainWithState) => {
|
||||
unset_best_header.take();
|
||||
|
||||
import_block_as_new_best(hash, parachain_head, parachain);
|
||||
import_block_as_new_best(hash, parachain_head, parachain).await;
|
||||
}
|
||||
Ok(BlockStatus::InChainPruned) => {
|
||||
tracing::error!(
|
||||
@@ -359,11 +359,8 @@ fn handle_new_best_parachain_head<Block, P>(
|
||||
}
|
||||
}
|
||||
|
||||
fn import_block_as_new_best<Block, P>(
|
||||
hash: Block::Hash,
|
||||
header: Block::Header,
|
||||
parachain: &P,
|
||||
) where
|
||||
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
|
||||
where
|
||||
Block: BlockT,
|
||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||
for<'a> &'a P: BlockImport<Block>,
|
||||
@@ -373,7 +370,10 @@ fn import_block_as_new_best<Block, P>(
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
|
||||
block_import_params.import_existing = true;
|
||||
|
||||
if let Err(err) = (&*parachain).import_block(block_import_params, Default::default()) {
|
||||
if let Err(err) = (&*parachain)
|
||||
.import_block(block_import_params, Default::default())
|
||||
.await
|
||||
{
|
||||
tracing::warn!(
|
||||
target: "cumulus-consensus",
|
||||
block_hash = ?hash,
|
||||
@@ -555,7 +555,9 @@ impl<B: BlockT> ParachainConsensus<B> for Box<dyn ParachainConsensus<B> + Send +
|
||||
relay_parent: PHash,
|
||||
validation_data: &PersistedValidationData,
|
||||
) -> Option<ParachainCandidate<B>> {
|
||||
(*self).produce_candidate(parent, relay_parent, validation_data).await
|
||||
(*self)
|
||||
.produce_candidate(parent, relay_parent, validation_data)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,9 +655,7 @@ mod tests {
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(false));
|
||||
block_import_params.body = Some(body);
|
||||
|
||||
client
|
||||
.import_block(block_import_params, Default::default())
|
||||
.unwrap();
|
||||
block_on(client.import_block(block_import_params, Default::default())).unwrap();
|
||||
assert_eq!(0, client.chain_info().best_number);
|
||||
|
||||
block
|
||||
@@ -865,6 +865,7 @@ mod tests {
|
||||
// Now import the unkown block to make it "known"
|
||||
client
|
||||
.import_block(block_import_params, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
|
||||
@@ -38,13 +38,14 @@ struct Verifier<Client, Block> {
|
||||
_marker: PhantomData<Block>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Client, Block> VerifierT<Block> for Verifier<Client, Block>
|
||||
where
|
||||
Block: BlockT,
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
|
||||
{
|
||||
fn verify(
|
||||
async fn verify(
|
||||
&mut self,
|
||||
origin: BlockOrigin,
|
||||
header: Block::Header,
|
||||
|
||||
@@ -62,7 +62,7 @@ pub struct RelayChainConsensus<B, PF, BI, RClient, RBackend> {
|
||||
_phantom: PhantomData<B>,
|
||||
proposer_factory: Arc<Mutex<PF>>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
block_import: Arc<Mutex<BI>>,
|
||||
block_import: Arc<futures::lock::Mutex<BI>>,
|
||||
relay_chain_client: Arc<RClient>,
|
||||
relay_chain_backend: Arc<RBackend>,
|
||||
}
|
||||
@@ -101,7 +101,7 @@ where
|
||||
para_id,
|
||||
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
||||
inherent_data_providers,
|
||||
block_import: Arc::new(Mutex::new(block_import)),
|
||||
block_import: Arc::new(futures::lock::Mutex::new(block_import)),
|
||||
relay_chain_backend: polkadot_backend,
|
||||
relay_chain_client: polkadot_client,
|
||||
_phantom: PhantomData,
|
||||
@@ -212,7 +212,9 @@ where
|
||||
if let Err(err) = self
|
||||
.block_import
|
||||
.lock()
|
||||
.await
|
||||
.import_block(block_import_params, Default::default())
|
||||
.await
|
||||
{
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -321,6 +321,7 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
|
||||
|
||||
client
|
||||
.import(BlockOrigin::Own, block)
|
||||
.await
|
||||
.expect("Imports the block");
|
||||
|
||||
assert!(matches!(
|
||||
@@ -386,7 +387,11 @@ sp_api::mock_impl_runtime_apis! {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn persisted_validation_data(&self, _: ParaId, _: OccupiedCoreAssumption) -> Option<PersistedValidationData<BlockNumber>> {
|
||||
fn persisted_validation_data(
|
||||
&self,
|
||||
_: ParaId,
|
||||
_: OccupiedCoreAssumption,
|
||||
) -> Option<PersistedValidationData<PHash, BlockNumber>> {
|
||||
Some(PersistedValidationData {
|
||||
parent_head: HeadData(default_header().encode()),
|
||||
..Default::default()
|
||||
@@ -430,5 +435,9 @@ sp_api::mock_impl_runtime_apis! {
|
||||
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
|
||||
BTreeMap::new()
|
||||
}
|
||||
|
||||
fn validation_code_by_hash(_: PHash) -> Option<ValidationCode> {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,9 +165,7 @@ mod tests {
|
||||
let (mut client, backend, block) = build_client_backend_and_block();
|
||||
let hash = block.hash();
|
||||
|
||||
client
|
||||
.import(BlockOrigin::Own, block)
|
||||
.expect("Imports the block");
|
||||
block_on(client.import(BlockOrigin::Own, block)).expect("Imports the block");
|
||||
|
||||
let wait = WaitOnRelayChainBlock::new(backend, client);
|
||||
|
||||
@@ -195,6 +193,7 @@ mod tests {
|
||||
// Import the block that should fire the notification
|
||||
client
|
||||
.import(BlockOrigin::Own, block)
|
||||
.await
|
||||
.expect("Imports the block");
|
||||
|
||||
// Now it should have received the notification and report that the block was imported
|
||||
@@ -246,6 +245,7 @@ mod tests {
|
||||
// Import the block that should fire the notification
|
||||
client
|
||||
.import(BlockOrigin::Own, block2)
|
||||
.await
|
||||
.expect("Imports the second block");
|
||||
|
||||
// The import notification of the second block should not make this one finish
|
||||
@@ -255,6 +255,7 @@ mod tests {
|
||||
|
||||
client
|
||||
.import(BlockOrigin::Own, block)
|
||||
.await
|
||||
.expect("Imports the first block");
|
||||
|
||||
// Now it should be ready
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use cumulus_client_consensus_common::ParachainConsensus;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use futures::FutureExt;
|
||||
use polkadot_primitives::v1::{Block as PBlock, CollatorId, CollatorPair};
|
||||
use polkadot_primitives::v1::{Block as PBlock, CollatorPair};
|
||||
use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeApiCollection};
|
||||
use sc_client_api::{
|
||||
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
|
||||
@@ -233,7 +233,7 @@ pub fn prepare_node_config(mut parachain_config: Configuration) -> Configuration
|
||||
#[sc_tracing::logging::prefix_logs_with("Relaychain")]
|
||||
pub fn build_polkadot_full_node(
|
||||
config: Configuration,
|
||||
collator_id: CollatorId,
|
||||
collator_pair: CollatorPair,
|
||||
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
||||
) -> Result<RFullNode<PClient>, polkadot_service::Error> {
|
||||
let is_light = matches!(config.role, Role::Light);
|
||||
@@ -244,7 +244,7 @@ pub fn build_polkadot_full_node(
|
||||
} else {
|
||||
polkadot_service::build_full(
|
||||
config,
|
||||
polkadot_service::IsCollator::Yes(collator_id),
|
||||
polkadot_service::IsCollator::Yes(collator_pair),
|
||||
None,
|
||||
None,
|
||||
telemetry_worker_handle,
|
||||
|
||||
Reference in New Issue
Block a user