diff --git a/Cargo.toml b/Cargo.toml index 04a96a66f..c67e8c3c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,9 @@ resolver = "2" [profile.production] codegen-units = 1 +features = [ + "on-chain-release-build", +] inherits = "release" lto = true strip = "symbols" diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index fc387b477..e3d33c580 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1711,7 +1711,7 @@ pub mod pallet { // choose the top TotalSelected qualified candidates, ordered by stake let collators = Self::compute_top_candidates(); if collators.is_empty() { - // SELECTION FAILED TO SELECT >=1 COLLATOR => select collators from previous round + log::error!("FAILED TO SELECT >=1 COLLATOR => using collators from previous round"); let last_round = now.saturating_sub(1u32); let mut total_per_candidate: BTreeMap> = BTreeMap::new(); // set this round AtStake to last round AtStake diff --git a/runtime/calamari/Cargo.toml b/runtime/calamari/Cargo.toml index ab558c6e2..2bd8e1773 100644 --- a/runtime/calamari/Cargo.toml +++ b/runtime/calamari/Cargo.toml @@ -269,3 +269,9 @@ std = [ 'pallet-manta-sbt/std', 'manta-support/std', ] +# A feature that should be enabled when the runtime should be build for on-chain +# deployment. This will disable stuff that shouldn't be part of the on-chain wasm +# to make it smaller like logging for example. +on-chain-release-build = [ + "sp-api/disable-logging", +] diff --git a/runtime/manta/Cargo.toml b/runtime/manta/Cargo.toml index d6bc310c7..131ca2814 100644 --- a/runtime/manta/Cargo.toml +++ b/runtime/manta/Cargo.toml @@ -248,3 +248,9 @@ std = [ 'orml-traits/std', 'orml-xtokens/std', ] +# A feature that should be enabled when the runtime should be build for on-chain +# deployment. This will disable stuff that shouldn't be part of the on-chain wasm +# to make it smaller like logging for example. +on-chain-release-build = [ + "sp-api/disable-logging", +] diff --git a/runtime/manta/src/lib.rs b/runtime/manta/src/lib.rs index 41d4a6687..05e417135 100644 --- a/runtime/manta/src/lib.rs +++ b/runtime/manta/src/lib.rs @@ -1034,7 +1034,15 @@ impl_runtime_apis! { // manually check aura eligibility (in the new round) // mirrors logic in `aura_style_filter` let truncated_half_slot = (slot >> 1) as usize; - let active: Vec = pallet_parachain_staking::Pallet::::compute_top_candidates(); + let mut active: Vec = pallet_parachain_staking::Pallet::::compute_top_candidates(); + if active.is_empty() { + // `SelectedCandidates` remains unchanged from last round (fallback) + active = pallet_parachain_staking::Pallet::::selected_candidates(); + if active.is_empty() { + log::error!("NimbusApi::can_author found no valid authors"); + return false; + } + } account == active[truncated_half_slot % active.len()] } else { // We're not changing rounds, `PotentialAuthors` is not changing, just use can_author