Skip to content

Keep baseSlot when unfolding storage layouts - #1298

Open
Steve0x2a wants to merge 1 commit into
OpenZeppelin:masterfrom
Steve0x2a:preserve-baseslot-on-unfold
Open

Steve0x2a wants to merge 1 commit into
OpenZeppelin:masterfrom
Steve0x2a:preserve-baseslot-on-unfold

Conversation

@Steve0x2a

@Steve0x2a Steve0x2a commented Aug 17, 2026

Copy link
Copy Markdown

unfoldStorageLayout rebuilt the layout without baseSlot. getStorageLayout and the deprecated UpgradeableContract API both go through that, so validateBaseSlotUnchanged compared undefined to undefined and a changed layout at slot passed on the AST-only path.

Hardhat/CLI flows already have compiler layouts, so they were not affected.

Credit to @nahimterrazas for the report and the repro.

Fixes #1296

Summary by CodeRabbit

  • Bug Fixes

    • Preserved storage layout base slots when unfolding and querying layouts.
    • Improved handling of flat and inherited storage layouts.
    • Continued detecting incompatible base slot changes during upgrade validation.
  • Tests

    • Added regression coverage for base slot preservation and upgrade validation.
  • Chores

    • Scheduled a patch release for the storage layout improvements.

getStorageLayout was dropping it, so a changed custom layout at
slot passed validation on the AST-only path.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5111c829-73c5-45f2-98b6-942611cfac45

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa87ac and 90dfcef.

📒 Files selected for processing (3)
  • .changeset/keep-baseslot-on-unfold.md
  • packages/core/src/storage-custom-layout.test.ts
  • packages/core/src/validate/query.ts

Included review availability: Your plan includes up to 4 reviews per rolling hour; 3 remain after this review.


Walkthrough

unfoldStorageLayout now preserves baseSlot for flat and inherited layouts. Regression tests verify preservation and confirm that storage-upgrade validation rejects changed base slots. A patch changeset documents the fix.

Changes

Storage-layout baseSlot preservation

Layer / File(s) Summary
Preserve baseSlot during unfolding
packages/core/src/validate/query.ts
unfoldStorageLayout copies baseSlot into flat and pre-flattened layouts.
Cover unfolded layout validation
packages/core/src/storage-custom-layout.test.ts, .changeset/keep-baseslot-on-unfold.md
Tests cover flat and inherited layouts and verify that changed base slots raise a storage-upgrade error. The changeset records a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 90dfc

The change preserves base-slot information when unfolding storage layouts and adds focused coverage for validation paths; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

Poem

A rabbit saw a slot unfold,
Its base stayed true, its tale was told.
Flat or nested, none went astray,
Changed slots now block the upgrade way.
Hop, hop—layouts behave today! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes preserve baseSlot in both unfolding branches and add coverage for getStorageLayout and AST-only validation paths [#1296].
Out of Scope Changes check ✅ Passed The changeset, implementation, and regression tests directly support the linked issue and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving baseSlot when unfolding storage layouts.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validateBaseSlotUnchanged never fires when layouts are read through unfoldStorageLayout

1 participant