Skip to content

Add ERC: Consolidated Dynamic Storage (CDS) #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

wisecameron
Copy link

@eip-review-bot
Copy link
Collaborator

eip-review-bot commented Dec 15, 2024

File ERCS/erc-7844.md

Requires 1 more reviewers from @g11tech, @SamWilsn, @xinbenlv

wisecameron and others added 2 commits December 17, 2024 13:37
Committing updated header

Co-authored-by: Andrew B Coathup <[email protected]>
@wisecameron wisecameron changed the title Created ERC-XXXX: Consolidated Dynamic Storage (CDS) Created ERC-7844: Consolidated Dynamic Storage (CDS) Dec 17, 2024
@github-actions github-actions bot removed the w-ci label Dec 17, 2024
@github-actions github-actions bot added the w-ci label Dec 17, 2024
@eip-review-bot eip-review-bot changed the title Created ERC-7844: Consolidated Dynamic Storage (CDS) Add ERC: Consolidated Dynamic Storage (CDS) Dec 19, 2024
@github-actions github-actions bot added w-ci and removed w-ci labels Dec 19, 2024
@wisecameron
Copy link
Author

wisecameron commented Jan 5, 2025

Changes in progress:

  • Put implementation & specification
  • Clarifications regarding entryIndex, memberIndex, safeIndex
  • Specification uses RFC 2119
  • Low-level diagrams depicting storage layout at various points.
  • Clarifications regarding what the system is (ie; a central storage and permisision management contract)
  • Specification: making basic permission management compulsory.
  • Example use cases
  • Optional feature: string alias for memberIndex.
  • Clarification regarding intended use(s) of the system.

Note: I believe the remaining errors are not currently fixable because they relate to the absence of my assets directory in the main branch. If this assumption is incorrect, please let me know and I will adjust immediately.

* Updated Contract
* Significantly Improved Hashing Scheme
* New storage-level diagrams
* RFC-2119
* memberIndex, entryIndex, safeIndex, stringIndex clarifications
* Example use cases
* Clear breakdown of the system
* Permission management spec
@wisecameron
Copy link
Author

In progress:

  • string aliasing
  • put implementation

My plan after this upcoming update is to start promoting the ERC more to encourage greater discussion before submitting for the next stage.

* Motivation
* Abstract
* Rationale

-- focused on clarifying exact technical benefits, exploring advantages more deeply - added standardization, interoperability
@wisecameron
Copy link
Author

Current status: setting up a developer group to start encouraging more discussion. I think this concept has a ton of potential but needs to be thoroughly reviewed and optimized because it's a significantly different approach to storage management.

The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY” and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

### Extendable Structs and Storage Spaces
- Extendable structs **MUST** leverage dynamic mappings with deterministic field hashes (`keccak256`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't bold the uppercase keywords. Just leave them uppercase, but otherwise unadorned.

![Adaptability](../assets/erc-7844/Adaptability.svg)

The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY” and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could do with a bit more introductory text before jumping straight into requirements. I'm having a bit of a hard time putting the specification into context (though admittedly I'm not a smart contract developer).

Copy link
Author

Choose a reason for hiding this comment

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

Awesome, yeah considering that a lot of the rationale also needs to be moved, I'll do a significant revision and present the narrative in a more straightforward way. When I initially made this, I was focused too much on the benefits of upgrading storage without re-deployment, when the more fundamental benefit behind all of this is that it's a standardized, holistic approach to storage management in general. Tertiary benefits like in-place upgradeability, standardized access patterns, etc are all within that fundamental basis, but I don't really communicate this in the proposal.

`A`, `B`, `C` hash offset structure not only allows CDS to functionally guarantee safety from collisions, but also aid in debugging by
allowing maintainers to instantly track the high-level objective of complex storage operations.

**Metadata Root:**
Copy link
Contributor

Choose a reason for hiding this comment

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

Re: introductory text, you definitely need some here. You're jumping straight into Yul.

The `init_create` function **MUST** handle storage space creation in both an initialization and live extension setting. The function **MUST** take an array of types and sizes as input, which **MUST** conform to the above specifications, and be equivalent in length when input. Developers **MUST** include length equivalency validation for `types` and `sizes`.

```solidity
function init_create(
Copy link
Contributor

Choose a reason for hiding this comment

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

You should move implementations into the reference implementation section (unless there is exactly one possible implementation). The specification section should define the observable behavior of an implementation, not the internals of how it works.

Comment on lines +397 to +405
Proxy-Delegate and Diamond Storage architectures have long been the industry standard for upgradeable smart contracts, providing critical mechanisms for separating logic from state. These approaches have enabled modular contract upgrades, mitigated contract size limitations, and allowed systems to evolve over time. However, as protocols scale, new challenges emerge—managing storage across multiple contracts, coordinating upgrades, and ensuring compatibility without introducing technical debt or unnecessary redeployments.

CDS builds upon these established patterns by introducing a dedicated, structured storage layer that eliminates many of the complexities inherent in Proxy-Delegate and Diamond architectures. In traditional models, storage modifications require careful slot management, pre-planning reserved fields, or governance-heavy migrations to maintain compatibility. These constraints impose operational overhead and increase the risk of misalignment between logic and storage. CDS removes these limitations by enabling in-place schema evolution, ensuring that storage structures expand deterministically without slot corruption, ABI misalignment, or redundant redeployments.

One of the key improvements CDS introduces is standardized storage access across contracts. Whereas Proxy-Delegate and Diamond models require each contract to define its own storage mappings, CDS provides a shared, structured interface that multiple contracts can access consistently. This reduces cross-contract storage fragmentation, simplifies state synchronization, and eliminates the inefficiencies of multi-hop storage dependencies and redundant mappings.

Furthermore, CDS is designed with long-term system maintainability in mind. As protocols expand, managing state across interdependent contracts becomes increasingly complex. CDS mitigates these risks by externalizing structured storage into a permissioned, extendable layer, ensuring that high-throughput contract interactions remain efficient even as ecosystems grow in scale and complexity.

Proxy-Delegate and Diamond architectures remain valuable for many upgradeable contract designs, offering modularity and logic flexibility. However, for protocols requiring sustainable long-term upgradeability, efficient cross-contract storage, and deterministic schema evolution, CDS provides a more scalable and future-proof alternative. By eliminating migration risks and reducing upgrade complexity, CDS ensures storage integrity, seamless interoperability, and efficient state management—empowering developers to focus on core logic rather than maintenance overhead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost all of this belongs in the Motivation section, because it's justifying the proposal as a whole. The Rationale section is for explaining choices made within the document itself. My favorite analogy is:

Motivation: We need to build a shed because...
Rationale: We chose to paint the shed red because...

@wisecameron
Copy link
Author

@SamWilsn Thank you so much for the thorough review, I sincerely appreciate it and will be sure to implement your recommendations, along with some additional points from the EM discussion.

As an aside, to record where this proposal is, I'm currently building out a lot of external infrastructure (ie; builder's docs, contributor program) around this and HoneyBadger (which is an extended ERC-7844 implementation). So there will likely be some delay as I'm setting all of this up, but this proposal is still very active.

wisecameron and others added 3 commits March 19, 2025 13:16
Co-authored-by: Sam Wilson <[email protected]>
Co-authored-by: Sam Wilson <[email protected]>
Co-authored-by: Sam Wilson <[email protected]>
@github-actions github-actions bot added w-ci and removed w-ci labels Mar 19, 2025
@github-actions github-actions bot added w-ci and removed w-ci labels Apr 11, 2025
Copy link

The commit 9c33747 (as a parent of 93185ba) contains errors.
Please inspect the Run Summary for details.

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

Successfully merging this pull request may close these issues.

5 participants