Skip to content

enforce slot based and make offset dynamic - #3740

Merged
librelois merged 11 commits into
masterfrom
elois/dynamic-offset
May 7, 2026
Merged

librelois merged 11 commits into
masterfrom
elois/dynamic-offset

Conversation

@librelois

@librelois librelois commented May 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Breaking Changes ⚠️

  • Runtime consensus validation now enforces the relay parent offset through cumulus_pallet_parachain_system::Config::RelayParentOffset.
  • Blocks authored with a relay parent offset that does not match the runtime-configured value will be rejected by the runtime.

What does it do?

Updates the runtimes to use the AsyncBacking pallet as the single source of truth for the relay parent offset.

The runtime API now returns AsyncBacking::relay_parent_offset(), and Moonbeam, Moonriver, and Moonbase wire cumulus_pallet_parachain_system::Config::RelayParentOffset to AsyncBacking instead of ConstU32<0>.

This makes the slot-based collation offset both dynamic and enforced by runtime consensus checks.

What important points should reviewers know?

  • Cargo.lock pins Moonkit to 8fae4417637f8e55ea04b3548809d7f1c22daf64, which adds the AsyncBacking storage value and Root setter for the relay parent offset.
  • The previous runtime API returned an offset of 1, while parachain-system consensus checks used 0; this PR removes that mismatch.
  • The effective default remains 1, but governance can update it through Moonkit’s pallet_async_backing::set_relay_parent_offset.

Is there something left for follow-up PRs?

No immediate follow-up required.

What alternative implementations were considered?

Keeping a runtime constant would enforce the offset, but would not allow governance to adjust it without a runtime upgrade. Using AsyncBacking directly keeps runtime API behavior and consensus validation aligned around the same storage value.

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

  • Moonkit commit: 8fae4417637f8e55ea04b3548809d7f1c22daf64

What value does it bring to the blockchain users?

It enforces the slot-based collation relay parent offset at runtime level, reducing the risk of accepting blocks that do not follow the intended async-backing consensus configuration.

@librelois librelois added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. breaking Needs to be mentioned in breaking changes labels May 4, 2026
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 9d39e559-3c00-4f69-bac7-df3108232042

📥 Commits

Reviewing files that changed from the base of the PR and between 5174902 and 4eec5e9.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • node/service/src/lazy_loading/mod.rs
  • node/service/src/lib.rs
  • node/service/src/rpc.rs
  • runtime/common/src/apis.rs
  • runtime/moonbase/src/lib.rs
  • runtime/moonbase/tests/common/mod.rs
  • runtime/moonbeam/src/lib.rs
  • runtime/moonbeam/tests/common/mod.rs
  • runtime/moonriver/src/lib.rs
  • runtime/moonriver/tests/common/mod.rs
  • test/configs/zombieAlphanet.json
  • test/configs/zombieMoonbeam.json
  • test/configs/zombieMoonriver.json
  • test/suites/dev/common/test-block/test-block-mocked-relay.ts
  • test/suites/dev/moonbase/test-precompile/test-precompile-relay-verifier.ts
  • test/suites/lazy-loading/common/test-runtime-upgrade.ts
  • zombienet/configs/moonbeam-polkadot.toml
  • zombienet/configs/moonriver-kusama.toml

📝 Walkthrough

Walkthrough

Relay-parent offset sourcing moved from hardcoded constants to the runtime AsyncBacking provider. Runtimes now configure RelayParentOffset = AsyncBacking; runtime API delegates to AsyncBacking::relay_parent_offset(). Node service, RPC, lazy-loading, tests, and inherent-data builders query the runtime API and propagate the computed offset into parachain inherent data and relay-state construction.

Changes

Relay Parent Offset Async Backing Migration

