mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
Removal of execution strategies (#14387)
* Start * More work! * Moar * More changes * More fixes * More worrk * More fixes * More fixes to make it compile * Adds `NoOffchainStorage` * Pass the extensions * Small basti making small progress * Fix merge errors and remove `ExecutionContext` * Move registration of `ReadRuntimeVersionExt` to `ExecutionExtension` Instead of registering `ReadRuntimeVersionExt` in `sp-state-machine` it is moved to `ExecutionExtension` which provides the default extensions. * Fix compilation * Register the global extensions inside runtime api instance * Fixes * Fix `generate_initial_session_keys` by passing the keystore extension * Fix the grandpa tests * Fix more tests * Fix more tests * Don't set any heap pages if there isn't an override * Fix small fallout * FMT * Fix tests * More tests * Offchain worker custom extensions * More fixes * Make offchain tx pool creation reusable Introduces an `OffchainTransactionPoolFactory` for creating offchain transactions pools that can be registered in the runtime externalities context. This factory will be required for a later pr to make the creation of offchain transaction pools easier. * Fixes * Fixes * Set offchain transaction pool in BABE before using it in the runtime * Add the `offchain_tx_pool` to Grandpa as well * Fix the nodes * Print some error when using the old warnings * Fix merge issues * Fix compilation * Rename `babe_link` * Rename to `offchain_tx_pool_factory` * Cleanup * FMT * Fix benchmark name * Fix `try-runtime` * Remove `--execution` CLI args * Make clippy happy * Forward bls functions * Fix docs * Update UI tests * Update client/api/src/execution_extensions.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Koute <koute@users.noreply.github.com> * Update client/cli/src/params/import_params.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Update client/api/src/execution_extensions.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Pass the offchain storage to the MMR RPC * Update client/api/src/execution_extensions.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Review comments * Fixes --------- Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Koute <koute@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
@@ -106,6 +106,7 @@ use sc_consensus_slots::{
|
||||
SlotInfo, StorageChanges,
|
||||
};
|
||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_api::{ApiExt, ProvideRuntimeApi};
|
||||
use sp_application_crypto::AppCrypto;
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
@@ -116,7 +117,7 @@ use sp_blockchain::{
|
||||
use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain};
|
||||
use sp_consensus_babe::inherents::BabeInherentData;
|
||||
use sp_consensus_slots::Slot;
|
||||
use sp_core::ExecutionContext;
|
||||
use sp_core::traits::SpawnEssentialNamed;
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
|
||||
use sp_keystore::KeystorePtr;
|
||||
use sp_runtime::{
|
||||
@@ -992,6 +993,7 @@ pub struct BabeVerifier<Block: BlockT, Client, SelectChain, CIDP> {
|
||||
config: BabeConfiguration,
|
||||
epoch_changes: SharedEpochChanges<Block, Epoch>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
}
|
||||
|
||||
impl<Block, Client, SelectChain, CIDP> BabeVerifier<Block, Client, SelectChain, CIDP>
|
||||
@@ -1008,12 +1010,11 @@ where
|
||||
at_hash: Block::Hash,
|
||||
inherent_data: InherentData,
|
||||
create_inherent_data_providers: CIDP::InherentDataProviders,
|
||||
execution_context: ExecutionContext,
|
||||
) -> Result<(), Error<Block>> {
|
||||
let inherent_res = self
|
||||
.client
|
||||
.runtime_api()
|
||||
.check_inherents_with_context(at_hash, execution_context, block, inherent_data)
|
||||
.check_inherents(at_hash, block, inherent_data)
|
||||
.map_err(Error::RuntimeApi)?;
|
||||
|
||||
if !inherent_res.ok() {
|
||||
@@ -1098,8 +1099,13 @@ where
|
||||
};
|
||||
|
||||
// submit equivocation report at best block.
|
||||
self.client
|
||||
.runtime_api()
|
||||
let mut runtime_api = self.client.runtime_api();
|
||||
|
||||
// Register the offchain tx pool to be able to use it from the runtime.
|
||||
runtime_api
|
||||
.register_extension(self.offchain_tx_pool_factory.offchain_transaction_pool(best_hash));
|
||||
|
||||
runtime_api
|
||||
.submit_report_equivocation_unsigned_extrinsic(
|
||||
best_hash,
|
||||
equivocation_proof,
|
||||
@@ -1250,7 +1256,6 @@ where
|
||||
parent_hash,
|
||||
inherent_data,
|
||||
create_inherent_data_providers,
|
||||
block.origin.into(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@@ -1768,6 +1773,38 @@ where
|
||||
Ok((import, link))
|
||||
}
|
||||
|
||||
/// Parameters passed to [`import_queue`].
|
||||
pub struct ImportQueueParams<'a, Block: BlockT, BI, Client, CIDP, SelectChain, Spawn> {
|
||||
/// The BABE link that is created by [`block_import`].
|
||||
pub link: BabeLink<Block>,
|
||||
/// The block import that should be wrapped.
|
||||
pub block_import: BI,
|
||||
/// Optional justification import.
|
||||
pub justification_import: Option<BoxJustificationImport<Block>>,
|
||||
/// The client to interact with the internals of the node.
|
||||
pub client: Arc<Client>,
|
||||
/// A [`SelectChain`] implementation.
|
||||
///
|
||||
/// Used to determine the best block that should be used as basis when sending an equivocation
|
||||
/// report.
|
||||
pub select_chain: SelectChain,
|
||||
/// Used to crate the inherent data providers.
|
||||
///
|
||||
/// These inherent data providers are then used to create the inherent data that is
|
||||
/// passed to the `check_inherents` runtime call.
|
||||
pub create_inherent_data_providers: CIDP,
|
||||
/// Spawner for spawning futures.
|
||||
pub spawner: &'a Spawn,
|
||||
/// Registry for prometheus metrics.
|
||||
pub registry: Option<&'a Registry>,
|
||||
/// Optional telemetry handle to report telemetry events.
|
||||
pub telemetry: Option<TelemetryHandle>,
|
||||
/// The offchain transaction pool factory.
|
||||
///
|
||||
/// Will be used when sending equivocation reports.
|
||||
pub offchain_tx_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
}
|
||||
|
||||
/// Start an import queue for the BABE consensus algorithm.
|
||||
///
|
||||
/// This method returns the import queue, some data that needs to be passed to the block authoring
|
||||
@@ -1777,19 +1814,22 @@ where
|
||||
///
|
||||
/// The block import object provided must be the `BabeBlockImport` or a wrapper
|
||||
/// of it, otherwise crucial import logic will be omitted.
|
||||
pub fn import_queue<Block: BlockT, Client, SelectChain, Inner, CIDP>(
|
||||
babe_link: BabeLink<Block>,
|
||||
block_import: Inner,
|
||||
justification_import: Option<BoxJustificationImport<Block>>,
|
||||
client: Arc<Client>,
|
||||
select_chain: SelectChain,
|
||||
create_inherent_data_providers: CIDP,
|
||||
spawner: &impl sp_core::traits::SpawnEssentialNamed,
|
||||
registry: Option<&Registry>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
pub fn import_queue<Block: BlockT, Client, SelectChain, BI, CIDP, Spawn>(
|
||||
ImportQueueParams {
|
||||
link: babe_link,
|
||||
block_import,
|
||||
justification_import,
|
||||
client,
|
||||
select_chain,
|
||||
create_inherent_data_providers,
|
||||
spawner,
|
||||
registry,
|
||||
telemetry,
|
||||
offchain_tx_pool_factory,
|
||||
}: ImportQueueParams<'_, Block, BI, Client, CIDP, SelectChain, Spawn>,
|
||||
) -> ClientResult<(DefaultImportQueue<Block, Client>, BabeWorkerHandle<Block>)>
|
||||
where
|
||||
Inner: BlockImport<
|
||||
BI: BlockImport<
|
||||
Block,
|
||||
Error = ConsensusError,
|
||||
Transaction = sp_api::TransactionFor<Client, Block>,
|
||||
@@ -1807,6 +1847,7 @@ where
|
||||
SelectChain: sp_consensus::SelectChain<Block> + 'static,
|
||||
CIDP: CreateInherentDataProviders<Block, ()> + Send + Sync + 'static,
|
||||
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
|
||||
Spawn: SpawnEssentialNamed,
|
||||
{
|
||||
const HANDLE_BUFFER_SIZE: usize = 1024;
|
||||
|
||||
@@ -1817,6 +1858,7 @@ where
|
||||
epoch_changes: babe_link.epoch_changes.clone(),
|
||||
telemetry,
|
||||
client: client.clone(),
|
||||
offchain_tx_pool_factory,
|
||||
};
|
||||
|
||||
let (worker_tx, worker_rx) = channel(HANDLE_BUFFER_SIZE);
|
||||
|
||||
@@ -26,6 +26,7 @@ use sc_consensus::{BoxBlockImport, BoxJustificationImport};
|
||||
use sc_consensus_epochs::{EpochIdentifier, EpochIdentifierPosition};
|
||||
use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging;
|
||||
use sc_network_test::{Block as TestBlock, *};
|
||||
use sc_transaction_pool_api::RejectAllTxPool;
|
||||
use sp_application_crypto::key_types::BABE;
|
||||
use sp_consensus::{DisableProofRecording, NoNetwork as DummyOracle, Proposal};
|
||||
use sp_consensus_babe::{
|
||||
@@ -283,6 +284,9 @@ impl TestNetFactory for BabeTestNet {
|
||||
config: data.link.config.clone(),
|
||||
epoch_changes: data.link.epoch_changes.clone(),
|
||||
telemetry: None,
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(
|
||||
RejectAllTxPool::default(),
|
||||
),
|
||||
},
|
||||
mutator: MUTATOR.with(|m| m.borrow().clone()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user