Skip to content

Commit

Permalink
remove async backing config
Browse files Browse the repository at this point in the history
  • Loading branch information
magecnion committed Oct 3, 2024
1 parent 0ec2898 commit b416bdc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 56 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ fp-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "pol
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false, features = ["parameterized-consensus-hook"]}
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
31 changes: 11 additions & 20 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ use laos_runtime::{apis::RuntimeApi, opaque::Block, types::TransactionConverter,
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
StartRelayChainTasksParams,
};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
relay_chain::CollatorPair,
ParaId, PersistedValidationData,
};
use cumulus_primitives_parachain_inherent::ParachainInherentData;
Expand All @@ -46,7 +45,7 @@ use fc_rpc::{StorageOverride, StorageOverrideHandler};
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use futures::FutureExt;
use sc_client_api::Backend;
use sc_consensus::{import_queue::BasicQueue, ImportQueue};
use sc_consensus::ImportQueue;
use sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
};
Expand All @@ -55,10 +54,6 @@ use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::{
sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair},
AuraApi,
};
use sp_core::U256;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;
Expand Down Expand Up @@ -428,7 +423,7 @@ async fn start_node_impl(
spawn_frontier_tasks(
&task_manager,
client.clone(),
backend.clone(),
backend,
frontier_backend,
filter_pool,
overrides,
Expand Down Expand Up @@ -495,7 +490,6 @@ async fn start_node_impl(
if validator {
start_consensus(
client.clone(),
backend.clone(),
block_import,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
Expand Down Expand Up @@ -557,7 +551,6 @@ fn build_import_queue(
#[allow(clippy::too_many_arguments)]
fn start_consensus(
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
block_import: ParachainBlockImport,
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
Expand All @@ -572,7 +565,9 @@ fn start_consensus(
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
) -> Result<(), sc_service::Error> {
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
use cumulus_client_consensus_aura::collators::basic::{
self as basic_aura, Params as BasicAuraParams,
};

// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
// when starting the network.
Expand All @@ -594,15 +589,11 @@ fn start_consensus(
client.clone(),
);

let params = AuraParams {
let params = BasicAuraParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
block_import,
para_client: client.clone(),
para_backend: backend.clone(),
para_client: client,
relay_client: relay_chain_interface,
code_hash_provider: move |block_hash| {
client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash())
},
sync_oracle,
keystore,
collator_key,
Expand All @@ -612,12 +603,12 @@ fn start_consensus(
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
};

let fut =
aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _, _, _>(
basic_aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _>(
params,
);
task_manager.spawn_essential_handle().spawn("aura", None, fut);
Expand Down
2 changes: 0 additions & 2 deletions runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true, optional = true}
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-timestamp = { workspace = true }
cumulus-primitives-utility = { workspace = true }
Expand Down Expand Up @@ -138,7 +137,6 @@ std = [
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-aura/std",
"pallet-message-queue/std",
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
Expand Down
31 changes: 3 additions & 28 deletions runtime/laos/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

use crate::SLOT_DURATION;
use fp_rpc::TransactionStatus;
use frame_support::{
genesis_builder_helper::{build_state, get_preset},
Expand All @@ -34,33 +33,18 @@ use sp_runtime::{
};
use sp_std::prelude::*;
use sp_version::RuntimeVersion;

// Local module imports
use super::{
AccountId, AuraId, Balance, Block, Ethereum, Executive, InherentDataExt, Nonce,
AccountId, Aura, AuraId, Balance, Block, Ethereum, Executive, InherentDataExt, Nonce,
ParachainSystem, Runtime, RuntimeCall, RuntimeGenesisConfig, SessionKeys, System,
TransactionPayment, UncheckedExtrinsic, EVM, VERSION,
};

/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;

pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;

impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
}

fn authorities() -> Vec<AuraId> {
Expand Down Expand Up @@ -412,15 +396,6 @@ impl_runtime_apis! {
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
Expand Down
7 changes: 4 additions & 3 deletions runtime/laos/src/configs/cumulus_parachain_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
type ConsensusHook = ConsensusHook;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;

pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
Expand Down Expand Up @@ -95,4 +95,5 @@ impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, crate::Executive>,
CheckInherents = CheckInherents,
}
1 change: 0 additions & 1 deletion runtime/laos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ impl_opaque_keys! {

/// This determines the average expected block time that we are targeting.
pub const MILLISECS_PER_BLOCK: u64 = 12000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;

/// Version of the runtime
#[sp_version::runtime_version]
Expand Down

0 comments on commit b416bdc

Please sign in to comment.