Skip to content

Commit e10cd59

Browse files
committed
feat: update README
1 parent f75b0a6 commit e10cd59

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,28 @@ forge test
1212
```
1313

1414
## Storage layout of `SemVerProxy`
15-
`SemVerProxy` reserves storage slots **0 to 99** for implementation contracts by declaring a fixed-size array that occupies these slots:
16-
```solidity
17-
uint256[100] private __gap; // Reserves slots 0-99 for implementations
18-
```
19-
So, the storage layout of a proxy and an arbitrary implementation contract can be represented as follows:
15+
`SemVerProxy` stores variables in the storage, starting at slot 1000. Therefore, implementation contracts can safely use all storage slots except 1000, 1001, and 1002.
16+
So, the storage layout of the proxy and an arbitrary implementation contract can be represented as follows:
2017
```text
2118
Proxy storage layout:
22-
┌─────────────┐
23-
│ Slot 0-99 │ ← `__gap` placeholder (reserved for implementations)
24-
├─────────────┤
25-
│ Slot 100 │ ← `_latestVersion`
26-
│ Slot 101 │ ← Other state variables
27-
│ ... │
28-
└─────────────┘
19+
┌───────────────┐
20+
│ Slot 0-1000 │ ← empty
21+
├───────────────┤
22+
│ Slot 1000 │ ← `_latestVersion`
23+
│ Slot 1001 │ ← `_releases` mapping
24+
│ Slot 1002 │ ← `_subscribedClients` mapping
25+
│ ... │
26+
└───────────────┘
2927
30-
Implementation storage example:
31-
┌─────────────┐
32-
│ Slot 0 │ ← Implementation's first state variable
33-
│ Slot 1 │ ← Implementation's second state variable
34-
│ ... │
35-
│ Slot 99 │ ← Last available slot for implementation
36-
├─────────────┤
37-
| Slot 100 | ← ⚠️ This will collide with proxy's storage
38-
└─────────────┘
28+
Implementation's storage example:
29+
┌───────────────
30+
│ Slot 0 │ ← Implementation's 1st state variable
31+
│ Slot 1 │ ← Implementation's 2nd state variable
32+
│ ...
33+
│ Slot 999 │ ← Implementation's 998th state variable
34+
├───────────────
35+
| Slot 1000 ← ⚠️ This will collide with proxy's storage
36+
└───────────────
3937
```
4038

4139
## Releases and Versioning
@@ -91,5 +89,5 @@ function unsubscribeFromVersioning() external;
9189
```
9290

9391
## Security Considerations
94-
- Since `SemVerProxy` only reserves slots from 0 to 99, any 100+ slot of the implementation will collide with proxy.
92+
- Storing variables in implementation's storage at slots 1000, 1001, 1002 will collide with the proxy's storage.
9593
- `SemVerProxy` has externally accessable function, therefore there's a possibiliy of function selector clash (i.e., if implementation defines functions that have the same signature as external functions of `SemVerProxy`).

0 commit comments

Comments
 (0)