Skip to content

Commit

Permalink
Merge branch 'pg/fix-eth-fee-rpc' into pg/fix-rpc-dead-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Feb 7, 2025
2 parents 289e3fd + bfb37f2 commit 729ce37
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,6 @@ mod benches {
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm_bridge_hub_router, ToRococo]
[pallet_asset_conversion_ops, AssetConversionMigration]
[pallet_revive, Revive]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
Expand Down
3 changes: 3 additions & 0 deletions cumulus/polkadot-omni-node/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ sc-consensus = { workspace = true, default-features = true }
sc-consensus-manual-seal = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sc-runtime-utilities = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sc-sysinfo = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sc-tracing = { workspace = true, default-features = true }
sc-transaction-pool = { workspace = true, default-features = true }
sc-transaction-pool-api = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
Expand All @@ -66,6 +68,7 @@ sp-crypto-hashing = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true, default-features = true }
sp-storage = { workspace = true, default-features = true }
Expand Down
3 changes: 3 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod types;

use cumulus_primitives_core::{CollectCollationInfo, GetCoreSelectorApi};
use sc_client_db::DbHash;
use sc_offchain::OffchainWorkerApi;
use serde::de::DeserializeOwned;
use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, Metadata};
use sp_block_builder::BlockBuilder;
Expand Down Expand Up @@ -65,6 +66,7 @@ pub trait NodeRuntimeApi<Block: BlockT>:
+ SessionKeys<Block>
+ BlockBuilder<Block>
+ TaggedTransactionQueue<Block>
+ OffchainWorkerApi<Block>
+ CollectCollationInfo<Block>
+ GetCoreSelectorApi<Block>
+ Sized
Expand All @@ -77,6 +79,7 @@ impl<T, Block: BlockT> NodeRuntimeApi<Block> for T where
+ SessionKeys<Block>
+ BlockBuilder<Block>
+ TaggedTransactionQueue<Block>
+ OffchainWorkerApi<Block>
+ GetCoreSelectorApi<Block>
+ CollectCollationInfo<Block>
{
Expand Down
24 changes: 24 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ use cumulus_client_service::{
};
use cumulus_primitives_core::{BlockT, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use futures::FutureExt;
use parachains_common::Hash;
use polkadot_primitives::CollatorPair;
use prometheus_endpoint::Registry;
use sc_client_api::Backend;
use sc_consensus::DefaultImportQueue;
use sc_executor::{HeapAllocStrategy, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::{config::FullNetworkConfiguration, NetworkBackend, NetworkBlock};
Expand All @@ -41,6 +43,7 @@ use sc_sysinfo::HwBench;
use sc_telemetry::{TelemetryHandle, TelemetryWorker};
use sc_tracing::tracing::Instrument;
use sc_transaction_pool::TransactionPoolHandle;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_keystore::KeystorePtr;
use std::{future::Future, pin::Pin, sync::Arc, time::Duration};

Expand Down Expand Up @@ -303,6 +306,27 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
})
.await?;

if parachain_config.offchain_worker.enabled {
let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(params.keystore_container.keystore()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: Arc::new(network.clone()),
is_validator: parachain_config.role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
);
}

let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
Expand Down
6 changes: 6 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/fake_runtime_api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ macro_rules! impl_node_runtime_apis {
}
}

impl sp_offchain::OffchainWorkerApi<$block> for $runtime {
fn offchain_worker(_: &<$block as BlockT>::Header) {
unimplemented!()
}
}

impl sp_session::SessionKeys<$block> for $runtime {
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
unimplemented!()
Expand Down
57 changes: 46 additions & 11 deletions cumulus/polkadot-omni-node/lib/src/nodes/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ use crate::common::{
};
use codec::Encode;
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{CollectCollationInfo, ParaId};
use futures::FutureExt;
use polkadot_primitives::UpgradeGoAhead;
use sc_client_api::Backend;
use sc_consensus::{DefaultImportQueue, LongestChain};
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
use sc_network::NetworkBackend;
use sc_service::{Configuration, PartialComponents, TaskManager};
use sc_telemetry::TelemetryHandle;
use sp_api::ProvideRuntimeApi;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_runtime::traits::Header;
use std::{marker::PhantomData, sync::Arc};

Expand Down Expand Up @@ -117,6 +121,27 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
metrics,
})?;

