Skip to content

Commit

Permalink
Fixup backing group computation time (#3170) (#3183)
Browse files Browse the repository at this point in the history
Fixes: #3165

---------


(cherry picked from commit 5ba8921)

Signed-off-by: Alexandru Gheorghe <[email protected]>
  • Loading branch information
alexggh authored Feb 5, 2024
1 parent 08cc7fe commit 97df9dd
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .gitlab/pipeline/zombienet/polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ zombienet-polkadot-functional-0010-validator-disabling:
--local-dir="${LOCAL_DIR}/functional"
--test="0010-validator-disabling.zndsl"

zombienet-polkadot-functional-0011-async-backing-6-seconds-rate:
extends:
- .zombienet-polkadot-common
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}/functional"
--test="0011-async-backing-6-seconds-rate.zndsl"

zombienet-polkadot-smoke-0001-parachains-smoke-test:
extends:
- .zombienet-polkadot-common
Expand Down
9 changes: 8 additions & 1 deletion polkadot/runtime/parachains/src/runtime_api_impl/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub fn validators<T: initializer::Config>() -> Vec<ValidatorId> {
/// Implementation for the `validator_groups` function of the runtime API.
pub fn validator_groups<T: initializer::Config>(
) -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumberFor<T>>) {
// This formula needs to be the same as the one we use
// when populating group_responsible in `availability_cores`
let now = <frame_system::Pallet<T>>::block_number() + One::one();

let groups = <scheduler::Pallet<T>>::validator_groups();
Expand Down Expand Up @@ -95,6 +97,11 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, Bl
.expect("Occupied core always has pending availability; qed");

let backed_in_number = *pending_availability.backed_in_number();

// Use the same block number for determining the responsible group as what the
// backing subsystem would use when it calls validator_groups api.
let backing_group_allocation_time =
pending_availability.relay_parent_number() + One::one();
CoreState::Occupied(OccupiedCore {
next_up_on_available: <scheduler::Pallet<T>>::next_up_on_available(CoreIndex(
i as u32,
Expand All @@ -106,7 +113,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, Bl
)),
availability: pending_availability.availability_votes().clone(),
group_responsible: group_responsible_for(
backed_in_number,
backing_group_allocation_time,
pending_availability.core_occupied(),
),
candidate_hash: pending_availability.candidate_hash(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[settings]
timeout = 1000

[relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local"

[relaychain.genesis.runtimeGenesis.patch.configuration.config]
needed_approvals = 4
relay_vrf_modulo_samples = 6
scheduling_lookahead = 2
group_rotation_frequency = 4

[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 3
allowed_ancestry_len = 2

[relaychain.default_resources]
limits = { memory = "4G", cpu = "2" }
requests = { memory = "2G", cpu = "1" }

[[relaychain.node_groups]]
name = "alice"
args = [ "-lparachain=debug" ]
count = 12

[[parachains]]
id = 2000
addToGenesis = true
genesis_state_generator = "undying-collator export-genesis-state --pov-size=100000 --pvf-complexity=1"

[parachains.collator]
name = "collator01"
image = "{{COL_IMAGE}}"
command = "undying-collator"
args = ["-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000"]

[[parachains]]
id = 2001
cumulus_based = true

[parachains.collator]
name = "collator02"
image = "{{CUMULUS_IMAGE}}"
command = "polkadot-parachain"
args = ["-lparachain=debug"]

[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Description: Test we are producing blocks at 6 seconds clip
Network: ./0011-async-backing-6-seconds-rate.toml
Creds: config

# Check authority status.
alice: reports node_roles is 4

# Ensure parachains are registered.
alice: parachain 2000 is registered within 60 seconds
alice: parachain 2001 is registered within 60 seconds

# Ensure parachains made progress.
alice: reports substrate_block_height{status="finalized"} is at least 10 within 100 seconds

# This parachains should produce blocks at 6s clip, let's assume an 8s rate, allowing for
# some slots to be missed on slower machines
alice: parachain 2000 block height is at least 30 within 240 seconds
# This should already have produced the needed blocks
alice: parachain 2001 block height is at least 30 within 6 seconds

0 comments on commit 97df9dd

Please sign in to comment.