Skip to content

Enable Moonbase elastic scaling#3792

Open
arturgontijo wants to merge 3 commits into
masterfrom
artur/elastic-scaling
Open

Enable Moonbase elastic scaling#3792
arturgontijo wants to merge 3 commits into
masterfrom
artur/elastic-scaling

Conversation

@arturgontijo

@arturgontijo arturgontijo commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables elastic scaling on Moonbase so the parachain can produce multiple blocks per relay-chain slot (async backing / fixed-velocity consensus), instead of a single block every ~6s.

  • Bump Moonbase spec_version from 4400 to 4500.
  • Set BLOCK_PROCESSING_VELOCITY from 1 to 3 (target minimum block time ~2s: 6000ms / 3).
  • Set UNINCLUDED_SEGMENT_CAPACITY to 12 using (3 + RELAY_PARENT_OFFSET) * BLOCK_PROCESSING_VELOCITY, with RELAY_PARENT_OFFSET hardcoded to 1 for now (build one slot behind the relay chain).
  • Raise the CLI --block-authoring-duration upper bound from 2s to 6s so collators can align with relay slot timing when authoring faster blocks.

Relay-parent offset is ultimately provided by pallet_async_backing in moonkit (type RelayParentOffset = AsyncBacking on cumulus_pallet_parachain_system::Config). This PR still uses a local RELAY_PARENT_OFFSET constant only in the unincluded-segment capacity formula; we can drop that const once we wire the capacity calculation to moonkit’s offset API.

Moonbeam and Moonriver are unchanged (velocity 1, capacity 3).

Motivation

Elastic scaling lets Moonbase keep up with higher throughput on testnet while staying within relay-chain inclusion rules. Moonbase is the first runtime in this repo to adopt the higher velocity and segment capacity.

Technical details

Parameter Before After
BLOCK_PROCESSING_VELOCITY 1 3
UNINCLUDED_SEGMENT_CAPACITY 3 (3 + 1) × 3 = 12
RELAY_PARENT_OFFSET (local, for capacity only) 1 (hardcoded)
Min block time (approx.) ~6s ~2s

Consensus hook remains FixedVelocityConsensusHook with RELAY_CHAIN_SLOT_DURATION_MILLIS = 6000.

Test plan

  • Build Moonbase runtime and node: cargo b -r
  • Run Zombienet with Moonbase collator using --authoring=slot-based; confirm blocks are produced at ~2s intervals when elastic scaling is active (after calling sudo( coretime.assignCore(core, 0, [[{ task: para }, 57600]], null) ) on relay).

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@arturgontijo arturgontijo self-assigned this Jun 2, 2026
@arturgontijo arturgontijo added B0-silent Changes should not be mentioned in any release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit not-breaking Does not need to be mentioned in breaking changes labels Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d27197f0-e790-4fea-b282-e8cc1882fb97

📥 Commits

Reviewing files that changed from the base of the PR and between e130e94 and 8ff9454.

📒 Files selected for processing (2)
  • node/cli/src/cli.rs
  • runtime/moonbase/src/lib.rs

📝 Walkthrough

Walkthrough

The PR updates the CLI block authoring duration parameter to accept up to 6,000ms, increments the Moonbase runtime spec version to 4500, and reconfigures relay-chain async backing timing constants with increased velocity and computed segment capacity, making these constants publicly accessible.

Changes

Configuration Updates

Layer / File(s) Summary
CLI block authoring duration bounds
node/cli/src/cli.rs
The block_authoring_duration_parser raises the maximum allowed --block-authoring-duration from 2,000ms to 6,000ms.
Runtime version and relay-chain timing constants
runtime/moonbase/src/lib.rs
Runtime spec version is incremented from 4400 to 4500. Relay-chain async backing constants are restructured: RELAY_PARENT_OFFSET is introduced, BLOCK_PROCESSING_VELOCITY changes from 1 to 3, and UNINCLUDED_SEGMENT_CAPACITY is recomputed as (3 + RELAY_PARENT_OFFSET) * BLOCK_PROCESSING_VELOCITY. All relay timing constants are promoted to public.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • moonbeam-foundation/moonbeam#3743: Updates to runtime/moonbase/src/lib.rs spec version and relay-chain configuration constants suggest a coordinated runtime release.

Suggested labels

D2-notlive

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Enable Moonbase elastic scaling' directly and clearly summarizes the main objective of the changeset, which enables elastic scaling functionality on the Moonbase parachain.
Description check ✅ Passed The PR description provides comprehensive context for the changeset, including motivation, technical details, parameter changes, and test plan, all directly related to enabling elastic scaling on Moonbase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch artur/elastic-scaling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B0-silent Changes should not be mentioned in any release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit not-breaking Does not need to be mentioned in breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant