mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Companion for removal of execution strategies (#7443)
* Companion for removal of execution strategies https://github.com/paritytech/substrate/pull/14387 * Fix some tests * 🤦 * Adapt to latest changes * Start supporting the offchain transaction pool * Fix tests * FMT * Remove patches * Update Substrate * update lockfile for {"substrate"} * Fix parachain upgrade smoke test * Fix test * Rewrite all tests to use `MockSubstemClient` --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -52,6 +52,7 @@ use {
|
||||
peer_set::PeerSetProtocolNames, request_response::ReqProtocolNames,
|
||||
},
|
||||
sc_client_api::BlockBackend,
|
||||
sc_transaction_pool_api::OffchainTransactionPoolFactory,
|
||||
sp_core::traits::SpawnNamed,
|
||||
sp_trie::PrefixedMemoryDB,
|
||||
};
|
||||
@@ -87,7 +88,7 @@ pub use consensus_common::{Proposal, SelectChain};
|
||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||
use mmr_gadget::MmrGadget;
|
||||
pub use polkadot_primitives::{Block, BlockId, BlockNumber, CollatorPair, Hash, Id as ParaId};
|
||||
pub use sc_client_api::{Backend, CallExecutor, ExecutionStrategy};
|
||||
pub use sc_client_api::{Backend, CallExecutor};
|
||||
pub use sc_consensus::{BlockImport, LongestChain};
|
||||
pub use sc_executor::NativeExecutionDispatch;
|
||||
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||
@@ -513,13 +514,13 @@ where
|
||||
babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?;
|
||||
|
||||
let slot_duration = babe_link.config().slot_duration();
|
||||
let (import_queue, babe_worker_handle) = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
move |_, ()| async move {
|
||||
let (import_queue, babe_worker_handle) = babe::import_queue(babe::ImportQueueParams {
|
||||
link: babe_link.clone(),
|
||||
block_import: block_import.clone(),
|
||||
justification_import: Some(Box::new(justification_import)),
|
||||
client: client.clone(),
|
||||
select_chain: select_chain.clone(),
|
||||
create_inherent_data_providers: move |_, ()| async move {
|
||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
@@ -530,10 +531,11 @@ where
|
||||
|
||||
Ok((slot, timestamp))
|
||||
},
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
)?;
|
||||
spawner: &task_manager.spawn_essential_handle(),
|
||||
registry: config.prometheus_registry(),
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
|
||||
})?;
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
@@ -579,9 +581,10 @@ where
|
||||
beefy_best_block_stream: beefy_rpc_links.from_voter_best_beefy_stream.clone(),
|
||||
subscription_executor,
|
||||
},
|
||||
backend: backend.clone(),
|
||||
};
|
||||
|
||||
polkadot_rpc::create_full(deps, backend.clone()).map_err(Into::into)
|
||||
polkadot_rpc::create_full(deps).map_err(Into::into)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -824,22 +827,25 @@ where
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
let offchain_workers = Arc::new(sc_offchain::OffchainWorkers::new_with_options(
|
||||
client.clone(),
|
||||
sc_offchain::OffchainWorkerOptions { enable_http_requests: false },
|
||||
));
|
||||
use futures::FutureExt;
|
||||
|
||||
// Start the offchain workers to have
|
||||
task_manager.spawn_handle().spawn(
|
||||
"offchain-notifications",
|
||||
None,
|
||||
sc_offchain::notification_future(
|
||||
config.role.is_authority(),
|
||||
client.clone(),
|
||||
offchain_workers,
|
||||
task_manager.spawn_handle().clone(),
|
||||
network.clone(),
|
||||
),
|
||||
"offchain-workers-runner",
|
||||
"offchain-work",
|
||||
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
|
||||
runtime_api_provider: client.clone(),
|
||||
keystore: Some(keystore_container.keystore()),
|
||||
offchain_db: backend.offchain_storage(),
|
||||
transaction_pool: Some(OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
)),
|
||||
network_provider: network.clone(),
|
||||
is_validator: role.is_authority(),
|
||||
enable_http_requests: false,
|
||||
custom_extensions: move |_| vec![],
|
||||
})
|
||||
.run(client.clone(), task_manager.spawn_handle())
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -981,6 +987,9 @@ where
|
||||
overseer_message_channel_capacity_override,
|
||||
req_protocol_names,
|
||||
peerset_protocol_names,
|
||||
offchain_transaction_pool_factory: OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
),
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
@@ -1026,7 +1035,7 @@ where
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
transaction_pool.clone(),
|
||||
prometheus_registry.as_ref(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
);
|
||||
@@ -1186,6 +1195,7 @@ where
|
||||
prometheus_registry: prometheus_registry.clone(),
|
||||
shared_voter_state,
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
|
||||
};
|
||||
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{AuthorityDiscoveryApi, Block, Error, Hash, IsCollator, Registry};
|
||||
use polkadot_node_subsystem_types::DefaultSubsystemClient;
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
use lru::LruCache;
|
||||
@@ -125,6 +127,8 @@ where
|
||||
pub req_protocol_names: ReqProtocolNames,
|
||||
/// [`PeerSet`] protocol names to protocols mapping.
|
||||
pub peerset_protocol_names: PeerSetProtocolNames,
|
||||
/// The offchain transaction pool factory.
|
||||
pub offchain_transaction_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
}
|
||||
|
||||
/// Obtain a prepared `OverseerBuilder`, that is initialized
|
||||
@@ -155,11 +159,12 @@ pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
||||
overseer_message_channel_capacity_override,
|
||||
req_protocol_names,
|
||||
peerset_protocol_names,
|
||||
offchain_transaction_pool_factory,
|
||||
}: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<
|
||||
InitializedOverseerBuilder<
|
||||
SpawnGlue<Spawner>,
|
||||
Arc<RuntimeClient>,
|
||||
Arc<DefaultSubsystemClient<RuntimeClient>>,
|
||||
CandidateValidationSubsystem,
|
||||
PvfCheckerSubsystem,
|
||||
CandidateBackingSubsystem,
|
||||
@@ -169,7 +174,7 @@ pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
||||
BitfieldSigningSubsystem,
|
||||
BitfieldDistributionSubsystem,
|
||||
ProvisionerSubsystem,
|
||||
RuntimeApiSubsystem<RuntimeClient>,
|
||||
RuntimeApiSubsystem<DefaultSubsystemClient<RuntimeClient>>,
|
||||
AvailabilityStoreSubsystem,
|
||||
NetworkBridgeRxSubsystem<
|
||||
Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
@@ -204,6 +209,11 @@ where
|
||||
|
||||
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
|
||||
|
||||
let runtime_api_client = Arc::new(DefaultSubsystemClient::new(
|
||||
runtime_client.clone(),
|
||||
offchain_transaction_pool_factory,
|
||||
));
|
||||
|
||||
let builder = Overseer::builder()
|
||||
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
|
||||
network_service.clone(),
|
||||
@@ -273,7 +283,7 @@ where
|
||||
})
|
||||
.provisioner(ProvisionerSubsystem::new(Metrics::register(registry)?))
|
||||
.runtime_api(RuntimeApiSubsystem::new(
|
||||
runtime_client.clone(),
|
||||
runtime_api_client.clone(),
|
||||
Metrics::register(registry)?,
|
||||
spawner.clone(),
|
||||
))
|
||||
@@ -312,7 +322,7 @@ where
|
||||
.activation_external_listeners(Default::default())
|
||||
.span_per_active_leaf(Default::default())
|
||||
.active_leaves(Default::default())
|
||||
.supports_parachains(runtime_client)
|
||||
.supports_parachains(runtime_api_client)
|
||||
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
|
||||
.metrics(metrics)
|
||||
.spawner(spawner);
|
||||
@@ -334,7 +344,10 @@ pub trait OverseerGen {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
@@ -358,7 +371,10 @@ impl OverseerGen for RealOverseerGen {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
|
||||
Reference in New Issue
Block a user