Skip to content

Commit

Permalink
WIP:
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuanyshbaev committed Oct 25, 2024
1 parent 3b904d3 commit 869dbb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions node/service/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use sc_network::NetworkService;
use sc_service::{config::Configuration, error::Error as ServiceError, TaskManager};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ConstructRuntimeApi;
use sp_api::CallApiAt;
use sp_runtime::OpaqueExtrinsic;
use sp_consensus_aura::sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};

Expand Down Expand Up @@ -57,8 +59,9 @@ pub trait RuntimeApiCollection:
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ CallApiAt<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
<Self as sp_api::CallApiAt<Block>>::StateBackend: sc_client_api::StateBackend<BlakeTwo256>,
{
}

Expand All @@ -73,11 +76,16 @@ where
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
+ sp_session::SessionKeys<Block>
+ CallApiAt<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>>,
<Self as sp_api::CallApiAt<Block>>::StateBackend: sc_client_api::StateBackend<BlakeTwo256>,
{
}

/// The minimum period of blocks on which justifications will be
/// imported and generated.
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;

/// Partially initialize serivice & deps.
pub fn new_partial<Runtime>(
config: &Configuration,
Expand All @@ -86,7 +94,7 @@ pub fn new_partial<Runtime>(
FullClient<Runtime>,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient<Runtime>>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient<Runtime>>,
(
impl Fn(
Expand Down Expand Up @@ -117,15 +125,16 @@ where
.transpose()?;

let heap_pages = config
.executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});

let executor = WasmExecutor::<HostFunctions>::builder()
.with_execution_method(config.wasm_method)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.with_execution_method(config.executor.wasm_method)
.with_max_runtime_instances(config.executor.max_runtime_instances)
.with_runtime_cache_size(config.executor.runtime_cache_size)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.build();
Expand Down Expand Up @@ -157,6 +166,7 @@ where

let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
client.clone(),
GRANDPA_JUSTIFICATION_PERIOD,
&(client.clone() as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
Expand Down
4 changes: 2 additions & 2 deletions node/service/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub trait RuntimeApiCollection:
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ sp_session::SessionKeys<Block>
where
sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
sc_client_api::StateBackendFor<ParachainBackend, Block>: sc_client_api::StateBackend<BlakeTwo256>,
{
}

Expand All @@ -84,7 +84,7 @@ where
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ sp_session::SessionKeys<Block>,
sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
sc_client_api::StateBackendFor<ParachainBackend, Block>: sc_client_api::StateBackend<BlakeTwo256>,
{
}

Expand Down

0 comments on commit 869dbb5

Please sign in to comment.