if config.offchain_worker.enabled {
let offchain_workers =
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: Arc::new(network.clone()),
is_validator: config.role.is_authority(),
enable_http_requests: true,
custom_extensions: move |_| vec![],
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
);
}

let proposer = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
Expand Down Expand Up @@ -158,16 +183,24 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
.expect("Header lookup should succeed")
.expect("Header passed in as parent should be present in backend.");

let should_send_go_ahead = match client_for_cidp
let should_send_go_ahead = client_for_cidp
.runtime_api()
.collect_collation_info(block, &current_para_head)
{
Ok(info) => info.new_validation_code.is_some(),
Err(e) => {
log::error!("Failed to collect collation info: {:?}", e);
false
},
};
.map(|info| info.new_validation_code.is_some())
.unwrap_or_default();

// The API version is relevant here because the constraints in the runtime changed
// in https://github.com/paritytech/polkadot-sdk/pull/6825. In general, the logic
// here assumes that we are using the aura-ext consensushook in the parachain
// runtime.
let requires_relay_progress = client_for_cidp
.runtime_api()
.has_api_with::<dyn AuraUnincludedSegmentApi<NodeSpec::Block>, _>(
block,
|version| version > 1,
)
.ok()
.unwrap_or_default();

let current_para_block_head =
Some(polkadot_primitives::HeadData(current_para_head.encode()));
Expand All @@ -183,8 +216,10 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
),
para_id,
current_para_block_head,
relay_offset: 1000,
relay_blocks_per_para_block: 1,
relay_offset: 0,
relay_blocks_per_para_block: requires_relay_progress
.then(|| 1)
.unwrap_or_default(),
para_blocks_per_relay_epoch: 10,
relay_randomness_config: (),
xcm_config: MockXcmConfig::new(&*client_for_xcm, block, Default::default()),
Expand Down
8 changes: 8 additions & 0 deletions prdoc/pr_7451.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: 'omni-node: Adjust manual seal parameters'
doc:
- audience: Runtime Dev
description: |-
This PR restores compatibility of older runtimes with the dev mode of omni-node. Before, runtimes built without the changes in https://github.com/paritytech/polkadot-sdk/pull/6825 were failing.
crates:
- name: polkadot-omni-node-lib
bump: patch
9 changes: 9 additions & 0 deletions prdoc/pr_7479.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: 'omni-node: add offchain worker'
doc:
- audience: [ Runtime Dev, Node Dev, Node Operator ]
description: |-
Added support for offchain worker to omni-node-lib for both aura and manual seal nodes.

crates:
- name: polkadot-omni-node-lib
bump: patch
10 changes: 10 additions & 0 deletions prdoc/pr_7488.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Increase litep2p keep-alive to 10 seconds to mirror libp2p

doc:
- audience: [Node Dev, Node Operator]
description: |
Increase litep2p keep-alive to 10 seconds to mirror libp2p behavior.

crates:
- name: sc-network
bump: patch
6 changes: 6 additions & 0 deletions substrate/client/network/src/litep2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ mod peerstore;
mod service;
mod shim;

/// Timeout for connection waiting new substreams.
const KEEP_ALIVE_TIMEOUT: Duration = Duration::from_secs(10);

/// Litep2p bandwidth sink.
struct Litep2pBandwidthSink {
sink: litep2p::BandwidthSink,
Expand Down Expand Up @@ -566,6 +569,9 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
.with_connection_limits(ConnectionLimitsConfig::default().max_incoming_connections(
Some(crate::MAX_CONNECTIONS_ESTABLISHED_INCOMING as usize),
))
// This has the same effect as `libp2p::Swarm::with_idle_connection_timeout` which is
// set to 10 seconds as well.
.with_keep_alive_timeout(KEEP_ALIVE_TIMEOUT)
.with_executor(executor);

if let Some(config) = maybe_mdns_config {
Expand Down
2 changes: 1 addition & 1 deletion templates/parachain/dev_chain_spec.json

Large diffs are not rendered by default.

0 comments on commit 729ce37

Please sign in to comment.