Add #[slot(raw = KEY)] for binding typed storage fields to fixed external (EIP-1967) slots#114
Add #[slot(raw = KEY)] for binding typed storage fields to fixed external (EIP-1967) slots#114filip-parity wants to merge 1 commit into
Conversation
c876e47 to
5baa149
Compare
Benchmark Size Comparison (vs main)
OK: All artifacts within 5% regression thresholdRun 28874914746 | 65e89f5 | 2026-07-07 15:01 UTC |
5baa149 to
f0e96d7
Compare
re-gius
left a comment
There was a problem hiding this comment.
LGTM
Just add a few fixes to the docs (CLAUDE.md)
get_slot bypasses the view/mut gate (a &self method can fabricate a writable handle without unsafe), so please add it to the "Honest caveat" escape-hatch list at CLAUDE.md:143 alongside raw uAPI and soften the CLAUDE.md:141 claim that #![forbid(unsafe_code)] closes that bypass
|
I think this EIP-1967 implementation belongs at the contracts level, not in the SDK - the same separation Stylus uses. In the Stylus ecosystem, stylus-sdk exposes only the low-level storage primitive (StorageType::new(slot, offset, host)), while the EIP-1967 constants and the StorageSlot helper live in the OpenZeppelin contracts library (rust-contracts-stylus). Probably we should follow the same line: keep only the generic mechanism in the SDK - e.g. a #[slot(raw = …)] attribute (and the underlying StorageComponent::new_at_raw) that lets a contract bind a typed field to a fixed, externally-known slot while preserving the borrow-checker's view-vs-mutating gate. The EIP-1967 constant and any proxy logic then live in an example or a future contracts crate. |
…nal slot (e.g. EIP-1967) while preserving the view/mut gate
f0e96d7 to
e810d53
Compare
|
@smiasojed reworked to follow the Stylus/OZ split you described. One simplification vs your sketch: since |
Thanks, looks good - just one thing: |
|
Please update the docs with this feature |
Closes #105.
Reworked per @smiasojed's review: the SDK now exposes only the generic
mechanism for binding a typed storage field to a fixed, externally-known slot,
and the EIP-1967 constant + proxy logic live in an example - mirroring the
Stylus/OZ separation.