Layer / File(s) Summary
Data Shape / Runtime API
runtime/common/src/apis.rs
RelayParentOffsetApi::relay_parent_offset() now delegates to crate::AsyncBacking::relay_parent_offset() instead of returning a static constant.
Runtime Config
runtime/moonbase/src/lib.rs, runtime/moonbeam/src/lib.rs, runtime/moonriver/src/lib.rs
Removed per-runtime RELAY_PARENT_OFFSET constants and changed cumulus_pallet_parachain_system::Config for Runtime to set type RelayParentOffset = AsyncBacking (replacing ConstU32<...>).
Relay-State Builder Usage / Tests Helpers
runtime/*/tests/common/mod.rs (moonbase, moonbeam, moonriver)
set_parachain_inherent_data switched from into_state_root_and_proof() to into_state_root_proof_and_descendants(...) and now supplies relay_parent_descendants into BasicParachainInherentData instead of defaulting it.
Node API Bounds & Imports
node/service/src/lib.rs, node/service/src/lazy_loading/mod.rs, node/service/src/rpc.rs
Imported cumulus_primitives_core::RelayParentOffsetApi and tightened runtime API trait bounds (e.g., RuntimeApi::RuntimeApi: ... + RelayParentOffsetApi<Block> and C::Api: ... + RelayParentOffsetApi<Block>).
Runtime API Querying
node/service/src/lazy_loading/mod.rs, node/service/src/lib.rs, node/service/src/rpc.rs
When building inherent data, code now calls runtime_api().relay_parent_offset(block).unwrap_or_default() to obtain the relay-parent offset.
Inherent Data Construction / Wiring
node/service/src/lazy_loading/mod.rs, node/service/src/lib.rs, node/service/src/rpc.rs
Replaced into_state_root_and_proof() usage with into_state_root_proof_and_descendants(u64::from(relay_parent_offset)), pass relay_parent_descendants into ParachainInherentData, and compute relay_offset = relay_parent_offset.saturating_add(additional_relay_offset) instead of using additional_relay_offset alone.
Tests / Expectations
test/suites/dev/common/test-block/*, test/suites/dev/moonbase/test-precompile/*
Updated expectations for relay-parent block numbers/latestRelayBlockNumber to reflect the async-backed offset (assertions adjusted: earlier 0→1 and 1→2 / 1→2).
Configs / Collator Args
test/configs/*, zombienet/configs/*
Inserted --authoring=slot-based into collator args for several test and zombienet configurations.
Runtime Upgrade Test Flow
test/suites/lazy-loading/common/test-runtime-upgrade.ts
Adjusted migration validation: detect MigrationAdvanced, drain migration queue across blocks, and conditionally assert MigrationCompleted only if MigrationAdvanced was observed; UpgradeCompleted still asserted.

Sequence Diagram

sequenceDiagram
    participant Node as Node Service
    participant Client as Client/Block Backend
    participant RuntimeAPI as RuntimeApi
    participant Builder as RelayStateBuilder
    participant Parachain as ParachainInherentData

    Node->>Client: request block handle
    Client->>RuntimeAPI: runtime_api().relay_parent_offset(block)
    RuntimeAPI-->>Client: relay_parent_offset (u32)
    Client-->>Node: relay_parent_offset (unwrap_or_default)
    Node->>Builder: into_state_root_proof_and_descendants(u64::from(relay_parent_offset))
    Builder-->>Node: (storage_root, chain_state, relay_parent_descendants)
    Node->>Parachain: construct ParachainInherentData{ relay_parent_descendants, relay_offset = relay_parent_offset + additional }
    Parachain-->>Node: inherent data ready
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • manuelmauro
  • arturgontijo
  • pLabarta
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'enforce slot based and make offset dynamic' directly matches the core objectives: enforcing slot-based collation and making the relay parent offset dynamic through AsyncBacking.
Description check ✅ Passed The description comprehensively explains breaking changes, implementation details, reviewer notes, and value proposition—all directly related to the changeset's relay parent offset updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 elois/dynamic-offset

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 4, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

WASM runtime size check:

Compared to target branch

Moonbase runtime: 2064 KB (+8 KB) ⚠️

Moonbeam runtime: 2196 KB (+12 KB) ⚠️

Moonriver runtime: 2196 KB (+12 KB) ⚠️

Compared to latest release (runtime-4300)

Moonbase runtime: 2064 KB (+204 KB compared to latest release) ⚠️

Moonbeam runtime: 2196 KB (+244 KB compared to latest release) ⚠️

Moonriver runtime: 2196 KB (+244 KB compared to latest release) ⚠️

stiiifff
stiiifff previously approved these changes May 5, 2026
@librelois
librelois dismissed stale reviews from coderabbitai[bot] and stiiifff via 763ee43 May 5, 2026 09:58
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
node/service/src/lib.rs (1)

1552-1569: 💤 Low value

Consider logging the runtime API error before defaulting to 0.

relay_parent_offset(block).unwrap_or_default() silently falls back to 0 if the runtime API call fails. In the manual-seal dev path this is mostly diagnostic, but failures here are still worth a log::error! (mirroring the pattern used a few lines above for collect_collation_info) so a misconfigured runtime doesn't quietly produce blocks with the wrong relay_offset.

♻️ Suggested change
-						let relay_parent_offset = client_for_xcm
-							.runtime_api()
-							.relay_parent_offset(block)
-							.unwrap_or_default();
+						let relay_parent_offset = match client_for_xcm
+							.runtime_api()
+							.relay_parent_offset(block)
+						{
+							Ok(offset) => offset,
+							Err(e) => {
+								log::error!(
+									"Failed to query relay_parent_offset, defaulting to 0: {:?}",
+									e
+								);
+								0
+							}
+						};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@node/service/src/lib.rs` around lines 1552 - 1569, The call to
client_for_xcm.runtime_api().relay_parent_offset(block).unwrap_or_default()
silently drops errors; change it to capture the Result/Option, log the error
with log::error! when it fails, and then use 0 as a fallback so misconfigured
runtimes are visible; locate the call to relay_parent_offset in the code that
constructs MockValidationDataInherentDataProvider (the relay_offset assignment)
and replace the unwrap_or_default usage with a pattern that logs the runtime API
error before defaulting (e.g., match/if let Err or .map_err/log and then
.unwrap_or(0)).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@node/service/src/lib.rs`:
- Around line 1552-1569: The call to
client_for_xcm.runtime_api().relay_parent_offset(block).unwrap_or_default()
silently drops errors; change it to capture the Result/Option, log the error
with log::error! when it fails, and then use 0 as a fallback so misconfigured
runtimes are visible; locate the call to relay_parent_offset in the code that
constructs MockValidationDataInherentDataProvider (the relay_offset assignment)
and replace the unwrap_or_default usage with a pattern that logs the runtime API
error before defaulting (e.g., match/if let Err or .map_err/log and then
.unwrap_or(0)).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d33f0f2d-4544-4a18-964a-a8f5ca93051c

📥 Commits

Reviewing files that changed from the base of the PR and between 763ee43 and 50191d6.

📒 Files selected for processing (3)
  • node/service/src/lazy_loading/mod.rs
  • node/service/src/lib.rs
  • node/service/src/rpc.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 5, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

@@                   Coverage Diff                   @@
##           master   elois/dynamic-offset     +/-   ##
=======================================================
  Coverage   77.11%                 77.11%   0.00%     
  Files         389                    389             
+ Lines       77230                  77242     +12     
=======================================================
+ Hits        59554                  59563      +9     
+ Misses      17676                  17679      +3     
Files Changed Coverage
/node/service/src/lib.rs 56.85% (+0.14%) 🔼
/node/service/src/rpc.rs 82.81% (+0.12%) 🔼
/runtime/moonbase/tests/common/mod.rs 94.48% (+0.02%) 🔼
/runtime/moonbeam/tests/common/mod.rs 92.60% (+0.02%) 🔼
/runtime/moonriver/tests/common/mod.rs 93.89% (+0.02%) 🔼

Coverage generated Wed May 6 19:48:25 UTC 2026

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 5, 2026
@librelois librelois added D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited and removed D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
runtime/moonbase/src/lib.rs (1)

760-773: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Verify the relay_parent_offset storage default in the external Moonkit pallet before deployment

pallet_async_backing is registered without a Config<T> genesis entry, so relay_parent_offset is uninitialized after the runtime upgrade. The Get<u32> impl will read from storage, which defaults to the item's ValueQuery default.

If that default is 0 (Rust's native u32 zero) instead of 1, then immediately after upgrade:

  • cumulus_pallet_parachain_system enforces relay-parent offset 0
  • Collators still use offset 1 (from the prior API contract)
  • Every block produced is rejected → network halt

The PR description states "the effective default remains 1" in Moonkit commit 8fae4417637f8e55ea04b3548809d7f1c22daf64. This must be confirmed in the pallet_async_backing storage declaration (verify the QueryKind or explicit DefaultValue). Test code across all three runtimes already calls AsyncBacking::relay_parent_offset() in production paths, which is encouraging; however, the actual pallet source is external and cannot be fully inspected from this repository.

Also note: spec_version: 4400 is consistent across moonbase, moonbeam, and moonriver and was not marked as changed in this diff. Confirm that spec_version has been or will be incremented separately before the on-chain runtime upgrade, as this is a breaking consensus change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@runtime/moonbase/src/lib.rs` around lines 760 - 773, The runtime registers
pallet_async_backing as AsyncBacking and uses it for RelayParentOffset in the
cumulus_pallet_parachain_system impl, but the pallet's storage key
relay_parent_offset may default to 0 if the pallet's StorageValue
QueryKind/DefaultValue isn't explicitly set; confirm that the external
pallet_async_backing declares relay_parent_offset with a ValueQuery/default of 1
(or an explicit DefaultValue => 1) or add an explicit genesis Config entry
setting AsyncBacking::relay_parent_offset = 1 for this runtime so
RelayParentOffset returns 1 after upgrade; also ensure spec_version is bumped
before the on‑chain upgrade.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@runtime/moonbase/src/lib.rs`:
- Around line 760-773: The runtime registers pallet_async_backing as
AsyncBacking and uses it for RelayParentOffset in the
cumulus_pallet_parachain_system impl, but the pallet's storage key
relay_parent_offset may default to 0 if the pallet's StorageValue
QueryKind/DefaultValue isn't explicitly set; confirm that the external
pallet_async_backing declares relay_parent_offset with a ValueQuery/default of 1
(or an explicit DefaultValue => 1) or add an explicit genesis Config entry
setting AsyncBacking::relay_parent_offset = 1 for this runtime so
RelayParentOffset returns 1 after upgrade; also ensure spec_version is bumped
before the on‑chain upgrade.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b0719544-87f6-4371-80a9-6cfce7fb40a7

📥 Commits

Reviewing files that changed from the base of the PR and between e503381 and 75eb569.

📒 Files selected for processing (3)
  • runtime/moonbase/src/lib.rs
  • runtime/moonbeam/src/lib.rs
  • runtime/moonriver/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • runtime/moonbeam/src/lib.rs
  • runtime/moonriver/src/lib.rs

@librelois

Copy link
Copy Markdown
Contributor Author

⚠️ Outside diff range comments (1)

runtime/moonbase/src/lib.rs (1)> 760-773: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Verify the relay_parent_offset storage default in the external Moonkit pallet before deployment
pallet_async_backing is registered without a Config<T> genesis entry, so relay_parent_offset is

  • Around line 760-773: The runtime registers pallet_async_backing as
    AsyncBacking and uses it for RelayParentOffset in the
    cumulus_pallet_parachain_system impl, but the pallet's storage key
    relay_parent_offset may default to 0 if the pallet's StorageValue
    QueryKind/DefaultValue isn't explicitly set; confirm that the external
    pallet_async_backing declares relay_parent_offset with a ValueQuery/default of 1
    (or an explicit DefaultValue => 1) or add an explicit genesis Config entry
    setting AsyncBacking::relay_parent_offset = 1 for this runtime so
    RelayParentOffset returns 1 after upgrade; also ensure spec_version is bumped
    before the on‑chain upgrade.

@coderabbitai The external Moonkit pallet already declares RelayParentOffset as ValueQuery with DefaultRelayParentOffset returning 1

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@librelois, thanks for the clarification! That fully addresses my concern — since pallet_async_backing in Moonkit already declares relay_parent_offset as ValueQuery with DefaultRelayParentOffset returning 1, the storage will correctly default to 1 even without an explicit genesis Config entry, and the effective offset after the upgrade is preserved as expected.


✏️ Learnings added
Learnt from: librelois
URL: https://github.com/moonbeam-foundation/moonbeam/pull/3740

Timestamp: 2026-05-05T15:20:55.479Z
Learning: In the Moonkit repository (Moonsong-Labs/moonkit), `pallet_async_backing` declares the `relay_parent_offset` StorageValue as a `ValueQuery` with a `DefaultRelayParentOffset` that returns `1`. No explicit genesis Config entry is needed for Moonbeam/Moonriver/Moonbase runtimes to get the correct default offset of 1 after upgrade.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@librelois

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
node/service/src/lib.rs (1)

1552-1569: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t silently fall back to relay offset 0 here.

If relay_parent_offset(block) fails, this path now authors mocked validation data with relay_offset = 0 + additional_relay_offset, which recreates the exact mismatch this PR is trying to remove. Please surface the runtime API error instead of defaulting so dev-authored blocks don’t silently use an invalid relay parent offset.

node/service/src/lazy_loading/mod.rs (1)

660-676: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid masking lazy-loading offset lookup failures with 0.

This has the same problem as the dev path: on any relay_parent_offset(block) error, lazy-loading will keep building mocked inherent data with the old implicit offset 0. Since this mode is already more exposed to remote-state failures, please propagate the error instead of fabricating a relay offset that may no longer match the runtime configuration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@node/service/src/lazy_loading/mod.rs` around lines 660 - 676, The code masks
failures from client_for_xcm.runtime_api().relay_parent_offset(block) by using
unwrap_or_default() which silently substitutes 0 into
MockValidationDataInherentDataProvider.relay_offset (combined with
additional_relay_offset.load), risking incorrect relay offsets; change the call
to propagate the error instead of swallowing it—replace unwrap_or_default() with
proper error propagation (e.g., using ? or map_err and propagating the Result
from the function that builds the MockValidationDataInherentDataProvider) so
that failures from relay_parent_offset are returned to the caller and the mock
is not constructed with a fabricated offset.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@node/service/src/rpc.rs`:
- Around line 244-247: The code currently swallows runtime API errors by calling
unwrap_or_default() on client_for_cidp.runtime_api().relay_parent_offset(block),
causing a synthesized offset 0 and incorrect relay_parent_descendants for
pending RPC simulation; replace unwrap_or_default() with proper error
propagation (e.g., use ? or map_err to return an error) so failures from
relay_parent_offset bubble up to the RPC caller, and apply the same change to
the other occurrences mentioned (the block handling around the 269-284 region)
so no runtime API error is converted into a default offset.

---

Outside diff comments:
In `@node/service/src/lazy_loading/mod.rs`:
- Around line 660-676: The code masks failures from
client_for_xcm.runtime_api().relay_parent_offset(block) by using
unwrap_or_default() which silently substitutes 0 into
MockValidationDataInherentDataProvider.relay_offset (combined with
additional_relay_offset.load), risking incorrect relay offsets; change the call
to propagate the error instead of swallowing it—replace unwrap_or_default() with
proper error propagation (e.g., using ? or map_err and propagating the Result
from the function that builds the MockValidationDataInherentDataProvider) so
that failures from relay_parent_offset are returned to the caller and the mock
is not constructed with a fabricated offset.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 50593e51-bd34-4980-97e8-20d980252c97

📥 Commits

Reviewing files that changed from the base of the PR and between b4f02de and b1374f5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • node/service/src/lazy_loading/mod.rs
  • node/service/src/lib.rs
  • node/service/src/rpc.rs
  • runtime/common/src/apis.rs
  • runtime/moonbase/src/lib.rs
  • runtime/moonbase/tests/common/mod.rs
  • runtime/moonbeam/src/lib.rs
  • runtime/moonbeam/tests/common/mod.rs
  • runtime/moonriver/src/lib.rs
  • runtime/moonriver/tests/common/mod.rs
  • test/configs/zombieAlphanet.json
  • test/configs/zombieMoonbeam.json
  • test/configs/zombieMoonriver.json
  • test/suites/dev/common/test-block/test-block-mocked-relay.ts
  • test/suites/dev/moonbase/test-precompile/test-precompile-relay-verifier.ts
  • test/suites/lazy-loading/common/test-runtime-upgrade.ts
  • zombienet/configs/moonbeam-polkadot.toml
  • zombienet/configs/moonriver-kusama.toml

Comment thread node/service/src/rpc.rs Outdated
@librelois

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@librelois
librelois merged commit ce8944f into master May 7, 2026
37 of 41 checks passed
@librelois
librelois deleted the elois/dynamic-offset branch May 7, 2026 12:01
manuelmauro added a commit that referenced this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants