Skip to content

refactor!: make Diamond an abstract fallback-only base#33

Merged
dadadave80 merged 1 commit into
mainfrom
dev
Jul 19, 2026
Merged

refactor!: make Diamond an abstract fallback-only base#33
dadadave80 merged 1 commit into
mainfrom
dev

Conversation

@dadadave80

Copy link
Copy Markdown
Owner

Summary

Restructures the library around a minimal, unopinionated core: Diamond is now an abstract, fallback-only proxy base (mirroring SolidState's DiamondBase architecture). Concrete diamonds decide their own deployment strategy:

  • Direct deploys: apply cuts in the constructor — atomic, nothing to front-run, no initializer slot needed
  • Factory/CREATE2/clone deploys: compose with an initializer guard (see test/mocks/MockDiamond.sol for the reference preset)

Changes

  • Diamond loses initialize and receive(), becomes abstract; plain ETH sends now revert with FunctionDoesNotExist unless the concrete diamond opts in
  • InitializableLib + Initializable stripped from src/ (destined for lattice) and vendored under test/utils/; ContextLib deleted (trivial msg.sender wrapper)
  • Bug fix carried in the vendored copy: preInitializer now returns the possibly-zeroed slot so nested constructor initializers finalize exactly once — the previous by-value split lost the skip signal, double-emitting Initialized and clearing the initializing flag mid-init. Pinned by testNestedConstructorInitializerFinalizesOnce
  • MockDiamond is the initializable preset consumed by the deploy script and all suites; ReinitializableDiamond extends it
  • Dropped deprecated virtual modifiers (solc 0.8.35) and dead library modifiers
  • README, SPECIFICATION, GLOSSARY, DEVELOPER_GUIDE updated for the constructor-based init pattern

Breaking changes

Diamond.initialize, Diamond.receive, InitializableLib, and ContextLib are removed from the library surface.

Testing

  • 92/92 tests pass, including a new nested-constructor-initializer regression test
  • Zero compiler warnings from project code (remaining warnings are forge-std's Vm.sol vs solc 0.8.35)

Diamond no longer ships initialize/receive or the Initializable
machinery; concrete diamonds now apply cuts in their constructor, or
compose Diamond with an initializer guard for factory/CREATE2 deploys.

- strip Initializable/InitializableLib and ContextLib from src/
  (initializables move to lattice); vendor the pair in test/utils
- preInitializer now returns the possibly-zeroed slot so nested
  constructor initializers finalize exactly once (regression test
  added); drop deprecated virtual modifiers and unusable lib modifiers
- make MockDiamond the reference initializable preset (Diamond +
  Initializable + receive) consumed by tests and the deploy script;
  ReinitializableDiamond now extends it
- update README, SPECIFICATION, GLOSSARY, and DEVELOPER_GUIDE for the
  constructor-based initialization pattern

BREAKING CHANGE: Diamond is abstract with no initialize or receive;
InitializableLib and ContextLib are removed from src/.
@dadadave80
dadadave80 merged commit 43e943f into main Jul 19, 2026
2 of 3 checks passed
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.

1 participant