Skip to content

Commit

Permalink
Remove Aura in orchestrator chain (#163)
Browse files Browse the repository at this point in the history
* cleanup pallets + wip tests

* fix integration tests

* remove now useless arg

* fix ts tests

* only return orchestrator authorities

* fix dev_tanssi tests

* remove unused pallets and deps
  • Loading branch information
nanocryk authored Jul 7, 2023
1 parent 4339506 commit d422831
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 302 deletions.
38 changes: 0 additions & 38 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ frame-system = { git = "https://github.com/moondance-labs/substrate.git", branch
frame-system-benchmarking = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
frame-try-runtime = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
pallet-aura = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
pallet-authorship = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
pallet-balances = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
pallet-root-testing = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
pallet-session = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false }
Expand Down Expand Up @@ -135,7 +133,6 @@ polkadot-primitives = { git = "https://github.com/moondance-labs/polkadot", bran
polkadot-service = { git = "https://github.com/moondance-labs/polkadot", branch = "tanssi-polkadot-v0.9.43" }

# Cumulus (wasm)
cumulus-pallet-aura-ext = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false }
cumulus-pallet-session-benchmarking = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false }
cumulus-primitives-core = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false }
Expand Down
9 changes: 0 additions & 9 deletions container-chains/templates/simple/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
Expand All @@ -55,7 +53,6 @@ polkadot-parachain = { workspace = true }
polkadot-runtime-common = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true }
cumulus-primitives-core = { workspace = true }
Expand All @@ -75,7 +72,6 @@ default = [
"std",
]
std = [
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-parachain-system/std",
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
Expand All @@ -86,9 +82,7 @@ std = [
"frame-try-runtime/std",
"log/std",
"nimbus-primitives/std",
"pallet-aura/std",
"pallet-author-inherent/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-cc-authorities-noting/std",
"pallet-session/std",
Expand Down Expand Up @@ -132,16 +126,13 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-utility/try-runtime",
"sp-runtime/try-runtime",
"polkadot-runtime-common/try-runtime",
"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"parachain-info/try-runtime",
"frame-try-runtime"
Expand Down
4 changes: 0 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ fn testnet_genesis(
})
.collect(),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
configuration,
registrar: RegistrarConfig {
Expand Down
3 changes: 1 addition & 2 deletions pallets/registrar/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
use {
crate::{Call, Config, DepositBalanceOf, Pallet},
frame_benchmarking::{account, v2::*},
frame_support::traits::Currency,
frame_support::BoundedVec,
frame_support::{traits::Currency, BoundedVec},
frame_system::RawOrigin,
sp_core::Get,
sp_std::vec,
Expand Down
9 changes: 0 additions & 9 deletions runtime/dancebox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-root-testing = { workspace = true }
pallet-session = { workspace = true }
Expand Down Expand Up @@ -68,7 +66,6 @@ polkadot-parachain = { workspace = true }
polkadot-runtime-common = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true }
cumulus-primitives-core = { workspace = true }
Expand All @@ -92,7 +89,6 @@ default = [
"std",
]
std = [
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-parachain-system/std",
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
Expand All @@ -103,10 +99,8 @@ std = [
"frame-try-runtime/std",
"log/std",
"nimbus-primitives/std",
"pallet-aura/std",
"pallet-author-noting/std",
"pallet-authority-assignment/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-collator-assignment-runtime-api/std",
"pallet-collator-selection/std",
Expand Down Expand Up @@ -169,8 +163,6 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-session/try-runtime",
Expand All @@ -179,7 +171,6 @@ try-runtime = [
"pallet-utility/try-runtime",
"sp-runtime/try-runtime",
"polkadot-runtime-common/try-runtime",
"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"pallet-collator-selection/try-runtime",
"parachain-info/try-runtime",
Expand Down
72 changes: 12 additions & 60 deletions runtime/dancebox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use {
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU32, ConstU64, Everything, OneSessionHandler},
traits::{ConstU32, ConstU64, Everything},
weights::{
constants::{
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
Expand Down Expand Up @@ -309,11 +309,6 @@ impl pallet_timestamp::Config for Runtime {
type WeightInfo = ();
}

impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type EventHandler = (CollatorSelection,);
}

pub struct CanAuthor;
impl nimbus_primitives::CanAuthor<NimbusId> for CanAuthor {
fn can_author(author: &NimbusId, slot: &u32) -> bool {
Expand All @@ -325,7 +320,8 @@ impl nimbus_primitives::CanAuthor<NimbusId> for CanAuthor {
return false;
}

let expected_author = &authorities[(*slot as usize) % authorities.len()];
let author_index = (*slot as usize) % authorities.len();
let expected_author = &authorities[author_index];

expected_author == author
}
Expand Down Expand Up @@ -381,7 +377,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
pub struct OwnApplySession;
impl pallet_initializer::ApplyNewSession<Runtime> for OwnApplySession {
fn apply_new_session(
changed: bool,
_changed: bool,
session_index: u32,
all_validators: Vec<(AccountId, NimbusId)>,
queued: Vec<(AccountId, NimbusId)>,
Expand All @@ -405,40 +401,6 @@ impl pallet_initializer::ApplyNewSession<Runtime> for OwnApplySession {
&queued_id_to_nimbus_map,
&assignments.next_assignment,
);

let orchestrator_current_assignemnt = assignments.active_assignment.orchestrator_chain;
let orchestrator_queued_assignemnt = assignments.next_assignment.orchestrator_chain;

// We filter the accounts based on the collators assigned to the orchestrator chain (this chain)
// We insert these in Aura
let validators: Vec<_> = all_validators
.iter()
.filter_map(|(k, v)| {
if orchestrator_current_assignemnt.contains(k) {
Some((k, v.clone()))
} else {
None
}
})
.collect();

let queued: Vec<_> = queued
.iter()
.filter_map(|(k, v)| {
if orchestrator_queued_assignemnt.contains(k) {
Some((k, v.clone()))
} else {
None
}
})
.collect();

// Then we apply Aura
if session_index == 0 {
Aura::on_genesis_session(validators.into_iter());
} else {
Aura::on_new_session(changed, validators.into_iter(), queued.into_iter());
}
}
}

Expand All @@ -453,8 +415,6 @@ impl pallet_initializer::Config for Runtime {

impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

parameter_types! {
pub const Period: u32 = prod_or_fast!(6 * HOURS, 1 * MINUTES);
pub const Offset: u32 = 0;
Expand All @@ -474,12 +434,6 @@ impl pallet_session::Config for Runtime {
type WeightInfo = ();
}

impl pallet_aura::Config for Runtime {
type AuthorityId = NimbusId;
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
}

impl pallet_collator_assignment::Config for Runtime {
type HostConfiguration = Configuration;
type ContainerChains = Registrar;
Expand Down Expand Up @@ -618,14 +572,10 @@ construct_runtime!(
AuthorityAssignment: pallet_authority_assignment = 25,

// Collator support. The order of these 4 are important and shall not change.
Authorship: pallet_authorship = 30,
CollatorSelection: pallet_collator_selection = 31,
Session: pallet_session = 32,
Aura: pallet_aura = 33,
AuraExt: cumulus_pallet_aura_ext = 34,
AuthorityMapping: pallet_authority_mapping = 35,

AuthorInherent: pallet_author_inherent = 50,
CollatorSelection: pallet_collator_selection = 30,
Session: pallet_session = 31,
AuthorityMapping: pallet_authority_mapping = 32,
AuthorInherent: pallet_author_inherent = 33,

RootTesting: pallet_root_testing = 100,
}
Expand All @@ -634,11 +584,13 @@ construct_runtime!(
impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, NimbusId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<NimbusId> {
Aura::authorities().into_inner()
pallet_authority_assignment::CollatorContainerChain::<Runtime>::get(Session::current_index())
.expect("authorities for current session should exist")
.orchestrator_chain
}
}

Expand Down
Loading

0 comments on commit d422831

Please sign in to comment.