Skip to content

Commit

Permalink
Merge branch 'master' into jeremy-iforgor-config
Browse files Browse the repository at this point in the history
  • Loading branch information
nanocryk authored Dec 9, 2024
2 parents 093d125 + 61c9874 commit 37e26e5
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 459 deletions.
735 changes: 370 additions & 365 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions client/consensus/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ impl CollatorLookaheadTestBuilder {
impl Future<Output = ()> + Send + 'static,
oneshot::Receiver<()>,
Arc<TestClient>,
Arc<sc_transaction_pool::FullPool<Block, TestClient>>,
Arc<sc_transaction_pool::TransactionPoolHandle<Block, TestClient>>,
CancellationToken,
) {
// Creation of keystore
Expand Down Expand Up @@ -917,12 +917,8 @@ impl CollatorLookaheadTestBuilder {

// Create the txpool for orchestrator, which should serve to test parathread buy core injection
let spawner = sp_core::testing::TaskExecutor::new();
let orchestrator_tx_pool = sc_transaction_pool::BasicPool::new_full(
Default::default(),
true.into(),
None,
spawner.clone(),
client.clone(),
let orchestrator_tx_pool = Arc::new(
sc_transaction_pool::Builder::new(spawner.clone(), client.clone(), true.into()).build(),
);

// Create the mocked runtime api, which will return whether we have a core scheduled
Expand Down
28 changes: 15 additions & 13 deletions client/node-common/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use {

#[allow(deprecated)]
use sc_executor::NativeElseWasmExecutor;
use sc_transaction_pool_api::TransactionPool;
use sp_api::StorageProof;
use sp_core::traits::SpawnNamed;

Expand Down Expand Up @@ -115,6 +116,7 @@ pub trait NodeBuilderConfig {
ExecutorOf<Self>:
Clone + CodeExecutor + RuntimeVersionOf + TanssiExecutorExt + Sync + Send + 'static,
RuntimeApiOf<Self>: MinimalRuntimeApi<BlockOf<Self>, ClientOf<Self>>,
BlockHashOf<Self>: Unpin,
{
NodeBuilder::<Self>::new(parachain_config, hwbench)
}
Expand Down Expand Up @@ -171,7 +173,7 @@ pub struct NodeBuilder<
pub backend: Arc<BackendOf<T>>,
pub task_manager: TaskManager,
pub keystore_container: KeystoreContainer,
pub transaction_pool: Arc<sc_transaction_pool::FullPool<BlockOf<T>, ClientOf<T>>>,
pub transaction_pool: Arc<sc_transaction_pool::TransactionPoolHandle<BlockOf<T>, ClientOf<T>>>,
pub telemetry: Option<Telemetry>,
pub telemetry_worker_handle: Option<TelemetryWorkerHandle>,

Expand Down Expand Up @@ -226,6 +228,7 @@ where
ExecutorOf<T>:
Clone + CodeExecutor + RuntimeVersionOf + TanssiExecutorExt + Sync + Send + 'static,
RuntimeApiOf<T>: MinimalRuntimeApi<BlockOf<T>, ClientOf<T>>,
BlockHashOf<T>: Unpin,
{
/// Create a new `NodeBuilder` which prepare objects required to launch a
/// node. However it only starts telemetry, and doesn't provide any
Expand Down Expand Up @@ -291,18 +294,19 @@ where
telemetry
});

let transaction_pool = sc_transaction_pool::BasicPool::new_full(
parachain_config.transaction_pool.clone(),
parachain_config.role.is_authority().into(),
parachain_config.prometheus_registry(),
let transaction_pool = sc_transaction_pool::Builder::new(
task_manager.spawn_essential_handle(),
client.clone(),
);
parachain_config.role.is_authority().into(),
)
.with_options(parachain_config.transaction_pool.clone())
.with_prometheus(parachain_config.prometheus_registry())
.build();

Ok(Self {
client,
backend,
transaction_pool,
transaction_pool: transaction_pool.into(),
telemetry,
telemetry_worker_handle,
task_manager,
Expand Down Expand Up @@ -673,16 +677,14 @@ where
Sealing::Instant => {
Box::new(
// This bit cribbed from the implementation of instant seal.
self.transaction_pool
.pool()
.validated_pool()
.import_notification_stream()
.map(|_| EngineCommand::SealNewBlock {
self.transaction_pool.import_notification_stream().map(|_| {
EngineCommand::SealNewBlock {
create_empty: false,
finalize: false,
parent_hash: None,
sender: None,
}),
}
}),
)
}
Sealing::Manual => {
Expand Down
2 changes: 1 addition & 1 deletion client/service-container-chain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub mod generate_rpc_builder {

pub type SyncingService = sc_network_sync::SyncingService<Block>;
pub type TransactionPool<RuntimeApi> =
sc_transaction_pool::FullPool<Block, ContainerChainClient<RuntimeApi>>;
sc_transaction_pool::TransactionPoolHandle<Block, ContainerChainClient<RuntimeApi>>;
pub type CommandSink =
futures::channel::mpsc::Sender<sc_consensus_manual_seal::EngineCommand<Hash>>;
pub type XcmSenders = (flume::Sender<Vec<u8>>, flume::Sender<(ParaId, Vec<u8>)>);
Expand Down
13 changes: 9 additions & 4 deletions client/service-container-chain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use {
},
sc_telemetry::TelemetryHandle,
sc_tracing::tracing::Instrument,
sc_transaction_pool::FullPool,
sc_transaction_pool::TransactionPoolHandle,
sp_api::ProvideRuntimeApi,
sp_consensus::EnableProofRecording,
sp_consensus_aura::SlotDuration,
Expand Down Expand Up @@ -147,8 +147,11 @@ pub type ParachainBackend = TFullBackend<Block>;
pub type DevParachainBlockImport = OrchestratorParachainBlockImport<Arc<ParachainClient>>;
pub type ParachainBlockImport =
TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
pub type ParachainProposerFactory =
ProposerFactory<FullPool<Block, ParachainClient>, ParachainClient, EnableProofRecording>;
pub type ParachainProposerFactory = ProposerFactory<
TransactionPoolHandle<Block, ParachainClient>,
ParachainClient,
EnableProofRecording,
>;

// Container chains types
type ContainerChainExecutor = WasmExecutor<ParachainHostFunctions>;
Expand Down Expand Up @@ -334,7 +337,9 @@ fn start_consensus_container<RuntimeApi: MinimalContainerRuntimeApi>(
spawner: SpawnTaskHandle,
relay_chain_interface: Arc<dyn RelayChainInterface>,
orchestrator_chain_interface: Arc<dyn OrchestratorChainInterface>,
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ContainerChainClient<RuntimeApi>>>,
transaction_pool: Arc<
sc_transaction_pool::TransactionPoolHandle<Block, ContainerChainClient<RuntimeApi>>,
>,
sync_oracle: Arc<SyncingService<Block>>,
keystore: KeystorePtr,
force_authoring: bool,
Expand Down
4 changes: 2 additions & 2 deletions client/service-container-chain/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use {
sc_cli::{Database, SyncMode},
sc_network::config::MultiaddrWithPeerId,
sc_service::SpawnTaskHandle,
sc_transaction_pool::FullPool,
sc_transaction_pool::TransactionPoolHandle,
sp_api::ProvideRuntimeApi,
sp_core::H256,
sp_keystore::KeystorePtr,
Expand Down Expand Up @@ -135,7 +135,7 @@ pub struct ContainerChainSpawnParams<
#[derive(Clone)]
pub struct CollationParams {
pub collator_key: CollatorPair,
pub orchestrator_tx_pool: Option<Arc<FullPool<OpaqueBlock, ParachainClient>>>,
pub orchestrator_tx_pool: Option<Arc<TransactionPoolHandle<OpaqueBlock, ParachainClient>>>,
pub orchestrator_client: Option<Arc<ParachainClient>>,
pub orchestrator_para_id: ParaId,
/// If this is `false`, then `orchestrator_tx_pool` and `orchestrator_client` must be `Some`.
Expand Down
20 changes: 17 additions & 3 deletions container-chains/nodes/frontier/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
pub use sc_rpc::SubscriptionTaskExecutor;

use {
container_chain_template_frontier_runtime::{opaque::Block, AccountId, Hash, Index},
container_chain_template_frontier_runtime::{
opaque::Block, AccountId, Hash, Index, RuntimeApi,
},
core::marker::PhantomData,
cumulus_client_parachain_inherent::ParachainInherentData,
cumulus_client_service::ParachainHostFunctions,
cumulus_primitives_core::{ParaId, PersistedValidationData},
cumulus_test_relay_sproof_builder::RelayStateSproofBuilder,
fc_rpc::{EthTask, TxPool},
Expand All @@ -43,8 +46,9 @@ use {
AuxStore, BlockOf, StorageProvider,
},
sc_consensus_manual_seal::rpc::{EngineCommand, ManualSeal, ManualSealApiServer},
sc_executor::WasmExecutor,
sc_network_sync::SyncingService,
sc_service::TaskManager,
sc_service::{TFullClient, TaskManager},
sc_transaction_pool::{ChainApi, Pool},
sc_transaction_pool_api::TransactionPool,
sp_api::{CallApiAt, ProvideRuntimeApi},
Expand All @@ -63,6 +67,12 @@ use {
tc_service_container_chain::service::{ContainerChainClient, MinimalContainerRuntimeApi},
};

type ParachainExecutor = WasmExecutor<ParachainHostFunctions>;
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;

type FullPool<Client> =
sc_transaction_pool::BasicPool<sc_transaction_pool::FullChainApi<Client, Block>, Block>;

pub struct DefaultEthConfig<C, BE>(std::marker::PhantomData<(C, BE)>);

impl<C, BE> fc_rpc::EthConfig<Block, C> for DefaultEthConfig<C, BE>
Expand Down Expand Up @@ -543,6 +553,10 @@ const _: () = {
));

Ok(Box::new(move |subscription_task_executor| {
let graph_pool = transaction_pool.0
.as_any()
.downcast_ref::<FullPool<ParachainClient>>()
.expect("Frontier container chain template supports only single state transaction pool! Use --pool-type=single-state");
let deps = crate::rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
Expand All @@ -551,7 +565,7 @@ const _: () = {
fc_db::Backend::KeyValue(b) => b.clone(),
fc_db::Backend::Sql(b) => b.clone(),
},
graph: transaction_pool.pool().clone(),
graph: graph_pool.pool().clone(),
pool: transaction_pool.clone(),
max_past_logs,
fee_history_limit,
Expand Down
15 changes: 13 additions & 2 deletions container-chains/nodes/frontier/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ async fn start_node_impl(
let frontier_backend = frontier_backend.clone();

Box::new(move |subscription_task_executor| {
let graph_pool = pool.0.as_any()
.downcast_ref::<sc_transaction_pool::BasicPool<
sc_transaction_pool::FullChainApi<ParachainClient, Block>
, Block
>>().expect("Frontier container chain template supports only single state transaction pool! Use --pool-type=single-state");

let deps = crate::rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
Expand All @@ -254,7 +260,7 @@ async fn start_node_impl(
fc_db::Backend::KeyValue(b) => b.clone(),
fc_db::Backend::Sql(b) => b.clone(),
},
graph: pool.pool().clone(),
graph: graph_pool.pool().clone(),
pool: pool.clone(),
max_past_logs,
fee_history_limit,
Expand Down Expand Up @@ -497,6 +503,11 @@ pub async fn start_dev_node(
let block_data_cache = block_data_cache;

Box::new(move |subscription_task_executor| {
let graph_pool= pool.0.as_any()
.downcast_ref::<sc_transaction_pool::BasicPool<
sc_transaction_pool::FullChainApi<ParachainClient, Block>
, Block
>>().expect("Frontier container chain template supports only single state transaction pool! Use --pool-type=single-state");
let deps = crate::rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
Expand All @@ -505,7 +516,7 @@ pub async fn start_dev_node(
fc_db::Backend::KeyValue(b) => b.clone(),
fc_db::Backend::Sql(b) => b.clone(),
},
graph: pool.pool().clone(),
graph: graph_pool.pool().clone(),
pool: pool.clone(),
max_past_logs,
fee_history_limit,
Expand Down
4 changes: 2 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use {
sc_network_sync::SyncingService,
sc_service::{Configuration, KeystoreContainer, SpawnTaskHandle, TFullBackend, TaskManager},
sc_telemetry::TelemetryHandle,
sc_transaction_pool::FullPool,
sc_transaction_pool::TransactionPoolHandle,
sp_api::StorageProof,
sp_consensus::SyncOracle,
sp_consensus_slots::Slot,
Expand Down Expand Up @@ -516,7 +516,7 @@ fn start_consensus_orchestrator(
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
proposer_factory: ParachainProposerFactory,
orchestrator_tx_pool: Arc<FullPool<Block, ParachainClient>>,
orchestrator_tx_pool: Arc<TransactionPoolHandle<Block, ParachainClient>>,
) -> (CancellationToken, futures::channel::oneshot::Receiver<()>) {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)
.expect("start_consensus_orchestrator: slot duration should exist");
Expand Down
25 changes: 12 additions & 13 deletions solo-chains/node/tanssi-relay-service/src/dev_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,16 +648,14 @@ fn new_full<
Sealing::Instant => {
Box::new(
// This bit cribbed from the implementation of instant seal.
transaction_pool
.pool()
.validated_pool()
.import_notification_stream()
.map(|_| EngineCommand::SealNewBlock {
transaction_pool.import_notification_stream().map(|_| {
EngineCommand::SealNewBlock {
create_empty: false,
finalize: false,
parent_hash: None,
sender: None,
}),
}
}),
)
}
Sealing::Manual => {
Expand Down Expand Up @@ -814,7 +812,7 @@ fn new_partial<ChainSelection>(
FullBackend,
ChainSelection,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
sc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
(
BabeBlockImport<Block, FullClient, Arc<FullClient>>,
BabeLink<Block>,
Expand All @@ -827,13 +825,14 @@ fn new_partial<ChainSelection>(
where
ChainSelection: 'static + SelectChain<Block>,
{
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
let transaction_pool = sc_transaction_pool::Builder::new(
task_manager.spawn_essential_handle(),
client.clone(),
);
config.role.is_authority().into(),
)
.with_options(config.transaction_pool.clone())
.with_prometheus(config.prometheus_registry())
.build();

// Create babe block import queue; this is required to have correct epoch data
// available for manual seal to produce block
Expand All @@ -856,7 +855,7 @@ where
keystore_container,
select_chain,
import_queue,
transaction_pool,
transaction_pool: transaction_pool.into(),
other: (babe_block_import, babe_link, slot_duration, telemetry),
})
}
Expand Down
Loading

0 comments on commit 37e26e5

Please sign in to comment.