Skip to content

Commit

Permalink
Enable elastic scaling node feature in local testnets genesis (#3509)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
  • Loading branch information
sandreim authored Feb 29, 2024
1 parent c244a94 commit 7f5d308
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 58 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions polkadot/node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ kvdb-rocksdb = { version = "0.19.0", optional = true }
parity-db = { version = "0.4.12", optional = true }
codec = { package = "parity-scale-codec", version = "3.6.1" }
parking_lot = "0.12.1"
bitvec = { version = "1.0.1", optional = true }

# Polkadot
polkadot-core-primitives = { path = "../../core-primitives" }
Expand Down Expand Up @@ -184,8 +185,8 @@ full-node = [
]

# Configure the native runtimes to use.
westend-native = ["westend-runtime", "westend-runtime-constants"]
rococo-native = ["rococo-runtime", "rococo-runtime-constants"]
westend-native = ["bitvec", "westend-runtime", "westend-runtime-constants"]
rococo-native = ["bitvec", "rococo-runtime", "rococo-runtime-constants"]

runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
Expand Down
7 changes: 6 additions & 1 deletion polkadot/node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ pub fn wococo_config() -> Result<RococoChainSpec, String> {
fn default_parachains_host_configuration(
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber>
{
use polkadot_primitives::{AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_primitives::{
vstaging::node_features::FeatureIndex, AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE,
};

polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_cooldown: 2u32,
Expand Down Expand Up @@ -155,6 +157,9 @@ fn default_parachains_host_configuration(
max_candidate_depth: 3,
allowed_ancestry_len: 2,
},
node_features: bitvec::vec::BitVec::from_element(
1u8 << (FeatureIndex::ElasticScalingMVP as usize),
),
scheduler_params: SchedulerParams {
lookahead: 2,
group_rotation_frequency: 20,
Expand Down
24 changes: 16 additions & 8 deletions polkadot/runtime/parachains/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use primitives::{
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments,
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt,
CompactStatement, CoreIndex, DisputeStatement, DisputeStatementSet, GroupIndex, HeadData,
Id as ParaId, IndexedVec, InherentData as ParachainsInherentData, InvalidDisputeStatementKind,
PersistedValidationData, SessionIndex, SigningContext, UncheckedSigned,
ValidDisputeStatementKind, ValidationCode, ValidatorId, ValidatorIndex, ValidityAttestation,
collator_signature_payload, vstaging::node_features::FeatureIndex, AvailabilityBitfield,
BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId,
CollatorSignature, CommittedCandidateReceipt, CompactStatement, CoreIndex, DisputeStatement,
DisputeStatementSet, GroupIndex, HeadData, Id as ParaId, IndexedVec,
InherentData as ParachainsInherentData, InvalidDisputeStatementKind, PersistedValidationData,
SessionIndex, SigningContext, UncheckedSigned, ValidDisputeStatementKind, ValidationCode,
ValidatorId, ValidatorIndex, ValidityAttestation,
};
use sp_core::{sr25519, H256};
use sp_runtime::{
Expand Down Expand Up @@ -509,7 +510,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
.iter()
.map(|(seed, num_votes)| {
assert!(*num_votes <= validators.len() as u32);
let (para_id, _core_idx, group_idx) = self.create_indexes(*seed);
let (para_id, core_idx, group_idx) = self.create_indexes(*seed);

// This generates a pair and adds it to the keystore, returning just the public.
let collator_public = CollatorId::generate_pair(None);
Expand Down Expand Up @@ -586,11 +587,18 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
})
.collect();

// Check if the elastic scaling bit is set, if so we need to supply the core index
// in the generated candidate.
let core_idx = configuration::Pallet::<T>::config()
.node_features
.get(FeatureIndex::ElasticScalingMVP as usize)
.map(|_the_bit| core_idx);

BackedCandidate::<T::Hash>::new(
candidate,
validity_votes,
bitvec::bitvec![u8, bitvec::order::Lsb0; 1; group_validators.len()],
None,
core_idx,
)
})
.collect()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Description: Test that a paraid acquiring multiple cores does not brick itself if ElasticScalingMVP feature is enabled
Description: Test that a paraid acquiring multiple cores does not brick itself if ElasticScalingMVP feature is enabled in genesis
Network: ./0012-elastic-scaling-mvp.toml
Creds: config

Expand All @@ -15,14 +15,5 @@ alice: js-script ./0012-register-para.js return is 0 within 600 seconds

validator: reports substrate_block_height{status="finalized"} is at least 35 within 100 seconds

# Parachain will now be stalled
validator: parachain 2000 block height is lower than 20 within 300 seconds

# Enable the ElasticScalingMVP node feature.
alice: js-script ./0012-enable-node-feature.js with "1" return is 0 within 600 seconds

# Wait two sessions for the config to be updated.
sleep 120 seconds

# Ensure parachain is now making progress.
validator: parachain 2000 block height is at least 30 within 200 seconds
37 changes: 0 additions & 37 deletions polkadot/zombienet_tests/functional/0012-enable-node-feature.js

This file was deleted.

0 comments on commit 7f5d308

Please sign in to comment.